微机原理8251串口实验自发自收代码(共3页).doc
精选优质文档-倾情为你奉上8251串口实验 自发自收 CODE SEGMENT ASSUME CS:CODE,DS:CODE,ES:CODE ORG 35C0H ;TX=RX H11: JMP START Z8251 EQU 0FFE1H D8251 EQU 0FFE0H COM_MOD EQU 04EH COM_COM EQU 25H ZXK EQU 0FFDCH ZWK EQU 0FFDDH LED DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H DB 88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,0DEH,0F3H BUF DB ?,?,?,?,?,? START: MOV BX,0400H MOV AL,BX CMP AL,00H JNZ SR0 SR8251: MOV DX,Z8251 MOV AL,COM_MOD OUT DX,AL MOV AL,COM_COM OUT DX,AL MOV AL,01H MOV BX,0400H MOV BX,AL SR0: CALL WP MOV SI,4000H MOV DI,5000H MOV CX,0010H SR1: MOV AH,SI CALL SEND CALL RX MOV DI,AH INC SI INC DI LOOP SR1 SR2: CALL DIS JMP SR2 RX: MOV DX,Z8251 RX1: IN AL,DX TEST AL,02H JZ RX1 MOV DX,D8251 IN AL,DX MOV AH,AL RET ;- WP: MOV BUF,11H MOV BUF+1,10H MOV BUF+2,10H MOV BUF+3,10H MOV BUF+4,10H MOV BUF+5,10H RET ;- SEND: MOV DX,Z8251 W1: IN AL,DX TEST AL,01H JZ W1 MOV DX,D8251 MOV AL,AH OUT DX,AL RET ;- DIS: MOV CL,20H MOV BX,OFFSET BUF DIS1: MOV AL,BX PUSH BX MOV BX,OFFSET LED XLAT POP BX MOV DX,ZXK OUT DX,AL MOV AL,CL MOV DX,ZWK OUT DX,AL PUSH CX MOV CX,0100H DELAY: LOOP $ POP CX CMP CL,01H JZ EXIT INC BX SHR CL,1 JMP DIS1 EXIT: MOV AL,00H MOV DX,ZWK OUT DX,AL RET ;- CODE ENDS END H11 专心-专注-专业