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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/01/10 05:42
Modified:
  04/01/10 05:47

Read: times


 
#174707 - If reading from codespace, use 'MOVC'
Responding to: ???'s previous message
Hi Hithesh,


Well, you were almost there.. ;) I think you've simply forgotten that the 8051 memory architecture is comprised of separate code and data spaces i.e. harvard architecture..

To access data from the instruction code space of an 8051, you need to use the MOVC instruction. For example:

MOV DPTR, #1000h
CLR A
MOVC A, @A+DPTR


You can also make (limited) indirect accesses to the same using the program counter instead (i.e. MOVC A,@A+PC) but let's not complicate matters..


Okay, why could your other two possibilities fail?

Well, firstly 'MOV A, addr' opcode allows direct data moves from either 128 bytes of internal RAM (IRAM) or special function register (SFR) areas, depending on the value of 'addr' operand i.e. 0->127d for IRAM and 128->255d for SFR

Second, 'MOVX A, @DPTR' instruction you've stated would not work in this case, since that would be accessing the external data memory space!


Hope this helps,

Valentin

List of 14 messages in thread
TopicAuthorDate
8051 Instruction MOV A, addr            01/01/70 00:00      
   If reading from codespace, use 'MOVC'            01/01/70 00:00      
      Why CLR A ?            01/01/70 00:00      
         Good question..            01/01/70 00:00      
            I must be going blind!            01/01/70 00:00      
               re            01/01/70 00:00      
                  Did you check the so-called "bible"?            01/01/70 00:00      
                     I should have clarified            01/01/70 00:00      
                        external            01/01/70 00:00      
                  reply to re            01/01/70 00:00      
      CLR A??            01/01/70 00:00      
         "bible" time            01/01/70 00:00      
            Done :-)            01/01/70 00:00      
   "bible" time            01/01/70 00:00      

Back to Subject List