Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

8051 calculator in assembly code. Please read (did some work!)

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:

[code]
$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
;
[/code]

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! :-)

Comments

  • DannielmaireDannielmaire Posts: 2Member
    did anyone ever reply? im hoping to use this as a final project for my microprocessor class.
  • DannielmaireDannielmaire Posts: 2Member
    did anyone ever reply? im hoping to use this as a final project for my microprocessor class.
  • Crono84Crono84 Posts: 6Member
    You can use the EdSim51 Program written in java.
    google it out its free and comes with lots of documentation.
    Your code is good written but tells nothing about how You did the wiring of Your components. So How could anyone tell something about it.
    If You decide to assemble Your board identical to the one simulated You can check the written code on the simulator. It has several possibilities of displaying calculation results I prefer to use the alphanumeric display. It's not that hard to use it and You will avoid writing more code just to display numbers on 7 segmented leds.
    EdSim gives You a keyboard witch is 3x4 but there is no problem to figure out the missing row to work. Check it out and if You need help with it contact me.

    Why use 8k RAM for calculator witch displays only 4 digits xD ?!
Sign In or Register to comment.