Content Entry

[串行通信8051/8253]微机原理实验14

  2004-11-30   School   8051 8253 Serial Communication
IOPORT EQU 0DC00H-280H C53 EQU IOPORT+283H T53 EQU IOPORT+280H C51 EQU IOPORT+2B9H D51 EQU IOPORT+2B8H DATA SEGMENT RUN DB 'INPUT:',0DH,0AH,'$' ERR DB 'ERROR!',0DH,0AH,'$' OVE DB 'OVER!',0DH,0AH,'$' DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX INIT8253: MOV DX,C53 MOV AL,17H OUT DX,AL MOV DX,T53 MOV AL,52H OUT DX,AL INIT8251: MOV DX,C51 MOV AL,0 OUT DX,AL CALL REVTIME OUT DX,AL CALL REVTIME OUT DX,AL CALL REVTIME MOV AL,40H OUT DX,AL CALL REVTIME MOV AL,7eh OUT DX,AL CALL REVTIME MOV AL,15h OUT DX,AL PRINT: LEA DX,RUN MOV AH,09H INT 21H SEND: MOV DX,C51 IN AL,DX TEST AL,01H JZ SEND MOV AH,01H INT 21H CMP AL,1BH JZ QUIT INC AL MOV DX,D51 OUT DX,AL RECEIVE: MOV DX,C51 IN AL,DX TEST AL,02h JZ RECEIVE TEST AL,38h JNZ ERROR MOV DX,D51 IN AL,DX MOV DL,AL MOV AH,02H INT 21H JMP SEND ERROR: LEA DX,ERR MOV AH,09H INT 21H REVTIME: PUSH CX MOV CX,2 D0: LOOP D0 POP CX RET QUIT: LEA DX,OVE MOV AH,09H INT 21H MOV AH,4CH INT 21H CODE ENDS END START
comments loading