6 Commits

Author SHA1 Message Date
Stephen Casner
05fc94ce90 Extend left-shift operator
- Negative shift values are right-shift
- Optimize shift of 0 or more than 15
- Allow shifting symbols by complex relocation
2021-02-15 19:48:16 +01:00
Stephen Casner
dcdbc02b2e Add binary operator '_' for left shift
If the command line option yus to allow the underscore character in
symbols is NOT selected, then interpret underscore as a new binary
operator meaning to do a left shift of the left side value by the
number of bit positions indicated by the right side value.  As for the
arithmetic operators, both values must be literal (numeric constants
or symbols equated to a numeric constant).
2021-02-14 14:33:42 +01:00
Olaf Seibert
e3042c9175 Remove dubious workaround in parse_unary().
The comment "eat first char of illegal label, else endless loop on
implied .WORD" was no longer true. It did reveal some other small
gotchas, which are corrected now as well.
2021-01-23 21:30:52 +01:00
Olaf Seibert
c587587f49 Fix/work around a bug in parse_expr().
There was an obscure bug in parse_expr(), used to evaluate 'if df',
where it could skip past the end of the line marker.

If this happened inside an expanded macro, then after that was the
next line...
In other cases it might be worse.

Now that this is fixed, another check for line end junk can be enabled.
2021-01-23 20:09:32 +01:00
Bjoren Davis
6f7e7963bc 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.
2021-01-18 20:22:34 +01:00
Olaf Seibert
d76e294b06 Add some tests for operators and their (lack of) precedence. 2015-11-09 21:24:10 +01:00