Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Onebit Add/Sub using 8051

Status
Not open for further replies.

lebronic

Junior Member level 1
Joined
Feb 26, 2012
Messages
18
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,283
Activity points
1,369
Onebit Add/Sub using 8051-HELP

Hello Friends:

i'm trying to do one bit simple calc(using 8051 MCU) , which can take two numbers and operator from the Keyboard (save the numbers in RAM)
then do the math

the problem i'm facing , i end up having wrong numbers when reading from RAM .

here's my asm code:
Code:
	ORG	000H
	JMP	MAIN
	ORG	003H
	JMP	INT0

	ORG	100H
	
MAIN:
	MOV	A,#78H
p1:	MOV	P1,#0FFH
	MOV	IE,#10000001B
	CLR	IT0
	MOV	R0,#0
	JMP	$



		
ZERO:	CJNE	R0,#00H,ONE
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI

ONE:	CJNE	R0,#01H,TWO
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI
TWO:
	CJNE	R0,#02H,THREE
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI

THREE:
	CJNE	R0,#03H,FOUR
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI

FOUR:
	CJNE	R0,#04H,FIVE
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI

FIVE:	
	CJNE	R0,#05H,SIX
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI

SIX:	
	CJNE	R0,#06H,SEVEN
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI
	
SEVEN:	
	CJNE	R0,#07H,EIGHT
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI


EIGHT:	CJNE	R0,#08H,NINE
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI


NINE:	CJNE	R0,#09H,AA
	POP	A
	MOV	R1,A
	MOV	A,R0
	MOV	@R1,A
	MOV	P2,R0
	MOV	A,R1
	INC	A
	SETB	EA
	RETI


AA:	CJNE	R0,#0AH,BB
	MOV	R1,78H
	MOV	A,79H
	ADD	A,R1
	MOV	P2,A
	SETB	EA
	RETI

BB:	
	CJNE	R0,#0BH,FINISH
	MOV	R1,78H
	MOV	A,79H
	SUBB	A,R1
	MOV	P2,A
	SETB	EA
	RETI

FINISH:
	RETI



DELAY:
	MOV	R5,#5
DL2:
	MOV	R6,#200
DL1:
	MOV	R7,#249
	DJNZ	R7,$
	DJNZ	R6,DL1
	DJNZ	R5,DL2
	RET



INT0:
	CLR	EA
	PUSH	A
	MOV	A,P1
	ANL	A,#00001111B
	MOV	R0,A
	JMP 	ZERO
	SETB	EA
	RETI



Any help would be appreciated
 
Last edited:

i figured out the problem , and fixed it

my next problem is i want to do serial communication with virtual terminal in proteus

Can someone help me transmit the Result into VT ?!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top