From a64da02dad9e88eb66199086cbae5abf7684432f Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 11 Oct 2019 19:56:34 +0200 Subject: [PATCH] added pseudocommands for branch word-relative instructions --- c64/aliases/,aliases_cpu.s | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/c64/aliases/,aliases_cpu.s b/c64/aliases/,aliases_cpu.s index 7e2bbfa5..7a61c8aa 100644 --- a/c64/aliases/,aliases_cpu.s +++ b/c64/aliases/,aliases_cpu.s @@ -47,3 +47,105 @@ tay #endif } + + +// +// Branches with far offsets, substitutes by Bxx + JMP for CPUs not supporting the instruction +// + + +.pseudocommand bcs_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $B3, mod(offset, $100), floor(offset / $100) +#else + bcc __l + jmp dst +__l: +#endif +} + +.pseudocommand bcc_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $93, mod(offset, $100), floor(offset / $100) +#else + bcs __l + jmp dst +__l: +#endif +} + +.pseudocommand beq_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $F3, mod(offset, $100), floor(offset / $100) +#else + bne __l + jmp dst +__l: +#endif +} + +.pseudocommand bne_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $D3, mod(offset, $100), floor(offset / $100) +#else + beq __l + jmp dst +__l: +#endif +} + +.pseudocommand bmi_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $33, mod(offset, $100), floor(offset / $100) +#else + bpl __l + jmp dst +__l: +#endif +} + +.pseudocommand bpl_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $13, mod(offset, $100), floor(offset / $100) +#else + bmi __l + jmp dst +__l: +#endif +} + +.pseudocommand bvc_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $53, mod(offset, $100), floor(offset / $100) +#else + bvs __l + jmp dst +__l: +#endif +} + +.pseudocommand bvs_far dst +{ +#if CONFIG_CPU_CSG_65CE02 + .var offset = mod($10000 + dst.getValue() - *, $10000) + .byte $73, mod(offset, $100), floor(offset / $100) +#else + bvc __l + jmp dst +__l: +#endif +}