A51 MACRO ASSEMBLER 4X4_KEYBOARD__1_ 07/27/2006 17:22:43 PAGE 1
MACRO ASSEMBLER A51 V8.00
OBJECT MODULE PLACED IN 4X4 KeyBoard (1).OBJ
ASSEMBLER INVOKED BY: e:\Program Files\Keil\C51\BIN\A51.EXE 4X4 KeyBoard (1).asm SET(SMALL) DEBUG EP
LOC OBJ LINE SOURCE
0030 1 DBUF EQU 30H
0040 2 TEMP EQU 40H
0000 3 ORG 00H
0000 7410 4 MOV A,#16
0002 1154 5 MAIN: ACALL DISP
0004 1108 6 ACALL KEY1
0006 0102 7 AJMP MAIN
0008 7590F0 8 KEY1: MOV P1,#0F0H ;读P1口前先写1
000B E590 9 MOV A,P1 ;读取键状态
000D B4F002 10 CJNE A,#0F0H,K11 ;判断是否有键按下
0010 0108 11 K10: AJMP KEY1
0012 1181 12 K11: ACALL DELAY
0014 7590F0 13 MOV P1,#0F0H
0017 E590 14 MOV A,P1
0019 B5F002 15 CJNE A,0F0H,K12 ;消除按键抖动
001C 80F2 16 SJMP K10
001E F5F0 17 K12: MOV B,A ;存列值
0020 75900F 18 MOV P1,#0FH
0023 E590 19 MOV A,P1 ;读行值
0025 55F0 20 ANL A,B
0027 F5F0 21 MOV B,A ;存键码
0029 7910 22 MOV R1,#10H
002B 7A00 23 MOV R2,#0
002D 900044 24 MOV DPTR,#K1TAB ;键码表首地址
0030 EA 25 K14: MOV A,R2
0031 93 26 MOVC A,@A+DPTR
0032 B5F00A 27 CJNE A,B,K16 ;比较,计算键值
0035 75900F 28 MOV P1,#0FH
0038 E590 29 K15: MOV A,P1
003A B40FFB 30 CJNE A,#0FH,K15 ;等待按键释放
003D EA 31 MOV A,R2
003E 22 32 RET
003F 0A 33 K16: INC R2
0040 D9EE 34 DJNZ R1,K14
0042 0110 35 AJMP K10
0044 81412111 36 K1TAB: DB 81H,41H,21H,11H ;键码表
0048 82422212 37 DB 82H,42H,22H,12H
004C 84442414 38 DB 84H,44H,24H,14H
0050 88482818 39 DB 88H,48H,28H,18H
0054 F530 40 DISP: MOV DBUF,A ;键值存入缓存
0056 7830 41 MOV R0,#DBUF
0058 7940 42 MOV R1,#TEMP
005A 90006F 43 DP10: MOV DPTR,#SEGTAB
005D E6 44 MOV A,@R0
005E 93 45 MOVC A,@A+DPTR ;根据键值查表取段码
005F F7 46 MOV @R1,A ;暂存段码
0060 7840 47 MOV R0,#TEMP
0062 7A08 48 DP12: MOV R2,#8 ;设置移位次数
0064 E6 49 MOV A,@R0
0065 33 50 DP13: RLC A ;段码移位输出
0066 92B0 51 MOV P3.0,C
0068 C2B1 52 CLR P3.1
006A D2B1 53 SETB P3.1 ;输出移位脉冲
006C DAF7 54 DJNZ R2,DP13
006E 22 55 RET
006F 3F065B4F 56 SEGTAB: DB 3FH,06H,5BH,4FH,66H,6DH
0073 666D
0075 7D077F6F 57 DB 7DH,07H,7FH,6FH,77H,7CH
A51 MACRO ASSEMBLER 4X4_KEYBOARD__1_ 07/27/2006 17:22:43 PAGE 2
0079 777C
007B 585E7971 58 DB 58H,5EH,79H,71H,00H,40H
007F 0040
0081 7C01 59 DELAY: MOV R4,#01H
0083 7D88 60 AA1: MOV R5,#088H
0085 00 61 AA: NOP
0086 DDFD 62 DJNZ R5,AA
0088 DCF9 63 DJNZ R4,AA1
008A 22 64 RET
65 END
A51 MACRO ASSEMBLER 4X4_KEYBOARD__1_ 07/27/2006 17:22:43 PAGE 3
SYMBOL TABLE LISTING
------ ----- -------
N A M E T Y P E V A L U E ATTRIBUTES
AA . . . . . . . . C ADDR 0085H A
AA1. . . . . . . . C ADDR 0083H A
B. . . . . . . . . D ADDR 00F0H A
DBUF . . . . . . . N NUMB 0030H A
DELAY. . . . . . . C ADDR 0081H A
DISP . . . . . . . C ADDR 0054H A
DP10 . . . . . . . C ADDR 005AH A
DP12 . . . . . . . C ADDR 0062H A
DP13 . . . . . . . C ADDR 0065H A
K10. . . . . . . . C ADDR 0010H A
K11. . . . . . . . C ADDR 0012H A
K12. . . . . . . . C ADDR 001EH A
K14. . . . . . . . C ADDR 0030H A
K15. . . . . . . . C ADDR 0038H A
K16. . . . . . . . C ADDR 003FH A
K1TAB. . . . . . . C ADDR 0044H A
KEY1 . . . . . . . C ADDR 0008H A
MAIN . . . . . . . C ADDR 0002H A
P1 . . . . . . . . D ADDR 0090H A
P3 . . . . . . . . D ADDR 00B0H A
SEGTAB . . . . . . C ADDR 006FH A
TEMP . . . . . . . N NUMB 0040H A
REGISTER BANK(S) USED: 0
ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)