| OLD | NEW |
| (Empty) |
| 1 divert(-1) | |
| 2 | |
| 3 dnl m4 macros for 68k assembler. | |
| 4 | |
| 5 dnl Copyright 2001, 2002, 2003 Free Software Foundation, Inc. | |
| 6 dnl | |
| 7 dnl This file is part of the GNU MP Library. | |
| 8 dnl | |
| 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. | |
| 13 dnl | |
| 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. | |
| 18 dnl | |
| 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/. | |
| 21 | |
| 22 | |
| 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. | |
| 27 | |
| 28 changecom(;) | |
| 29 | |
| 30 | |
| 31 dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo) | |
| 32 dnl | |
| 33 dnl Same as the standard PROLOGUE, but align to 2 bytes not 4. | |
| 34 | |
| 35 define(`PROLOGUE_cpu', | |
| 36 m4_assert_numargs(1) | |
| 37 ` TEXT | |
| 38 ALIGN(2) | |
| 39 GLOBL `$1' GLOBL_ATTR | |
| 40 TYPE(`$1',`function') | |
| 41 `$1'LABEL_SUFFIX') | |
| 42 | |
| 43 | |
| 44 dnl Usage: d0, etc | |
| 45 dnl | |
| 46 dnl Expand to d0 or %d0 according to the assembler's requirements. | |
| 47 dnl | |
| 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 | |
| 51 dnl %d0 system. | |
| 52 dnl | |
| 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. | |
| 56 dnl | |
| 57 dnl define(counter, `d7') | |
| 58 dnl | |
| 59 | |
| 60 dnl Called: m68k_reg(r) | |
| 61 define(m68k_reg, | |
| 62 m4_assert_numargs(1) | |
| 63 m4_assert_defined(`WANT_REGISTER_PERCENT') | |
| 64 `ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'') | |
| 65 | |
| 66 dnl Usage: m68k_defreg(r) | |
| 67 define(m68k_defreg, | |
| 68 m4_assert_numargs(1) | |
| 69 `deflit($1,`m68k_reg(`$1')')') | |
| 70 | |
| 71 m68k_defreg(d0) | |
| 72 m68k_defreg(d1) | |
| 73 m68k_defreg(d2) | |
| 74 m68k_defreg(d3) | |
| 75 m68k_defreg(d4) | |
| 76 m68k_defreg(d5) | |
| 77 m68k_defreg(d6) | |
| 78 m68k_defreg(d7) | |
| 79 | |
| 80 m68k_defreg(a0) | |
| 81 m68k_defreg(a1) | |
| 82 m68k_defreg(a2) | |
| 83 m68k_defreg(a3) | |
| 84 m68k_defreg(a4) | |
| 85 m68k_defreg(a5) | |
| 86 m68k_defreg(a6) | |
| 87 m68k_defreg(a7) | |
| 88 | |
| 89 m68k_defreg(sp) | |
| 90 m68k_defreg(pc) | |
| 91 | |
| 92 | |
| 93 dnl Usage: M(base) | |
| 94 dnl M(base,displacement) | |
| 95 dnl M(base,index,size) | |
| 96 dnl M(base,index,size,scale) | |
| 97 dnl M(base,+) | |
| 98 dnl M(-,base) | |
| 99 dnl | |
| 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. | |
| 102 dnl | |
| 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. | |
| 105 dnl | |
| 106 dnl Enhancement: Add the memory indirect modes, if/when they're needed. | |
| 107 | |
| 108 define(M, | |
| 109 m4_assert_numargs_range(1,4) | |
| 110 m4_assert_defined(`WANT_ADDRESSING') | |
| 111 `ifelse(WANT_ADDRESSING,mit, | |
| 112 `ifelse($#,1, ``$1'@')dnl | |
| 113 ifelse($#,2, | |
| 114 `ifelse($2,+, ``$1'@+', | |
| 115 `ifelse($1,-, ``$2'@-', | |
| 116 ``$1'@($2)')')')dnl | |
| 117 ifelse($#,3, ``$1'@(`$2':`$3')')dnl | |
| 118 ifelse($#,4, ``$1'@(`$2':`$3':$4)')', | |
| 119 | |
| 120 dnl WANT_ADDRESSING `motorola' | |
| 121 `ifelse($#,1, `(`$1')')dnl | |
| 122 ifelse($#,2, | |
| 123 `ifelse($2,+, `(`$1')+', | |
| 124 `ifelse($1,-, `-(`$2')', | |
| 125 `$2(`$1')')')')dnl | |
| 126 ifelse($#,3, `(`$1',`$2'.$3)')dnl | |
| 127 ifelse($#,4, `(`$1',`$2'.$3*$4)')')') | |
| 128 | |
| 129 | |
| 130 dnl Usage: addl etc | |
| 131 dnl | |
| 132 dnl m68k instructions with special handling for the suffix, with for | |
| 133 dnl instance addl expanding to addl or add.l as necessary. | |
| 134 dnl | |
| 135 dnl See also t-m68k-defs.pl which verifies all mnemonics used in the asm | |
| 136 dnl files have entries here. | |
| 137 | |
| 138 dnl Called: m68k_insn(mnemonic,suffix) | |
| 139 define(m68k_insn, | |
| 140 m4_assert_numargs(2) | |
| 141 m4_assert_defined(`WANT_DOT_SIZE') | |
| 142 `ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''', | |
| 143 ``$1$2'')') | |
| 144 | |
| 145 dnl Usage: m68k_definsn(mnemonic,suffix) | |
| 146 define(m68k_definsn, | |
| 147 m4_assert_numargs(2) | |
| 148 `deflit($1`'$2,`m68k_insn(`$1',`$2')')') | |
| 149 | |
| 150 m68k_definsn(add, l) | |
| 151 m68k_definsn(addx, l) | |
| 152 m68k_definsn(addq, l) | |
| 153 m68k_definsn(asl, l) | |
| 154 m68k_definsn(cmp, l) | |
| 155 m68k_definsn(cmp, w) | |
| 156 m68k_definsn(clr, l) | |
| 157 m68k_definsn(divu, l) | |
| 158 m68k_definsn(eor, w) | |
| 159 m68k_definsn(lsl, l) | |
| 160 m68k_definsn(lsr, 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) | |
| 166 m68k_definsn(neg, l) | |
| 167 m68k_definsn(or, l) | |
| 168 m68k_definsn(roxl, l) | |
| 169 m68k_definsn(roxr, l) | |
| 170 m68k_definsn(sub, l) | |
| 171 m68k_definsn(subx, l) | |
| 172 m68k_definsn(subq, l) | |
| 173 | |
| 174 | |
| 175 dnl Usage: bra etc | |
| 176 dnl | |
| 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. | |
| 179 dnl | |
| 180 dnl See also t-m68k-defs.pl which verifies all the bXX branches used in the | |
| 181 dnl asm files have entries here. | |
| 182 | |
| 183 dnl Called: m68k_branch(cond) | |
| 184 define(m68k_branch, | |
| 185 m4_assert_numargs(1) | |
| 186 m4_assert_defined(`WANT_BRANCHES') | |
| 187 `ifelse(WANT_BRANCHES,jra, `j$1', | |
| 188 `ifelse(WANT_BRANCHES,jbra,`jb$1', | |
| 189 ``b$1'')')') | |
| 190 | |
| 191 dnl Called: m68k_defbranch(cond) | |
| 192 define(m68k_defbranch, | |
| 193 m4_assert_numargs(1) | |
| 194 `deflit(b$1,`m68k_branch(`$1')')') | |
| 195 | |
| 196 m68k_defbranch(ra) | |
| 197 m68k_defbranch(cc) | |
| 198 m68k_defbranch(cs) | |
| 199 m68k_defbranch(ls) | |
| 200 m68k_defbranch(eq) | |
| 201 m68k_defbranch(ne) | |
| 202 | |
| 203 | |
| 204 dnl Usage: scale_available_p | |
| 205 dnl | |
| 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. | |
| 209 | |
| 210 define(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 | |
| 219 divert | |
| OLD | NEW |