3 dnl m4 macros for 68k assembler.
5 dnl Copyright 2001-2003 Free Software Foundation, Inc.
7 dnl This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
12 dnl * the GNU Lesser General Public License as published by the Free
13 dnl Software Foundation; either version 3 of the License, or (at your
14 dnl option) any later version.
18 dnl * the GNU General Public License as published by the Free Software
19 dnl Foundation; either version 2 of the License, or (at your option) any
22 dnl or both in parallel, as here.
24 dnl The GNU MP Library is distributed in the hope that it will be useful, but
25 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29 dnl You should have received copies of the GNU General Public License and the
30 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31 dnl see https://www.gnu.org/licenses/.
34 dnl The default m4 `#' commenting interferes with the assembler syntax for
35 dnl immediates. `|' would be correct, but it interferes with "||" in
36 dnl eval(). Would like to disable commenting, but that's not possible (see
37 dnl mpn/asm-defs.m4), so use `;' which should be harmless.
42 dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
44 dnl Same as the standard PROLOGUE, but align to 2 bytes not 4.
46 define(`PROLOGUE_cpu',
57 dnl Expand to d0 or %d0 according to the assembler's requirements.
59 dnl Actually d0 expands to `d0' or %`d0', the quotes protecting against
60 dnl further expansion. Definitions are made even if d0 is to be just `d0',
61 dnl so that any m4 quoting problems will show up everywhere, not just on a
64 dnl Care must be taken with quoting when using these in a definition. For
65 dnl instance the quotes in the following are essential or two %'s will be
66 dnl produced when `counter' is used.
68 dnl define(counter, `d7')
71 dnl Called: m68k_reg(r)
74 m4_assert_defined(`WANT_REGISTER_PERCENT')
75 `ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'')
77 dnl Usage: m68k_defreg(r)
80 `deflit($1,`m68k_reg(`$1')')')
105 dnl M(base,displacement)
106 dnl M(base,index,size)
107 dnl M(base,index,size,scale)
111 dnl `base' is an address register, `index' is a data register, `size' is w
112 dnl or l, and scale is 1, 2, 4 or 8.
114 dnl M(-,base) has it's arguments that way around to emphasise it's a
115 dnl pre-decrement, as opposed to M(base,+) a post-increment.
117 dnl Enhancement: Add the memory indirect modes, if/when they're needed.
120 m4_assert_numargs_range(1,4)
121 m4_assert_defined(`WANT_ADDRESSING')
122 `ifelse(WANT_ADDRESSING,mit,
123 `ifelse($#,1, ``$1'@')dnl
125 `ifelse($2,+, ``$1'@+',
126 `ifelse($1,-, ``$2'@-',
128 ifelse($#,3, ``$1'@(`$2':`$3')')dnl
129 ifelse($#,4, ``$1'@(`$2':`$3':$4)')',
131 dnl WANT_ADDRESSING `motorola'
132 `ifelse($#,1, `(`$1')')dnl
134 `ifelse($2,+, `(`$1')+',
135 `ifelse($1,-, `-(`$2')',
137 ifelse($#,3, `(`$1',`$2'.$3)')dnl
138 ifelse($#,4, `(`$1',`$2'.$3*$4)')')')
143 dnl m68k instructions with special handling for the suffix, with for
144 dnl instance addl expanding to addl or add.l as necessary.
146 dnl See also t-m68k-defs.pl which verifies all mnemonics used in the asm
147 dnl files have entries here.
149 dnl Called: m68k_insn(mnemonic,suffix)
152 m4_assert_defined(`WANT_DOT_SIZE')
153 `ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''',
156 dnl Usage: m68k_definsn(mnemonic,suffix)
159 `deflit($1`'$2,`m68k_insn(`$1',`$2')')')
162 m68k_definsn(addx, l)
163 m68k_definsn(addq, l)
168 m68k_definsn(divu, l)
172 m68k_definsn(move, l)
173 m68k_definsn(move, w)
174 m68k_definsn(movem,l)
175 m68k_definsn(moveq,l)
176 m68k_definsn(mulu, l)
179 m68k_definsn(roxl, l)
180 m68k_definsn(roxr, l)
182 m68k_definsn(subx, l)
183 m68k_definsn(subq, l)
188 dnl Expand to `bra', `jra' or `jbra' according to what the assembler will
189 dnl accept. The latter two give variable-sized branches in gas.
191 dnl See also t-m68k-defs.pl which verifies all the bXX branches used in the
192 dnl asm files have entries here.
194 dnl Called: m68k_branch(cond)
197 m4_assert_defined(`WANT_BRANCHES')
198 `ifelse(WANT_BRANCHES,jra, `j$1',
199 `ifelse(WANT_BRANCHES,jbra,`jb$1',
202 dnl Called: m68k_defbranch(cond)
203 define(m68k_defbranch,
205 `deflit(b$1,`m68k_branch(`$1')')')
215 dnl Usage: scale_available_p
217 dnl Expand to 1 if a scale factor can be used in addressing modes, or 0 if
218 dnl not. M(a0,d0,l,4), meaning a0+d0*4, is not available in 68000 or
219 dnl 68010, but is in CPU32 and in 68020 and up.
221 define(scale_available_p,
223 `HAVE_HOST_CPU_m68360'
224 `HAVE_HOST_CPU_m68020'
225 `HAVE_HOST_CPU_m68030'
226 `HAVE_HOST_CPU_m68040'
227 `HAVE_HOST_CPU_m68060')')