; Interface a numeric keypad to PORT 0 and display the entered decimal digits
; ,1-9, on a 7-segment display connected to PORT 1
org 0x0
Repeat:
mov P1, #11000000B ; "0" is displayed on the display
mov P0, #0x0FF ;Port 0 is now an input port
mov A, P0
KeepChecking:
mov A, P0
cpl A
JZ KeepChecking
cpl A
CJNE A, #11111110B, DigitIz2
mov P1, #11111001B ;this will diplay "1" on 7-segment display
SJMP Repeat ;execution of the program repeats
DigitIz2:
CJNE A, #11111101B, DigitIz3
mov P1, #10100100B
SJMP Repeat
DigitIz3:
CJNE A, #11111011B, DigitIz4
mov P1, #10110000B
SJMP Repeat
DigitIz4:
CJNE A, #11110111B, DigitIz5
mov P1, #10011001B
SJMP Repeat
DigitIz5:
CJNE A, #11101111B, DigitIz6
mov P1, #10010010B
SJMP Repeat
DigitIz6:
CJNE A, #11011111B, DigitIz7
mov P1, #10000010B
SJMP Repeat
DigitIz7:
CJNE A, #10111111B, DigitIz8
mov P1, #11111000B
SJMP Repeat
DigitIz8:
CJNE A, #01111111B, Error
mov P1, #10000000B
SJMP Repeat
Error:
;CJNE A, #, DigitIz0 ;here digit "0" stands for an error
mov P1, #01111111B ;dot will denote error
SJMP Repeat
end