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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/18/06 08:56
Read: times


 
#110266 - How I use that MOVC
Responding to: ???'s previous message
Hello

In most cases, when programming in assembler of course, I do clear A before using that instruction, only using DPTR with the correct address.

However, sometimes, when not a complete string is to be read, but to look up a single byte only in a lookup table in a buffer of up to 256 bytes, I prefer to load DPTR with the buffer start address and use A as an index to the buffer. This avoids to calculate the address before and put that address to DPTR and then clear A; because the 8051 caculates the address for me.

Note that this can be done without using DPTR at all, I use MOVC A,@A+PC sometimes like this:
; A is the table index 0 to 252
ADD A, #3 ; compensate for LJMP after MOVC
MOVC A,@A+PC
LJMP BehindTable
Table:
...
BehindTable:

Best reagrds


List of 14 messages in thread
TopicAuthorDate
MOVC A , @A+DPTR            01/01/70 00:00      
   Thats the way it works            01/01/70 00:00      
   its because its.....            01/01/70 00:00      
      MOVC A , @A+DPTR            01/01/70 00:00      
         Re:            01/01/70 00:00      
            Re            01/01/70 00:00      
               Re:            01/01/70 00:00      
   A does not have to be 0            01/01/70 00:00      
      It can be convenient ...            01/01/70 00:00      
   velocity            01/01/70 00:00      
      I'm not so sure...            01/01/70 00:00      
      Be carefull            01/01/70 00:00      
         Re:            01/01/70 00:00      
   How I use that MOVC            01/01/70 00:00      

Back to Subject List