open-simh.simtools/tests/test-float.mac
Olaf Seibert 22fdaedded Some floating point fixes.
- Fixed immediate source operand of LDEXP, LD[IL][FD]
  which is an integer, unlike several other FPP instructions.
- Renamed floating point instruction formats so they match the
  instruction descriptions in the architecture handbook better.
2021-03-30 20:13:31 +02:00

168 lines
6.8 KiB
Plaintext

;;;;;
;
; Test floating point numbers.
;
; The values in the comments are the reference values from MACRO V05.05.
;
.word ^F 1.0 ; 040200
.word ^F-1.0 ; 140200
.word -^F 1.0 ; 137600
.word -^F-1.0 ; 037600
.word ^F6.2 ; 040706
.word ^C^F6.2 ; 137071
.word ^C<^F6.2> ; 137071
.flt2 6.2 ; 040706 063146
.flt4 6.2 ; 040706 063146 063146 063146
.flt2 1.5 ; 040300 000000
.flt4 1.5 ; 040300 000000 000000 000000
.word ^F 3.1415926535897932384626433 ; 040511
.flt2 3.1415926535897932384626433 ; 040511 007733
.flt4 3.1415926535897932384626433 ; 040511 007732 121041 064302
; Test some large numbers at the edge of the exactly representable
; integers.
; 1 << 56 just barely fits: it uses 57 bits but the lsb is 0 so
; when it is cut off, we don't notice.
; 1 << 56 + 1 R the lsb are 01 and is cut off.
; 1 << 56 + 2 the lsb are 10 and the missing 0 goes unnoticed.
; 1 << 56 - 1 consists of 56 1 bits. This value and all smaller ints
; 1 << 56 - 2 get represented exactly.
; Going up, to rounding steps of 4:
;
; 1 << 57
; 1 << 57 + 4 next higher available representation
; 1 << 57 + 8 next higher available representation
; 1 << 56 - 3
.flt4 72057594037927933 ; 056177 177777 177777 177775
; 1 << 56 - 2
.flt4 72057594037927934 ; 056177 177777 177777 177776
; 1 << 56 - 1
.word ^F 72057594037927935 ; 056200 (rounded up!)
.flt2 72057594037927935 ; 056200 000000 (rounded up!)
.flt4 72057594037927935 ; 056177 177777 177777 177777
; 1 << 56
.word ^F 72057594037927936 ; 056200
.flt2 72057594037927936 ; 056200 000000
.flt4 72057594037927936 ; 056200 000000 000000 000000
.flt4 72057594037927938 ; 1 << 56 + 2
; 056200 000000 000000 000001
.flt4 144115188075855872 ; 1 << 57
; 056400 000000 000000 000000
.flt4 144115188075855873 ; 1 << 57 + 1
; 056400 000000 000000 000000 (inexact)
.flt4 144115188075855874 ; 1 << 57 + 2
; 056400 000000 000000 000001 (inexact)
.flt4 144115188075855875 ; 1 << 57 + 3
; 056400 000000 000000 000001 (inexact)
.flt4 144115188075855876 ; 1 << 57 + 4
; 056400 000000 000000 000001 (exact!)
.flt4 144115188075855880 ; 1 << 57 + 8
; 056400 000000 000000 000002 (exact!)
; This one triggers rounding up (round == 1)
.flt4 6.66666 ; 040725 052507 055061 122276
; MACRO-11 truncates these ^F values despite what the manual says.
; On the other hand, it does round up some of the test values above.
; We stick to the manual since the result is more consistent.
; Expression RT-11 this
; MACRO-11 version
; V05.06
.word ^F 0.994140625 ; (2**9-3)/2**9 040176 040177
.flt4 0.994140625
.word ^F 0.998046875 ; (2**9-1)/2**9 040177 040200
.flt4 0.998046875
.word ^F 1.00390625 ; (2**8+1)/2**8 040200 040201
.flt4 1.00390625
.word ^F 1.01171875 ; (2**8+3)/2**8 040201 040202
.flt4 1.01171875
.flt4 1.701411834604692307e+38 ; 077777 177777 177777 177777
.FLT4 170141183460469230551095682998472802304 ; 2**127-2**70
.FLT4 170141183460469230564930741053754966015 ; 2**127-(2**70-2**64+2**62+1)
.FLT4 170141183460469230564930741053754966016 ; 2**127-(2**70-2**64+2**62+2)
; Several ways to define a name for the fpp registers
ac0 = r0
ac1 = %1
f2 = %2
mulf r3,ac0
mulf r2,ac1
ADDF #^O41040,F2
addf #1,ac1
mulf r3,ac0
mulf r2,ac1
addf #^O41040,F2 ; taken literally
addf #1,ac1 ; as float
addf #1.,ac1 ; as float
addf #1.0,ac1 ; as float
addf #^D1,ac1 ; literally
subf #<1>,ac0 ; literally
addf #<1+1>,ac1 ; literally
subf #<1.0>,ac0 ; error
addf #1.5,ac1 ; as float
addd #-1.4,ac1 ; as float
subf #<^F 1.0>,ac0 ; as float
subf #<^D 1.0>,ac0 ; error
subf #<^D 1>,ac0 ; literally
subf #^D<1+1>,ac0 ; literally
subf #^D 1+1 ,ac0 ; literally
subf #1e3,ac0 ; as float
subf #1e 3,ac0 ; TODO: accepted by MACRO11 as 1E3 (but not 1 e3, 1 e 3)
a = 1
e3 = 3
subf #a,ac0 ; a interpreted as bit pattern
subf #<a>,ac0 ; a interpreted as bit pattern
subf #e3,ac0 ; e3 is the label
subf #<1e3>,ac0 ; error N
absf #2.5 ; bad: operand is destination
tstd #2.5 ; bad: operand is considered FDST by the arch handbook
stf ac0,#2.5 ; bad: junk at end of line
stf ac0,#2 ; doesn't makes sense but MACRO11 allows it
; Test immediate source argument for instructions that have one (src or fsrc)
addd #1,ac0 ; float
addf #1,ac0 ; float
cmpd #1,ac0 ; float
cmpf #1,ac0 ; float
divd #1,ac0 ; float
divf #1,ac0 ; float
ldcdf #1,ac0 ; float
ldcfd #1,ac0 ; float
ldcid #1,ac0 ; integer
ldcif #1,ac0 ; integer
ldcld #1,ac0 ; integer
ldclf #1,ac0 ; integer
ldd #1,ac0 ; float
ldf #1,ac0 ; float
ldexp #1,ac0 ; integer
modd #1,ac0 ; float
modf #1,ac0 ; float
muld #1,ac0 ; float
mulf #1,ac0 ; float
subd #1,ac0 ; float
subf #1,ac0 ; float
.end