prnstr macro msg
mov ah, 09h
lea dx, msg
int 21h
endm
data segment
msg1 db "Enter string to be printed : $"
msg2 db 0dh, 0ah, "I/O Error or Paper out...$"
msg3 db 0ah, "Printing string...$"
buf db 80
db 0
db 80 dup(' ')
data ends
code segment
assume cs:code, ds:data, es:data
start :
mov ax, data
mov ds, ax
mov es, ax
prnstr msg1
mov ah, 0ah
lea dx, buf
int 21h
mov si, offset buf + 2
mov ch, 00h
mov cl, byte ptr [si-1]
mov dx, 0000h
again :
mov ah, 02h
int 17h
test ah, 00101001b
jz cont
prnstr msg2
jmp again
cont :
mov ah, 00h
mov dx, 0000h
next :
mov ah, 00h
mov al, [si]
int 17h
inc si
loop next
mov ax, 4c00h
int 21h
code ends
end start