How do you find the hub address of initialized data?
pedward
Posts: 1,642
If I include initialized data in a SPIN program (PASM at this point), how do I find the hub address of that initialized data? I looked at Chips ROM monitor code and he takes some very elaborate steps to statically calculate the offsets and store them as immediates, but I want to know the right way of finding the hub address of a variable.
Comments
What I do is look at the object listing in Pnut, then add the load address to it, which is usually $e80, but can be $1000, or something else
That is from the object listing for the fractal thing I just did. The VALUE: field is two words. For YMAX, these are 0140 02C4. The lower word is the HUB address, starting from 0. The upper word is the address relative to the ORG last issued.
So then, YMAX lives at $0e80+$02c4 absolute HUB address.
The "@" operator generally just needs the load address added to it for things to work nicely, if you've not padded the code with an array.
IMHO, the monitor being in low RAM warrants and ORG and OBJ operator... or some other thing that specifies an address offset to work with.
There is a more detailed explanation aimed at using the monitor to modify values, start COGS, etc... You can find that document here: http://forums.parallax.com/attachment.php?attachmentid=98587&d=1357887830
and use p2load like this...
p2load (-s) skips the first $e80 longs, and starts cog execution at (-h) $1000 hub.
This method saves worrying about the $e80 offset.
If you remove the -h, then execution will start at $e80, so delete the line allocating the
byte 0[_RESERVED]