diff --git a/src/asm/asm.eval.s b/src/asm/asm.eval.s index 366024d..cf25664 100644 --- a/src/asm/asm.eval.s +++ b/src/asm/asm.eval.s @@ -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 + diff --git a/src/asm/asm.opcodes.s b/src/asm/asm.opcodes.s index 86a8828..e457c5d 100644 --- a/src/asm/asm.opcodes.s +++ b/src/asm/asm.opcodes.s @@ -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