From 3a6c77a4eb8b230b47fb90a5472683fd06d40131 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 13 Apr 2018 12:09:14 -0700 Subject: [PATCH] Simplify VM configurations and auto-load alternative VMs --- src/libsrc/apple/jit16.pla | 1 + src/makefile | 6 +- src/vmsrc/apple/cmd.pla | 106 +--- src/vmsrc/apple/cmdjit.pla | 8 +- src/vmsrc/apple/cmdjitstub.s | 27 +- src/vmsrc/apple/cmdstub.s | 76 +-- src/vmsrc/apple/plvm02.s | 1012 +++------------------------------- src/vmsrc/apple/plvm802.s | 22 +- src/vmsrc/apple/plvmjit02.s | 25 +- 9 files changed, 178 insertions(+), 1105 deletions(-) diff --git a/src/libsrc/apple/jit16.pla b/src/libsrc/apple/jit16.pla index d3839a0..37e7ce1 100644 --- a/src/libsrc/apple/jit16.pla +++ b/src/libsrc/apple/jit16.pla @@ -47,5 +47,6 @@ fin *jitcomp = @compiler cmdsys.jitcount = 44 cmdsys.jitsize = 96 +puts("16 BIT VM/JITC enabled.\n") return modkeep done diff --git a/src/makefile b/src/makefile index 692e4e3..8a76ceb 100755 --- a/src/makefile +++ b/src/makefile @@ -4,12 +4,12 @@ PLVM = plvm PLVMZP_APL = vmsrc/apple/plvmzp.inc PLVM01 = rel/apple/A1PLASMA\#060280 PLVM02 = rel/apple/PLASMA.SYSTEM\#FF2000 -PLVMJIT = rel/apple/PLASMAJIT.SYSTEM\#FF2000 -PLVM802 = rel/apple/PLASMA16.SYSTEM\#FF2000 +PLVMJIT = rel/apple/PLVM-128\#FF2000 +PLVM802 = rel/apple/PLVM16\#FF2000 PLVM03 = rel/apple/SOS.INTERP\#050000 SOSCMD = rel/apple/SOS.CMD\#FE1000 CMD = rel/apple/CMD\#061000 -CMDJIT = rel/apple/CMDJIT\#061000 +CMDJIT = rel/apple/CMD128\#061000 PLVMZP_C64 = vmsrc/c64/plvmzp.inc PLVMC64 = rel/c64/PLASMA ED = rel/ED\#FE1000 diff --git a/src/vmsrc/apple/cmd.pla b/src/vmsrc/apple/cmd.pla index 300a185..78fb73b 100755 --- a/src/vmsrc/apple/cmd.pla +++ b/src/vmsrc/apple/cmd.pla @@ -931,39 +931,6 @@ def releaseheap(newheap)#1 heap = newheap return @newheap - heap end -def allocxheap(size)#1 - word xaddr - xaddr = xheap - xheap = xheap + size - if systemflags & restxt1 - if uword_isle(xaddr, $0800) and uword_isgt(xheap, $0400) - xaddr = $0800 - xheap = xaddr + size - fin - fin - if systemflags & restxt2 - if uword_isle(xaddr, $0C00) and uword_isgt(xheap, $0800) - xaddr = $0C00 - xheap = xaddr + size - fin - fin - if systemflags & resxhgr1 - if uword_isle(xaddr, $4000) and uword_isgt(xheap, $2000) - xaddr = $4000 - xheap = xaddr + size - fin - fin - if systemflags & resxhgr2 - if uword_isle(xaddr, $6000) and uword_isgt(xheap, $4000) - xaddr = $6000 - xheap = xaddr + size - fin - fin - if uword_isge(xheap, $BF00) - return 0 - fin - return xaddr -end // // Symbol table routines. // @@ -1009,12 +976,12 @@ def lookupextern(esd, index)#1 fin return 0 end -def adddef(bank, addr, deflast)#1 +def adddef(addr, deflast)#1 word defentry defentry = *deflast *deflast = defentry + 5 defentry->0 = $20 - defentry=>1 = bank ?? $03DC :: $03D6 // JSR $03DC (AUX MEM INTERP) or $03D6 (MAIN MEM INTERP) + defentry=>1 = $03D6 defentry=>3 = addr defentry->5 = 0 // NULL out next entry return defentry @@ -1024,7 +991,7 @@ def loadmod(mod)#1 word addr, defaddr, modaddr, modfix, modofst, modend word deftbl, deflast word moddep, rld, esd, sym - byte refnum, defbank, filename[64], str[] + byte refnum, filename[64], str[] byte header[128] // // Read the RELocatable module header (first 128 bytes) @@ -1121,17 +1088,7 @@ def loadmod(mod)#1 esd = esd + 4 loop esd = esd + 1 - // - // Locate bytecode defs in appropriate bank. - // - if ^MACHID & $30 == $30 - defbank = 1 - defaddr = allocxheap(rld - bytecode) - modend = bytecode - else - defbank = 0 - defaddr = bytecode - fin + defaddr = bytecode codefix = defaddr - bytecode defofst = defaddr - defofst // @@ -1141,7 +1098,7 @@ def loadmod(mod)#1 // // This is a bytcode def entry - add it to the def directory. // - adddef(defbank, rld=>1 + defofst, @deflast) + adddef(rld=>1 + defofst, @deflast) rld = rld + 4 loop // @@ -1153,31 +1110,6 @@ def loadmod(mod)#1 *addr = ^rld & $10 ?? *addr + lookupextern(esd, rld->3) :: lookupdef(fixup + codefix, deftbl) rld = rld + 4 fin - //addr = rld=>1 + modfix - //if uword_isge(addr, modaddr) // Skip fixups to header - // if type & $80 // WORD sized fixup. - // fixup = *addr - // else // BYTE sized fixup. - // fixup = ^addr - // fin - // if ^rld & $10 // EXTERN reference. - // fixup = fixup + lookupextern(esd, rld->3) - // else // INTERN fixup. - // fixup = fixup + modofst - // if uword_isge(fixup, bytecode) - // // - // // Bytecode address - replace with call def directory. - // // - // fixup = lookupdef(fixup + codefix, deftbl) - // fin - // fin - // if type & $80 // WORD sized fixup. - // *addr = fixup - // else // BYTE sized fixup. - // ^addr = fixup - // fin - //fin - //rld = rld + 4 loop // // Run through the External/Entry Symbol Directory. @@ -1200,15 +1132,6 @@ def loadmod(mod)#1 fin esd = esd + 3 loop - if defbank - // - // Move bytecode to AUX bank. - // - *$003C = bytecode - *$003E = modaddr + modsize - *$0042 = defaddr - call($C311, 0, 0, 0, $05) // CALL XMOVE with carry set (MAIN->AUX) and ints disabled - fin else perr = $46 fin @@ -1216,7 +1139,7 @@ def loadmod(mod)#1 return -perr fin // - // Free up rld+esd (and bytecode on 128K) in main memory. + // Free up rld+esd in main memory. // releaseheap(modend) // @@ -1225,19 +1148,12 @@ def loadmod(mod)#1 fixup = 0 // This is repurposed for the return code if init init = init + defofst - fixup = adddef(defbank, init, @deflast)() + fixup = adddef(init, @deflast)() if fixup < modinitkeep // // Free init routine unless initkeep // - if defbank - xheap = init - else - // - // Free up init code in main memory. - // - releaseheap(init) - fin + releaseheap(init) if fixup < 0 perr = -fixup fin @@ -1366,6 +1282,9 @@ def parsecmd(strptr)#1 return cmd end def resetmemfiles()#0 + byte terr + + terr = perr // Save perr // // Close all files // @@ -1377,6 +1296,7 @@ def resetmemfiles()#0 memset($BF58, 0, 24) ^$BF58 = $CF ^$BF6F = $01 + perr = terr // Restore perr end def execsys(sysfile)#0 byte refnum @@ -1430,7 +1350,7 @@ heap = *freemem // // Print PLASMA version // -prstr("PLASMA 2.0 Dev\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout +prstr("PLASMA 64K 2.0 Dev\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout // // Init symbol table. // diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla index 442bf2d..ee5f38b 100755 --- a/src/vmsrc/apple/cmdjit.pla +++ b/src/vmsrc/apple/cmdjit.pla @@ -1346,6 +1346,9 @@ def parsecmd(strptr)#1 return cmd end def resetmemfiles()#0 + byte terr + + terr = perr // Save perr // // Close all files // @@ -1357,6 +1360,7 @@ def resetmemfiles()#0 memset($BF58, 0, 24) ^$BF58 = $CF ^$BF6F = $01 + perr = terr // Restore perr end def execsys(sysfile)#0 byte refnum @@ -1412,7 +1416,7 @@ heap = *freemem // // Print PLASMA version // -prstr("PLASMA JITC 2.0 Dev\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout +prstr("PLASMA 128K 2.0 Dev\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout // // Init symbol table. // @@ -1428,7 +1432,7 @@ strcat(strcpy(@sysmods, $280), "SYS/")) // This is the path to CMD syspath = @sysmods // Update external interface table syscmdln = @cmdln loadmod(jitmod) -xheap = $0800 // Reset heap to point at low memory +xheap = $0400 // Reset heap to point at low memory xheaptop = $A000 // Top where JIT loaded // // Try to load autorun. diff --git a/src/vmsrc/apple/cmdjitstub.s b/src/vmsrc/apple/cmdjitstub.s index 8e926dd..483d4bb 100644 --- a/src/vmsrc/apple/cmdjitstub.s +++ b/src/vmsrc/apple/cmdjitstub.s @@ -1,12 +1,12 @@ -INTERP = $03D0 -LCRDEN = $C080 -LCWTEN = $C081 -ROMEN = $C082 -LCRWEN = $C083 -LCBNK2 = $00 -LCBNK1 = $08 -JITCOMP = $03E2 -JITCODE = $03E4 +INTERP = $03D0 +LCRDEN = $C080 +LCWTEN = $C081 +ROMEN = $C082 +LCRWEN = $C083 +LCBNK2 = $00 +LCBNK1 = $08 +JITCOMP = $03E2 +JITCODE = $03E4 !SOURCE "vmsrc/plvmzp.inc" ;* ;* MOVE CMD DOWN TO $1000-$2000 @@ -25,7 +25,7 @@ JITCODE = $03E4 BNE - INC SRCH INC DSTH - DEX ; STOP WHEN DST=$2000 REACHED + DEX ; STOP WHEN DST=$2000 REACHED BNE - LDA #<_CMDEND STA SRCL @@ -34,11 +34,11 @@ JITCODE = $03E4 ; ; INIT VM ENVIRONMENT STACK POINTERS ; + STY PPL + STY IFPL ; INIT FRAME POINTER = $AF00 (4K FOR JIT CODE) + STY JITCODE STY JITCOMP STY JITCOMP+1 - STY PPL - STY IFPL ; INIT FRAME POINTER - STY JITCODE LDA #$AF STA PPH STA IFPH @@ -46,7 +46,6 @@ JITCODE = $03E4 LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS) TXS LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX - JMP $1000 _CMDBEGIN = * !PSEUDOPC $1000 { diff --git a/src/vmsrc/apple/cmdstub.s b/src/vmsrc/apple/cmdstub.s index deae3cc..ff00909 100644 --- a/src/vmsrc/apple/cmdstub.s +++ b/src/vmsrc/apple/cmdstub.s @@ -1,48 +1,48 @@ -INTERP = $03D0 -LCRDEN = $C080 -LCWTEN = $C081 -ROMEN = $C082 -LCRWEN = $C083 -LCBNK2 = $00 -LCBNK1 = $08 +INTERP = $03D0 +LCRDEN = $C080 +LCWTEN = $C081 +ROMEN = $C082 +LCRWEN = $C083 +LCBNK2 = $00 +LCBNK1 = $08 !SOURCE "vmsrc/plvmzp.inc" ;* ;* MOVE CMD DOWN TO $1000-$2000 ;* - LDA #<_CMDBEGIN - STA SRCL - LDA #>_CMDBEGIN - STA SRCH - LDY #$00 - STY DSTL - LDX #$10 - STX DSTH -- LDA (SRC),Y - STA (DST),Y - INY - BNE - - INC SRCH - INC DSTH - DEX ; STOP WHEN DST=$2000 REACHED - BNE - - LDA #<_CMDEND - STA SRCL - LDA #>_CMDEND - STA SRCH + LDA #<_CMDBEGIN + STA SRCL + LDA #>_CMDBEGIN + STA SRCH + LDY #$00 + STY DSTL + LDX #$10 + STX DSTH +- LDA (SRC),Y + STA (DST),Y + INY + BNE - + INC SRCH + INC DSTH + DEX ; STOP WHEN DST=$2000 REACHED + BNE - + LDA #<_CMDEND + STA SRCL + LDA #>_CMDEND + STA SRCH ; ; INIT VM ENVIRONMENT STACK POINTERS ; - STY PPL - STY IFPL ; INIT FRAME POINTER - LDA #$BF - STA PPH - STA IFPH - LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS) - TXS - LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX - JMP $1000 + STY PPL + STY IFPL ; INIT FRAME POINTER = $BF00 + LDA #$BF + STA PPH + STA IFPH + LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS) + TXS + LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX + JMP $1000 _CMDBEGIN = * - !PSEUDOPC $1000 { - !SOURCE "vmsrc/apple/cmd.a" + !PSEUDOPC $1000 { + !SOURCE "vmsrc/apple/cmd.a" _CMDEND = * } diff --git a/src/vmsrc/apple/plvm02.s b/src/vmsrc/apple/plvm02.s index abb60cb..cf61fbb 100755 --- a/src/vmsrc/apple/plvm02.s +++ b/src/vmsrc/apple/plvm02.s @@ -1,11 +1,10 @@ ;********************************************************** ;* -;* APPLE ][ 64K/128K PLASMA INTERPRETER +;* APPLE ][ 64K PLASMA INTERPRETER ;* ;* SYSTEM ROUTINES AND LOCATIONS ;* ;********************************************************** - !CPU 65C02 ;* ;* MONITOR SPECIAL LOCATIONS ;* @@ -16,11 +15,7 @@ PROMPT = $33 ;* PRODOS ;* PRODOS = $BF00 -DEVCNT = $BF31 ; GLOBAL PAGE DEVICE COUNT -DEVLST = $BF32 ; GLOBAL PAGE DEVICE LIST MACHID = $BF98 ; GLOBAL PAGE MACHINE ID BYTE -RAMSLOT = $BF26 ; SLOT 3, DRIVE 2 IS /RAM'S DRIVER VECTOR -NODEV = $BF10 ;* ;* HARDWARE ADDRESSES ;* @@ -33,12 +28,6 @@ ROMEN = $C082 LCRWEN = $C083 LCBNK2 = $00 LCBNK1 = $08 -ALTZPOFF= $C008 -ALTZPON = $C009 -ALTRDOFF= $C002 -ALTRDON = $C003 -ALTWROFF= $C004 -ALTWRON = $C005 !SOURCE "vmsrc/plvmzp.inc" PSR = TMP+2 DVSIGN = PSR+1 @@ -58,47 +47,23 @@ INTERP = $03D0 ;* * ;****************************** * = $2000 - LDX #$FE - TXS - LDX #$00 - STX $01FF ;* -;* DISCONNECT /RAM +;* CHECK FOR ALTERNTATIVE VM IMPEMENTATIONS ;* - ;SEI ; DISABLE /RAM - LDA MACHID + LDA MACHID ; CHECK FOR 128K AND #$30 CMP #$30 - BNE RAMDONE - LDA RAMSLOT - CMP NODEV - BNE RAMCONT - LDA RAMSLOT+1 - CMP NODEV+1 - BEQ RAMDONE -RAMCONT LDY DEVCNT -RAMLOOP LDA DEVLST,Y - AND #$F3 - CMP #$B3 - BEQ GETLOOP - DEY - BPL RAMLOOP - BMI RAMDONE -GETLOOP LDA DEVLST+1,Y - STA DEVLST,Y - BEQ RAMEXIT + BNE + + LDY #$00 +- LDA ALTVM,Y + STA $1000,Y INY - BNE GETLOOP -RAMEXIT LDA NODEV - STA RAMSLOT - LDA NODEV+1 - STA RAMSLOT+1 - DEC DEVCNT -RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE + BNE - + JSR $1000 ; TRY AND LOAD ALT VM ;* ;* MOVE VM INTO LANGUAGE CARD ;* - BIT LCRWEN+LCBNK2 ++ BIT LCRWEN+LCBNK2 BIT LCRWEN+LCBNK2 LDA #ENTER64 - STA OPTBL+$59 - LDA #LEAVE64 - STA OPTBL+$5B -;* ;* SAVE DEFAULT COMMAND INTERPRETER PATH IN LC ;* + JSR PRODOS ; GET PREFIX @@ -205,7 +145,19 @@ OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 !WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 90 92 94 96 98 9A 9C 9E !WORD BRGT,BRLT,INCBRLE,ADDBRLE,DECBRGE,SUBBRGE,BRAND,BROR ; A0 A2 A4 A6 A8 AA AC AE !WORD ADDLB,ADDLW,ADDAB,ADDAW,IDXLB,IDXLW,IDXAB,IDXAW ; B0 B2 B4 B6 B8 BA BC BE + !WORD NATV ; C0 ;* +;* DIRECTLY ENTER INTO BYTECODE INTERPRETER +;* +DINTRP PLA + CLC + ADC #$01 + STA IPL + PLA + ADC #$00 + STA IPH + LDY #$00 + JMP FETCHOP ;* ;* INDIRECTLY ENTER INTO BYTECODE INTERPRETER ;* @@ -220,27 +172,6 @@ IINTRP PLA LDA (TMP),Y STA IPL DEY -+ LDA #>OPTBL - STA OPPAGE - JMP FETCHOP -IINTRPX PHP - PLA - STA PSR - SEI - PLA - STA TMPL - PLA - STA TMPH - LDY #$02 - LDA (TMP),Y - STA IPH - DEY - LDA (TMP),Y - STA IPL - DEY - LDA #>OPXTBL - STA OPPAGE - STA ALTRDON JMP FETCHOP ;************************************************************ ;* * @@ -287,7 +218,7 @@ CMDENTRY = * ; ; INSTALL PAGE 3 VECTORS ; - LDY #$12 + LDY #$0C - LDA PAGE3,Y STA INTERP,Y DEY @@ -381,46 +312,11 @@ PAGE3 = * JMP DINTRP BIT LCRDEN+LCBNK2 ; $03D6 - INDIRECT INTERP ENTRY JMP IINTRP - BIT LCRDEN+LCBNK2 ; $03DC - INDIRECT INTERPX ENTRY - JMP IINTRPX } DEFCMD = * ;!FILL 28 ENDBYE = * } LCDEFCMD = * ;*-28 ; DEFCMD IN LC MEMORY -;***************** -;* * -;* OPXCODE TABLE * -;* * -;***************** - !ALIGN 255,0 -OPXTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E - !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E - !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CSX ; 20 22 24 26 28 2A 2C 2E - !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 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,SEL,CALLX,ICALX,ENTER,LEAVEX,RETX,CFFB ; 50 52 54 56 58 5A 5C 5E - !WORD LBX,LWX,LLBX,LLWX,LABX,LAWX,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 LNOT,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 80 82 84 86 88 8A 8C 8E - !WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 90 92 94 96 98 9A 9C 9E - !WORD BRGT,BRLT,INCBRLE,ADDBRLE,DECBRGE,SUBBRGE,BRAND,BROR ; A0 A2 A4 A6 A8 AA AC AE - !WORD ADDLBX,ADDLWX,ADDABX,ADDAWX,IDXLBX,IDXLWX,IDXABX,IDXAWX ; B0 B2 B4 B6 B8 BA BC BE -;* -;* -;* DIRECTLY ENTER INTO BYTECODE INTERPRETER -;* -DINTRP PLA - CLC - ADC #$01 - STA IPL - PLA - ADC #$00 - STA IPH - LDY #$00 - LDA #>OPTBL - STA OPPAGE - JMP FETCHOP ;* ;* ADD TOS TO TOS-1 ;* @@ -822,76 +718,6 @@ CS DEX LDA (IP),Y TAY JMP NEXTOP -CSX DEX - ;INY ;+INC_IP - TYA ; NORMALIZE IP - SEC - ADC IPL - STA IPL - LDA #$00 - TAY - ADC IPH - STA IPH - LDA PPL ; SCAN POOL FOR STRING ALREADY THERE - STA TMPL - LDA PPH - STA TMPH -_CMPPSX ;LDA TMPH ; CHECK FOR END OF POOL - CMP IFPH - BCC _CMPSX ; CHECK FOR MATCHING STRING - BNE _CPYSX ; BEYOND END OF POOL, COPY STRING OVER - LDA TMPL - CMP IFPL - BCS _CPYSX ; AT OR BEYOND END OF POOL, COPY STRING OVER -_CMPSX STA ALTRDOFF - LDA (TMP),Y ; COMPARE STRINGS FROM AUX MEM TO STRINGS IN MAIN MEM - STA ALTRDON - CMP (IP),Y ; COMPARE STRING LENGTHS - BNE _CNXTSX1 - TAY -_CMPCSX STA ALTRDOFF - LDA (TMP),Y ; COMPARE STRING CHARS FROM END - STA ALTRDON - CMP (IP),Y - BNE _CNXTSX - DEY - BNE _CMPCSX - LDA TMPL ; MATCH - SAVE EXISTING ADDR ON ESTK AND MOVE ON - STA ESTKL,X - LDA TMPH - STA ESTKH,X - BNE _CEXSX -_CNXTSX LDY #$00 - STA ALTRDOFF - LDA (TMP),Y - STA ALTRDON -_CNXTSX1 SEC - ADC TMPL - STA TMPL - LDA #$00 - ADC TMPH - STA TMPH - BNE _CMPPSX -_CPYSX LDA (IP),Y ; COPY STRING FROM AUX TO MAIN MEM POOL - TAY ; MAKE ROOM IN POOL AND SAVE ADDR ON ESTK - EOR #$FF - CLC - ADC PPL - STA PPL - STA ESTKL,X - LDA #$FF - ADC PPH - STA PPH - STA ESTKH,X ; COPY STRING FROM AUX MEM BYTECODE TO MAIN MEM POOL -_CPYSX1 LDA (IP),Y ; ALTRD IS ON, NO NEED TO CHANGE IT HERE - STA (PP),Y ; ALTWR IS OFF, NO NEED TO CHANGE IT HERE - DEY - CPY #$FF - BNE _CPYSX1 - INY -_CEXSX LDA (IP),Y ; SKIP TO NEXT OP ADDR AFTER STRING - TAY - JMP NEXTOP ;* ;* LOAD VALUE FROM ADDRESS TAG ;* @@ -915,31 +741,6 @@ LW LDA ESTKL,X LDA (ESTKH-1,X) STA ESTKH,X JMP NEXTOP -LBX LDA ESTKL,X - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-1,X) - STA ESTKL,X - LDA #$00 - STA ESTKH,X - STA ALTRDON - JMP NEXTOP -LWX LDA ESTKL,X - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-1,X) - STA ESTKL,X - INC ESTKH-1,X - BEQ + - LDA (ESTKH-1,X) - STA ESTKH,X - STA ALTRDON - JMP NEXTOP -+ INC ESTKH,X - LDA (ESTKH-1,X) - STA ESTKH,X - STA ALTRDON - JMP NEXTOP ;* ;* LOAD ADDRESS OF LOCAL FRAME OFFSET ;* @@ -987,33 +788,6 @@ LLW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -LLBX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - STA ALTRDOFF - LDA (IFP),Y - STA ESTKL,X - LDA #$00 - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP -LLWX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - STA ALTRDOFF - LDA (IFP),Y - STA ESTKL,X - INY - LDA (IFP),Y - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* ADD VALUE FROM LOCAL FRAME OFFSET ;* @@ -1029,20 +803,6 @@ ADDLB INY ;+INC_IP INC ESTKH,X + LDY IPY JMP NEXTOP -ADDLBX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - STA ALTRDOFF - LDA (IFP),Y - CLC - ADC ESTKL,X - STA ESTKL,X - BCC + - INC ESTKH,X -+ STA ALTRDON - LDY IPY - JMP NEXTOP ADDLW INY ;+INC_IP LDA (IP),Y STY IPY @@ -1057,22 +817,6 @@ ADDLW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -ADDLWX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - STA ALTRDOFF - LDA (IFP),Y - CLC - ADC ESTKL,X - STA ESTKL,X - INY - LDA (IFP),Y - ADC ESTKH,X - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* INDEX VALUE FROM LOCAL FRAME OFFSET ;* @@ -1093,25 +837,6 @@ IDXLB INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -IDXLBX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - STA ALTRDOFF - LDA (IFP),Y - LDY #$00 - ASL - BCC + - INY - CLC -+ ADC ESTKL,X - STA ESTKL,X - TYA - ADC ESTKH,X - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP IDXLW INY ;+INC_IP LDA (IP),Y STY IPY @@ -1132,28 +857,6 @@ IDXLW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -IDXLWX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - STA ALTRDOFF - LDA (IFP),Y - ASL - STA TMPL - INY - LDA (IFP),Y - ROL - STA TMPH - LDA TMPL - CLC - ADC ESTKL,X - STA ESTKL,X - LDA TMPH - ADC ESTKH,X - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* LOAD VALUE FROM ABSOLUTE ADDRESS ;* @@ -1185,38 +888,6 @@ LAW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -LABX INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-2,X) - DEX - STA ESTKL,X - LDA #$00 - STA ESTKH,X - STA ALTRDON - JMP NEXTOP -LAWX INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - STY IPY - STA ALTRDOFF - LDY #$00 - LDA (TMP),Y - DEX - STA ESTKL,X - INY - LDA (TMP),Y - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* ADD VALUE FROM ABSOLUTE ADDRESS ;* @@ -1233,21 +904,6 @@ ADDAB INY ;+INC_IP BCC + INC ESTKH,X + JMP NEXTOP -ADDABX INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-2,X) - CLC - ADC ESTKL,X - STA ESTKL,X - BCC + - INC ESTKH,X -+ STA ALTRDON - JMP NEXTOP ADDAW INY ;+INC_IP LDA (IP),Y STA SRCL @@ -1266,26 +922,6 @@ ADDAW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -ADDAWX INY ;+INC_IP - LDA (IP),Y - STA SRCL - INY ;+INC_IP - LDA (IP),Y - STA SRCH - STY IPY - STA ALTRDOFF - LDY #$00 - LDA (SRC),Y - CLC - ADC ESTKL,X - STA ESTKL,X - INY - LDA (SRC),Y - ADC ESTKH,X - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* INDEX VALUE FROM ABSOLUTE ADDRESS ;* @@ -1309,28 +945,6 @@ IDXAB INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -IDXABX INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-2,X) - STY IPY - LDY #$00 - ASL - BCC + - INY - CLC -+ ADC ESTKL,X - STA ESTKL,X - TYA - ADC ESTKH,X - STA ESTKH,X - LDY IPY - STA ALTRDON - JMP NEXTOP IDXAW INY ;+INC_IP LDA (IP),Y STA SRCL @@ -1355,32 +969,6 @@ IDXAW INY ;+INC_IP STA ESTKH,X LDY IPY JMP NEXTOP -IDXAWX INY ;+INC_IP - LDA (IP),Y - STA SRCL - INY ;+INC_IP - LDA (IP),Y - STA SRCH - STY IPY - STA ALTRDOFF - LDY #$00 - LDA (SRC),Y - ASL - STA TMPL - INY - LDA (SRC),Y - ROL - STA TMPH - LDA TMPL - CLC - ADC ESTKL,X - STA ESTKL,X - LDA TMPH - ADC ESTKH,X - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP ;* ;* STORE VALUE TO ADDRESS ;* @@ -1808,37 +1396,6 @@ CALL INY ;+INC_IP STA OPPAGE LDY #$00 JMP FETCHOP -CALLX INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - TYA - SEC - ADC IPL - PHA - LDA IPH - ADC #$00 - PHA - STA ALTRDOFF - LDA PSR - PHA - PLP - JSR JMPTMP - PHP - PLA - STA PSR - SEI - STA ALTRDON - PLA - STA IPH - PLA - STA IPL - LDA #>OPXTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE - STA OPPAGE - LDY #$00 - JMP FETCHOP ;* ;* INDIRECT CALL TO ADDRESS (NATIVE CODE) ;* @@ -1863,43 +1420,10 @@ ICAL LDA ESTKL,X STA OPPAGE LDY #$00 JMP FETCHOP -ICALX LDA ESTKL,X - STA TMPL - LDA ESTKH,X - STA TMPH - INX - TYA - SEC - ADC IPL - PHA - LDA IPH - ADC #$00 - PHA - STA ALTRDOFF - LDA PSR - PHA - PLP - JSR JMPTMP - PHP - PLA - STA PSR - STA ALTRDON - PLA - STA IPH - PLA - STA IPL - LDA #>OPXTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE - STA OPPAGE - LDY #$0 - JMP FETCHOP -;* -;* JUMP INDIRECT TRHOUGH TMP -;* -;JMPTMP JMP (TMP) ;* ;* ENTER FUNCTION WITH FRAME SIZE AND PARAM COUNT ;* -ENTER64 INY +ENTER INY LDA (IP),Y EOR #$FF SEC @@ -1922,57 +1446,10 @@ ENTER64 INY BNE - + LDY #$03 JMP FETCHOP -ENTER LDA IFPH - PHA ; SAVE ON STACK FOR LEAVE - LDA IFPL - PHA - INY - LDA (IP),Y - EOR #$FF ; ALLOCATE FRAME - SEC - ADC PPL - STA PPL - STA IFPL - LDA #$FF - ADC PPH - STA PPH - STA IFPH - INY - LDA (IP),Y - BEQ + - ASL - TAY -- LDA ESTKH,X - DEY - STA (IFP),Y - LDA ESTKL,X - INX - DEY - STA (IFP),Y - BNE - -+ LDY #$03 - JMP FETCHOP ;* ;* LEAVE FUNCTION ;* -LEAVEX INY ;+INC_IP - LDA (IP),Y - CLC - ADC IFPL - STA PPL - LDA #$00 - ADC IFPH - STA PPH - PLA ; RESTORE PREVIOUS FRAME - STA IFPL - PLA - STA IFPH -RETX STA ALTRDOFF - LDA PSR - PHA - PLP - RTS -LEAVE64 INY ;+INC_IP +LEAVE INY ;+INC_IP LDA (IP),Y CLC ADC IFPL @@ -1980,380 +1457,69 @@ LEAVE64 INY ;+INC_IP BCS + RTS + INC IFPH - RTS -LEAVE INY ;+INC_IP - LDA (IP),Y - CLC - ADC IFPL - STA PPL - LDA #$00 - ADC IFPH - STA PPH - PLA ; RESTORE PREVIOUS FRAME - STA IFPL - PLA - STA IFPH RET RTS +;* +;* RETURN TO NATIVE CODE +;* +NATV TYA ; FLATTEN IP + SEC + ADC IPL + STA IPL + LDA #$00 + ADC IPH + STA IPH + JMP (IP) VMEND = * } -;*************************************** -;* * -;* 65C02 OPS TO OVERWRITE STANDARD OPS * -;* * -;*************************************** -C02OPS LDA #DINTRP - LDY #(CDINTRPEND-CDINTRP) - JSR OPCPY -CDINTRP PLY - PLA - INY - BNE + - INC -+ STY IPL - STA IPH - LDY #$00 - LDA #>OPTBL - STA OPPAGE - JMP FETCHOP -CDINTRPEND -; - LDA #CN - LDY #(CCNEND-CCN) - JSR OPCPY -CCN DEX - LSR - STA ESTKL,X - STZ ESTKH,X - JMP NEXTOP -CCNEND -; - LDA #CB - LDY #(CCBEND-CCB) - JSR OPCPY -CCB DEX - STZ ESTKH,X - INY - LDA (IP),Y - STA ESTKL,X - JMP NEXTOP -CCBEND -; - LDA #CS - LDY #(CCSEND-CCS) - JSR OPCPY -CCS DEX - ;INY ;+INC_IP - TYA ; NORMALIZE IP AND SAVE STRING ADDR ON ESTK - SEC - ADC IPL - STA IPL - STA ESTKL,X - LDA #$00 - ADC IPH - STA IPH - STA ESTKH,X - LDA (IP) - TAY - JMP NEXTOP -CCSEND -; - LDA #SHL - LDY #(CSHLEND-CSHL) - JSR OPCPY -CSHL STY IPY - LDA ESTKL,X - CMP #$08 - BCC + - LDY ESTKL+1,X - STY ESTKH+1,X - STZ ESTKL+1,X - SBC #$08 -+ TAY - BEQ + - LDA ESTKL+1,X -- ASL - ROL ESTKH+1,X - DEY - BNE - - STA ESTKL+1,X -+ LDY IPY - JMP DROP -CSHLEND -; - LDA #LB - LDY #(CLBEND-CLB) - JSR OPCPY -CLB LDA ESTKL,X - STA ESTKH-1,X - LDA (ESTKH-1,X) - STA ESTKL,X - STZ ESTKH,X - JMP NEXTOP -CLBEND -; - LDA #LBX - LDY #(CLBXEND-CLBX) - JSR OPCPY -CLBX LDA ESTKL,X - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-1,X) - STA ESTKL,X - STZ ESTKH,X - STA ALTRDON - JMP NEXTOP -CLBXEND -; - LDA #LLB - LDY #(CLLBEND-CLLB) - JSR OPCPY -CLLB INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - LDA (IFP),Y - STA ESTKL,X - STZ ESTKH,X - LDY IPY - JMP NEXTOP -CLLBEND -; - LDA #LLBX - LDY #(CLLBXEND-CLLBX) - JSR OPCPY -CLLBX INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - DEX - STA ALTRDOFF - LDA (IFP),Y - STA ESTKL,X - STZ ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP -CLLBXEND -; - LDA #LAB - LDY #(CLABEND-CLAB) - JSR OPCPY -CLAB INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - LDA (ESTKH-2,X) - DEX - STA ESTKL,X - STZ ESTKH,X - JMP NEXTOP -CLABEND -; - LDA #LAW - LDY #(CLAWEND-CLAW) - JSR OPCPY -CLAW INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDA (TMP) - DEX - STA ESTKL,X - LDY #$01 - LDA (TMP),Y - STA ESTKH,X - LDY IPY - JMP NEXTOP -CLAWEND -; - LDA #LABX - LDY #(CLABXEND-CLABX) - JSR OPCPY -CLABX INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - STA ALTRDOFF - LDA (ESTKH-2,X) - DEX - STA ESTKL,X - STZ ESTKH,X - STA ALTRDON - JMP NEXTOP -CLABXEND -; - LDA #LAWX - LDY #(CLAWXEND-CLAWX) - JSR OPCPY -CLAWX INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - STY IPY - STA ALTRDOFF - LDA (TMP) - DEX - STA ESTKL,X - LDY #$01 - LDA (TMP),Y - STA ESTKH,X - STA ALTRDON - LDY IPY - JMP NEXTOP -CLAWXEND -; - LDA #SAW - LDY #(CSAWEND-CSAW) - JSR OPCPY -CSAW INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDA ESTKL,X - STA (TMP) - LDY #$01 - LDA ESTKH,X - STA (TMP),Y - LDY IPY - BMI + - JMP DROP -+ JMP FIXDROP -CSAWEND -; - LDA #DAW - LDY #(CDAWEND-CDAW) - JSR OPCPY -CDAW INY ;+INC_IP - LDA (IP),Y - STA TMPL - INY ;+INC_IP - LDA (IP),Y - STA TMPH - STY IPY - LDA ESTKL,X - STA (TMP) - LDY #$01 - LDA ESTKH,X - STA (TMP),Y - LDY IPY - JMP NEXTOP -CDAWEND -; - LDA #DAB - LDY #(CDABEND-CDAB) - JSR OPCPY -CDAB INY ;+INC_IP - LDA (IP),Y - STA ESTKH-2,X - INY ;+INC_IP - LDA (IP),Y - STA ESTKH-1,X - LDA ESTKL,X - STA (ESTKH-2,X) - STZ ESTKH,X - JMP NEXTOP -CDABEND -; - LDA #DLB - LDY #(CDLBEND-CDLB) - JSR OPCPY -CDLB INY ;+INC_IP - LDA (IP),Y - STY IPY - TAY - LDA ESTKL,X - STA (IFP),Y - STZ ESTKH,X - LDY IPY - JMP NEXTOP -CDLBEND -; - LDA #ISFLS - LDY #(CISFLSEND-CISFLS) - JSR OPCPY -CISFLS STZ ESTKL+1,X - STZ ESTKH+1,X - JMP DROP -CISFLSEND -; - LDA #BRNCH - LDY #(CBRNCHEND-CBRNCH) - JSR OPCPY -CBRNCH TYA ; FLATTEN IP - SEC - ADC IPL - STA TMPL - LDA #$00 - ADC IPH - STA TMPH ; ADD BRANCH OFFSET - LDA (TMP) - ;CLC ; BETTER NOT CARRY OUT OF IP+Y - ADC TMPL - STA IPL - LDY #$01 - LDA (TMP),Y - ADC TMPH - STA IPH - DEY - JMP FETCHOP -CBRNCHEND -; - RTS -;* -;* COPY OP TO VM -;* -OPCPY STA DST - STX DST+1 - PLA - STA SRC - PLA - STA SRC+1 - TYA +;************************************************ +;* * +;* ALTERNATIVE VM LOAD * +;* * +;************************************************ +ALTVM = * + !PSEUDOPC $1000 { + !CPU 65816 CLC - ADC SRC - TAX - LDA #$00 - ADC SRC+1 - PHA - PHX - INC SRC - BNE + - INC SRC+1 -+ DEY -- LDA (SRC),Y - STA (DST),Y - DEY - BPL - - RTS + XCE ; TRY SWITCH TO NATIVE MODE + BCC + ; NOT 65802/65816 IF CARRY CLEAR + XCE ; SWITCH BACK TO EMULATED MODE + LDA #VM16 + STA OPENVM+1 + JSR + + LDA #VM128 + STA OPENVM+1 ++ JSR PRODOS ; OPEN CMD + !BYTE $C8 + !WORD OPENVM + BNE NOVM + LDA REFVM + STA READVM+1 + JSR PRODOS + !BYTE $CA + !WORD READVM + BNE NOVM + JSR PRODOS + !BYTE $CC + !WORD CLOSEVM + BNE NOVM + JMP $2000 ; JUMP TO ALT VM +NOVM RTS +OPENVM !BYTE 3 + !WORD VM128 + !WORD $0800 +REFVM !BYTE 0 +READVM !BYTE 4 + !BYTE 0 + !WORD $2000 + !WORD $9F00 + !WORD 0 +CLOSEVM !BYTE 1 + !BYTE 0 +VM128 !BYTE 8, 'P', 'L', 'V', 'M', '-', '1', '2', '8' +VM16 !BYTE 6, 'P', 'L', 'V', 'M', '1', '6' + !CPU 6502 +} diff --git a/src/vmsrc/apple/plvm802.s b/src/vmsrc/apple/plvm802.s index ed319bb..b05c283 100644 --- a/src/vmsrc/apple/plvm802.s +++ b/src/vmsrc/apple/plvm802.s @@ -97,7 +97,7 @@ NOS = $03 ; TOS-1 ;* INTERPRETER INITIALIZATION * ;* * ;****************************** -* = $2000 +* = $2000 ;* ;* MUST HAVE 128K FOR JIT ;* @@ -143,13 +143,6 @@ BADCPU !TEXT "65C802/65C816 CPU REQUIRED.", 13 ANYKEY !TEXT "PRESS ANY KEY...", 0 ++ XCE ; SWITCH BACK TO EMULATED MODE -;* -;* INITIALIZE STACK -;* -;INITSP LDX #$FE -; TXS -; LDX #$00 -; STX $01FF ;* ;* DISCONNECT /RAM ;* @@ -196,7 +189,7 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE STY DSTL LDA #$D0 STA DSTH -- LDA (SRC),Y ; COPY VM+CMD INTO LANGUAGE CARD +- LDA (SRC),Y ; COPY VM+BYE INTO LANGUAGE CARD STA (DST),Y INY BNE - @@ -208,10 +201,7 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE ;* ;* MOVE FIRST PAGE OF 'BYE' INTO PLACE ;* - STY SRCL - LDA #$D1 - STA SRCH -- LDA (SRC),Y +- LDA $D100,Y STA $1000,Y INY BNE - @@ -236,13 +226,13 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE LDA #"D" INY STA STRBUF,Y - LDA #"J" + LDA #"1" INY STA STRBUF,Y - LDA #"I" + LDA #"2" INY STA STRBUF,Y - LDA #"T" + LDA #"8" INY STA STRBUF,Y STY STRBUF diff --git a/src/vmsrc/apple/plvmjit02.s b/src/vmsrc/apple/plvmjit02.s index 2d75e7c..b9f516b 100755 --- a/src/vmsrc/apple/plvmjit02.s +++ b/src/vmsrc/apple/plvmjit02.s @@ -1,6 +1,6 @@ ;********************************************************** ;* -;* APPLE ][ 64K/128K PLASMA INTERPRETER +;* APPLE ][ 128K PLASMA INTERPRETER ;* ;* SYSTEM ROUTINES AND LOCATIONS ;* @@ -61,10 +61,6 @@ JITCODE = $03E4 ;* * ;****************************** * = $2000 - LDX #$FE - TXS - LDX #$00 - STX $01FF ;* ;* MUST HAVE 128K FOR JIT ;* @@ -134,7 +130,7 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE STY DSTL LDA #$D0 STA DSTH -- LDA (SRC),Y ; COPY VM+CMD INTO LANGUAGE CARD +- LDA (SRC),Y ; COPY VM+BYE INTO LANGUAGE CARD STA (DST),Y INY BNE - @@ -146,10 +142,7 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE ;* ;* MOVE FIRST PAGE OF 'BYE' INTO PLACE ;* - STY SRCL - LDA #$D1 - STA SRCH -- LDA (SRC),Y +- LDA $D100,Y STA $1000,Y INY BNE - @@ -181,13 +174,13 @@ RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE LDA #"D" INY STA STRBUF,Y - LDA #"J" + LDA #"1" INY STA STRBUF,Y - LDA #"I" + LDA #"2" INY STA STRBUF,Y - LDA #"T" + LDA #"8" INY STA STRBUF,Y STY STRBUF @@ -2035,11 +2028,11 @@ RET RTS NATV TYA ; FLATTEN IP SEC ADC IPL - STA TMPL + STA IPL LDA #$00 ADC IPH - STA TMPH - JMP JMPTMP + STA IPH + JMP (IP) VMEND = * } ;***************************************