| ??? 08/14/08 20:44 Read: times |
#157492 - cjne Responding to: ???'s previous message |
You can do only CJNE A, direct, displacement.
R0, R1 etc. are NOT memory addresses. Rather, you should look at them as part of an instruction - e.g. MOV R0, #55 is NOT "[move] [to address R0] [number 55]", but, rather, "[move to R0] [number 55]". And, there is no CJNE A, Rn, displacement. Further, the "registers" in '51 are implemented in the - directly accessible - internal RAM. However, there are 4 baks of registers, depending on the RB0 and RB1 bits in SFR. So, you cannot simply tell, R0 is the same as direct address 00. However, you can assume this if you are absolutely sure that when executing this particular instruction, register bank 0 will be ALWAYS selected (e.g. when you NEVER touch RB0 and RB2 throughout the whole program, or if you change it only in an interrupt service routine and the restore before the reti, usually by POP PSW - both these cases are quite typical in smaller '51 programs). This leads to CJNE A, 00h, displacement, if you want to compare A to R0. A somewhat better option for the same is to use the AR0, AR1, ... "pseudo-direct" symbols, together with the "USING" directive, but all this is slightly advanced stuff. And, finally, the SAFEST option is to move the content of register to be compared into a direct addressable memory or SFR byte, and perform CJNE A, direct, displacement on that byte. This all is "biblical" stuff and you should really read the "bible" thoroughly; but I know how this might be confusing for the newbie. The '51 is really quite a weird architecture... JW |
| Topic | Author | Date |
| cjne w/ 2 registers? | 01/01/70 00:00 | |
| think i found it | 01/01/70 00:00 | |
| cjne | 01/01/70 00:00 | |
| there is nothing particularly weird about 805x | 01/01/70 00:00 | |
| I ran this through the simulator ... | 01/01/70 00:00 | |
| Looking at the code... | 01/01/70 00:00 | |
| SUBB and carry | 01/01/70 00:00 | |
Thank You | 01/01/70 00:00 |



