Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of threads: 1030
Number of posts: 1826

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
8051 calculator in assembly code. Please read (did some work!) Posted by apollonlim88 on 11 Jan 2009 at 6:44 AM
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!
Report
Re: 8051 calculator in assembly code. Please read (did some work!) Posted by Dannielmaire on 1 Feb 2012 at 6:38 AM
did anyone ever reply? im hoping to use this as a final project for my microprocessor class.
Report
Re: 8051 calculator in assembly code. Please read (did some work!) Posted by Dannielmaire on 1 Feb 2012 at 6:41 AM
did anyone ever reply? im hoping to use this as a final project for my microprocessor class.
Report
Re: 8051 calculator in assembly code. Please read (did some work!) Posted by Crono84 on 21 Feb 2012 at 4:07 PM
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 ?!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.