M68K_002dBranch.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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-2017 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.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: M68K-Branch</title>
  15. <meta name="description" content="Using as: M68K-Branch">
  16. <meta name="keywords" content="Using as: M68K-Branch">
  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="M68K_002dopcodes.html#M68K_002dopcodes" rel="up" title="M68K-opcodes">
  25. <link href="M68K_002dChars.html#M68K_002dChars" rel="next" title="M68K-Chars">
  26. <link href="M68K_002dopcodes.html#M68K_002dopcodes" rel="prev" title="M68K-opcodes">
  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="M68K_002dBranch"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="M68K_002dChars.html#M68K_002dChars" accesskey="n" rel="next">M68K-Chars</a>, Up: <a href="M68K_002dopcodes.html#M68K_002dopcodes" accesskey="u" rel="up">M68K-opcodes</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="Branch-Improvement"></a>
  64. <h4 class="subsubsection">9.23.6.1 Branch Improvement</h4>
  65. <a name="index-pseudo_002dopcodes_002c-M680x0"></a>
  66. <a name="index-M680x0-pseudo_002dopcodes"></a>
  67. <a name="index-branch-improvement_002c-M680x0"></a>
  68. <a name="index-M680x0-branch-improvement"></a>
  69. <p>Certain pseudo opcodes are permitted for branch instructions.
  70. They expand to the shortest branch instruction that reach the
  71. target. Generally these mnemonics are made by substituting &lsquo;<samp>j</samp>&rsquo; for
  72. &lsquo;<samp>b</samp>&rsquo; at the start of a Motorola mnemonic.
  73. </p>
  74. <p>The following table summarizes the pseudo-operations. A <code>*</code> flags
  75. cases that are more fully described after the table:
  76. </p>
  77. <div class="smallexample">
  78. <pre class="smallexample"> Displacement
  79. +------------------------------------------------------------
  80. | 68020 68000/10, not PC-relative OK
  81. Pseudo-Op |BYTE WORD LONG ABSOLUTE LONG JUMP **
  82. +------------------------------------------------------------
  83. jbsr |bsrs bsrw bsrl jsr
  84. jra |bras braw bral jmp
  85. * jXX |bXXs bXXw bXXl bNXs;jmp
  86. * dbXX | N/A dbXXw dbXX;bras;bral dbXX;bras;jmp
  87. fjXX | N/A fbXXw fbXXl N/A
  88. XX: condition
  89. NX: negative of condition XX
  90. </pre></div>
  91. <div align="center"><code>*</code>&mdash;see full description below
  92. </div><div align="center"><code>**</code>&mdash;this expansion mode is disallowed by &lsquo;<samp>--pcrel</samp>&rsquo;
  93. </div>
  94. <dl compact="compact">
  95. <dt><code>jbsr</code></dt>
  96. <dt><code>jra</code></dt>
  97. <dd><p>These are the simplest jump pseudo-operations; they always map to one
  98. particular machine instruction, depending on the displacement to the
  99. branch target. This instruction will be a byte or word branch is that
  100. is sufficient. Otherwise, a long branch will be emitted if available.
  101. If no long branches are available and the &lsquo;<samp>--pcrel</samp>&rsquo; option is not
  102. given, an absolute long jump will be emitted instead. If no long
  103. branches are available, the &lsquo;<samp>--pcrel</samp>&rsquo; option is given, and a word
  104. branch cannot reach the target, an error message is generated.
  105. </p>
  106. <p>In addition to standard branch operands, <code>as</code> allows these
  107. pseudo-operations to have all operands that are allowed for jsr and jmp,
  108. substituting these instructions if the operand given is not valid for a
  109. branch instruction.
  110. </p>
  111. </dd>
  112. <dt><code>j<var>XX</var></code></dt>
  113. <dd><p>Here, &lsquo;<samp>j<var>XX</var></samp>&rsquo; stands for an entire family of pseudo-operations,
  114. where <var>XX</var> is a conditional branch or condition-code test. The full
  115. list of pseudo-ops in this family is:
  116. </p><div class="smallexample">
  117. <pre class="smallexample"> jhi jls jcc jcs jne jeq jvc
  118. jvs jpl jmi jge jlt jgt jle
  119. </pre></div>
  120. <p>Usually, each of these pseudo-operations expands to a single branch
  121. instruction. However, if a word branch is not sufficient, no long branches
  122. are available, and the &lsquo;<samp>--pcrel</samp>&rsquo; option is not given, <code>as</code>
  123. issues a longer code fragment in terms of <var>NX</var>, the opposite condition
  124. to <var>XX</var>. For example, under these conditions:
  125. </p><div class="smallexample">
  126. <pre class="smallexample"> j<var>XX</var> foo
  127. </pre></div>
  128. <p>gives
  129. </p><div class="smallexample">
  130. <pre class="smallexample"> b<var>NX</var>s oof
  131. jmp foo
  132. oof:
  133. </pre></div>
  134. </dd>
  135. <dt><code>db<var>XX</var></code></dt>
  136. <dd><p>The full family of pseudo-operations covered here is
  137. </p><div class="smallexample">
  138. <pre class="smallexample"> dbhi dbls dbcc dbcs dbne dbeq dbvc
  139. dbvs dbpl dbmi dbge dblt dbgt dble
  140. dbf dbra dbt
  141. </pre></div>
  142. <p>Motorola &lsquo;<samp>db<var>XX</var></samp>&rsquo; instructions allow word displacements only. When
  143. a word displacement is sufficient, each of these pseudo-operations expands
  144. to the corresponding Motorola instruction. When a word displacement is not
  145. sufficient and long branches are available, when the source reads
  146. &lsquo;<samp>db<var>XX</var> foo</samp>&rsquo;, <code>as</code> emits
  147. </p><div class="smallexample">
  148. <pre class="smallexample"> db<var>XX</var> oo1
  149. bras oo2
  150. oo1:bral foo
  151. oo2:
  152. </pre></div>
  153. <p>If, however, long branches are not available and the &lsquo;<samp>--pcrel</samp>&rsquo; option is
  154. not given, <code>as</code> emits
  155. </p><div class="smallexample">
  156. <pre class="smallexample"> db<var>XX</var> oo1
  157. bras oo2
  158. oo1:jmp foo
  159. oo2:
  160. </pre></div>
  161. </dd>
  162. <dt><code>fj<var>XX</var></code></dt>
  163. <dd><p>This family includes
  164. </p><div class="smallexample">
  165. <pre class="smallexample"> fjne fjeq fjge fjlt fjgt fjle fjf
  166. fjt fjgl fjgle fjnge fjngl fjngle fjngt
  167. fjnle fjnlt fjoge fjogl fjogt fjole fjolt
  168. fjor fjseq fjsf fjsne fjst fjueq fjuge
  169. fjugt fjule fjult fjun
  170. </pre></div>
  171. <p>Each of these pseudo-operations always expands to a single Motorola
  172. coprocessor branch instruction, word or long. All Motorola coprocessor
  173. branch instructions allow both word and long displacements.
  174. </p>
  175. </dd>
  176. </dl>
  177. <hr>
  178. <div class="header">
  179. <p>
  180. Next: <a href="M68K_002dChars.html#M68K_002dChars" accesskey="n" rel="next">M68K-Chars</a>, Up: <a href="M68K_002dopcodes.html#M68K_002dopcodes" accesskey="u" rel="up">M68K-opcodes</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>
  181. </div>
  182. </body>
  183. </html>