??? 12/21/05 15:48 Modified: 12/21/05 15:50 Read: times |
#105669 - it DOES NOT write to R0 Responding to: ???'s previous message |
George,
It does not write into R0 in the loop. Let's hand-simulate what happens: R0 gets filled by 7Fh and it starts to write 0 into RAM addressed by R0 and decrement R0. Now let's start our "simulation" at the moment when R0 contains 2: mov @r0,#0 ;moves 0 into address 02, which is R2 in bank 0 djnz r0,Loop ;r0 gets decremented, so it contains 01, ; which is nonzero, so it loops back mov @r0,#0 ;moves 0 into address 01, which is R1 in bank 0 djnz r0,Loop ;r0 gets decremented, so it contains 00, ; which is zero, so it does not loop back ; but it continues - loop exitsSo R0 is at the end of the loop 0, but it has not been written to in the loop. If the constant would be different, e.g. mov @r0,#55h, at the end of the loop the whole RAM in the addresses 01-7F would be filled by 55h, but R0 would contain 00. You can see it in a different way, the loop counter is R0 and it starts with 7Fh, and as it is the pointer at the same time, it fills 7Fh=127 bytes starting at 7Fh downwards, so it does not fill the whole 128 bytes which would be 00h-7Fh, it fills one less -> 01h-7Fh. Actually, if it would write 0 into R0 inside the loop (through some other mechanism), it would stay in the loop forever, as after djnz R0 would be FFh which is nonzero so it would keep looping. I understand this kind of "blindness" - I suffer from it too... Jan Waclawek |
Topic | Author | Date |
this code is not working | 01/01/70 00:00 | |
You solved it! | 01/01/70 00:00 | |
overreaction | 01/01/70 00:00 | |
Humility ? | 01/01/70 00:00 | |
Call it cultural difference... | 01/01/70 00:00 | |
Sounds familiar | 01/01/70 00:00 | |
thanks Jan Waclawek | 01/01/70 00:00 | |
Keil's startup.a51 | 01/01/70 00:00 | |
hex seems OK | 01/01/70 00:00 | |
re hex seems OK | 01/01/70 00:00 | |
And the switch? | 01/01/70 00:00 | |
and switch | 01/01/70 00:00 | |
Try a pull-up | 01/01/70 00:00 | |
switch function | 01/01/70 00:00 | |
Not at all | 01/01/70 00:00 | |
reset cap | 01/01/70 00:00 | |
yeah | 01/01/70 00:00 | |
It can! | 01/01/70 00:00 | |
points | 01/01/70 00:00 | |
Some suggestions | 01/01/70 00:00 | |
nope | 01/01/70 00:00 | |
Use LEDs | 01/01/70 00:00 | |
ok let me follow | 01/01/70 00:00 | |
That sounds good ! | 01/01/70 00:00 | |
try this code | 01/01/70 00:00 | |
and what good will that do?![]() | 01/01/70 00:00 | |
How? | 01/01/70 00:00 | |
capital | 01/01/70 00:00 | |
Thanks! | 01/01/70 00:00 | |
I did the same thing recently | 01/01/70 00:00 | |
At least... | 01/01/70 00:00 | |
HORSEFEATHERS | 01/01/70 00:00 | |
i think yopu didn't got the message | 01/01/70 00:00 | |
of course it is not | 01/01/70 00:00 | |
It's easy to fix the code | 01/01/70 00:00 | |
no, he does not | 01/01/70 00:00 | |
wrong suggestion | 01/01/70 00:00 | |
it DOES NOT write to R0 | 01/01/70 00:00 | |
RE: it DOES NOT write to R0 | 01/01/70 00:00 | |
why the continued discussion | 01/01/70 00:00 | |
Time zone | 01/01/70 00:00 | |
just another guess | 01/01/70 00:00 | |
She is most likely from India | 01/01/70 00:00 | |
Irony | 01/01/70 00:00 | |
Help me | 01/01/70 00:00 | |
re help me | 01/01/70 00:00 | |
What happens if? | 01/01/70 00:00 | |
i will see | 01/01/70 00:00 | |
"mov @r0,#00h" by "NOP, NOP"? | 01/01/70 00:00 | |
A good idea | 01/01/70 00:00 | |
nothing postive | 01/01/70 00:00 | |
RAM fill ? | 01/01/70 00:00 | |
re ram fill | 01/01/70 00:00 | |
Simulator. | 01/01/70 00:00 | |
Is the CPU really running? | 01/01/70 00:00 | |
mov p1,r0 | 01/01/70 00:00 | |
last hope | 01/01/70 00:00 | |
Tell this first | 01/01/70 00:00 | |
let me clear | 01/01/70 00:00 | |
pull ups | 01/01/70 00:00 | |
re pull ups | 01/01/70 00:00 | |
a word on pull ups | 01/01/70 00:00 | |
What to say for that ignorance? | 01/01/70 00:00 |