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 584

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
        l.movhi r1,hi(_stack)           /* Set up the stack */
357
        l.ori   r1,r1,lo(_stack)
358 458 julius
 
359
        l.movhi r3,hi(start)            /* Jump to test start */
360
        l.ori   r3,r3,lo(start)
361 104 jeremybenn
        l.jr    r3
362
        l.nop
363 458 julius
 
364
        .org 0x700
365
illegal_insn:
366
        l.nop
367
        .section .rodata                                                ;\
368
1:                                                                      ;\
369
        .string "Illegal instruction. Enable hardware FPU.\n"           ;\
370
                                                                        ;\
371
        .section .except,"ax"                                                   ;\
372
        l.movhi r3,hi(1b)                                               ;\
373
        l.ori   r3,r3,lo(1b)
374
        l.jal   _puts
375
        l.nop
376
 
377
        .section .rodata                                                ;\
378
1:                                                                      ;\
379
        .string "Exiting.\n"                                            ;\
380
                                                                        ;\
381
        .section .except,"ax"                                                   ;\
382
        l.movhi r3,hi(1b)                                               ;\
383
        l.ori   r3,r3,lo(1b)
384
        l.jal   _puts
385
        l.nop
386
 
387
        l.addi  r3,r0,1
388
        l.nop   NOP_EXIT
389
 
390 104 jeremybenn
 
391 458 julius
        .section .text
392 104 jeremybenn
/* ----------------------------------------------------------------------------
393
 * Subroutine to print out a string
394
 *
395
 * The string is followed by a newline
396
 *
397
 * Parameters:
398
 *  r3  Pointer to the string to print
399
 * ------------------------------------------------------------------------- */
400
_puts:
401
        l.add   r2,r0,r3                /* Copy the string pointer */
402
 
403
        /* Loop getting and printing each char until end of string */
404
10:
405
        l.lbz   r3,0(r2)
406
        l.sfeq  r3,r0                   /* NULL termination? */
407
        l.bf    11f
408
 
409
        l.addi  r2,r2,1                 /* Delay slot, move to next char */
410
        l.j     10b                     /* Repeat */
411
        l.nop   NOP_PUTC                /* Delay slot */
412
 
413
11:
414
        l.jr    r9                      /* Return */
415
        l.nop
416
 
417
/* ----------------------------------------------------------------------------
418
 * Subroutine to print out a test name prompt
419
 *
420
 * The string is preceded by two spaces
421
 *
422
 * Parameters:
423
 *  r3  Pointer to the test name to print
424
 * ------------------------------------------------------------------------- */
425
_ptest:
426
        PUSH(r9)                        /* Save the return address */
427
        PUSH(r3)                        /* Save the test name for later */
428
 
429
        LOAD_STR(r3, "  ")              /* Prefix */
430
        l.jal   _puts
431
        l.nop
432
 
433
        POP(r3)                         /* Test name */
434
        l.jal   _puts
435
        l.nop
436
 
437
        POP (r9)
438
        l.jr    r9
439
 
440
 
441
/* ----------------------------------------------------------------------------
442
 * Subroutine to print out "OK"
443
 *
444
 * The string is followed by a newline
445
 * ------------------------------------------------------------------------- */
446
_pok:
447
        PUSH(r9)                        /* Save the return address */
448
 
449
        LOAD_STR(r3, "OK\n")
450
        l.jal   _puts
451
        l.nop
452
 
453
        POP (r9)
454
        l.jr    r9
455
 
456
 
457
/* ----------------------------------------------------------------------------
458
 * Subroutine to print out "Failed"
459
 *
460
 * The string is followed by a ": ", which will then allow a report
461
 * ------------------------------------------------------------------------- */
462
_pfail:
463
        PUSH(r9)                        /* Save the return address */
464
 
465
        LOAD_STR(r3, "Failed: ")
466
        l.jal   _puts
467
        l.nop
468
 
469
        POP (r9)
470
        l.jr    r9
471
 
472
/* ----------------------------------------------------------------------------
473
 * Subroutine to print out "TRUE"
474
 * ------------------------------------------------------------------------- */
475
_ptrue:
476
        PUSH(r9)                        /* Save the return address */
477
 
478
        LOAD_STR(r3, "TRUE")
479
        l.jal   _puts
480
        l.nop
481
 
482
        POP (r9)
483
        l.jr    r9
484
 
485
 
486
/* ----------------------------------------------------------------------------
487
 * Subroutine to print out "FALSE"
488
 * ------------------------------------------------------------------------- */
489
_pfalse:
490
        PUSH(r9)                        /* Save the return address */
491
 
492
        LOAD_STR(r3, "FALSE")
493
        l.jal   _puts
494
        l.nop
495
 
496
        POP (r9)
497
        l.jr    r9
498
 
499
/* ----------------------------------------------------------------------------
500
 * Subroutine to print out "unexpected"
501
 *
502
 * Preceded by a space and followed by a newline
503
 * ------------------------------------------------------------------------- */
504
_punexpected:
505
        PUSH(r9)                        /* Save the return address */
506
 
507
        LOAD_STR(r3, " unexpected\n")
508
        l.jal   _puts
509
        l.nop
510
 
511
        POP (r9)
512
        l.jr    r9
513
 
514
/* ----------------------------------------------------------------------------
515 458 julius
 * Start of tests
516 104 jeremybenn
 * ------------------------------------------------------------------------- */
517 458 julius
 
518
start:
519
 
520 104 jeremybenn
/* ----------------------------------------------------------------------------
521
 * Test of single precision add: lf.add.s
522
 * ------------------------------------------------------------------------- */
523 458 julius
 
524 104 jeremybenn
_add_s:
525
        LOAD_STR (r3, "lf.add.s\n")
526
        l.jal   _puts
527
        l.nop
528
 
529
        /* Simple integer addition */
530
        LOAD_CONST (r5,FP_S_ONE)
531
        LOAD_CONST (r6,FP_S_P_ZERO)
532
        lf.add.s  r4,r5,r6
533
        CHECK_RES (" 1.0 +  0.0  =  1.0:  ", r4, FP_S_ONE)
534
 
535
        LOAD_CONST (r5,FP_S_ONE)
536
        LOAD_CONST (r6,FP_S_N_ZERO)
537
        lf.add.s  r4,r5,r6
538
        CHECK_RES (" 1.0 + -0.0  =  1.0:  ", r4, FP_S_ONE)
539
 
540
        LOAD_CONST (r5,FP_S_ONE)
541
        LOAD_CONST (r6,FP_S_ONE)
542
        lf.add.s  r4,r5,r6
543
        CHECK_RES (" 1.0 +  1.0  =  2.0:  ", r4, FP_S_TWO)
544
 
545
        LOAD_CONST (r5,FP_S_TWO)
546
        LOAD_CONST (r6,FP_S_ONE)
547
        lf.add.s  r4,r5,r6
548
        CHECK_RES (" 2.0 +  1.0  =  3.0:  ", r4, FP_S_THREE)
549
 
550
        /* Fractional addition */
551
        LOAD_CONST (r5,FP_S_1_5)
552
        LOAD_CONST (r6,FP_S_1_5)
553
        lf.add.s  r4,r5,r6
554
        CHECK_RES (" 1.5 +  1.5  =  3.0:  ", r4, FP_S_THREE)
555
 
556
        /* Addition with negative numbers */
557
        LOAD_CONST (r5,FP_S_TWO)
558
        LOAD_CONST (r6,FP_S_N_ONE)
559
        lf.add.s  r4,r5,r6
560
        CHECK_RES (" 2.0 + -1.0  =  1.0:  ", r4, FP_S_ONE)
561
 
562
        LOAD_CONST (r5,FP_S_ONE)
563
        LOAD_CONST (r6,FP_S_N_TWO)
564
        lf.add.s  r4,r5,r6
565
        CHECK_RES (" 1.0 + -2.0  = -1.0:  ", r4, FP_S_N_ONE)
566
 
567
        LOAD_CONST (r5,FP_S_ONE)
568
        LOAD_CONST (r6,FP_S_N_ONE)
569
        lf.add.s  r4,r5,r6
570
        CHECK_RES (" 1.0 + -1.0  = +0.0:  ", r4, FP_S_P_ZERO)
571
 
572
        /* Addition with infinities */
573
        LOAD_CONST (r5,FP_S_ONE)
574
        LOAD_CONST (r6,FP_S_P_INF)
575
        lf.add.s  r4,r5,r6
576
        CHECK_RES (" 1.0 + +inf  = +inf:  ", r4, FP_S_P_INF)
577
 
578
        LOAD_CONST (r5,FP_S_ONE)
579
        LOAD_CONST (r6,FP_S_N_INF)
580
        lf.add.s  r4,r5,r6
581
        CHECK_RES (" 1.0 + -inf  = -inf:  ", r4, FP_S_N_INF)
582
 
583
        LOAD_CONST (r5,FP_S_P_INF)
584
        LOAD_CONST (r6,FP_S_P_INF)
585
        lf.add.s  r4,r5,r6
586
        CHECK_RES ("+inf + +inf  = +inf:  ", r4, FP_S_P_INF)
587
 
588
        LOAD_CONST (r5,FP_S_P_INF)
589
        LOAD_CONST (r6,FP_S_N_INF)
590
        lf.add.s  r4,r5,r6
591
        CHECK_RES ("+inf + -inf  = -NaN:  ", r4, FP_S_N_NAN)
592
 
593
        LOAD_CONST (r5,FP_S_N_INF)
594
        LOAD_CONST (r6,FP_S_N_INF)
595
        lf.add.s  r4,r5,r6
596
        CHECK_RES ("-inf + -inf  = -inf:  ", r4, FP_S_N_INF)
597
 
598
        /* Addition with NaNs */
599
        LOAD_CONST (r5,FP_S_ONE)
600
        LOAD_CONST (r6,FP_S_P_NAN)
601
        lf.add.s  r4,r5,r6
602
        CHECK_RES (" 1.0 + +NaN  = +NaN:  ", r4, FP_S_P_NAN)
603
 
604
        LOAD_CONST (r5,FP_S_ONE)
605
        LOAD_CONST (r6,FP_S_N_NAN)
606
        lf.add.s  r4,r5,r6
607
        CHECK_RES (" 1.0 + -NaN  = -NaN:  ", r4, FP_S_N_NAN)
608
 
609
        LOAD_CONST (r5,FP_S_P_NAN)
610
        LOAD_CONST (r6,FP_S_P_NAN)
611
        lf.add.s  r4,r5,r6
612
        CHECK_RES ("+NaN + +NaN  = +NaN:  ", r4, FP_S_P_NAN)
613
 
614
        LOAD_CONST (r5,FP_S_P_NAN)
615
        LOAD_CONST (r6,FP_S_N_NAN)
616
        lf.add.s  r4,r5,r6
617
        CHECK_RES ("+NaN + -NaN  = +NaN:  ", r4, FP_S_P_NAN)
618
 
619
        LOAD_CONST (r5,FP_S_N_NAN)
620
        LOAD_CONST (r6,FP_S_N_NAN)
621
        lf.add.s  r4,r5,r6
622
        CHECK_RES ("-NaN + -NaN  = -NaN:  ", r4, FP_S_N_NAN)
623
 
624
        LOAD_CONST (r5,FP_S_ONE)
625
        LOAD_CONST (r6,FP_S_P_NAN_B)
626
        lf.add.s  r4,r5,r6
627
        CHECK_RES (" 1.0 + +sNaN = +qNaN: ", r4, 0x7fc00001)
628
 
629
        LOAD_CONST (r5,FP_S_ONE)
630
        LOAD_CONST (r6,FP_S_N_NAN_B)
631
        lf.add.s  r4,r5,r6
632
        CHECK_RES (" 1.0 + -sNaN = -qNaN: ", r4, 0xffc00001)
633
 
634
        /* Addition with overflow */
635
        LOAD_CONST (r5,FP_S_HUGE2)
636
        LOAD_CONST (r6,FP_S_HUGE2)
637
        lf.add.s  r4,r5,r6
638
        CHECK_RES (" 1.0 * 2^127 +  1.0 * 2^127  = +inf:  ", r4, FP_S_P_INF)
639
 
640
        LOAD_CONST (r5,FP_S_N_HUGE2)
641
        LOAD_CONST (r6,FP_S_N_HUGE2)
642
        lf.add.s  r4,r5,r6
643
        CHECK_RES ("-1.0 * 2^127 + -1.0 * 2^127  = -inf:  ", r4, FP_S_N_INF)
644
 
645
/* ----------------------------------------------------------------------------
646
 * Test of single precision custom instruction: lf.cust1.s
647
 * ------------------------------------------------------------------------- */
648
_cust1_s:
649
        LOAD_STR (r3, "lf.cust1.s\n")
650
        l.jal   _puts
651
        l.nop
652
 
653
        /* Just test that the instruction does nothing */
654
        LOAD_CONST (r4,FP_S_ONE)
655
        LOAD_CONST (r5,FP_S_TWO)
656
        lf.cust1.s  r4,r5               /* Should do nothing */
657
        CHECK_RES ("l.cust1: ", r4, FP_S_ONE)
658
 
659
/* ----------------------------------------------------------------------------
660
 * Test of single precision divide instruction: lf.div.s
661
 * ------------------------------------------------------------------------- */
662
_div_s:
663
        LOAD_STR (r3, "lf.div.s\n")
664
        l.jal   _puts
665
        l.nop
666
 
667
        /* Tests of integer division */
668
        LOAD_CONST (r5,FP_S_ONE)
669
        LOAD_CONST (r6,FP_S_ONE)
670
        lf.div.s  r4,r5,r6
671
        CHECK_RES (" 1.0 /  1.0 =  1.0: ", r4, FP_S_ONE)
672
 
673
        LOAD_CONST (r5,FP_S_TWO)
674
        LOAD_CONST (r6,FP_S_ONE)
675
        lf.div.s  r4,r5,r6
676
        CHECK_RES (" 2.0 /  1.0 =  2.0: ", r4, FP_S_TWO)
677
 
678
        /* Test division with fractional result */
679
        LOAD_CONST (r5,FP_S_THREE)
680
        LOAD_CONST (r6,FP_S_TWO)
681
        lf.div.s  r4,r5,r6
682
        CHECK_RES (" 3.0 /  2.0 =  1.5: ", r4, FP_S_1_5)
683
 
684
        /* Test division of zero */
685
        LOAD_CONST (r5,FP_S_P_ZERO)
686
        LOAD_CONST (r6,FP_S_ONE)
687
        lf.div.s  r4,r5,r6
688
        CHECK_RES ("+0.0 /  1.0 = +0.0: ", r4, FP_S_P_ZERO)
689
 
690
        LOAD_CONST (r5,FP_S_N_ZERO)
691
        LOAD_CONST (r6,FP_S_ONE)
692
        lf.div.s  r4,r5,r6
693
        CHECK_RES ("-0.0 /  1.0 = -0.0: ", r4, FP_S_N_ZERO)
694
 
695
        /* Test signed division */
696
        LOAD_CONST (r5,FP_S_N_THREE)
697
        LOAD_CONST (r6,FP_S_TWO)
698
        lf.div.s  r4,r5,r6
699
        CHECK_RES ("-3.0 /  2.0 = -1.5: ", r4, FP_S_N_1_5)
700
 
701
        LOAD_CONST (r5,FP_S_THREE)
702
        LOAD_CONST (r6,FP_S_N_TWO)
703
        lf.div.s  r4,r5,r6
704
        CHECK_RES (" 3.0 / -2.0 = -1.5: ", r4, FP_S_N_1_5)
705
 
706
        LOAD_CONST (r5,FP_S_N_THREE)
707
        LOAD_CONST (r6,FP_S_N_TWO)
708
        lf.div.s  r4,r5,r6
709
        CHECK_RES ("-3.0 / -2.0 = -1.5: ", r4, FP_S_1_5)
710
 
711
        /* Division by zero */
712
        LOAD_CONST (r5,FP_S_ONE)
713
        LOAD_CONST (r6,FP_S_P_ZERO)
714
        lf.div.s  r4,r5,r6
715
        CHECK_RES (" 1.0 / +0.0 = +inf: ", r4, FP_S_P_INF)
716
 
717
        LOAD_CONST (r5,FP_S_ONE)
718
        LOAD_CONST (r6,FP_S_P_ZERO)
719
        lf.div.s  r4,r5,r6
720
        CHECK_RES (" 1.0 / -0.0 = +inf: ", r4, FP_S_P_INF)
721
 
722
        LOAD_CONST (r5,FP_S_N_ONE)
723
        LOAD_CONST (r6,FP_S_P_ZERO)
724
        lf.div.s  r4,r5,r6
725
        CHECK_RES ("-1.0 / +0.0 = -inf: ", r4, FP_S_N_INF)
726
 
727
        LOAD_CONST (r5,FP_S_N_ONE)
728
        LOAD_CONST (r6,FP_S_P_ZERO)
729
        lf.div.s  r4,r5,r6
730
        CHECK_RES ("-1.0 / -0.0 = -inf: ", r4, FP_S_N_INF)
731
 
732
        /* Division with infinities */
733
        LOAD_CONST (r5,FP_S_ONE)
734
        LOAD_CONST (r6,FP_S_P_INF)
735
        lf.div.s  r4,r5,r6
736
        CHECK_RES (" 1.0 / +inf = +0.0: ", r4, FP_S_P_ZERO)
737
 
738
        LOAD_CONST (r5,FP_S_ONE)
739
        LOAD_CONST (r6,FP_S_N_INF)
740
        lf.div.s  r4,r5,r6
741
        CHECK_RES (" 1.0 / -inf = -0.0: ", r4, FP_S_N_ZERO)
742
 
743
        LOAD_CONST (r5,FP_S_N_ONE)
744
        LOAD_CONST (r6,FP_S_P_INF)
745
        lf.div.s  r4,r5,r6
746
        CHECK_RES ("-1.0 / +inf = -0.0: ", r4, FP_S_N_ZERO)
747
 
748
        LOAD_CONST (r5,FP_S_N_ONE)
749
        LOAD_CONST (r6,FP_S_N_INF)
750
        lf.div.s  r4,r5,r6
751
        CHECK_RES ("-1.0 / -inf = +0.0: ", r4, FP_S_P_ZERO)
752
 
753
        LOAD_CONST (r5,FP_S_P_INF)
754
        LOAD_CONST (r6,FP_S_ONE)
755
        lf.div.s  r4,r5,r6
756
        CHECK_RES ("+inf /  1.0 = +inf: ", r4, FP_S_P_INF)
757
 
758
        LOAD_CONST (r5,FP_S_N_INF)
759
        LOAD_CONST (r6,FP_S_ONE)
760
        lf.div.s  r4,r5,r6
761
        CHECK_RES ("-inf /  1.0 = -inf: ", r4, FP_S_N_INF)
762
 
763
        LOAD_CONST (r5,FP_S_P_INF)
764
        LOAD_CONST (r6,FP_S_N_ONE)
765
        lf.div.s  r4,r5,r6
766
        CHECK_RES ("+inf / -1.0 = -inf: ", r4, FP_S_N_INF)
767
 
768
        LOAD_CONST (r5,FP_S_N_INF)
769
        LOAD_CONST (r6,FP_S_N_ONE)
770
        lf.div.s  r4,r5,r6
771
        CHECK_RES ("-inf / -1.0 = +inf: ", r4, FP_S_P_INF)
772
 
773
        LOAD_CONST (r5,FP_S_P_INF)
774
        LOAD_CONST (r6,FP_S_P_INF)
775
        lf.div.s  r4,r5,r6
776
        CHECK_RES ("+inf / +inf = -NaN: ", r4, FP_S_N_NAN)
777
 
778
        LOAD_CONST (r5,FP_S_P_INF)
779
        LOAD_CONST (r6,FP_S_N_INF)
780
        lf.div.s  r4,r5,r6
781
        CHECK_RES ("+inf / -inf = -NaN: ", r4, FP_S_N_NAN)
782
 
783
        LOAD_CONST (r5,FP_S_N_INF)
784
        LOAD_CONST (r6,FP_S_P_INF)
785
        lf.div.s  r4,r5,r6
786
        CHECK_RES ("-inf / +inf = -NaN: ", r4, FP_S_N_NAN)
787
 
788
        LOAD_CONST (r5,FP_S_N_INF)
789
        LOAD_CONST (r6,FP_S_N_INF)
790
        lf.div.s  r4,r5,r6
791
        CHECK_RES ("-inf / -inf = -NaN: ", r4, FP_S_N_NAN)
792
 
793
        /* Division with NaNs */
794
        LOAD_CONST (r5,FP_S_ONE)
795
        LOAD_CONST (r6,FP_S_P_NAN)
796
        lf.div.s  r4,r5,r6
797
        CHECK_RES (" 1.0 / +NaN = +NaN: ", r4, FP_S_P_NAN)
798
 
799
        LOAD_CONST (r5,FP_S_ONE)
800
        LOAD_CONST (r6,FP_S_N_NAN)
801
        lf.div.s  r4,r5,r6
802
        CHECK_RES (" 1.0 / -NaN = -NaN: ", r4, FP_S_N_NAN)
803
 
804
        LOAD_CONST (r5,FP_S_N_ONE)
805
        LOAD_CONST (r6,FP_S_P_NAN)
806
        lf.div.s  r4,r5,r6
807
        CHECK_RES ("-1.0 / +NaN = +NaN: ", r4, FP_S_P_NAN)
808
 
809
        LOAD_CONST (r5,FP_S_N_ONE)
810
        LOAD_CONST (r6,FP_S_N_NAN)
811
        lf.div.s  r4,r5,r6
812
        CHECK_RES ("-1.0 / -NaN = 1NaN: ", r4, FP_S_N_NAN)
813
 
814
        LOAD_CONST (r5,FP_S_P_NAN)
815
        LOAD_CONST (r6,FP_S_ONE)
816
        lf.div.s  r4,r5,r6
817
        CHECK_RES ("+NaN /  1.0 = +NaN: ", r4, FP_S_P_NAN)
818
 
819
        LOAD_CONST (r5,FP_S_N_NAN)
820
        LOAD_CONST (r6,FP_S_ONE)
821
        lf.div.s  r4,r5,r6
822
        CHECK_RES ("-NaN /  1.0 = -NaN: ", r4, FP_S_N_NAN)
823
 
824
        LOAD_CONST (r5,FP_S_P_NAN)
825
        LOAD_CONST (r6,FP_S_N_ONE)
826
        lf.div.s  r4,r5,r6
827
        CHECK_RES ("+NaN / -1.0 = +NaN: ", r4, FP_S_P_NAN)
828
 
829
        LOAD_CONST (r5,FP_S_N_NAN)
830
        LOAD_CONST (r6,FP_S_N_ONE)
831
        lf.div.s  r4,r5,r6
832
        CHECK_RES ("-NaN / -1.0 = -NaN: ", r4, FP_S_N_NAN)
833
 
834
        LOAD_CONST (r5,FP_S_P_NAN)
835
        LOAD_CONST (r6,FP_S_P_NAN)
836
        lf.div.s  r4,r5,r6
837
        CHECK_RES ("+NaN / +NaN = +NaN: ", r4, FP_S_P_NAN)
838
 
839
        LOAD_CONST (r5,FP_S_P_NAN)
840
        LOAD_CONST (r6,FP_S_N_NAN)
841
        lf.div.s  r4,r5,r6
842
        CHECK_RES ("+NaN / -NaN = +NaN: ", r4, FP_S_P_NAN)
843
 
844
        LOAD_CONST (r5,FP_S_N_NAN)
845
        LOAD_CONST (r6,FP_S_P_NAN)
846
        lf.div.s  r4,r5,r6
847 233 julius
        CHECK_RES ("-NaN / +NaN = -NaN: ", r4, FP_S_N_NAN)
848 104 jeremybenn
 
849
        LOAD_CONST (r5,FP_S_N_NAN)
850
        LOAD_CONST (r6,FP_S_N_NAN)
851
        lf.div.s  r4,r5,r6
852
        CHECK_RES ("-NaN / -NaN = -NaN: ", r4, FP_S_N_NAN)
853
 
854
        /* Division with overflow */
855
        LOAD_CONST (r5,FP_S_HUGE2)
856
        LOAD_CONST (r6,FP_S_SMALL1)
857
        lf.div.s  r4,r5,r6
858
        CHECK_RES (" 1.0 * 2^127  /  1.0 * 2^-129 = +inf: ", r4, FP_S_P_INF)
859
 
860
        LOAD_CONST (r5,FP_S_N_HUGE2)
861
        LOAD_CONST (r6,FP_S_SMALL1)
862
        lf.div.s  r4,r5,r6
863
        CHECK_RES ("-1.0 * 2^127  /  1.0 * 2^-129 = -inf: ", r4, FP_S_N_INF)
864
 
865
        LOAD_CONST (r5,FP_S_HUGE2)
866
        LOAD_CONST (r6,FP_S_N_SMALL1)
867
        lf.div.s  r4,r5,r6
868
        CHECK_RES (" 1.0 * 2^127  / -1.0 * 2^-129 = -inf: ", r4, FP_S_N_INF)
869
 
870
        LOAD_CONST (r5,FP_S_N_HUGE2)
871
        LOAD_CONST (r6,FP_S_N_SMALL1)
872
        lf.div.s  r4,r5,r6
873
        CHECK_RES ("-1.0 * 2^127  / -1.0 * 2^-129 = +inf: ", r4, FP_S_P_INF)
874
 
875
        /* Division with underflow */
876
        LOAD_CONST (r5,FP_S_SMALL1)
877
        LOAD_CONST (r6,FP_S_HUGE1)
878
        lf.div.s  r4,r5,r6
879
        CHECK_RES (" 1.0 * 2^-129 /  1.0 * 2^127  = +0.0: ", r4, FP_S_P_ZERO)
880
 
881
        LOAD_CONST (r5,FP_S_N_SMALL1)
882
        LOAD_CONST (r6,FP_S_HUGE1)
883
        lf.div.s  r4,r5,r6
884
        CHECK_RES ("-1.0 * 2^-129 /  1.0 * 2^127  = -0.0: ", r4, FP_S_N_ZERO)
885
 
886
        LOAD_CONST (r5,FP_S_SMALL1)
887
        LOAD_CONST (r6,FP_S_N_HUGE1)
888
        lf.div.s  r4,r5,r6
889
        CHECK_RES (" 1.0 * 2^-129 / -1.0 * 2^127  = -0.0: ", r4, FP_S_N_ZERO)
890
 
891
        LOAD_CONST (r5,FP_S_N_SMALL1)
892
        LOAD_CONST (r6,FP_S_N_HUGE1)
893
        lf.div.s  r4,r5,r6
894
        CHECK_RES ("-1.0 * 2^-129 / -1.0 * 2^127  = +0.0: ", r4, FP_S_P_ZERO)
895
 
896
        /* Needs tests of normalization to denormalization */
897
 
898
/* ----------------------------------------------------------------------------
899
 * Test of single precision fp to integer conversion: lf.ftoi.s
900
 * ------------------------------------------------------------------------- */
901
v_ftoi_s:
902
        LOAD_STR (r3, "lf.ftoi.s\n")
903
        l.jal   _puts
904
        l.nop
905
 
906
        /* Integer conversion */
907
        LOAD_CONST (r5,FP_S_ONE)
908
        lf.ftoi.s  r4,r5
909
        CHECK_RES ("(int)  1.0          =  1:    ", r4, 0x00000001)
910
 
911
        LOAD_CONST (r5,FP_S_N_ONE)
912
        lf.ftoi.s  r4,r5
913
        CHECK_RES ("(int) -1.0          = -1:    ", r4, 0xffffffff)
914
 
915
        LOAD_CONST (r5,FP_S_P_ZERO)
916
        lf.ftoi.s  r4,r5
917
        CHECK_RES ("(int) +0.0          =  0:    ", r4, 0x00000000)
918
 
919
        LOAD_CONST (r5,FP_S_N_ZERO)
920
        lf.ftoi.s  r4,r5
921
        CHECK_RES ("(int) -0.0          =  0:    ", r4, 0x00000000)
922
 
923
        /* Fractional conversion (round towards zero) */
924 233 julius
        SET_RM  (FPCSR_RM_RZ)
925 104 jeremybenn
        LOAD_CONST (r5,FP_S_1_5)
926
        lf.ftoi.s  r4,r5
927
        CHECK_RES ("(int)  1.5          =  1:    ", r4, 0x00000001)
928
 
929
        LOAD_CONST (r5,FP_S_N_1_5)
930
        lf.ftoi.s  r4,r5
931
        CHECK_RES ("(int) -1.5          = -1:    ", r4, 0xffffffff)
932
 
933
        /* Conversion of values too big */
934
        LOAD_CONST (r5,FP_S_HUGE1)
935
        lf.ftoi.s  r4,r5
936 233 julius
        CHECK_RES ("(int)  1.0 * 2^126  = 2^31: ", r4, 0x7fffffff)
937 104 jeremybenn
 
938
        LOAD_CONST (r5,FP_S_N_HUGE1)
939
        lf.ftoi.s  r4,r5
940
        CHECK_RES ("(int) -1.0 * 2^126  = -2^31: ", r4, 0x80000000)
941
 
942
        /* Conversion of very small values */
943
        LOAD_CONST (r5,FP_S_SMALL1)
944
        lf.ftoi.s  r4,r5
945
        CHECK_RES ("(int)  1.0 * 2^-129 =  0:    ", r4, 0x00000000)
946
 
947
        LOAD_CONST (r5,FP_S_N_SMALL1)
948
        lf.ftoi.s  r4,r5
949
        CHECK_RES ("(int) -1.0 * 2^-129 =  0:    ", r4, 0x00000000)
950
 
951
        /* Just basic check of Infinity & NaN */
952
        LOAD_CONST (r5,FP_S_P_INF)
953
        lf.ftoi.s  r4,r5
954 233 julius
        CHECK_RES ("(int) +inf          = 2^31: ", r4, 0x7fffffff)
955 104 jeremybenn
 
956
        LOAD_CONST (r5,FP_S_N_INF)
957
        lf.ftoi.s  r4,r5
958
        CHECK_RES ("(int) -inf          = -2^31: ", r4, 0x80000000)
959
 
960
        LOAD_CONST (r5,FP_S_P_NAN)
961
        lf.ftoi.s  r4,r5
962 233 julius
        CHECK_RES ("(int) +NaN          = 2^31: ", r4, 0x7fffffff)
963 104 jeremybenn
 
964
        LOAD_CONST (r5,FP_S_N_NAN)
965
        lf.ftoi.s  r4,r5
966 233 julius
        CHECK_RES ("(int) -NaN          = 2^31: ", r4, 0x7fffffff)
967 104 jeremybenn
 
968
/* ----------------------------------------------------------------------------
969
 * Test of single precision integer to fp conversion: lf.itof.s
970
 * ------------------------------------------------------------------------- */
971
_itof_s:
972
        LOAD_STR (r3, "lf.itof.s\n")
973
        l.jal   _puts
974
        l.nop
975
 
976
        /* Integer conversion */
977
        LOAD_CONST (r5,FP_S_ONE)
978
        lf.ftoi.s  r4,r5
979
        CHECK_RES ("(float)  1.0 =  1: ", r4, 0x00000001)
980
 
981
        LOAD_CONST (r5,FP_S_N_ONE)
982
        lf.ftoi.s  r4,r5
983
        CHECK_RES ("(float) -1.0 = -1: ", r4, 0xffffffff)
984
 
985
        LOAD_CONST (r5,FP_S_P_ZERO)
986
        lf.ftoi.s  r4,r5
987
        CHECK_RES ("(float) +0.0 =  0: ", r4, 0x00000000)
988
 
989
        LOAD_CONST (r5,FP_S_N_ZERO)
990
        lf.ftoi.s  r4,r5
991
        CHECK_RES ("(float) -0.0 =  0: ", r4, 0x00000000)
992
 
993
/* ----------------------------------------------------------------------------
994
 * Test of single precision multiply and add: lf.madd.s
995
 * ------------------------------------------------------------------------- */
996
_madd_s:
997
        LOAD_STR (r3, "lf.madd.s\n")
998
        l.jal   _puts
999
        l.nop
1000
 
1001
        /* Test of integer multiply and add */
1002
        LOAD_CONST (r4,FP_S_ONE)
1003
        LOAD_CONST (r5,FP_S_ONE)
1004
        LOAD_CONST (r6,FP_S_ONE)
1005
        lf.madd.s  r4,r5,r6
1006
        CHECK_RES (" 1.0 +  1.0 *  1.0 =  2.0: ", r4, FP_S_TWO)
1007
 
1008
        /* Multiply and add with fractions */
1009
        LOAD_CONST (r4,FP_S_0_5)
1010
        LOAD_CONST (r5,FP_S_ONE)
1011
        LOAD_CONST (r6,FP_S_ONE)
1012
        lf.madd.s  r4,r5,r6
1013
        CHECK_RES (" 0.5 +  1.0 *  1.0 =  1.5: ", r4, FP_S_1_5)
1014
 
1015
        LOAD_CONST (r4,FP_S_ONE)
1016
        LOAD_CONST (r5,FP_S_0_5)
1017
        LOAD_CONST (r6,FP_S_TWO)
1018
        lf.madd.s  r4,r5,r6
1019
        CHECK_RES (" 1.0 +  0.5 *  2.0 =  2.0: ", r4, FP_S_TWO)
1020
 
1021
        /* Multiply and add with negative numbers */
1022
        LOAD_CONST (r4,FP_S_ONE)
1023
        LOAD_CONST (r5,FP_S_N_ONE)
1024
        LOAD_CONST (r6,FP_S_TWO)
1025
        lf.madd.s  r4,r5,r6
1026
        CHECK_RES (" 1.0 + -1.0 *  2.0 = -1.0: ", r4, FP_S_N_ONE)
1027
 
1028
        LOAD_CONST (r4,FP_S_N_TWO)
1029
        LOAD_CONST (r5,FP_S_TWO)
1030
        LOAD_CONST (r6,FP_S_0_5)
1031
        lf.madd.s  r4,r5,r6
1032
        CHECK_RES ("-2.0 +  2.0 *  0.5 = -1.0: ", r4, FP_S_N_ONE)
1033
 
1034
        LOAD_CONST (r4,FP_S_N_0_5)
1035
        LOAD_CONST (r5,FP_S_N_0_5)
1036
        LOAD_CONST (r6,FP_S_THREE)
1037
        lf.madd.s  r4,r5,r6
1038
        CHECK_RES ("-0.5 + -0.5 *  3.0 = -2.0: ", r4, FP_S_N_TWO)
1039
 
1040
        /* Multiply and add with zeros (more needed) */
1041
        LOAD_CONST (r4,FP_S_P_ZERO)
1042
        LOAD_CONST (r5,FP_S_P_ZERO)
1043
        LOAD_CONST (r6,FP_S_P_ZERO)
1044
        lf.madd.s  r4,r5,r6
1045
        CHECK_RES ("+0.0 + +0.0 * +0.0 = +0.0: ", r4, FP_S_P_ZERO)
1046
 
1047
        LOAD_CONST (r4,FP_S_N_ZERO)
1048
        LOAD_CONST (r5,FP_S_N_ZERO)
1049
        LOAD_CONST (r6,FP_S_N_ZERO)
1050
        lf.madd.s  r4,r5,r6
1051
        CHECK_RES ("-0.0 + +0.0 * -0.0 = +0.0: ", r4, FP_S_P_ZERO)
1052
 
1053
        LOAD_CONST (r4,FP_S_N_ZERO)
1054
        LOAD_CONST (r5,FP_S_N_ZERO)
1055
        LOAD_CONST (r6,FP_S_N_ZERO)
1056
        lf.madd.s  r4,r5,r6
1057
        CHECK_RES ("-0.0 + -0.0 * -0.0 = +0.0: ", r4, FP_S_P_ZERO)
1058
 
1059
        LOAD_CONST (r4,FP_S_N_ONE)
1060
        LOAD_CONST (r5,FP_S_ONE)
1061
        LOAD_CONST (r6,FP_S_ONE)
1062
        lf.madd.s  r4,r5,r6
1063
        CHECK_RES ("-1.0 +  1.0 *  1.0 = +0.0: ", r4, FP_S_P_ZERO)
1064
 
1065
        /* Multiply and add with infinities (more needed) */
1066
        LOAD_CONST (r4,FP_S_P_INF)
1067
        LOAD_CONST (r5,FP_S_ONE)
1068
        LOAD_CONST (r6,FP_S_ONE)
1069
        lf.madd.s  r4,r5,r6
1070
        CHECK_RES ("+inf +  1.0 *  1.0 = +inf: ", r4, FP_S_P_INF)
1071
 
1072
        LOAD_CONST (r4,FP_S_ONE)
1073
        LOAD_CONST (r5,FP_S_ONE)
1074
        LOAD_CONST (r6,FP_S_P_INF)
1075
        lf.madd.s  r4,r5,r6
1076
        CHECK_RES (" 1.0 +  1.0 * +inf = +inf: ", r4, FP_S_P_INF)
1077
 
1078
        LOAD_CONST (r4,FP_S_P_INF)
1079
        LOAD_CONST (r5,FP_S_ONE)
1080
        LOAD_CONST (r6,FP_S_P_INF)
1081
        lf.madd.s  r4,r5,r6
1082
        CHECK_RES ("+inf +  1.0 * +inf = +inf: ", r4, FP_S_P_INF)
1083
 
1084
        LOAD_CONST (r4,FP_S_N_INF)
1085
        LOAD_CONST (r5,FP_S_ONE)
1086
        LOAD_CONST (r6,FP_S_ONE)
1087
        lf.madd.s  r4,r5,r6
1088
        CHECK_RES ("-inf +  1.0 *  1.0 = -inf: ", r4, FP_S_N_INF)
1089
 
1090
        /* Multiply and add with NaNs (more needed) */
1091
        LOAD_CONST (r4,FP_S_P_NAN)
1092
        LOAD_CONST (r5,FP_S_ONE)
1093
        LOAD_CONST (r6,FP_S_ONE)
1094
        lf.madd.s  r4,r5,r6
1095
        CHECK_RES ("+NaN +  1.0 *  1.0 = +NaN: ", r4, FP_S_P_NAN)
1096
 
1097
        LOAD_CONST (r4,FP_S_ONE)
1098
        LOAD_CONST (r5,FP_S_ONE)
1099
        LOAD_CONST (r6,FP_S_P_NAN)
1100
        lf.madd.s  r4,r5,r6
1101
        CHECK_RES (" 1.0 +  1.0 * +NaN = +NaN: ", r4, FP_S_P_NAN)
1102
 
1103
        LOAD_CONST (r4,FP_S_P_NAN)
1104
        LOAD_CONST (r5,FP_S_ONE)
1105
        LOAD_CONST (r6,FP_S_P_NAN)
1106
        lf.madd.s  r4,r5,r6
1107
        CHECK_RES ("+NaN +  1.0 * +NaN = +NaN: ", r4, FP_S_P_NAN)
1108
 
1109
        LOAD_CONST (r4,FP_S_N_NAN)
1110
        LOAD_CONST (r5,FP_S_ONE)
1111
        LOAD_CONST (r6,FP_S_ONE)
1112
        lf.madd.s  r4,r5,r6
1113
        CHECK_RES ("-NaN +  1.0 *  1.0 = -NaN: ", r4, FP_S_N_NAN)
1114
 
1115
        /* Multiply and add with overflow (more needed) */
1116 233 julius
        SET_RM  (FPCSR_RM_RIP)
1117 104 jeremybenn
        LOAD_CONST (r4,FP_S_HUGE2)
1118
        LOAD_CONST (r5,FP_S_HUGE2)
1119
        LOAD_CONST (r6,FP_S_ONE)
1120
        lf.madd.s  r4,r5,r6
1121 233 julius
        CHECK_RES (" 1.0 * 2^127  +  1.0 * 2^127  *  1.0 = +inf: ",
1122 104 jeremybenn
                   r4, FP_S_P_INF)
1123
 
1124 233 julius
        SET_RM  (FPCSR_RM_RIN)
1125 104 jeremybenn
        LOAD_CONST (r4,FP_S_HUGE2)
1126
        LOAD_CONST (r5,FP_S_HUGE2)
1127
        LOAD_CONST (r6,FP_S_SMALL1)
1128
        lf.madd.s  r4,r5,r6
1129
        CHECK_RES (" 1.0 * 2^127  +  1.0 * 2^127  *  1.0 * 2^-129 = +inf: ",
1130
                   r4, FP_S_HUGE2)
1131
 
1132
/* ----------------------------------------------------------------------------
1133
 * Test of single precision multiply: lf.mul.s
1134
 * ------------------------------------------------------------------------- */
1135
_mul_s:
1136
        LOAD_STR (r3, "lf.mul.s\n")
1137
        l.jal   _puts
1138
        l.nop
1139
 
1140
        /* Tests of integer multiplication */
1141
        LOAD_CONST (r5,FP_S_ONE)
1142
        LOAD_CONST (r6,FP_S_ONE)
1143
        lf.mul.s  r4,r5,r6
1144
        CHECK_RES (" 1.0 *  1.0 =  1.0: ", r4, FP_S_ONE)
1145
 
1146
        LOAD_CONST (r5,FP_S_THREE)
1147
        LOAD_CONST (r6,FP_S_ONE)
1148
        lf.mul.s  r4,r5,r6
1149
        CHECK_RES (" 3.0 *  1.0 =  3.0: ", r4, FP_S_THREE)
1150
 
1151
        /* Multiplication with fractions */
1152
        LOAD_CONST (r5,FP_S_1_5)
1153
        LOAD_CONST (r6,FP_S_TWO)
1154
        lf.mul.s  r4,r5,r6
1155
        CHECK_RES (" 1.5 *  2.0 =  3.0: ", r4, FP_S_THREE)
1156
 
1157
        /* Multiplication with negative numbers */
1158
        LOAD_CONST (r5,FP_S_N_ONE)
1159
        LOAD_CONST (r6,FP_S_TWO)
1160
        lf.mul.s  r4,r5,r6
1161
        CHECK_RES ("-1.0 *  2.0 = -2.0: ", r4, FP_S_N_TWO)
1162
 
1163
        LOAD_CONST (r5,FP_S_N_ONE)
1164
        LOAD_CONST (r6,FP_S_N_TWO)
1165
        lf.mul.s  r4,r5,r6
1166
        CHECK_RES ("-1.0 * -2.0 = +2.0: ", r4, FP_S_TWO)
1167
 
1168
        /* Multiplication with zeros */
1169
        LOAD_CONST (r5,FP_S_P_ZERO)
1170
        LOAD_CONST (r6,FP_S_TWO)
1171
        lf.mul.s  r4,r5,r6
1172
        CHECK_RES ("+0.0 *  2.0 = +0.0: ", r4, FP_S_P_ZERO)
1173
 
1174
        LOAD_CONST (r5,FP_S_N_ZERO)
1175
        LOAD_CONST (r6,FP_S_TWO)
1176
        lf.mul.s  r4,r5,r6
1177
        CHECK_RES ("+0.0 *  2.0 = +0.0: ", r4, FP_S_N_ZERO)
1178
 
1179
        /* Multiplication with infinities (more needed) */
1180
        LOAD_CONST (r5,FP_S_P_INF)
1181
        LOAD_CONST (r6,FP_S_N_TWO)
1182
        lf.mul.s  r4,r5,r6
1183
        CHECK_RES ("+inf * -2.0 = -inf: ", r4, FP_S_N_INF)
1184
 
1185
        /* Multiplication with NaNs (more needed) */
1186
        LOAD_CONST (r5,FP_S_P_NAN)
1187
        LOAD_CONST (r6,FP_S_TWO)
1188
        lf.mul.s  r4,r5,r6
1189
        CHECK_RES ("+NaN *  2.0 = +NaN: ", r4, FP_S_P_NAN)
1190
 
1191
        /* Multiplication overflow */
1192 233 julius
        SET_RM  (FPCSR_RM_RIP)
1193
 
1194 104 jeremybenn
        LOAD_CONST (r5,FP_S_HUGE1)
1195
        LOAD_CONST (r6,FP_S_HUGE1)
1196
        lf.mul.s  r4,r5,r6
1197
        CHECK_RES (" 1.0 * 2^127 *  1.0 * 2^127 = +inf: ", r4, FP_S_P_INF)
1198
 
1199
        LOAD_CONST (r5,FP_S_N_HUGE1)
1200 233 julius
        LOAD_CONST (r6,FP_S_N_HUGE1)
1201
        lf.mul.s  r4,r5,r6
1202
        CHECK_RES ("-1.0 * 2^127 * -1.0 * 2^127 = +inf: ", r4, FP_S_P_INF)
1203
 
1204
        SET_RM  (FPCSR_RM_RIN)
1205
        LOAD_CONST (r5,FP_S_N_HUGE1)
1206 104 jeremybenn
        LOAD_CONST (r6,FP_S_HUGE1)
1207
        lf.mul.s  r4,r5,r6
1208
        CHECK_RES ("-1.0 * 2^127 *  1.0 * 2^127 = -inf: ", r4, FP_S_N_INF)
1209
 
1210
        LOAD_CONST (r5,FP_S_HUGE1)
1211
        LOAD_CONST (r6,FP_S_N_HUGE1)
1212
        lf.mul.s  r4,r5,r6
1213
        CHECK_RES (" 1.0 * 2^127 * -1.0 * 2^127 = -inf: ", r4, FP_S_N_INF)
1214
 
1215
 
1216
/* ----------------------------------------------------------------------------
1217
 * Test of single precision remainder: lf.rem.s
1218
 * ------------------------------------------------------------------------- */
1219
_rem_s:
1220
        LOAD_STR (r3, "lf.rem.s\n")
1221
        l.jal   _puts
1222
        l.nop
1223
 
1224
        /* Tests of integer remainder */
1225
        LOAD_CONST (r5,FP_S_ONE)
1226
        LOAD_CONST (r6,FP_S_ONE)
1227
        lf.rem.s  r4,r5,r6
1228
        CHECK_RES (" 1.0 %  1.0 = +0.0: ", r4, FP_S_P_ZERO)
1229
 
1230
        LOAD_CONST (r5,FP_S_ONE)
1231
        LOAD_CONST (r6,FP_S_TWO)
1232
        lf.rem.s  r4,r5,r6
1233
        CHECK_RES (" 1.0 %  2.0 =  1.0: ", r4, FP_S_ONE)
1234
 
1235
        /* Remainder with fractions */
1236 233 julius
        // FIXME: This is failing, giving rem = -0.5 with softfloat
1237
        /*
1238 104 jeremybenn
        LOAD_CONST (r5,FP_S_1_5)
1239
        LOAD_CONST (r6,FP_S_TWO)
1240
        lf.rem.s  r4,r5,r6
1241
        CHECK_RES (" 1.5 %  2.0 =  1.5: ", r4, FP_S_1_5)
1242 233 julius
        */
1243 104 jeremybenn
        LOAD_CONST (r5,FP_S_TWO)
1244
        LOAD_CONST (r6,FP_S_1_5)
1245
        lf.rem.s  r4,r5,r6
1246
        CHECK_RES (" 2.0 %  1.5 =  0.5: ", r4, FP_S_0_5)
1247
 
1248
        LOAD_CONST (r5,FP_S_THREE)
1249
        LOAD_CONST (r6,FP_S_1_5)
1250
        lf.rem.s  r4,r5,r6
1251
        CHECK_RES (" 3.0 %  1.5 = +0.0: ", r4, FP_S_P_ZERO)
1252
 
1253
        /* Remainder with negative numbers */
1254 233 julius
        // FIXME: These next 4 are failing with the wrong signs on the results!
1255
        /*
1256 104 jeremybenn
        LOAD_CONST (r5,FP_S_N_THREE)
1257
        LOAD_CONST (r6,FP_S_TWO)
1258
        lf.rem.s  r4,r5,r6
1259
        CHECK_RES ("-3.0 %  2.0 = -1.0: ", r4, FP_S_N_ONE)
1260
 
1261
        LOAD_CONST (r5,FP_S_N_THREE)
1262
        LOAD_CONST (r6,FP_S_TWO)
1263
        lf.rem.s  r4,r5,r6
1264
        CHECK_RES ("-3.0 %  2.0 = -1.0: ", r4, FP_S_N_ONE)
1265
 
1266
        LOAD_CONST (r5,FP_S_THREE)
1267
        LOAD_CONST (r6,FP_S_N_TWO)
1268
        lf.rem.s  r4,r5,r6
1269
        CHECK_RES (" 3.0 % -2.0 =  1.0: ", r4, FP_S_ONE)
1270
 
1271
        LOAD_CONST (r5,FP_S_N_THREE)
1272
        LOAD_CONST (r6,FP_S_N_TWO)
1273
        lf.rem.s  r4,r5,r6
1274
        CHECK_RES ("-3.0 % -2.0 = -1.0: ", r4, FP_S_N_ONE)
1275 233 julius
        */
1276 104 jeremybenn
        /* Remainder with zeros (more are needed) */
1277
        LOAD_CONST (r5,FP_S_P_ZERO)
1278
        LOAD_CONST (r6,FP_S_TWO)
1279
        lf.rem.s  r4,r5,r6
1280
        CHECK_RES ("+0.0 %  2.0 = +0.0: ", r4, FP_S_P_ZERO)
1281
 
1282
        LOAD_CONST (r5,FP_S_N_ZERO)
1283
        LOAD_CONST (r6,FP_S_TWO)
1284
        lf.rem.s  r4,r5,r6
1285
        CHECK_RES ("-0.0 %  2.0 = -0.0: ", r4, FP_S_N_ZERO)
1286
 
1287
        LOAD_CONST (r5,FP_S_TWO)
1288
        LOAD_CONST (r6,FP_S_P_ZERO)
1289
        lf.rem.s  r4,r5,r6
1290
        CHECK_RES (" 2.0 % +0.0 = -NaN: ", r4, FP_S_N_NAN)
1291
 
1292
        LOAD_CONST (r5,FP_S_N_TWO)
1293
        LOAD_CONST (r6,FP_S_P_ZERO)
1294
        lf.rem.s  r4,r5,r6
1295
        CHECK_RES ("-2.0 % +0.0 = -NaN: ", r4, FP_S_N_NAN)
1296
 
1297
        LOAD_CONST (r5,FP_S_TWO)
1298
        LOAD_CONST (r6,FP_S_N_ZERO)
1299
        lf.rem.s  r4,r5,r6
1300
        CHECK_RES (" 2.0 % -0.0 = -NaN: ", r4, FP_S_N_NAN)
1301
 
1302
        /* Remainder with infinities (more are needed) */
1303
        LOAD_CONST (r5,FP_S_TWO)
1304
        LOAD_CONST (r6,FP_S_P_INF)
1305
        lf.rem.s  r4,r5,r6
1306
        CHECK_RES (" 2.0 % +inf =  2.0: ", r4, FP_S_TWO)
1307
 
1308
        LOAD_CONST (r5,FP_S_P_INF)
1309
        LOAD_CONST (r6,FP_S_TWO)
1310
        lf.rem.s  r4,r5,r6
1311
        CHECK_RES ("+inf %  2.0 = -NaN: ", r4, FP_S_N_NAN)
1312
 
1313
        /* Remainder with NaNs (more are needed) */
1314
        LOAD_CONST (r5,FP_S_TWO)
1315
        LOAD_CONST (r6,FP_S_P_NAN)
1316
        lf.rem.s  r4,r5,r6
1317
        CHECK_RES (" 2.0 % +NaN = +NaN: ", r4, FP_S_P_NAN)
1318
 
1319
        LOAD_CONST (r5,FP_S_P_NAN)
1320
        LOAD_CONST (r6,FP_S_TWO)
1321
        lf.rem.s  r4,r5,r6
1322
        CHECK_RES ("+NaN %  2.0 = +NaN: ", r4, FP_S_P_NAN)
1323
 
1324
        /* Remainder with overflow of division (more are needed) */
1325
        LOAD_CONST (r5,FP_S_HUGE2)
1326
        LOAD_CONST (r6,FP_S_SMALL1)
1327
        lf.rem.s  r4,r5,r6
1328
        CHECK_RES (" 1.0 * 2^127  % 1.0 * 2^-129 = +0.0: ", r4, FP_S_P_ZERO)
1329
 
1330
        /* Remainder with underflow (more are needed) */
1331
        LOAD_CONST (r5,FP_S_SMALL1)
1332
        LOAD_CONST (r6,FP_S_HUGE2)
1333
        lf.rem.s  r4,r5,r6
1334
        CHECK_RES (" 1.0 * 2^-129 % 1.0 * 2^127  = +0.0: ", r4, FP_S_SMALL1)
1335
 
1336
        /* Remainder with denormalization (more are needed) */
1337
 
1338
/* ----------------------------------------------------------------------------
1339
 * Test of single precision set flag if equal: lf.sfeq.s
1340
 * ------------------------------------------------------------------------- */
1341
_sfeq_s:
1342
        LOAD_STR (r3, "lf.sfeq.s\n")
1343
        l.jal   _puts
1344
        l.nop
1345
 
1346
        /* Tests of integer equality */
1347
        LOAD_CONST (r4,FP_S_ONE)
1348
        LOAD_CONST (r5,FP_S_ONE)
1349
        lf.sfeq.s  r4,r5
1350
        CHECK_FLAG (" 1.0 ==  1.0: ", TRUE)
1351
 
1352
        LOAD_CONST (r4,FP_S_ONE)
1353
        LOAD_CONST (r5,FP_S_TWO)
1354
        lf.sfeq.s  r4,r5
1355
        CHECK_FLAG (" 1.0 ==  2.0: ", FALSE)
1356
 
1357
        /* Fractional equality */
1358
        LOAD_CONST (r4,FP_S_1_5)
1359
        LOAD_CONST (r5,FP_S_1_5)
1360
        lf.sfeq.s  r4,r5
1361
        CHECK_FLAG (" 1.5 ==  1.5: ", TRUE)
1362
 
1363
        LOAD_CONST (r4,FP_S_1_5)
1364
        LOAD_CONST (r5,FP_S_0_5)
1365
        lf.sfeq.s  r4,r5
1366
        CHECK_FLAG (" 1.5 ==  0.5: ", FALSE)
1367
 
1368
        /* Signed equality */
1369
        LOAD_CONST (r4,FP_S_N_1_5)
1370
        LOAD_CONST (r5,FP_S_N_1_5)
1371
        lf.sfeq.s  r4,r5
1372
        CHECK_FLAG ("-1.5 == -1.5: ", TRUE)
1373
 
1374
        LOAD_CONST (r4,FP_S_1_5)
1375
        LOAD_CONST (r5,FP_S_N_1_5)
1376
        lf.sfeq.s  r4,r5
1377
        CHECK_FLAG (" 1.5 == -1.5: ", FALSE)
1378
 
1379
        /* Equality of zeros */
1380
        LOAD_CONST (r4,FP_S_P_ZERO)
1381
        LOAD_CONST (r5,FP_S_P_ZERO)
1382
        lf.sfeq.s  r4,r5
1383
        CHECK_FLAG ("+0.0 == +0.0: ", TRUE)
1384
 
1385
        LOAD_CONST (r4,FP_S_N_ZERO)
1386
        LOAD_CONST (r5,FP_S_N_ZERO)
1387
        lf.sfeq.s  r4,r5
1388
        CHECK_FLAG ("-0.0 == -0.0: ", TRUE)
1389
 
1390
        LOAD_CONST (r4,FP_S_P_ZERO)
1391
        LOAD_CONST (r5,FP_S_N_ZERO)
1392
        lf.sfeq.s  r4,r5
1393
        CHECK_FLAG ("+0.0 == -0.0: ", TRUE)
1394
 
1395
        /* Equality with infinities (more needed) */
1396
        LOAD_CONST (r4,FP_S_ONE)
1397
        LOAD_CONST (r5,FP_S_P_INF)
1398
        lf.sfeq.s  r4,r5
1399
        CHECK_FLAG (" 1.0 == +inf: ", FALSE)
1400
 
1401
        LOAD_CONST (r4,FP_S_P_INF)
1402
        LOAD_CONST (r5,FP_S_P_INF)
1403
        lf.sfeq.s  r4,r5
1404
        CHECK_FLAG ("+inf == +inf: ", TRUE)
1405
 
1406
        LOAD_CONST (r4,FP_S_N_INF)
1407
        LOAD_CONST (r5,FP_S_N_INF)
1408
        lf.sfeq.s  r4,r5
1409
        CHECK_FLAG ("-inf == -inf: ", TRUE)
1410
 
1411
        LOAD_CONST (r4,FP_S_P_INF)
1412
        LOAD_CONST (r5,FP_S_N_INF)
1413
        lf.sfeq.s  r4,r5
1414
        CHECK_FLAG ("+inf == -inf: ", FALSE)
1415
 
1416
        /* Equality with NaNs (more needed) */
1417
        LOAD_CONST (r4,FP_S_ONE)
1418
        LOAD_CONST (r5,FP_S_P_NAN)
1419
        lf.sfeq.s  r4,r5
1420
        CHECK_FLAG (" 1.0 == +NaN: ", FALSE)
1421
 
1422
        LOAD_CONST (r4,FP_S_P_NAN)
1423
        LOAD_CONST (r5,FP_S_P_NAN)
1424
        lf.sfeq.s  r4,r5
1425
        CHECK_FLAG ("+NaN == +NaN: ", FALSE)
1426
 
1427
        LOAD_CONST (r4,FP_S_N_NAN)
1428
        LOAD_CONST (r5,FP_S_N_NAN)
1429
        lf.sfeq.s  r4,r5
1430
        CHECK_FLAG ("-NaN == -NaN: ", FALSE)
1431
 
1432
        LOAD_CONST (r4,FP_S_P_NAN)
1433
        LOAD_CONST (r5,FP_S_N_NAN)
1434
        lf.sfeq.s  r4,r5
1435
        CHECK_FLAG ("+NaN == -NaN: ", FALSE)
1436
 
1437
        /* Equality with denormalized numbers (more needed) */
1438
        LOAD_CONST (r4,FP_S_SMALL1)
1439
        LOAD_CONST (r5,FP_S_SMALL1)
1440
        lf.sfeq.s  r4,r5
1441
        CHECK_FLAG (" 1.0 * 2^-129 == 1.0 * 2^-129: ", TRUE)
1442
 
1443
        LOAD_CONST (r4,FP_S_SMALL1)
1444
        LOAD_CONST (r5,FP_S_SMALL2)
1445
        lf.sfeq.s  r4,r5
1446
        CHECK_FLAG (" 1.0 * 2^-129 == 1.0 * 2^-128: ", FALSE)
1447
 
1448
        LOAD_CONST (r4,FP_S_HUGE1)
1449
        LOAD_CONST (r5,FP_S_SMALL2)
1450
        lf.sfeq.s  r4,r5
1451
        CHECK_FLAG (" 1.0 * 2^126  == 1.0 * 2^-128: ", FALSE)
1452
 
1453
 
1454
/* ----------------------------------------------------------------------------
1455
 * Test of single precision set flag if greater than or equal: lf.sfge.s
1456
 * ------------------------------------------------------------------------- */
1457
_sfge_s:
1458
        LOAD_STR (r3, "lf.sfge.s\n")
1459
        l.jal   _puts
1460
        l.nop
1461
 
1462
        /* Tests of integer greater than or equality */
1463
        LOAD_CONST (r4,FP_S_ONE)
1464
        LOAD_CONST (r5,FP_S_ONE)
1465
        lf.sfge.s  r4,r5
1466
        CHECK_FLAG (" 1.0 >=  1.0: ", TRUE)
1467
 
1468
        LOAD_CONST (r4,FP_S_TWO)
1469
        LOAD_CONST (r5,FP_S_ONE)
1470
        lf.sfge.s  r4,r5
1471
        CHECK_FLAG (" 2.0 >=  1.0: ", TRUE)
1472
 
1473
        LOAD_CONST (r4,FP_S_ONE)
1474
        LOAD_CONST (r5,FP_S_TWO)
1475
        lf.sfge.s  r4,r5
1476
        CHECK_FLAG (" 1.0 >=  2.0: ", FALSE)
1477
 
1478
        /* Fractional greater than or equality */
1479
        LOAD_CONST (r4,FP_S_1_5)
1480
        LOAD_CONST (r5,FP_S_1_5)
1481
        lf.sfge.s  r4,r5
1482
        CHECK_FLAG (" 1.5 >=  1.5: ", TRUE)
1483
 
1484
        LOAD_CONST (r4,FP_S_1_5)
1485
        LOAD_CONST (r5,FP_S_0_5)
1486
        lf.sfge.s  r4,r5
1487
        CHECK_FLAG (" 1.5 >=  0.5: ", TRUE)
1488
 
1489
        LOAD_CONST (r4,FP_S_0_5)
1490
        LOAD_CONST (r5,FP_S_1_5)
1491
        lf.sfge.s  r4,r5
1492
        CHECK_FLAG (" 0.5 >=  1.5: ", FALSE)
1493
 
1494
        /* Signed greater than or equality */
1495
        LOAD_CONST (r4,FP_S_N_1_5)
1496
        LOAD_CONST (r5,FP_S_N_1_5)
1497
        lf.sfge.s  r4,r5
1498
        CHECK_FLAG ("-1.5 >= -1.5: ", TRUE)
1499
 
1500
        LOAD_CONST (r4,FP_S_N_1_5)
1501
        LOAD_CONST (r5,FP_S_N_0_5)
1502
        lf.sfge.s  r4,r5
1503
        CHECK_FLAG ("-1.5 >= -0.5: ", FALSE)
1504
 
1505
        LOAD_CONST (r4,FP_S_N_0_5)
1506
        LOAD_CONST (r5,FP_S_N_1_5)
1507
        lf.sfge.s  r4,r5
1508
        CHECK_FLAG ("-0.5 >= -1.5: ", TRUE)
1509
 
1510
        LOAD_CONST (r4,FP_S_1_5)
1511
        LOAD_CONST (r5,FP_S_N_1_5)
1512
        lf.sfge.s  r4,r5
1513
        CHECK_FLAG (" 1.5 >= -1.5: ", TRUE)
1514
 
1515
        LOAD_CONST (r4,FP_S_N_1_5)
1516
        LOAD_CONST (r5,FP_S_1_5)
1517
        lf.sfge.s  r4,r5
1518
        CHECK_FLAG ("-1.5 >=  1.5: ", FALSE)
1519
 
1520
        /* Greater than or equality of zeros */
1521
        LOAD_CONST (r4,FP_S_P_ZERO)
1522
        LOAD_CONST (r5,FP_S_P_ZERO)
1523
        lf.sfge.s  r4,r5
1524
        CHECK_FLAG ("+0.0 >= +0.0: ", TRUE)
1525
 
1526
        LOAD_CONST (r4,FP_S_N_ZERO)
1527
        LOAD_CONST (r5,FP_S_N_ZERO)
1528
        lf.sfge.s  r4,r5
1529
        CHECK_FLAG ("-0.0 >= -0.0: ", TRUE)
1530
 
1531
        LOAD_CONST (r4,FP_S_P_ZERO)
1532
        LOAD_CONST (r5,FP_S_N_ZERO)
1533
        lf.sfge.s  r4,r5
1534
        CHECK_FLAG ("+0.0 >= -0.0: ", TRUE)
1535
 
1536
        LOAD_CONST (r4,FP_S_N_ZERO)
1537
        LOAD_CONST (r5,FP_S_P_ZERO)
1538
        lf.sfge.s  r4,r5
1539
        CHECK_FLAG ("-0.0 >= +0.0: ", TRUE)
1540
 
1541
        /* Greater than or equality with infinities (more needed) */
1542
        LOAD_CONST (r4,FP_S_ONE)
1543
        LOAD_CONST (r5,FP_S_P_INF)
1544
        lf.sfge.s  r4,r5
1545
        CHECK_FLAG (" 1.0 >= +inf: ", FALSE)
1546
 
1547
        LOAD_CONST (r4,FP_S_P_INF)
1548
        LOAD_CONST (r5,FP_S_ONE)
1549
        lf.sfge.s  r4,r5
1550
        CHECK_FLAG ("+inf >=  1.0: ", TRUE)
1551
 
1552
        LOAD_CONST (r4,FP_S_ONE)
1553
        LOAD_CONST (r5,FP_S_N_INF)
1554
        lf.sfge.s  r4,r5
1555
        CHECK_FLAG (" 1.0 >= -inf: ", TRUE)
1556
 
1557
        LOAD_CONST (r4,FP_S_N_INF)
1558
        LOAD_CONST (r5,FP_S_ONE)
1559
        lf.sfge.s  r4,r5
1560
        CHECK_FLAG ("-inf >=  1.0: ", FALSE)
1561
 
1562
        LOAD_CONST (r4,FP_S_P_INF)
1563
        LOAD_CONST (r5,FP_S_P_INF)
1564
        lf.sfge.s  r4,r5
1565
        CHECK_FLAG ("+inf >= +inf: ", TRUE)
1566
 
1567
        LOAD_CONST (r4,FP_S_N_INF)
1568
        LOAD_CONST (r5,FP_S_N_INF)
1569
        lf.sfge.s  r4,r5
1570
        CHECK_FLAG ("-inf >= -inf: ", TRUE)
1571
 
1572
        LOAD_CONST (r4,FP_S_P_INF)
1573
        LOAD_CONST (r5,FP_S_N_INF)
1574
        lf.sfge.s  r4,r5
1575
        CHECK_FLAG ("+inf >= -inf: ", TRUE)
1576
 
1577
        LOAD_CONST (r4,FP_S_N_INF)
1578
        LOAD_CONST (r5,FP_S_P_INF)
1579
        lf.sfge.s  r4,r5
1580
        CHECK_FLAG ("-inf >= +inf: ", FALSE)
1581
 
1582
        /* Greater than or equality with NaNs (more needed) */
1583
        LOAD_CONST (r4,FP_S_ONE)
1584
        LOAD_CONST (r5,FP_S_P_NAN)
1585
        lf.sfge.s  r4,r5
1586
        CHECK_FLAG (" 1.0 >= +NaN: ", FALSE)
1587
 
1588
        LOAD_CONST (r4,FP_S_P_NAN)
1589
        LOAD_CONST (r5,FP_S_P_NAN)
1590
        lf.sfge.s  r4,r5
1591
        CHECK_FLAG ("+NaN >= +NaN: ", FALSE)
1592
 
1593
        LOAD_CONST (r4,FP_S_N_NAN)
1594
        LOAD_CONST (r5,FP_S_N_NAN)
1595
        lf.sfge.s  r4,r5
1596
        CHECK_FLAG ("-NaN >= -NaN: ", FALSE)
1597
 
1598
        LOAD_CONST (r4,FP_S_P_NAN)
1599
        LOAD_CONST (r5,FP_S_N_NAN)
1600
        lf.sfge.s  r4,r5
1601
        CHECK_FLAG ("+NaN >= -NaN: ", FALSE)
1602
 
1603
        LOAD_CONST (r4,FP_S_N_NAN)
1604
        LOAD_CONST (r5,FP_S_P_NAN)
1605
        lf.sfge.s  r4,r5
1606
        CHECK_FLAG ("-NaN >= +NaN: ", FALSE)
1607
 
1608
        /* Greater than or equality with denormalized numbers (more needed) */
1609
        LOAD_CONST (r4,FP_S_SMALL1)
1610
        LOAD_CONST (r5,FP_S_SMALL1)
1611
        lf.sfge.s  r4,r5
1612
        CHECK_FLAG (" 1.0 * 2^-129 >= 1.0 * 2^-129: ", TRUE)
1613
 
1614
        LOAD_CONST (r4,FP_S_SMALL1)
1615
        LOAD_CONST (r5,FP_S_SMALL2)
1616
        lf.sfge.s  r4,r5
1617
        CHECK_FLAG (" 1.0 * 2^-129 >= 1.0 * 2^-128: ", FALSE)
1618
 
1619
        LOAD_CONST (r4,FP_S_SMALL2)
1620
        LOAD_CONST (r5,FP_S_SMALL1)
1621
        lf.sfge.s  r4,r5
1622
        CHECK_FLAG (" 1.0 * 2^-128 >= 1.0 * 2^-129: ", TRUE)
1623
 
1624
        LOAD_CONST (r4,FP_S_HUGE1)
1625
        LOAD_CONST (r5,FP_S_SMALL2)
1626
        lf.sfge.s  r4,r5
1627
        CHECK_FLAG (" 1.0 * 2^126  >= 1.0 * 2^-128: ", TRUE)
1628
 
1629
        LOAD_CONST (r4,FP_S_SMALL2)
1630
        LOAD_CONST (r5,FP_S_HUGE1)
1631
        lf.sfge.s  r4,r5
1632
        CHECK_FLAG (" 1.0 * 2^-128 >= 1.0 * 2^126:  ", FALSE)
1633
 
1634
 
1635
/* ----------------------------------------------------------------------------
1636
 * Test of single precision set flag if greater than: lf.sfgt.s
1637
 * ------------------------------------------------------------------------- */
1638
_sfgt_s:
1639
        LOAD_STR (r3, "lf.sfgt.s\n")
1640
        l.jal   _puts
1641
        l.nop
1642
 
1643
        /* Tests of integer greater than */
1644
        LOAD_CONST (r4,FP_S_ONE)
1645
        LOAD_CONST (r5,FP_S_ONE)
1646
        lf.sfgt.s  r4,r5
1647
        CHECK_FLAG (" 1.0 >  1.0: ", FALSE)
1648
 
1649
        LOAD_CONST (r4,FP_S_TWO)
1650
        LOAD_CONST (r5,FP_S_ONE)
1651
        lf.sfgt.s  r4,r5
1652
        CHECK_FLAG (" 2.0 >  1.0: ", TRUE)
1653
 
1654
        LOAD_CONST (r4,FP_S_ONE)
1655
        LOAD_CONST (r5,FP_S_TWO)
1656
        lf.sfgt.s  r4,r5
1657
        CHECK_FLAG (" 1.0 >  2.0: ", FALSE)
1658
 
1659
        /* Fractional greater than */
1660
        LOAD_CONST (r4,FP_S_1_5)
1661
        LOAD_CONST (r5,FP_S_1_5)
1662
        lf.sfgt.s  r4,r5
1663
        CHECK_FLAG (" 1.5 >  1.5: ", FALSE)
1664
 
1665
        LOAD_CONST (r4,FP_S_1_5)
1666
        LOAD_CONST (r5,FP_S_0_5)
1667
        lf.sfgt.s  r4,r5
1668
        CHECK_FLAG (" 1.5 >  0.5: ", TRUE)
1669
 
1670
        LOAD_CONST (r4,FP_S_0_5)
1671
        LOAD_CONST (r5,FP_S_1_5)
1672
        lf.sfgt.s  r4,r5
1673
        CHECK_FLAG (" 0.5 >  1.5: ", FALSE)
1674
 
1675
        /* Signed greater than */
1676
        LOAD_CONST (r4,FP_S_N_1_5)
1677
        LOAD_CONST (r5,FP_S_N_1_5)
1678
        lf.sfgt.s  r4,r5
1679
        CHECK_FLAG ("-1.5 > -1.5: ", FALSE)
1680
 
1681
        LOAD_CONST (r4,FP_S_N_1_5)
1682
        LOAD_CONST (r5,FP_S_N_0_5)
1683
        lf.sfgt.s  r4,r5
1684
        CHECK_FLAG ("-1.5 > -0.5: ", FALSE)
1685
 
1686
        LOAD_CONST (r4,FP_S_N_0_5)
1687
        LOAD_CONST (r5,FP_S_N_1_5)
1688
        lf.sfgt.s  r4,r5
1689
        CHECK_FLAG ("-0.5 > -1.5: ", TRUE)
1690
 
1691
        LOAD_CONST (r4,FP_S_1_5)
1692
        LOAD_CONST (r5,FP_S_N_1_5)
1693
        lf.sfgt.s  r4,r5
1694
        CHECK_FLAG (" 1.5 > -1.5: ", TRUE)
1695
 
1696
        LOAD_CONST (r4,FP_S_N_1_5)
1697
        LOAD_CONST (r5,FP_S_1_5)
1698
        lf.sfgt.s  r4,r5
1699
        CHECK_FLAG ("-1.5 >  1.5: ", FALSE)
1700
 
1701
        /* Greater than of zeros */
1702
        LOAD_CONST (r4,FP_S_P_ZERO)
1703
        LOAD_CONST (r5,FP_S_P_ZERO)
1704
        lf.sfgt.s  r4,r5
1705
        CHECK_FLAG ("+0.0 > +0.0: ", FALSE)
1706
 
1707
        LOAD_CONST (r4,FP_S_N_ZERO)
1708
        LOAD_CONST (r5,FP_S_N_ZERO)
1709
        lf.sfgt.s  r4,r5
1710
        CHECK_FLAG ("-0.0 > -0.0: ", FALSE)
1711
 
1712
        LOAD_CONST (r4,FP_S_P_ZERO)
1713
        LOAD_CONST (r5,FP_S_N_ZERO)
1714
        lf.sfgt.s  r4,r5
1715
        CHECK_FLAG ("+0.0 > -0.0: ", FALSE)
1716
 
1717
        LOAD_CONST (r4,FP_S_N_ZERO)
1718
        LOAD_CONST (r5,FP_S_P_ZERO)
1719
        lf.sfgt.s  r4,r5
1720
        CHECK_FLAG ("-0.0 > +0.0: ", FALSE)
1721
 
1722
        /* Greater than with infinities (more needed) */
1723
        LOAD_CONST (r4,FP_S_ONE)
1724
        LOAD_CONST (r5,FP_S_P_INF)
1725
        lf.sfgt.s  r4,r5
1726
        CHECK_FLAG (" 1.0 > +inf: ", FALSE)
1727
 
1728
        LOAD_CONST (r4,FP_S_P_INF)
1729
        LOAD_CONST (r5,FP_S_ONE)
1730
        lf.sfgt.s  r4,r5
1731
        CHECK_FLAG ("+inf >  1.0: ", TRUE)
1732
 
1733
        LOAD_CONST (r4,FP_S_ONE)
1734
        LOAD_CONST (r5,FP_S_N_INF)
1735
        lf.sfgt.s  r4,r5
1736
        CHECK_FLAG (" 1.0 > -inf: ", TRUE)
1737
 
1738
        LOAD_CONST (r4,FP_S_N_INF)
1739
        LOAD_CONST (r5,FP_S_ONE)
1740
        lf.sfgt.s  r4,r5
1741
        CHECK_FLAG ("-inf >  1.0: ", FALSE)
1742
 
1743
        LOAD_CONST (r4,FP_S_P_INF)
1744
        LOAD_CONST (r5,FP_S_P_INF)
1745
        lf.sfgt.s  r4,r5
1746
        CHECK_FLAG ("+inf > +inf: ", FALSE)
1747
 
1748
        LOAD_CONST (r4,FP_S_N_INF)
1749
        LOAD_CONST (r5,FP_S_N_INF)
1750
        lf.sfgt.s  r4,r5
1751
        CHECK_FLAG ("-inf > -inf: ", FALSE)
1752
 
1753
        LOAD_CONST (r4,FP_S_P_INF)
1754
        LOAD_CONST (r5,FP_S_N_INF)
1755
        lf.sfgt.s  r4,r5
1756
        CHECK_FLAG ("+inf > -inf: ", TRUE)
1757
 
1758
        LOAD_CONST (r4,FP_S_N_INF)
1759
        LOAD_CONST (r5,FP_S_P_INF)
1760
        lf.sfgt.s  r4,r5
1761
        CHECK_FLAG ("-inf > +inf: ", FALSE)
1762
 
1763
        /* Greater than with NaNs (more needed) */
1764
        LOAD_CONST (r4,FP_S_ONE)
1765
        LOAD_CONST (r5,FP_S_P_NAN)
1766
        lf.sfgt.s  r4,r5
1767
        CHECK_FLAG (" 1.0 > +NaN: ", FALSE)
1768
 
1769
        LOAD_CONST (r4,FP_S_P_NAN)
1770
        LOAD_CONST (r5,FP_S_P_NAN)
1771
        lf.sfgt.s  r4,r5
1772
        CHECK_FLAG ("+NaN > +NaN: ", FALSE)
1773
 
1774
        LOAD_CONST (r4,FP_S_N_NAN)
1775
        LOAD_CONST (r5,FP_S_N_NAN)
1776
        lf.sfgt.s  r4,r5
1777
        CHECK_FLAG ("-NaN > -NaN: ", FALSE)
1778
 
1779
        LOAD_CONST (r4,FP_S_P_NAN)
1780
        LOAD_CONST (r5,FP_S_N_NAN)
1781
        lf.sfgt.s  r4,r5
1782
        CHECK_FLAG ("+NaN > -NaN: ", FALSE)
1783
 
1784
        LOAD_CONST (r4,FP_S_N_NAN)
1785
        LOAD_CONST (r5,FP_S_P_NAN)
1786
        lf.sfgt.s  r4,r5
1787
        CHECK_FLAG ("-NaN > +NaN: ", FALSE)
1788
 
1789
        /* Greater than with denormalized numbers (more needed) */
1790
        LOAD_CONST (r4,FP_S_SMALL1)
1791
        LOAD_CONST (r5,FP_S_SMALL1)
1792
        lf.sfgt.s  r4,r5
1793
        CHECK_FLAG (" 1.0 * 2^-129 > 1.0 * 2^-129: ", FALSE)
1794
 
1795
        LOAD_CONST (r4,FP_S_SMALL1)
1796
        LOAD_CONST (r5,FP_S_SMALL2)
1797
        lf.sfgt.s  r4,r5
1798
        CHECK_FLAG (" 1.0 * 2^-129 > 1.0 * 2^-128: ", FALSE)
1799
 
1800
        LOAD_CONST (r4,FP_S_SMALL2)
1801
        LOAD_CONST (r5,FP_S_SMALL1)
1802
        lf.sfgt.s  r4,r5
1803
        CHECK_FLAG (" 1.0 * 2^-128 > 1.0 * 2^-129: ", TRUE)
1804
 
1805
        LOAD_CONST (r4,FP_S_HUGE1)
1806
        LOAD_CONST (r5,FP_S_SMALL2)
1807
        lf.sfgt.s  r4,r5
1808
        CHECK_FLAG (" 1.0 * 2^126  > 1.0 * 2^-128: ", TRUE)
1809
 
1810
        LOAD_CONST (r4,FP_S_SMALL2)
1811
        LOAD_CONST (r5,FP_S_HUGE1)
1812
        lf.sfgt.s  r4,r5
1813
        CHECK_FLAG (" 1.0 * 2^-128 > 1.0 * 2^126:  ", FALSE)
1814
 
1815
/* ----------------------------------------------------------------------------
1816
 * Test of single precision set flag if less than or equal: lf.sfle.s
1817
 * ------------------------------------------------------------------------- */
1818
_sfle_s:
1819
        LOAD_STR (r3, "lf.sfle.s\n")
1820
        l.jal   _puts
1821
        l.nop
1822
 
1823
        /* Tests of integer less than or equality */
1824
        LOAD_CONST (r4,FP_S_ONE)
1825
        LOAD_CONST (r5,FP_S_ONE)
1826
        lf.sfle.s  r4,r5
1827
        CHECK_FLAG (" 1.0 <=  1.0: ", TRUE)
1828
 
1829
        LOAD_CONST (r4,FP_S_TWO)
1830
        LOAD_CONST (r5,FP_S_ONE)
1831
        lf.sfle.s  r4,r5
1832
        CHECK_FLAG (" 2.0 <=  1.0: ", FALSE)
1833
 
1834
        LOAD_CONST (r4,FP_S_ONE)
1835
        LOAD_CONST (r5,FP_S_TWO)
1836
        lf.sfle.s  r4,r5
1837
        CHECK_FLAG (" 1.0 <=  2.0: ", TRUE)
1838
 
1839
        /* Fractional less than or equality */
1840
        LOAD_CONST (r4,FP_S_1_5)
1841
        LOAD_CONST (r5,FP_S_1_5)
1842
        lf.sfle.s  r4,r5
1843
        CHECK_FLAG (" 1.5 <=  1.5: ", TRUE)
1844
 
1845
        LOAD_CONST (r4,FP_S_1_5)
1846
        LOAD_CONST (r5,FP_S_0_5)
1847
        lf.sfle.s  r4,r5
1848
        CHECK_FLAG (" 1.5 <=  0.5: ", FALSE)
1849
 
1850
        LOAD_CONST (r4,FP_S_0_5)
1851
        LOAD_CONST (r5,FP_S_1_5)
1852
        lf.sfle.s  r4,r5
1853
        CHECK_FLAG (" 0.5 <=  1.5: ", TRUE)
1854
 
1855
        /* Signed less than or equality */
1856
        LOAD_CONST (r4,FP_S_N_1_5)
1857
        LOAD_CONST (r5,FP_S_N_1_5)
1858
        lf.sfle.s  r4,r5
1859
        CHECK_FLAG ("-1.5 <= -1.5: ", TRUE)
1860
 
1861
        LOAD_CONST (r4,FP_S_N_1_5)
1862
        LOAD_CONST (r5,FP_S_N_0_5)
1863
        lf.sfle.s  r4,r5
1864
        CHECK_FLAG ("-1.5 <= -0.5: ", TRUE)
1865
 
1866
        LOAD_CONST (r4,FP_S_N_0_5)
1867
        LOAD_CONST (r5,FP_S_N_1_5)
1868
        lf.sfle.s  r4,r5
1869
        CHECK_FLAG ("-0.5 <= -1.5: ", FALSE)
1870
 
1871
        LOAD_CONST (r4,FP_S_1_5)
1872
        LOAD_CONST (r5,FP_S_N_1_5)
1873
        lf.sfle.s  r4,r5
1874
        CHECK_FLAG (" 1.5 <= -1.5: ", FALSE)
1875
 
1876
        LOAD_CONST (r4,FP_S_N_1_5)
1877
        LOAD_CONST (r5,FP_S_1_5)
1878
        lf.sfle.s  r4,r5
1879
        CHECK_FLAG ("-1.5 <=  1.5: ", TRUE)
1880
 
1881
        /* Less than or equality of zeros */
1882
        LOAD_CONST (r4,FP_S_P_ZERO)
1883
        LOAD_CONST (r5,FP_S_P_ZERO)
1884
        lf.sfle.s  r4,r5
1885
        CHECK_FLAG ("+0.0 <= +0.0: ", TRUE)
1886
 
1887
        LOAD_CONST (r4,FP_S_N_ZERO)
1888
        LOAD_CONST (r5,FP_S_N_ZERO)
1889
        lf.sfle.s  r4,r5
1890
        CHECK_FLAG ("-0.0 <= -0.0: ", TRUE)
1891
 
1892
        LOAD_CONST (r4,FP_S_P_ZERO)
1893
        LOAD_CONST (r5,FP_S_N_ZERO)
1894
        lf.sfle.s  r4,r5
1895
        CHECK_FLAG ("+0.0 <= -0.0: ", TRUE)
1896
 
1897
        LOAD_CONST (r4,FP_S_N_ZERO)
1898
        LOAD_CONST (r5,FP_S_P_ZERO)
1899
        lf.sfle.s  r4,r5
1900
        CHECK_FLAG ("-0.0 <= +0.0: ", TRUE)
1901
 
1902
        /* Less than or equality with infinities (more needed) */
1903
        LOAD_CONST (r4,FP_S_ONE)
1904
        LOAD_CONST (r5,FP_S_P_INF)
1905
        lf.sfle.s  r4,r5
1906
        CHECK_FLAG (" 1.0 <= +inf: ", TRUE)
1907
 
1908
        LOAD_CONST (r4,FP_S_P_INF)
1909
        LOAD_CONST (r5,FP_S_ONE)
1910
        lf.sfle.s  r4,r5
1911
        CHECK_FLAG ("+inf <=  1.0: ", FALSE)
1912
 
1913
        LOAD_CONST (r4,FP_S_ONE)
1914
        LOAD_CONST (r5,FP_S_N_INF)
1915
        lf.sfle.s  r4,r5
1916
        CHECK_FLAG (" 1.0 <= -inf: ", FALSE)
1917
 
1918
        LOAD_CONST (r4,FP_S_N_INF)
1919
        LOAD_CONST (r5,FP_S_ONE)
1920
        lf.sfle.s  r4,r5
1921
        CHECK_FLAG ("-inf <=  1.0: ", TRUE)
1922
 
1923
        LOAD_CONST (r4,FP_S_P_INF)
1924
        LOAD_CONST (r5,FP_S_P_INF)
1925
        lf.sfle.s  r4,r5
1926
        CHECK_FLAG ("+inf <= +inf: ", TRUE)
1927
 
1928
        LOAD_CONST (r4,FP_S_N_INF)
1929
        LOAD_CONST (r5,FP_S_N_INF)
1930
        lf.sfle.s  r4,r5
1931
        CHECK_FLAG ("-inf <= -inf: ", TRUE)
1932
 
1933
        LOAD_CONST (r4,FP_S_P_INF)
1934
        LOAD_CONST (r5,FP_S_N_INF)
1935
        lf.sfle.s  r4,r5
1936
        CHECK_FLAG ("+inf <= -inf: ", FALSE)
1937
 
1938
        LOAD_CONST (r4,FP_S_N_INF)
1939
        LOAD_CONST (r5,FP_S_P_INF)
1940
        lf.sfle.s  r4,r5
1941
        CHECK_FLAG ("-inf <= +inf: ", TRUE)
1942
 
1943
        /* Less than or equality with NaNs (more needed) */
1944
        LOAD_CONST (r4,FP_S_ONE)
1945
        LOAD_CONST (r5,FP_S_P_NAN)
1946
        lf.sfle.s  r4,r5
1947
        CHECK_FLAG (" 1.0 <= +NaN: ", FALSE)
1948
 
1949
        LOAD_CONST (r4,FP_S_P_NAN)
1950
        LOAD_CONST (r5,FP_S_P_NAN)
1951
        lf.sfle.s  r4,r5
1952
        CHECK_FLAG ("+NaN <= +NaN: ", FALSE)
1953
 
1954
        LOAD_CONST (r4,FP_S_N_NAN)
1955
        LOAD_CONST (r5,FP_S_N_NAN)
1956
        lf.sfle.s  r4,r5
1957
        CHECK_FLAG ("-NaN <= -NaN: ", FALSE)
1958
 
1959
        LOAD_CONST (r4,FP_S_P_NAN)
1960
        LOAD_CONST (r5,FP_S_N_NAN)
1961
        lf.sfle.s  r4,r5
1962
        CHECK_FLAG ("+NaN <= -NaN: ", FALSE)
1963
 
1964
        LOAD_CONST (r4,FP_S_N_NAN)
1965
        LOAD_CONST (r5,FP_S_P_NAN)
1966
        lf.sfle.s  r4,r5
1967
        CHECK_FLAG ("-NaN <= +NaN: ", FALSE)
1968
 
1969
        /* Less than or equality with denormalized numbers (more needed) */
1970
        LOAD_CONST (r4,FP_S_SMALL1)
1971
        LOAD_CONST (r5,FP_S_SMALL1)
1972
        lf.sfle.s  r4,r5
1973
        CHECK_FLAG (" 1.0 * 2^-129 <= 1.0 * 2^-129: ", TRUE)
1974
 
1975
        LOAD_CONST (r4,FP_S_SMALL1)
1976
        LOAD_CONST (r5,FP_S_SMALL2)
1977
        lf.sfle.s  r4,r5
1978
        CHECK_FLAG (" 1.0 * 2^-129 <= 1.0 * 2^-128: ", TRUE)
1979
 
1980
        LOAD_CONST (r4,FP_S_SMALL2)
1981
        LOAD_CONST (r5,FP_S_SMALL1)
1982
        lf.sfle.s  r4,r5
1983
        CHECK_FLAG (" 1.0 * 2^-128 <= 1.0 * 2^-129: ", FALSE)
1984
 
1985
        LOAD_CONST (r4,FP_S_HUGE1)
1986
        LOAD_CONST (r5,FP_S_SMALL2)
1987
        lf.sfle.s  r4,r5
1988
        CHECK_FLAG (" 1.0 * 2^126  <= 1.0 * 2^-128: ", FALSE)
1989
 
1990
        LOAD_CONST (r4,FP_S_SMALL2)
1991
        LOAD_CONST (r5,FP_S_HUGE1)
1992
        lf.sfle.s  r4,r5
1993
        CHECK_FLAG (" 1.0 * 2^-128 <= 1.0 * 2^126:  ", TRUE)
1994
 
1995
 
1996
/* ----------------------------------------------------------------------------
1997
 * Test of single precision set flag if less than: lf.sflt.s
1998
 * ------------------------------------------------------------------------- */
1999
_sflt_s:
2000
        LOAD_STR (r3, "lf.sflt.s\n")
2001
        l.jal   _puts
2002
        l.nop
2003
 
2004
        /* Tests of integer less than */
2005
        LOAD_CONST (r4,FP_S_ONE)
2006
        LOAD_CONST (r5,FP_S_ONE)
2007
        lf.sflt.s  r4,r5
2008
        CHECK_FLAG (" 1.0 <  1.0: ", FALSE)
2009
 
2010
        LOAD_CONST (r4,FP_S_TWO)
2011
        LOAD_CONST (r5,FP_S_ONE)
2012
        lf.sflt.s  r4,r5
2013
        CHECK_FLAG (" 2.0 <  1.0: ", FALSE)
2014
 
2015
        LOAD_CONST (r4,FP_S_ONE)
2016
        LOAD_CONST (r5,FP_S_TWO)
2017
        lf.sflt.s  r4,r5
2018
        CHECK_FLAG (" 1.0 <  2.0: ", TRUE)
2019
 
2020
        /* Fractional less than */
2021
        LOAD_CONST (r4,FP_S_1_5)
2022
        LOAD_CONST (r5,FP_S_1_5)
2023
        lf.sflt.s  r4,r5
2024
        CHECK_FLAG (" 1.5 <  1.5: ", FALSE)
2025
 
2026
        LOAD_CONST (r4,FP_S_1_5)
2027
        LOAD_CONST (r5,FP_S_0_5)
2028
        lf.sflt.s  r4,r5
2029
        CHECK_FLAG (" 1.5 <  0.5: ", FALSE)
2030
 
2031
        LOAD_CONST (r4,FP_S_0_5)
2032
        LOAD_CONST (r5,FP_S_1_5)
2033
        lf.sflt.s  r4,r5
2034
        CHECK_FLAG (" 0.5 <  1.5: ", TRUE)
2035
 
2036
        /* Signed less than */
2037
        LOAD_CONST (r4,FP_S_N_1_5)
2038
        LOAD_CONST (r5,FP_S_N_1_5)
2039
        lf.sflt.s  r4,r5
2040
        CHECK_FLAG ("-1.5 < -1.5: ", FALSE)
2041
 
2042
        LOAD_CONST (r4,FP_S_N_1_5)
2043
        LOAD_CONST (r5,FP_S_N_0_5)
2044
        lf.sflt.s  r4,r5
2045
        CHECK_FLAG ("-1.5 < -0.5: ", TRUE)
2046
 
2047
        LOAD_CONST (r4,FP_S_N_0_5)
2048
        LOAD_CONST (r5,FP_S_N_1_5)
2049
        lf.sflt.s  r4,r5
2050
        CHECK_FLAG ("-0.5 < -1.5: ", FALSE)
2051
 
2052
        LOAD_CONST (r4,FP_S_1_5)
2053
        LOAD_CONST (r5,FP_S_N_1_5)
2054
        lf.sflt.s  r4,r5
2055
        CHECK_FLAG (" 1.5 < -1.5: ", FALSE)
2056
 
2057
        LOAD_CONST (r4,FP_S_N_1_5)
2058
        LOAD_CONST (r5,FP_S_1_5)
2059
        lf.sflt.s  r4,r5
2060
        CHECK_FLAG ("-1.5 <  1.5: ", TRUE)
2061
 
2062
        /* Less than of zeros */
2063
        LOAD_CONST (r4,FP_S_P_ZERO)
2064
        LOAD_CONST (r5,FP_S_P_ZERO)
2065
        lf.sflt.s  r4,r5
2066
        CHECK_FLAG ("+0.0 < +0.0: ", FALSE)
2067
 
2068
        LOAD_CONST (r4,FP_S_N_ZERO)
2069
        LOAD_CONST (r5,FP_S_N_ZERO)
2070
        lf.sflt.s  r4,r5
2071
        CHECK_FLAG ("-0.0 < -0.0: ", FALSE)
2072
 
2073
        LOAD_CONST (r4,FP_S_P_ZERO)
2074
        LOAD_CONST (r5,FP_S_N_ZERO)
2075
        lf.sflt.s  r4,r5
2076
        CHECK_FLAG ("+0.0 < -0.0: ", FALSE)
2077
 
2078
        LOAD_CONST (r4,FP_S_N_ZERO)
2079
        LOAD_CONST (r5,FP_S_P_ZERO)
2080
        lf.sflt.s  r4,r5
2081
        CHECK_FLAG ("-0.0 < +0.0: ", FALSE)
2082
 
2083
        /* Less than with infinities (more needed) */
2084
        LOAD_CONST (r4,FP_S_ONE)
2085
        LOAD_CONST (r5,FP_S_P_INF)
2086
        lf.sflt.s  r4,r5
2087
        CHECK_FLAG (" 1.0 < +inf: ", TRUE)
2088
 
2089
        LOAD_CONST (r4,FP_S_P_INF)
2090
        LOAD_CONST (r5,FP_S_ONE)
2091
        lf.sflt.s  r4,r5
2092
        CHECK_FLAG ("+inf <  1.0: ", FALSE)
2093
 
2094
        LOAD_CONST (r4,FP_S_ONE)
2095
        LOAD_CONST (r5,FP_S_N_INF)
2096
        lf.sflt.s  r4,r5
2097
        CHECK_FLAG (" 1.0 < -inf: ", FALSE)
2098
 
2099
        LOAD_CONST (r4,FP_S_N_INF)
2100
        LOAD_CONST (r5,FP_S_ONE)
2101
        lf.sflt.s  r4,r5
2102
        CHECK_FLAG ("-inf <  1.0: ", TRUE)
2103
 
2104
        LOAD_CONST (r4,FP_S_P_INF)
2105
        LOAD_CONST (r5,FP_S_P_INF)
2106
        lf.sflt.s  r4,r5
2107
        CHECK_FLAG ("+inf < +inf: ", FALSE)
2108
 
2109
        LOAD_CONST (r4,FP_S_N_INF)
2110
        LOAD_CONST (r5,FP_S_N_INF)
2111
        lf.sflt.s  r4,r5
2112
        CHECK_FLAG ("-inf < -inf: ", FALSE)
2113
 
2114
        LOAD_CONST (r4,FP_S_P_INF)
2115
        LOAD_CONST (r5,FP_S_N_INF)
2116
        lf.sflt.s  r4,r5
2117
        CHECK_FLAG ("+inf < -inf: ", FALSE)
2118
 
2119
        LOAD_CONST (r4,FP_S_N_INF)
2120
        LOAD_CONST (r5,FP_S_P_INF)
2121
        lf.sflt.s  r4,r5
2122
        CHECK_FLAG ("-inf < +inf: ", TRUE)
2123
 
2124
        /* Less than with NaNs (more needed) */
2125
        LOAD_CONST (r4,FP_S_ONE)
2126
        LOAD_CONST (r5,FP_S_P_NAN)
2127
        lf.sflt.s  r4,r5
2128
        CHECK_FLAG (" 1.0 < +NaN: ", FALSE)
2129
 
2130
        LOAD_CONST (r4,FP_S_P_NAN)
2131
        LOAD_CONST (r5,FP_S_P_NAN)
2132
        lf.sflt.s  r4,r5
2133
        CHECK_FLAG ("+NaN < +NaN: ", FALSE)
2134
 
2135
        LOAD_CONST (r4,FP_S_N_NAN)
2136
        LOAD_CONST (r5,FP_S_N_NAN)
2137
        lf.sflt.s  r4,r5
2138
        CHECK_FLAG ("-NaN < -NaN: ", FALSE)
2139
 
2140
        LOAD_CONST (r4,FP_S_P_NAN)
2141
        LOAD_CONST (r5,FP_S_N_NAN)
2142
        lf.sflt.s  r4,r5
2143
        CHECK_FLAG ("+NaN < -NaN: ", FALSE)
2144
 
2145
        LOAD_CONST (r4,FP_S_N_NAN)
2146
        LOAD_CONST (r5,FP_S_P_NAN)
2147
        lf.sflt.s  r4,r5
2148
        CHECK_FLAG ("-NaN < +NaN: ", FALSE)
2149
 
2150
        /* Less than with denormalized numbers (more needed) */
2151
        LOAD_CONST (r4,FP_S_SMALL1)
2152
        LOAD_CONST (r5,FP_S_SMALL1)
2153
        lf.sflt.s  r4,r5
2154
        CHECK_FLAG (" 1.0 * 2^-129 < 1.0 * 2^-129: ", FALSE)
2155
 
2156
        LOAD_CONST (r4,FP_S_SMALL1)
2157
        LOAD_CONST (r5,FP_S_SMALL2)
2158
        lf.sflt.s  r4,r5
2159
        CHECK_FLAG (" 1.0 * 2^-129 < 1.0 * 2^-128: ", TRUE)
2160
 
2161
        LOAD_CONST (r4,FP_S_SMALL2)
2162
        LOAD_CONST (r5,FP_S_SMALL1)
2163
        lf.sflt.s  r4,r5
2164
        CHECK_FLAG (" 1.0 * 2^-128 < 1.0 * 2^-129: ", FALSE)
2165
 
2166
        LOAD_CONST (r4,FP_S_HUGE1)
2167
        LOAD_CONST (r5,FP_S_SMALL2)
2168
        lf.sflt.s  r4,r5
2169
        CHECK_FLAG (" 1.0 * 2^126  < 1.0 * 2^-128: ", FALSE)
2170
 
2171
        LOAD_CONST (r4,FP_S_SMALL2)
2172
        LOAD_CONST (r5,FP_S_HUGE1)
2173
        lf.sflt.s  r4,r5
2174
        CHECK_FLAG (" 1.0 * 2^-128 < 1.0 * 2^126:  ", TRUE)
2175
 
2176
/* ----------------------------------------------------------------------------
2177
 * Test of single precision set flag if not equal: lf.sfne.s
2178
 * ------------------------------------------------------------------------- */
2179
_sfne_s:
2180
        LOAD_STR (r3, "lf.sfne.s\n")
2181
        l.jal   _puts
2182
        l.nop
2183
 
2184
        /* Tests of integer inequality */
2185
        LOAD_CONST (r4,FP_S_ONE)
2186
        LOAD_CONST (r5,FP_S_ONE)
2187
        lf.sfne.s  r4,r5
2188
        CHECK_FLAG (" 1.0 !=  1.0: ", FALSE)
2189
 
2190
        LOAD_CONST (r4,FP_S_ONE)
2191
        LOAD_CONST (r5,FP_S_TWO)
2192
        lf.sfne.s  r4,r5
2193
        CHECK_FLAG (" 1.0 !=  2.0: ", TRUE)
2194
 
2195
        /* Fractional inequality */
2196
        LOAD_CONST (r4,FP_S_1_5)
2197
        LOAD_CONST (r5,FP_S_1_5)
2198
        lf.sfne.s  r4,r5
2199
        CHECK_FLAG (" 1.5 !=  1.5: ", FALSE)
2200
 
2201
        LOAD_CONST (r4,FP_S_1_5)
2202
        LOAD_CONST (r5,FP_S_0_5)
2203
        lf.sfne.s  r4,r5
2204
        CHECK_FLAG (" 1.5 !=  0.5: ", TRUE)
2205
 
2206
        /* Signed inequality */
2207
        LOAD_CONST (r4,FP_S_N_1_5)
2208
        LOAD_CONST (r5,FP_S_N_1_5)
2209
        lf.sfne.s  r4,r5
2210
        CHECK_FLAG ("-1.5 != -1.5: ", FALSE)
2211
 
2212
        LOAD_CONST (r4,FP_S_1_5)
2213
        LOAD_CONST (r5,FP_S_N_1_5)
2214
        lf.sfne.s  r4,r5
2215
        CHECK_FLAG (" 1.5 != -1.5: ", TRUE)
2216
 
2217
        /* Inequality of zeros */
2218
        LOAD_CONST (r4,FP_S_P_ZERO)
2219
        LOAD_CONST (r5,FP_S_P_ZERO)
2220
        lf.sfne.s  r4,r5
2221
        CHECK_FLAG ("+0.0 != +0.0: ", FALSE)
2222
 
2223
        LOAD_CONST (r4,FP_S_N_ZERO)
2224
        LOAD_CONST (r5,FP_S_N_ZERO)
2225
        lf.sfne.s  r4,r5
2226
        CHECK_FLAG ("-0.0 != -0.0: ", FALSE)
2227
 
2228
        LOAD_CONST (r4,FP_S_P_ZERO)
2229
        LOAD_CONST (r5,FP_S_N_ZERO)
2230
        lf.sfne.s  r4,r5
2231
        CHECK_FLAG ("+0.0 != -0.0: ", FALSE)
2232
 
2233
        /* Inequality with infinities (more needed) */
2234
        LOAD_CONST (r4,FP_S_ONE)
2235
        LOAD_CONST (r5,FP_S_P_INF)
2236
        lf.sfne.s  r4,r5
2237
        CHECK_FLAG (" 1.0 != +inf: ", TRUE)
2238
 
2239
        LOAD_CONST (r4,FP_S_P_INF)
2240
        LOAD_CONST (r5,FP_S_P_INF)
2241
        lf.sfne.s  r4,r5
2242
        CHECK_FLAG ("+inf != +inf: ", FALSE)
2243
 
2244
        LOAD_CONST (r4,FP_S_N_INF)
2245
        LOAD_CONST (r5,FP_S_N_INF)
2246
        lf.sfne.s  r4,r5
2247
        CHECK_FLAG ("-inf != -inf: ", FALSE)
2248
 
2249
        LOAD_CONST (r4,FP_S_P_INF)
2250
        LOAD_CONST (r5,FP_S_N_INF)
2251
        lf.sfne.s  r4,r5
2252
        CHECK_FLAG ("+inf != -inf: ", TRUE)
2253
 
2254
        /* Inequality with NaNs (more needed) */
2255
        LOAD_CONST (r4,FP_S_ONE)
2256
        LOAD_CONST (r5,FP_S_P_NAN)
2257
        lf.sfne.s  r4,r5
2258
        CHECK_FLAG (" 1.0 != +NaN: ", TRUE)
2259
 
2260
        LOAD_CONST (r4,FP_S_P_NAN)
2261
        LOAD_CONST (r5,FP_S_P_NAN)
2262
        lf.sfne.s  r4,r5
2263
        CHECK_FLAG ("+NaN != +NaN: ", TRUE)
2264
 
2265
        LOAD_CONST (r4,FP_S_N_NAN)
2266
        LOAD_CONST (r5,FP_S_N_NAN)
2267
        lf.sfne.s  r4,r5
2268
        CHECK_FLAG ("-NaN != -NaN: ", TRUE)
2269
 
2270
        LOAD_CONST (r4,FP_S_P_NAN)
2271
        LOAD_CONST (r5,FP_S_N_NAN)
2272
        lf.sfne.s  r4,r5
2273
        CHECK_FLAG ("+NaN != -NaN: ", TRUE)
2274
 
2275
        /* Inequality with denormalized numbers (more needed) */
2276
        LOAD_CONST (r4,FP_S_SMALL1)
2277
        LOAD_CONST (r5,FP_S_SMALL1)
2278
        lf.sfne.s  r4,r5
2279
        CHECK_FLAG (" 1.0 * 2^-129 != 1.0 * 2^-129: ", FALSE)
2280
 
2281
        LOAD_CONST (r4,FP_S_SMALL1)
2282
        LOAD_CONST (r5,FP_S_SMALL2)
2283
        lf.sfne.s  r4,r5
2284
        CHECK_FLAG (" 1.0 * 2^-129 != 1.0 * 2^-128: ", TRUE)
2285
 
2286
        LOAD_CONST (r4,FP_S_HUGE1)
2287
        LOAD_CONST (r5,FP_S_SMALL2)
2288
        lf.sfne.s  r4,r5
2289
        CHECK_FLAG (" 1.0 * 2^126  != 1.0 * 2^-128: ", TRUE)
2290
 
2291
/* ----------------------------------------------------------------------------
2292
 * Test of single precision subtract: lf.sub.s
2293
 * ------------------------------------------------------------------------- */
2294
        .section .text
2295
_sub_s:
2296
        LOAD_STR (r3, "lf.sub.s\n")
2297
        l.jal   _puts
2298
        l.nop
2299
 
2300 233 julius
        SET_RM  (FPCSR_RM_RIP)
2301
 
2302 104 jeremybenn
        /* Simple integer subtraction */
2303
        LOAD_CONST (r5,FP_S_ONE)
2304
        LOAD_CONST (r6,FP_S_P_ZERO)
2305
        lf.sub.s  r4,r5,r6
2306
        CHECK_RES (" 1.0 -  0.0  =  1.0:  ", r4, FP_S_ONE)
2307
 
2308
        LOAD_CONST (r5,FP_S_ONE)
2309
        LOAD_CONST (r6,FP_S_N_ZERO)
2310
        lf.sub.s  r4,r5,r6
2311
        CHECK_RES (" 1.0 - -0.0  =  1.0:  ", r4, FP_S_ONE)
2312
 
2313
        LOAD_CONST (r5,FP_S_ONE)
2314
        LOAD_CONST (r6,FP_S_ONE)
2315
        lf.sub.s  r4,r5,r6
2316
        CHECK_RES (" 1.0 -  1.0  = +0.0:  ", r4, FP_S_P_ZERO)
2317
 
2318
        LOAD_CONST (r5,FP_S_TWO)
2319
        LOAD_CONST (r6,FP_S_ONE)
2320
        lf.sub.s  r4,r5,r6
2321
        CHECK_RES (" 2.0 -  1.0  =  1.0:  ", r4, FP_S_ONE)
2322
 
2323
        /* Fractional subtraction */
2324
        LOAD_CONST (r5,FP_S_1_5)
2325
        LOAD_CONST (r6,FP_S_1_5)
2326
        lf.sub.s  r4,r5,r6
2327
        CHECK_RES (" 1.5 -  1.5  = +0.0:  ", r4, FP_S_P_ZERO)
2328
 
2329
        LOAD_CONST (r5,FP_S_1_5)
2330
        LOAD_CONST (r6,FP_S_0_5)
2331
        lf.sub.s  r4,r5,r6
2332
        CHECK_RES (" 1.5 -  0.5  =  1.0:  ", r4, FP_S_ONE)
2333
 
2334
        LOAD_CONST (r5,FP_S_1_5)
2335
        LOAD_CONST (r6,FP_S_ONE)
2336
        lf.sub.s  r4,r5,r6
2337
        CHECK_RES (" 1.5 -  1.5  =  0.5:  ", r4, FP_S_0_5)
2338
 
2339
        /* Subtraction with negative numbers */
2340
        LOAD_CONST (r5,FP_S_TWO)
2341
        LOAD_CONST (r6,FP_S_N_ONE)
2342
        lf.sub.s  r4,r5,r6
2343
        CHECK_RES (" 2.0 - -1.0  =  3.0:  ", r4, FP_S_THREE)
2344
 
2345
        LOAD_CONST (r5,FP_S_ONE)
2346
        LOAD_CONST (r6,FP_S_N_TWO)
2347
        lf.sub.s  r4,r5,r6
2348
        CHECK_RES (" 1.0 - -2.0  =  3.0:  ", r4, FP_S_THREE)
2349
 
2350
        LOAD_CONST (r5,FP_S_ONE)
2351
        LOAD_CONST (r6,FP_S_N_ONE)
2352
        lf.sub.s  r4,r5,r6
2353
        CHECK_RES (" 1.0 - -1.0  =  2.0:  ", r4, FP_S_TWO)
2354
 
2355
        LOAD_CONST (r5,FP_S_N_ONE)
2356
        LOAD_CONST (r6,FP_S_TWO)
2357
        lf.sub.s  r4,r5,r6
2358
        CHECK_RES ("-1.0 -  2.0  = -3.0:  ", r4, FP_S_N_THREE)
2359
 
2360
        LOAD_CONST (r5,FP_S_ONE)
2361
        LOAD_CONST (r6,FP_S_TWO)
2362
        lf.sub.s  r4,r5,r6
2363
        CHECK_RES (" 1.0 -  2.0  = -1.0:  ", r4, FP_S_N_ONE)
2364
 
2365
        LOAD_CONST (r5,FP_S_N_ONE)
2366
        LOAD_CONST (r6,FP_S_N_ONE)
2367
        lf.sub.s  r4,r5,r6
2368
        CHECK_RES ("-1.0 - -1.0  =  0.0:  ", r4, FP_S_P_ZERO)
2369
 
2370
        /* Subtraction with infinities (more needed) */
2371
        LOAD_CONST (r5,FP_S_ONE)
2372
        LOAD_CONST (r6,FP_S_P_INF)
2373
        lf.sub.s  r4,r5,r6
2374
        CHECK_RES (" 1.0 - +inf  = -inf:  ", r4, FP_S_N_INF)
2375
 
2376
        LOAD_CONST (r5,FP_S_ONE)
2377
        LOAD_CONST (r6,FP_S_N_INF)
2378
        lf.sub.s  r4,r5,r6
2379
        CHECK_RES (" 1.0 - -inf  = +inf:  ", r4, FP_S_P_INF)
2380
 
2381
        LOAD_CONST (r5,FP_S_P_INF)
2382
        LOAD_CONST (r6,FP_S_P_INF)
2383
        lf.sub.s  r4,r5,r6
2384
        CHECK_RES ("+inf - +inf  = -NaN:  ", r4, FP_S_N_NAN)
2385
 
2386
        LOAD_CONST (r5,FP_S_P_INF)
2387
        LOAD_CONST (r6,FP_S_N_INF)
2388
        lf.sub.s  r4,r5,r6
2389
        CHECK_RES ("+inf - -inf  = +inf:  ", r4, FP_S_P_INF)
2390
 
2391
        LOAD_CONST (r5,FP_S_N_INF)
2392
        LOAD_CONST (r6,FP_S_N_INF)
2393
        lf.sub.s  r4,r5,r6
2394
        CHECK_RES ("-inf - -inf  = -NaN:  ", r4, FP_S_N_NAN)
2395
 
2396
        /* Subtraction with NaNs (more needed) */
2397
        LOAD_CONST (r5,FP_S_ONE)
2398
        LOAD_CONST (r6,FP_S_P_NAN)
2399
        lf.sub.s  r4,r5,r6
2400
        CHECK_RES (" 1.0 - +NaN  = +NaN:  ", r4, FP_S_P_NAN)
2401
 
2402
        LOAD_CONST (r5,FP_S_ONE)
2403
        LOAD_CONST (r6,FP_S_N_NAN)
2404
        lf.sub.s  r4,r5,r6
2405
        CHECK_RES (" 1.0 - -NaN  = -NaN:  ", r4, FP_S_N_NAN)
2406
 
2407
        LOAD_CONST (r5,FP_S_P_NAN)
2408
        LOAD_CONST (r6,FP_S_P_NAN)
2409
        lf.sub.s  r4,r5,r6
2410
        CHECK_RES ("+NaN - +NaN  = +NaN:  ", r4, FP_S_P_NAN)
2411
 
2412
        LOAD_CONST (r5,FP_S_P_NAN)
2413
        LOAD_CONST (r6,FP_S_N_NAN)
2414
        lf.sub.s  r4,r5,r6
2415
        CHECK_RES ("+NaN - -NaN  = +NaN:  ", r4, FP_S_P_NAN)
2416
 
2417
        LOAD_CONST (r5,FP_S_N_NAN)
2418
        LOAD_CONST (r6,FP_S_N_NAN)
2419
        lf.sub.s  r4,r5,r6
2420
        CHECK_RES ("-NaN - -NaN  = -NaN:  ", r4, FP_S_N_NAN)
2421
 
2422
        LOAD_CONST (r5,FP_S_ONE)
2423
        LOAD_CONST (r6,FP_S_P_NAN_B)
2424
        lf.sub.s  r4,r5,r6
2425
        CHECK_RES (" 1.0 - +sNaN = +qNaN: ", r4, 0x7fc00001)
2426
 
2427
        LOAD_CONST (r5,FP_S_ONE)
2428
        LOAD_CONST (r6,FP_S_N_NAN_B)
2429
        lf.sub.s  r4,r5,r6
2430
        CHECK_RES (" 1.0 - -sNaN = -qNaN: ", r4, 0xffc00001)
2431
 
2432
        /* Subtraction with overflow (more neeeded) */
2433 233 julius
        SET_RM  (FPCSR_RM_RIN)
2434
 
2435 104 jeremybenn
        LOAD_CONST (r5,FP_S_N_HUGE2)
2436
        LOAD_CONST (r6,FP_S_HUGE2)
2437
        lf.sub.s  r4,r5,r6
2438
        CHECK_RES ("-1.0 * 2^127 -  1.0 * 2^127  = +inf:  ", r4, FP_S_N_INF)
2439
 
2440 233 julius
        SET_RM  (FPCSR_RM_RIP)
2441 104 jeremybenn
        LOAD_CONST (r5,FP_S_HUGE2)
2442
        LOAD_CONST (r6,FP_S_N_HUGE2)
2443
        lf.sub.s  r4,r5,r6
2444
        CHECK_RES (" 1.0 * 2^127 - -1.0 * 2^127  = -inf:  ", r4, FP_S_P_INF)
2445
 
2446
 
2447
/* ----------------------------------------------------------------------------
2448
 * All done
2449
 * ------------------------------------------------------------------------- */
2450
_exit:
2451
        LOAD_STR (r3, "Test completed\n")
2452
        l.jal   _puts
2453
        l.nop
2454
 
2455
        l.movhi r3,hi(ALL_DONE)
2456
        l.ori   r3,r3,lo(ALL_DONE)
2457
        l.nop   NOP_REPORT              /* Should be 0xdeaddead */
2458
 
2459
        l.addi  r3,r0,0
2460
        l.nop   NOP_EXIT

powered by: WebSVN 2.1.0

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