DATA SEGMENT ;定义内存100个字节
BUFFER DB 100 DUP(?)
DATA ENDS
;
STACK SEGMENT ;堆栈段定义
DB 100 DUP(?)
STACK ENDS
;
CODE SEGMENT
ASSUME DS:DATA,ES:DATA,SS:STACK,CS:CODE
RECEIVE PROC FAR ;定义一个过程调用,FAR
BEGIN: PUSH CX
PUCH DI
PUSH DX
PUSH AX ;保护该子程式中用到的寄存器
MOV CL,100 ;100个字节数据
LEA DI,BUFFER ;DI指向BUFFER
MOV DX,201H ;DX中装入状态端口地址
L1: IN AL,DX
AND AL,80H ;检测状态口数据的第七位是否为1
JZ L1
MOV DX,200H ;准备好后,DX装入数据端口
L2: IN AL,DX
MOV [DI],AL ;将数据端口的数给内存
INC DI ;指向内存下一个字节
DEC CX
JNZ L2 ;数是否传完
POP AX
POP DX
POP DI
POP CX ;恢复保护的寄存器
RET
RECEIVE ENDP
CODE ENDS
END BEGIN
LEA AL,200H
LEA BL,201H
LEA BP,200H
MOV CL,100
AND [BL],80H
JNE LOOP
JMP END
LOOP: IN DL,[BP]
MOV ADDR,DL
INC BP
JNE LOOP
END