Aligning table data in DAT sections
rogloh
Posts: 5,786
in Propeller 2
What's the best way in spin to align a table in a DAT section to a 512 byte boundary?
In the SPIN2 documentation I can only see ALIGNW and ALIGNB capabilities but not a general purpose align directive.
Is there some trick that could work to roundup the current $ pointer to the nearest 512 bytes to pad the DAT section without using absolute address hacks? Something like this maybe?
DAT padding byte 0[$+512 & !511] aligned_table file "table.dat"
Comments
Umm, maybe that should be:
Update: this approach seems to work in Flexspin anyway. Hopefully PropTool works the same.
Yeah, that ain't gonna work in Pnut/Proptool unless it's pure Pasm code. The $ won't have a compile time hubRAM address in official Spin2. Only a cogRAM address within an ORG/END.
Is there a way then in PropTool?
I haven't tried. But Pnut works on the principle of the program it compiles can be subsequently placed anywhere in hubRAM without the compiler's knowledge of where. Presumably longword aligned though. It'll work from a base address with relative offsets.
What you probably want is memory allocation management API. Not something that exists at the moment.
The stack and heap could both make use of such an API. The mailbox system could be part of it. And would be a clear foundation for an OS. Which could be used for self-hosted dev.
Seems a bit limited if there isn't a way to do this. I guess there is a way if you add 512 bytes before the table data starts and do a longmove of the table contents to the next lowest 512 byte boundary before the table start address. A bit ugly but probably doable.
Yes, a large array with runtime address maths would work.