the assembler allows relative instructions (per, bra, etc) to external labels which won't link correctly. Merlin flags them as an error.

Additionally, per was generating a relocation record which causes the linked code to be wrong (even with an internal label).
This commit is contained in:
Kelvin Sherlock 2024-12-02 20:16:39 -05:00
parent e687507a3b
commit f0859c8356
2 changed files with 47 additions and 17 deletions

View File

@ -1439,3 +1439,44 @@ cnvttbl adrl 0,1,2,3,4,5,6,7,8,9
adrl 0,1000000000,2000000000,3000000000,4000000000,5000000000
adrl 6000000000,7000000000,8000000000,900000000
eval_rel
* like eval but returns an error if this is a reference to an external label
* assumes 16-bit m/x
* lableused values:
* $ffff - no labels encountered in eval (eg, $1234)
* $7fff - relative value (eg, *)
* 0-$7ffe - label # ; may be internal or external.
mx %00
jsr eval
bcc :check
rts
:check lda lableused
bmi :ok ; merlin allows it...
cmp #$7fff
beq :ok
asl
asl
tay
lda [lableptr1],y
sta lableptr
iny
iny
lda [lableptr1],y
sta lableptr+2
ldy #o_labtype
lda [lableptr],y
bit #externalbit
beq :ok
sec
lda #badrelative ; merlin: bad external (bra, etc)
rts ; or or illegal forward ref (brl/per)
:ok clc
rts

View File

@ -7,7 +7,7 @@ dobranch
ldy passnum
jeq :p1
ldx #$00
jsr eval
jsr eval_rel
bcc :offset
jmp :errput2
:offset lda objptr
@ -73,7 +73,7 @@ dobranch
ldy passnum
beq :p1
ldx #$00
jsr eval
jsr eval_rel
bcc :offset1
jmp :errput3
:offset1 lda objptr
@ -446,16 +446,10 @@ perop lda passnum
and #amforce24.amforce16.amforce8!$FFFF
bne :bad
ldx #$00
jsr eval
jsr eval_rel
bcc :ok
rts
:ok lda #relflag ;if rel'ing you can't use an
bit modeflag ;absolute value
beq :ok1
bit lableused
bpl :ok1
;check for lableused
:ok1 lda objptr
:ok lda objptr
clc
adc #$03
pha
@ -470,13 +464,8 @@ perop lda passnum
jsr putbyte
lda lvalue+1
jsr putbyte
lda #$7fff
sta lableused
lda lvalue
sta noshift
jmp relcorrect
* clc
* rts
clc
rts
:bad lda #badaddress
sec
rts