summaryrefslogtreecommitdiffstats
path: root/private/ntos/ke/mips/alignx.s
blob: 8821d764fce54cd361d842772a548c4422890a2f (plain) (blame)
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
//      TITLE("Unaligned Branch Tests")
//++
//
// Copyright (c) 1991  Microsoft Corporation
//
// Module Name:
//
//    alignx.s
//
// Abstract:
//
//    This module implements the unaligned branch tests.
//
// Author:
//
//    David N. Cutler (davec) 27-Feb-1991
//
// Environment:
//
//    User mode only.
//
// Revision History:
//
//--

#include "ksmips.h"

        SBTTL("Unaligned BEQ/BNE/BC1F/BC1T Branch Tests")
//++
//
// Routine Description:
//
//    The following routines implement beq/bne/bc1f/bc1t tests with an unaligned
//    load word instruction in the delay slot.
//
// Arguments:
//
//    a0 - Supplies first operand for branch test.
//    a1 - Supplies second operate for branch test.
//    a2 - Supplies a pointer to an unaligned word.
//    a3 - Supplies a pointer to an aligned word that receives the result
//       of the unaligned load.
//
// Return Value:
//
//    A value of true is returned in the brancd was taken. Otherwise,
//    FALSE is returned.
//
//--

        LEAF_ENTRY(Beq)

        .set    noreorder
        li      v0,1                    // set branched true
        beq     a0,a1,10f               // if eq, branch
        lw      v1,0(a2)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a3)                // store unaligned value
        .set    reorder

        .end    Beq

        LEAF_ENTRY(Bne)

        .set    noreorder
        li      v0,1                    // set branched true
        bne     a0,a1,10f               // if eq, branch
        lw      v1,0(a2)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a3)                // store unaligned value
        .set    reorder

        .end    Bne

        LEAF_ENTRY(Bc1f)

        .set    noreorder
        mtc1    a0,f0                   // set comparand 1
        mtc1    a1,f2                   // set comparand 2
        li      v0,1                    // set branched true
        c.eq.s  f0,f2                   // compare for equality
        bc1f    10f                     // if f, branch
        lw      v1,0(a2)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a3)                // store unaligned value
        .set    reorder

        .end    Bc1f

        LEAF_ENTRY(Bc1t)

        .set    noreorder
        mtc1    a0,f0                   // set comparand 1
        mtc1    a1,f2                   // set comparand 2
        li      v0,1                    // set branched true
        c.eq.s  f0,f2                   // compare for equality
        bc1t    10f                     // if t, branch
        lw      v1,0(a2)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a3)                // store unaligned value
        .set    reorder

        .end    Bc1t

        SBTTL("Unaligned BLEZ/BLTZ/BGEZ/BGTZ/BGEZAL/BLTZAL Branch Tests")
//++
//
// Routine Description:
//
//    The following routines implement blez/bltz/bgez/bgtz/bgezal/bltzal
//    tests with an unaligned load word instruction in the delay slot.
//
// Arguments:
//
//    a0 - Supplies the operand for branch test.
//    a1 - Supplies a pointer to an unaligned word.
//    a2 - Supplies a pointer to an aligned word that receives the result
//       of the unaligned load.
//
// Return Value:
//
//    A value of true is returned in the branch was taken. Otherwise,
//    FALSE is returned.
//
//--

        LEAF_ENTRY(Blez)

        .set    noreorder
        li      v0,1                    // set branched true
        blez    a0,10f                  // if lez, branch
        lw      v1,0(a1)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a2)                // store unaligned value
        .set    reorder

        .end    Blez

        LEAF_ENTRY(Bltz)

        .set    noreorder
        li      v0,1                    // set branched true
        bltz    a0,10f                  // if ltz, branch
        lw      v1,0(a1)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a2)                // store unaligned value
        .set    reorder

        .end    Bltz

        LEAF_ENTRY(Bgez)

        .set    noreorder
        li      v0,1                    // set branched true
        bgez    a0,10f                  // if gez, branch
        lw      v1,0(a1)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a2)                // store unaligned value
        .set    reorder

        .end    Bgez

        LEAF_ENTRY(Bgtz)

        .set    noreorder
        li      v0,1                    // set branched true
        bgtz    a0,10f                  // if gtz, branch
        lw      v1,0(a1)                // load unaligned data
        move    v0,zero                 // set branched false
10:     j       ra                      // return
        sw      v1,0(a2)                // store unaligned value
        .set    reorder

        .end    Bgtz

        LEAF_ENTRY(Bgezal)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        bgezal  a0,10f                  // if gez, branch and link
        lw      v1,0(a1)                // load unaligned data
        lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a2)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       ra                      // return
        li      v0,1                    // set branched true
        .set    reorder

        .end    Bgezal

        LEAF_ENTRY(Bltzal)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        bltzal  a0,10f                  // if ltz, branch and link
        lw      v1,0(a1)                // load unaligned data
        lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a2)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       ra                      // return
        li      v0,1                    // set branched true
        .set    reorder

        .end    Bltzal

        SBTTL("Unaligned JAL/J Tests")
//++
//
// Routine Description:
//
//    The following routines implement jal/j tests with an unaligned
//    load word instruction in the delay slot.
//
// Arguments:
//
//    a0 - Supplies a pointer to an unaligned word.
//    a1 - Supplies a pointer to an aligned word that receives the result
//       of the unaligned load.
//
// Return Value:
//
//    A value of true is returned in the brancd was taken. Otherwise,
//    FALSE is returned.
//
//--

        LEAF_ENTRY(Jal)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        jal     10f                     // jump and link
        lw      v1,0(a0)                // load unaligned data
        lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a1)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       ra                      // return
        li      v0,1                    // set branched true
        .set    reorder

        .end    Jal

        LEAF_ENTRY(Jalr)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        la      t0,10f                  // get destination address
        jal     t0                      // jump
        lw      v1,0(a0)                // load unaligned data
        lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a1)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       ra                      // jump back
        li      v0,1                    // set branched true
        .set    reorder

        .end    Jalr

        LEAF_ENTRY(J)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        j       10f                     // jump
        lw      v1,0(a0)                // load unaligned data
20:     lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a1)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       20b                     // jump back
        li      v0,1                    // set branched true
        .set    reorder

        .end    J

        LEAF_ENTRY(Jr)

        .set    noreorder
        sw      ra,4 * 4(sp)            // save return address
        move    v0,zero                 // set branched false
        la      t0,10f                  // get destination address
        j       t0                      // jump
        lw      v1,0(a0)                // load unaligned data
20:     lw      ra,4 * 4(sp)            // restore return address
        sw      v1,0(a1)                // store unaligned value
        j       ra                      // return
        nop                             //

10:     j       20b                     // return
        li      v0,1                    // set branched true
        .set    reorder

        .end    Jr