| 1 | @c Copyright (C) 1991-2016 Free Software Foundation, Inc. |
| 2 | @c This is part of the GAS manual. |
| 3 | @c For copying conditions, see the file as.texinfo. |
| 4 | @ifset GENERIC |
| 5 | @page |
| 6 | @end ifset |
| 7 | @node H8/300-Dependent |
| 8 | @chapter H8/300 Dependent Features |
| 9 | |
| 10 | @cindex H8/300 support |
| 11 | @menu |
| 12 | * H8/300 Options:: Options |
| 13 | * H8/300 Syntax:: Syntax |
| 14 | * H8/300 Floating Point:: Floating Point |
| 15 | * H8/300 Directives:: H8/300 Machine Directives |
| 16 | * H8/300 Opcodes:: Opcodes |
| 17 | @end menu |
| 18 | |
| 19 | @node H8/300 Options |
| 20 | @section Options |
| 21 | |
| 22 | @cindex H8/300 options |
| 23 | @cindex options, H8/300 |
| 24 | The Renesas H8/300 version of @code{@value{AS}} has one |
| 25 | machine-dependent option: |
| 26 | |
| 27 | @c man begin OPTIONS |
| 28 | @table @gcctabopt |
| 29 | @item -h-tick-hex |
| 30 | Support H'00 style hex constants in addition to 0x00 style. |
| 31 | |
| 32 | @item -mach=@var{name} |
| 33 | Sets the H8300 machine variant. The following machine names |
| 34 | are recognised: |
| 35 | @code{h8300h}, |
| 36 | @code{h8300hn}, |
| 37 | @code{h8300s}, |
| 38 | @code{h8300sn}, |
| 39 | @code{h8300sx} and |
| 40 | @code{h8300sxn}. |
| 41 | |
| 42 | @end table |
| 43 | @c man end |
| 44 | |
| 45 | @node H8/300 Syntax |
| 46 | @section Syntax |
| 47 | @menu |
| 48 | * H8/300-Chars:: Special Characters |
| 49 | * H8/300-Regs:: Register Names |
| 50 | * H8/300-Addressing:: Addressing Modes |
| 51 | @end menu |
| 52 | |
| 53 | @node H8/300-Chars |
| 54 | @subsection Special Characters |
| 55 | |
| 56 | @cindex line comment character, H8/300 |
| 57 | @cindex H8/300 line comment character |
| 58 | @samp{;} is the line comment character. |
| 59 | |
| 60 | @cindex line separator, H8/300 |
| 61 | @cindex statement separator, H8/300 |
| 62 | @cindex H8/300 line separator |
| 63 | @samp{$} can be used instead of a newline to separate statements. |
| 64 | Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300. |
| 65 | |
| 66 | @node H8/300-Regs |
| 67 | @subsection Register Names |
| 68 | |
| 69 | @cindex H8/300 registers |
| 70 | @cindex register names, H8/300 |
| 71 | You can use predefined symbols of the form @samp{r@var{n}h} and |
| 72 | @samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit |
| 73 | general-purpose registers. @var{n} is a digit from @samp{0} to |
| 74 | @samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid |
| 75 | register names. |
| 76 | |
| 77 | You can also use the eight predefined symbols @samp{r@var{n}} to refer |
| 78 | to the H8/300 registers as 16-bit registers (you must use this form for |
| 79 | addressing). |
| 80 | |
| 81 | On the H8/300H, you can also use the eight predefined symbols |
| 82 | @samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit |
| 83 | general purpose registers. |
| 84 | |
| 85 | The two control registers are called @code{pc} (program counter; a |
| 86 | 16-bit register, except on the H8/300H where it is 24 bits) and |
| 87 | @code{ccr} (condition code register; an 8-bit register). @code{r7} is |
| 88 | used as the stack pointer, and can also be called @code{sp}. |
| 89 | |
| 90 | @node H8/300-Addressing |
| 91 | @subsection Addressing Modes |
| 92 | |
| 93 | @cindex addressing modes, H8/300 |
| 94 | @cindex H8/300 addressing modes |
| 95 | @value{AS} understands the following addressing modes for the H8/300: |
| 96 | @table @code |
| 97 | @item r@var{n} |
| 98 | Register direct |
| 99 | |
| 100 | @item @@r@var{n} |
| 101 | Register indirect |
| 102 | |
| 103 | @need 1200 |
| 104 | @item @@(@var{d}, r@var{n}) |
| 105 | @itemx @@(@var{d}:16, r@var{n}) |
| 106 | @itemx @@(@var{d}:24, r@var{n}) |
| 107 | Register indirect: 16-bit or 24-bit displacement @var{d} from register |
| 108 | @var{n}. (24-bit displacements are only meaningful on the H8/300H.) |
| 109 | |
| 110 | @item @@r@var{n}+ |
| 111 | Register indirect with post-increment |
| 112 | |
| 113 | @item @@-r@var{n} |
| 114 | Register indirect with pre-decrement |
| 115 | |
| 116 | @item @code{@@}@var{aa} |
| 117 | @itemx @code{@@}@var{aa}:8 |
| 118 | @itemx @code{@@}@var{aa}:16 |
| 119 | @itemx @code{@@}@var{aa}:24 |
| 120 | Absolute address @code{aa}. (The address size @samp{:24} only makes |
| 121 | sense on the H8/300H.) |
| 122 | |
| 123 | @item #@var{xx} |
| 124 | @itemx #@var{xx}:8 |
| 125 | @itemx #@var{xx}:16 |
| 126 | @itemx #@var{xx}:32 |
| 127 | Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or |
| 128 | @samp{:32} for clarity, if you wish; but @code{@value{AS}} neither |
| 129 | requires this nor uses it---the data size required is taken from |
| 130 | context. |
| 131 | |
| 132 | @item @code{@@}@code{@@}@var{aa} |
| 133 | @itemx @code{@@}@code{@@}@var{aa}:8 |
| 134 | Memory indirect. You may specify the @samp{:8} for clarity, if you |
| 135 | wish; but @code{@value{AS}} neither requires this nor uses it. |
| 136 | @end table |
| 137 | |
| 138 | @node H8/300 Floating Point |
| 139 | @section Floating Point |
| 140 | |
| 141 | @cindex floating point, H8/300 (@sc{ieee}) |
| 142 | @cindex H8/300 floating point (@sc{ieee}) |
| 143 | The H8/300 family has no hardware floating point, but the @code{.float} |
| 144 | directive generates @sc{ieee} floating-point numbers for compatibility |
| 145 | with other development tools. |
| 146 | |
| 147 | @page |
| 148 | @node H8/300 Directives |
| 149 | @section H8/300 Machine Directives |
| 150 | |
| 151 | @cindex H8/300 machine directives (none) |
| 152 | @cindex machine directives, H8/300 (none) |
| 153 | @cindex @code{word} directive, H8/300 |
| 154 | @cindex @code{int} directive, H8/300 |
| 155 | @code{@value{AS}} has the following machine-dependent directives for |
| 156 | the H8/300: |
| 157 | |
| 158 | @table @code |
| 159 | @cindex H8/300H, assembling for |
| 160 | @item .h8300h |
| 161 | Recognize and emit additional instructions for the H8/300H variant, and |
| 162 | also make @code{.int} emit 32-bit numbers rather than the usual (16-bit) |
| 163 | for the H8/300 family. |
| 164 | |
| 165 | @item .h8300s |
| 166 | Recognize and emit additional instructions for the H8S variant, and |
| 167 | also make @code{.int} emit 32-bit numbers rather than the usual (16-bit) |
| 168 | for the H8/300 family. |
| 169 | |
| 170 | @item .h8300hn |
| 171 | Recognize and emit additional instructions for the H8/300H variant in |
| 172 | normal mode, and also make @code{.int} emit 32-bit numbers rather than |
| 173 | the usual (16-bit) for the H8/300 family. |
| 174 | |
| 175 | @item .h8300sn |
| 176 | Recognize and emit additional instructions for the H8S variant in |
| 177 | normal mode, and also make @code{.int} emit 32-bit numbers rather than |
| 178 | the usual (16-bit) for the H8/300 family. |
| 179 | @end table |
| 180 | |
| 181 | On the H8/300 family (including the H8/300H) @samp{.word} directives |
| 182 | generate 16-bit numbers. |
| 183 | |
| 184 | @node H8/300 Opcodes |
| 185 | @section Opcodes |
| 186 | |
| 187 | @cindex H8/300 opcode summary |
| 188 | @cindex opcode summary, H8/300 |
| 189 | @cindex mnemonics, H8/300 |
| 190 | @cindex instruction summary, H8/300 |
| 191 | For detailed information on the H8/300 machine instruction set, see |
| 192 | @cite{H8/300 Series Programming Manual}. For information specific to |
| 193 | the H8/300H, see @cite{H8/300H Series Programming Manual} (Renesas). |
| 194 | |
| 195 | @code{@value{AS}} implements all the standard H8/300 opcodes. No additional |
| 196 | pseudo-instructions are needed on this family. |
| 197 | |
| 198 | @ifset SMALL |
| 199 | @c this table, due to the multi-col faking and hardcoded order, looks silly |
| 200 | @c except in smallbook. See comments below "@set SMALL" near top of this file. |
| 201 | |
| 202 | The following table summarizes the H8/300 opcodes, and their arguments. |
| 203 | Entries marked @samp{*} are opcodes used only on the H8/300H. |
| 204 | |
| 205 | @smallexample |
| 206 | @c Using @group seems to use the normal baselineskip, not the smallexample |
| 207 | @c baselineskip; looks approx doublespaced. |
| 208 | @i{Legend:} |
| 209 | Rs @r{source register} |
| 210 | Rd @r{destination register} |
| 211 | abs @r{absolute address} |
| 212 | imm @r{immediate data} |
| 213 | disp:N @r{N-bit displacement from a register} |
| 214 | pcrel:N @r{N-bit displacement relative to program counter} |
| 215 | |
| 216 | add.b #imm,rd * andc #imm,ccr |
| 217 | add.b rs,rd band #imm,rd |
| 218 | add.w rs,rd band #imm,@@rd |
| 219 | * add.w #imm,rd band #imm,@@abs:8 |
| 220 | * add.l rs,rd bra pcrel:8 |
| 221 | * add.l #imm,rd * bra pcrel:16 |
| 222 | adds #imm,rd bt pcrel:8 |
| 223 | addx #imm,rd * bt pcrel:16 |
| 224 | addx rs,rd brn pcrel:8 |
| 225 | and.b #imm,rd * brn pcrel:16 |
| 226 | and.b rs,rd bf pcrel:8 |
| 227 | * and.w rs,rd * bf pcrel:16 |
| 228 | * and.w #imm,rd bhi pcrel:8 |
| 229 | * and.l #imm,rd * bhi pcrel:16 |
| 230 | * and.l rs,rd bls pcrel:8 |
| 231 | @page |
| 232 | * bls pcrel:16 bld #imm,rd |
| 233 | bcc pcrel:8 bld #imm,@@rd |
| 234 | * bcc pcrel:16 bld #imm,@@abs:8 |
| 235 | bhs pcrel:8 bnot #imm,rd |
| 236 | * bhs pcrel:16 bnot #imm,@@rd |
| 237 | bcs pcrel:8 bnot #imm,@@abs:8 |
| 238 | * bcs pcrel:16 bnot rs,rd |
| 239 | blo pcrel:8 bnot rs,@@rd |
| 240 | * blo pcrel:16 bnot rs,@@abs:8 |
| 241 | bne pcrel:8 bor #imm,rd |
| 242 | * bne pcrel:16 bor #imm,@@rd |
| 243 | beq pcrel:8 bor #imm,@@abs:8 |
| 244 | * beq pcrel:16 bset #imm,rd |
| 245 | bvc pcrel:8 bset #imm,@@rd |
| 246 | * bvc pcrel:16 bset #imm,@@abs:8 |
| 247 | bvs pcrel:8 bset rs,rd |
| 248 | * bvs pcrel:16 bset rs,@@rd |
| 249 | bpl pcrel:8 bset rs,@@abs:8 |
| 250 | * bpl pcrel:16 bsr pcrel:8 |
| 251 | bmi pcrel:8 bsr pcrel:16 |
| 252 | * bmi pcrel:16 bst #imm,rd |
| 253 | bge pcrel:8 bst #imm,@@rd |
| 254 | * bge pcrel:16 bst #imm,@@abs:8 |
| 255 | blt pcrel:8 btst #imm,rd |
| 256 | * blt pcrel:16 btst #imm,@@rd |
| 257 | bgt pcrel:8 btst #imm,@@abs:8 |
| 258 | * bgt pcrel:16 btst rs,rd |
| 259 | ble pcrel:8 btst rs,@@rd |
| 260 | * ble pcrel:16 btst rs,@@abs:8 |
| 261 | bclr #imm,rd bxor #imm,rd |
| 262 | bclr #imm,@@rd bxor #imm,@@rd |
| 263 | bclr #imm,@@abs:8 bxor #imm,@@abs:8 |
| 264 | bclr rs,rd cmp.b #imm,rd |
| 265 | bclr rs,@@rd cmp.b rs,rd |
| 266 | bclr rs,@@abs:8 cmp.w rs,rd |
| 267 | biand #imm,rd cmp.w rs,rd |
| 268 | biand #imm,@@rd * cmp.w #imm,rd |
| 269 | biand #imm,@@abs:8 * cmp.l #imm,rd |
| 270 | bild #imm,rd * cmp.l rs,rd |
| 271 | bild #imm,@@rd daa rs |
| 272 | bild #imm,@@abs:8 das rs |
| 273 | bior #imm,rd dec.b rs |
| 274 | bior #imm,@@rd * dec.w #imm,rd |
| 275 | bior #imm,@@abs:8 * dec.l #imm,rd |
| 276 | bist #imm,rd divxu.b rs,rd |
| 277 | bist #imm,@@rd * divxu.w rs,rd |
| 278 | bist #imm,@@abs:8 * divxs.b rs,rd |
| 279 | bixor #imm,rd * divxs.w rs,rd |
| 280 | bixor #imm,@@rd eepmov |
| 281 | bixor #imm,@@abs:8 * eepmovw |
| 282 | @page |
| 283 | * exts.w rd mov.w rs,@@abs:16 |
| 284 | * exts.l rd * mov.l #imm,rd |
| 285 | * extu.w rd * mov.l rs,rd |
| 286 | * extu.l rd * mov.l @@rs,rd |
| 287 | inc rs * mov.l @@(disp:16,rs),rd |
| 288 | * inc.w #imm,rd * mov.l @@(disp:24,rs),rd |
| 289 | * inc.l #imm,rd * mov.l @@rs+,rd |
| 290 | jmp @@rs * mov.l @@abs:16,rd |
| 291 | jmp abs * mov.l @@abs:24,rd |
| 292 | jmp @@@@abs:8 * mov.l rs,@@rd |
| 293 | jsr @@rs * mov.l rs,@@(disp:16,rd) |
| 294 | jsr abs * mov.l rs,@@(disp:24,rd) |
| 295 | jsr @@@@abs:8 * mov.l rs,@@-rd |
| 296 | ldc #imm,ccr * mov.l rs,@@abs:16 |
| 297 | ldc rs,ccr * mov.l rs,@@abs:24 |
| 298 | * ldc @@abs:16,ccr movfpe @@abs:16,rd |
| 299 | * ldc @@abs:24,ccr movtpe rs,@@abs:16 |
| 300 | * ldc @@(disp:16,rs),ccr mulxu.b rs,rd |
| 301 | * ldc @@(disp:24,rs),ccr * mulxu.w rs,rd |
| 302 | * ldc @@rs+,ccr * mulxs.b rs,rd |
| 303 | * ldc @@rs,ccr * mulxs.w rs,rd |
| 304 | * mov.b @@(disp:24,rs),rd neg.b rs |
| 305 | * mov.b rs,@@(disp:24,rd) * neg.w rs |
| 306 | mov.b @@abs:16,rd * neg.l rs |
| 307 | mov.b rs,rd nop |
| 308 | mov.b @@abs:8,rd not.b rs |
| 309 | mov.b rs,@@abs:8 * not.w rs |
| 310 | mov.b rs,rd * not.l rs |
| 311 | mov.b #imm,rd or.b #imm,rd |
| 312 | mov.b @@rs,rd or.b rs,rd |
| 313 | mov.b @@(disp:16,rs),rd * or.w #imm,rd |
| 314 | mov.b @@rs+,rd * or.w rs,rd |
| 315 | mov.b @@abs:8,rd * or.l #imm,rd |
| 316 | mov.b rs,@@rd * or.l rs,rd |
| 317 | mov.b rs,@@(disp:16,rd) orc #imm,ccr |
| 318 | mov.b rs,@@-rd pop.w rs |
| 319 | mov.b rs,@@abs:8 * pop.l rs |
| 320 | mov.w rs,@@rd push.w rs |
| 321 | * mov.w @@(disp:24,rs),rd * push.l rs |
| 322 | * mov.w rs,@@(disp:24,rd) rotl.b rs |
| 323 | * mov.w @@abs:24,rd * rotl.w rs |
| 324 | * mov.w rs,@@abs:24 * rotl.l rs |
| 325 | mov.w rs,rd rotr.b rs |
| 326 | mov.w #imm,rd * rotr.w rs |
| 327 | mov.w @@rs,rd * rotr.l rs |
| 328 | mov.w @@(disp:16,rs),rd rotxl.b rs |
| 329 | mov.w @@rs+,rd * rotxl.w rs |
| 330 | mov.w @@abs:16,rd * rotxl.l rs |
| 331 | mov.w rs,@@(disp:16,rd) rotxr.b rs |
| 332 | mov.w rs,@@-rd * rotxr.w rs |
| 333 | @page |
| 334 | * rotxr.l rs * stc ccr,@@(disp:24,rd) |
| 335 | bpt * stc ccr,@@-rd |
| 336 | rte * stc ccr,@@abs:16 |
| 337 | rts * stc ccr,@@abs:24 |
| 338 | shal.b rs sub.b rs,rd |
| 339 | * shal.w rs sub.w rs,rd |
| 340 | * shal.l rs * sub.w #imm,rd |
| 341 | shar.b rs * sub.l rs,rd |
| 342 | * shar.w rs * sub.l #imm,rd |
| 343 | * shar.l rs subs #imm,rd |
| 344 | shll.b rs subx #imm,rd |
| 345 | * shll.w rs subx rs,rd |
| 346 | * shll.l rs * trapa #imm |
| 347 | shlr.b rs xor #imm,rd |
| 348 | * shlr.w rs xor rs,rd |
| 349 | * shlr.l rs * xor.w #imm,rd |
| 350 | sleep * xor.w rs,rd |
| 351 | stc ccr,rd * xor.l #imm,rd |
| 352 | * stc ccr,@@rs * xor.l rs,rd |
| 353 | * stc ccr,@@(disp:16,rd) xorc #imm,ccr |
| 354 | @end smallexample |
| 355 | @end ifset |
| 356 | |
| 357 | @cindex size suffixes, H8/300 |
| 358 | @cindex H8/300 size suffixes |
| 359 | Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov}, |
| 360 | @code{sub}) are defined with variants using the suffixes @samp{.b}, |
| 361 | @samp{.w}, and @samp{.l} to specify the size of a memory operand. |
| 362 | @code{@value{AS}} supports these suffixes, but does not require them; |
| 363 | since one of the operands is always a register, @code{@value{AS}} can |
| 364 | deduce the correct size. |
| 365 | |
| 366 | For example, since @code{r0} refers to a 16-bit register, |
| 367 | @example |
| 368 | mov r0,@@foo |
| 369 | @exdent is equivalent to |
| 370 | mov.w r0,@@foo |
| 371 | @end example |
| 372 | |
| 373 | If you use the size suffixes, @code{@value{AS}} issues a warning when |
| 374 | the suffix and the register size do not match. |