Home > other >  O bosses converts assembly language into the C language
O bosses converts assembly language into the C language

Time:11-27

The code is as follows:
ORG 0000 h
SJMP MAIN
ORG 000 bh
LJMP T0_ISR
ORG 0030 h

MAIN: MOV P0, # 3 fh; Initialize the assignment
MOV P1, # 0 FFH
MOV P2, # 3 fh
MOV R0, # 00 h
MOV R1, # 24
MOV DPTR, # TAB

KEY: JB P3.0, $; To determine whether a start button press
ACALL DELAY30MS
JNB P3.0, $
ACALL START
SJMP KEY;

START: MOV TMOD, # 01 h; Start the program
MOV TH0, # 0 d8h
MOV TL0, # 0 efh
SETB ET0
SETB EA
SETB TR0

STOP: JB P3.2, ZTJX; To determine whether a reset button to press
ACALL DELAY30MS
JNB P3.2, $
SJMP MAIN; Reset the program

ZTJX: JB P3.1, XS; To determine whether a pause button press
ACALL DELAY30MS
JNB P3.1, $
ZT: CLR TR0; The K2 press to pause count, switch interrupt
The CLR ET0
The CLR EA
JB P3.1, $; K2 again press the continue time
ACALL DELAY30MS
JNB P3.1, $

JX: SETB ET0; After the second press the pause button to continue time
SETB EA
SETB TR0

XS: MOV A, R1; Display subroutine
MOV, B # 10
DIV AB
MOVC A, @ A + DPTR
MOV P0, A; Display the second ten
MOV A, B
MOVC A, @ A + DPTR
MOV P2, A; Display second bits
CJNE R0, # 100, STOP; 1 s to no time, not to directly turn to the digital tube display
MOV R0, # 00 h; 1 s to time, RO heavy initialise
MOV A, R1; R1 minus 1, digital tube display does not turn to 0, 0, start
The CLR C

SUBB A, # 1
MOV R1, A
JNC STOP; Count not continue to judge pause button and stop button 0
MOV R1, # 24; Count stop counting and close interrupt 0
The CLR ET0
The CLR EA
The CLR TR0
SJMP SND. Jump to the alarm program
SJMP KEY; Jump back to the starting test start button
RET

DEL AY30MS: MOV R6, # 150; Delay subroutine program
AAA: MOV R7, # 100
DJNZ R7, $
DJNZ R6, AAA
RET

T0_ISR: CLR TR0; Interrupt subroutine program

MOV TH0, # 0 d8h
MOV TL0, # 0 efh
INC R0
SEPB TR0
RETI
SND: CLR P1.0; Alarm program subroutine (red leds on it)
MOV R7, # 0 FFH
DL: MOV R6, # 0 FFH
DL1: DJNZ R6, DL1
DJNZ R7, DL
SETB P1.0
RET

TAB: DB 3 fh, 6 h, 5 bh, 4 fh, 66 h, 6 dh, 7 dh, 7 h, 7 fh, 6 fh
END
  • Related