mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-11-04 11:05:12 +00:00
f8bc917601
This pass actually isn't an optimizer in that it produces larger binaries when it triggers. However, the larger binaries created will actually assemble properly. The ExtendBranches pass detects Relative instructions (that is, branches) that extend past the signed-8-bit range Relative instructions permit, and replaces them with a branch-jump combination with identical semantics. Since this may be evidence of a program bug, Ophis will warn when the optimization is triggered. Due to similarities between this pass and UpdateLabels, both passes have been refactored in passing.
54 lines
686 B
Plaintext
54 lines
686 B
Plaintext
.text
|
|
.org $0800
|
|
early:
|
|
bmi +
|
|
jmp late
|
|
* bpl +
|
|
jmp late
|
|
* bvs +
|
|
jmp late
|
|
* bvc +
|
|
jmp late
|
|
* bcs +
|
|
jmp late
|
|
* bcc +
|
|
jmp late
|
|
* beq +
|
|
jmp late
|
|
* bne +
|
|
jmp late
|
|
* bpl early
|
|
bmi early
|
|
bvc early
|
|
bvs early
|
|
bcc early
|
|
bcs early
|
|
bne early
|
|
beq early
|
|
.advance $0900
|
|
late:
|
|
bpl late
|
|
bmi late
|
|
bvc late
|
|
bvs late
|
|
bcc late
|
|
bcs late
|
|
bne late
|
|
beq late
|
|
bmi +
|
|
jmp early
|
|
* bpl +
|
|
jmp early
|
|
* bvs +
|
|
jmp early
|
|
* bvc +
|
|
jmp early
|
|
* bcs +
|
|
jmp early
|
|
* bcc +
|
|
jmp early
|
|
* beq +
|
|
jmp early
|
|
* bne +
|
|
jmp early
|
|
* |