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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/26/07 03:45
Read: times


 
#139858 - depends
Responding to: ???'s previous message
Obviously it depends on the spec of your chip as to how much code space you have. The chip doesn't care how you divvy up the code space (presumably flash) - in other words it makes no difference if you want to fill it with all instructions or all data or any mix. You can specify if you want where your data sits in flash or let your linker deal with it. Depending on your application it's useful to know the address where it sits.

If you want to specify do:

cseg AT blahblahh
stuff_I_want_to_store: db "blah blah blah blah"
stuff_i_also_want_to_store: db "blah blah 2"

If you don't care about specifying, you can just dump it in your code (inside any cseg). To access it you use movc and mov dptr. So for example if you want to get at stuff_I_want_to_store you would do:

mov dptr, stuff_I_want_to_store ;this moves the data pointer to stuff_I_want_to_store

then you could say
clr a
movc a, @a+dptr

and that would move "b" (the character - the byte sitting at stuff_I_want_to_store) to your accumulator. You could then do inc dptr and movc again to get at the "l". Another inc dptr would point you to the “a”.

If you want to do memory reservation (for constants or something that might get programmed on start up etc) then you need to do ds and write to flash. That's mildly more complicated because it's more processor dependent and takes more time (writting to flash takes much more time than executing an instruction b/c you need to erase an entire page - typically). Hope that helps,

D


List of 24 messages in thread
TopicAuthorDate
How to store data in 8051/DB command            01/01/70 00:00      
   More Detail            01/01/70 00:00      
      Data            01/01/70 00:00      
         DB            01/01/70 00:00      
            1k in db            01/01/70 00:00      
               depends            01/01/70 00:00      
                  starting to understand            01/01/70 00:00      
                     Yes            01/01/70 00:00      
                        better?            01/01/70 00:00      
                           Example ?            01/01/70 00:00      
                              need...            01/01/70 00:00      
                                 Thats it            01/01/70 00:00      
   some answers...            01/01/70 00:00      
      I got MOVC!            01/01/70 00:00      
         The datasheet is the cuestion            01/01/70 00:00      
         store the A contents away...            01/01/70 00:00      
   cant debug a problem...            01/01/70 00:00      
      First step            01/01/70 00:00      
         a skywriter...            01/01/70 00:00      
            well, if you copy crap,, you get crap            01/01/70 00:00      
      I always thought.....            01/01/70 00:00      
   Cant debug, explained + Code            01/01/70 00:00      
   I THINK i found the problem            01/01/70 00:00      
      Long lines            01/01/70 00:00      

Back to Subject List