From e06a217f33db3d2a7ea5e64efc1c725f9fc30d49 Mon Sep 17 00:00:00 2001 From: Dave Schmenk Date: Thu, 18 Jan 2018 20:27:53 -0800 Subject: [PATCH] Switch all VMs to lazy IP update --- src/vmsrc/plvm01.s | 1379 +++++++++++++++++++++---------------------- src/vmsrc/plvm02.s | 8 +- src/vmsrc/plvm03.s | 83 ++- src/vmsrc/plvm802.s | 92 ++- 4 files changed, 768 insertions(+), 794 deletions(-) diff --git a/src/vmsrc/plvm01.s b/src/vmsrc/plvm01.s index 8801fc9..ea4b51c 100644 --- a/src/vmsrc/plvm01.s +++ b/src/vmsrc/plvm01.s @@ -13,7 +13,7 @@ SELFMODIFY = 1 DVSIGN = TMP+2 DROP = $EF NEXTOP = $F0 -FETCHOP = NEXTOP+3 +FETCHOP = NEXTOP+1 IP = FETCHOP+1 IPL = IP IPH = IPL+1 @@ -24,13 +24,17 @@ OPPAGE = OPIDX+1 ;* !MACRO INC_IP { INY - BNE *+4 - INC IPH -} + BPL + + INC IPH + TYA + AND #$7F + TAY ++ + } ;* ;* INTERPRETER HEADER+INITIALIZATION ;* - *= $0280 + *= $0280 SEGBEGIN JMP VMINIT ;* ;* SYSTEM INTERPRETER ENTRYPOINT @@ -58,76 +62,74 @@ IINTERP PLA LDA (TMP),Y STA IPL DEY - JMP FETCHOP + JMP FETCHOP ;* ;* MUL TOS-1 BY TOS ;* -MUL STY IPY - LDY #$10 - LDA ESTKL+1,X - EOR #$FF - STA TMPL - LDA ESTKH+1,X - EOR #$FF - STA TMPH - LDA #$00 - STA ESTKL+1,X ; PRODL -; STA ESTKH+1,X ; PRODH -MULLP LSR TMPH ; MULTPLRH - ROR TMPL ; MULTPLRL - BCS + - STA ESTKH+1,X ; PRODH - LDA ESTKL,X ; MULTPLNDL - ADC ESTKL+1,X ; PRODL - STA ESTKL+1,X - LDA ESTKH,X ; MULTPLNDH - ADC ESTKH+1,X ; PRODH -+ ASL ESTKL,X ; MULTPLNDL - ROL ESTKH,X ; MULTPLNDH - DEY - BNE MULLP - STA ESTKH+1,X ; PRODH - LDY IPY -; INX -; JMP NEXTOP +MUL STY IPY + LDY #$10 + LDA ESTKL+1,X + EOR #$FF + STA TMPL + LDA ESTKH+1,X + EOR #$FF + STA TMPH + LDA #$00 + STA ESTKL+1,X ; PRODL +; STA ESTKH+1,X ; PRODH +MULLP LSR TMPH ; MULTPLRH + ROR TMPL ; MULTPLRL + BCS + + STA ESTKH+1,X ; PRODH + LDA ESTKL,X ; MULTPLNDL + ADC ESTKL+1,X ; PRODL + STA ESTKL+1,X + LDA ESTKH,X ; MULTPLNDH + ADC ESTKH+1,X ; PRODH ++ ASL ESTKL,X ; MULTPLNDL + ROL ESTKH,X ; MULTPLNDH + DEY + BNE MULLP + STA ESTKH+1,X ; PRODH + LDY IPY JMP DROP ;* ;* INCREMENT TOS ;* -INCR INC ESTKL,X - BNE INCR1 - INC ESTKH,X -INCR1 JMP NEXTOP +INCR INC ESTKL,X + BNE INCR1 + INC ESTKH,X +INCR1 JMP NEXTOP ;* ;* DECREMENT TOS ;* -DECR LDA ESTKL,X - BNE DECR1 - DEC ESTKH,X -DECR1 DEC ESTKL,X - JMP NEXTOP +DECR LDA ESTKL,X + BNE DECR1 + DEC ESTKH,X +DECR1 DEC ESTKL,X + JMP NEXTOP ;* ;* BITWISE COMPLIMENT TOS ;* -COMP LDA #$FF - EOR ESTKL,X - STA ESTKL,X - LDA #$FF - EOR ESTKH,X - STA ESTKH,X - JMP NEXTOP +COMP LDA #$FF + EOR ESTKL,X + STA ESTKL,X + LDA #$FF + EOR ESTKH,X + STA ESTKH,X + JMP NEXTOP ;* ;* OPCODE TABLE ;* !ALIGN 255,0 -OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E - !WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E - !WORD LNOT,LOR,LAND,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E - !WORD DROP,DUP,NEXTOP,DIVMOD,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E +OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E + !WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E + !WORD LNOT,LOR,LAND,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E + !WORD DROP,DUP,NEXTOP,DIVMOD,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E !WORD ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E - !WORD BRNCH,IBRNCH,CALL,ICAL,ENTER,LEAVE,RET,CFFB ; 50 52 54 56 58 5A 5C 5E - !WORD LB,LW,LLB,LLW,LAB,LAW,DLB,DLW ; 60 62 64 66 68 6A 6C 6E - !WORD SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E + !WORD BRNCH,IBRNCH,CALL,ICAL,ENTER,LEAVE,RET,CFFB ; 50 52 54 56 58 5A 5C 5E + !WORD LB,LW,LLB,LLW,LAB,LAW,DLB,DLW ; 60 62 64 66 68 6A 6C 6E + !WORD SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E ;* ;* DIV TOS-1 BY TOS ;* @@ -165,766 +167,748 @@ DIVMOD JSR _DIV ;* ;* NEGATE TOS ;* -NEG LDA #$00 - SEC - SBC ESTKL,X - STA ESTKL,X - LDA #$00 - SBC ESTKH,X - STA ESTKH,X - JMP NEXTOP +NEG LDA #$00 + SEC + SBC ESTKL,X + STA ESTKL,X + LDA #$00 + SBC ESTKH,X + STA ESTKH,X + JMP NEXTOP ;* ;* INTERNAL DIVIDE ALGORITHM ;* -_NEG LDA #$00 - SEC - SBC ESTKL,X - STA ESTKL,X - LDA #$00 - SBC ESTKH,X - STA ESTKH,X - RTS -_DIV STY IPY - LDY #$11 ; #BITS+1 - LDA #$00 - STA TMPL ; REMNDRL - STA TMPH ; REMNDRH - LDA ESTKH,X - AND #$80 - STA DVSIGN - BPL + - JSR _NEG - INC DVSIGN -+ LDA ESTKH+1,X - BPL + - INX - JSR _NEG - DEX - INC DVSIGN - BNE _DIV1 -+ ORA ESTKL+1,X ; DVDNDL - BEQ _DIVEX -_DIV1 ASL ESTKL+1,X ; DVDNDL - ROL ESTKH+1,X ; DVDNDH - DEY - BCC _DIV1 -_DIVLP ROL TMPL ; REMNDRL - ROL TMPH ; REMNDRH - LDA TMPL ; REMNDRL - CMP ESTKL,X ; DVSRL - LDA TMPH ; REMNDRH - SBC ESTKH,X ; DVSRH - BCC + - STA TMPH ; REMNDRH - LDA TMPL ; REMNDRL - SBC ESTKL,X ; DVSRL - STA TMPL ; REMNDRL - SEC -+ ROL ESTKL+1,X ; DVDNDL - ROL ESTKH+1,X ; DVDNDH - DEY - BNE _DIVLP +_NEG LDA #$00 + SEC + SBC ESTKL,X + STA ESTKL,X + LDA #$00 + SBC ESTKH,X + STA ESTKH,X + RTS +_DIV STY IPY + LDY #$11 ; #BITS+1 + LDA #$00 + STA TMPL ; REMNDRL + STA TMPH ; REMNDRH + LDA ESTKH,X + AND #$80 + STA DVSIGN + BPL + + JSR _NEG + INC DVSIGN ++ LDA ESTKH+1,X + BPL + + INX + JSR _NEG + DEX + INC DVSIGN + BNE _DIV1 ++ ORA ESTKL+1,X ; DVDNDL + BEQ _DIVEX +_DIV1 ASL ESTKL+1,X ; DVDNDL + ROL ESTKH+1,X ; DVDNDH + DEY + BCC _DIV1 +_DIVLP ROL TMPL ; REMNDRL + ROL TMPH ; REMNDRH + LDA TMPL ; REMNDRL + CMP ESTKL,X ; DVSRL + LDA TMPH ; REMNDRH + SBC ESTKH,X ; DVSRH + BCC + + STA TMPH ; REMNDRH + LDA TMPL ; REMNDRL + SBC ESTKL,X ; DVSRL + STA TMPL ; REMNDRL + SEC ++ ROL ESTKL+1,X ; DVDNDL + ROL ESTKH+1,X ; DVDNDH + DEY + BNE _DIVLP _DIVEX INX - LDY IPY - RTS + LDY IPY + RTS ;* ;* ADD TOS TO TOS-1 ;* -ADD LDA ESTKL,X - CLC - ADC ESTKL+1,X - STA ESTKL+1,X - LDA ESTKH,X - ADC ESTKH+1,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +ADD LDA ESTKL,X + CLC + ADC ESTKL+1,X + STA ESTKL+1,X + LDA ESTKH,X + ADC ESTKH+1,X + STA ESTKH+1,X + JMP DROP ;* ;* SUB TOS FROM TOS-1 ;* -SUB LDA ESTKL+1,X - SEC - SBC ESTKL,X - STA ESTKL+1,X - LDA ESTKH+1,X - SBC ESTKH,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +SUB LDA ESTKL+1,X + SEC + SBC ESTKL,X + STA ESTKL+1,X + LDA ESTKH+1,X + SBC ESTKH,X + STA ESTKH+1,X + JMP DROP ; ;* ;* SHIFT TOS LEFT BY 1, ADD TO TOS-1 ;* -IDXW LDA ESTKL,X - ASL - ROL ESTKH,X - CLC - ADC ESTKL+1,X - STA ESTKL+1,X - LDA ESTKH,X - ADC ESTKH+1,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +IDXW LDA ESTKL,X + ASL + ROL ESTKH,X + CLC + ADC ESTKL+1,X + STA ESTKL+1,X + LDA ESTKH,X + ADC ESTKH+1,X + STA ESTKH+1,X + JMP DROP ;* ;* BITWISE AND TOS TO TOS-1 ;* -BAND LDA ESTKL+1,X - AND ESTKL,X - STA ESTKL+1,X - LDA ESTKH+1,X - AND ESTKH,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +BAND LDA ESTKL+1,X + AND ESTKL,X + STA ESTKL+1,X + LDA ESTKH+1,X + AND ESTKH,X + STA ESTKH+1,X + JMP DROP ;* ;* INCLUSIVE OR TOS TO TOS-1 ;* -IOR LDA ESTKL+1,X - ORA ESTKL,X - STA ESTKL+1,X - LDA ESTKH+1,X - ORA ESTKH,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +IOR LDA ESTKL+1,X + ORA ESTKL,X + STA ESTKL+1,X + LDA ESTKH+1,X + ORA ESTKH,X + STA ESTKH+1,X + JMP DROP ;* ;* EXLUSIVE OR TOS TO TOS-1 ;* -XOR LDA ESTKL+1,X - EOR ESTKL,X - STA ESTKL+1,X - LDA ESTKH+1,X - EOR ESTKH,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +XOR LDA ESTKL+1,X + EOR ESTKL,X + STA ESTKL+1,X + LDA ESTKH+1,X + EOR ESTKH,X + STA ESTKH+1,X + JMP DROP ;* ;* SHIFT TOS-1 LEFT BY TOS ;* SHL STY IPY - LDA ESTKL,X - CMP #$08 - BCC SHL1 - LDY ESTKL+1,X - STY ESTKH+1,X - LDY #$00 - STY ESTKL+1,X - SBC #$08 + LDA ESTKL,X + CMP #$08 + BCC SHL1 + LDY ESTKL+1,X + STY ESTKH+1,X + LDY #$00 + STY ESTKL+1,X + SBC #$08 SHL1 TAY - BEQ SHL3 -SHL2 ASL ESTKL+1,X - ROL ESTKH+1,X - DEY - BNE SHL2 -SHL3 LDY IPY -; INX -; JMP NEXTOP - JMP DROP + BEQ SHL3 +SHL2 ASL ESTKL+1,X + ROL ESTKH+1,X + DEY + BNE SHL2 +SHL3 LDY IPY + JMP DROP ;* ;* SHIFT TOS-1 RIGHT BY TOS ;* -SHR STY IPY - LDA ESTKL,X - CMP #$08 - BCC SHR2 - LDY ESTKH+1,X - STY ESTKL+1,X - CPY #$80 - LDY #$00 - BCC SHR1 - DEY -SHR1 STY ESTKH+1,X - SEC - SBC #$08 +SHR STY IPY + LDA ESTKL,X + CMP #$08 + BCC SHR2 + LDY ESTKH+1,X + STY ESTKL+1,X + CPY #$80 + LDY #$00 + BCC SHR1 + DEY +SHR1 STY ESTKH+1,X + SEC + SBC #$08 SHR2 TAY - BEQ SHR4 - LDA ESTKH+1,X -SHR3 CMP #$80 - ROR - ROR ESTKL+1,X - DEY - BNE SHR3 - STA ESTKH+1,X -SHR4 LDY IPY -; INX -; JMP NEXTOP - JMP DROP + BEQ SHR4 + LDA ESTKH+1,X +SHR3 CMP #$80 + ROR + ROR ESTKL+1,X + DEY + BNE SHR3 + STA ESTKH+1,X +SHR4 LDY IPY + JMP DROP ;* ;* LOGICAL NOT ;* -LNOT LDA ESTKL,X - ORA ESTKH,X - BEQ LNOT1 - LDA #$FF -LNOT1 EOR #$FF - STA ESTKL,X - STA ESTKH,X - JMP NEXTOP +LNOT LDA ESTKL,X + ORA ESTKH,X + BEQ LNOT1 + LDA #$FF +LNOT1 EOR #$FF + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP ;* ;* LOGICAL AND ;* -LAND LDA ESTKL+1,X - ORA ESTKH+1,X - BEQ LAND2 - LDA ESTKL,X - ORA ESTKH,X - BEQ LAND1 - LDA #$FF -LAND1 STA ESTKL+1,X - STA ESTKH+1,X -;LAND2 INX -; JMP NEXTOP -LAND2 JMP DROP +LAND LDA ESTKL+1,X + ORA ESTKH+1,X + BEQ LAND2 + LDA ESTKL,X + ORA ESTKH,X + BEQ LAND1 + LDA #$FF +LAND1 STA ESTKL+1,X + STA ESTKH+1,X +LAND2 JMP DROP ;* ;* LOGICAL OR ;* -LOR LDA ESTKL,X - ORA ESTKH,X - ORA ESTKL+1,X - ORA ESTKH+1,X - BEQ LOR1 - LDA #$FF - STA ESTKL+1,X - STA ESTKH+1,X -;LOR1 INX -; JMP NEXTOP -LOR1 JMP DROP +LOR LDA ESTKL,X + ORA ESTKH,X + ORA ESTKL+1,X + ORA ESTKH+1,X + BEQ LOR1 + LDA #$FF + STA ESTKL+1,X + STA ESTKH+1,X +LOR1 JMP DROP ;* ;* DUPLICATE TOS ;* DUP DEX - LDA ESTKL+1,X - STA ESTKL,X - LDA ESTKH+1,X - STA ESTKH,X - JMP NEXTOP + LDA ESTKL+1,X + STA ESTKL,X + LDA ESTKH+1,X + STA ESTKH,X + JMP NEXTOP ;* ;* CONSTANT ;* ZERO DEX - LDA #$00 - STA ESTKL,X - STA ESTKH,X - JMP NEXTOP -CFFB LDA #$FF - !BYTE $2C ; BIT $00A9 - effectively skips LDA #$00, no harm in reading this address -CB LDA #$00 - DEX - STA ESTKH,X - +INC_IP - LDA (IP),Y - STA ESTKL,X - JMP NEXTOP + LDA #$00 + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP +CFFB LDA #$FF + !BYTE $2C ; BIT $00A9 - effectively skips LDA #$00, no harm in reading this address +CB LDA #$00 + DEX + STA ESTKH,X + +INC_IP + LDA (IP),Y + STA ESTKL,X + JMP NEXTOP ;* ;* LOAD ADDRESS & LOAD CONSTANT WORD (SAME THING, WITH OR WITHOUT FIXUP) ;* -LA = * -CW DEX - +INC_IP - LDA (IP),Y - STA ESTKL,X - +INC_IP - LDA (IP),Y - STA ESTKH,X - JMP NEXTOP +LA = * +CW DEX + INY ;+INC_IP + LDA (IP),Y + STA ESTKL,X + +INC_IP + LDA (IP),Y + STA ESTKH,X + JMP NEXTOP ;* ;* CONSTANT STRING ;* -CS DEX - +INC_IP - TYA ; NORMALIZE IP AND SAVE STRING ADDR ON ESTK - CLC - ADC IPL - STA IPL - STA ESTKL,X - LDA #$00 - TAY - ADC IPH - STA IPH - STA ESTKH,X - LDA (IP),Y - TAY - JMP NEXTOP +CS DEX + INY ;+INC_IP + TYA ; NORMALIZE IP AND SAVE STRING ADDR ON ESTK + CLC + ADC IPL + STA IPL + STA ESTKL,X + LDA #$00 + TAY + ADC IPH + STA IPH + STA ESTKH,X + LDA (IP),Y + TAY + JMP NEXTOP ;* ;* LOAD VALUE FROM ADDRESS TAG ;* -!IF SELFMODIFY { -LB LDA ESTKL,X - STA LBLDA+1 - LDA ESTKH,X - STA LBLDA+2 -LBLDA LDA $FFFF - STA ESTKL,X - LDA #$00 - STA ESTKH,X - JMP NEXTOP +!IF SELFMODIFY { +LB LDA ESTKL,X + STA LBLDA+1 + LDA ESTKH,X + STA LBLDA+2 +LBLDA LDA $FFFF + STA ESTKL,X + LDA #$00 + STA ESTKH,X + JMP NEXTOP } ELSE { -LB LDA ESTKL,X - STA TMPL - LDA ESTKH,X - STA TMPH - STY IPY - LDY #$00 - LDA (TMP),Y - STA ESTKL,X - STY ESTKH,X - LDY IPY - JMP NEXTOP +LB LDA ESTKL,X + STA TMPL + LDA ESTKH,X + STA TMPH + STY IPY + LDY #$00 + LDA (TMP),Y + STA ESTKL,X + STY ESTKH,X + LDY IPY + JMP NEXTOP } -LW LDA ESTKL,X - STA TMPL - LDA ESTKH,X - STA TMPH - STY IPY - LDY #$00 - LDA (TMP),Y - STA ESTKL,X - INY - LDA (TMP),Y - STA ESTKH,X - LDY IPY - JMP NEXTOP +LW LDA ESTKL,X + STA TMPL + LDA ESTKH,X + STA TMPH + STY IPY + LDY #$00 + LDA (TMP),Y + STA ESTKL,X + INY + LDA (TMP),Y + STA ESTKH,X + LDY IPY + JMP NEXTOP ;* ;* LOAD ADDRESS OF LOCAL FRAME OFFSET ;* LLA +INC_IP - LDA (IP),Y - DEX - CLC - ADC IFPL - STA ESTKL,X - LDA #$00 - ADC IFPH - STA ESTKH,X - JMP NEXTOP + LDA (IP),Y + DEX + CLC + ADC IFPL + STA ESTKL,X + LDA #$00 + ADC IFPH + STA ESTKH,X + JMP NEXTOP ;* ;* LOAD VALUE FROM LOCAL FRAME OFFSET ;* LLB +INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - LDA (IFP),Y - STA ESTKL,X - LDA #$00 - STA ESTKH,X - LDY IPY - JMP NEXTOP + LDA (IP),Y + STY IPY + TAY + DEX + LDA (IFP),Y + STA ESTKL,X + LDA #$00 + STA ESTKH,X + LDY IPY + JMP NEXTOP LLW +INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - LDA (IFP),Y - STA ESTKL,X - INY - LDA (IFP),Y - STA ESTKH,X - LDY IPY - JMP NEXTOP + LDA (IP),Y + STY IPY + TAY + DEX + LDA (IFP),Y + STA ESTKL,X + INY + LDA (IFP),Y + STA ESTKH,X + LDY IPY + JMP NEXTOP ;* ;* LOAD VALUE FROM ABSOLUTE ADDRESS ;* -!IF SELFMODIFY { -LAB +INC_IP - LDA (IP),Y - STA LABLDA+1 - +INC_IP - LDA (IP),Y - STA LABLDA+2 -LABLDA LDA $FFFF - DEX - STA ESTKL,X - LDA #$00 - STA ESTKH,X - JMP NEXTOP +!IF SELFMODIFY { +LAB INY ;+INC_IP + LDA (IP),Y + STA LABLDA+1 + +INC_IP + LDA (IP),Y + STA LABLDA+2 +LABLDA LDA $FFFF + DEX + STA ESTKL,X + LDA #$00 + STA ESTKH,X + JMP NEXTOP } ELSE { -LAB +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDY #$00 - LDA (TMP),Y - DEX - STA ESTKL,X - STY ESTKH,X - LDY IPY - JMP NEXTOP +LAB INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + STY IPY + LDY #$00 + LDA (TMP),Y + DEX + STA ESTKL,X + STY ESTKH,X + LDY IPY + JMP NEXTOP } -LAW +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDY #$00 - LDA (TMP),Y - DEX - STA ESTKL,X - INY - LDA (TMP),Y - STA ESTKH,X - LDY IPY - JMP NEXTOP +LAW INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + STY IPY + LDY #$00 + LDA (TMP),Y + DEX + STA ESTKL,X + INY + LDA (TMP),Y + STA ESTKH,X + LDY IPY + JMP NEXTOP ;* ;* STORE VALUE TO ADDRESS ;* -!IF SELFMODIFY { -SB LDA ESTKL,X - STA SBSTA+1 - LDA ESTKH,X - STA SBSTA+2 - LDA ESTKL+1,X -SBSTA STA $FFFF - INX -; INX -; JMP NEXTOP - JMP DROP +!IF SELFMODIFY { +SB LDA ESTKL,X + STA SBSTA+1 + LDA ESTKH,X + STA SBSTA+2 + LDA ESTKL+1,X +SBSTA STA $FFFF + INX + JMP DROP } ELSE { -SB LDA ESTKL,X - STA TMPL - LDA ESTKH,X - STA TMPH - LDA ESTKL+1,X - STY IPY - LDY #$00 - STA (TMP),Y - LDY IPY - INX -; INX -; JMP NEXTOP - JMP DROP +SB LDA ESTKL,X + STA TMPL + LDA ESTKH,X + STA TMPH + LDA ESTKL+1,X + STY IPY + LDY #$00 + STA (TMP),Y + LDY IPY + INX + JMP DROP } -SW LDA ESTKL,X - STA TMPL - LDA ESTKH,X - STA TMPH - STY IPY - LDY #$00 - LDA ESTKL+1,X - STA (TMP),Y - INY - LDA ESTKH+1,X - STA (TMP),Y - LDY IPY - INX -; INX -; JMP NEXTOP - JMP DROP +SW LDA ESTKL,X + STA TMPL + LDA ESTKH,X + STA TMPH + STY IPY + LDY #$00 + LDA ESTKL+1,X + STA (TMP),Y + INY + LDA ESTKH+1,X + STA (TMP),Y + LDY IPY + INX + JMP DROP ;* ;* STORE VALUE TO LOCAL FRAME OFFSET ;* SLB +INC_IP - LDA (IP),Y - STY IPY - TAY - LDA ESTKL,X - STA (IFP),Y - LDY IPY -; INX -; JMP NEXTOP - JMP DROP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + LDY IPY + JMP DROP SLW +INC_IP - LDA (IP),Y - STY IPY - TAY - LDA ESTKL,X - STA (IFP),Y - INY - LDA ESTKH,X - STA (IFP),Y - LDY IPY -; INX -; JMP NEXTOP - JMP DROP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + INY + LDA ESTKH,X + STA (IFP),Y + LDY IPY + JMP DROP ;* ;* STORE VALUE TO LOCAL FRAME OFFSET WITHOUT POPPING STACK ;* DLB +INC_IP - LDA (IP),Y - STY IPY - TAY - LDA ESTKL,X - STA (IFP),Y - LDY IPY - JMP NEXTOP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + LDY IPY + JMP NEXTOP DLW +INC_IP - LDA (IP),Y - STY IPY - TAY - LDA ESTKL,X - STA (IFP),Y - INY - LDA ESTKH,X - STA (IFP),Y - LDY IPY - JMP NEXTOP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + INY + LDA ESTKH,X + STA (IFP),Y + LDY IPY + JMP NEXTOP ;* ;* STORE VALUE TO ABSOLUTE ADDRESS ;* -!IF SELFMODIFY { -SAB +INC_IP - LDA (IP),Y - STA SABSTA+1 - +INC_IP - LDA (IP),Y - STA SABSTA+2 - LDA ESTKL,X -SABSTA STA $FFFF -; INX -; JMP NEXTOP - JMP DROP +!IF SELFMODIFY { +SAB INY ;+INC_IP + LDA (IP),Y + STA SABSTA+1 + +INC_IP + LDA (IP),Y + STA SABSTA+2 + LDA ESTKL,X +SABSTA STA $FFFF + JMP DROP } ELSE { -SAB +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - LDA ESTKL,X - STY IPY - LDY #$00 - STA (TMP),Y - LDY IPY -; INX -; JMP NEXTOP - JMP DROP +SAB INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + LDA ESTKL,X + STY IPY + LDY #$00 + STA (TMP),Y + LDY IPY + JMP DROP } -SAW +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDY #$00 - LDA ESTKL,X - STA (TMP),Y - INY - LDA ESTKH,X - STA (TMP),Y - LDY IPY -; INX -; JMP NEXTOP - JMP DROP +SAW INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + STY IPY + LDY #$00 + LDA ESTKL,X + STA (TMP),Y + INY + LDA ESTKH,X + STA (TMP),Y + LDY IPY + JMP DROP ;* ;* STORE VALUE TO ABSOLUTE ADDRESS WITHOUT POPPING STACK ;* -!IF SELFMODIFY { -DAB +INC_IP - LDA (IP),Y - STA DABSTA+1 - +INC_IP - LDA (IP),Y - STA DABSTA+2 - LDA ESTKL,X -DABSTA STA $FFFF - JMP NEXTOP +!IF SELFMODIFY { +DAB INY ;+INC_IP + LDA (IP),Y + STA DABSTA+1 + +INC_IP + LDA (IP),Y + STA DABSTA+2 + LDA ESTKL,X +DABSTA STA $FFFF + JMP NEXTOP } ELSE { -DAB +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDY #$00 - LDA ESTKL,X - STA (TMP),Y - LDY IPY - JMP NEXTOP +DAB INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + STY IPY + LDY #$00 + LDA ESTKL,X + STA (TMP),Y + LDY IPY + JMP NEXTOP } -DAW +INC_IP - LDA (IP),Y - STA TMPL - +INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDY #$00 - LDA ESTKL,X - STA (TMP),Y - INY - LDA ESTKH,X - STA (TMP),Y - LDY IPY - JMP NEXTOP +DAW INY ;+INC_IP + LDA (IP),Y + STA TMPL + +INC_IP + LDA (IP),Y + STA TMPH + STY IPY + LDY #$00 + LDA ESTKL,X + STA (TMP),Y + INY + LDA ESTKH,X + STA (TMP),Y + LDY IPY + JMP NEXTOP ;* ;* COMPARES ;* -ISEQ LDA ESTKL,X - CMP ESTKL+1,X - BNE ISFLS - LDA ESTKH,X - CMP ESTKH+1,X - BNE ISFLS -ISTRU LDA #$FF - STA ESTKL+1,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +ISEQ LDA ESTKL,X + CMP ESTKL+1,X + BNE ISFLS + LDA ESTKH,X + CMP ESTKH+1,X + BNE ISFLS +ISTRU LDA #$FF + STA ESTKL+1,X + STA ESTKH+1,X + JMP DROP ; -ISNE LDA ESTKL,X - CMP ESTKL+1,X - BNE ISTRU - LDA ESTKH,X - CMP ESTKH+1,X - BNE ISTRU -ISFLS LDA #$00 - STA ESTKL+1,X - STA ESTKH+1,X -; INX -; JMP NEXTOP - JMP DROP +ISNE LDA ESTKL,X + CMP ESTKL+1,X + BNE ISTRU + LDA ESTKH,X + CMP ESTKH+1,X + BNE ISTRU +ISFLS LDA #$00 + STA ESTKL+1,X + STA ESTKH+1,X + JMP DROP ; -ISGE LDA ESTKL+1,X - CMP ESTKL,X - LDA ESTKH+1,X - SBC ESTKH,X - BVC ISGE1 - EOR #$80 -ISGE1 BPL ISTRU - BMI ISFLS +ISGE LDA ESTKL+1,X + CMP ESTKL,X + LDA ESTKH+1,X + SBC ESTKH,X + BVC ISGE1 + EOR #$80 +ISGE1 BPL ISTRU + BMI ISFLS ; -ISGT LDA ESTKL,X - CMP ESTKL+1,X - LDA ESTKH,X - SBC ESTKH+1,X - BVC ISGT1 - EOR #$80 -ISGT1 BMI ISTRU - BPL ISFLS +ISGT LDA ESTKL,X + CMP ESTKL+1,X + LDA ESTKH,X + SBC ESTKH+1,X + BVC ISGT1 + EOR #$80 +ISGT1 BMI ISTRU + BPL ISFLS ; -ISLE LDA ESTKL,X - CMP ESTKL+1,X - LDA ESTKH,X - SBC ESTKH+1,X - BVC ISLE1 - EOR #$80 -ISLE1 BPL ISTRU - BMI ISFLS +ISLE LDA ESTKL,X + CMP ESTKL+1,X + LDA ESTKH,X + SBC ESTKH+1,X + BVC ISLE1 + EOR #$80 +ISLE1 BPL ISTRU + BMI ISFLS ; -ISLT LDA ESTKL+1,X - CMP ESTKL,X - LDA ESTKH+1,X - SBC ESTKH,X - BVC ISLT1 - EOR #$80 -ISLT1 BMI ISTRU - BPL ISFLS +ISLT LDA ESTKL+1,X + CMP ESTKL,X + LDA ESTKH+1,X + SBC ESTKH,X + BVC ISLT1 + EOR #$80 +ISLT1 BMI ISTRU + BPL ISFLS ;* ;* BRANCHES ;* BRTRU INX - LDA ESTKH-1,X - ORA ESTKL-1,X - BNE BRNCH -NOBRNCH +INC_IP - +INC_IP - JMP NEXTOP + LDA ESTKH-1,X + ORA ESTKL-1,X + BNE BRNCH +NOBRNCH INY ;+INC_IP + +INC_IP + JMP NEXTOP BRFLS INX - LDA ESTKH-1,X - ORA ESTKL-1,X - BNE NOBRNCH -BRNCH LDA IPH - STA TMPH - LDA IPL - +INC_IP - CLC - ADC (IP),Y - STA TMPL - LDA TMPH - +INC_IP - ADC (IP),Y - STA IPH - LDA TMPL - STA IPL - DEY - DEY - JMP NEXTOP + LDA ESTKH-1,X + ORA ESTKL-1,X + BNE NOBRNCH +BRNCH TYA ; FLATTEN IP + CLC + ADC IPL + STA TMPL + LDA #$00 + ADC IPH + STA TMPH ; ADD BRANCH OFFSET + INY + LDA (IP),Y + CLC + ADC TMPL + STA TMPL + INY + LDA (IP),Y + ADC TMPH + STA IPH + LDA TMPL + STA IPL + LDY #$01 + JMP FETCHOP BREQ INX - LDA ESTKL-1,X - CMP ESTKL,X - BNE NOBRNCH - LDA ESTKH-1,X - CMP ESTKH,X - BEQ BRNCH - BNE NOBRNCH + LDA ESTKL-1,X + CMP ESTKL,X + BNE NOBRNCH + LDA ESTKH-1,X + CMP ESTKH,X + BEQ BRNCH + BNE NOBRNCH BRNE INX - LDA ESTKL-1,X - CMP ESTKL,X - BNE BRNCH - LDA ESTKH-1,X - CMP ESTKH,X - BEQ NOBRNCH - BNE BRNCH + LDA ESTKL-1,X + CMP ESTKL,X + BNE BRNCH + LDA ESTKH-1,X + CMP ESTKH,X + BEQ NOBRNCH + BNE BRNCH BRGT INX - LDA ESTKL-1,X - CMP ESTKL,X - LDA ESTKH-1,X - SBC ESTKH,X - BPL NOBRNCH - BMI BRNCH + LDA ESTKL-1,X + CMP ESTKL,X + LDA ESTKH-1,X + SBC ESTKH,X + BPL NOBRNCH + BMI BRNCH BRLT INX - LDA ESTKL,X - CMP ESTKL-1,X - LDA ESTKH,X - SBC ESTKH-1,X - BPL NOBRNCH - BMI BRNCH -IBRNCH LDA IPL - CLC - ADC ESTKL,X - STA IPL - LDA IPH - ADC ESTKH,X - STA IPH -; INX -; JMP NEXTOP - JMP DROP + LDA ESTKL,X + CMP ESTKL-1,X + LDA ESTKH,X + SBC ESTKH-1,X + BPL NOBRNCH + BMI BRNCH +IBRNCH LDA IPL + CLC + ADC ESTKL,X + STA IPL + LDA IPH + ADC ESTKH,X + STA IPH + JMP DROP ;* ;* CALL INTO ABSOLUTE ADDRESS (NATIVE CODE) ;* -CALL +INC_IP - LDA (IP),Y - STA CALLADR+1 - +INC_IP - LDA (IP),Y - STA CALLADR+2 - TYA - CLC - ADC IPL - PHA - LDA IPH - ADC #$00 - PHA +CALL INY ;+INC_IP + LDA (IP),Y +!IF SELFMODIFY { + STA CALLADR+1 +} ELSE { + STA TMPL +} + INY ;+INC_IP + LDA (IP),Y +!IF SELFMODIFY { + STA CALLADR+2 +} ELSE { + STA TMPH +} + TYA + CLC + ADC IPL + PHA + LDA IPH + ADC #$00 + PHA +!IF SELFMODIFY { CALLADR JSR $FFFF - PLA - STA IPH - PLA - STA IPL - LDY #$00 - JMP NEXTOP +} ELSE { + JSR JMPTMP +} + PLA + STA IPH + PLA + STA IPL + LDY #$01 + JMP FETCHOP ;* ;* INDIRECT CALL TO ADDRESS (NATIVE CODE) ;* ICAL LDA ESTKL,X +!IF SELFMODIFY { STA ICALADR+1 +} ELSE { + STA TMPL +} LDA ESTKH,X +!IF SELFMODIFY { STA ICALADR+2 +} ELSE { + STA TMPH +} INX TYA CLC @@ -933,7 +917,11 @@ ICAL LDA ESTKL,X LDA IPH ADC #$00 PHA +!IF SELFMODIFY { ICALADR JSR $FFFF +} ELSE { + JSR JMPTMP +} PLA STA IPH PLA @@ -941,6 +929,10 @@ ICALADR JSR $FFFF LDY #$01 JMP FETCHOP ;* +;* JUMP INDIRECT TRHOUGH TMP +;* +JMPTMP JMP (TMP) +;* ;* ENTER FUNCTION WITH FRAME SIZE AND PARAM COUNT ;* ENTER INY @@ -969,7 +961,7 @@ ENTER INY ;* ;* LEAVE FUNCTION ;* -LEAVE +INC_IP +LEAVE INY ;+INC_IP LDA (IP),Y CLC ADC IFPL @@ -994,17 +986,14 @@ VMINIT LDY #$10 ; INSTALL PAGE 0 FETCHOP ROUTINE STA SRCH LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX JMP A1CMD -PAGE0 = * +PAGE0 = * !PSEUDOPC DROP { ;* ;* INTERP BYTECODE INNER LOOP ;* INX ; DROP INY ; NEXTOP - BEQ NEXTOPH LDA $FFFF,Y ; FETCHOP @ $F3, IP MAPS OVER $FFFF @ $F4 STA OPIDX JMP (OPTBL) -NEXTOPH INC IPH - BNE FETCHOP } diff --git a/src/vmsrc/plvm02.s b/src/vmsrc/plvm02.s index 94b46c0..884c08e 100755 --- a/src/vmsrc/plvm02.s +++ b/src/vmsrc/plvm02.s @@ -44,7 +44,6 @@ PSR = TMP+2 DVSIGN = PSR+1 DROP = $EF NEXTOP = $F0 -;FETCHOP = NEXTOP+3 FETCHOP = NEXTOP+1 IP = FETCHOP+1 IPL = IP @@ -372,12 +371,9 @@ PAGE0 = * !PSEUDOPC DROP { INX ; DROP @ $EF INY ; NEXTOP @ $F0 -; BEQ NEXTOPH LDA $FFFF,Y ; FETCHOP @ $F3, IP MAPS OVER $FFFF @ $F4 STA OPIDX JMP (OPTBL) ; OPIDX AND OPPAGE MAP OVER OPTBL -;NEXTOPH INC IPH -; BNE FETCHOP } PAGE3 = * ;* @@ -1333,13 +1329,13 @@ BRFLS INX LDA ESTKH-1,X ORA ESTKL-1,X BNE NOBRNCH -BRNCH TYA ; FLATTEN IP +BRNCH TYA ; FLATTEN IP CLC ADC IPL STA TMPL LDA #$00 ADC IPH - STA TMPH ; ADD BRANCH OFFSET + STA TMPH ; ADD BRANCH OFFSET INY LDA (IP),Y CLC diff --git a/src/vmsrc/plvm03.s b/src/vmsrc/plvm03.s index 8dec521..96e20f2 100755 --- a/src/vmsrc/plvm03.s +++ b/src/vmsrc/plvm03.s @@ -14,7 +14,7 @@ MEMBANK = $FFEF DVSIGN = TMP+2 DROP = $EF NEXTOP = $F0 -FETCHOP = NEXTOP+3 +FETCHOP = NEXTOP+1 IP = FETCHOP+1 IPL = IP IPH = IPL+1 @@ -44,8 +44,12 @@ DSTX = XPAGE+DSTH ;* !MACRO INC_IP { INY - BNE *+4 - INC IPH + BPL + + INC IPH + TYA + AND #$7F + TAY ++ } ;* ;* INTERPRETER HEADER+INITIALIZATION @@ -113,12 +117,9 @@ PAGE0 = * ;* INX ; DROP INY ; NEXTOP - BEQ NEXTOPH LDA $FFFF,Y ; FETCHOP @ $F3, IP MAPS OVER $FFFF @ $F4 STA OPIDX JMP (OPTBL) -NEXTOPH INC IPH - BNE FETCHOP } ;* ;* SYSTEM INTERPRETER ENTRYPOINT @@ -539,7 +540,7 @@ CB LDA #$00 ;* LA = * CW DEX - +INC_IP + INY ;+INC_IP LDA (IP),Y STA ESTKL,X +INC_IP @@ -550,7 +551,7 @@ CW DEX ;* CONSTANT STRING ;* CS DEX - +INC_IP + INY ;+INC_IP TYA ; NORMALIZE IP CLC ADC IPL @@ -695,7 +696,7 @@ LLW +INC_IP ;* LOAD VALUE FROM ABSOLUTE ADDRESS ;* !IF SELFMODIFY { -LAB +INC_IP +LAB INY ;+INC_IP LDA (IP),Y STA LABLDA+1 +INC_IP @@ -708,7 +709,7 @@ LABLDA LDA $FFFF STA ESTKH,X JMP NEXTOP } ELSE { -LAB +INC_IP +LAB INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -723,7 +724,7 @@ LAB +INC_IP LDY IPY JMP NEXTOP } -LAW +INC_IP +LAW INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -764,8 +765,6 @@ SB LDA ESTKL,X STA (TMP),Y LDY IPY INX -; INX -; JMP NEXTOP JMP DROP } SW LDA ESTKL,X @@ -781,8 +780,6 @@ SW LDA ESTKL,X STA (TMP),Y LDY IPY INX -; INX -; JMP NEXTOP JMP DROP ;* ;* STORE VALUE TO LOCAL FRAME OFFSET @@ -794,8 +791,6 @@ SLB +INC_IP LDA ESTKL,X STA (IFP),Y LDY IPY -; INX -; JMP NEXTOP JMP DROP SLW +INC_IP LDA (IP),Y @@ -807,8 +802,6 @@ SLW +INC_IP LDA ESTKH,X STA (IFP),Y LDY IPY -; INX -; JMP NEXTOP JMP DROP ;* ;* STORE VALUE TO LOCAL FRAME OFFSET WITHOUT POPPING STACK @@ -836,7 +829,7 @@ DLW +INC_IP ;* STORE VALUE TO ABSOLUTE ADDRESS ;* !IF SELFMODIFY { -SAB +INC_IP +SAB INY ;+INC_IP LDA (IP),Y STA SABSTA+1 +INC_IP @@ -844,11 +837,9 @@ SAB +INC_IP STA SABSTA+2 LDA ESTKL,X SABSTA STA $FFFF -; INX -; JMP NEXTOP JMP DROP } ELSE { -SAB +INC_IP +SAB INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -859,11 +850,9 @@ SAB +INC_IP LDY #$00 STA (TMP),Y LDY IPY -; INX -; JMP NEXTOP JMP DROP } -SAW +INC_IP +SAW INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -877,14 +866,12 @@ SAW +INC_IP LDA ESTKH,X STA (TMP),Y LDY IPY -; INX -; JMP NEXTOP JMP DROP ;* ;* STORE VALUE TO ABSOLUTE ADDRESS WITHOUT POPPING STACK ;* !IF SELFMODIFY { -DAB +INC_IP +DAB INY ;+INC_IP LDA (IP),Y STA DABSTA+1 +INC_IP @@ -894,7 +881,7 @@ DAB +INC_IP DABSTA STA $FFFF JMP NEXTOP } ELSE { -DAB +INC_IP +DAB INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -907,7 +894,7 @@ DAB +INC_IP LDY IPY JMP NEXTOP } -DAW +INC_IP +DAW INY ;+INC_IP LDA (IP),Y STA TMPL +INC_IP @@ -993,29 +980,33 @@ BRTRU INX LDA ESTKH-1,X ORA ESTKL-1,X BNE BRNCH -NOBRNCH +INC_IP +NOBRNCH INY ;+INC_IP +INC_IP JMP NEXTOP BRFLS INX LDA ESTKH-1,X ORA ESTKL-1,X BNE NOBRNCH -BRNCH LDA IPH - STA TMPH - LDA IPL - +INC_IP +BRNCH TYA ; FLATTEN IP CLC - ADC (IP),Y + ADC IPL STA TMPL - LDA TMPH - +INC_IP - ADC (IP),Y + LDA #$00 + ADC IPH + STA TMPH ; ADD BRANCH OFFSET + INY + LDA (IP),Y + CLC + ADC TMPL + STA TMPL + INY + LDA (IP),Y + ADC TMPH STA IPH LDA TMPL STA IPL - DEY - DEY - JMP NEXTOP + LDY #$01 + JMP FETCHOP BREQ INX LDA ESTKL-1,X CMP ESTKL,X @@ -1059,10 +1050,10 @@ IBRNCH LDA IPL ;* ;* CALL INTO ABSOLUTE ADDRESS (NATIVE CODE) ;* -CALL +INC_IP +CALL INY ;+INC_IP LDA (IP),Y STA CALLADR+1 - +INC_IP + INY ;+INC_IP LDA (IP),Y STA CALLADR+2 TYA @@ -1146,7 +1137,7 @@ ENTER LDA IFPH ;* ;* LEAVE FUNCTION ;* -LEAVE +INC_IP +LEAVE INY ;+INC_IP LDA (IP),Y CLC ADC IFPL diff --git a/src/vmsrc/plvm802.s b/src/vmsrc/plvm802.s index 1b71cdb..479378f 100644 --- a/src/vmsrc/plvm802.s +++ b/src/vmsrc/plvm802.s @@ -55,7 +55,7 @@ PSR = TMP+2 HWSP = PSR+1 DROP = $EF NEXTOP = DROP+1 -FETCHOP = NEXTOP+3 +FETCHOP = NEXTOP+1 IP = FETCHOP+1 IPL = IP IPH = IPL+1 @@ -76,10 +76,11 @@ NOS = $03 ; TOS-1 ;* !MACRO INC_IP { INY - BNE + - LDX IPH - INX - STX IPH + BPL + + INC IPH + TYA + AND #$7F + TAY + } ;* @@ -468,13 +469,8 @@ PAGE0 = * !PSEUDOPC DROP { PLA ; DROP @ $EF INY ; NEXTOP @ $F0 - BEQ NEXTOPH LDX $FFFF,Y ; FETCHOP @ $F3, IP MAPS OVER $FFFF @ $F4 JMP (OPTBL,X) ; OPIDX AND OPPAGE MAP OVER OPTBL -NEXTOPH LDX IPH - INX - STX IPH - BRA FETCHOP } PAGE3 = * ;* @@ -782,15 +778,15 @@ CB +INC_IP ;* LOAD ADDRESS & LOAD CONSTANT WORD (SAME THING, WITH OR WITHOUT FIXUP) ;* LA = * -CW +INC_IP +CW INY ;+INC_IP LDA (IP),Y - +INC_IP PHA + +INC_IP JMP NEXTOP ;* ;* CONSTANT STRING ;* -CS +INC_IP +CS INY ;+INC_IP TYA ; NORMALIZE IP AND SAVE STRING ADDR ON ESTK CLC ADC IP @@ -800,7 +796,7 @@ CS +INC_IP TAY JMP NEXTOP ; -CSX +INC_IP +CSX INY ;+INC_IP TYA ; NORMALIZE IP CLC ADC IP @@ -968,49 +964,48 @@ LLWX +INC_IP ;* LOAD VALUE FROM ABSOLUTE ADDRESS ;* !IF SELFMODIFY { -LAB +INC_IP +LAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA LABLDX+1 LABLDX LDX $FFFF TXA PHA + +INC_IP JMP NEXTOP } ELSE { -LAB +INC_IP +LAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP TYA ; QUICKY CLEAR OUT MSB +ACCMEM8 ; 8 BIT A/M LDA (TMP) +ACCMEM16 ; 16 BIT A/M PHA + +INC_IP JMP NEXTOP } -LAW +INC_IP +LAW INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP LDA (TMP) PHA + +INC_IP JMP NEXTOP ; !IF SELFMODIFY { -LABX +INC_IP +LABX INY ;+INC_IP LDA (IP),Y - +INC_IP STA LABXLDX+1 STX ALTRDOFF LABXLDX LDX $FFFF STX ALTRDON TXA PHA + +INC_IP JMP NEXTOP } ELSE { -LABX +INC_IP +LABX INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP TYA ; QUICKY CLEAR OUT MSB STX ALTRDOFF @@ -1019,16 +1014,17 @@ LABX +INC_IP +ACCMEM16 ; 16 BIT A/M STX ALTRDON PHA + +INC_IP JMP NEXTOP } -LAWX +INC_IP +LAWX INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP STX ALTRDOFF LDA (TMP) STX ALTRDON PHA + +INC_IP JMP NEXTOP ; ;* @@ -1132,61 +1128,61 @@ DLW +INC_IP ;* STORE VALUE TO ABSOLUTE ADDRESS ;* !IF SELFMODIFY { -SAB +INC_IP +SAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA SABSTX+1 PLA TAX SABSTX STX $FFFF + +INC_IP JMP NEXTOP } ELSE { -SAB +INC_IP +SAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP PLA +ACCMEM8 ; 8 BIT A/M STA (TMP) +ACCMEM16 ; 16 BIT A/M + +INC_IP JMP NEXTOP } -SAW +INC_IP +SAW INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP PLA STA (TMP) + +INC_IP JMP NEXTOP ;* ;* STORE VALUE TO ABSOLUTE ADDRESS WITHOUT POPPING STACK ;* !IF SELFMODIFY { -DAB +INC_IP +DAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA DABSTX+1 LDA TOS,S TAX DABSTX STX $FFFF + +INC_IP JMP NEXTOP } ELSE { -DAB +INC_IP +DAB INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP +ACCMEM8 ; 8 BIT A/M LDA TOS,S STA (TMP) +ACCMEM16 ; 16 BIT A/M + +INC_IP JMP NEXTOP } -DAW +INC_IP +DAW INY ;+INC_IP LDA (IP),Y - +INC_IP STA TMP LDA TOS,S STA (TMP) + +INC_IP JMP NEXTOP ;* ;* COMPARES @@ -1249,18 +1245,20 @@ ISLT PLA ;* BRTRU PLA BNE BRNCH -NOBRNCH +INC_IP +NOBRNCH INY ;+INC_IP +INC_IP JMP NEXTOP BRFLS PLA BNE NOBRNCH -BRNCH LDA IP - +INC_IP +BRNCH TYA ; FLATTEN IP CLC + ADC IP + INY ;+INC_IP + CLC ; ADD BRANCH OFFSET ADC (IP),Y STA IP - DEY - JMP NEXTOP + LDY #$01 + JMP FETCHOP BREQ PLA CMP TOS,S BEQ BRNCH @@ -1295,7 +1293,7 @@ IBRNCH PLA ;* ;* CALL INTO ABSOLUTE ADDRESS (NATIVE CODE) ;* -CALL +INC_IP +CALL INY ;+INC_IP LDA (IP),Y INY BNE EMUSTK @@ -1411,7 +1409,7 @@ EMUSTK STA TMP ;* ;* CALL INTO ABSOLUTE ADDRESS (NATIVE CODE) ;* -CALLX +INC_IP +CALLX INY ;+INC_IP LDA (IP),Y INY BNE EMUSTKX @@ -1575,12 +1573,12 @@ ENTER PEI (IFP) ; SAVE ON STACK FOR LEAVE ;* ;* LEAVE FUNCTION ;* -LEAVEX +INC_IP +LEAVEX INY ;+INC_IP +ACCMEM8 ; 8 BIT A/M LDA (IP),Y ; DEALLOCATE POOL + FRAME STA ALTRDOFF BRA + -LEAVE +INC_IP +LEAVE INY ;+INC_IP +ACCMEM8 ; 8 BIT A/M LDA (IP),Y ; DEALLOCATE POOL + FRAME + STA TMPL