[ << ] [ >> ]           [] [] [] [ ? ]

29 6809/6309/68HC12 cpu module

This chapter documents the backend for the Motorola 6809, 68HC12 and Hitachi 6309.


29.1 Legal

This module is written in 2020-2021 by Frank Wille and is covered by the vasm copyright without modifications.


29.2 Additional options for this module

This module provides the following additional options:

-6809

Generate code for the 6809 CPU (default setting). Also works on the 6309, which is backwards compatible.

-6309

Generate code for the 6309 CPU.

-68hc12

Generate code for the 68HC12 CPU.

-opt-branch

Translate short-branches to long and optimize long-branches to short when required/possible. Also tries to optimize jmp and jsr instructions into short-branches.

-opt-offset

Delete zero offsets in indexed addressing modes, when possible.

-opt-pc

Convert all extended addressing modes with local or external labels to indexed, PC-relative addressing. Also translates absolute jmp/jsr instructions into PC-relative lbra/lbsr (or better).


29.3 General

This backend accepts 6809/6309 instructions as described in the Motorola 6809 and Hitachi 6309 Programmer’s Reference (Copyright 2009 Darren Atkinson). Optionally supports the 68HC12 instruction set as documented in Motorola’s CPU12 Reference Manual.

The target address type is 16 bit.

Instructions consist of one up to six bytes and require no alignment. There is also no alignment requirement for sections and data.


29.4 Extensions

The backend supports the unary operators < and > to either select the size of an addressing mode or the LSB/MSB of a 16-bit word.

In absence of < or > vasm selects the best addressing mode possible, i.e. the one which requires the least amount of memory when the symbol value is known, or the one which allows the largest symbol values, when it is unknown at assembly time.

This backend extends the selected syntax module by the following directives:

setdp <expr>

Set the current base address of the direct page. It is used to decide whether an extended addressing mode can be optimized to direct addressing. No effect for 68HC12.

direct <symbol>

Tell the assembler to use direct addressing for expressions based on this symbol.


29.5 Optimizations

This backend performs the following operand optimizations:


29.6 Known Problems

Some known problems of this module at the moment:


29.7 Error Messages

This module has the following error messages:


[ << ] [ >> ]           [] [] [] [ ? ]