Hello forums, I started playing with a coding the 8051 after a long search for an assembly language to learn and it seemed like the way coolest one. I looked around a bit for how to do this but I probably just couldn't word it correctly; what I'm trying to do is fill memory locations 0x0200-0x05ff with a certain value, doesn't matter what it is. If i had to just do something like fill locations 0x200-0x2ff it would be easy as I could just use:
mov r0, # 100h mov dptr, # 200h a: mov a, #27 mov @dptr, a inc dptr djnz r0, a
but what is the best way to do it for more than 256 bytes?
Answers on a postcard please.
Consider "mov a,#27" inside the loop.
Handling larger ranges that 256? Use one more loop that iterates the above code. That your djnz is limited shouldn't be a big issue.
Ah, i see what you mean.
mov r1, # 5 mov r0, # 100h mov dptr, # 200h mov a, #27 loop: mov @dptr, a inc dptr djnz r0, loop djnz r1, loop </rep> This 8051 is incredible stuff. And it does each instruction very fast.
0x0200H is on external RAM memory (one can't write data in the code memory. hence the conclusion). In which case i think you should be using MOVX instead of just MOV. I hope your code works as expected.
View all questions in Keil forum