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

Subversion Repositories openrisc_me

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

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

powered by: WebSVN 2.1.0

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