mirror of
https://github.com/marketideas/qasm.git
synced 2025-01-14 11:29:46 +00:00
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:
parent
e687507a3b
commit
f0859c8356
@ -1439,3 +1439,44 @@ cnvttbl adrl 0,1,2,3,4,5,6,7,8,9
|
|||||||
adrl 0,1000000000,2000000000,3000000000,4000000000,5000000000
|
adrl 0,1000000000,2000000000,3000000000,4000000000,5000000000
|
||||||
adrl 6000000000,7000000000,8000000000,900000000
|
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
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ dobranch
|
|||||||
ldy passnum
|
ldy passnum
|
||||||
jeq :p1
|
jeq :p1
|
||||||
ldx #$00
|
ldx #$00
|
||||||
jsr eval
|
jsr eval_rel
|
||||||
bcc :offset
|
bcc :offset
|
||||||
jmp :errput2
|
jmp :errput2
|
||||||
:offset lda objptr
|
:offset lda objptr
|
||||||
@ -73,7 +73,7 @@ dobranch
|
|||||||
ldy passnum
|
ldy passnum
|
||||||
beq :p1
|
beq :p1
|
||||||
ldx #$00
|
ldx #$00
|
||||||
jsr eval
|
jsr eval_rel
|
||||||
bcc :offset1
|
bcc :offset1
|
||||||
jmp :errput3
|
jmp :errput3
|
||||||
:offset1 lda objptr
|
:offset1 lda objptr
|
||||||
@ -446,16 +446,10 @@ perop lda passnum
|
|||||||
and #amforce24.amforce16.amforce8!$FFFF
|
and #amforce24.amforce16.amforce8!$FFFF
|
||||||
bne :bad
|
bne :bad
|
||||||
ldx #$00
|
ldx #$00
|
||||||
jsr eval
|
jsr eval_rel
|
||||||
bcc :ok
|
bcc :ok
|
||||||
rts
|
rts
|
||||||
:ok lda #relflag ;if rel'ing you can't use an
|
:ok lda objptr
|
||||||
bit modeflag ;absolute value
|
|
||||||
beq :ok1
|
|
||||||
bit lableused
|
|
||||||
bpl :ok1
|
|
||||||
;check for lableused
|
|
||||||
:ok1 lda objptr
|
|
||||||
clc
|
clc
|
||||||
adc #$03
|
adc #$03
|
||||||
pha
|
pha
|
||||||
@ -470,13 +464,8 @@ perop lda passnum
|
|||||||
jsr putbyte
|
jsr putbyte
|
||||||
lda lvalue+1
|
lda lvalue+1
|
||||||
jsr putbyte
|
jsr putbyte
|
||||||
lda #$7fff
|
clc
|
||||||
sta lableused
|
rts
|
||||||
lda lvalue
|
|
||||||
sta noshift
|
|
||||||
jmp relcorrect
|
|
||||||
* clc
|
|
||||||
* rts
|
|
||||||
:bad lda #badaddress
|
:bad lda #badaddress
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user