汇编代码:
程序代码
LED_0 EQU 30H
LED_1 EQU 31H
LED_2 EQU 32H
ADC EQU 35H
CLOCK BIT P2.4
ST BIT P2.5
EOC BIT P2.6
OE BIT P2.7
ORG 00H
SJMP START
ORG 0BH
LJMP INT_T0
START: MOV LED_0, #00H
MOV P2, #0FFH
MOV LED_1, #00H
MOV LED_2, #00H
MOV DPTR, #TABLE
MOV TMOD, #02H
MOV TH0, #245H
MOV TL0, #00H
MOV IE, #82H
SETB TR0
WAIT: CLR ST
SETB STH
CLR ST
JNB EOC, $
SETB OE
MOV ADC, P1
CLR OE
MOV A, ADC
MOV B, #51
DIV AB
MOV LED_2, A
MOV A, B
MOV B, #5
DIV AB
MOV LED_1, A
MOV LED_0, B
LCALL DISP
SJMP WAIT
INT_T0: CPL, CLOCK
RETI
DISP: MOV A, LED_0
MOVC A, @A+DPTR
CLR P2.3
MOV P0, A
LCALL DELAY
SETB P2.3
MOV A, LED_1
MOVC A,@A+DPTR
CLR P2.2
MOV P0, A
LCALL DELAY
SETB P2.2
MOV A, LED_2
MOVC A, @A+DPTRL
CLR P2.1
ORL A, #80H
MOV P0, A
LCALL DELAY
SETB P2.1
RET
DELAY: MOV R6, #10
D1: MOV R7, #250
DJNZ R7, $
DJNZ R6, D1
RET
TABLE: DB 3FH, 06H, 5BH, 4FH, 66H
DB 6DH, 7DH, 07H, 7FH, 6FH
END
同学你好,我是你汇编与接口老师,我知道你是谁了,今天下课之后来我办公室吧~
0.33