;********************************************************************************************** ;* * ;* LAB3-6.ASM - Assembler Laboratory ZMiTAC * ;* * ;* program that displays characters from the file on the screen * ;* * ;********************************************************************************************** comment % ********************************************* * display bytes from the text file * ********************************************* % .model small .stack 512 .data file db "disp.txt", 0 character db ? handle dw ? .code start: mov ax, seg file mov ds, ax ; open input file mov dx, offset file ; DS:DX - ASCIIZ of filename mov ah, 3Dh ; open file mov al, 0 ; open for reading int 21h ; call DOS function jc open_error ; CF set -> error mov handle, ax ; file handle copy_loop: ; read character mov dx, offset character ; buffer address mov bx, handle ; file handle mov cx, sizeof character ; buffer size mov ah, 3Fh ; read data int 21h jc close_file ; jump on read error cmp ax, 0 jz close_file ; nothing to display ; display character mov ah, 02h mov dl, character int 21h ; write character jmp copy_loop close_file: mov ah, 3Eh ; close input file mov bx, handle int 21h open_error: mov ax, 4C00h ; exit int 21h end start