Alignment for multiple DataSections
Posted: Sun Dec 29, 2013 12:14 pm
It would be nice if any DataSection would start at a aligned boundary instead of only the first DataSection to be aligned.
When saying "aligned", I mean the start address of each DataSection to be aligned. I do not mean the labels inside of a single DataSection to be aligned!
A manual alignment is quite hard to maintain when having multiple DataSections spread throughout different include files. Since the "Align" keyword has already been introduced for structures, it maybe can be used here as well in a way like this:
Code: Select all
DataSection
x: : Data.b 0
EndDataSection
DataSection
y: : Data.b 0
EndDataSection
Debug ?x ; = 5368960240
Debug ?y ; = 5368960241
Debug ""
Debug ?x % 16 ; = 0
Debug ?y % 16 ; = 1
A manual alignment is quite hard to maintain when having multiple DataSections spread throughout different include files. Since the "Align" keyword has already been introduced for structures, it maybe can be used here as well in a way like this:
Code: Select all
; first one's alway aligned (like now)
DataSection
a: : Data.b 0
EndDataSection
; default alignment (4 Byte on x86 and 8 Byte on x64)
DataSection
b: : Data.b 0
EndDataSection
; no alignment
DataSection Align #PB_DataSection_NoAlign ; or simply "Align 0"
c: : Data.b 0
EndDataSection
; odd manual alignment
DataSection Align 7
d:
EndDataSection
Debug ?a ; = 5368960240 (start alignment)
Debug ?b ; = 5368960248 (default alignment)
Debug ?c ; = 5368960249 (no alignment)
Debug ?d ; = 5368960254 (odd manual alignment)
Debug ""
Debug ?a % SizeOf(Integer) ; = 0 (start alignment)
Debug ?b % SizeOf(Integer) ; = 0 (default alignment)
Debug ?c % SizeOf(Integer) ; = 1 (no alignment)
Debug ?d % 7 ; = 0 (odd manual alignment)