Properly evaluate non-constant expressions in EQU/GEQU records.

Previously, the values of such expressions were essentially ignored, resulting in incorrect output.

This affected code like the following example:

test1   start
        lda     >p

D1      data
p       gequ    val

val     data
        dc      i'123'

Note that the EQU/GEQU expression is evaluated within the context of the location that references it, not the location where it is defined. This affects the value of the location counter, as well as the symbol search behavior. The references for the OMF format do not clearly define which way this should be done, but the current behavior can cause problems with certain object files produced by ORCA/M.
This commit is contained in:
Stephen Heumann 2022-09-25 21:42:20 -05:00
parent 0b275e5b22
commit da13b94a43
3 changed files with 6 additions and 12 deletions

View File

@ -727,6 +727,7 @@ addr dc a'EndExp' $00 End
* shiftFlag - 1 if the value is shifted, else 0
* shiftValue - expression result before shifting
* shiftCount - shift counter
* symbolRelocatable - non-zero if sym is relocatable
* returns the value of the expression

View File

@ -10,6 +10,9 @@ Updated 2022
2. A load segment is now flagged as position-independent only if
all the constituent object segments have that attribute set.
3. Fixed bug that caused EQU or GEQU expressions with non-constant
operands to be evaluated incorrectly.
2.0.6 1. The linker could give a spurious error about the relative
address calculation for a BRL instruction if it branched
forward or backward more than 32 KB. Since the address

View File

@ -845,15 +845,10 @@ gb3 ldy #symPriv if sym^.symPriv then
sv1 ldy #symExp if the value is an expression then
lda [sym],Y
jeq sv2
ph2 copiedExpression save volitile variables
ph2 copiedExpression save volatile variables
ph4 shiftCount
ph2 shiftFlag
ph4 shiftValue
ph2 symbolCount
ph2 symbolLength
ph2 symbolRelocatable
ph2 symbolType
ph4 symbolValue
ldy #symVal+2 evaluate the expression
lda [sym],Y
@ -875,12 +870,7 @@ sv1a lda symbolRelocatable if the symbol is relocatable then
ldy #symSeg set the expression file
lda [sym],Y
sta expSegment
sv1c pl4 symbolValue restore volitile variables
pl2 symbolType
pl2 symbolRelocatable
pl2 symbolLength
pl2 symbolCount
pl4 shiftValue
sv1c pl4 shiftValue restore volatile variables
pl2 shiftFlag
pl4 shiftCount
pl2 copiedExpression