📄 keypad.lst
字号:
MPASM 03.00 Released KEYPAD.ASM 8-28-2005 20:25:49 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00002 ;
00003 ; KEYPAD.ASM MPB Ver 1.0 28-8-05
00004 ;
00005 ; Reads keypad and shows digit on display
00006 ; Design file KEYPAD.DSN
00007 ;
00008 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00009
00010 PROCESSOR 16F877
00011
00000002 00012 PCL EQU 002 ; Program Counter
00000007 00013 PORTC EQU 007 ; 7-Segment display
00000008 00014 PORTD EQU 008 ; 3x4 keypad
00015
00000087 00016 TRISC EQU 087 ; Data direction
00000088 00017 TRISD EQU 088 ; registers
00018
00000020 00019 Key EQU 020 ; Count of keys
00020
00021 ; Initialise ports.........................................
00022
0000 1683 1303 00023 BANKSEL TRISC ; Display
0002 0103 00024 CLRW ; all outputs
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0003 0087 00025 MOVWF TRISC ;
0004 3007 00026 MOVLW B'00000111' ; Keypad
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0005 0088 00027 MOVWF TRISD ; bidirectional
00028
0006 1283 1303 00029 BANKSEL PORTC ; Display off
0008 0187 00030 CLRF PORTC ; initially
0009 2830 00031 GOTO main ; jump to main
00032
00033 ; Check a row of keys .....................................
00034
Message[305]: Using default destination of 1 (file).
000A 0AA0 00035 row INCF Key ; Count first key
000B 1C08 00036 BTFSS PORTD,0 ; Check key
000C 281D 00037 GOTO found ; and quit if on
00038
Message[305]: Using default destination of 1 (file).
000D 0AA0 00039 INCF Key ; and repeat
000E 1C88 00040 BTFSS PORTD,1 ; for second
000F 281D 00041 GOTO found ; key
00042
Message[305]: Using default destination of 1 (file).
0010 0AA0 00043 INCF Key ; and repeat
0011 1D08 00044 BTFSS PORTD,2 ; for third
0012 281D 00045 GOTO found ; key
0013 2818 00046 GOTO next ; go for next row
00047
00048 ; Scan the keypad..........................................
MPASM 03.00 Released KEYPAD.ASM 8-28-2005 20:25:49 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00049
0014 01A0 00050 scan CLRF Key ; Zero key count
0015 1403 00051 BSF 3,0 ; Set Carry Flag
0016 1208 00052 BCF PORTD,4 ; Select first row
0017 280A 00053 newrow GOTO row ; check row
00054
0018 1588 00055 next BSF PORTD,3 ; Set fill bit
Message[305]: Using default destination of 1 (file).
0019 0D88 00056 RLF PORTD ; Select next row
001A 1803 00057 BTFSC 3,0 ; 0 into carry flag?
001B 2817 00058 GOTO newrow ; if not, next row
001C 2814 00059 GOTO scan ; if so, start again
00060
001D 0008 00061 found RETURN ; quit with key count
00062
00063 ; Display code table.......................................
00064
001E 0820 00065 table MOVF Key,W ; Get key count
Message[305]: Using default destination of 1 (file).
001F 0782 00066 ADDWF PCL ; and calculate jump
0020 0000 00067 NOP ; into table
0021 340C 00068 RETLW B'00001100' ; Code for '1'
0022 34B6 00069 RETLW B'10110110' ; Code for '2'
0023 349E 00070 RETLW B'10011110' ; Code for '3'
0024 34CC 00071 RETLW B'11001100' ; Code for '4'
0025 34DA 00072 RETLW B'11011010' ; Code for '5'
0026 34F8 00073 RETLW B'11111000' ; Code for '6'
0027 340E 00074 RETLW B'00001110' ; Code for '7'
0028 34FE 00075 RETLW B'11111110' ; Code for '8'
0029 34CE 00076 RETLW B'11001110' ; Code for '9'
002A 3492 00077 RETLW B'10010010' ; Code for '*'
002B 347E 00078 RETLW B'01111110' ; Code for '0'
002C 34EC 00079 RETLW B'11101100' ; Code for '#'
00080
00081 ; Output display code......................................
00082
002D 201E 00083 show CALL table ; Get display code
002E 0087 00084 MOVWF PORTC ; and show it
002F 0008 00085 RETURN
00086
00087 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00088
00089 ; Read keypad & display....
00090
0030 30FF 00091 main MOVLW 0FF ; Set all outputs
0031 0088 00092 MOVWF PORTD ; to keypad high
0032 2014 00093 CALL scan ; Get key number
0033 202D 00094 CALL show ; and dsiplay it
0034 2830 00095 GOTO main ; and repeat
00096 END
MPASM 03.00 Released KEYPAD.ASM 8-28-2005 20:25:49 PAGE 3
SYMBOL TABLE
LABEL VALUE
Key 00000020
PCL 00000002
PORTC 00000007
PORTD 00000008
TRISC 00000087
TRISD 00000088
__16F877 00000001
found 0000001D
main 00000030
newrow 00000017
next 00000018
row 0000000A
scan 00000014
show 0000002D
table 0000001E
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXX-----------
All other memory blocks unused.
Program Memory Words Used: 53
Program Memory Words Free: 8139
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 7 reported, 0 suppressed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -