Multiple fixes and enhancements to RPN behavior: (#1448)

- FIX: `Label & const` was not actually doing the `& const` masking
  (fixes #1446)
- ADD: `LOW(Label)` can be constant if `Label` is aligned to 8 or more bits
  (resolves #1444)
- ADD: `!expr` can be constant 0 if `expr` has any non-zero bits
  (resolves #1447)
- `LOW()` and `HIGH()` have their own RPN operator values
  (resolves #1445)

The change to RPN values means that the object file version was incremented.

This also refactors unary operators and functions, combining their
evaluation similarly to binary ones.
This commit is contained in:
Sylvie
2024-08-06 07:54:55 -04:00
committed by GitHub
parent 2f8f99bd94
commit 2706f94788
8 changed files with 150 additions and 74 deletions

View File

@@ -2,7 +2,7 @@
.\"
.\" SPDX-License-Identifier: MIT
.\"
.Dd December 22, 2023
.Dd August 6, 2024
.Dt RGBASM 5
.Os
.Sh NAME
@@ -326,6 +326,7 @@ with a non-zero constant as either operand will be constant 1, even if the other
.Pp
.Ic \&!
returns 1 if the operand was 0, and 0 otherwise.
Even a non-constant operand with any non-zero bits will return 0.
.Ss Fixed-point expressions
Fixed-point numbers are basically normal (32-bit) integers, which count fractions instead of whole numbers.
They offer better precision than integers but limit the range of values.
@@ -557,6 +558,9 @@ has been defined, FALSE (0) otherwise.
String constants are not expanded within the parentheses.
.It Fn HIGH arg Ta Returns the top 8 bits of the operand if Ar arg No is a label or constant, or the top 8-bit register if it is a 16-bit register .
.It Fn LOW arg Ta Returns the bottom 8 bits of the operand if Ar arg No is a label or constant, or the bottom 8-bit register if it is a 16-bit register Pq Cm AF No isn't a valid register for this function .
The result may be constant if
.Nm
is able to compute it.
.It Fn ISCONST arg Ta Returns 1 if Ar arg Ap s value is known by RGBASM (e.g. if it can be an argument to
.Ic IF ) ,
or 0 if only RGBLINK can compute its value.