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