这里有个汇编的程序 你可以看看
本程序是用来显示倒计时的程序的
;
;'4'+'1'+HH+LL 表示雨强
;'4'+'2'+HH+LL 表示开度
;'4'+'3'+HH+LL 表示倒计时
L1 BIT P3.4;P3.3
L2 BIT P3.5;P3.2
L3 BIT P3.2;P3.5
L4 BIT P3.3;P3.4
C_485 BIT P3.7
LED1 EQU 30H
LED2 EQU 31H
LED3 EQU 32H
LED4 EQU 33H
LED_CNT EQU 34H
DATA0 EQU 35H
DATA1 EQU 36H
DATA2 EQU 37H
DATA3 EQU 38H
DATA4 EQU 39H
HH EQU 3AH
LL EQU 3BH
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP SCAN
ORG 0023H
LJMP RXT
ORG 0060H
MAIN: MOV SP, #60H
MOV R6, #50H
MOV R0, #20H
MOV A, #00H
STR0: MOV @R0, A
INC R0
NOP
CLR C_485
DJNZ R6,STR0
MOV TMOD, #21H
MOV SCON, #50H
MOV TH1,#0fdh ;9600bit
MOV TL1,#0fdh
MOV TH0,#0EEH ;5ms
MOV TL0,#00H
SETB EA
SETB REN
SETB TR1
SETB ET0
SETB TR0
SETB ES
MOV HH, #01H
MOV LL, #12H
MOV LED1, #00
MOV LED2, #09
MOV LED3, #07
MOV LED4, #08
LL0: ACALL DISP_LED
JMP LL0
;显示数码管子程序
DISP_LED:
MOV A, HH
ANL A, #0F0H
SWAP A
MOV LED1, A
MOV A, HH
ANL A, #0FH
MOV LED2, A
MOV A, LL
ANL A, #0F0H
SWAP A
MOV LED3, A
MOV A, LL
ANL A, #0FH
MOV LED4, A
CLR L1
CLR L2
CLR L3
CLR L4
MOV A, LED1
MOV DPTR, #LED_CODE
MOVC A, @A+DPTR
MOV P1, A
SETB L1
NOP
CLR L1
MOV A, LED2
MOV DPTR, #LED_CODE
MOVC A, @A+DPTR
MOV P1, A
SETB L2
NOP
CLR L2
MOV A, LED3
MOV DPTR, #LED_CODE
MOVC A, @A+DPTR
MOV P1, A
SETB L3
NOP
CLR L3
MOV A, LED4
MOV DPTR, #LED_CODE
MOVC A, @A+DPTR
MOV P1, A
SETB L4
NOP
CLR L4
RET
;定时中断
SCAN: PUSH ACC
PUSH PSW
SCAN2: POP PSW
POP ACC
RETI
;串口中断
RXT: PUSH ACC
PUSH PSW
JNB RI,RXT_END
CLR RI
MOV DATA0,DATA1
MOV DATA1,DATA2
MOV DATA2,DATA3
MOV DATA3,DATA4
MOV DATA4,SBUF
MOV A, DATA0
CJNE A, #34H, RXT_END ;'4'
MOV A, DATA1
CJNE A, #33H, RXT_END ;'3'
MOV HH, DATA3
MOV LL, DATA4
RXT_END:POP PSW
POP ACC
RETI
LED_CODE:DB 0FCH,0A0H,0DBH,0F2H,0A7H,76H,7EH,0E0H,0FEH,0F6H,0FCH
END |