¡¡¡¡
¡¡¡¡Àý8.2 PRT_CHAR³ÌÐò
¡¡¡¡
¡¡¡¡TITLE PRT_CHAR-EXAMPLE 8-2£»Print a message by inquiring printer
state
¡¡¡¡data ¡¡segment
¡¡¡¡¡¡¡¡¡¡ mess ¡¡¡¡db 'Printer is normal',0dh,0ah
¡¡¡¡¡¡¡¡ ¡¡count¡¡¡¡equ $-mess
¡¡¡¡data ¡¡ends
¡¡¡¡
¡¡¡¡cseg ¡¡segment
¡¡¡¡main ¡¡proc far
¡¡¡¡¡¡¡¡ ¡¡assume cs:cseg, ds:data
¡¡¡¡start: mov ¡¡si,offset mess ¡¡¡¡; message offset
¡¡¡¡¡¡¡¡¡¡ mov ¡¡cx,count ¡¡¡¡¡¡¡¡¡¡; count of char.
¡¡¡¡next:¡¡mov ¡¡dx,379h ¡¡¡¡¡¡¡¡¡¡ ; state port
¡¡¡¡wait:¡¡in¡¡¡¡al,dx
¡¡¡¡¡¡¡¡¡¡ test¡¡al,80h ¡¡¡¡¡¡¡¡¡¡¡¡; printer busy?
¡¡¡¡¡¡¡¡¡¡ Je¡¡¡¡wait¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ; yes,test again
¡¡¡¡¡¡¡¡¡¡ mov ¡¡al,[si] ¡¡¡¡¡¡¡¡¡¡ ; no,read a char.
¡¡¡¡¡¡¡¡¡¡ mov ¡¡dx,378h ¡¡¡¡¡¡¡¡¡¡ ; data port
¡¡¡¡¡¡¡¡¡¡ out ¡¡dx,al¡¡¡¡¡¡¡¡¡¡¡¡¡¡; putout to data port
¡¡¡¡¡¡¡¡¡¡ mov ¡¡dx,37ah ¡¡¡¡¡¡¡¡¡¡ ; control port
¡¡¡¡¡¡¡¡¡¡ mov ¡¡al,0dh ¡¡¡¡¡¡¡¡¡¡¡¡; control code
¡¡¡¡¡¡¡¡¡¡ out ¡¡dx,al ¡¡¡¡¡¡¡¡¡¡¡¡ ; send a strobe=1
¡¡¡¡¡¡¡¡¡¡ mov ¡¡al,0ch ¡¡¡¡¡¡¡¡¡¡¡¡; control code
¡¡¡¡¡¡¡¡¡¡ out ¡¡dx,al ¡¡¡¡¡¡¡¡¡¡¡¡ ; strobe=0
¡¡¡¡¡¡¡¡¡¡ inc ¡¡si¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ; addr. Of mess increment
¡¡¡¡¡¡¡¡¡¡ loop¡¡next ¡¡¡¡¡¡¡¡¡¡¡¡¡¡; next char.
¡¡¡¡¡¡¡¡¡¡ Mov ¡¡ah,4ch¡¡¡¡¡¡¡¡¡¡¡¡ ; return to DOS
¡¡¡¡¡¡¡¡¡¡ Int¡¡ 21h
¡¡¡¡main ¡¡endp
¡¡¡¡cseg ¡¡ends
¡¡¡¡¡¡¡¡¡¡ end start