Greetings.
I am trying to make a small software for using a simple 8051 calculator (doing +,-,*,/) using assembly language.
I used for the circuit the followings:
micro phillips 89C668
7-segment decoder (74HCT4511)
4-digit common cathode 7-segment display
Inverting buffer (74HCT240)
decoder (AND & OR GATE)
matrix 4x4 keyboard
What I did so far are the following:
$INCLUDE (REG66X.INC)
ROW0 equ P0.4
ROW1 equ P0.5
ROW2 equ P0.6
ROW3 equ P0.7
KEY equ 30H
org 0
sjmp START
org 40H
START: acall readKey
acall display
sjmp START
readKey: mov P0,#0FFH
MOV KEY, #0FFH
clr ROW0
acall delay
mov A,P0
anl A, #0FH
cjne A, #0FH,firstRow
;
setb ROW0
clr ROW1
acall delay
mov A, P0
anl A, #0FH
cjne A, #0FH,secondRow
setb ROW1
clr ROW2
acall delay
mov A, P0
anl A, #0FH
cjne A, #0FH,thirdRow
setb ROW2
clr ROW3
acall delay
mov A, P0
anl A, #0FH
cjne A, #0FH,fourthRow
ret
firstRow:
cjne A,#14,r1c2
mov KEY, #1
ret
r1c2: cjne A,#13,r1c3
move KEY, #2
ret
r1c3: cjne A,#11,r1c4
mov KEY, #3
ret
r1c4: mov KEY, #'A'
ret
secondRow:
cjne A,#14,r2c2
mov KEY, #4
ret
r2c2: cjne A,#13,r1c3
move KEY, #5
ret
r2c3: cjne A,#11,r1c4
mov KEY, #6
ret
r2c4: mov KEY, #'B'
ret
;
thirdRow:
cjne A,#14,r2c2
mov KEY, #7
ret
r2c2: cjne A,#13,r1c3
move KEY, #8
ret
r2c3: cjne A,#11,r1c4
mov KEY, #9
ret
r2c4: mov KEY, #'C'
ret
;
fourthrow:
cjne A,#14,r2c2
mov KEY, #'*'
ret
r2c2: cjne A,#13,r1c3
move KEY, #0
ret
r2c3: cjne A,#11,r1c4
mov KEY, #'#'
ret
r2c4: mov KEY, #'D'
ret
;
I think, this procedure can read the keyboard when a key is pressed. I don't know if I made any mistakes. So can anyone help me out in how I am going to do this calculator to do the functions?
Is there any book or web so I can study how to do those things?
I also need to make a delay routine.
Thanks for reading and thanks in advance for those that are going to reply,help me out and guide me to finish this one.
Cheers!