Implement ds align[alignment, offset] (#1181)

This commit is contained in:
Rangi
2023-11-21 17:57:47 -05:00
committed by GitHub
parent 6f0ffcf3e1
commit 46e29de66f
17 changed files with 148 additions and 17 deletions

View File

@@ -0,0 +1,7 @@
SECTION "test", ROM0
align 3 ; 3 < 4, so this is used in `ds align` below
db 1, 2, 5 ; three
ds align[4] ; (1 << 3) - three = 5 bytes
db 10, 20 ; two
align 4, 2
assert @ - STARTOF("test") == 3 + 5 + 2

View File

View File

Binary file not shown.

View File

@@ -0,0 +1,7 @@
SECTION "test", ROM0
align 3, 3 ; 3 < 4, so this is used in `ds align` below
db 2, 22, 222 ; three
ds align[4, 4] ; (1 << 3) - 3 - three + 4 = 6 bytes
db 42 ; one
align 4, 5
assert @ - STARTOF("test") == 3 + 6 + 1

View File

View File

Binary file not shown.

25
test/asm/ds-align.asm Normal file
View File

@@ -0,0 +1,25 @@
SECTION "aligned", ROM0, ALIGN[8]
db 1, 2, 3, 4, 5 ; five
ds align[8, $ff], 6 ; (1 << 8) - five - one = 250 bytes
db 7 ; one
align 8
assert @ - STARTOF("aligned") == 5 + 250 + 1
SECTION "fixed", ROM0[$100]
ds align[2] ; already aligned, 0 bytes
db 8, 9, 10 ; three
ds align[4, $e], 11 ; (1 << 4) - three - two = 11 bytes
db 12, 13 ; two
align 4
assert @ - STARTOF("fixed") == 3 + 11 + 2
SECTION "floating", ROM0
db 14, 15 ; two
ds align[4] ; not aligned, 0 bytes
align 4 ; redundant
db 16, 17, 18 ; three
align 4, 3
ds align[5], 19, 20 ; (1 << 4) - three = 13 bytes
db 21 ; one
align 5, 1
assert @ - STARTOF("floating") == 2 + 3 + 13 + 1

0
test/asm/ds-align.err Normal file
View File

0
test/asm/ds-align.out Normal file
View File

BIN
test/asm/ds-align.out.bin Normal file

Binary file not shown.