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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-fp.S] - Blame information for rev 504

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

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

powered by: WebSVN 2.1.0

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