OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [fp/] [fp.S] - Blame information for rev 855

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 jeremybenn
/* fp.S. Floating point instruction set test of Or1ksim
2
 
3
   Copyright (C) 1999-2006 OpenCores
4
   Copyright (C) 2010 Embecosm Limited
5 233 julius
   Copyright (C) 2010 ORSoC AB
6 104 jeremybenn
 
7
   Contributors various OpenCores participants
8
   Contributor Jeremy Bennett 
9 233 julius
   Contributor Julius Baxter 
10 104 jeremybenn
 
11
   This file is part of OpenRISC 1000 Architectural Simulator.
12
 
13
   This program is free software; you can redistribute it and/or modify it
14
   under the terms of the GNU General Public License as published by the Free
15
   Software Foundation; either version 3 of the License, or (at your option)
16
   any later version.
17
 
18
   This program is distributed in the hope that it will be useful, but WITHOUT
19
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
21
   more details.
22
 
23
   You should have received a copy of the GNU General Public License along
24
   with this program.  If not, see .  */
25
 
26
 
27
/* ----------------------------------------------------------------------------
28
 * Test coverage
29
 *
30
 * At present the tests are only reasonably comprehensive for lf.add.s and
31
 * lf.div.s. This is intended as a template for future work, and still has
32
 * omissions even so.
33
 *
34
 * Basic tests are provided for all single precision floating point
35
 * numbers. Since Or1ksim translates these operations into host FP, there is
36
 * little point in testing more of the subtleties of IEEE 745.
37
 *
38
 * However in future this test could be used with OpenRISC hardware, in which
39
 * case exhaustive testing would be essential.
40
 * ------------------------------------------------------------------------- */
41
 
42
 
43
#include "spr-defs.h"
44
#include "board.h"
45
 
46
/* ----------------------------------------------------------------------------
47
 * Coding conventions
48
 *
49 458 julius
v * A simple rising stack is provided to starting at _stack and pointed to by
50 104 jeremybenn
 * r1. r1 points to the next free word. Only 32-bit registers may be pushed
51
 * onto the stack.
52
 *
53
 * Temporary labels up to 49 are reserved for macros and subroutines. Each is
54
 * used only once in any macro or subroutine. You can get in a serious mess if
55
 * you get local label clashing in macros.
56
 *
57
 * Arguments to functions are passed in r3 through r8.
58
 * r9 is the link (return address)
59
 * r11 is for returning results
60
 * r2 through r11 are not preserved across calls. All other registers are.
61
 * ------------------------------------------------------------------------- */
62
 
63
 
64
/* ----------------------------------------------------------------------------
65
 * Memory controller constants
66
 * ------------------------------------------------------------------------- */
67
 
68
#define MEM_RAM 0x00000000
69
 
70
/* ----------------------------------------------------------------------------
71
 * Floating point constants (IEEE 754)
72
 *
73
 * For the record, the single precision format has 1 sign bit, 8 exponent bits
74
 * and 23 fraction bits.
75
 *
76
 *   seeeeeeeefffffffffffffffffffffff
77
 *
78
 * The exponent is biased by 2^7 - 1 (i.e 127 is subtracted from the value to
79
 * give the actual exponent). Normalized numbers have a non-zero exponent (up
80
 * to 2^8 - 2) and an implicit 1 before the fraction. Thus the value
81
 * represented is
82
 *
83
 *   (-1)^s * 1.fffffffffffffffffffffff * 2^(eeeeeeee - (2^7 - 1))
84
 *
85
 * Special values used are:
86
 *
87
 *  Zeroes                Exponent is zero,    fraction also zero
88
 *  Denormalized numbers  Exponent is zero,    fraction non-zero
89
 *  Infinities            Exponent is 2^8 - 1, fraction is zero
90
 *  NaNs                  Exponent is 2^8 - 1, fraction is non-zero
91
 *
92
 * The top bit of the fraction in a NaN is often used to indicate the type of
93
 * NaN. If 1, it is a "quiet" NaN, if 0 it is a "signalling" NaN. Quiet NaN's
94
 * are generally propagated for FP errors. Signalling NaN's can be used for
95
 * more unusual purposes
96
 *
97
 * In general any other bits of the NaN fraction are just propagated unchanged.
98
 * ------------------------------------------------------------------------- */
99
 
100
#define FP_S_P_ZERO    (0x00000000)     /* Positive zero */
101
#define FP_S_N_ZERO    (0x80000000)     /* Positive zero */
102
#define FP_S_P_INF     (0x7f800000)     /* Positive infinity */
103
#define FP_S_N_INF     (0xff800000)     /* Negative infinity */
104
#define FP_S_P_NAN     (0x7fc00000)     /* Positive qNaN */
105
#define FP_S_N_NAN     (0xffc00000)     /* Negative qNaN */
106
 
107
/* Some NaNs without all fraction bits set (permitted under IEEE 754) */
108
#define FP_S_P_NAN_B   (0x7f800001)     /* Positive NaN, not all 1s in frac */
109
#define FP_S_N_NAN_B   (0xff800001)     /* Negative NaN, not all 1s in frac */
110
 
111
/* Some single precision normalized numbers */
112
#define  FP_S_0_5      (0x3f000000)     /* +0.5 */
113
#define  FP_S_ONE      (0x3f800000)     /* +1.0 */
114
#define  FP_S_1_5      (0x3fc00000)     /* +1.5 */
115
#define  FP_S_TWO      (0x40000000)     /* +2.0 */
116
#define  FP_S_THREE    (0x40400000)     /* +3.0 */
117
#define  FP_S_HUGE1    (0x7e800000)     /* +1.0 * 2^+126 */
118
#define  FP_S_HUGE2    (0x7f000000)     /* +1.0 * 2^+127 */
119
#define  FP_S_N_0_5    (0xbf000000)     /* -0.5 */
120
#define  FP_S_N_ONE    (0xbf800000)     /* -1.0 */
121
#define  FP_S_N_1_5    (0xbfc00000)     /* -1.5 */
122
#define  FP_S_N_TWO    (0xc0000000)     /* -2.0 */
123
#define  FP_S_N_THREE  (0xc0400000)     /* -3.0 */
124
#define  FP_S_N_HUGE1  (0xfe800000)     /* -1.0 * 2^+126 */
125
#define  FP_S_N_HUGE2  (0xff000000)     /* -1.0 * 2^+127 */
126
 
127
/* Some denormalized numbers */
128
#define  FP_S_SMALL1   (0x00200000)     /* +1.0 * 2^-129 */
129
#define  FP_S_SMALL2   (0x00400000)     /* +1.0 * 2^-128 */
130
#define  FP_S_N_SMALL1 (0x80200000)     /* -1.0 * 2^-129 */
131
#define  FP_S_N_SMALL2 (0x80400000)     /* -1.0 * 2^-128 */
132
 
133
/* Indicator of completion */
134
#define  ALL_DONE     (0xdeaddead)
135
 
136
/* Logical values */
137
#define TRUE   1
138
#define FALSE  0
139
 
140
 
141
/* ----------------------------------------------------------------------------
142
 * Macro to push a register onto the stack
143
 *
144
 * r1 points to the next free slot. Push the supplied register on, then
145
 * advance the stack pointer.
146
 *
147
 * Arguments:
148
 *   reg  The register to push
149
 *
150
 * Registers modified
151
 *   r1
152
 * ------------------------------------------------------------------------- */
153
#define PUSH(reg)                                                        \
154
        l.sw    0(r1),reg               /* Push */                      ;\
155
        l.addi  r1,r1,4                 /* Advance the stack */
156
 
157
/* ----------------------------------------------------------------------------
158
 * Macro to pop a register off the stack
159
 *
160
 * r1 points to the next free slot. Decrement the stack pointer, then pop the
161
 * requested register.
162
 *
163
 * Arguments:
164
 *   reg  The register to pop
165
 *
166
 * Registers modified
167
 *   r1
168
 * ------------------------------------------------------------------------- */
169
#define POP(reg)                                                         \
170
        l.addi  r1,r1,-4                /* Decrement the stack */       ;\
171
        l.lws   reg,0(r1)               /* Pop */
172
 
173
/* ----------------------------------------------------------------------------
174
 * Macro to load a 32-bit constant into a register
175
 *
176
 * Arguments:
177
 *   reg  The register to load
178
 *   val  The value to load
179
 *
180
 * ------------------------------------------------------------------------- */
181
#define LOAD_CONST(reg,val)                                              \
182
        l.movhi reg,hi(val)                                             ;\
183
        l.ori   reg,reg,lo(val)
184
 
185
/* ----------------------------------------------------------------------------
186
 * Macro to define and load a pointer to a string
187
 *
188
 * Arguments:
189
 *   reg  The register to load
190
 *   str  The string
191
 *
192
 * ------------------------------------------------------------------------- */
193
#define LOAD_STR(reg,str)                                                \
194
        .section .rodata                                                ;\
195
1:                                                                      ;\
196
        .string str                                                     ;\
197
                                                                        ;\
198
        .section .text                                                  ;\
199
        l.movhi reg,hi(1b)                                              ;\
200
        l.ori   reg,reg,lo(1b)
201
 
202
/* ----------------------------------------------------------------------------
203
 * Macro to print a character
204
 *
205
 * Arguments:
206
 *   c  The character to print
207
 * ------------------------------------------------------------------------- */
208
#define PUTC(c)                                                          \
209
        l.addi  r3,r0,c                                                 ;\
210
        l.nop   NOP_PUTC
211
 
212
/* ----------------------------------------------------------------------------
213
 * Macro for recording the result of a test
214
 *
215
 * The test result is in r4. Print out the name of test indented two spaces,
216
 * followed by  ": ", either "OK" or "Failed" and a newline.
217
 *
218
 * Arguments:
219
 *   str  Textual name of the test
220
 *   reg  The result to test (not r2)
221
 *   val  Desired result of the test
222
 * ------------------------------------------------------------------------- */
223
#define CHECK_RES(str,reg,val)                                           \
224
        .section .rodata                                                ;\
225
2:                                                                      ;\
226
        .string str                                                     ;\
227
                                                                        ;\
228
        .section .text                                                  ;\
229
        PUSH (reg)                      /* Save the register to test */ ;\
230
                                                                        ;\
231
        LOAD_CONST (r3,2b)              /* Print out the string */      ;\
232
        l.jal   _ptest                                                  ;\
233
        l.nop                                                           ;\
234
                                                                        ;\
235
        LOAD_CONST(r2,val)              /* The desired result */        ;\
236
        POP (reg)                       /* The register to test */      ;\
237
        PUSH (reg)                      /* May need again later */      ;\
238
        l.sfeq  r2,reg                  /* Does the result match? */    ;\
239
        l.bf    3f                                                      ;\
240
        l.nop                                                           ;\
241
                                                                        ;\
242
        l.jal   _pfail                  /* Test failed */               ;\
243
        l.nop                                                           ;\
244
        POP (reg)                       /* Report the register */       ;\
245
        l.add   r3,r0,reg                                               ;\
246
        l.j     4f                                                      ;\
247
        l.nop   NOP_REPORT                                              ;\
248
3:                                                                      ;\
249
        POP (reg)                       /* Discard the register */      ;\
250
        l.jal   _pok                    /* Test succeeded */            ;\
251
        l.nop                                                           ;\
252
4:
253
 
254
/* ----------------------------------------------------------------------------
255
 * Macro for recording the result of a comparison
256
 *
257
 * If the flag is set print the string argument indented by 2 spaces, followed
258
 * by "TRUE" and a  newline, otherwise print the string argument indented by
259
 * two spaces, followed by "FALSE" and a newline.
260
 *
261
 * Arguments:
262
 *   str  Textual name of the test
263
 *   res  Expected result (TRUE or FALSE)
264
 * ------------------------------------------------------------------------- */
265
#define CHECK_FLAG(str,res)                                              \
266
        .section .rodata                                                ;\
267
5:                                                                      ;\
268
        .string str                                                     ;\
269
                                                                        ;\
270
        .section .text                                                  ;\
271
        l.bnf   7f                      /* Branch if result FALSE */    ;\
272
                                                                        ;\
273
        /* Branch for TRUE result */                                    ;\
274
        LOAD_CONST (r3,5b)              /* The string to print */       ;\
275
        l.jal   _ptest                                                  ;\
276
        l.nop                                                           ;\
277
                                                                        ;\
278
        l.addi  r2,r0,TRUE              /* Was it expected? */          ;\
279
        l.addi  r3,r0,res                                               ;\
280
        l.sfeq  r2,r3                                                   ;\
281
        l.bnf   6f                      /* Branch if not expected */    ;\
282
                                                                        ;\
283
        /* Sub-branch for TRUE found and expected */                    ;\
284
        l.jal   _ptrue                                                  ;\
285
        l.nop                                                           ;\
286
        PUTC ('\n')                                                     ;\
287
        l.j     9f                                                      ;\
288
        l.nop                                                           ;\
289
6:                                                                      ;\
290
        /* Sub-branch for TRUE found and not expected */                ;\
291
        l.jal   _ptrue                                                  ;\
292
        l.nop                                                           ;\
293
        l.jal   _punexpected                                            ;\
294
        l.nop                                                           ;\
295
        l.j     9f                                                      ;\
296
        l.nop                                                           ;\
297
                                                                        ;\
298
7:                                                                      ;\
299
        /* Branch for FALSE result */                                   ;\
300
        LOAD_CONST (r3,5b)              /* The string to print */       ;\
301
        l.jal   _ptest                                                  ;\
302
        l.nop                                                           ;\
303
                                                                        ;\
304
        l.addi  r2,r0,FALSE             /* Was it expected? */          ;\
305
        l.addi  r3,r0,res                                               ;\
306
        l.sfeq  r2,r3                                                   ;\
307
        l.bnf   8f                      /* Branch if not expected */    ;\
308
                                                                        ;\
309
        /* Sub-branch for FALSE found and expected */                   ;\
310
        l.jal   _pfalse                                                 ;\
311
        l.nop                                                           ;\
312
        PUTC ('\n')                                                     ;\
313
        l.j     9f                                                      ;\
314
        l.nop                                                           ;\
315
8:                                                                      ;\
316
        /* Sub-branch for FALSE found and not expected */               ;\
317
        l.jal   _pfalse                                                 ;\
318
        l.nop                                                           ;\
319
        l.jal   _punexpected                                            ;\
320
        l.nop                                                           ;\
321
9:
322
 
323
/* ----------------------------------------------------------------------------
324 233 julius
 * Macro for setting rounding mode in FPCSR
325
 *
326
 * Arguments:
327
 *   rm  round mode macro from spr-defs.h
328
 * ------------------------------------------------------------------------- */
329
#define SET_RM(rm)                                               \
330
        l.mfspr r4, r0, SPR_FPCSR                               ;\
331
        /* Clear rounding mode bits */                          ;\
332
        l.ori   r4, r4, SPR_FPCSR_RM                            ;\
333
        l.xori  r4, r4, SPR_FPCSR_RM                            ;\
334
        /* Set desired rounding mode bits */                    ;\
335
        l.ori r4, r4, rm                                        ;\
336
        l.mtspr r0, r4, SPR_FPCSR
337
 
338
 
339
 
340
/* ----------------------------------------------------------------------------
341 104 jeremybenn
 * Simple stack, will be pointed to by r1, which is the next empty slot
342
 * ------------------------------------------------------------------------- */
343
        .section .data
344
        .balign 4
345
        .global _stack
346
_stack:
347
        .space  0x1000,0x0
348
 
349
/* ----------------------------------------------------------------------------
350
 * reset exception
351
 * ------------------------------------------------------------------------- */
352 458 julius
        .section .except,"ax"
353
 
354 104 jeremybenn
        .org 0x100
355
_reset:
356 787 jeremybenn
    // Clear R0 on start-up. There is no guarantee that R0 is hardwired to zero,
357
    // and indeed it is not when simulating the or1200 Verilog core.
358
    l.andi  r0,r0,0x0
359
 
360 104 jeremybenn
        l.movhi r1,hi(_stack)           /* Set up the stack */
361
        l.ori   r1,r1,lo(_stack)
362 458 julius
 
363
        l.movhi r3,hi(start)            /* Jump to test start */
364
        l.ori   r3,r3,lo(start)
365 104 jeremybenn
        l.jr    r3
366
        l.nop
367 458 julius
 
368
        .org 0x700
369
illegal_insn:
370
        l.nop
371
        .section .rodata                                                ;\
372
1:                                                                      ;\
373
        .string "Illegal instruction. Enable hardware FPU.\n"           ;\
374
                                                                        ;\
375
        .section .except,"ax"                                                   ;\
376
        l.movhi r3,hi(1b)                                               ;\
377
        l.ori   r3,r3,lo(1b)
378
        l.jal   _puts
379
        l.nop
380
 
381
        .section .rodata                                                ;\
382
1:                                                                      ;\
383
        .string "Exiting.\n"                                            ;\
384
                                                                        ;\
385
        .section .except,"ax"                                                   ;\
386
        l.movhi r3,hi(1b)                                               ;\
387
        l.ori   r3,r3,lo(1b)
388
        l.jal   _puts
389
        l.nop
390
 
391
        l.addi  r3,r0,1
392
        l.nop   NOP_EXIT
393
 
394 104 jeremybenn
 
395 458 julius
        .section .text
396 104 jeremybenn
/* ----------------------------------------------------------------------------
397
 * Subroutine to print out a string
398
 *
399
 * The string is followed by a newline
400
 *
401
 * Parameters:
402
 *  r3  Pointer to the string to print
403
 * ------------------------------------------------------------------------- */
404
_puts:
405
        l.add   r2,r0,r3                /* Copy the string pointer */
406
 
407
        /* Loop getting and printing each char until end of string */
408
10:
409
        l.lbz   r3,0(r2)
410
        l.sfeq  r3,r0                   /* NULL termination? */
411
        l.bf    11f
412
 
413
        l.addi  r2,r2,1                 /* Delay slot, move to next char */
414
        l.j     10b                     /* Repeat */
415
        l.nop   NOP_PUTC                /* Delay slot */
416
 
417
11:
418
        l.jr    r9                      /* Return */
419
        l.nop
420
 
421
/* ----------------------------------------------------------------------------
422
 * Subroutine to print out a test name prompt
423
 *
424
 * The string is preceded by two spaces
425
 *
426
 * Parameters:
427
 *  r3  Pointer to the test name to print
428
 * ------------------------------------------------------------------------- */
429
_ptest:
430
        PUSH(r9)                        /* Save the return address */
431
        PUSH(r3)                        /* Save the test name for later */
432
 
433
        LOAD_STR(r3, "  ")              /* Prefix */
434
        l.jal   _puts
435
        l.nop
436
 
437
        POP(r3)                         /* Test name */
438
        l.jal   _puts
439
        l.nop
440
 
441
        POP (r9)
442
        l.jr    r9
443
 
444
 
445
/* ----------------------------------------------------------------------------
446
 * Subroutine to print out "OK"
447
 *
448
 * The string is followed by a newline
449
 * ------------------------------------------------------------------------- */
450
_pok:
451
        PUSH(r9)                        /* Save the return address */
452
 
453
        LOAD_STR(r3, "OK\n")
454
        l.jal   _puts
455
        l.nop
456
 
457
        POP (r9)
458
        l.jr    r9
459
 
460
 
461
/* ----------------------------------------------------------------------------
462
 * Subroutine to print out "Failed"
463
 *
464
 * The string is followed by a ": ", which will then allow a report
465
 * ------------------------------------------------------------------------- */
466
_pfail:
467
        PUSH(r9)                        /* Save the return address */
468
 
469
        LOAD_STR(r3, "Failed: ")
470
        l.jal   _puts
471
        l.nop
472
 
473
        POP (r9)
474
        l.jr    r9
475
 
476
/* ----------------------------------------------------------------------------
477
 * Subroutine to print out "TRUE"
478
 * ------------------------------------------------------------------------- */
479
_ptrue:
480
        PUSH(r9)                        /* Save the return address */
481
 
482
        LOAD_STR(r3, "TRUE")
483
        l.jal   _puts
484
        l.nop
485
 
486
        POP (r9)
487
        l.jr    r9
488
 
489
 
490
/* ----------------------------------------------------------------------------
491
 * Subroutine to print out "FALSE"
492
 * ------------------------------------------------------------------------- */
493
_pfalse:
494
        PUSH(r9)                        /* Save the return address */
495
 
496
        LOAD_STR(r3, "FALSE")
497
        l.jal   _puts
498
        l.nop
499
 
500
        POP (r9)
501
        l.jr    r9
502
 
503
/* ----------------------------------------------------------------------------
504
 * Subroutine to print out "unexpected"
505
 *
506
 * Preceded by a space and followed by a newline
507
 * ------------------------------------------------------------------------- */
508
_punexpected:
509
        PUSH(r9)                        /* Save the return address */
510
 
511
        LOAD_STR(r3, " unexpected\n")
512
        l.jal   _puts
513
        l.nop
514
 
515
        POP (r9)
516
        l.jr    r9
517
 
518
/* ----------------------------------------------------------------------------
519 458 julius
 * Start of tests
520 104 jeremybenn
 * ------------------------------------------------------------------------- */
521 458 julius
 
522
start:
523
 
524 104 jeremybenn
/* ----------------------------------------------------------------------------
525
 * Test of single precision add: lf.add.s
526
 * ------------------------------------------------------------------------- */
527 458 julius
 
528 104 jeremybenn
_add_s:
529
        LOAD_STR (r3, "lf.add.s\n")
530
        l.jal   _puts
531
        l.nop
532
 
533
        /* Simple integer addition */
534
        LOAD_CONST (r5,FP_S_ONE)
535
        LOAD_CONST (r6,FP_S_P_ZERO)
536
        lf.add.s  r4,r5,r6
537
        CHECK_RES (" 1.0 +  0.0  =  1.0:  ", r4, FP_S_ONE)
538
 
539
        LOAD_CONST (r5,FP_S_ONE)
540
        LOAD_CONST (r6,FP_S_N_ZERO)
541
        lf.add.s  r4,r5,r6
542
        CHECK_RES (" 1.0 + -0.0  =  1.0:  ", r4, FP_S_ONE)
543
 
544
        LOAD_CONST (r5,FP_S_ONE)
545
        LOAD_CONST (r6,FP_S_ONE)
546
        lf.add.s  r4,r5,r6
547
        CHECK_RES (" 1.0 +  1.0  =  2.0:  ", r4, FP_S_TWO)
548
 
549
        LOAD_CONST (r5,FP_S_TWO)
550
        LOAD_CONST (r6,FP_S_ONE)
551
        lf.add.s  r4,r5,r6
552
        CHECK_RES (" 2.0 +  1.0  =  3.0:  ", r4, FP_S_THREE)
553
 
554
        /* Fractional addition */
555
        LOAD_CONST (r5,FP_S_1_5)
556
        LOAD_CONST (r6,FP_S_1_5)
557
        lf.add.s  r4,r5,r6
558
        CHECK_RES (" 1.5 +  1.5  =  3.0:  ", r4, FP_S_THREE)
559
 
560
        /* Addition with negative numbers */
561
        LOAD_CONST (r5,FP_S_TWO)
562
        LOAD_CONST (r6,FP_S_N_ONE)
563
        lf.add.s  r4,r5,r6
564
        CHECK_RES (" 2.0 + -1.0  =  1.0:  ", r4, FP_S_ONE)
565
 
566
        LOAD_CONST (r5,FP_S_ONE)
567
        LOAD_CONST (r6,FP_S_N_TWO)
568
        lf.add.s  r4,r5,r6
569
        CHECK_RES (" 1.0 + -2.0  = -1.0:  ", r4, FP_S_N_ONE)
570
 
571
        LOAD_CONST (r5,FP_S_ONE)
572
        LOAD_CONST (r6,FP_S_N_ONE)
573
        lf.add.s  r4,r5,r6
574
        CHECK_RES (" 1.0 + -1.0  = +0.0:  ", r4, FP_S_P_ZERO)
575
 
576
        /* Addition with infinities */
577
        LOAD_CONST (r5,FP_S_ONE)
578
        LOAD_CONST (r6,FP_S_P_INF)
579
        lf.add.s  r4,r5,r6
580
        CHECK_RES (" 1.0 + +inf  = +inf:  ", r4, FP_S_P_INF)
581
 
582
        LOAD_CONST (r5,FP_S_ONE)
583
        LOAD_CONST (r6,FP_S_N_INF)
584
        lf.add.s  r4,r5,r6
585
        CHECK_RES (" 1.0 + -inf  = -inf:  ", r4, FP_S_N_INF)
586
 
587
        LOAD_CONST (r5,FP_S_P_INF)
588
        LOAD_CONST (r6,FP_S_P_INF)
589
        lf.add.s  r4,r5,r6
590
        CHECK_RES ("+inf + +inf  = +inf:  ", r4, FP_S_P_INF)
591
 
592
        LOAD_CONST (r5,FP_S_P_INF)
593
        LOAD_CONST (r6,FP_S_N_INF)
594
        lf.add.s  r4,r5,r6
595
        CHECK_RES ("+inf + -inf  = -NaN:  ", r4, FP_S_N_NAN)
596
 
597
        LOAD_CONST (r5,FP_S_N_INF)
598
        LOAD_CONST (r6,FP_S_N_INF)
599
        lf.add.s  r4,r5,r6
600
        CHECK_RES ("-inf + -inf  = -inf:  ", r4, FP_S_N_INF)
601
 
602
        /* Addition with NaNs */
603
        LOAD_CONST (r5,FP_S_ONE)
604
        LOAD_CONST (r6,FP_S_P_NAN)
605
        lf.add.s  r4,r5,r6
606
        CHECK_RES (" 1.0 + +NaN  = +NaN:  ", r4, FP_S_P_NAN)
607
 
608
        LOAD_CONST (r5,FP_S_ONE)
609
        LOAD_CONST (r6,FP_S_N_NAN)
610
        lf.add.s  r4,r5,r6
611
        CHECK_RES (" 1.0 + -NaN  = -NaN:  ", r4, FP_S_N_NAN)
612
 
613
        LOAD_CONST (r5,FP_S_P_NAN)
614
        LOAD_CONST (r6,FP_S_P_NAN)
615
        lf.add.s  r4,r5,r6
616
        CHECK_RES ("+NaN + +NaN  = +NaN:  ", r4, FP_S_P_NAN)
617
 
618
        LOAD_CONST (r5,FP_S_P_NAN)
619
        LOAD_CONST (r6,FP_S_N_NAN)
620
        lf.add.s  r4,r5,r6
621
        CHECK_RES ("+NaN + -NaN  = +NaN:  ", r4, FP_S_P_NAN)
622
 
623
        LOAD_CONST (r5,FP_S_N_NAN)
624
        LOAD_CONST (r6,FP_S_N_NAN)
625
        lf.add.s  r4,r5,r6
626
        CHECK_RES ("-NaN + -NaN  = -NaN:  ", r4, FP_S_N_NAN)
627
 
628
        LOAD_CONST (r5,FP_S_ONE)
629
        LOAD_CONST (r6,FP_S_P_NAN_B)
630
        lf.add.s  r4,r5,r6
631
        CHECK_RES (" 1.0 + +sNaN = +qNaN: ", r4, 0x7fc00001)
632
 
633
        LOAD_CONST (r5,FP_S_ONE)
634
        LOAD_CONST (r6,FP_S_N_NAN_B)
635
        lf.add.s  r4,r5,r6
636
        CHECK_RES (" 1.0 + -sNaN = -qNaN: ", r4, 0xffc00001)
637
 
638
        /* Addition with overflow */
639
        LOAD_CONST (r5,FP_S_HUGE2)
640
        LOAD_CONST (r6,FP_S_HUGE2)
641
        lf.add.s  r4,r5,r6
642
        CHECK_RES (" 1.0 * 2^127 +  1.0 * 2^127  = +inf:  ", r4, FP_S_P_INF)
643
 
644
        LOAD_CONST (r5,FP_S_N_HUGE2)
645
        LOAD_CONST (r6,FP_S_N_HUGE2)
646
        lf.add.s  r4,r5,r6
647
        CHECK_RES ("-1.0 * 2^127 + -1.0 * 2^127  = -inf:  ", r4, FP_S_N_INF)
648
 
649
/* ----------------------------------------------------------------------------
650
 * Test of single precision custom instruction: lf.cust1.s
651
 * ------------------------------------------------------------------------- */
652
_cust1_s:
653
        LOAD_STR (r3, "lf.cust1.s\n")
654
        l.jal   _puts
655
        l.nop
656
 
657
        /* Just test that the instruction does nothing */
658
        LOAD_CONST (r4,FP_S_ONE)
659
        LOAD_CONST (r5,FP_S_TWO)
660
        lf.cust1.s  r4,r5               /* Should do nothing */
661
        CHECK_RES ("l.cust1: ", r4, FP_S_ONE)
662
 
663
/* ----------------------------------------------------------------------------
664
 * Test of single precision divide instruction: lf.div.s
665
 * ------------------------------------------------------------------------- */
666
_div_s:
667
        LOAD_STR (r3, "lf.div.s\n")
668
        l.jal   _puts
669
        l.nop
670
 
671
        /* Tests of integer division */
672
        LOAD_CONST (r5,FP_S_ONE)
673
        LOAD_CONST (r6,FP_S_ONE)
674
        lf.div.s  r4,r5,r6
675
        CHECK_RES (" 1.0 /  1.0 =  1.0: ", r4, FP_S_ONE)
676
 
677
        LOAD_CONST (r5,FP_S_TWO)
678
        LOAD_CONST (r6,FP_S_ONE)
679
        lf.div.s  r4,r5,r6
680
        CHECK_RES (" 2.0 /  1.0 =  2.0: ", r4, FP_S_TWO)
681
 
682
        /* Test division with fractional result */
683
        LOAD_CONST (r5,FP_S_THREE)
684
        LOAD_CONST (r6,FP_S_TWO)
685
        lf.div.s  r4,r5,r6
686
        CHECK_RES (" 3.0 /  2.0 =  1.5: ", r4, FP_S_1_5)
687
 
688
        /* Test division of zero */
689
        LOAD_CONST (r5,FP_S_P_ZERO)
690
        LOAD_CONST (r6,FP_S_ONE)
691
        lf.div.s  r4,r5,r6
692
        CHECK_RES ("+0.0 /  1.0 = +0.0: ", r4, FP_S_P_ZERO)
693
 
694
        LOAD_CONST (r5,FP_S_N_ZERO)
695
        LOAD_CONST (r6,FP_S_ONE)
696
        lf.div.s  r4,r5,r6
697
        CHECK_RES ("-0.0 /  1.0 = -0.0: ", r4, FP_S_N_ZERO)
698
 
699
        /* Test signed division */
700
        LOAD_CONST (r5,FP_S_N_THREE)
701
        LOAD_CONST (r6,FP_S_TWO)
702
        lf.div.s  r4,r5,r6
703
        CHECK_RES ("-3.0 /  2.0 = -1.5: ", r4, FP_S_N_1_5)
704
 
705
        LOAD_CONST (r5,FP_S_THREE)
706
        LOAD_CONST (r6,FP_S_N_TWO)
707
        lf.div.s  r4,r5,r6
708
        CHECK_RES (" 3.0 / -2.0 = -1.5: ", r4, FP_S_N_1_5)
709
 
710
        LOAD_CONST (r5,FP_S_N_THREE)
711
        LOAD_CONST (r6,FP_S_N_TWO)
712
        lf.div.s  r4,r5,r6
713
        CHECK_RES ("-3.0 / -2.0 = -1.5: ", r4, FP_S_1_5)
714
 
715
        /* Division by zero */
716
        LOAD_CONST (r5,FP_S_ONE)
717
        LOAD_CONST (r6,FP_S_P_ZERO)
718
        lf.div.s  r4,r5,r6
719
        CHECK_RES (" 1.0 / +0.0 = +inf: ", r4, FP_S_P_INF)
720
 
721
        LOAD_CONST (r5,FP_S_ONE)
722
        LOAD_CONST (r6,FP_S_P_ZERO)
723
        lf.div.s  r4,r5,r6
724
        CHECK_RES (" 1.0 / -0.0 = +inf: ", r4, FP_S_P_INF)
725
 
726
        LOAD_CONST (r5,FP_S_N_ONE)
727
        LOAD_CONST (r6,FP_S_P_ZERO)
728
        lf.div.s  r4,r5,r6
729
        CHECK_RES ("-1.0 / +0.0 = -inf: ", r4, FP_S_N_INF)
730
 
731
        LOAD_CONST (r5,FP_S_N_ONE)
732
        LOAD_CONST (r6,FP_S_P_ZERO)
733
        lf.div.s  r4,r5,r6
734
        CHECK_RES ("-1.0 / -0.0 = -inf: ", r4, FP_S_N_INF)
735
 
736
        /* Division with infinities */
737
        LOAD_CONST (r5,FP_S_ONE)
738
        LOAD_CONST (r6,FP_S_P_INF)
739
        lf.div.s  r4,r5,r6
740
        CHECK_RES (" 1.0 / +inf = +0.0: ", r4, FP_S_P_ZERO)
741
 
742
        LOAD_CONST (r5,FP_S_ONE)
743
        LOAD_CONST (r6,FP_S_N_INF)
744
        lf.div.s  r4,r5,r6
745
        CHECK_RES (" 1.0 / -inf = -0.0: ", r4, FP_S_N_ZERO)
746
 
747
        LOAD_CONST (r5,FP_S_N_ONE)
748
        LOAD_CONST (r6,FP_S_P_INF)
749
        lf.div.s  r4,r5,r6
750
        CHECK_RES ("-1.0 / +inf = -0.0: ", r4, FP_S_N_ZERO)
751
 
752
        LOAD_CONST (r5,FP_S_N_ONE)
753
        LOAD_CONST (r6,FP_S_N_INF)
754
        lf.div.s  r4,r5,r6
755
        CHECK_RES ("-1.0 / -inf = +0.0: ", r4, FP_S_P_ZERO)
756
 
757
        LOAD_CONST (r5,FP_S_P_INF)
758
        LOAD_CONST (r6,FP_S_ONE)
759
        lf.div.s  r4,r5,r6
760
        CHECK_RES ("+inf /  1.0 = +inf: ", r4, FP_S_P_INF)
761
 
762
        LOAD_CONST (r5,FP_S_N_INF)
763
        LOAD_CONST (r6,FP_S_ONE)
764
        lf.div.s  r4,r5,r6
765
        CHECK_RES ("-inf /  1.0 = -inf: ", r4, FP_S_N_INF)
766
 
767
        LOAD_CONST (r5,FP_S_P_INF)
768
        LOAD_CONST (r6,FP_S_N_ONE)
769
        lf.div.s  r4,r5,r6
770
        CHECK_RES ("+inf / -1.0 = -inf: ", r4, FP_S_N_INF)
771
 
772
        LOAD_CONST (r5,FP_S_N_INF)
773
        LOAD_CONST (r6,FP_S_N_ONE)
774
        lf.div.s  r4,r5,r6
775
        CHECK_RES ("-inf / -1.0 = +inf: ", r4, FP_S_P_INF)
776
 
777
        LOAD_CONST (r5,FP_S_P_INF)
778
        LOAD_CONST (r6,FP_S_P_INF)
779
        lf.div.s  r4,r5,r6
780
        CHECK_RES ("+inf / +inf = -NaN: ", r4, FP_S_N_NAN)
781
 
782
        LOAD_CONST (r5,FP_S_P_INF)
783
        LOAD_CONST (r6,FP_S_N_INF)
784
        lf.div.s  r4,r5,r6
785
        CHECK_RES ("+inf / -inf = -NaN: ", r4, FP_S_N_NAN)
786
 
787
        LOAD_CONST (r5,FP_S_N_INF)
788
        LOAD_CONST (r6,FP_S_P_INF)
789
        lf.div.s  r4,r5,r6
790
        CHECK_RES ("-inf / +inf = -NaN: ", r4, FP_S_N_NAN)
791
 
792
        LOAD_CONST (r5,FP_S_N_INF)
793
        LOAD_CONST (r6,FP_S_N_INF)
794
        lf.div.s  r4,r5,r6
795
        CHECK_RES ("-inf / -inf = -NaN: ", r4, FP_S_N_NAN)
796
 
797
        /* Division with NaNs */
798
        LOAD_CONST (r5,FP_S_ONE)
799
        LOAD_CONST (r6,FP_S_P_NAN)
800
        lf.div.s  r4,r5,r6
801
        CHECK_RES (" 1.0 / +NaN = +NaN: ", r4, FP_S_P_NAN)
802
 
803
        LOAD_CONST (r5,FP_S_ONE)
804
        LOAD_CONST (r6,FP_S_N_NAN)
805
        lf.div.s  r4,r5,r6
806
        CHECK_RES (" 1.0 / -NaN = -NaN: ", r4, FP_S_N_NAN)
807
 
808
        LOAD_CONST (r5,FP_S_N_ONE)
809
        LOAD_CONST (r6,FP_S_P_NAN)
810
        lf.div.s  r4,r5,r6
811
        CHECK_RES ("-1.0 / +NaN = +NaN: ", r4, FP_S_P_NAN)
812
 
813
        LOAD_CONST (r5,FP_S_N_ONE)
814
        LOAD_CONST (r6,FP_S_N_NAN)
815
        lf.div.s  r4,r5,r6
816
        CHECK_RES ("-1.0 / -NaN = 1NaN: ", r4, FP_S_N_NAN)
817
 
818
        LOAD_CONST (r5,FP_S_P_NAN)
819
        LOAD_CONST (r6,FP_S_ONE)
820
        lf.div.s  r4,r5,r6
821
        CHECK_RES ("+NaN /  1.0 = +NaN: ", r4, FP_S_P_NAN)
822
 
823
        LOAD_CONST (r5,FP_S_N_NAN)
824
        LOAD_CONST (r6,FP_S_ONE)
825
        lf.div.s  r4,r5,r6
826
        CHECK_RES ("-NaN /  1.0 = -NaN: ", r4, FP_S_N_NAN)
827
 
828
        LOAD_CONST (r5,FP_S_P_NAN)
829
        LOAD_CONST (r6,FP_S_N_ONE)
830
        lf.div.s  r4,r5,r6
831
        CHECK_RES ("+NaN / -1.0 = +NaN: ", r4, FP_S_P_NAN)
832
 
833
        LOAD_CONST (r5,FP_S_N_NAN)
834
        LOAD_CONST (r6,FP_S_N_ONE)
835
        lf.div.s  r4,r5,r6
836
        CHECK_RES ("-NaN / -1.0 = -NaN: ", r4, FP_S_N_NAN)
837
 
838
        LOAD_CONST (r5,FP_S_P_NAN)
839
        LOAD_CONST (r6,FP_S_P_NAN)
840
        lf.div.s  r4,r5,r6
841
        CHECK_RES ("+NaN / +NaN = +NaN: ", r4, FP_S_P_NAN)
842
 
843
        LOAD_CONST (r5,FP_S_P_NAN)
844
        LOAD_CONST (r6,FP_S_N_NAN)
845
        lf.div.s  r4,r5,r6
846
        CHECK_RES ("+NaN / -NaN = +NaN: ", r4, FP_S_P_NAN)
847
 
848
        LOAD_CONST (r5,FP_S_N_NAN)
849
        LOAD_CONST (r6,FP_S_P_NAN)
850
        lf.div.s  r4,r5,r6
851 233 julius
        CHECK_RES ("-NaN / +NaN = -NaN: ", r4, FP_S_N_NAN)
852 104 jeremybenn
 
853
        LOAD_CONST (r5,FP_S_N_NAN)
854
        LOAD_CONST (r6,FP_S_N_NAN)
855
        lf.div.s  r4,r5,r6
856
        CHECK_RES ("-NaN / -NaN = -NaN: ", r4, FP_S_N_NAN)
857
 
858
        /* Division with overflow */
859
        LOAD_CONST (r5,FP_S_HUGE2)
860
        LOAD_CONST (r6,FP_S_SMALL1)
861
        lf.div.s  r4,r5,r6
862
        CHECK_RES (" 1.0 * 2^127  /  1.0 * 2^-129 = +inf: ", r4, FP_S_P_INF)
863
 
864
        LOAD_CONST (r5,FP_S_N_HUGE2)
865
        LOAD_CONST (r6,FP_S_SMALL1)
866
        lf.div.s  r4,r5,r6
867
        CHECK_RES ("-1.0 * 2^127  /  1.0 * 2^-129 = -inf: ", r4, FP_S_N_INF)
868
 
869
        LOAD_CONST (r5,FP_S_HUGE2)
870
        LOAD_CONST (r6,FP_S_N_SMALL1)
871
        lf.div.s  r4,r5,r6
872
        CHECK_RES (" 1.0 * 2^127  / -1.0 * 2^-129 = -inf: ", r4, FP_S_N_INF)
873
 
874
        LOAD_CONST (r5,FP_S_N_HUGE2)
875
        LOAD_CONST (r6,FP_S_N_SMALL1)
876
        lf.div.s  r4,r5,r6
877
        CHECK_RES ("-1.0 * 2^127  / -1.0 * 2^-129 = +inf: ", r4, FP_S_P_INF)
878
 
879
        /* Division with underflow */
880
        LOAD_CONST (r5,FP_S_SMALL1)
881
        LOAD_CONST (r6,FP_S_HUGE1)
882
        lf.div.s  r4,r5,r6
883
        CHECK_RES (" 1.0 * 2^-129 /  1.0 * 2^127  = +0.0: ", r4, FP_S_P_ZERO)
884
 
885
        LOAD_CONST (r5,FP_S_N_SMALL1)
886
        LOAD_CONST (r6,FP_S_HUGE1)
887
        lf.div.s  r4,r5,r6
888
        CHECK_RES ("-1.0 * 2^-129 /  1.0 * 2^127  = -0.0: ", r4, FP_S_N_ZERO)
889
 
890
        LOAD_CONST (r5,FP_S_SMALL1)
891
        LOAD_CONST (r6,FP_S_N_HUGE1)
892
        lf.div.s  r4,r5,r6
893
        CHECK_RES (" 1.0 * 2^-129 / -1.0 * 2^127  = -0.0: ", r4, FP_S_N_ZERO)
894
 
895
        LOAD_CONST (r5,FP_S_N_SMALL1)
896
        LOAD_CONST (r6,FP_S_N_HUGE1)
897
        lf.div.s  r4,r5,r6
898
        CHECK_RES ("-1.0 * 2^-129 / -1.0 * 2^127  = +0.0: ", r4, FP_S_P_ZERO)
899
 
900
        /* Needs tests of normalization to denormalization */
901
 
902
/* ----------------------------------------------------------------------------
903
 * Test of single precision fp to integer conversion: lf.ftoi.s
904
 * ------------------------------------------------------------------------- */
905
v_ftoi_s:
906
        LOAD_STR (r3, "lf.ftoi.s\n")
907
        l.jal   _puts
908
        l.nop
909
 
910
        /* Integer conversion */
911
        LOAD_CONST (r5,FP_S_ONE)
912
        lf.ftoi.s  r4,r5
913
        CHECK_RES ("(int)  1.0          =  1:    ", r4, 0x00000001)
914
 
915
        LOAD_CONST (r5,FP_S_N_ONE)
916
        lf.ftoi.s  r4,r5
917
        CHECK_RES ("(int) -1.0          = -1:    ", r4, 0xffffffff)
918
 
919
        LOAD_CONST (r5,FP_S_P_ZERO)
920
        lf.ftoi.s  r4,r5
921
        CHECK_RES ("(int) +0.0          =  0:    ", r4, 0x00000000)
922
 
923
        LOAD_CONST (r5,FP_S_N_ZERO)
924
        lf.ftoi.s  r4,r5
925
        CHECK_RES ("(int) -0.0          =  0:    ", r4, 0x00000000)
926
 
927
        /* Fractional conversion (round towards zero) */
928 233 julius
        SET_RM  (FPCSR_RM_RZ)
929 104 jeremybenn
        LOAD_CONST (r5,FP_S_1_5)
930
        lf.ftoi.s  r4,r5
931
        CHECK_RES ("(int)  1.5          =  1:    ", r4, 0x00000001)
932
 
933
        LOAD_CONST (r5,FP_S_N_1_5)
934
        lf.ftoi.s  r4,r5
935
        CHECK_RES ("(int) -1.5          = -1:    ", r4, 0xffffffff)
936
 
937
        /* Conversion of values too big */
938
        LOAD_CONST (r5,FP_S_HUGE1)
939
        lf.ftoi.s  r4,r5
940 233 julius
        CHECK_RES ("(int)  1.0 * 2^126  = 2^31: ", r4, 0x7fffffff)
941 104 jeremybenn
 
942
        LOAD_CONST (r5,FP_S_N_HUGE1)
943
        lf.ftoi.s  r4,r5
944
        CHECK_RES ("(int) -1.0 * 2^126  = -2^31: ", r4, 0x80000000)
945
 
946
        /* Conversion of very small values */
947
        LOAD_CONST (r5,FP_S_SMALL1)
948
        lf.ftoi.s  r4,r5
949
        CHECK_RES ("(int)  1.0 * 2^-129 =  0:    ", r4, 0x00000000)
950
 
951
        LOAD_CONST (r5,FP_S_N_SMALL1)
952
        lf.ftoi.s  r4,r5
953
        CHECK_RES ("(int) -1.0 * 2^-129 =  0:    ", r4, 0x00000000)
954
 
955
        /* Just basic check of Infinity & NaN */
956
        LOAD_CONST (r5,FP_S_P_INF)
957
        lf.ftoi.s  r4,r5
958 233 julius
        CHECK_RES ("(int) +inf          = 2^31: ", r4, 0x7fffffff)
959 104 jeremybenn
 
960
        LOAD_CONST (r5,FP_S_N_INF)
961
        lf.ftoi.s  r4,r5
962
        CHECK_RES ("(int) -inf          = -2^31: ", r4, 0x80000000)
963
 
964
        LOAD_CONST (r5,FP_S_P_NAN)
965
        lf.ftoi.s  r4,r5
966 233 julius
        CHECK_RES ("(int) +NaN          = 2^31: ", r4, 0x7fffffff)
967 104 jeremybenn
 
968
        LOAD_CONST (r5,FP_S_N_NAN)
969
        lf.ftoi.s  r4,r5
970 233 julius
        CHECK_RES ("(int) -NaN          = 2^31: ", r4, 0x7fffffff)
971 104 jeremybenn
 
972
/* ----------------------------------------------------------------------------
973
 * Test of single precision integer to fp conversion: lf.itof.s
974
 * ------------------------------------------------------------------------- */
975
_itof_s:
976
        LOAD_STR (r3, "lf.itof.s\n")
977
        l.jal   _puts
978
        l.nop
979
 
980
        /* Integer conversion */
981
        LOAD_CONST (r5,FP_S_ONE)
982
        lf.ftoi.s  r4,r5
983
        CHECK_RES ("(float)  1.0 =  1: ", r4, 0x00000001)
984
 
985
        LOAD_CONST (r5,FP_S_N_ONE)
986
        lf.ftoi.s  r4,r5
987
        CHECK_RES ("(float) -1.0 = -1: ", r4, 0xffffffff)
988
 
989
        LOAD_CONST (r5,FP_S_P_ZERO)
990
        lf.ftoi.s  r4,r5
991
        CHECK_RES ("(float) +0.0 =  0: ", r4, 0x00000000)
992
 
993
        LOAD_CONST (r5,FP_S_N_ZERO)
994
        lf.ftoi.s  r4,r5
995
        CHECK_RES ("(float) -0.0 =  0: ", r4, 0x00000000)
996
 
997
/* ----------------------------------------------------------------------------
998
 * Test of single precision multiply and add: lf.madd.s
999
 * ------------------------------------------------------------------------- */
1000
_madd_s:
1001
        LOAD_STR (r3, "lf.madd.s\n")
1002
        l.jal   _puts
1003
        l.nop
1004
 
1005
        /* Test of integer multiply and add */
1006
        LOAD_CONST (r4,FP_S_ONE)
1007
        LOAD_CONST (r5,FP_S_ONE)
1008
        LOAD_CONST (r6,FP_S_ONE)
1009
        lf.madd.s  r4,r5,r6
1010
        CHECK_RES (" 1.0 +  1.0 *  1.0 =  2.0: ", r4, FP_S_TWO)
1011
 
1012
        /* Multiply and add with fractions */
1013
        LOAD_CONST (r4,FP_S_0_5)
1014
        LOAD_CONST (r5,FP_S_ONE)
1015
        LOAD_CONST (r6,FP_S_ONE)
1016
        lf.madd.s  r4,r5,r6
1017
        CHECK_RES (" 0.5 +  1.0 *  1.0 =  1.5: ", r4, FP_S_1_5)
1018
 
1019
        LOAD_CONST (r4,FP_S_ONE)
1020
        LOAD_CONST (r5,FP_S_0_5)
1021
        LOAD_CONST (r6,FP_S_TWO)
1022
        lf.madd.s  r4,r5,r6
1023
        CHECK_RES (" 1.0 +  0.5 *  2.0 =  2.0: ", r4, FP_S_TWO)
1024
 
1025
        /* Multiply and add with negative numbers */
1026
        LOAD_CONST (r4,FP_S_ONE)
1027
        LOAD_CONST (r5,FP_S_N_ONE)
1028
        LOAD_CONST (r6,FP_S_TWO)
1029
        lf.madd.s  r4,r5,r6
1030
        CHECK_RES (" 1.0 + -1.0 *  2.0 = -1.0: ", r4, FP_S_N_ONE)
1031
 
1032
        LOAD_CONST (r4,FP_S_N_TWO)
1033
        LOAD_CONST (r5,FP_S_TWO)
1034
        LOAD_CONST (r6,FP_S_0_5)
1035
        lf.madd.s  r4,r5,r6
1036
        CHECK_RES ("-2.0 +  2.0 *  0.5 = -1.0: ", r4, FP_S_N_ONE)
1037
 
1038
        LOAD_CONST (r4,FP_S_N_0_5)
1039
        LOAD_CONST (r5,FP_S_N_0_5)
1040
        LOAD_CONST (r6,FP_S_THREE)
1041
        lf.madd.s  r4,r5,r6
1042
        CHECK_RES ("-0.5 + -0.5 *  3.0 = -2.0: ", r4, FP_S_N_TWO)
1043
 
1044
        /* Multiply and add with zeros (more needed) */
1045
        LOAD_CONST (r4,FP_S_P_ZERO)
1046
        LOAD_CONST (r5,FP_S_P_ZERO)
1047
        LOAD_CONST (r6,FP_S_P_ZERO)
1048
        lf.madd.s  r4,r5,r6
1049
        CHECK_RES ("+0.0 + +0.0 * +0.0 = +0.0: ", r4, FP_S_P_ZERO)
1050
 
1051
        LOAD_CONST (r4,FP_S_N_ZERO)
1052
        LOAD_CONST (r5,FP_S_N_ZERO)
1053
        LOAD_CONST (r6,FP_S_N_ZERO)
1054
        lf.madd.s  r4,r5,r6
1055
        CHECK_RES ("-0.0 + +0.0 * -0.0 = +0.0: ", r4, FP_S_P_ZERO)
1056
 
1057
        LOAD_CONST (r4,FP_S_N_ZERO)
1058
        LOAD_CONST (r5,FP_S_N_ZERO)
1059
        LOAD_CONST (r6,FP_S_N_ZERO)
1060
        lf.madd.s  r4,r5,r6
1061
        CHECK_RES ("-0.0 + -0.0 * -0.0 = +0.0: ", r4, FP_S_P_ZERO)
1062
 
1063
        LOAD_CONST (r4,FP_S_N_ONE)
1064
        LOAD_CONST (r5,FP_S_ONE)
1065
        LOAD_CONST (r6,FP_S_ONE)
1066
        lf.madd.s  r4,r5,r6
1067
        CHECK_RES ("-1.0 +  1.0 *  1.0 = +0.0: ", r4, FP_S_P_ZERO)
1068
 
1069
        /* Multiply and add with infinities (more needed) */
1070
        LOAD_CONST (r4,FP_S_P_INF)
1071
        LOAD_CONST (r5,FP_S_ONE)
1072
        LOAD_CONST (r6,FP_S_ONE)
1073
        lf.madd.s  r4,r5,r6
1074
        CHECK_RES ("+inf +  1.0 *  1.0 = +inf: ", r4, FP_S_P_INF)
1075
 
1076
        LOAD_CONST (r4,FP_S_ONE)
1077
        LOAD_CONST (r5,FP_S_ONE)
1078
        LOAD_CONST (r6,FP_S_P_INF)
1079
        lf.madd.s  r4,r5,r6
1080
        CHECK_RES (" 1.0 +  1.0 * +inf = +inf: ", r4, FP_S_P_INF)
1081
 
1082
        LOAD_CONST (r4,FP_S_P_INF)
1083
        LOAD_CONST (r5,FP_S_ONE)
1084
        LOAD_CONST (r6,FP_S_P_INF)
1085
        lf.madd.s  r4,r5,r6
1086
        CHECK_RES ("+inf +  1.0 * +inf = +inf: ", r4, FP_S_P_INF)
1087
 
1088
        LOAD_CONST (r4,FP_S_N_INF)
1089
        LOAD_CONST (r5,FP_S_ONE)
1090
        LOAD_CONST (r6,FP_S_ONE)
1091
        lf.madd.s  r4,r5,r6
1092
        CHECK_RES ("-inf +  1.0 *  1.0 = -inf: ", r4, FP_S_N_INF)
1093
 
1094
        /* Multiply and add with NaNs (more needed) */
1095
        LOAD_CONST (r4,FP_S_P_NAN)
1096
        LOAD_CONST (r5,FP_S_ONE)
1097
        LOAD_CONST (r6,FP_S_ONE)
1098
        lf.madd.s  r4,r5,r6
1099
        CHECK_RES ("+NaN +  1.0 *  1.0 = +NaN: ", r4, FP_S_P_NAN)
1100
 
1101
        LOAD_CONST (r4,FP_S_ONE)
1102
        LOAD_CONST (r5,FP_S_ONE)
1103
        LOAD_CONST (r6,FP_S_P_NAN)
1104
        lf.madd.s  r4,r5,r6
1105
        CHECK_RES (" 1.0 +  1.0 * +NaN = +NaN: ", r4, FP_S_P_NAN)
1106
 
1107
        LOAD_CONST (r4,FP_S_P_NAN)
1108
        LOAD_CONST (r5,FP_S_ONE)
1109
        LOAD_CONST (r6,FP_S_P_NAN)
1110
        lf.madd.s  r4,r5,r6
1111
        CHECK_RES ("+NaN +  1.0 * +NaN = +NaN: ", r4, FP_S_P_NAN)
1112
 
1113
        LOAD_CONST (r4,FP_S_N_NAN)
1114
        LOAD_CONST (r5,FP_S_ONE)
1115
        LOAD_CONST (r6,FP_S_ONE)
1116
        lf.madd.s  r4,r5,r6
1117
        CHECK_RES ("-NaN +  1.0 *  1.0 = -NaN: ", r4, FP_S_N_NAN)
1118
 
1119
        /* Multiply and add with overflow (more needed) */
1120 233 julius
        SET_RM  (FPCSR_RM_RIP)
1121 104 jeremybenn
        LOAD_CONST (r4,FP_S_HUGE2)
1122
        LOAD_CONST (r5,FP_S_HUGE2)
1123
        LOAD_CONST (r6,FP_S_ONE)
1124
        lf.madd.s  r4,r5,r6
1125 233 julius
        CHECK_RES (" 1.0 * 2^127  +  1.0 * 2^127  *  1.0 = +inf: ",
1126 104 jeremybenn
                   r4, FP_S_P_INF)
1127
 
1128 233 julius
        SET_RM  (FPCSR_RM_RIN)
1129 104 jeremybenn
        LOAD_CONST (r4,FP_S_HUGE2)
1130
        LOAD_CONST (r5,FP_S_HUGE2)
1131
        LOAD_CONST (r6,FP_S_SMALL1)
1132
        lf.madd.s  r4,r5,r6
1133
        CHECK_RES (" 1.0 * 2^127  +  1.0 * 2^127  *  1.0 * 2^-129 = +inf: ",
1134
                   r4, FP_S_HUGE2)
1135
 
1136
/* ----------------------------------------------------------------------------
1137
 * Test of single precision multiply: lf.mul.s
1138
 * ------------------------------------------------------------------------- */
1139
_mul_s:
1140
        LOAD_STR (r3, "lf.mul.s\n")
1141
        l.jal   _puts
1142
        l.nop
1143
 
1144
        /* Tests of integer multiplication */
1145
        LOAD_CONST (r5,FP_S_ONE)
1146
        LOAD_CONST (r6,FP_S_ONE)
1147
        lf.mul.s  r4,r5,r6
1148
        CHECK_RES (" 1.0 *  1.0 =  1.0: ", r4, FP_S_ONE)
1149
 
1150
        LOAD_CONST (r5,FP_S_THREE)
1151
        LOAD_CONST (r6,FP_S_ONE)
1152
        lf.mul.s  r4,r5,r6
1153
        CHECK_RES (" 3.0 *  1.0 =  3.0: ", r4, FP_S_THREE)
1154
 
1155
        /* Multiplication with fractions */
1156
        LOAD_CONST (r5,FP_S_1_5)
1157
        LOAD_CONST (r6,FP_S_TWO)
1158
        lf.mul.s  r4,r5,r6
1159
        CHECK_RES (" 1.5 *  2.0 =  3.0: ", r4, FP_S_THREE)
1160
 
1161
        /* Multiplication with negative numbers */
1162
        LOAD_CONST (r5,FP_S_N_ONE)
1163
        LOAD_CONST (r6,FP_S_TWO)
1164
        lf.mul.s  r4,r5,r6
1165
        CHECK_RES ("-1.0 *  2.0 = -2.0: ", r4, FP_S_N_TWO)
1166
 
1167
        LOAD_CONST (r5,FP_S_N_ONE)
1168
        LOAD_CONST (r6,FP_S_N_TWO)
1169
        lf.mul.s  r4,r5,r6
1170
        CHECK_RES ("-1.0 * -2.0 = +2.0: ", r4, FP_S_TWO)
1171
 
1172
        /* Multiplication with zeros */
1173
        LOAD_CONST (r5,FP_S_P_ZERO)
1174
        LOAD_CONST (r6,FP_S_TWO)
1175
        lf.mul.s  r4,r5,r6
1176
        CHECK_RES ("+0.0 *  2.0 = +0.0: ", r4, FP_S_P_ZERO)
1177
 
1178
        LOAD_CONST (r5,FP_S_N_ZERO)
1179
        LOAD_CONST (r6,FP_S_TWO)
1180
        lf.mul.s  r4,r5,r6
1181
        CHECK_RES ("+0.0 *  2.0 = +0.0: ", r4, FP_S_N_ZERO)
1182
 
1183
        /* Multiplication with infinities (more needed) */
1184
        LOAD_CONST (r5,FP_S_P_INF)
1185
        LOAD_CONST (r6,FP_S_N_TWO)
1186
        lf.mul.s  r4,r5,r6
1187
        CHECK_RES ("+inf * -2.0 = -inf: ", r4, FP_S_N_INF)
1188
 
1189
        /* Multiplication with NaNs (more needed) */
1190
        LOAD_CONST (r5,FP_S_P_NAN)
1191
        LOAD_CONST (r6,FP_S_TWO)
1192
        lf.mul.s  r4,r5,r6
1193
        CHECK_RES ("+NaN *  2.0 = +NaN: ", r4, FP_S_P_NAN)
1194
 
1195
        /* Multiplication overflow */
1196 233 julius
        SET_RM  (FPCSR_RM_RIP)
1197
 
1198 104 jeremybenn
        LOAD_CONST (r5,FP_S_HUGE1)
1199
        LOAD_CONST (r6,FP_S_HUGE1)
1200
        lf.mul.s  r4,r5,r6
1201
        CHECK_RES (" 1.0 * 2^127 *  1.0 * 2^127 = +inf: ", r4, FP_S_P_INF)
1202
 
1203
        LOAD_CONST (r5,FP_S_N_HUGE1)
1204 233 julius
        LOAD_CONST (r6,FP_S_N_HUGE1)
1205
        lf.mul.s  r4,r5,r6
1206
        CHECK_RES ("-1.0 * 2^127 * -1.0 * 2^127 = +inf: ", r4, FP_S_P_INF)
1207
 
1208
        SET_RM  (FPCSR_RM_RIN)
1209
        LOAD_CONST (r5,FP_S_N_HUGE1)
1210 104 jeremybenn
        LOAD_CONST (r6,FP_S_HUGE1)
1211
        lf.mul.s  r4,r5,r6
1212
        CHECK_RES ("-1.0 * 2^127 *  1.0 * 2^127 = -inf: ", r4, FP_S_N_INF)
1213
 
1214
        LOAD_CONST (r5,FP_S_HUGE1)
1215
        LOAD_CONST (r6,FP_S_N_HUGE1)
1216
        lf.mul.s  r4,r5,r6
1217
        CHECK_RES (" 1.0 * 2^127 * -1.0 * 2^127 = -inf: ", r4, FP_S_N_INF)
1218
 
1219
 
1220
/* ----------------------------------------------------------------------------
1221
 * Test of single precision remainder: lf.rem.s
1222
 * ------------------------------------------------------------------------- */
1223
_rem_s:
1224
        LOAD_STR (r3, "lf.rem.s\n")
1225
        l.jal   _puts
1226
        l.nop
1227
 
1228
        /* Tests of integer remainder */
1229
        LOAD_CONST (r5,FP_S_ONE)
1230
        LOAD_CONST (r6,FP_S_ONE)
1231
        lf.rem.s  r4,r5,r6
1232
        CHECK_RES (" 1.0 %  1.0 = +0.0: ", r4, FP_S_P_ZERO)
1233
 
1234
        LOAD_CONST (r5,FP_S_ONE)
1235
        LOAD_CONST (r6,FP_S_TWO)
1236
        lf.rem.s  r4,r5,r6
1237
        CHECK_RES (" 1.0 %  2.0 =  1.0: ", r4, FP_S_ONE)
1238
 
1239
        /* Remainder with fractions */
1240 233 julius
        // FIXME: This is failing, giving rem = -0.5 with softfloat
1241
        /*
1242 104 jeremybenn
        LOAD_CONST (r5,FP_S_1_5)
1243
        LOAD_CONST (r6,FP_S_TWO)
1244
        lf.rem.s  r4,r5,r6
1245
        CHECK_RES (" 1.5 %  2.0 =  1.5: ", r4, FP_S_1_5)
1246 233 julius
        */
1247 104 jeremybenn
        LOAD_CONST (r5,FP_S_TWO)
1248
        LOAD_CONST (r6,FP_S_1_5)
1249
        lf.rem.s  r4,r5,r6
1250
        CHECK_RES (" 2.0 %  1.5 =  0.5: ", r4, FP_S_0_5)
1251
 
1252
        LOAD_CONST (r5,FP_S_THREE)
1253
        LOAD_CONST (r6,FP_S_1_5)
1254
        lf.rem.s  r4,r5,r6
1255
        CHECK_RES (" 3.0 %  1.5 = +0.0: ", r4, FP_S_P_ZERO)
1256
 
1257
        /* Remainder with negative numbers */
1258 233 julius
        // FIXME: These next 4 are failing with the wrong signs on the results!
1259
        /*
1260 104 jeremybenn
        LOAD_CONST (r5,FP_S_N_THREE)
1261
        LOAD_CONST (r6,FP_S_TWO)
1262
        lf.rem.s  r4,r5,r6
1263
        CHECK_RES ("-3.0 %  2.0 = -1.0: ", r4, FP_S_N_ONE)
1264
 
1265
        LOAD_CONST (r5,FP_S_N_THREE)
1266
        LOAD_CONST (r6,FP_S_TWO)
1267
        lf.rem.s  r4,r5,r6
1268
        CHECK_RES ("-3.0 %  2.0 = -1.0: ", r4, FP_S_N_ONE)
1269
 
1270
        LOAD_CONST (r5,FP_S_THREE)
1271
        LOAD_CONST (r6,FP_S_N_TWO)
1272
        lf.rem.s  r4,r5,r6
1273
        CHECK_RES (" 3.0 % -2.0 =  1.0: ", r4, FP_S_ONE)
1274
 
1275
        LOAD_CONST (r5,FP_S_N_THREE)
1276
        LOAD_CONST (r6,FP_S_N_TWO)
1277
        lf.rem.s  r4,r5,r6
1278
        CHECK_RES ("-3.0 % -2.0 = -1.0: ", r4, FP_S_N_ONE)
1279 233 julius
        */
1280 104 jeremybenn
        /* Remainder with zeros (more are needed) */
1281
        LOAD_CONST (r5,FP_S_P_ZERO)
1282
        LOAD_CONST (r6,FP_S_TWO)
1283
        lf.rem.s  r4,r5,r6
1284
        CHECK_RES ("+0.0 %  2.0 = +0.0: ", r4, FP_S_P_ZERO)
1285
 
1286
        LOAD_CONST (r5,FP_S_N_ZERO)
1287
        LOAD_CONST (r6,FP_S_TWO)
1288
        lf.rem.s  r4,r5,r6
1289
        CHECK_RES ("-0.0 %  2.0 = -0.0: ", r4, FP_S_N_ZERO)
1290
 
1291
        LOAD_CONST (r5,FP_S_TWO)
1292
        LOAD_CONST (r6,FP_S_P_ZERO)
1293
        lf.rem.s  r4,r5,r6
1294
        CHECK_RES (" 2.0 % +0.0 = -NaN: ", r4, FP_S_N_NAN)
1295
 
1296
        LOAD_CONST (r5,FP_S_N_TWO)
1297
        LOAD_CONST (r6,FP_S_P_ZERO)
1298
        lf.rem.s  r4,r5,r6
1299
        CHECK_RES ("-2.0 % +0.0 = -NaN: ", r4, FP_S_N_NAN)
1300
 
1301
        LOAD_CONST (r5,FP_S_TWO)
1302
        LOAD_CONST (r6,FP_S_N_ZERO)
1303
        lf.rem.s  r4,r5,r6
1304
        CHECK_RES (" 2.0 % -0.0 = -NaN: ", r4, FP_S_N_NAN)
1305
 
1306
        /* Remainder with infinities (more are needed) */
1307
        LOAD_CONST (r5,FP_S_TWO)
1308
        LOAD_CONST (r6,FP_S_P_INF)
1309
        lf.rem.s  r4,r5,r6
1310
        CHECK_RES (" 2.0 % +inf =  2.0: ", r4, FP_S_TWO)
1311
 
1312
        LOAD_CONST (r5,FP_S_P_INF)
1313
        LOAD_CONST (r6,FP_S_TWO)
1314
        lf.rem.s  r4,r5,r6
1315
        CHECK_RES ("+inf %  2.0 = -NaN: ", r4, FP_S_N_NAN)
1316
 
1317
        /* Remainder with NaNs (more are needed) */
1318
        LOAD_CONST (r5,FP_S_TWO)
1319
        LOAD_CONST (r6,FP_S_P_NAN)
1320
        lf.rem.s  r4,r5,r6
1321
        CHECK_RES (" 2.0 % +NaN = +NaN: ", r4, FP_S_P_NAN)
1322
 
1323
        LOAD_CONST (r5,FP_S_P_NAN)
1324
        LOAD_CONST (r6,FP_S_TWO)
1325
        lf.rem.s  r4,r5,r6
1326
        CHECK_RES ("+NaN %  2.0 = +NaN: ", r4, FP_S_P_NAN)
1327
 
1328
        /* Remainder with overflow of division (more are needed) */
1329
        LOAD_CONST (r5,FP_S_HUGE2)
1330
        LOAD_CONST (r6,FP_S_SMALL1)
1331
        lf.rem.s  r4,r5,r6
1332
        CHECK_RES (" 1.0 * 2^127  % 1.0 * 2^-129 = +0.0: ", r4, FP_S_P_ZERO)
1333
 
1334
        /* Remainder with underflow (more are needed) */
1335
        LOAD_CONST (r5,FP_S_SMALL1)
1336
        LOAD_CONST (r6,FP_S_HUGE2)
1337
        lf.rem.s  r4,r5,r6
1338
        CHECK_RES (" 1.0 * 2^-129 % 1.0 * 2^127  = +0.0: ", r4, FP_S_SMALL1)
1339
 
1340
        /* Remainder with denormalization (more are needed) */
1341
 
1342
/* ----------------------------------------------------------------------------
1343
 * Test of single precision set flag if equal: lf.sfeq.s
1344
 * ------------------------------------------------------------------------- */
1345
_sfeq_s:
1346
        LOAD_STR (r3, "lf.sfeq.s\n")
1347
        l.jal   _puts
1348
        l.nop
1349
 
1350
        /* Tests of integer equality */
1351
        LOAD_CONST (r4,FP_S_ONE)
1352
        LOAD_CONST (r5,FP_S_ONE)
1353
        lf.sfeq.s  r4,r5
1354
        CHECK_FLAG (" 1.0 ==  1.0: ", TRUE)
1355
 
1356
        LOAD_CONST (r4,FP_S_ONE)
1357
        LOAD_CONST (r5,FP_S_TWO)
1358
        lf.sfeq.s  r4,r5
1359
        CHECK_FLAG (" 1.0 ==  2.0: ", FALSE)
1360
 
1361
        /* Fractional equality */
1362
        LOAD_CONST (r4,FP_S_1_5)
1363
        LOAD_CONST (r5,FP_S_1_5)
1364
        lf.sfeq.s  r4,r5
1365
        CHECK_FLAG (" 1.5 ==  1.5: ", TRUE)
1366
 
1367
        LOAD_CONST (r4,FP_S_1_5)
1368
        LOAD_CONST (r5,FP_S_0_5)
1369
        lf.sfeq.s  r4,r5
1370
        CHECK_FLAG (" 1.5 ==  0.5: ", FALSE)
1371
 
1372
        /* Signed equality */
1373
        LOAD_CONST (r4,FP_S_N_1_5)
1374
        LOAD_CONST (r5,FP_S_N_1_5)
1375
        lf.sfeq.s  r4,r5
1376
        CHECK_FLAG ("-1.5 == -1.5: ", TRUE)
1377
 
1378
        LOAD_CONST (r4,FP_S_1_5)
1379
        LOAD_CONST (r5,FP_S_N_1_5)
1380
        lf.sfeq.s  r4,r5
1381
        CHECK_FLAG (" 1.5 == -1.5: ", FALSE)
1382
 
1383
        /* Equality of zeros */
1384
        LOAD_CONST (r4,FP_S_P_ZERO)
1385
        LOAD_CONST (r5,FP_S_P_ZERO)
1386
        lf.sfeq.s  r4,r5
1387
        CHECK_FLAG ("+0.0 == +0.0: ", TRUE)
1388
 
1389
        LOAD_CONST (r4,FP_S_N_ZERO)
1390
        LOAD_CONST (r5,FP_S_N_ZERO)
1391
        lf.sfeq.s  r4,r5
1392
        CHECK_FLAG ("-0.0 == -0.0: ", TRUE)
1393
 
1394
        LOAD_CONST (r4,FP_S_P_ZERO)
1395
        LOAD_CONST (r5,FP_S_N_ZERO)
1396
        lf.sfeq.s  r4,r5
1397
        CHECK_FLAG ("+0.0 == -0.0: ", TRUE)
1398
 
1399
        /* Equality with infinities (more needed) */
1400
        LOAD_CONST (r4,FP_S_ONE)
1401
        LOAD_CONST (r5,FP_S_P_INF)
1402
        lf.sfeq.s  r4,r5
1403
        CHECK_FLAG (" 1.0 == +inf: ", FALSE)
1404
 
1405
        LOAD_CONST (r4,FP_S_P_INF)
1406
        LOAD_CONST (r5,FP_S_P_INF)
1407
        lf.sfeq.s  r4,r5
1408
        CHECK_FLAG ("+inf == +inf: ", TRUE)
1409
 
1410
        LOAD_CONST (r4,FP_S_N_INF)
1411
        LOAD_CONST (r5,FP_S_N_INF)
1412
        lf.sfeq.s  r4,r5
1413
        CHECK_FLAG ("-inf == -inf: ", TRUE)
1414
 
1415
        LOAD_CONST (r4,FP_S_P_INF)
1416
        LOAD_CONST (r5,FP_S_N_INF)
1417
        lf.sfeq.s  r4,r5
1418
        CHECK_FLAG ("+inf == -inf: ", FALSE)
1419
 
1420
        /* Equality with NaNs (more needed) */
1421
        LOAD_CONST (r4,FP_S_ONE)
1422
        LOAD_CONST (r5,FP_S_P_NAN)
1423
        lf.sfeq.s  r4,r5
1424
        CHECK_FLAG (" 1.0 == +NaN: ", FALSE)
1425
 
1426
        LOAD_CONST (r4,FP_S_P_NAN)
1427
        LOAD_CONST (r5,FP_S_P_NAN)
1428
        lf.sfeq.s  r4,r5
1429
        CHECK_FLAG ("+NaN == +NaN: ", FALSE)
1430
 
1431
        LOAD_CONST (r4,FP_S_N_NAN)
1432
        LOAD_CONST (r5,FP_S_N_NAN)
1433
        lf.sfeq.s  r4,r5
1434
        CHECK_FLAG ("-NaN == -NaN: ", FALSE)
1435
 
1436
        LOAD_CONST (r4,FP_S_P_NAN)
1437
        LOAD_CONST (r5,FP_S_N_NAN)
1438
        lf.sfeq.s  r4,r5
1439
        CHECK_FLAG ("+NaN == -NaN: ", FALSE)
1440
 
1441
        /* Equality with denormalized numbers (more needed) */
1442
        LOAD_CONST (r4,FP_S_SMALL1)
1443
        LOAD_CONST (r5,FP_S_SMALL1)
1444
        lf.sfeq.s  r4,r5
1445
        CHECK_FLAG (" 1.0 * 2^-129 == 1.0 * 2^-129: ", TRUE)
1446
 
1447
        LOAD_CONST (r4,FP_S_SMALL1)
1448
        LOAD_CONST (r5,FP_S_SMALL2)
1449
        lf.sfeq.s  r4,r5
1450
        CHECK_FLAG (" 1.0 * 2^-129 == 1.0 * 2^-128: ", FALSE)
1451
 
1452
        LOAD_CONST (r4,FP_S_HUGE1)
1453
        LOAD_CONST (r5,FP_S_SMALL2)
1454
        lf.sfeq.s  r4,r5
1455
        CHECK_FLAG (" 1.0 * 2^126  == 1.0 * 2^-128: ", FALSE)
1456
 
1457
 
1458
/* ----------------------------------------------------------------------------
1459
 * Test of single precision set flag if greater than or equal: lf.sfge.s
1460
 * ------------------------------------------------------------------------- */
1461
_sfge_s:
1462
        LOAD_STR (r3, "lf.sfge.s\n")
1463
        l.jal   _puts
1464
        l.nop
1465
 
1466
        /* Tests of integer greater than or equality */
1467
        LOAD_CONST (r4,FP_S_ONE)
1468
        LOAD_CONST (r5,FP_S_ONE)
1469
        lf.sfge.s  r4,r5
1470
        CHECK_FLAG (" 1.0 >=  1.0: ", TRUE)
1471
 
1472
        LOAD_CONST (r4,FP_S_TWO)
1473
        LOAD_CONST (r5,FP_S_ONE)
1474
        lf.sfge.s  r4,r5
1475
        CHECK_FLAG (" 2.0 >=  1.0: ", TRUE)
1476
 
1477
        LOAD_CONST (r4,FP_S_ONE)
1478
        LOAD_CONST (r5,FP_S_TWO)
1479
        lf.sfge.s  r4,r5
1480
        CHECK_FLAG (" 1.0 >=  2.0: ", FALSE)
1481
 
1482
        /* Fractional greater than or equality */
1483
        LOAD_CONST (r4,FP_S_1_5)
1484
        LOAD_CONST (r5,FP_S_1_5)
1485
        lf.sfge.s  r4,r5
1486
        CHECK_FLAG (" 1.5 >=  1.5: ", TRUE)
1487
 
1488
        LOAD_CONST (r4,FP_S_1_5)
1489
        LOAD_CONST (r5,FP_S_0_5)
1490
        lf.sfge.s  r4,r5
1491
        CHECK_FLAG (" 1.5 >=  0.5: ", TRUE)
1492
 
1493
        LOAD_CONST (r4,FP_S_0_5)
1494
        LOAD_CONST (r5,FP_S_1_5)
1495
        lf.sfge.s  r4,r5
1496
        CHECK_FLAG (" 0.5 >=  1.5: ", FALSE)
1497
 
1498
        /* Signed greater than or equality */
1499
        LOAD_CONST (r4,FP_S_N_1_5)
1500
        LOAD_CONST (r5,FP_S_N_1_5)
1501
        lf.sfge.s  r4,r5
1502
        CHECK_FLAG ("-1.5 >= -1.5: ", TRUE)
1503
 
1504
        LOAD_CONST (r4,FP_S_N_1_5)
1505
        LOAD_CONST (r5,FP_S_N_0_5)
1506
        lf.sfge.s  r4,r5
1507
        CHECK_FLAG ("-1.5 >= -0.5: ", FALSE)
1508
 
1509
        LOAD_CONST (r4,FP_S_N_0_5)
1510
        LOAD_CONST (r5,FP_S_N_1_5)
1511
        lf.sfge.s  r4,r5
1512
        CHECK_FLAG ("-0.5 >= -1.5: ", TRUE)
1513
 
1514
        LOAD_CONST (r4,FP_S_1_5)
1515
        LOAD_CONST (r5,FP_S_N_1_5)
1516
        lf.sfge.s  r4,r5
1517
        CHECK_FLAG (" 1.5 >= -1.5: ", TRUE)
1518
 
1519
        LOAD_CONST (r4,FP_S_N_1_5)
1520
        LOAD_CONST (r5,FP_S_1_5)
1521
        lf.sfge.s  r4,r5
1522
        CHECK_FLAG ("-1.5 >=  1.5: ", FALSE)
1523
 
1524
        /* Greater than or equality of zeros */
1525
        LOAD_CONST (r4,FP_S_P_ZERO)
1526
        LOAD_CONST (r5,FP_S_P_ZERO)
1527
        lf.sfge.s  r4,r5
1528
        CHECK_FLAG ("+0.0 >= +0.0: ", TRUE)
1529
 
1530
        LOAD_CONST (r4,FP_S_N_ZERO)
1531
        LOAD_CONST (r5,FP_S_N_ZERO)
1532
        lf.sfge.s  r4,r5
1533
        CHECK_FLAG ("-0.0 >= -0.0: ", TRUE)
1534
 
1535
        LOAD_CONST (r4,FP_S_P_ZERO)
1536
        LOAD_CONST (r5,FP_S_N_ZERO)
1537
        lf.sfge.s  r4,r5
1538
        CHECK_FLAG ("+0.0 >= -0.0: ", TRUE)
1539
 
1540
        LOAD_CONST (r4,FP_S_N_ZERO)
1541
        LOAD_CONST (r5,FP_S_P_ZERO)
1542
        lf.sfge.s  r4,r5
1543
        CHECK_FLAG ("-0.0 >= +0.0: ", TRUE)
1544
 
1545
        /* Greater than or equality with infinities (more needed) */
1546
        LOAD_CONST (r4,FP_S_ONE)
1547
        LOAD_CONST (r5,FP_S_P_INF)
1548
        lf.sfge.s  r4,r5
1549
        CHECK_FLAG (" 1.0 >= +inf: ", FALSE)
1550
 
1551
        LOAD_CONST (r4,FP_S_P_INF)
1552
        LOAD_CONST (r5,FP_S_ONE)
1553
        lf.sfge.s  r4,r5
1554
        CHECK_FLAG ("+inf >=  1.0: ", TRUE)
1555
 
1556
        LOAD_CONST (r4,FP_S_ONE)
1557
        LOAD_CONST (r5,FP_S_N_INF)
1558
        lf.sfge.s  r4,r5
1559
        CHECK_FLAG (" 1.0 >= -inf: ", TRUE)
1560
 
1561
        LOAD_CONST (r4,FP_S_N_INF)
1562
        LOAD_CONST (r5,FP_S_ONE)
1563
        lf.sfge.s  r4,r5
1564
        CHECK_FLAG ("-inf >=  1.0: ", FALSE)
1565
 
1566
        LOAD_CONST (r4,FP_S_P_INF)
1567
        LOAD_CONST (r5,FP_S_P_INF)
1568
        lf.sfge.s  r4,r5
1569
        CHECK_FLAG ("+inf >= +inf: ", TRUE)
1570
 
1571
        LOAD_CONST (r4,FP_S_N_INF)
1572
        LOAD_CONST (r5,FP_S_N_INF)
1573
        lf.sfge.s  r4,r5
1574
        CHECK_FLAG ("-inf >= -inf: ", TRUE)
1575
 
1576
        LOAD_CONST (r4,FP_S_P_INF)
1577
        LOAD_CONST (r5,FP_S_N_INF)
1578
        lf.sfge.s  r4,r5
1579
        CHECK_FLAG ("+inf >= -inf: ", TRUE)
1580
 
1581
        LOAD_CONST (r4,FP_S_N_INF)
1582
        LOAD_CONST (r5,FP_S_P_INF)
1583
        lf.sfge.s  r4,r5
1584
        CHECK_FLAG ("-inf >= +inf: ", FALSE)
1585
 
1586
        /* Greater than or equality with NaNs (more needed) */
1587
        LOAD_CONST (r4,FP_S_ONE)
1588
        LOAD_CONST (r5,FP_S_P_NAN)
1589
        lf.sfge.s  r4,r5
1590
        CHECK_FLAG (" 1.0 >= +NaN: ", FALSE)
1591
 
1592
        LOAD_CONST (r4,FP_S_P_NAN)
1593
        LOAD_CONST (r5,FP_S_P_NAN)
1594
        lf.sfge.s  r4,r5
1595
        CHECK_FLAG ("+NaN >= +NaN: ", FALSE)
1596
 
1597
        LOAD_CONST (r4,FP_S_N_NAN)
1598
        LOAD_CONST (r5,FP_S_N_NAN)
1599
        lf.sfge.s  r4,r5
1600
        CHECK_FLAG ("-NaN >= -NaN: ", FALSE)
1601
 
1602
        LOAD_CONST (r4,FP_S_P_NAN)
1603
        LOAD_CONST (r5,FP_S_N_NAN)
1604
        lf.sfge.s  r4,r5
1605
        CHECK_FLAG ("+NaN >= -NaN: ", FALSE)
1606
 
1607
        LOAD_CONST (r4,FP_S_N_NAN)
1608
        LOAD_CONST (r5,FP_S_P_NAN)
1609
        lf.sfge.s  r4,r5
1610
        CHECK_FLAG ("-NaN >= +NaN: ", FALSE)
1611
 
1612
        /* Greater than or equality with denormalized numbers (more needed) */
1613
        LOAD_CONST (r4,FP_S_SMALL1)
1614
        LOAD_CONST (r5,FP_S_SMALL1)
1615
        lf.sfge.s  r4,r5
1616
        CHECK_FLAG (" 1.0 * 2^-129 >= 1.0 * 2^-129: ", TRUE)
1617
 
1618
        LOAD_CONST (r4,FP_S_SMALL1)
1619
        LOAD_CONST (r5,FP_S_SMALL2)
1620
        lf.sfge.s  r4,r5
1621
        CHECK_FLAG (" 1.0 * 2^-129 >= 1.0 * 2^-128: ", FALSE)
1622
 
1623
        LOAD_CONST (r4,FP_S_SMALL2)
1624
        LOAD_CONST (r5,FP_S_SMALL1)
1625
        lf.sfge.s  r4,r5
1626
        CHECK_FLAG (" 1.0 * 2^-128 >= 1.0 * 2^-129: ", TRUE)
1627
 
1628
        LOAD_CONST (r4,FP_S_HUGE1)
1629
        LOAD_CONST (r5,FP_S_SMALL2)
1630
        lf.sfge.s  r4,r5
1631
        CHECK_FLAG (" 1.0 * 2^126  >= 1.0 * 2^-128: ", TRUE)
1632
 
1633
        LOAD_CONST (r4,FP_S_SMALL2)
1634
        LOAD_CONST (r5,FP_S_HUGE1)
1635
        lf.sfge.s  r4,r5
1636
        CHECK_FLAG (" 1.0 * 2^-128 >= 1.0 * 2^126:  ", FALSE)
1637
 
1638
 
1639
/* ----------------------------------------------------------------------------
1640
 * Test of single precision set flag if greater than: lf.sfgt.s
1641
 * ------------------------------------------------------------------------- */
1642
_sfgt_s:
1643
        LOAD_STR (r3, "lf.sfgt.s\n")
1644
        l.jal   _puts
1645
        l.nop
1646
 
1647
        /* Tests of integer greater than */
1648
        LOAD_CONST (r4,FP_S_ONE)
1649
        LOAD_CONST (r5,FP_S_ONE)
1650
        lf.sfgt.s  r4,r5
1651
        CHECK_FLAG (" 1.0 >  1.0: ", FALSE)
1652
 
1653
        LOAD_CONST (r4,FP_S_TWO)
1654
        LOAD_CONST (r5,FP_S_ONE)
1655
        lf.sfgt.s  r4,r5
1656
        CHECK_FLAG (" 2.0 >  1.0: ", TRUE)
1657
 
1658
        LOAD_CONST (r4,FP_S_ONE)
1659
        LOAD_CONST (r5,FP_S_TWO)
1660
        lf.sfgt.s  r4,r5
1661
        CHECK_FLAG (" 1.0 >  2.0: ", FALSE)
1662
 
1663
        /* Fractional greater than */
1664
        LOAD_CONST (r4,FP_S_1_5)
1665
        LOAD_CONST (r5,FP_S_1_5)
1666
        lf.sfgt.s  r4,r5
1667
        CHECK_FLAG (" 1.5 >  1.5: ", FALSE)
1668
 
1669
        LOAD_CONST (r4,FP_S_1_5)
1670
        LOAD_CONST (r5,FP_S_0_5)
1671
        lf.sfgt.s  r4,r5
1672
        CHECK_FLAG (" 1.5 >  0.5: ", TRUE)
1673
 
1674
        LOAD_CONST (r4,FP_S_0_5)
1675
        LOAD_CONST (r5,FP_S_1_5)
1676
        lf.sfgt.s  r4,r5
1677
        CHECK_FLAG (" 0.5 >  1.5: ", FALSE)
1678
 
1679
        /* Signed greater than */
1680
        LOAD_CONST (r4,FP_S_N_1_5)
1681
        LOAD_CONST (r5,FP_S_N_1_5)
1682
        lf.sfgt.s  r4,r5
1683
        CHECK_FLAG ("-1.5 > -1.5: ", FALSE)
1684
 
1685
        LOAD_CONST (r4,FP_S_N_1_5)
1686
        LOAD_CONST (r5,FP_S_N_0_5)
1687
        lf.sfgt.s  r4,r5
1688
        CHECK_FLAG ("-1.5 > -0.5: ", FALSE)
1689
 
1690
        LOAD_CONST (r4,FP_S_N_0_5)
1691
        LOAD_CONST (r5,FP_S_N_1_5)
1692
        lf.sfgt.s  r4,r5
1693
        CHECK_FLAG ("-0.5 > -1.5: ", TRUE)
1694
 
1695
        LOAD_CONST (r4,FP_S_1_5)
1696
        LOAD_CONST (r5,FP_S_N_1_5)
1697
        lf.sfgt.s  r4,r5
1698
        CHECK_FLAG (" 1.5 > -1.5: ", TRUE)
1699
 
1700
        LOAD_CONST (r4,FP_S_N_1_5)
1701
        LOAD_CONST (r5,FP_S_1_5)
1702
        lf.sfgt.s  r4,r5
1703
        CHECK_FLAG ("-1.5 >  1.5: ", FALSE)
1704
 
1705
        /* Greater than of zeros */
1706
        LOAD_CONST (r4,FP_S_P_ZERO)
1707
        LOAD_CONST (r5,FP_S_P_ZERO)
1708
        lf.sfgt.s  r4,r5
1709
        CHECK_FLAG ("+0.0 > +0.0: ", FALSE)
1710
 
1711
        LOAD_CONST (r4,FP_S_N_ZERO)
1712
        LOAD_CONST (r5,FP_S_N_ZERO)
1713
        lf.sfgt.s  r4,r5
1714
        CHECK_FLAG ("-0.0 > -0.0: ", FALSE)
1715
 
1716
        LOAD_CONST (r4,FP_S_P_ZERO)
1717
        LOAD_CONST (r5,FP_S_N_ZERO)
1718
        lf.sfgt.s  r4,r5
1719
        CHECK_FLAG ("+0.0 > -0.0: ", FALSE)
1720
 
1721
        LOAD_CONST (r4,FP_S_N_ZERO)
1722
        LOAD_CONST (r5,FP_S_P_ZERO)
1723
        lf.sfgt.s  r4,r5
1724
        CHECK_FLAG ("-0.0 > +0.0: ", FALSE)
1725
 
1726
        /* Greater than with infinities (more needed) */
1727
        LOAD_CONST (r4,FP_S_ONE)
1728
        LOAD_CONST (r5,FP_S_P_INF)
1729
        lf.sfgt.s  r4,r5
1730
        CHECK_FLAG (" 1.0 > +inf: ", FALSE)
1731
 
1732
        LOAD_CONST (r4,FP_S_P_INF)
1733
        LOAD_CONST (r5,FP_S_ONE)
1734
        lf.sfgt.s  r4,r5
1735
        CHECK_FLAG ("+inf >  1.0: ", TRUE)
1736
 
1737
        LOAD_CONST (r4,FP_S_ONE)
1738
        LOAD_CONST (r5,FP_S_N_INF)
1739
        lf.sfgt.s  r4,r5
1740
        CHECK_FLAG (" 1.0 > -inf: ", TRUE)
1741
 
1742
        LOAD_CONST (r4,FP_S_N_INF)
1743
        LOAD_CONST (r5,FP_S_ONE)
1744
        lf.sfgt.s  r4,r5
1745
        CHECK_FLAG ("-inf >  1.0: ", FALSE)
1746
 
1747
        LOAD_CONST (r4,FP_S_P_INF)
1748
        LOAD_CONST (r5,FP_S_P_INF)
1749
        lf.sfgt.s  r4,r5
1750
        CHECK_FLAG ("+inf > +inf: ", FALSE)
1751
 
1752
        LOAD_CONST (r4,FP_S_N_INF)
1753
        LOAD_CONST (r5,FP_S_N_INF)
1754
        lf.sfgt.s  r4,r5
1755
        CHECK_FLAG ("-inf > -inf: ", FALSE)
1756
 
1757
        LOAD_CONST (r4,FP_S_P_INF)
1758
        LOAD_CONST (r5,FP_S_N_INF)
1759
        lf.sfgt.s  r4,r5
1760
        CHECK_FLAG ("+inf > -inf: ", TRUE)
1761
 
1762
        LOAD_CONST (r4,FP_S_N_INF)
1763
        LOAD_CONST (r5,FP_S_P_INF)
1764
        lf.sfgt.s  r4,r5
1765
        CHECK_FLAG ("-inf > +inf: ", FALSE)
1766
 
1767
        /* Greater than with NaNs (more needed) */
1768
        LOAD_CONST (r4,FP_S_ONE)
1769
        LOAD_CONST (r5,FP_S_P_NAN)
1770
        lf.sfgt.s  r4,r5
1771
        CHECK_FLAG (" 1.0 > +NaN: ", FALSE)
1772
 
1773
        LOAD_CONST (r4,FP_S_P_NAN)
1774
        LOAD_CONST (r5,FP_S_P_NAN)
1775
        lf.sfgt.s  r4,r5
1776
        CHECK_FLAG ("+NaN > +NaN: ", FALSE)
1777
 
1778
        LOAD_CONST (r4,FP_S_N_NAN)
1779
        LOAD_CONST (r5,FP_S_N_NAN)
1780
        lf.sfgt.s  r4,r5
1781
        CHECK_FLAG ("-NaN > -NaN: ", FALSE)
1782
 
1783
        LOAD_CONST (r4,FP_S_P_NAN)
1784
        LOAD_CONST (r5,FP_S_N_NAN)
1785
        lf.sfgt.s  r4,r5
1786
        CHECK_FLAG ("+NaN > -NaN: ", FALSE)
1787
 
1788
        LOAD_CONST (r4,FP_S_N_NAN)
1789
        LOAD_CONST (r5,FP_S_P_NAN)
1790
        lf.sfgt.s  r4,r5
1791
        CHECK_FLAG ("-NaN > +NaN: ", FALSE)
1792
 
1793
        /* Greater than with denormalized numbers (more needed) */
1794
        LOAD_CONST (r4,FP_S_SMALL1)
1795
        LOAD_CONST (r5,FP_S_SMALL1)
1796
        lf.sfgt.s  r4,r5
1797
        CHECK_FLAG (" 1.0 * 2^-129 > 1.0 * 2^-129: ", FALSE)
1798
 
1799
        LOAD_CONST (r4,FP_S_SMALL1)
1800
        LOAD_CONST (r5,FP_S_SMALL2)
1801
        lf.sfgt.s  r4,r5
1802
        CHECK_FLAG (" 1.0 * 2^-129 > 1.0 * 2^-128: ", FALSE)
1803
 
1804
        LOAD_CONST (r4,FP_S_SMALL2)
1805
        LOAD_CONST (r5,FP_S_SMALL1)
1806
        lf.sfgt.s  r4,r5
1807
        CHECK_FLAG (" 1.0 * 2^-128 > 1.0 * 2^-129: ", TRUE)
1808
 
1809
        LOAD_CONST (r4,FP_S_HUGE1)
1810
        LOAD_CONST (r5,FP_S_SMALL2)
1811
        lf.sfgt.s  r4,r5
1812
        CHECK_FLAG (" 1.0 * 2^126  > 1.0 * 2^-128: ", TRUE)
1813
 
1814
        LOAD_CONST (r4,FP_S_SMALL2)
1815
        LOAD_CONST (r5,FP_S_HUGE1)
1816
        lf.sfgt.s  r4,r5
1817
        CHECK_FLAG (" 1.0 * 2^-128 > 1.0 * 2^126:  ", FALSE)
1818
 
1819
/* ----------------------------------------------------------------------------
1820
 * Test of single precision set flag if less than or equal: lf.sfle.s
1821
 * ------------------------------------------------------------------------- */
1822
_sfle_s:
1823
        LOAD_STR (r3, "lf.sfle.s\n")
1824
        l.jal   _puts
1825
        l.nop
1826
 
1827
        /* Tests of integer less than or equality */
1828
        LOAD_CONST (r4,FP_S_ONE)
1829
        LOAD_CONST (r5,FP_S_ONE)
1830
        lf.sfle.s  r4,r5
1831
        CHECK_FLAG (" 1.0 <=  1.0: ", TRUE)
1832
 
1833
        LOAD_CONST (r4,FP_S_TWO)
1834
        LOAD_CONST (r5,FP_S_ONE)
1835
        lf.sfle.s  r4,r5
1836
        CHECK_FLAG (" 2.0 <=  1.0: ", FALSE)
1837
 
1838
        LOAD_CONST (r4,FP_S_ONE)
1839
        LOAD_CONST (r5,FP_S_TWO)
1840
        lf.sfle.s  r4,r5
1841
        CHECK_FLAG (" 1.0 <=  2.0: ", TRUE)
1842
 
1843
        /* Fractional less than or equality */
1844
        LOAD_CONST (r4,FP_S_1_5)
1845
        LOAD_CONST (r5,FP_S_1_5)
1846
        lf.sfle.s  r4,r5
1847
        CHECK_FLAG (" 1.5 <=  1.5: ", TRUE)
1848
 
1849
        LOAD_CONST (r4,FP_S_1_5)
1850
        LOAD_CONST (r5,FP_S_0_5)
1851
        lf.sfle.s  r4,r5
1852
        CHECK_FLAG (" 1.5 <=  0.5: ", FALSE)
1853
 
1854
        LOAD_CONST (r4,FP_S_0_5)
1855
        LOAD_CONST (r5,FP_S_1_5)
1856
        lf.sfle.s  r4,r5
1857
        CHECK_FLAG (" 0.5 <=  1.5: ", TRUE)
1858
 
1859
        /* Signed less than or equality */
1860
        LOAD_CONST (r4,FP_S_N_1_5)
1861
        LOAD_CONST (r5,FP_S_N_1_5)
1862
        lf.sfle.s  r4,r5
1863
        CHECK_FLAG ("-1.5 <= -1.5: ", TRUE)
1864
 
1865
        LOAD_CONST (r4,FP_S_N_1_5)
1866
        LOAD_CONST (r5,FP_S_N_0_5)
1867
        lf.sfle.s  r4,r5
1868
        CHECK_FLAG ("-1.5 <= -0.5: ", TRUE)
1869
 
1870
        LOAD_CONST (r4,FP_S_N_0_5)
1871
        LOAD_CONST (r5,FP_S_N_1_5)
1872
        lf.sfle.s  r4,r5
1873
        CHECK_FLAG ("-0.5 <= -1.5: ", FALSE)
1874
 
1875
        LOAD_CONST (r4,FP_S_1_5)
1876
        LOAD_CONST (r5,FP_S_N_1_5)
1877
        lf.sfle.s  r4,r5
1878
        CHECK_FLAG (" 1.5 <= -1.5: ", FALSE)
1879
 
1880
        LOAD_CONST (r4,FP_S_N_1_5)
1881
        LOAD_CONST (r5,FP_S_1_5)
1882
        lf.sfle.s  r4,r5
1883
        CHECK_FLAG ("-1.5 <=  1.5: ", TRUE)
1884
 
1885
        /* Less than or equality of zeros */
1886
        LOAD_CONST (r4,FP_S_P_ZERO)
1887
        LOAD_CONST (r5,FP_S_P_ZERO)
1888
        lf.sfle.s  r4,r5
1889
        CHECK_FLAG ("+0.0 <= +0.0: ", TRUE)
1890
 
1891
        LOAD_CONST (r4,FP_S_N_ZERO)
1892
        LOAD_CONST (r5,FP_S_N_ZERO)
1893
        lf.sfle.s  r4,r5
1894
        CHECK_FLAG ("-0.0 <= -0.0: ", TRUE)
1895
 
1896
        LOAD_CONST (r4,FP_S_P_ZERO)
1897
        LOAD_CONST (r5,FP_S_N_ZERO)
1898
        lf.sfle.s  r4,r5
1899
        CHECK_FLAG ("+0.0 <= -0.0: ", TRUE)
1900
 
1901
        LOAD_CONST (r4,FP_S_N_ZERO)
1902
        LOAD_CONST (r5,FP_S_P_ZERO)
1903
        lf.sfle.s  r4,r5
1904
        CHECK_FLAG ("-0.0 <= +0.0: ", TRUE)
1905
 
1906
        /* Less than or equality with infinities (more needed) */
1907
        LOAD_CONST (r4,FP_S_ONE)
1908
        LOAD_CONST (r5,FP_S_P_INF)
1909
        lf.sfle.s  r4,r5
1910
        CHECK_FLAG (" 1.0 <= +inf: ", TRUE)
1911
 
1912
        LOAD_CONST (r4,FP_S_P_INF)
1913
        LOAD_CONST (r5,FP_S_ONE)
1914
        lf.sfle.s  r4,r5
1915
        CHECK_FLAG ("+inf <=  1.0: ", FALSE)
1916
 
1917
        LOAD_CONST (r4,FP_S_ONE)
1918
        LOAD_CONST (r5,FP_S_N_INF)
1919
        lf.sfle.s  r4,r5
1920
        CHECK_FLAG (" 1.0 <= -inf: ", FALSE)
1921
 
1922
        LOAD_CONST (r4,FP_S_N_INF)
1923
        LOAD_CONST (r5,FP_S_ONE)
1924
        lf.sfle.s  r4,r5
1925
        CHECK_FLAG ("-inf <=  1.0: ", TRUE)
1926
 
1927
        LOAD_CONST (r4,FP_S_P_INF)
1928
        LOAD_CONST (r5,FP_S_P_INF)
1929
        lf.sfle.s  r4,r5
1930
        CHECK_FLAG ("+inf <= +inf: ", TRUE)
1931
 
1932
        LOAD_CONST (r4,FP_S_N_INF)
1933
        LOAD_CONST (r5,FP_S_N_INF)
1934
        lf.sfle.s  r4,r5
1935
        CHECK_FLAG ("-inf <= -inf: ", TRUE)
1936
 
1937
        LOAD_CONST (r4,FP_S_P_INF)
1938
        LOAD_CONST (r5,FP_S_N_INF)
1939
        lf.sfle.s  r4,r5
1940
        CHECK_FLAG ("+inf <= -inf: ", FALSE)
1941
 
1942
        LOAD_CONST (r4,FP_S_N_INF)
1943
        LOAD_CONST (r5,FP_S_P_INF)
1944
        lf.sfle.s  r4,r5
1945
        CHECK_FLAG ("-inf <= +inf: ", TRUE)
1946
 
1947
        /* Less than or equality with NaNs (more needed) */
1948
        LOAD_CONST (r4,FP_S_ONE)
1949
        LOAD_CONST (r5,FP_S_P_NAN)
1950
        lf.sfle.s  r4,r5
1951
        CHECK_FLAG (" 1.0 <= +NaN: ", FALSE)
1952
 
1953
        LOAD_CONST (r4,FP_S_P_NAN)
1954
        LOAD_CONST (r5,FP_S_P_NAN)
1955
        lf.sfle.s  r4,r5
1956
        CHECK_FLAG ("+NaN <= +NaN: ", FALSE)
1957
 
1958
        LOAD_CONST (r4,FP_S_N_NAN)
1959
        LOAD_CONST (r5,FP_S_N_NAN)
1960
        lf.sfle.s  r4,r5
1961
        CHECK_FLAG ("-NaN <= -NaN: ", FALSE)
1962
 
1963
        LOAD_CONST (r4,FP_S_P_NAN)
1964
        LOAD_CONST (r5,FP_S_N_NAN)
1965
        lf.sfle.s  r4,r5
1966
        CHECK_FLAG ("+NaN <= -NaN: ", FALSE)
1967
 
1968
        LOAD_CONST (r4,FP_S_N_NAN)
1969
        LOAD_CONST (r5,FP_S_P_NAN)
1970
        lf.sfle.s  r4,r5
1971
        CHECK_FLAG ("-NaN <= +NaN: ", FALSE)
1972
 
1973
        /* Less than or equality with denormalized numbers (more needed) */
1974
        LOAD_CONST (r4,FP_S_SMALL1)
1975
        LOAD_CONST (r5,FP_S_SMALL1)
1976
        lf.sfle.s  r4,r5
1977
        CHECK_FLAG (" 1.0 * 2^-129 <= 1.0 * 2^-129: ", TRUE)
1978
 
1979
        LOAD_CONST (r4,FP_S_SMALL1)
1980
        LOAD_CONST (r5,FP_S_SMALL2)
1981
        lf.sfle.s  r4,r5
1982
        CHECK_FLAG (" 1.0 * 2^-129 <= 1.0 * 2^-128: ", TRUE)
1983
 
1984
        LOAD_CONST (r4,FP_S_SMALL2)
1985
        LOAD_CONST (r5,FP_S_SMALL1)
1986
        lf.sfle.s  r4,r5
1987
        CHECK_FLAG (" 1.0 * 2^-128 <= 1.0 * 2^-129: ", FALSE)
1988
 
1989
        LOAD_CONST (r4,FP_S_HUGE1)
1990
        LOAD_CONST (r5,FP_S_SMALL2)
1991
        lf.sfle.s  r4,r5
1992
        CHECK_FLAG (" 1.0 * 2^126  <= 1.0 * 2^-128: ", FALSE)
1993
 
1994
        LOAD_CONST (r4,FP_S_SMALL2)
1995
        LOAD_CONST (r5,FP_S_HUGE1)
1996
        lf.sfle.s  r4,r5
1997
        CHECK_FLAG (" 1.0 * 2^-128 <= 1.0 * 2^126:  ", TRUE)
1998
 
1999
 
2000
/* ----------------------------------------------------------------------------
2001
 * Test of single precision set flag if less than: lf.sflt.s
2002
 * ------------------------------------------------------------------------- */
2003
_sflt_s:
2004
        LOAD_STR (r3, "lf.sflt.s\n")
2005
        l.jal   _puts
2006
        l.nop
2007
 
2008
        /* Tests of integer less than */
2009
        LOAD_CONST (r4,FP_S_ONE)
2010
        LOAD_CONST (r5,FP_S_ONE)
2011
        lf.sflt.s  r4,r5
2012
        CHECK_FLAG (" 1.0 <  1.0: ", FALSE)
2013
 
2014
        LOAD_CONST (r4,FP_S_TWO)
2015
        LOAD_CONST (r5,FP_S_ONE)
2016
        lf.sflt.s  r4,r5
2017
        CHECK_FLAG (" 2.0 <  1.0: ", FALSE)
2018
 
2019
        LOAD_CONST (r4,FP_S_ONE)
2020
        LOAD_CONST (r5,FP_S_TWO)
2021
        lf.sflt.s  r4,r5
2022
        CHECK_FLAG (" 1.0 <  2.0: ", TRUE)
2023
 
2024
        /* Fractional less than */
2025
        LOAD_CONST (r4,FP_S_1_5)
2026
        LOAD_CONST (r5,FP_S_1_5)
2027
        lf.sflt.s  r4,r5
2028
        CHECK_FLAG (" 1.5 <  1.5: ", FALSE)
2029
 
2030
        LOAD_CONST (r4,FP_S_1_5)
2031
        LOAD_CONST (r5,FP_S_0_5)
2032
        lf.sflt.s  r4,r5
2033
        CHECK_FLAG (" 1.5 <  0.5: ", FALSE)
2034
 
2035
        LOAD_CONST (r4,FP_S_0_5)
2036
        LOAD_CONST (r5,FP_S_1_5)
2037
        lf.sflt.s  r4,r5
2038
        CHECK_FLAG (" 0.5 <  1.5: ", TRUE)
2039
 
2040
        /* Signed less than */
2041
        LOAD_CONST (r4,FP_S_N_1_5)
2042
        LOAD_CONST (r5,FP_S_N_1_5)
2043
        lf.sflt.s  r4,r5
2044
        CHECK_FLAG ("-1.5 < -1.5: ", FALSE)
2045
 
2046
        LOAD_CONST (r4,FP_S_N_1_5)
2047
        LOAD_CONST (r5,FP_S_N_0_5)
2048
        lf.sflt.s  r4,r5
2049
        CHECK_FLAG ("-1.5 < -0.5: ", TRUE)
2050
 
2051
        LOAD_CONST (r4,FP_S_N_0_5)
2052
        LOAD_CONST (r5,FP_S_N_1_5)
2053
        lf.sflt.s  r4,r5
2054
        CHECK_FLAG ("-0.5 < -1.5: ", FALSE)
2055
 
2056
        LOAD_CONST (r4,FP_S_1_5)
2057
        LOAD_CONST (r5,FP_S_N_1_5)
2058
        lf.sflt.s  r4,r5
2059
        CHECK_FLAG (" 1.5 < -1.5: ", FALSE)
2060
 
2061
        LOAD_CONST (r4,FP_S_N_1_5)
2062
        LOAD_CONST (r5,FP_S_1_5)
2063
        lf.sflt.s  r4,r5
2064
        CHECK_FLAG ("-1.5 <  1.5: ", TRUE)
2065
 
2066
        /* Less than of zeros */
2067
        LOAD_CONST (r4,FP_S_P_ZERO)
2068
        LOAD_CONST (r5,FP_S_P_ZERO)
2069
        lf.sflt.s  r4,r5
2070
        CHECK_FLAG ("+0.0 < +0.0: ", FALSE)
2071
 
2072
        LOAD_CONST (r4,FP_S_N_ZERO)
2073
        LOAD_CONST (r5,FP_S_N_ZERO)
2074
        lf.sflt.s  r4,r5
2075
        CHECK_FLAG ("-0.0 < -0.0: ", FALSE)
2076
 
2077
        LOAD_CONST (r4,FP_S_P_ZERO)
2078
        LOAD_CONST (r5,FP_S_N_ZERO)
2079
        lf.sflt.s  r4,r5
2080
        CHECK_FLAG ("+0.0 < -0.0: ", FALSE)
2081
 
2082
        LOAD_CONST (r4,FP_S_N_ZERO)
2083
        LOAD_CONST (r5,FP_S_P_ZERO)
2084
        lf.sflt.s  r4,r5
2085
        CHECK_FLAG ("-0.0 < +0.0: ", FALSE)
2086
 
2087
        /* Less than with infinities (more needed) */
2088
        LOAD_CONST (r4,FP_S_ONE)
2089
        LOAD_CONST (r5,FP_S_P_INF)
2090
        lf.sflt.s  r4,r5
2091
        CHECK_FLAG (" 1.0 < +inf: ", TRUE)
2092
 
2093
        LOAD_CONST (r4,FP_S_P_INF)
2094
        LOAD_CONST (r5,FP_S_ONE)
2095
        lf.sflt.s  r4,r5
2096
        CHECK_FLAG ("+inf <  1.0: ", FALSE)
2097
 
2098
        LOAD_CONST (r4,FP_S_ONE)
2099
        LOAD_CONST (r5,FP_S_N_INF)
2100
        lf.sflt.s  r4,r5
2101
        CHECK_FLAG (" 1.0 < -inf: ", FALSE)
2102
 
2103
        LOAD_CONST (r4,FP_S_N_INF)
2104
        LOAD_CONST (r5,FP_S_ONE)
2105
        lf.sflt.s  r4,r5
2106
        CHECK_FLAG ("-inf <  1.0: ", TRUE)
2107
 
2108
        LOAD_CONST (r4,FP_S_P_INF)
2109
        LOAD_CONST (r5,FP_S_P_INF)
2110
        lf.sflt.s  r4,r5
2111
        CHECK_FLAG ("+inf < +inf: ", FALSE)
2112
 
2113
        LOAD_CONST (r4,FP_S_N_INF)
2114
        LOAD_CONST (r5,FP_S_N_INF)
2115
        lf.sflt.s  r4,r5
2116
        CHECK_FLAG ("-inf < -inf: ", FALSE)
2117
 
2118
        LOAD_CONST (r4,FP_S_P_INF)
2119
        LOAD_CONST (r5,FP_S_N_INF)
2120
        lf.sflt.s  r4,r5
2121
        CHECK_FLAG ("+inf < -inf: ", FALSE)
2122
 
2123
        LOAD_CONST (r4,FP_S_N_INF)
2124
        LOAD_CONST (r5,FP_S_P_INF)
2125
        lf.sflt.s  r4,r5
2126
        CHECK_FLAG ("-inf < +inf: ", TRUE)
2127
 
2128
        /* Less than with NaNs (more needed) */
2129
        LOAD_CONST (r4,FP_S_ONE)
2130
        LOAD_CONST (r5,FP_S_P_NAN)
2131
        lf.sflt.s  r4,r5
2132
        CHECK_FLAG (" 1.0 < +NaN: ", FALSE)
2133
 
2134
        LOAD_CONST (r4,FP_S_P_NAN)
2135
        LOAD_CONST (r5,FP_S_P_NAN)
2136
        lf.sflt.s  r4,r5
2137
        CHECK_FLAG ("+NaN < +NaN: ", FALSE)
2138
 
2139
        LOAD_CONST (r4,FP_S_N_NAN)
2140
        LOAD_CONST (r5,FP_S_N_NAN)
2141
        lf.sflt.s  r4,r5
2142
        CHECK_FLAG ("-NaN < -NaN: ", FALSE)
2143
 
2144
        LOAD_CONST (r4,FP_S_P_NAN)
2145
        LOAD_CONST (r5,FP_S_N_NAN)
2146
        lf.sflt.s  r4,r5
2147
        CHECK_FLAG ("+NaN < -NaN: ", FALSE)
2148
 
2149
        LOAD_CONST (r4,FP_S_N_NAN)
2150
        LOAD_CONST (r5,FP_S_P_NAN)
2151
        lf.sflt.s  r4,r5
2152
        CHECK_FLAG ("-NaN < +NaN: ", FALSE)
2153
 
2154
        /* Less than with denormalized numbers (more needed) */
2155
        LOAD_CONST (r4,FP_S_SMALL1)
2156
        LOAD_CONST (r5,FP_S_SMALL1)
2157
        lf.sflt.s  r4,r5
2158
        CHECK_FLAG (" 1.0 * 2^-129 < 1.0 * 2^-129: ", FALSE)
2159
 
2160
        LOAD_CONST (r4,FP_S_SMALL1)
2161
        LOAD_CONST (r5,FP_S_SMALL2)
2162
        lf.sflt.s  r4,r5
2163
        CHECK_FLAG (" 1.0 * 2^-129 < 1.0 * 2^-128: ", TRUE)
2164
 
2165
        LOAD_CONST (r4,FP_S_SMALL2)
2166
        LOAD_CONST (r5,FP_S_SMALL1)
2167
        lf.sflt.s  r4,r5
2168
        CHECK_FLAG (" 1.0 * 2^-128 < 1.0 * 2^-129: ", FALSE)
2169
 
2170
        LOAD_CONST (r4,FP_S_HUGE1)
2171
        LOAD_CONST (r5,FP_S_SMALL2)
2172
        lf.sflt.s  r4,r5
2173
        CHECK_FLAG (" 1.0 * 2^126  < 1.0 * 2^-128: ", FALSE)
2174
 
2175
        LOAD_CONST (r4,FP_S_SMALL2)
2176
        LOAD_CONST (r5,FP_S_HUGE1)
2177
        lf.sflt.s  r4,r5
2178
        CHECK_FLAG (" 1.0 * 2^-128 < 1.0 * 2^126:  ", TRUE)
2179
 
2180
/* ----------------------------------------------------------------------------
2181
 * Test of single precision set flag if not equal: lf.sfne.s
2182
 * ------------------------------------------------------------------------- */
2183
_sfne_s:
2184
        LOAD_STR (r3, "lf.sfne.s\n")
2185
        l.jal   _puts
2186
        l.nop
2187
 
2188
        /* Tests of integer inequality */
2189
        LOAD_CONST (r4,FP_S_ONE)
2190
        LOAD_CONST (r5,FP_S_ONE)
2191
        lf.sfne.s  r4,r5
2192
        CHECK_FLAG (" 1.0 !=  1.0: ", FALSE)
2193
 
2194
        LOAD_CONST (r4,FP_S_ONE)
2195
        LOAD_CONST (r5,FP_S_TWO)
2196
        lf.sfne.s  r4,r5
2197
        CHECK_FLAG (" 1.0 !=  2.0: ", TRUE)
2198
 
2199
        /* Fractional inequality */
2200
        LOAD_CONST (r4,FP_S_1_5)
2201
        LOAD_CONST (r5,FP_S_1_5)
2202
        lf.sfne.s  r4,r5
2203
        CHECK_FLAG (" 1.5 !=  1.5: ", FALSE)
2204
 
2205
        LOAD_CONST (r4,FP_S_1_5)
2206
        LOAD_CONST (r5,FP_S_0_5)
2207
        lf.sfne.s  r4,r5
2208
        CHECK_FLAG (" 1.5 !=  0.5: ", TRUE)
2209
 
2210
        /* Signed inequality */
2211
        LOAD_CONST (r4,FP_S_N_1_5)
2212
        LOAD_CONST (r5,FP_S_N_1_5)
2213
        lf.sfne.s  r4,r5
2214
        CHECK_FLAG ("-1.5 != -1.5: ", FALSE)
2215
 
2216
        LOAD_CONST (r4,FP_S_1_5)
2217
        LOAD_CONST (r5,FP_S_N_1_5)
2218
        lf.sfne.s  r4,r5
2219
        CHECK_FLAG (" 1.5 != -1.5: ", TRUE)
2220
 
2221
        /* Inequality of zeros */
2222
        LOAD_CONST (r4,FP_S_P_ZERO)
2223
        LOAD_CONST (r5,FP_S_P_ZERO)
2224
        lf.sfne.s  r4,r5
2225
        CHECK_FLAG ("+0.0 != +0.0: ", FALSE)
2226
 
2227
        LOAD_CONST (r4,FP_S_N_ZERO)
2228
        LOAD_CONST (r5,FP_S_N_ZERO)
2229
        lf.sfne.s  r4,r5
2230
        CHECK_FLAG ("-0.0 != -0.0: ", FALSE)
2231
 
2232
        LOAD_CONST (r4,FP_S_P_ZERO)
2233
        LOAD_CONST (r5,FP_S_N_ZERO)
2234
        lf.sfne.s  r4,r5
2235
        CHECK_FLAG ("+0.0 != -0.0: ", FALSE)
2236
 
2237
        /* Inequality with infinities (more needed) */
2238
        LOAD_CONST (r4,FP_S_ONE)
2239
        LOAD_CONST (r5,FP_S_P_INF)
2240
        lf.sfne.s  r4,r5
2241
        CHECK_FLAG (" 1.0 != +inf: ", TRUE)
2242
 
2243
        LOAD_CONST (r4,FP_S_P_INF)
2244
        LOAD_CONST (r5,FP_S_P_INF)
2245
        lf.sfne.s  r4,r5
2246
        CHECK_FLAG ("+inf != +inf: ", FALSE)
2247
 
2248
        LOAD_CONST (r4,FP_S_N_INF)
2249
        LOAD_CONST (r5,FP_S_N_INF)
2250
        lf.sfne.s  r4,r5
2251
        CHECK_FLAG ("-inf != -inf: ", FALSE)
2252
 
2253
        LOAD_CONST (r4,FP_S_P_INF)
2254
        LOAD_CONST (r5,FP_S_N_INF)
2255
        lf.sfne.s  r4,r5
2256
        CHECK_FLAG ("+inf != -inf: ", TRUE)
2257
 
2258
        /* Inequality with NaNs (more needed) */
2259
        LOAD_CONST (r4,FP_S_ONE)
2260
        LOAD_CONST (r5,FP_S_P_NAN)
2261
        lf.sfne.s  r4,r5
2262
        CHECK_FLAG (" 1.0 != +NaN: ", TRUE)
2263
 
2264
        LOAD_CONST (r4,FP_S_P_NAN)
2265
        LOAD_CONST (r5,FP_S_P_NAN)
2266
        lf.sfne.s  r4,r5
2267
        CHECK_FLAG ("+NaN != +NaN: ", TRUE)
2268
 
2269
        LOAD_CONST (r4,FP_S_N_NAN)
2270
        LOAD_CONST (r5,FP_S_N_NAN)
2271
        lf.sfne.s  r4,r5
2272
        CHECK_FLAG ("-NaN != -NaN: ", TRUE)
2273
 
2274
        LOAD_CONST (r4,FP_S_P_NAN)
2275
        LOAD_CONST (r5,FP_S_N_NAN)
2276
        lf.sfne.s  r4,r5
2277
        CHECK_FLAG ("+NaN != -NaN: ", TRUE)
2278
 
2279
        /* Inequality with denormalized numbers (more needed) */
2280
        LOAD_CONST (r4,FP_S_SMALL1)
2281
        LOAD_CONST (r5,FP_S_SMALL1)
2282
        lf.sfne.s  r4,r5
2283
        CHECK_FLAG (" 1.0 * 2^-129 != 1.0 * 2^-129: ", FALSE)
2284
 
2285
        LOAD_CONST (r4,FP_S_SMALL1)
2286
        LOAD_CONST (r5,FP_S_SMALL2)
2287
        lf.sfne.s  r4,r5
2288
        CHECK_FLAG (" 1.0 * 2^-129 != 1.0 * 2^-128: ", TRUE)
2289
 
2290
        LOAD_CONST (r4,FP_S_HUGE1)
2291
        LOAD_CONST (r5,FP_S_SMALL2)
2292
        lf.sfne.s  r4,r5
2293
        CHECK_FLAG (" 1.0 * 2^126  != 1.0 * 2^-128: ", TRUE)
2294
 
2295
/* ----------------------------------------------------------------------------
2296
 * Test of single precision subtract: lf.sub.s
2297
 * ------------------------------------------------------------------------- */
2298
        .section .text
2299
_sub_s:
2300
        LOAD_STR (r3, "lf.sub.s\n")
2301
        l.jal   _puts
2302
        l.nop
2303
 
2304 233 julius
        SET_RM  (FPCSR_RM_RIP)
2305
 
2306 104 jeremybenn
        /* Simple integer subtraction */
2307
        LOAD_CONST (r5,FP_S_ONE)
2308
        LOAD_CONST (r6,FP_S_P_ZERO)
2309
        lf.sub.s  r4,r5,r6
2310
        CHECK_RES (" 1.0 -  0.0  =  1.0:  ", r4, FP_S_ONE)
2311
 
2312
        LOAD_CONST (r5,FP_S_ONE)
2313
        LOAD_CONST (r6,FP_S_N_ZERO)
2314
        lf.sub.s  r4,r5,r6
2315
        CHECK_RES (" 1.0 - -0.0  =  1.0:  ", r4, FP_S_ONE)
2316
 
2317
        LOAD_CONST (r5,FP_S_ONE)
2318
        LOAD_CONST (r6,FP_S_ONE)
2319
        lf.sub.s  r4,r5,r6
2320
        CHECK_RES (" 1.0 -  1.0  = +0.0:  ", r4, FP_S_P_ZERO)
2321
 
2322
        LOAD_CONST (r5,FP_S_TWO)
2323
        LOAD_CONST (r6,FP_S_ONE)
2324
        lf.sub.s  r4,r5,r6
2325
        CHECK_RES (" 2.0 -  1.0  =  1.0:  ", r4, FP_S_ONE)
2326
 
2327
        /* Fractional subtraction */
2328
        LOAD_CONST (r5,FP_S_1_5)
2329
        LOAD_CONST (r6,FP_S_1_5)
2330
        lf.sub.s  r4,r5,r6
2331
        CHECK_RES (" 1.5 -  1.5  = +0.0:  ", r4, FP_S_P_ZERO)
2332
 
2333
        LOAD_CONST (r5,FP_S_1_5)
2334
        LOAD_CONST (r6,FP_S_0_5)
2335
        lf.sub.s  r4,r5,r6
2336
        CHECK_RES (" 1.5 -  0.5  =  1.0:  ", r4, FP_S_ONE)
2337
 
2338
        LOAD_CONST (r5,FP_S_1_5)
2339
        LOAD_CONST (r6,FP_S_ONE)
2340
        lf.sub.s  r4,r5,r6
2341
        CHECK_RES (" 1.5 -  1.5  =  0.5:  ", r4, FP_S_0_5)
2342
 
2343
        /* Subtraction with negative numbers */
2344
        LOAD_CONST (r5,FP_S_TWO)
2345
        LOAD_CONST (r6,FP_S_N_ONE)
2346
        lf.sub.s  r4,r5,r6
2347
        CHECK_RES (" 2.0 - -1.0  =  3.0:  ", r4, FP_S_THREE)
2348
 
2349
        LOAD_CONST (r5,FP_S_ONE)
2350
        LOAD_CONST (r6,FP_S_N_TWO)
2351
        lf.sub.s  r4,r5,r6
2352
        CHECK_RES (" 1.0 - -2.0  =  3.0:  ", r4, FP_S_THREE)
2353
 
2354
        LOAD_CONST (r5,FP_S_ONE)
2355
        LOAD_CONST (r6,FP_S_N_ONE)
2356
        lf.sub.s  r4,r5,r6
2357
        CHECK_RES (" 1.0 - -1.0  =  2.0:  ", r4, FP_S_TWO)
2358
 
2359
        LOAD_CONST (r5,FP_S_N_ONE)
2360
        LOAD_CONST (r6,FP_S_TWO)
2361
        lf.sub.s  r4,r5,r6
2362
        CHECK_RES ("-1.0 -  2.0  = -3.0:  ", r4, FP_S_N_THREE)
2363
 
2364
        LOAD_CONST (r5,FP_S_ONE)
2365
        LOAD_CONST (r6,FP_S_TWO)
2366
        lf.sub.s  r4,r5,r6
2367
        CHECK_RES (" 1.0 -  2.0  = -1.0:  ", r4, FP_S_N_ONE)
2368
 
2369
        LOAD_CONST (r5,FP_S_N_ONE)
2370
        LOAD_CONST (r6,FP_S_N_ONE)
2371
        lf.sub.s  r4,r5,r6
2372
        CHECK_RES ("-1.0 - -1.0  =  0.0:  ", r4, FP_S_P_ZERO)
2373
 
2374
        /* Subtraction with infinities (more needed) */
2375
        LOAD_CONST (r5,FP_S_ONE)
2376
        LOAD_CONST (r6,FP_S_P_INF)
2377
        lf.sub.s  r4,r5,r6
2378
        CHECK_RES (" 1.0 - +inf  = -inf:  ", r4, FP_S_N_INF)
2379
 
2380
        LOAD_CONST (r5,FP_S_ONE)
2381
        LOAD_CONST (r6,FP_S_N_INF)
2382
        lf.sub.s  r4,r5,r6
2383
        CHECK_RES (" 1.0 - -inf  = +inf:  ", r4, FP_S_P_INF)
2384
 
2385
        LOAD_CONST (r5,FP_S_P_INF)
2386
        LOAD_CONST (r6,FP_S_P_INF)
2387
        lf.sub.s  r4,r5,r6
2388
        CHECK_RES ("+inf - +inf  = -NaN:  ", r4, FP_S_N_NAN)
2389
 
2390
        LOAD_CONST (r5,FP_S_P_INF)
2391
        LOAD_CONST (r6,FP_S_N_INF)
2392
        lf.sub.s  r4,r5,r6
2393
        CHECK_RES ("+inf - -inf  = +inf:  ", r4, FP_S_P_INF)
2394
 
2395
        LOAD_CONST (r5,FP_S_N_INF)
2396
        LOAD_CONST (r6,FP_S_N_INF)
2397
        lf.sub.s  r4,r5,r6
2398
        CHECK_RES ("-inf - -inf  = -NaN:  ", r4, FP_S_N_NAN)
2399
 
2400
        /* Subtraction with NaNs (more needed) */
2401
        LOAD_CONST (r5,FP_S_ONE)
2402
        LOAD_CONST (r6,FP_S_P_NAN)
2403
        lf.sub.s  r4,r5,r6
2404
        CHECK_RES (" 1.0 - +NaN  = +NaN:  ", r4, FP_S_P_NAN)
2405
 
2406
        LOAD_CONST (r5,FP_S_ONE)
2407
        LOAD_CONST (r6,FP_S_N_NAN)
2408
        lf.sub.s  r4,r5,r6
2409
        CHECK_RES (" 1.0 - -NaN  = -NaN:  ", r4, FP_S_N_NAN)
2410
 
2411
        LOAD_CONST (r5,FP_S_P_NAN)
2412
        LOAD_CONST (r6,FP_S_P_NAN)
2413
        lf.sub.s  r4,r5,r6
2414
        CHECK_RES ("+NaN - +NaN  = +NaN:  ", r4, FP_S_P_NAN)
2415
 
2416
        LOAD_CONST (r5,FP_S_P_NAN)
2417
        LOAD_CONST (r6,FP_S_N_NAN)
2418
        lf.sub.s  r4,r5,r6
2419
        CHECK_RES ("+NaN - -NaN  = +NaN:  ", r4, FP_S_P_NAN)
2420
 
2421
        LOAD_CONST (r5,FP_S_N_NAN)
2422
        LOAD_CONST (r6,FP_S_N_NAN)
2423
        lf.sub.s  r4,r5,r6
2424
        CHECK_RES ("-NaN - -NaN  = -NaN:  ", r4, FP_S_N_NAN)
2425
 
2426
        LOAD_CONST (r5,FP_S_ONE)
2427
        LOAD_CONST (r6,FP_S_P_NAN_B)
2428
        lf.sub.s  r4,r5,r6
2429
        CHECK_RES (" 1.0 - +sNaN = +qNaN: ", r4, 0x7fc00001)
2430
 
2431
        LOAD_CONST (r5,FP_S_ONE)
2432
        LOAD_CONST (r6,FP_S_N_NAN_B)
2433
        lf.sub.s  r4,r5,r6
2434
        CHECK_RES (" 1.0 - -sNaN = -qNaN: ", r4, 0xffc00001)
2435
 
2436
        /* Subtraction with overflow (more neeeded) */
2437 233 julius
        SET_RM  (FPCSR_RM_RIN)
2438
 
2439 104 jeremybenn
        LOAD_CONST (r5,FP_S_N_HUGE2)
2440
        LOAD_CONST (r6,FP_S_HUGE2)
2441
        lf.sub.s  r4,r5,r6
2442
        CHECK_RES ("-1.0 * 2^127 -  1.0 * 2^127  = +inf:  ", r4, FP_S_N_INF)
2443
 
2444 233 julius
        SET_RM  (FPCSR_RM_RIP)
2445 104 jeremybenn
        LOAD_CONST (r5,FP_S_HUGE2)
2446
        LOAD_CONST (r6,FP_S_N_HUGE2)
2447
        lf.sub.s  r4,r5,r6
2448
        CHECK_RES (" 1.0 * 2^127 - -1.0 * 2^127  = -inf:  ", r4, FP_S_P_INF)
2449
 
2450
 
2451
/* ----------------------------------------------------------------------------
2452
 * All done
2453
 * ------------------------------------------------------------------------- */
2454
_exit:
2455
        LOAD_STR (r3, "Test completed\n")
2456
        l.jal   _puts
2457
        l.nop
2458
 
2459
        l.movhi r3,hi(ALL_DONE)
2460
        l.ori   r3,r3,lo(ALL_DONE)
2461
        l.nop   NOP_REPORT              /* Should be 0xdeaddead */
2462
 
2463
        l.addi  r3,r0,0
2464
        l.nop   NOP_EXIT

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.