S12Z-Addressing-Modes.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: S12Z Addressing Modes</title>
  15. <meta name="description" content="Using as: S12Z Addressing Modes">
  16. <meta name="keywords" content="Using as: S12Z Addressing Modes">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="S12Z-Syntax.html#S12Z-Syntax" rel="up" title="S12Z Syntax">
  25. <link href="S12Z-Register-Notation.html#S12Z-Register-Notation" rel="next" title="S12Z Register Notation">
  26. <link href="S12Z-Syntax-Overview.html#S12Z-Syntax-Overview" rel="previous" title="S12Z Syntax Overview">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="S12Z-Addressing-Modes"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="S12Z-Register-Notation.html#S12Z-Register-Notation" accesskey="n" rel="next">S12Z Register Notation</a>, Previous: <a href="S12Z-Syntax-Overview.html#S12Z-Syntax-Overview" accesskey="p" rel="previous">S12Z Syntax Overview</a>, Up: <a href="S12Z-Syntax.html#S12Z-Syntax" accesskey="u" rel="up">S12Z Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Addressing-Modes-3"></a>
  64. <h4 class="subsubsection">9.24.2.2 Addressing Modes</h4>
  65. <a name="index-S12Z-addressing-modes"></a>
  66. <a name="index-addressing-modes_002c-S12Z"></a>
  67. <p>The following addressing modes are understood for the S12Z.
  68. </p><dl compact="compact">
  69. <dt><em>Immediate</em></dt>
  70. <dd><p>&lsquo;<samp>#<var>number</var></samp>&rsquo;
  71. </p>
  72. </dd>
  73. <dt><em>Immediate Bit Field</em></dt>
  74. <dd><p>&lsquo;<samp>#<var>width</var>:<var>offset</var></samp>&rsquo;
  75. </p>
  76. <p>Bit field instructions in the immediate mode require the width and offset to
  77. be specified.
  78. The <var>width</var> parameter specifies the number of bits in the field.
  79. It should be a number in the range [1,32].
  80. <var>Offset</var> determines the position within the field where the operation
  81. should start.
  82. It should be a number in the range [0,31].
  83. </p>
  84. </dd>
  85. <dt><em>Relative</em></dt>
  86. <dd><p>&lsquo;<samp>*<var>symbol</var></samp>&rsquo;, or &lsquo;<samp>*[+-]<var>digits</var></samp>&rsquo;
  87. </p>
  88. <p>Program counter relative addresses have a width of 15 bits.
  89. Thus, they must be within the range [-32768, 32767].
  90. </p>
  91. </dd>
  92. <dt><em>Register</em></dt>
  93. <dd><p>&lsquo;<samp><var>reg</var></samp>&rsquo;
  94. </p>
  95. <a name="index-register-names_002c-S12Z"></a>
  96. <p>Some instructions accept a register as an operand.
  97. In general, <var>reg</var> may be a
  98. data register (&lsquo;<samp>D0</samp>&rsquo;, &lsquo;<samp>D1</samp>&rsquo; &hellip; &lsquo;<samp>D7</samp>&rsquo;),
  99. the &lsquo;<samp>X</samp>&rsquo; register or the &lsquo;<samp>Y</samp>&rsquo; register.
  100. </p>
  101. <p>A few instructions accept as an argument the stack pointer
  102. register (&lsquo;<samp>S</samp>&rsquo;), and/or the program counter (&lsquo;<samp>P</samp>&rsquo;).
  103. </p>
  104. <p>Some very special instructions accept arguments which refer to the
  105. condition code register. For these arguments the syntax is
  106. &lsquo;<samp>CCR</samp>&rsquo;, &lsquo;<samp>CCH</samp>&rsquo; or &lsquo;<samp>CCL</samp>&rsquo; which refer to the complete
  107. condition code register, the condition code register high byte
  108. and the condition code register low byte respectively.
  109. </p>
  110. </dd>
  111. <dt><em>Absolute Direct</em></dt>
  112. <dd><p>&lsquo;<samp><var>symbol</var></samp>&rsquo;, or &lsquo;<samp><var>digits</var></samp>&rsquo;
  113. </p>
  114. </dd>
  115. <dt><em>Absolute Indirect</em></dt>
  116. <dd><p>&lsquo;<samp>[<var>symbol</var></samp>&rsquo;, or &lsquo;<samp><var>digits</var>]</samp>&rsquo;
  117. </p>
  118. </dd>
  119. <dt><em>Constant Offset Indexed</em></dt>
  120. <dd><p>&lsquo;<samp>(<var>number</var>,<var>reg</var>)</samp>&rsquo;
  121. </p>
  122. <p><var>Reg</var> may be either &lsquo;<samp>X</samp>&rsquo;, &lsquo;<samp>Y</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo; or
  123. &lsquo;<samp>P</samp>&rsquo; or one of the data registers &lsquo;<samp>D0</samp>&rsquo;, &lsquo;<samp>D1</samp>&rsquo; &hellip;
  124. &lsquo;<samp>D7</samp>&rsquo;.
  125. If any of the registers &lsquo;<samp>D2</samp>&rsquo; &hellip; &lsquo;<samp>D5</samp>&rsquo; are specified, then the
  126. register value is treated as a signed value.
  127. Otherwise it is treated as unsigned.
  128. <var>Number</var> may be any integer in the range [-8388608,8388607].
  129. </p>
  130. </dd>
  131. <dt><em>Offset Indexed Indirect</em></dt>
  132. <dd><p>&lsquo;<samp>[<var>number</var>,<var>reg</var>]</samp>&rsquo;
  133. </p>
  134. <p><var>Reg</var> may be either &lsquo;<samp>X</samp>&rsquo;, &lsquo;<samp>Y</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo; or
  135. &lsquo;<samp>P</samp>&rsquo;.
  136. <var>Number</var> may be any integer in the range [-8388608,8388607].
  137. </p>
  138. </dd>
  139. <dt><em>Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement</em></dt>
  140. <dd><p>&lsquo;<samp>-<var>reg</var></samp>&rsquo;,
  141. &lsquo;<samp>+<var>reg</var></samp>&rsquo;,
  142. &lsquo;<samp><var>reg</var>-</samp>&rsquo; or
  143. &lsquo;<samp><var>reg</var>+</samp>&rsquo;
  144. </p>
  145. <p>This addressing mode is typically used to access a value at an address,
  146. and simultaneously to increment/decrement the register pointing to that
  147. address.
  148. Thus <var>reg</var> may be any of the 24 bit registers &lsquo;<samp>X</samp>&rsquo;, &lsquo;<samp>Y</samp>&rsquo;, or
  149. &lsquo;<samp>S</samp>&rsquo;.
  150. Pre-increment and post-decrement are not available for
  151. register &lsquo;<samp>S</samp>&rsquo; (only post-increment and pre-decrement are available).
  152. </p>
  153. </dd>
  154. <dt><em>Register Offset Direct</em></dt>
  155. <dd><p>&lsquo;<samp>(<var>data-reg</var>,<var>reg</var>)</samp>&rsquo;
  156. </p>
  157. <p><var>Reg</var> can be either &lsquo;<samp>X</samp>&rsquo;, &lsquo;<samp>Y</samp>&rsquo;, or &lsquo;<samp>S</samp>&rsquo;.
  158. <var>Data-reg</var>
  159. must be one of the data registers &lsquo;<samp>D0</samp>&rsquo;, &lsquo;<samp>D1</samp>&rsquo; &hellip; &lsquo;<samp>D7</samp>&rsquo;.
  160. If any of the registers &lsquo;<samp>D2</samp>&rsquo; &hellip; &lsquo;<samp>D5</samp>&rsquo; are specified, then
  161. the register value is treated as a signed value.
  162. Otherwise it is treated as unsigned.
  163. </p>
  164. </dd>
  165. <dt><em>Register Offset Indirect</em></dt>
  166. <dd><p>&lsquo;<samp>[<var>data-reg</var>,<var>reg</var>]</samp>&rsquo;
  167. </p>
  168. <p><var>Reg</var> can be either &lsquo;<samp>X</samp>&rsquo; or &lsquo;<samp>Y</samp>&rsquo;.
  169. <var>Data-reg</var>
  170. must be one of the data registers &lsquo;<samp>D0</samp>&rsquo;, &lsquo;<samp>D1</samp>&rsquo; &hellip; &lsquo;<samp>D7</samp>&rsquo;.
  171. If any of the registers &lsquo;<samp>D2</samp>&rsquo; &hellip; &lsquo;<samp>D5</samp>&rsquo; are specified, then
  172. the register value is treated as a signed value.
  173. Otherwise it is treated as unsigned.
  174. </p></dd>
  175. </dl>
  176. <p>For example:
  177. </p>
  178. <div class="smallexample">
  179. <pre class="smallexample"> trap #197 ;; Immediate mode
  180. bra *+49 ;; Relative mode
  181. bra .L0 ;; ditto
  182. jmp 0xFE0034 ;; Absolute direct mode
  183. jmp [0xFD0012] ;; Absolute indirect mode
  184. inc.b (4,x) ;; Constant offset indexed mode
  185. jsr (45, d0) ;; ditto
  186. dec.w [4,y] ;; Constant offset indexed indirect mode
  187. clr.p (-s) ;; Pre-decrement mode
  188. neg.l (d0, s) ;; Register offset direct mode
  189. com.b [d1, x] ;; Register offset indirect mode
  190. psh cch ;; Register mode
  191. </pre></div>
  192. <hr>
  193. <div class="header">
  194. <p>
  195. Next: <a href="S12Z-Register-Notation.html#S12Z-Register-Notation" accesskey="n" rel="next">S12Z Register Notation</a>, Previous: <a href="S12Z-Syntax-Overview.html#S12Z-Syntax-Overview" accesskey="p" rel="previous">S12Z Syntax Overview</a>, Up: <a href="S12Z-Syntax.html#S12Z-Syntax" accesskey="u" rel="up">S12Z Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  196. </div>
  197. </body>
  198. </html>