??? 07/09/07 10:08 Read: times |
#141600 - data, registers, acc, and existing instructions Responding to: ???'s previous message |
Nimish Dave said:
CJNE data address,data address,code addr. eg CJNE R6,36H,JUMP1 First, R6 is not a data address, it's a register. The '51 has a rather peculiar notion of registers - general Ri and the accumulator. Think of Ri and A not as operands of an instruction, rather, as a part of the instruction. FOr example, think of mov Ri, data as an instruction mov Ri, operand where operand is in this case direct data, and not as mov operand1, operand2 where operand1 would be Ri. Similarly with A. The peculiarity of '51 is, that you still can access the same physical memory locations containing Ri and A using direct data addresses (with the added twist of register banks when accessing Ri); and that that is the only way how to access them for certain instructions, such as push and pop. I am writing all this to highlight your mistake when you said, you want cjne data1, data2, address and as an example you used data1=R6. That does not work. The only cjne instructions you have available are: cjne A, data, address cjne A, #constant, address cjne Ri, #constant, address cjne @Rn, #constant, address. So, if you want to compare two variables data1 and data2, the only way is to use accumulator: mov A,data1 cjne A, data2, address If you want to compare to a constant, you either use accumulator: mov A, data cjne A, #constant, address or Ri: mov Ri, data cjne Ri, #constant, address or Rn: mov @Rn, #data cjne @Rn, #constant, address (throughout this description, i=0..7, n=0..1). In some applications, you might also consider using subb (caution, you need to clear carry before using it); or if you want only know if two data are the same, you can also use xrl (and this has also form of xrl data, #constant). All of this is "biblic" stuff, but I can imagine a newbie can be easily confused by this. JW |
Topic | Author | Date |
CJNE modification | 01/01/70 00:00 | |
data, registers, acc, and existing instructions | 01/01/70 00:00 | |
a minor correction | 01/01/70 00:00 | |
blame on me! | 01/01/70 00:00 | |
Solution | 01/01/70 00:00 | |
huh? | 01/01/70 00:00 | |
I do not like that | 01/01/70 00:00 | |
Many mistakes![]() | 01/01/70 00:00 |