Code: Select all
.macro assert_branch_page label_
.assert >(label_) = >(*+2), error, "Page crossing detected!"
.endmacro
test:
assert_branch_page :+
beq :+ ; .assert should happen if this would cross a page
nop
:
rts
Edit: Later on I decided to just put the assert immediately after the branch instruction rather than before, which eliminates the need for +2.
Code: Select all
.macro assert_branch_page label_
.assert >(label_) = >*, error, "Page crossing detected!"
.endmacro
test:
beq :+ ; .assert should happen if this would cross a page
assert_branch_page :+
nop
:
rts