A51 MACRO ASSEMBLER DIGITAL_CLOCK__1_ 09/01/2006 16:57:35 PAGE 1
MACRO ASSEMBLER A51 V8.00
OBJECT MODULE PLACED IN Digital Clock (1).OBJ
ASSEMBLER INVOKED BY: E:\Program Files\Keil\C51\BIN\A51.EXE Digital Clock (1).asm SET(SMALL) DEBUG EP
LOC OBJ LINE SOURCE
0030 1 LEDBUF EQU 30H ;显示码缓存区
0040 2 HOUR EQU 40H
0041 3 MINUTE EQU 41H
0042 4 SECOND EQU 42H
0043 5 C100us EQU 43H
2710 6 TICK EQU 10000 ;置中断次数
009C 7 T100us EQU 256-100 ;置定时器初始值
0000 02007D 8 LJMP START ;跳转至主程序
000B 9 ORG 000BH ;定时器0中断入口
000B C0D0 10 T0INT: PUSH PSW ;状态保护
000D C0E0 11 PUSH ACC
000F E544 12 MOV A,C100us+1
0011 7002 13 JNZ GOON ;计数值是否为0
0013 1543 14 DEC C100us
0015 1544 15 GOON: DEC C100us+1
0017 E543 16 MOV A,C100us
0019 4544 17 ORL A,C100us+1
001B 7024 18 JNZ EXIT
001D 754327 19 MOV C100us,#HIGH(TICK) ;重置计数值
0020 754410 20 MOV C100us+1,#LOW(TICK)
0023 0542 21 INC SECOND ;秒值加一
0025 E542 22 MOV A,SECOND
0027 B43C17 23 CJNE A,#60,EXIT ;判断秒值是否为60
002A 754200 24 MOV SECOND,#0 ;秒值为60,则清0
002D 0541 25 INC MINUTE ;分值加一
002F E541 26 MOV A,MINUTE
0031 B43C0D 27 CJNE A,#60,EXIT ;判断分值是否为60
0034 754100 28 MOV MINUTE,#0 ;分值为60,则清0
0037 0540 29 INC HOUR ;小时值加一
0039 E540 30 MOV A,HOUR
003B B41803 31 CJNE A,#24,EXIT ;判断小时值是否为24
003E 754000 32 MOV HOUR,#0 ;小时值为24,则清0
0041 D0E0 33 EXIT: POP ACC
0043 D0D0 34 POP PSW
0045 32 35 RETI
0046 36 DELAY: ;延时子程序
0046 7FFF 37 MOV R7,#0FFH
0048 38 DELAYLOOP:
0048 DFFE 39 DJNZ R7,DELAYLOOP
004A DEFC 40 DJNZ R6,DELAYLOOP
004C 22 41 RET
004D 3F065B4F 42 LEDMAP: DB 3FH,06H,5BH,4FH ;八段数码管显示码
0051 666D7D07 43 DB 66H,6DH,7DH,07H
0055 7F6F777C 44 DB 7FH,6FH,77H,7CH
0059 395E7971 45 DB 39H,5EH,79H,71H
005D 46 DISPLAYLED:
005D 7830 47 MOV R0,#LEDBUF
005F 7906 48 MOV R1,#6 ;共6个八段管
0061 7A7F 49 MOV R2,#01111111B ;位扫描码初值
0063 7400 50 LOOP: MOV A,#0
0065 F580 51 MOV P0,A ;关所有八段管
0067 E6 52 MOV A,@R0
0068 F580 53 MOV P0,A
006A EA 54 MOV A,R2
006B F5B0 55 MOV P3,A ;显示一位八段管
006D 7E01 56 MOV R6,#01H
006F 1146 57 CALL DELAY
0071 EA 58 MOV A,R2 ;显示下一位
A51 MACRO ASSEMBLER DIGITAL_CLOCK__1_ 09/01/2006 16:57:35 PAGE 2
0072 03 59 RR A
0073 FA 60 MOV R2,A
0074 08 61 INC R0
0075 D9EC 62 DJNZ R1,LOOP
0077 22 63 RET
0078 90004D 64 T0LED: MOV DPTR,#LEDMAP ;将字段码转换显示码
007B 93 65 MOVC A,@A+DPTR
007C 22 66 RET
007D 758902 67 START: MOV TMOD,#02H ;定时器工作方式2
0080 758C9C 68 MOV TH0,#T100us ;置定时器初始值
0083 758A9C 69 MOV TL0,#T100us
0086 75A882 70 MOV IE,#10000010B ;EA=1,IT0=1
0089 754000 71 MOV HOUR,#0 ;显示初始值
008C 754100 72 MOV MINUTE,#0
008F 754200 73 MOV SECOND,#0
0092 754327 74 MOV C100us,#HIGH(TICK)
0095 754410 75 MOV C100us+1,#LOW(TICK)
0098 D28C 76 SETB TR0 ;启动定时器0
009A E540 77 MLOOP: MOV A,HOUR ;显示小时值十位
009C 75F00A 78 MOV B,#10
009F 84 79 DIV AB
00A0 1178 80 CALL T0LED
00A2 F530 81 MOV LEDBUF,A ;将十位值送显示码缓存区
00A4 E5F0 82 MOV A,B ;显示小时值个位
00A6 1178 83 CALL T0LED
00A8 4480 84 ORL A,#80H ;显示小数点
00AA F531 85 MOV LEDBUF+1,A ;送显示码缓存区
00AC E541 86 MOV A,MINUTE ;显示分钟值十位
00AE 75F00A 87 MOV B,#10
00B1 84 88 DIV AB
00B2 1178 89 CALL T0LED
00B4 F532 90 MOV LEDBUF+2,A ;将十位值送显示码缓存区
00B6 E5F0 91 MOV A,B ;显示分钟个位值
00B8 1178 92 CALL T0LED
00BA 4480 93 ORL A,#80H ;显示小数点
00BC F533 94 MOV LEDBUF+3,A ;送显示码缓存区
00BE E542 95 MOV A,SECOND
00C0 75F00A 96 MOV B,#10 ;显示秒十位值
00C3 84 97 DIV AB
00C4 1178 98 CALL T0LED
00C6 F534 99 MOV LEDBUF+4,A ;送显示码缓存区
00C8 E5F0 100 MOV A,B
00CA 1178 101 CALL T0LED
00CC F535 102 MOV LEDBUF+5,A
00CE 115D 103 CALL DISPLAYLED ;调用显示子程序
00D0 02009A 104 LJMP MLOOP
105 END
A51 MACRO ASSEMBLER DIGITAL_CLOCK__1_ 09/01/2006 16:57:35 PAGE 3
SYMBOL TABLE LISTING
------ ----- -------
N A M E T Y P E V A L U E ATTRIBUTES
ACC. . . . . . . . D ADDR 00E0H A
B. . . . . . . . . D ADDR 00F0H A
C100US . . . . . . N NUMB 0043H A
DELAY. . . . . . . C ADDR 0046H A
DELAYLOOP. . . . . C ADDR 0048H A
DISPLAYLED . . . . C ADDR 005DH A
EXIT . . . . . . . C ADDR 0041H A
GOON . . . . . . . C ADDR 0015H A
HOUR . . . . . . . N NUMB 0040H A
IE . . . . . . . . D ADDR 00A8H A
LEDBUF . . . . . . N NUMB 0030H A
LEDMAP . . . . . . C ADDR 004DH A
LOOP . . . . . . . C ADDR 0063H A
MINUTE . . . . . . N NUMB 0041H A
MLOOP. . . . . . . C ADDR 009AH A
P0 . . . . . . . . D ADDR 0080H A
P3 . . . . . . . . D ADDR 00B0H A
PSW. . . . . . . . D ADDR 00D0H A
SECOND . . . . . . N NUMB 0042H A
START. . . . . . . C ADDR 007DH A
T0INT. . . . . . . C ADDR 000BH A
T0LED. . . . . . . C ADDR 0078H A
T100US . . . . . . N NUMB 009CH A
TH0. . . . . . . . D ADDR 008CH A
TICK . . . . . . . N NUMB 2710H A
TL0. . . . . . . . D ADDR 008AH A
TMOD . . . . . . . D ADDR 0089H A
TR0. . . . . . . . B ADDR 0088H.4 A
REGISTER BANK(S) USED: 0
ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)