| 1 | # MIPS simulator testsuite utility functions. |
| 2 | # Copyright (C) 2004 Free Software Foundation, Inc. |
| 3 | # Contributed by Chris Demetriou of Broadcom Corporation. |
| 4 | # |
| 5 | # This file is part of the GNU simulators. |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2, or (at your option) |
| 10 | # any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License along |
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | |
| 22 | # $1, $4, $5, %6, are used as temps by the macros defined here. |
| 23 | |
| 24 | .macro writemsg msg |
| 25 | .data |
| 26 | 901: .ascii "\msg\n" |
| 27 | 902: |
| 28 | .previous |
| 29 | la $5, 901b |
| 30 | li $6, 902b - 901b |
| 31 | .set push |
| 32 | .set noreorder |
| 33 | jal _dowrite |
| 34 | li $4, 0 |
| 35 | .set pop |
| 36 | .endm |
| 37 | |
| 38 | |
| 39 | # The MIPS simulator uses "break 0x3ff" as the code to exit, |
| 40 | # with the return value in $4 (a0). |
| 41 | .macro exit rc |
| 42 | li $4, \rc |
| 43 | break 0x3ff |
| 44 | .endm |
| 45 | |
| 46 | |
| 47 | .macro setup |
| 48 | |
| 49 | .global _start |
| 50 | .ent _start |
| 51 | _start: |
| 52 | .set push |
| 53 | .set noreorder |
| 54 | j DIAG |
| 55 | nop |
| 56 | .set pop |
| 57 | .end _start |
| 58 | |
| 59 | .global _fail |
| 60 | .ent _fail |
| 61 | _fail: |
| 62 | writemsg "fail" |
| 63 | exit 1 |
| 64 | .end _fail |
| 65 | |
| 66 | .global _pass |
| 67 | .ent _pass |
| 68 | _pass: |
| 69 | writemsg "pass" |
| 70 | exit 0 |
| 71 | .end _pass |
| 72 | |
| 73 | # The MIPS simulator can use multiple different monitor types, |
| 74 | # so we hard-code the simulator "write" reserved instruction opcode, |
| 75 | # rather than jumping to a vector that invokes it. The operation |
| 76 | # expects RA to point to the location at which to continue |
| 77 | # after writing. |
| 78 | .global _dowrite |
| 79 | .ent _dowrite |
| 80 | _dowrite: |
| 81 | # Write opcode (reserved instruction). See sim_monitor and its |
| 82 | # callers in sim/mips/interp.c. |
| 83 | .word 0x00000005 | ((8 << 1) << 6) |
| 84 | .end _dowrite |
| 85 | |
| 86 | .endm # setup |
| 87 | |
| 88 | |
| 89 | .macro pass |
| 90 | .set push |
| 91 | .set noreorder |
| 92 | j _pass |
| 93 | nop |
| 94 | .set pop |
| 95 | .endm |
| 96 | |
| 97 | |
| 98 | .macro fail |
| 99 | .set push |
| 100 | .set noreorder |
| 101 | j _fail |
| 102 | nop |
| 103 | .set pop |
| 104 | .endm |
| 105 | |
| 106 | |
| 107 | .macro load32 reg, val |
| 108 | li \reg, \val |
| 109 | .endm |
| 110 | |
| 111 | |
| 112 | .macro load64 reg, val |
| 113 | dli \reg, \val |
| 114 | .endm |
| 115 | |
| 116 | |
| 117 | .macro loadaddr reg, addr |
| 118 | la \reg, \addr |
| 119 | .endm |
| 120 | |
| 121 | |
| 122 | .macro checkreg reg, expreg |
| 123 | .set push |
| 124 | .set noat |
| 125 | .set noreorder |
| 126 | beq \expreg, \reg, 901f |
| 127 | nop |
| 128 | fail |
| 129 | 901: |
| 130 | .set pop |
| 131 | .endm |
| 132 | |
| 133 | |
| 134 | .macro check32 reg, val |
| 135 | .set push |
| 136 | .set noat |
| 137 | load32 $1, \val |
| 138 | checkreg \reg, $1 |
| 139 | .set pop |
| 140 | .endm |
| 141 | |
| 142 | |
| 143 | .macro check64 reg, val |
| 144 | .set push |
| 145 | .set noat |
| 146 | load64 $1, \val |
| 147 | checkreg \reg, $1 |
| 148 | .set pop |
| 149 | .endm |