Retro Assembler V2020.7 Released

May 13, 2020Retro Assembler

In this new update I added a couple of new features:

I added a new directive .format to replace the old .setting "OutputFormat" solution. It's strange I haven't done this sooner, but now it's here.

I added a new Setting HandleLongBranch. The instructions that use relative addressing, typically branching instructions like bne or beq can only handle a certain address range, especially on 8-bit CPUs. When this range is exceeded, the assembler shows an error message about it. If you enable this setting, the assembler tries to resolve these errors by automatically replacing the generated code with a counterpart that can handle long jumps to absolute addresses.

Label  nop
(Lots of instructions here, over $80 bytes worth)
bne Label
(Other instructions)

This fails because Label is way too far away for a relative address jump. The assembler will compile this instead:

Label  nop
(Lots of instructions here, over $80 bytes worth)
beq AfterJmp  //Branch counterpart for "bne"
jmp Label     //Jump to an absolute address.
AfterJmp      //The label that's accessible as a short relative jump.
(Other instructions)

It's handled like this on 6502, 65C02 and 65816, with all the branch instructions of these CPUs. On Z80 and Gameboy CPUs the case is simpler, the jr instructions get replaced with the appropriate jp instructions.

Of course this is not ideal if your goal is writing code that can be relocated to any memory address, but that's rare and then you surely know what you are doing. The feature is not turned on by default, but if you need it, and most people likely would, it can be enabled, even for just a section of the code, by .setting "HandleLongBranch", true

The rest of the changes can be filed under Good Housekeeping:

See the documentation for details.

Download the latest version from the Retro Assembler page!