Storing words in bptr

oracacle

Senior Member
I am re-writing the code for the macro rail due to changes in the equations that are used.
I am currently facing a slight shortage of variables. some of the data that I am using isn't used that often, primarily for storing previous data. a fair amount of this info is stored as words as it can exceed 255. will I need to store the info in a high and low byte fashion?
I presume its ok to assign variable to the point ie
Code:
symbol store = 56
symbol stuff = b0

bptr store 
@bptr = stuff
is it also possible to use @bptrinc to write the data, and for that matter read the data directly back from external eeprom
if this is all true I presume its also safe to use @bptr directly in if statements, would that be a correct assumption?
 
Last edited by a moderator:

oracacle

Senior Member
thanks westaust

would I be correct in saying that this code will store w0 (stuff = 2016) into the bptr addresses of 56 and 57

Code:
[color=Blue]symbol store      [/color][color=DarkCyan]= [/color][color=Navy]56[/color]
[color=Blue]symbol [/color][color=Purple]stuff      [/color][color=DarkCyan]= [/color][color=Purple]w0
      [/color][color=Blue]symbol [/color][color=Purple]stuff_low  [/color][color=DarkCyan]= [/color][color=Purple]b0
      [/color][color=Blue]symbol [/color][color=Purple]stuff_high [/color][color=DarkCyan]= [/color][color=Purple]b1
      [/color]
[color=Black]main:
      [/color][color=Purple]stuff [/color][color=DarkCyan]= [/color][color=Navy]2016
      
      [/color][color=Purple]bptr [/color][color=DarkCyan]= [/color][color=Blue]store
      [/color][color=Purple]@bptr [/color][color=DarkCyan]= [/color][color=Purple]stuff_low
      @bptrinc [/color][color=DarkCyan]= [/color][color=Purple]stuff_high
      
      [/color][color=Blue]end[/color]
 

hippy

Technical Support
Staff member
You can use bptr, @bptr, @bptrinc and @bptrdec as you suggest; you can basically use those anywhere you could use any variable with just a few exceptions.

When reading or writing a word the inc ( or dec ) would be after the first byte read or written ...

bptr = store
@bptrinc = stuff_low
@bptr = stuff_high
 

oracacle

Senior Member
thanks hippy, I was just about to post the test code I quickly tried and found that just now.

I did use bptr and its variants for reading data onto a display for the timer project, but I was not using word variable than.

thanks all
 

lbenson

Senior Member
You can also use peek/poke with bptr to store/retrieve as many sequential bytes as you want:
Code:
symbol store      = 56
symbol stuff      = w0
symbol storeFrom  = 0  ' in bptr, equivalent to address of b0      
main:
      stuff = 2016
      
      bptr = storeFrom
      poke store,@bptrinc,@bptr
      
      end
pokebptr.jpg
 
Top