1 /* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle 7 * Copyright (C) 1999 by Silicon Graphics, Inc. 8 * Copyright (C) 2001 MIPS Technologies, Inc. 9 * Copyright (C) 2002 Maciej W. Rozycki 10 * 11 * Some useful macros for MIPS assembler code 12 * 13 * Some of the routines below contain useless nops that will be optimized 14 * away by gas in -O mode. These nops are however required to fill delay 15 * slots in noreorder mode. 16 */ 17 #ifndef __ASM_H__ 18 #define __ASM_H__ 19 20 /* 21 * LEAF - declare leaf routine 22 */ 23 #define LEAF(symbol) \ 24 .globl symbol; \ 25 .align 2; \ 26 .type symbol,@function; \ 27 .ent symbol,0; \ 28 symbol: .frame sp,0,ra 29 30 /* 31 * NESTED - declare nested routine entry point 32 */ 33 #define NESTED(symbol, framesize, rpc) \ 34 .globl symbol; \ 35 .align 2; \ 36 .type symbol,@function; \ 37 .ent symbol,0; \ 38 symbol: .frame sp, framesize, rpc 39 40 /* 41 * END - mark end of function 42 */ 43 #define END(function) \ 44 .end function; \ 45 .size function,.-function 46 47 /* 48 * EXPORT - export definition of symbol 49 */ 50 #define EXPORT(symbol) \ 51 .globl symbol; \ 52 symbol: 53 54 /* 55 * FEXPORT - export definition of a function symbol 56 */ 57 #define FEXPORT(symbol) \ 58 .globl symbol; \ 59 .type symbol,@function; \ 60 symbol: 61 62 /* 63 * Global data declaration with size. 64 */ 65 #define EXPORTS(name,sz) \ 66 .globl name; \ 67 .type name,@object; \ 68 .size name,sz; \ 69 name: 70 71 /* 72 * Weak data declaration with size. 73 */ 74 #define WEXPORT(name,sz) \ 75 .weakext name; \ 76 .type name,@object; \ 77 .size name,sz; \ 78 name: 79 80 /* 81 * Global data reference with size. 82 */ 83 #define IMPORT(name, size) \ 84 .extern name,size 85 86 /* 87 * Global zeroed data. 88 */ 89 #define BSS(name,size) \ 90 .type name,@object; \ 91 .comm name,size 92 93 /* 94 * Local zeroed data. 95 */ 96 #define LBSS(name,size) \ 97 .lcomm name,size 98 99 100 /* 101 * ABS - export absolute symbol 102 */ 103 #define ABS(symbol,value) \ 104 .globl symbol; \ 105 symbol = value 106 107 108 #define TEXT(msg) \ 109 .pushsection .data; \ 110 8: .asciiz msg; \ 111 .popsection; 112 113 114 #define ENTRY(name) \ 115 .globl name; \ 116 .align 2; \ 117 .ent name,0; \ 118 name##: 119 120 /* 121 * Macros to handle different pointer/register sizes for 32/64-bit code 122 */ 123 124 /* 125 * Size of a register 126 */ 127 #define SZREG 4 128 129 130 /* 131 * Use the following macros in assemblercode to load/store registers, 132 * pointers etc. 133 */ 134 #define REG_S sw 135 #define REG_L lw 136 #define REG_SUBU subu 137 #define REG_ADDU addu 138 139 140 /* 141 * How to add/sub/load/store/shift C int variables. 142 */ 143 #define INT_ADD add 144 #define INT_ADDU addu 145 #define INT_ADDI addi 146 #define INT_ADDIU addiu 147 #define INT_SUB sub 148 #define INT_SUBU subu 149 #define INT_L lw 150 #define INT_S sw 151 #define INT_SLL sll 152 #define INT_SLLV sllv 153 #define INT_SRL srl 154 #define INT_SRLV srlv 155 #define INT_SRA sra 156 #define INT_SRAV srav 157 158 159 160 /* 161 * How to add/sub/load/store/shift C long variables. 162 */ 163 #define LONG_ADD add 164 #define LONG_ADDU addu 165 #define LONG_ADDI addi 166 #define LONG_ADDIU addiu 167 #define LONG_SUB sub 168 #define LONG_SUBU subu 169 #define LONG_L lw 170 #define LONG_S sw 171 #define LONG_SLL sll 172 #define LONG_SLLV sllv 173 #define LONG_SRL srl 174 #define LONG_SRLV srlv 175 #define LONG_SRA sra 176 #define LONG_SRAV srav 177 178 #define LONG .word 179 #define LONGSIZE 4 180 #define LONGMASK 3 181 #define LONGLOG 2 182 183 184 185 /* 186 * How to add/sub/load/store/shift pointers. 187 */ 188 #define PTR_ADD add 189 #define PTR_ADDU addu 190 #define PTR_ADDI addi 191 #define PTR_ADDIU addiu 192 #define PTR_SUB sub 193 #define PTR_SUBU subu 194 #define PTR_L lw 195 #define PTR_S sw 196 #define PTR_LA la 197 #define PTR_SLL sll 198 #define PTR_SLLV sllv 199 #define PTR_SRL srl 200 #define PTR_SRLV srlv 201 #define PTR_SRA sra 202 #define PTR_SRAV srav 203 204 #define PTR_SCALESHIFT 2 205 206 #define PTR .word 207 #define PTRSIZE 4 208 #define PTRLOG 2 209 210 211 /* 212 * Some cp0 registers were extended to 64bit for MIPS III. 213 */ 214 #define MFC0 mfc0 215 #define MTC0 mtc0 216 217 218 #define SSNOP sll zero, zero, 1 219 220 #endif /* end of __ASM_H__ */ 221