Treat ORG records as giving a signed offset from the current location.

This is the way they are defined in the GS/OS Reference, as well as the way they seem to be used by all assemblers and all other linkers that I could check (ORCA/M, MPW AsmIIGS, Apple LinkIIGS, old ORCA/APW LINKED, 8-bit ORCA linker).

Previously, this linker treated ORG records as giving an absolute address to ORG to (but with a bug in the address computation). The OMF spec in appendix B of the ORCA/M manual defines them this way, but this is inconsistent with the spec in the GS/OS Reference and with the way ORG records are generated by ORCA/M itself (for an ORG *+expression directive). Therefore, I think this is just an error and the specification in the GS/OS Reference should be regarded as correct.

We still do not support going backward (using a negative ORG operand). Trying to do so will just give an error.
This commit is contained in:
Stephen Heumann 2022-09-26 21:28:12 -05:00
parent 9f232e883a
commit 850952d612
3 changed files with 15 additions and 10 deletions

View File

@ -13,6 +13,11 @@ Updated 2022
3. Fixed bug that caused EQU or GEQU expressions with non-constant
operands to be evaluated incorrectly.
4. The numeric value in an ORG record is now treated as a signed
offset from the current location, consistent with its
definition in the GS/OS Reference. However, negative offset
values are not supported and will produce an error.
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
@ -69,7 +74,9 @@ Updated 2022
-- Documentation Update -----------------------------------------------------
No changes.
ORCA/M Manual, p. 492
The operand in an ORG record is a signed offset from the current location, not an absolute address. (This is consistent with the definition in the GS/OS Reference, and with the behavior of ORCA/M and other assemblers and linkers.)
-- Changes introduced in ORCA/Linker 2.1.0 ----------------------------------

View File

@ -137,13 +137,12 @@ DoOrg private
sta r0
ldy #3
lda [sp],Y
sta r2+2
sta r2
add4 sp,#5
sub4 r0,loadOrg get the disp from the segment start
cmpl pc,r0
bge lb1 if the disp is greater than the pc then
move4 r0,pc update the pc
lda r2
bmi lb1 if the disp is positive
add4 pc,r0 update the pc
lb1 anop

View File

@ -643,13 +643,12 @@ DoOrg private
ldy #1 get the value
lda [sp],Y
sta r4
sta r0
ldy #3
lda [sp],Y
sta r6
sta r2
add4 sp,#5 skip the op code & operand
sub4 pc,r4,r0 calculate the space to insert
lda r2 if space < 0 then
lda r2 if disp < 0 then
bpl lb1
ph4 #0 Error(NULL,3)
ph2 #3