Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/05/05 18:49
Read: times


 
#96638 - register - RAM overlap
Responding to: ???'s previous message
Hi Jeroen,

maybe you are fooled by the 8051 specific behaviour that the registers in fact are RAM cells. Assuming that you use register bank 0, and this is what your code does, register R0 in fact is equal to RAM address 0, R1 is equal to 1, and so on. So what happens if the 8051 executes your code:

FILL_MEM
mov R0, #00h <- writes 0x00 into address 0x00
mov @R0, #'A' <- writes 0x41 into address 0x00

the data is ok but it overwrites your pointer in R0

inc R0 <- writex 0x42 into address 0x00
mov @R0, #'B' <- writex 0x42 into address 0x42

I'm sure that this isn't that what you wanted. So, do not use the RAM area starting at 0 for to store data. Registers are overlapped with the lower 32 Bytes of RAM. And don't forget to set the stack pointer to a valid address before you call a subroutine

Hope that helps,

Harald


List of 17 messages in thread
TopicAuthorDate
how to use RAM?            01/01/70 00:00      
   RAM            01/01/70 00:00      
   Flaw            01/01/70 00:00      
      why flaw?            01/01/70 00:00      
         Register Banks Are Not in Bible :-o            01/01/70 00:00      
            open up your eyes and let the sun shine            01/01/70 00:00      
               Misunderstood            01/01/70 00:00      
                  If you want to state "wonder" SAY SO            01/01/70 00:00      
         RAM area            01/01/70 00:00      
            but how?            01/01/70 00:00      
               Do it yourself            01/01/70 00:00      
                  I will do It myself            01/01/70 00:00      
                     upper RAM            01/01/70 00:00      
                     how can anyone help based on what you th            01/01/70 00:00      
                     register - RAM overlap            01/01/70 00:00      
                        See Post By Andy below            01/01/70 00:00      
         Not in the Tutorial?? :-0            01/01/70 00:00      

Back to Subject List