c-m68hc11.texi 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. @c Copyright (C) 1991-2015 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. @node M68HC11-Dependent
  7. @chapter M68HC11 and M68HC12 Dependent Features
  8. @end ifset
  9. @ifclear GENERIC
  10. @node Machine Dependencies
  11. @chapter M68HC11 and M68HC12 Dependent Features
  12. @end ifclear
  13. @cindex M68HC11 and M68HC12 support
  14. @menu
  15. * M68HC11-Opts:: M68HC11 and M68HC12 Options
  16. * M68HC11-Syntax:: Syntax
  17. * M68HC11-Modifiers:: Symbolic Operand Modifiers
  18. * M68HC11-Directives:: Assembler Directives
  19. * M68HC11-Float:: Floating Point
  20. * M68HC11-opcodes:: Opcodes
  21. @end menu
  22. @node M68HC11-Opts
  23. @section M68HC11 and M68HC12 Options
  24. @cindex options, M68HC11
  25. @cindex M68HC11 options
  26. The Motorola 68HC11 and 68HC12 version of @code{@value{AS}} have a few machine
  27. dependent options.
  28. @table @code
  29. @cindex @samp{-m68hc11}
  30. @item -m68hc11
  31. This option switches the assembler into the M68HC11 mode. In this mode,
  32. the assembler only accepts 68HC11 operands and mnemonics. It produces
  33. code for the 68HC11.
  34. @cindex @samp{-m68hc12}
  35. @item -m68hc12
  36. This option switches the assembler into the M68HC12 mode. In this mode,
  37. the assembler also accepts 68HC12 operands and mnemonics. It produces
  38. code for the 68HC12. A few 68HC11 instructions are replaced by
  39. some 68HC12 instructions as recommended by Motorola specifications.
  40. @cindex @samp{-m68hcs12}
  41. @item -m68hcs12
  42. This option switches the assembler into the M68HCS12 mode. This mode is
  43. similar to @samp{-m68hc12} but specifies to assemble for the 68HCS12
  44. series. The only difference is on the assembling of the @samp{movb}
  45. and @samp{movw} instruction when a PC-relative operand is used.
  46. @cindex @samp{-mm9s12x}
  47. @item -mm9s12x
  48. This option switches the assembler into the M9S12X mode. This mode is
  49. similar to @samp{-m68hc12} but specifies to assemble for the S12X
  50. series which is a superset of the HCS12.
  51. @cindex @samp{-mm9s12xg}
  52. @item -mm9s12xg
  53. This option switches the assembler into the XGATE mode for the RISC
  54. co-processor featured on some S12X-family chips.
  55. @cindex @samp{--xgate-ramoffset}
  56. @item --xgate-ramoffset
  57. This option instructs the linker to offset RAM addresses from S12X address
  58. space into XGATE address space.
  59. @cindex @samp{-mshort}
  60. @item -mshort
  61. This option controls the ABI and indicates to use a 16-bit integer ABI.
  62. It has no effect on the assembled instructions.
  63. This is the default.
  64. @cindex @samp{-mlong}
  65. @item -mlong
  66. This option controls the ABI and indicates to use a 32-bit integer ABI.
  67. @cindex @samp{-mshort-double}
  68. @item -mshort-double
  69. This option controls the ABI and indicates to use a 32-bit float ABI.
  70. This is the default.
  71. @cindex @samp{-mlong-double}
  72. @item -mlong-double
  73. This option controls the ABI and indicates to use a 64-bit float ABI.
  74. @cindex @samp{--strict-direct-mode}
  75. @item --strict-direct-mode
  76. You can use the @samp{--strict-direct-mode} option to disable
  77. the automatic translation of direct page mode addressing into
  78. extended mode when the instruction does not support direct mode.
  79. For example, the @samp{clr} instruction does not support direct page
  80. mode addressing. When it is used with the direct page mode,
  81. @code{@value{AS}} will ignore it and generate an absolute addressing.
  82. This option prevents @code{@value{AS}} from doing this, and the wrong
  83. usage of the direct page mode will raise an error.
  84. @cindex @samp{--short-branches}
  85. @item --short-branches
  86. The @samp{--short-branches} option turns off the translation of
  87. relative branches into absolute branches when the branch offset is
  88. out of range. By default @code{@value{AS}} transforms the relative
  89. branch (@samp{bsr}, @samp{bgt}, @samp{bge}, @samp{beq}, @samp{bne},
  90. @samp{ble}, @samp{blt}, @samp{bhi}, @samp{bcc}, @samp{bls},
  91. @samp{bcs}, @samp{bmi}, @samp{bvs}, @samp{bvs}, @samp{bra}) into
  92. an absolute branch when the offset is out of the -128 .. 127 range.
  93. In that case, the @samp{bsr} instruction is translated into a
  94. @samp{jsr}, the @samp{bra} instruction is translated into a
  95. @samp{jmp} and the conditional branches instructions are inverted and
  96. followed by a @samp{jmp}. This option disables these translations
  97. and @code{@value{AS}} will generate an error if a relative branch
  98. is out of range. This option does not affect the optimization
  99. associated to the @samp{jbra}, @samp{jbsr} and @samp{jbXX} pseudo opcodes.
  100. @cindex @samp{--force-long-branches}
  101. @item --force-long-branches
  102. The @samp{--force-long-branches} option forces the translation of
  103. relative branches into absolute branches. This option does not affect
  104. the optimization associated to the @samp{jbra}, @samp{jbsr} and
  105. @samp{jbXX} pseudo opcodes.
  106. @cindex @samp{--print-insn-syntax}
  107. @item --print-insn-syntax
  108. You can use the @samp{--print-insn-syntax} option to obtain the
  109. syntax description of the instruction when an error is detected.
  110. @cindex @samp{--print-opcodes}
  111. @item --print-opcodes
  112. The @samp{--print-opcodes} option prints the list of all the
  113. instructions with their syntax. The first item of each line
  114. represents the instruction name and the rest of the line indicates
  115. the possible operands for that instruction. The list is printed
  116. in alphabetical order. Once the list is printed @code{@value{AS}}
  117. exits.
  118. @cindex @samp{--generate-example}
  119. @item --generate-example
  120. The @samp{--generate-example} option is similar to @samp{--print-opcodes}
  121. but it generates an example for each instruction instead.
  122. @end table
  123. @node M68HC11-Syntax
  124. @section Syntax
  125. @cindex M68HC11 syntax
  126. @cindex syntax, M68HC11
  127. In the M68HC11 syntax, the instruction name comes first and it may
  128. be followed by one or several operands (up to three). Operands are
  129. separated by comma (@samp{,}). In the normal mode,
  130. @code{@value{AS}} will complain if too many operands are specified for
  131. a given instruction. In the MRI mode (turned on with @samp{-M} option),
  132. it will treat them as comments. Example:
  133. @smallexample
  134. inx
  135. lda #23
  136. bset 2,x #4
  137. brclr *bot #8 foo
  138. @end smallexample
  139. @cindex line comment character, M68HC11
  140. @cindex M68HC11 line comment character
  141. The presence of a @samp{;} character or a @samp{!} character anywhere
  142. on a line indicates the start of a comment that extends to the end of
  143. that line.
  144. A @samp{*} or a @samp{#} character at the start of a line also
  145. introduces a line comment, but these characters do not work elsewhere
  146. on the line. If the first character of the line is a @samp{#} then as
  147. well as starting a comment, the line could also be logical line number
  148. directive (@pxref{Comments}) or a preprocessor control command
  149. (@pxref{Preprocessing}).
  150. @cindex line separator, M68HC11
  151. @cindex statement separator, M68HC11
  152. @cindex M68HC11 line separator
  153. The M68HC11 assembler does not currently support a line separator
  154. character.
  155. @cindex M68HC11 addressing modes
  156. @cindex addressing modes, M68HC11
  157. The following addressing modes are understood for 68HC11 and 68HC12:
  158. @table @dfn
  159. @item Immediate
  160. @samp{#@var{number}}
  161. @item Address Register
  162. @samp{@var{number},X}, @samp{@var{number},Y}
  163. The @var{number} may be omitted in which case 0 is assumed.
  164. @item Direct Addressing mode
  165. @samp{*@var{symbol}}, or @samp{*@var{digits}}
  166. @item Absolute
  167. @samp{@var{symbol}}, or @samp{@var{digits}}
  168. @end table
  169. The M68HC12 has other more complex addressing modes. All of them
  170. are supported and they are represented below:
  171. @table @dfn
  172. @item Constant Offset Indexed Addressing Mode
  173. @samp{@var{number},@var{reg}}
  174. The @var{number} may be omitted in which case 0 is assumed.
  175. The register can be either @samp{X}, @samp{Y}, @samp{SP} or
  176. @samp{PC}. The assembler will use the smaller post-byte definition
  177. according to the constant value (5-bit constant offset, 9-bit constant
  178. offset or 16-bit constant offset). If the constant is not known by
  179. the assembler it will use the 16-bit constant offset post-byte and the value
  180. will be resolved at link time.
  181. @item Offset Indexed Indirect
  182. @samp{[@var{number},@var{reg}]}
  183. The register can be either @samp{X}, @samp{Y}, @samp{SP} or @samp{PC}.
  184. @item Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement
  185. @samp{@var{number},-@var{reg}}
  186. @samp{@var{number},+@var{reg}}
  187. @samp{@var{number},@var{reg}-}
  188. @samp{@var{number},@var{reg}+}
  189. The number must be in the range @samp{-8}..@samp{+8} and must not be 0.
  190. The register can be either @samp{X}, @samp{Y}, @samp{SP} or @samp{PC}.
  191. @item Accumulator Offset
  192. @samp{@var{acc},@var{reg}}
  193. The accumulator register can be either @samp{A}, @samp{B} or @samp{D}.
  194. The register can be either @samp{X}, @samp{Y}, @samp{SP} or @samp{PC}.
  195. @item Accumulator D offset indexed-indirect
  196. @samp{[D,@var{reg}]}
  197. The register can be either @samp{X}, @samp{Y}, @samp{SP} or @samp{PC}.
  198. @end table
  199. For example:
  200. @smallexample
  201. ldab 1024,sp
  202. ldd [10,x]
  203. orab 3,+x
  204. stab -2,y-
  205. ldx a,pc
  206. sty [d,sp]
  207. @end smallexample
  208. @node M68HC11-Modifiers
  209. @section Symbolic Operand Modifiers
  210. @cindex M68HC11 modifiers
  211. @cindex syntax, M68HC11
  212. The assembler supports several modifiers when using symbol addresses
  213. in 68HC11 and 68HC12 instruction operands. The general syntax is
  214. the following:
  215. @smallexample
  216. %modifier(symbol)
  217. @end smallexample
  218. @table @code
  219. @cindex symbol modifiers
  220. @item %addr
  221. This modifier indicates to the assembler and linker to use
  222. the 16-bit physical address corresponding to the symbol. This is intended
  223. to be used on memory window systems to map a symbol in the memory bank window.
  224. If the symbol is in a memory expansion part, the physical address
  225. corresponds to the symbol address within the memory bank window.
  226. If the symbol is not in a memory expansion part, this is the symbol address
  227. (using or not using the %addr modifier has no effect in that case).
  228. @item %page
  229. This modifier indicates to use the memory page number corresponding
  230. to the symbol. If the symbol is in a memory expansion part, its page
  231. number is computed by the linker as a number used to map the page containing
  232. the symbol in the memory bank window. If the symbol is not in a memory
  233. expansion part, the page number is 0.
  234. @item %hi
  235. This modifier indicates to use the 8-bit high part of the physical
  236. address of the symbol.
  237. @item %lo
  238. This modifier indicates to use the 8-bit low part of the physical
  239. address of the symbol.
  240. @end table
  241. For example a 68HC12 call to a function @samp{foo_example} stored in memory
  242. expansion part could be written as follows:
  243. @smallexample
  244. call %addr(foo_example),%page(foo_example)
  245. @end smallexample
  246. and this is equivalent to
  247. @smallexample
  248. call foo_example
  249. @end smallexample
  250. And for 68HC11 it could be written as follows:
  251. @smallexample
  252. ldab #%page(foo_example)
  253. stab _page_switch
  254. jsr %addr(foo_example)
  255. @end smallexample
  256. @node M68HC11-Directives
  257. @section Assembler Directives
  258. @cindex assembler directives, M68HC11
  259. @cindex assembler directives, M68HC12
  260. @cindex M68HC11 assembler directives
  261. @cindex M68HC12 assembler directives
  262. The 68HC11 and 68HC12 version of @code{@value{AS}} have the following
  263. specific assembler directives:
  264. @table @code
  265. @item .relax
  266. @cindex assembler directive .relax, M68HC11
  267. @cindex M68HC11 assembler directive .relax
  268. The relax directive is used by the @samp{GNU Compiler} to emit a specific
  269. relocation to mark a group of instructions for linker relaxation.
  270. The sequence of instructions within the group must be known to the linker
  271. so that relaxation can be performed.
  272. @item .mode [mshort|mlong|mshort-double|mlong-double]
  273. @cindex assembler directive .mode, M68HC11
  274. @cindex M68HC11 assembler directive .mode
  275. This directive specifies the ABI. It overrides the @samp{-mshort},
  276. @samp{-mlong}, @samp{-mshort-double} and @samp{-mlong-double} options.
  277. @item .far @var{symbol}
  278. @cindex assembler directive .far, M68HC11
  279. @cindex M68HC11 assembler directive .far
  280. This directive marks the symbol as a @samp{far} symbol meaning that it
  281. uses a @samp{call/rtc} calling convention as opposed to @samp{jsr/rts}.
  282. During a final link, the linker will identify references to the @samp{far}
  283. symbol and will verify the proper calling convention.
  284. @item .interrupt @var{symbol}
  285. @cindex assembler directive .interrupt, M68HC11
  286. @cindex M68HC11 assembler directive .interrupt
  287. This directive marks the symbol as an interrupt entry point.
  288. This information is then used by the debugger to correctly unwind the
  289. frame across interrupts.
  290. @item .xrefb @var{symbol}
  291. @cindex assembler directive .xrefb, M68HC11
  292. @cindex M68HC11 assembler directive .xrefb
  293. This directive is defined for compatibility with the
  294. @samp{Specification for Motorola 8 and 16-Bit Assembly Language Input
  295. Standard} and is ignored.
  296. @end table
  297. @node M68HC11-Float
  298. @section Floating Point
  299. @cindex floating point, M68HC11
  300. @cindex M68HC11 floating point
  301. Packed decimal (P) format floating literals are not supported.
  302. Feel free to add the code!
  303. The floating point formats generated by directives are these.
  304. @table @code
  305. @cindex @code{float} directive, M68HC11
  306. @item .float
  307. @code{Single} precision floating point constants.
  308. @cindex @code{double} directive, M68HC11
  309. @item .double
  310. @code{Double} precision floating point constants.
  311. @cindex @code{extend} directive M68HC11
  312. @cindex @code{ldouble} directive M68HC11
  313. @item .extend
  314. @itemx .ldouble
  315. @code{Extended} precision (@code{long double}) floating point constants.
  316. @end table
  317. @need 2000
  318. @node M68HC11-opcodes
  319. @section Opcodes
  320. @cindex M68HC11 opcodes
  321. @cindex opcodes, M68HC11
  322. @cindex instruction set, M68HC11
  323. @menu
  324. * M68HC11-Branch:: Branch Improvement
  325. @end menu
  326. @node M68HC11-Branch
  327. @subsection Branch Improvement
  328. @cindex pseudo-opcodes, M68HC11
  329. @cindex M68HC11 pseudo-opcodes
  330. @cindex branch improvement, M68HC11
  331. @cindex M68HC11 branch improvement
  332. Certain pseudo opcodes are permitted for branch instructions.
  333. They expand to the shortest branch instruction that reach the
  334. target. Generally these mnemonics are made by prepending @samp{j} to
  335. the start of Motorola mnemonic. These pseudo opcodes are not affected
  336. by the @samp{--short-branches} or @samp{--force-long-branches} options.
  337. The following table summarizes the pseudo-operations.
  338. @smallexample
  339. Displacement Width
  340. +-------------------------------------------------------------+
  341. | Options |
  342. | --short-branches --force-long-branches |
  343. +--------------------------+----------------------------------+
  344. Op |BYTE WORD | BYTE WORD |
  345. +--------------------------+----------------------------------+
  346. bsr | bsr <pc-rel> <error> | jsr <abs> |
  347. bra | bra <pc-rel> <error> | jmp <abs> |
  348. jbsr | bsr <pc-rel> jsr <abs> | bsr <pc-rel> jsr <abs> |
  349. jbra | bra <pc-rel> jmp <abs> | bra <pc-rel> jmp <abs> |
  350. bXX | bXX <pc-rel> <error> | bNX +3; jmp <abs> |
  351. jbXX | bXX <pc-rel> bNX +3; | bXX <pc-rel> bNX +3; jmp <abs> |
  352. | jmp <abs> | |
  353. +--------------------------+----------------------------------+
  354. XX: condition
  355. NX: negative of condition XX
  356. @end smallexample
  357. @table @code
  358. @item jbsr
  359. @itemx jbra
  360. These are the simplest jump pseudo-operations; they always map to one
  361. particular machine instruction, depending on the displacement to the
  362. branch target.
  363. @item jb@var{XX}
  364. Here, @samp{jb@var{XX}} stands for an entire family of pseudo-operations,
  365. where @var{XX} is a conditional branch or condition-code test. The full
  366. list of pseudo-ops in this family is:
  367. @smallexample
  368. jbcc jbeq jbge jbgt jbhi jbvs jbpl jblo
  369. jbcs jbne jblt jble jbls jbvc jbmi
  370. @end smallexample
  371. For the cases of non-PC relative displacements and long displacements,
  372. @code{@value{AS}} issues a longer code fragment in terms of
  373. @var{NX}, the opposite condition to @var{XX}. For example, for the
  374. non-PC relative case:
  375. @smallexample
  376. jb@var{XX} foo
  377. @end smallexample
  378. gives
  379. @smallexample
  380. b@var{NX}s oof
  381. jmp foo
  382. oof:
  383. @end smallexample
  384. @end table