small (1 and 2 word) floating point literals not parsed correctly

Fix gitlab issue #5.

The parse_float() function has several bugs:

    1. For 1- and 2-word floats it will always write all 4 bytes if the value is
       exactly 0.
    2. It incorrectly rounds and normalizes 1- and 2-word floats.

To see the issue easily try the following inputs:

     .flt2  1.0
     .flt4  1.0

These will assemble as '040100 000000' and '040200 000000 000000 000000'.
They should both begin '040200'.

In fact the test file test/test-prec.mac is incorrect in its only floating point value:
	.word	^f 1.5		; 040140
should actually assemble as 040300, not 040140 (040140 is actually ^F0.875).
I confirmed this on RT-11 running MACRO V05.06.

I fixed the problem with the following deltas:

[the patch]

The most crucial change is the very last one. 0x200000000000 is actually (1 << 45)
and because ufrac is normalized it means that it will always downshift ufrac by 1.
This commit is contained in:
Bjoren Davis
2021-01-18 20:22:34 +01:00
committed by Olaf Seibert
parent 07ee904c38
commit 6f7e7963bc
3 changed files with 36 additions and 11 deletions

View File

@@ -45,7 +45,7 @@
45 000100 070204 .word ^r<R D> ; bracketed strings are an extension
46 000102 070250 .word ^r<RA > ; bracketed strings are an extension
47 000104 157614 .word ^R50. ; 157614 there is no whitespace in between.
48 000106 040140 .word ^f 1.5 ; 040140
48 000106 040300 .word ^f 1.5 ; 040300
49
50 ;;;;;
51 ;

View File

@@ -45,7 +45,7 @@
.word ^r<R D> ; bracketed strings are an extension
.word ^r<RA > ; bracketed strings are an extension
.word ^R50. ; 157614 there is no whitespace in between.
.word ^f 1.5 ; 040140
.word ^f 1.5 ; 040300
;;;;;
;