0% found this document useful (0 votes)
14 views4 pages

Program.asm

The document outlines an assembly language program for reading key presses from a keypad and displaying the corresponding keycode. It includes initialization of ports, key press detection logic, and a delay function, along with a lookup table for keycodes. The program continuously checks for key presses and updates the display based on the detected input.

Uploaded by

omarzahran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Program.asm

The document outlines an assembly language program for reading key presses from a keypad and displaying the corresponding keycode. It includes initialization of ports, key press detection logic, and a delay function, along with a lookup table for keycodes. The program continuously checks for key presses and updates the display based on the detected input.

Uploaded by

omarzahran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

DB Keycode, 30H

Org 100
Start: Mov P2, #0FFH ; Port 2 as I/P Port
Setb P3.0, P3.1, P3.3
Again: Mov P1, #00H ; Rows = 0000 0000
Mov A, P2 ; Read columns
ANL A, #0FH ; Mask unused bit
CJNE A,#0FH, Again

;
No Key Pressed:
Mov P1,#00H ; Rows = 0000 0000.
Mov A,P2 ; Read columns
ANL A,#0F ; Mask unused bit
CJNE A,#0FH,New Key Pressed
Acall Display 1
AJMP No Key Pressed

;
New Key Pressed:
Acall Delay 25m
Mov A,P2
ANL A,#0F
CJNE A,#0F,Ok
AJMP No Key Pressed
;

Ok:
Mov P1 ,#(0000 1110)b ;first column activator
Mov A,P2
ANL A,#(0000 1111)b
CJNE A,#(0000 1110)b,R1-C1
Mov keycode,#00
LJMP Display
R1-C1:
CJNE A,#(0000 1101)b,R1-C2
Mov keycode,#01
LJMP Display
R1-C2:
CJNE A,#(0000 1011)b,R1-C3
Mov keycode,#02
1
LJMP Display

R1-C3:
CJNE A,#(0000 0111)b, Row 2
Mov keycode,#03
LJMP Display

Row 2:
Mov P1 ,#(0000 1101)b ;second column activator
Mov A,P2
ANL A,#(0000 1111)b
CJNE A,#(0000 1110)b,R2-C1
Mov keycode,#04
LJMP Display
R2-C1:
CJNE A,#(0000 1101)b,R2-C2
Mov keycode,#05
LJMP Display
R2-C2:
CJNE A,#(0000 1011)b,R2-C3
Mov keycode,#06
LJMP Display
R2-C3:
CJNE A,#(0000 0111)b,Row 3
Mov keycode,#07
LJMP Display
Row 3:
Mov P1 ,#(0000 1011)b ;Third column activator
Mov A,P2
ANL A,#(0000 1111)b
CJNE A,#(0000 1110)b,R3-C1
Mov keycode,#08
LJMP Display
R3-C1:
CJNE A,#(0000 1101)b,R3-C2
Mov keycode,#09
LJMP Display
R3-C2:
CJNE A,#(0000 1011)b,R3-C3
Mov keycode,#0AH
LJMP Display
2
R3-C3:
CJNE A,#(0000 0111)b,Row 4
Mov keycode,#0BH
LJMP Display
Row 4:
Mov P1 ,#(0000 0111)b ;Forth column activator
Mov A,P2
ANL A,#(0000 1111)b
CJNE A,#(0000 1110)b,R4-C1
Mov keycode,#0CH
LJMP Display
R4-C1:
CJNE A,#(0000 1101)b,R4-C2
Mov keycode,#0DH
LJMP Display
R4-C2:
CJNE A,#(0000 1011)b,R4-C3
Mov keycode,#0EH
LJMP Display

R4-C3:
CJNE A,#(0000 0111)b,No Key Pressed
Mov keycode,#0F
LJMP Display
Display:
Mov A,@33H
Mov 34H,A
Mov A,@32H
Mov 33H,A
Mov A,@31H
Mov 32H,A

Mov DPTR,#300H
Mov A,@ keycode
Movc A,@A+ DPTR
Mov 31H,A
Acall Display 1
Ret.

3
LJMP Again
; Delay By 25m

Delay 25m

Mov R2,#100
L2: Mov R3,#125
L1: DJNZ R3,L1
DJNZ R2,L2
Ret.

; look up table

Org 300H

DB 11000000,11111001,10100100,10110000,10011001,10010010,10000010,
11111000,10000000,10010000,10001000,10000011,11000110,10100001,1000011
0.1000110
END
Display 1
CLR P3.0
Mov A,@31H
Mov P0,A
NOP NOP NOP
Setb P3.0
CLR P3.1
Mov A,@32H
Mov P0,A
NOP NOP NOP
Setb P3.1
CLR P3.2
Mov A,@33H
Mov P0,A
NOP NOP NOP
Setb P3.2
CLR P3.3
MovA,@34H
Mov P0,A
NOP NOP NOP
Ret.
4

You might also like