1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
# R0 and P0 are used as tmps, consider them call clobbered by these macros.
# To build for hardware, use:
# bfin-linux-uclibc-gcc -nostdlib -g -Wa,--defsym,BFIN_HOST=1 foo.s
# MACRO: start
# All assembler tests should start with a call to "start"
.macro start
.text
# Pad with EMUEXCPT to make sure "jump to 0" always fails
__panic:
.rep 0xf
.word 0x0025
.endr
abort;
jump __panic;
.global __pass
__pass:
write 1, _passmsg, 5
exit 0
.ifdef BFIN_JTAG
__emu_out:
/* DBGSTAT */
imm32 P0 0xFFE05008;
1: R7 = [P0];
CC = BITTST (R7,0);
IF CC JUMP 1b;
EMUDAT = R0;
RTS;
.endif
.global __fail
__fail:
.ifndef BFIN_HOST
P0.H = _rets;
P0.L = _rets;
R0 = RETS;
R0 += -4;
P1 = 8;
R2 = '9';
LSETUP (1f, 3f) LC0 = P1;
1:
R1 = R0;
R1 >>= 28;
R1 += 0x30;
CC = R2 < R1;
IF !CC jump 2f;
R1 += 7;
2:
B[P0++] = R1;
3:
R0 <<= 4;
write 1, _failmsg, 22
.else
write 1, _failmsg, 5
.endif
exit 1
.ifndef BFIN_HOST
.data
_failmsg:
.ascii "fail at PC=0x"
_rets:
.ascii "12345678\n"
_passmsg:
.ascii "pass\n"
.align 4
_params:
.long 0
.long 0
.long 0
.long 0
.text
.global __start
__start:
.else
.global ___uClibc_main;
___uClibc_main:
.global _main;
_main:
.endif
.endm
# MACRO: system_call
# Make a libgloss/Linux system call
.macro system_call nr:req
P0 = \nr (X);
EXCPT 0;
.endm
# MACRO: exit
# Quit the current test
.macro exit rc:req
R0 = \rc (X);
.ifndef BFIN_HOST
P0.H = _params;
P0.L = _params;
[P0] = R0;
R0 = P0;
.endif
system_call 1
.endm
# MACRO: pass
# Write 'pass' to stdout via syscalls and quit;
# meant for non-OS operating environments
.macro pass
CALL __pass;
.endm
# MACRO: fail
# Write 'fail' to stdout via syscalls and quit;
# meant for non-OS operating environments
.macro fail
CALL __fail;
.endm
# MACRO: write
# Just like the write() C function; uses system calls
.macro write fd:req, buf:req, count:req
.ifndef BFIN_HOST
P0.H = _params;
P0.L = _params;
R0 = \fd (X);
[P0] = R0;
R0.H = \buf;
R0.L = \buf;
[P0 + 4] = R0;
R0 = \count (X);
[P0 + 8] = R0;
R0 = P0;
system_call 5
.endif
.endm
# MACRO: outc_str
# Output a string using the debug OUTC insn
.macro outc_str ch:req, more:vararg
OUTC \ch;
.ifnb \more
outc_str \more
.endif
.endm
# MACRO: dbg_pass
# Write 'pass' to stdout and quit (all via debug insns);
# meant for OS operating environments
.macro dbg_pass
.ifdef BFIN_JTAG
R0 = 6;
CALL __emu_out;
R0.L = 0x6170; /* 'p'=0x70 'a'=0x70 */
R0.H = 0x7373; /* 's'=0x73 */
CALL __emu_out;
R0.L = 0x0A; /* newline */
R0.H = 0x0000;
CALL __emu_out;
1:
EMUEXCPT;
JUMP 1b;
.else
outc_str 'p', 'a', 's', 's', '\n'
HLT;
.endif
.endm
# MACRO: dbg_fail
# Write 'fail' to stdout and quit (all via debug insns);
# meant for OS operating environments
.macro dbg_fail
.ifdef BFIN_JTAG
R0 = 6;
CALL __emu_out;
R0.L = 0x6166; /* 'f'=0x66 'a'=0x61 */
R0.H = 0x6c69; /* 'i'=0x69 'l'=0x6c */
CALL __emu_out;
R0.L = 0x0A; /* newline */
R0.H = 0x0000;
CALL __emu_out;
1:
EMUEXCPT;
JUMP 1b;
.else
outc_str 'f', 'a', 'i', 'l', '\n'
.endif
ABORT;
.endm
# MACRO: imm32
# Load a 32bit immediate directly into a register
.macro imm32 reg:req, val:req
.if (\val) & ~0x7fff
\reg\().L = ((\val) & 0xffff);
\reg\().H = (((\val) >> 16) & 0xffff);
.else
\reg = \val;
.endif
.endm
# MACRO: dmm32
# Load a 32bit immediate indirectly into a register
.macro dmm32 reg:req, val:req
[--SP] = R0;
imm32 R0, \val
\reg = R0;
R0 = [SP++];
.endm
# MACRO: loadsym
# Load a symbol directly into a register
.ifndef BFIN_HOST
.macro loadsym reg:req, sym:req, offset=0
\reg\().L = (\sym\() + \offset\());
\reg\().H = (\sym\() + \offset\());
.endm
.else
.macro loadsym reg:req, sym:req, offset=0
[--SP] = R0;
R0 = [P3 + \sym\()@GOT17M4];
.if \offset
[--SP] = R1;
R1 = \offset\() (Z);
R0 = R0 + R1;
R1 = [SP++];
.endif
\reg = R0;
R0 = [SP++];
.endm
.endif
# MACRO: CHECKREG
# Use debug insns to verify the value of a register matches
.macro CHECKREG reg:req, val:req
DBGAL (\reg, ((\val) & 0xffff));
DBGAH (\reg, (((\val) >> 16) & 0xffff));
.endm
# internal helper macros; ignore them
.macro __init_regs reg:req, max:req, x:req, val:req
.ifle (\x - \max)
imm32 \reg\()\x, \val
.endif
.endm
.macro _init_regs reg:req, max:req, val:req
__init_regs \reg, \max, 0, \val
__init_regs \reg, \max, 1, \val
__init_regs \reg, \max, 2, \val
__init_regs \reg, \max, 3, \val
__init_regs \reg, \max, 4, \val
__init_regs \reg, \max, 5, \val
__init_regs \reg, \max, 6, \val
__init_regs \reg, \max, 7, \val
.endm
# MACRO: init_r_regs
# MACRO: init_p_regs
# MACRO: init_b_regs
# MACRO: init_i_regs
# MACRO: init_l_regs
# MACRO: init_m_regs
# Set the specified group of regs to the specified value
.macro init_r_regs val:req
_init_regs R, 7, \val
.endm
.macro init_p_regs val:req
_init_regs P, 5, \val
.endm
.macro init_b_regs val:req
_init_regs B, 3, \val
.endm
.macro init_i_regs val:req
_init_regs I, 3, \val
.endm
.macro init_l_regs val:req
_init_regs L, 3, \val
.endm
.macro init_m_regs val:req
_init_regs M, 3, \val
.endm
// the test framework needs things to be quiet, so don't
// print things out by default.
.macro _DBG reg:req
//DBG \reg;
.endm
.macro _DBGCMPLX reg:req
//
.endm
|