count equ 9217 ; define 1s count value, for 11.0592 crystal oscillator, delay 10ms
second equ 30h ; define temporary variable area
second_ge equal 31h
second_shi equal 32h
minute equ 33h
minute_ge equal 34h
minute_time 35h
hour equal 36h
hour_ge equal 37h
hour_shi equal 38h
org 0000h
sjmp main ; enter the main program
org 0003h
reti
org 000bh ;time0 (timer/counter T0 entry address)
ljmp int_time0 ; jump to interrupt 0 service routine
org001bh
reti
org 0023h
reti
main:
mov r0,#0 ; Initialize the program (the initial value of this program is set to 13:33:22)
mov second,#22
mov second_ge,#0
mov second_shi,#0
mov minute,#33
mov minute_ge,#0
mov minute_shi,#0
mov hour,#13
mov hour_ge,#0
mov hour_shi,#0
mov tmod,#00000001b
mov th0,#high(65536-count); get the high eight bits of data
mov tl0,#low(65536-count); get the bottom five bits
clr tf0
setbea
setb et0
setb tr0 ; start timing
loop:
lcall digitor_display ;Call the digital tube scanning display program
sjmp loop ; The program loops here
;Timer 0 interrupt
int_time0:
push acc
push psw
clr tf0
mov th0,#high(65536-count); get the high eight bits of data
mov tl0,#low(65536-count); get the bottom five bits
inc r0
cjne r0,#100,ret_loop ;The second value increases by one
sjmp second_add
second_add: ; Second value processing
mov r0,#0
inc second
mov a,second
cjne a,#60, ret_loop
sjmp minute_add
minute_add: ; minute value processing
mov second,#0
inc minute
move a,minute
cjne a,#60, ret_loop
sjmp hour_add
hour_add: ; Hour processing
mov minute,#0
inc hour
move a,hour
cjne a,#24,ret_loop
sjmp hour_reset
hour_reset:
mov hour,#0
ret_loop:
pop psw
pop acc
reti ;Interrupt return
digitor_display: ;digital tube scanning
push acc
push psw
mov a,second
mov b,#10
div ab
mov second_shi,a
mov second_ge,b
move a,minute
mov b,#10
div ab
mov minute_shi,a
mov minute_ge,b
move a,hour
mov b,#10
div ab
mov hour_shi,a
mov hour_ge,b
mov p1,#11011111b ; Display the units of seconds
mov a,second_ge
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
mov p1,#11101111b ; Display the tens digit of seconds
mov a,second_shi
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
mov p1,#11110111b ; Display the units of minutes
mov a,minute_ge
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
mov p1,#11111011b ; Display the tens digit of minutes
mov a,minute_shi
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
mov p1,#11111101b ; Display the unit digit of the hour
mov a,hour_ge
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
mov p1,#11111110b ; Display the tens place of the hour
mov a,hour_shi
mov dptr,#table
movc a,@a+dptr
mov p2,a
lcall delay
pop psw
pop acc
ret ; Scanning program returns
table: ; Common cathode digital tube scanning code
DB 3FH ;0
DB 06H ;1
DB 5BH ;2
DB 4FH ;3
DB 66H ;4
DB 6DH ;5
DB 7DH ;6
DB 27H ;7
DB 7FH ;8
DB 6FH ;9
delay: mov r4,#5 ; delay function (delay is about 5*255*2=25ms)
l1: mov r5,#0ffh
l2: djnz r5,$
djnz r4,l1
ret
end
Previous article:Implementation of ASM51 calling C51 function
Next article:Assembly bubble sort (51) (need debugger to pay initial value)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- micropython update: 2020.2
- TI's latest generation ACF Controller UCC28782 helps miniaturize adapters
- The difference between high frequency capacitors and ceramic capacitors
- Today's broadcast starts at 10:00: Introduction to Littelfuse's SiC MOSFET and Schottky diode products and related applications
- [Me and Arty 2] AT32 transplant threadX and its awesome component GUIX
- TI official website cannot be accessed! ? ?
- Everyone, is it harder to be a hardware engineer or a software engineer?
- Discussion: Can the COVID-19 pandemic help companies related to 5G and wifi6 technology? Get 5-20 Chip Points!
- How to use arrays in C language for microcontrollers
- [GD32L233C-START Review] 17. CMSIS-RTOS2 RTX5 ported to GD32L233 (kernel, multithreading)