@Reference inside of DAT block
CassLan
Posts: 586
Hello,
I want to first thank the people who helped me out the other day with:
http://forums.parallax.com/showthread.php?p=788688
In continuing with this Menu function which is only provided the address of the start of that particular menus data, I have inside of the DAT Blocks the next Menu location to jump to:
At the moment the first piece of Info is the Title of the Menu, then the # of Choices, then the Label of Each Choice, then the StartingAddress of the Menu to jump too if that choice is selected:
·The Problem is that if I write the hex memory address instead of the "@SystemInfoMenu" everything goes smoothly, however I'm finding (through printing variables on screen) that where the address of @MainMenu should be $0024, its showing up as $0014 when reading from the DAT block. Also when reading @SystemInfoMenu it should be reading $0084, its reading $0074.
Any idea why it would be the correct address -16 bytes?
Thanks,
Rick
I want to first thank the people who helped me out the other day with:
http://forums.parallax.com/showthread.php?p=788688
In continuing with this Menu function which is only provided the address of the start of that particular menus data, I have inside of the DAT Blocks the next Menu location to jump to:
At the moment the first piece of Info is the Title of the Menu, then the # of Choices, then the Label of Each Choice, then the StartingAddress of the Menu to jump too if that choice is selected:
DAT MainMenu byte "Main Menu ",4 byte "System Info ", long @SystemInfoMenu byte "Setup Zones ", long @MainMenu byte "Setup Sensors ", long @MainMenu byte "Setup Outputs ", long @SystemInfoMenu
SystemInfoMenu byte "System Info ",3 byte "Test Option 1 ", long @MainMenu byte "Test Option 2 ", long @MainMenu byte "Test Option 3 ", long @MainMenu
·The Problem is that if I write the hex memory address instead of the "@SystemInfoMenu" everything goes smoothly, however I'm finding (through printing variables on screen) that where the address of @MainMenu should be $0024, its showing up as $0014 when reading from the DAT block. Also when reading @SystemInfoMenu it should be reading $0084, its reading $0074.
Any idea why it would be the correct address -16 bytes?
Thanks,
Rick
Comments
Erik,
If you are reffering to the Alignment of the bytes/longs, I have checked it against the Prop Manual's guidlines and Table 4-8: Example Data in Memory.
I will break it down as I am seeing it:
It should all line up. If it didn't I dont think my program would·display the menu at all. (The alignment was an earlier problem which I resolved)
Post Edited (CassLan) : 3/3/2009 1:39:18 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Steve, thank you again. Your absolutely correct. I can see that in the hex info (F8).
Rick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
Personally I feel that "@foo" should mean what it says wherever it is but at the time people almost convinced me the Spin way was sensible.
This program demonstrates the issue and the work arounds, as already suggested here:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Post Edited (mojorizing) : 3/4/2009 5:17:08 AM GMT
The only time I experienced this issue was when the·Memory Reference·was located within the DAT section:
[/code][/size]
I'm almost nervous to speculate because I know there are people who know a hell of a lot more than I do that read/respond regularly but I would have to guess that the Address references inside of the DAT blocks are calulated as an offset of the "usable" object memory, while the references inside of the code portion are calculated as an offset of the total memory, the difference being $10 bytes.
Try putting altering your code to something like this to see the result:
(I shortened one of the blank spaces off of each of your string values to align the Byte/Longs making the string·+ the terminating 0 = 20Bytes)
[/code][/size]
·Hope that answered what you meant.
Rick
·
@symbol in a PUB or PRI method is computed at run time and is the absolute address of the symbol.
The top object ends up being placed in memory starting at $10, hence the 16-byte difference between the object-relative offset and the absolute address. But... sub-objects will end up starting at other addresses, so the offset for them won't be $10. That's when the @@ operator comes in. It simply adds the object's start address to whatever follows it, thereby converting object-relative offsets into absolute addresses.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!