1divert(-1) 2 3dnl m4 macros for 68k assembler. 4 5dnl Copyright 2001-2003 Free Software Foundation, Inc. 6 7dnl This file is part of the GNU MP Library. 8dnl 9dnl The GNU MP Library is free software; you can redistribute it and/or modify 10dnl it under the terms of either: 11dnl 12dnl * the GNU Lesser General Public License as published by the Free 13dnl Software Foundation; either version 3 of the License, or (at your 14dnl option) any later version. 15dnl 16dnl or 17dnl 18dnl * the GNU General Public License as published by the Free Software 19dnl Foundation; either version 2 of the License, or (at your option) any 20dnl later version. 21dnl 22dnl or both in parallel, as here. 23dnl 24dnl The GNU MP Library is distributed in the hope that it will be useful, but 25dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 26dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27dnl for more details. 28dnl 29dnl You should have received copies of the GNU General Public License and the 30dnl GNU Lesser General Public License along with the GNU MP Library. If not, 31dnl see https://www.gnu.org/licenses/. 32 33 34dnl The default m4 `#' commenting interferes with the assembler syntax for 35dnl immediates. `|' would be correct, but it interferes with "||" in 36dnl eval(). Would like to disable commenting, but that's not possible (see 37dnl mpn/asm-defs.m4), so use `;' which should be harmless. 38 39changecom(;) 40 41 42dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo) 43dnl 44dnl Same as the standard PROLOGUE, but align to 2 bytes not 4. 45 46define(`PROLOGUE_cpu', 47m4_assert_numargs(1) 48` TEXT 49 ALIGN(2) 50 GLOBL `$1' GLOBL_ATTR 51 TYPE(`$1',`function') 52`$1'LABEL_SUFFIX') 53 54 55dnl Usage: d0, etc 56dnl 57dnl Expand to d0 or %d0 according to the assembler's requirements. 58dnl 59dnl Actually d0 expands to `d0' or %`d0', the quotes protecting against 60dnl further expansion. Definitions are made even if d0 is to be just `d0', 61dnl so that any m4 quoting problems will show up everywhere, not just on a 62dnl %d0 system. 63dnl 64dnl Care must be taken with quoting when using these in a definition. For 65dnl instance the quotes in the following are essential or two %'s will be 66dnl produced when `counter' is used. 67dnl 68dnl define(counter, `d7') 69dnl 70 71dnl Called: m68k_reg(r) 72define(m68k_reg, 73m4_assert_numargs(1) 74m4_assert_defined(`WANT_REGISTER_PERCENT') 75`ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'') 76 77dnl Usage: m68k_defreg(r) 78define(m68k_defreg, 79m4_assert_numargs(1) 80`deflit($1,`m68k_reg(`$1')')') 81 82m68k_defreg(d0) 83m68k_defreg(d1) 84m68k_defreg(d2) 85m68k_defreg(d3) 86m68k_defreg(d4) 87m68k_defreg(d5) 88m68k_defreg(d6) 89m68k_defreg(d7) 90 91m68k_defreg(a0) 92m68k_defreg(a1) 93m68k_defreg(a2) 94m68k_defreg(a3) 95m68k_defreg(a4) 96m68k_defreg(a5) 97m68k_defreg(a6) 98m68k_defreg(a7) 99 100m68k_defreg(sp) 101m68k_defreg(pc) 102 103 104dnl Usage: M(base) 105dnl M(base,displacement) 106dnl M(base,index,size) 107dnl M(base,index,size,scale) 108dnl M(base,+) 109dnl M(-,base) 110dnl 111dnl `base' is an address register, `index' is a data register, `size' is w 112dnl or l, and scale is 1, 2, 4 or 8. 113dnl 114dnl M(-,base) has it's arguments that way around to emphasise it's a 115dnl pre-decrement, as opposed to M(base,+) a post-increment. 116dnl 117dnl Enhancement: Add the memory indirect modes, if/when they're needed. 118 119define(M, 120m4_assert_numargs_range(1,4) 121m4_assert_defined(`WANT_ADDRESSING') 122`ifelse(WANT_ADDRESSING,mit, 123`ifelse($#,1, ``$1'@')dnl 124ifelse($#,2, 125`ifelse($2,+, ``$1'@+', 126`ifelse($1,-, ``$2'@-', 127 ``$1'@($2)')')')dnl 128ifelse($#,3, ``$1'@(`$2':`$3')')dnl 129ifelse($#,4, ``$1'@(`$2':`$3':$4)')', 130 131dnl WANT_ADDRESSING `motorola' 132`ifelse($#,1, `(`$1')')dnl 133ifelse($#,2, 134`ifelse($2,+, `(`$1')+', 135`ifelse($1,-, `-(`$2')', 136 `$2(`$1')')')')dnl 137ifelse($#,3, `(`$1',`$2'.$3)')dnl 138ifelse($#,4, `(`$1',`$2'.$3*$4)')')') 139 140 141dnl Usage: addl etc 142dnl 143dnl m68k instructions with special handling for the suffix, with for 144dnl instance addl expanding to addl or add.l as necessary. 145dnl 146dnl See also t-m68k-defs.pl which verifies all mnemonics used in the asm 147dnl files have entries here. 148 149dnl Called: m68k_insn(mnemonic,suffix) 150define(m68k_insn, 151m4_assert_numargs(2) 152m4_assert_defined(`WANT_DOT_SIZE') 153`ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''', 154 ``$1$2'')') 155 156dnl Usage: m68k_definsn(mnemonic,suffix) 157define(m68k_definsn, 158m4_assert_numargs(2) 159`deflit($1`'$2,`m68k_insn(`$1',`$2')')') 160 161m68k_definsn(add, l) 162m68k_definsn(addx, l) 163m68k_definsn(addq, l) 164m68k_definsn(asl, l) 165m68k_definsn(cmp, l) 166m68k_definsn(cmp, w) 167m68k_definsn(clr, l) 168m68k_definsn(divu, l) 169m68k_definsn(eor, w) 170m68k_definsn(lsl, l) 171m68k_definsn(lsr, l) 172m68k_definsn(move, l) 173m68k_definsn(move, w) 174m68k_definsn(movem,l) 175m68k_definsn(moveq,l) 176m68k_definsn(mulu, l) 177m68k_definsn(neg, l) 178m68k_definsn(or, l) 179m68k_definsn(roxl, l) 180m68k_definsn(roxr, l) 181m68k_definsn(sub, l) 182m68k_definsn(subx, l) 183m68k_definsn(subq, l) 184 185 186dnl Usage: bra etc 187dnl 188dnl Expand to `bra', `jra' or `jbra' according to what the assembler will 189dnl accept. The latter two give variable-sized branches in gas. 190dnl 191dnl See also t-m68k-defs.pl which verifies all the bXX branches used in the 192dnl asm files have entries here. 193 194dnl Called: m68k_branch(cond) 195define(m68k_branch, 196m4_assert_numargs(1) 197m4_assert_defined(`WANT_BRANCHES') 198`ifelse(WANT_BRANCHES,jra, `j$1', 199`ifelse(WANT_BRANCHES,jbra,`jb$1', 200 ``b$1'')')') 201 202dnl Called: m68k_defbranch(cond) 203define(m68k_defbranch, 204m4_assert_numargs(1) 205`deflit(b$1,`m68k_branch(`$1')')') 206 207m68k_defbranch(ra) 208m68k_defbranch(cc) 209m68k_defbranch(cs) 210m68k_defbranch(ls) 211m68k_defbranch(eq) 212m68k_defbranch(ne) 213 214 215dnl Usage: scale_available_p 216dnl 217dnl Expand to 1 if a scale factor can be used in addressing modes, or 0 if 218dnl not. M(a0,d0,l,4), meaning a0+d0*4, is not available in 68000 or 219dnl 68010, but is in CPU32 and in 68020 and up. 220 221define(scale_available_p, 222`m4_ifdef_anyof_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')') 228 229 230divert 231