blob: c89224bc8abef4d05e3da74c15ecfedad875508d [file] [log] [blame]
This chapter documents the Backend for the 68hc12 and 6809/6309 microcontroller families.
@section Additional options for this version
This backend provides the following additional options:
@table @option
@item -merge-constants
Place identical floating point constants at the same
memory location. This can reduce program size and increase
compilation time. (No fp support yet.)
@item -const-in-data
By default constant data will be placed in a read-only
section. Using this option it will be placed in the
data section.
@item -no-delayed-popping
By default arguments of function calls are not always popped
from the stack immediately after the call, so that the
arguments of several calls may be popped at once.
With this option vbcc can be forced to pop them after every
function call.
This may simplify debugging and very slightly reduce the
stack size needed by the compiled program.
@item -no-peephole
Do not perform peephole-optimizations.
@item -mem-cse
Try to hold values loaded from memory in registers and
reuse them. Due to the small register-set of the hc12
this is disabled by default as it increases register-
pressure and tends to spill to the stack.
@item -cpu=<n>
Specify the processor family. Currently supported values are:
@itemize
@item 6812: Generate code for the Motorola 68hc12 series (default).
@item 6809: Generate code for the Motorola 6809 series.
@item 6309: Generate code for the Hitachi 6309 series (currently identical to 6809).
@end itemize
@item -acc-glob
Make the accumulator available for global register allocation.
By default, the accumulator will only be used for register allocation
within basic blocks. In many cases, global allocation will result in
worse code, because the accumulator has to be pushed/popped many times.
@item -pcrel
Generate PC-relative code. May not fully work with 68hc12.
@item -drel
Generate code that accesses data relative to register @code{u}. Does not
work with 68hc12.
@end table
@section ABI
The current version generates assembly output for use with vasm6809_std or the GNU
assembler using the non-banked model.
This backend supports the following registers:
@itemize @minus
@item @code{d} for the accumulator (also used for byte, i.e. @code{b})
@item @code{x} for index register x
@item @code{y} for index register y
@item @code{u} for index register u (not on 68hc12)
@item @code{sp} for the stack-pointer
@end itemize
The accumulator and @code{x} are caller-save. The @code{y} register is callee-save.
The @code{u} register is used as data-page pointer with @code{-drel}.
The first function argument which has integer or pointer type up to 16 bits
is passed in the accumulator @code{d}.
The remaining arguments are passed on the stack.
Integers and pointers are returned in @code{d} or @code{d/x} (@code{x} contains the higher bits).
All other types are returned by passing the function the address
of the result as a hidden argument - so when you call such a function
without a proper declaration in scope you can expect a crash.
The elementary data types are represented like:
@example
type size in bits alignment in bytes
char 8 1
short 16 1
int 16 1
long 32 1
near pointers 16 1
far pointers 24 1 (not yet)
huge pointers 24 1 (not yet)
float 32 1 (not yet)
double 64 1 (not yet)
long double 64 1 (not yet)
@end example
@section Target-specific variable-attributes
The 6809/hc12-backend offers the following variable attributes:
@table @code
@item __interrupt
Return with @code{rti} rather than @code{rts}.
@item __section("name","attr")
Place this function/object in section "section"
with attributes "attr".
@item __dpage
Place the variable in section @code{.dpage} and use direct addressing.
@end table
@section Predefined Macros
This backend defines the following macros:
@table @code
@item __HC12__
If code for 68hc12 is generated.
@item __6809__
If code for 6809 is generated.
@item __6309__
If code for 6309 is generated.
@
@end table
@section Stack
If the @option{-stack-check} option is used, every function-prologue will
call the function @code{__stack_check} with the stacksize needed by this
function in register @code{y}. This function has to consider its own
stacksize and must restore all registers.
@section Stdarg
Stdarg is supported by the provided include.
@section Known Problems
@itemize @minus
@item Support for floating point and long long is still missing.
@item U register is not really used yet.
@item No support for 6309 extensions yet.
@item Many optimizations still missing.
@item Some code generation bugs to be fixed.
@end itemize