??? 04/21/07 14:05 Read: times |
#137715 - Thanks (after I tried it LOL) Responding to: ???'s previous message |
I give you +1 because you pointed out what the command that works.
I discovered that movx @Rx,A (where X is 0 or 1) is the best command. I found out that it works when I use it after mov P2,<high byte of address>. This must make me think that somehow or another the contents of P2 are either saved or swapped with another location of memory, because within one machine cycle, there are normally 2 or 3 bytes the system fetches from code rom for each instruction. Here is what I mean. If we look at: mov R0,#0FFh ; My assembler requires a '0' in front of a hex number that starts with a letter. mov P2,#0EEh mov A,#0ABh movx @R0,A According to experimentation, It functions exactly the same as: mov DPTR,#0EEFFh mov A,#0ABh movx @DPTR,A but when I really look at it: mov R0,#0FFh mov P2,#0EEh mov A,#0ABh movx @R0,A In the "mov P2,#0EEh" instruction, the system increments the program counter (I'll call it PC from now on) 3 times and before each increment, it fetches code at the PC's address. Because my code is external to the 8051 micro, P2 and P0 equal to the high byte and the low byte of the PC when code is fetched. so somehow, P2 is automatically saved by the system, just before "mov A,#0ABh" is executed. I'm thinking P2 is stored in a special latch or in an undocumented internal RAM address. Had P2 not have been able to be saved, then movx @Rx,A would be useless, because we couldn't then define the high address bits. |
Topic | Author | Date |
if I could crunch my code... | 01/01/70 00:00 | |
Optimisation | 01/01/70 00:00 | |
the original 8051 is the problem... | 01/01/70 00:00 | |
Duhh! | 01/01/70 00:00 | |
again, I want to "crunch my code" | 01/01/70 00:00 | |
starg with something that works. | 01/01/70 00:00 | |
Did You Look at Movx @R0 ? | 01/01/70 00:00 | |
Thanks (after I tried it LOL) | 01/01/70 00:00 | |
data sheet | 01/01/70 00:00 | |
Hidden P2 Register?![]() | 01/01/70 00:00 | |
Simple,but no simpler | 01/01/70 00:00 | |
Problem? | 01/01/70 00:00 | |
save a few bytes by using JBC | 01/01/70 00:00 | |
an alternative | 01/01/70 00:00 | |
WRONG | 01/01/70 00:00 |