Assemply Program On Atm89C51

Status
Not open for further replies.

IronMan2010

New Member
I wrote this Program To Count Fro 0 to 9 On 7-seg

ORG 0H
MOV A, #0H
MOV P2, A
ACALL DELAY
main : INC A
MOV P2, A
ACALL DELAY
CJNE A, #9H, main
MOV R4, #2
DELAY : MOV R3, #220
HERE : NOP
NOP
NOP
NOP
NOP
DJNZ R3, HERE
DJNZ R4, DELAY
RET
END

I will connect BCD To 7-seg to pins 0 : 3 .. It works Fine but i dont know why it stops and freeze on ZERO after counting twice from 0 to 9 ??? Offcourse this on simulation program Protus ,, i didnt made it practically yet >>>> can sm 1 tell me why it freez after Counting twice from 0 to 9 ?>??
 
Because you are not resetting 'A' to zero on the second pass you never get back to 9

Code:
	ORG 0H
	MOV A, #0H
	MOV P2, A
	ACALL DELAY
main :	
	MOV P2, A
        INC A
	ACALL DELAY
	CJNE A, #0AH, main
	MOV A, #0H		; reset a
	JMP main

DELAY :	MOV R4, #0
DLY   : MOV R3, #220
HERE  : NOP
	NOP
	NOP
	NOP
	NOP
	DJNZ R3, HERE
	DJNZ R4, DLY
	RET
END

Cheers Ian
 
Last edited:
Are you sure! I've just tried it in proteus and its working!!

Cheers Ian
 
There is no instuction called ''GOTO''' in assemply ,, Keil gives me error , so i deleted it and it gave the same result
 
Yes! sorry about that! it's" JMP main " not goto (pic on the brain ) Another thing.. if you want '0' place the INC A after writing to port 2. the delay needs to be a bit slower as well start with R4 = 0.

cheers Ian

P.S. I edited the code again
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…