; Interface a numeric keypad to PORT 1 and display the entered decimal digits
; ,1-9, on a 7-segment display connected to PORT 2
org 0x0
Repeat:
mov P1, #0x0FF ;Port 1 is not an input port
mov A, P1 ;the contents of P1 are moved into A
CJNE A, #1, DigitIz2 ;if A=1, then this would mean entered digit was "1"
mov P1, #1 ;this will diplay "1" on 7-segment display
SJMP Repeat ;execution of the program repeats
DigitIz2:
CJNE A, #2, DigitIz3
mov P1, #2
SJMP Repeat
DigitIz3:
CJNE A, #3, DigitIz4
mov P1, #3
SJMP Repeat
DigitIz4:
CJNE A, #4, DigitIz5
mov P1, #4
SJMP Repeat
DigitIz5:
CJNE A, #5, DigitIz6
mov P1, #5
SJMP Repeat
DigitIz6:
CJNE A, #6, DigitIz7
mov P1, #6
SJMP Repeat
DigitIz7:
CJNE A, #7, DigitIz8
mov P1, #7
SJMP Repeat
DigitIz8:
CJNE A, #8, DigitIz9
mov P1, #8
SJMP Repeat
DigitIz9:
CJNE A, #9, DigitIz0 ;here digit "0" stands for an error
mov P1, #9
SJMP Repeat
DigitIz0:
mov P1, #0
SJMP Repeat
end