Quote:
I am guessing you're using this on a 64k 65C816 which ignores the bank byte.
Code: Select all
HEADER "0branch", NOT_IMMEDIATE
0branch: PRIMITIVE
INX2
LDA FFFE,X
BEQ branch+2
.
.
.Code: Select all
#HEADER "branch", NOT_IMMEDIATE ; ( -- )
branch: .WORD branchcode
;-------------------
#HEADER "0branch", NOT_IMMEDIATE ; ( n -- )
Zbranch: #PRIMITIVE
;
; only on 65802 (64K wrap-around)
; #INX_INX
; LDA $FFFE,X ; Get the value that was at TOS before INX_INX .
; BEQ branchcode ; Do the branch if TOS was 0.
;
; fixed for 65816, no bank wrapping!
LDA 0,X
BEQ dbranch ; Do the branch if TOS was 0.
#INX_INX ; drop and bump
bump: LDA G.IP ; bump (advance) the instruction pointer by two
#INA_INA ; LDA, INA, INA, STA is faster than INC INC.
STA G.IP
#GO_NEXT
dbranch:
#INX_INX ; drop
branchcode: ; Set the G.IP to the absolute addr
LDA (G.IP) ; pointed to by the cell following the
STA G.IP ; execution token of branch. It's faster
#GO_NEXT ; this way not making it relative.
Code: Select all
#HEADER "leave", NOT_IMMEDIATE ; ( -- )
USleave: .WORD USleavecode ; leave is compiled by LEAVE .
;-------------------
#HEADER "?leave", NOT_IMMEDIATE ; ( f -- )
QM_leave: #PRIMITIVE ; QM_leave is compiles by QMLEAVE
;
; only on 65802 (64K wrap-around)
; #INX_INX
; LDA $FFFE,X ; Get the value that was at TOS before INX_INX .
; BNE USleavecode ; If not 0, then do the same as USleave does.
;
; fixed for 65816, no bank wrapping!
LDA 0,X
BNE doleave ; If not 0, then do the same as USleave does.
#INX_INX ; drop TOS
#GO_NEXT
doleave:
#INX_INX ; drop TOS
USleavecode:
.AL
LDA #$FFFF
STA LOOP_LEAVEdata ; Show that LEAVE was taken,
BRA lv_lp ; then end the same way as when a loop finishes.
Code: Select all
#HEADER "?EXIT", NOT_IMMEDIATE ; ( f -- ) IF R> DROP THEN
QMEXIT: #PRIMITIVE
;
; only on 65802 (64K wrap-around)
; #INX_INX
; LDA $FFFE,X ; Get the value that was at TOS before INX_INX .
; BNE unnestcode ; If not 0, then do the same as unnest does.
;
; fixed for 65816, no bank wrapping!
LDA 0,X
BEQ doexit
#INX_INX ; Drop
#GO_NEXT
doexit:
#INX_INX ; Drop
unnestcode:
PLA ; nest, and the same as EXIT.
STA G.IP ; It is often called SEMIS
#GO_NEXT ; because it's compiled by ;