PulkoMandy | 17fc759 | 2022-07-28 18:27:54 +0200 | [diff] [blame] | 1 | This chapter documents the Backend for the 68hc12 and 6809/6309 microcontroller families. |
| 2 | |
| 3 | @section Additional options for this version |
| 4 | |
| 5 | This backend provides the following additional options: |
| 6 | |
| 7 | @table @option |
| 8 | |
| 9 | @item -merge-constants |
| 10 | Place identical floating point constants at the same |
| 11 | memory location. This can reduce program size and increase |
| 12 | compilation time. (No fp support yet.) |
| 13 | |
| 14 | @item -const-in-data |
| 15 | By default constant data will be placed in a read-only |
| 16 | section. Using this option it will be placed in the |
| 17 | data section. |
| 18 | |
| 19 | @item -no-delayed-popping |
| 20 | By default arguments of function calls are not always popped |
| 21 | from the stack immediately after the call, so that the |
| 22 | arguments of several calls may be popped at once. |
| 23 | With this option vbcc can be forced to pop them after every |
| 24 | function call. |
| 25 | This may simplify debugging and very slightly reduce the |
| 26 | stack size needed by the compiled program. |
| 27 | |
| 28 | @item -no-peephole |
| 29 | Do not perform peephole-optimizations. |
| 30 | |
| 31 | @item -mem-cse |
| 32 | Try to hold values loaded from memory in registers and |
| 33 | reuse them. Due to the small register-set of the hc12 |
| 34 | this is disabled by default as it increases register- |
| 35 | pressure and tends to spill to the stack. |
| 36 | |
| 37 | @item -cpu=<n> |
| 38 | Specify the processor family. Currently supported values are: |
| 39 | @itemize |
| 40 | @item 6812: Generate code for the Motorola 68hc12 series (default). |
| 41 | |
| 42 | @item 6809: Generate code for the Motorola 6809 series. |
| 43 | |
| 44 | @item 6309: Generate code for the Hitachi 6309 series (currently identical to 6809). |
| 45 | @end itemize |
| 46 | |
| 47 | |
| 48 | @item -acc-glob |
| 49 | Make the accumulator available for global register allocation. |
| 50 | By default, the accumulator will only be used for register allocation |
| 51 | within basic blocks. In many cases, global allocation will result in |
| 52 | worse code, because the accumulator has to be pushed/popped many times. |
| 53 | |
| 54 | @item -pcrel |
| 55 | Generate PC-relative code. May not fully work with 68hc12. |
| 56 | |
| 57 | @item -drel |
| 58 | Generate code that accesses data relative to register @code{u}. Does not |
| 59 | work with 68hc12. |
| 60 | |
| 61 | @end table |
| 62 | |
| 63 | @section ABI |
| 64 | |
| 65 | The current version generates assembly output for use with vasm6809_std or the GNU |
| 66 | assembler using the non-banked model. |
| 67 | |
| 68 | This backend supports the following registers: |
| 69 | |
| 70 | @itemize @minus |
| 71 | @item @code{d} for the accumulator (also used for byte, i.e. @code{b}) |
| 72 | @item @code{x} for index register x |
| 73 | @item @code{y} for index register y |
| 74 | @item @code{u} for index register u (not on 68hc12) |
| 75 | @item @code{sp} for the stack-pointer |
| 76 | @end itemize |
| 77 | |
| 78 | The accumulator and @code{x} are caller-save. The @code{y} register is callee-save. |
| 79 | The @code{u} register is used as data-page pointer with @code{-drel}. |
| 80 | |
| 81 | The first function argument which has integer or pointer type up to 16 bits |
| 82 | is passed in the accumulator @code{d}. |
| 83 | The remaining arguments are passed on the stack. |
| 84 | |
| 85 | Integers and pointers are returned in @code{d} or @code{d/x} (@code{x} contains the higher bits). |
| 86 | All other types are returned by passing the function the address |
| 87 | of the result as a hidden argument - so when you call such a function |
| 88 | without a proper declaration in scope you can expect a crash. |
| 89 | |
| 90 | The elementary data types are represented like: |
| 91 | @example |
| 92 | type size in bits alignment in bytes |
| 93 | |
| 94 | char 8 1 |
| 95 | short 16 1 |
| 96 | int 16 1 |
| 97 | long 32 1 |
| 98 | near pointers 16 1 |
| 99 | far pointers 24 1 (not yet) |
| 100 | huge pointers 24 1 (not yet) |
| 101 | float 32 1 (not yet) |
| 102 | double 64 1 (not yet) |
| 103 | long double 64 1 (not yet) |
| 104 | @end example |
| 105 | |
| 106 | |
| 107 | @section Target-specific variable-attributes |
| 108 | |
| 109 | The 6809/hc12-backend offers the following variable attributes: |
| 110 | |
| 111 | @table @code |
| 112 | @item __interrupt |
| 113 | Return with @code{rti} rather than @code{rts}. |
| 114 | |
| 115 | @item __section("name","attr") |
| 116 | Place this function/object in section "section" |
| 117 | with attributes "attr". |
| 118 | |
| 119 | @item __dpage |
| 120 | Place the variable in section @code{.dpage} and use direct addressing. |
| 121 | |
| 122 | @end table |
| 123 | |
| 124 | @section Predefined Macros |
| 125 | |
| 126 | This backend defines the following macros: |
| 127 | |
| 128 | @table @code |
| 129 | @item __HC12__ |
| 130 | If code for 68hc12 is generated. |
| 131 | |
| 132 | @item __6809__ |
| 133 | If code for 6809 is generated. |
| 134 | |
| 135 | @item __6309__ |
| 136 | If code for 6309 is generated. |
| 137 | @ |
| 138 | @end table |
| 139 | |
| 140 | @section Stack |
| 141 | |
| 142 | If the @option{-stack-check} option is used, every function-prologue will |
| 143 | call the function @code{__stack_check} with the stacksize needed by this |
| 144 | function in register @code{y}. This function has to consider its own |
| 145 | stacksize and must restore all registers. |
| 146 | |
| 147 | |
| 148 | @section Stdarg |
| 149 | |
| 150 | Stdarg is supported by the provided include. |
| 151 | |
| 152 | @section Known Problems |
| 153 | |
| 154 | @itemize @minus |
| 155 | @item Support for floating point and long long is still missing. |
| 156 | @item U register is not really used yet. |
| 157 | @item No support for 6309 extensions yet. |
| 158 | @item Many optimizations still missing. |
| 159 | @item Some code generation bugs to be fixed. |
| 160 | |
| 161 | @end itemize |
| 162 | |
| 163 | |