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.

Help me compare two register values in 89C51

Status
Not open for further replies.

vijaya_narayana

Full Member level 3
Joined
Jun 12, 2007
Messages
178
Helped
11
Reputation
22
Reaction score
1
Trophy points
1,298
Location
India
Activity points
2,182
guys i need your help i need to compare two register values and if it is equal the code must proceed to next sequence for this
i tried the following statement it gives error

CJNE A,R1,NEXT

is there any alternaste for this the data stored in a will be a floating value it is not a fixed value

the controller is 89c51
 

Re: help on 8051

First of all, you can't compare A and R1, but you can compare A with "location" 01h (which in fact is the address of R1) ..
Second, the result (equal) of the CJNE instruction is just "below" it, so:

CJNE A, 01h, Not_Equal
LJMP NEXT ; Here A is equal to 01h(R1) ..

Not_Equal: .. here you will continue if A is not equal to 01h(R1) ..

Regards,
IanP
 
Re: help on 8051

IanP said:
First of all, you can't compare A and R1, but you can compare A with "location" 01h (which in fact is the address of R1) ..
... but of course only if register bank 0 is active (which is the default case)...

Sounds like hairsplitting, but may save some problem hunting later if the OP decides to implement bank switching. The proper way to assign the absolute address in some of the assemblers is to use the builtin AR0..AR7 symbols together with the USING directive.

If bank-independent solution is needed, there are two options: either to move Ri to a direct-addressed location before the compare (often, B is used for this task; but any other location suffices); or, if content of A (and C) may be destroyed, use subb (or xrl, if only equality test is required).

JW
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top