mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Implement ds align[alignment, offset] (#1181)
This commit is contained in:
7
test/asm/ds-align-min.asm
Normal file
7
test/asm/ds-align-min.asm
Normal 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
|
||||
0
test/asm/ds-align-min.err
Normal file
0
test/asm/ds-align-min.err
Normal file
0
test/asm/ds-align-min.out
Normal file
0
test/asm/ds-align-min.out
Normal file
BIN
test/asm/ds-align-min.out.bin
Normal file
BIN
test/asm/ds-align-min.out.bin
Normal file
Binary file not shown.
7
test/asm/ds-align-offset.asm
Normal file
7
test/asm/ds-align-offset.asm
Normal 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
|
||||
0
test/asm/ds-align-offset.err
Normal file
0
test/asm/ds-align-offset.err
Normal file
0
test/asm/ds-align-offset.out
Normal file
0
test/asm/ds-align-offset.out
Normal file
BIN
test/asm/ds-align-offset.out.bin
Normal file
BIN
test/asm/ds-align-offset.out.bin
Normal file
Binary file not shown.
25
test/asm/ds-align.asm
Normal file
25
test/asm/ds-align.asm
Normal 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
0
test/asm/ds-align.err
Normal file
0
test/asm/ds-align.out
Normal file
0
test/asm/ds-align.out
Normal file
BIN
test/asm/ds-align.out.bin
Normal file
BIN
test/asm/ds-align.out.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user