diff --git a/src/Ophis/CorePragmas.py b/src/Ophis/CorePragmas.py index d5faea7..176222c 100644 --- a/src/Ophis/CorePragmas.py +++ b/src/Ophis/CorePragmas.py @@ -94,8 +94,13 @@ def pragmaOrg(ppt, line, result): def pragmaAdvance(ppt, line, result): "Outputs filler until reaching the target PC" newPC = FE.parse_expr(line) + if str(line.lookahead(0)) == ",": + line.pop() + fillexpr = FE.parse_expr(line) + else: + fillexpr = IR.ConstantExpr(0) line.expect("EOL") - result.append(IR.Node(ppt, "Advance", newPC)) + result.append(IR.Node(ppt, "Advance", newPC, fillexpr)) def pragmaCheckpc(ppt, line, result): "Enforces that the PC has not exceeded a certain point" diff --git a/src/Ophis/Passes.py b/src/Ophis/Passes.py index 8b20dd4..a19d02c 100644 --- a/src/Ophis/Passes.py +++ b/src/Ophis/Passes.py @@ -575,7 +575,6 @@ class Assembler(Pass): if (pc > target): Err.log("Attempted to .advance backwards: $%x to $%x" % (pc, target)) else: - zero = IR.ConstantExpr(0) - for i in xrange(target-pc): self.outputbyte(zero, env) + for i in xrange(target-pc): self.outputbyte(node.data[1], env) self.filler += target-pc env.setPC(target) diff --git a/tests/testdata.bin b/tests/testdata.bin index 8169f7c..6279ccb 100644 Binary files a/tests/testdata.bin and b/tests/testdata.bin differ diff --git a/tests/testdata.oph b/tests/testdata.oph index 0727b6e..c0fc1aa 100644 --- a/tests/testdata.oph +++ b/tests/testdata.oph @@ -1,7 +1,9 @@ -; This data file just dumps out $00-$0F repeatedly with different forms. - +; This data file just dumps out $00-$0F repeatedly with different forms, +; bracketed by $00s and then $60s. +.advance $10, ^ .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 .word 256, $0302, $0504, $0706, $0908, $0b0a, $0d0c, $0f0e .dword $03020100, $07060504, $0b0a0908, $0f0e0d0c .wordbe 1, $0203, $0405, $0607, $0809, $0a0b, $0c0d, $0e0f .dwordbe $010203, $04050607, $08090a0b, $0c0d0e0f +.advance $70, ^