3 dnl m4 macros for 68k assembler.
5 dnl Copyright 2001, 2002, 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
10 dnl modify it under the terms of the GNU Lesser General Public License as
11 dnl published by the Free Software Foundation; either version 3 of the
12 dnl License, or (at your option) any later version.
14 dnl The GNU MP Library is distributed in the hope that it will be useful,
15 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 dnl Lesser General Public License for more details.
19 dnl You should have received a copy of the GNU Lesser General Public License
20 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
23 dnl The default m4 `#' commenting interferes with the assembler syntax for
24 dnl immediates. `|' would be correct, but it interferes with "||" in
25 dnl eval(). Would like to disable commenting, but that's not possible (see
26 dnl mpn/asm-defs.m4), so use `;' which should be harmless.
31 dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
33 dnl Same as the standard PROLOGUE, but align to 2 bytes not 4.
35 define(`PROLOGUE_cpu',
46 dnl Expand to d0 or %d0 according to the assembler's requirements.
48 dnl Actually d0 expands to `d0' or %`d0', the quotes protecting against
49 dnl further expansion. Definitions are made even if d0 is to be just `d0',
50 dnl so that any m4 quoting problems will show up everywhere, not just on a
53 dnl Care must be taken with quoting when using these in a definition. For
54 dnl instance the quotes in the following are essential or two %'s will be
55 dnl produced when `counter' is used.
57 dnl define(counter, `d7')
60 dnl Called: m68k_reg(r)
63 m4_assert_defined(`WANT_REGISTER_PERCENT')
64 `ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'')
66 dnl Usage: m68k_defreg(r)
69 `deflit($1,`m68k_reg(`$1')')')
94 dnl M(base,displacement)
95 dnl M(base,index,size)
96 dnl M(base,index,size,scale)
100 dnl `base' is an address register, `index' is a data register, `size' is w
101 dnl or l, and scale is 1, 2, 4 or 8.
103 dnl M(-,base) has it's arguments that way around to emphasise it's a
104 dnl pre-decrement, as opposed to M(base,+) a post-increment.
106 dnl Enhancement: Add the memory indirect modes, if/when they're needed.
109 m4_assert_numargs_range(1,4)
110 m4_assert_defined(`WANT_ADDRESSING')
111 `ifelse(WANT_ADDRESSING,mit,
112 `ifelse($#,1, ``$1'@')dnl
114 `ifelse($2,+, ``$1'@+',
115 `ifelse($1,-, ``$2'@-',
117 ifelse($#,3, ``$1'@(`$2':`$3')')dnl
118 ifelse($#,4, ``$1'@(`$2':`$3':$4)')',
120 dnl WANT_ADDRESSING `motorola'
121 `ifelse($#,1, `(`$1')')dnl
123 `ifelse($2,+, `(`$1')+',
124 `ifelse($1,-, `-(`$2')',
126 ifelse($#,3, `(`$1',`$2'.$3)')dnl
127 ifelse($#,4, `(`$1',`$2'.$3*$4)')')')
132 dnl m68k instructions with special handling for the suffix, with for
133 dnl instance addl expanding to addl or add.l as necessary.
135 dnl See also t-m68k-defs.pl which verifies all mnemonics used in the asm
136 dnl files have entries here.
138 dnl Called: m68k_insn(mnemonic,suffix)
141 m4_assert_defined(`WANT_DOT_SIZE')
142 `ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''',
145 dnl Usage: m68k_definsn(mnemonic,suffix)
148 `deflit($1`'$2,`m68k_insn(`$1',`$2')')')
151 m68k_definsn(addx, l)
152 m68k_definsn(addq, l)
157 m68k_definsn(divu, l)
161 m68k_definsn(move, l)
162 m68k_definsn(move, w)
163 m68k_definsn(movem,l)
164 m68k_definsn(moveq,l)
165 m68k_definsn(mulu, l)
168 m68k_definsn(roxl, l)
169 m68k_definsn(roxr, l)
171 m68k_definsn(subx, l)
172 m68k_definsn(subq, l)
177 dnl Expand to `bra', `jra' or `jbra' according to what the assembler will
178 dnl accept. The latter two give variable-sized branches in gas.
180 dnl See also t-m68k-defs.pl which verifies all the bXX branches used in the
181 dnl asm files have entries here.
183 dnl Called: m68k_branch(cond)
186 m4_assert_defined(`WANT_BRANCHES')
187 `ifelse(WANT_BRANCHES,jra, `j$1',
188 `ifelse(WANT_BRANCHES,jbra,`jb$1',
191 dnl Called: m68k_defbranch(cond)
192 define(m68k_defbranch,
194 `deflit(b$1,`m68k_branch(`$1')')')
204 dnl Usage: scale_available_p
206 dnl Expand to 1 if a scale factor can be used in addressing modes, or 0 if
207 dnl not. M(a0,d0,l,4), meaning a0+d0*4, is not available in 68000 or
208 dnl 68010, but is in CPU32 and in 68020 and up.
210 define(scale_available_p,
212 `HAVE_HOST_CPU_m68360'
213 `HAVE_HOST_CPU_m68020'
214 `HAVE_HOST_CPU_m68030'
215 `HAVE_HOST_CPU_m68040'
216 `HAVE_HOST_CPU_m68060')')