diff --git a/src/libsrc/apple/jit.pla b/src/libsrc/apple/jit.pla index 267bf44..c2d15b1 100644 --- a/src/libsrc/apple/jit.pla +++ b/src/libsrc/apple/jit.pla @@ -49,7 +49,7 @@ def compiler(defptr)#0 word codeptr, isdata, addrxlate, bytecode, i, case, dest, VX byte opcode, j, A_IS_TOSL - puts("JIT compiler invoked for :$"); puth(defptr=>bytecodeaddr); putln + //puts("JIT compiler invoked for :$"); puth(defptr=>bytecodeaddr); putln if isult(heapavail, 512 + defptr->bytecodesize) // 256 * sizeof(word) address xlate // // Not enough heap available @@ -68,8 +68,8 @@ def compiler(defptr)#0 *$0042 = bytecode call($C311, 0, 0, 0, $00) // CALL XMOVE with carry clear (AUX->MAIN) //^$C053 // MIX TEXT - puts("Addr Xlate: $"); puth(addrxlate); putln - puts("Bytecode: $"); puth(bytecode); putln + //puts("Addr Xlate: $"); puth(addrxlate); putln + //puts("Bytecode: $"); puth(bytecode); putln // // Find all branch targets and optimization fences. Tag the opcode with the LSB set // @@ -211,9 +211,9 @@ def compiler(defptr)#0 // // First optimization is to keep zero in Y register at all times // - if ^bytecode <> $58 // ENTER will set Y to zero - ^codeptr = $A0; codeptr++ // LDY #imm - ^codeptr = $00; codeptr++ // $00 + if ^bytecode & $FE <> $58 // ENTER will set Y to zero + ^codeptr = $A0; codeptr++ // LDY #imm + ^codeptr = $00; codeptr++ // $00 fin while isule(codeptr, codemax) // @@ -231,8 +231,8 @@ def compiler(defptr)#0 until not case fin addrxlate=>[i] = codeptr - putc('$'); puth(codeptr); putc(':') - putc('['); puti(i); puts("] ") + //putc('$'); puth(codeptr); putc(':') + //putc('['); puti(i); //puts("] ") opcode = ^(bytecode+i) if opcode & 1 // @@ -249,10 +249,18 @@ def compiler(defptr)#0 if opcode < $20 // CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E // CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E - puts("CN $"); putb(^(bytecode+i)/2) + //puts("CN $"); putb(^(bytecode+i)/2) + if A_IS_TOSL + ^codeptr = $95; codeptr++ // STA zp,X + ^codeptr = $D0+VX; codeptr++ // ESTKL + fin VX-- //^codeptr = $CA; codeptr++ // DEX - ^codeptr = $A9; codeptr++ // LDA #imm - ^codeptr = ^(bytecode+i)/2; codeptr++ + if ^(bytecode+i) == 0 + ^codeptr = $98; codeptr++ // TYA -> LDA #$00 + else + ^codeptr = $A9; codeptr++ // LDA #imm + ^codeptr = ^(bytecode+i)/2; codeptr++ + fin ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH //^codeptr = $95; codeptr++ // STA zp,X @@ -262,7 +270,7 @@ def compiler(defptr)#0 when opcode // MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E is $20 - puts("MINUS_ONE") + //puts("MINUS_ONE") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -280,7 +288,7 @@ def compiler(defptr)#0 i++ dest = i + *(bytecode+i) i++ - puts("BREQ "); puti(dest) + //puts("BREQ "); puti(dest) //^codeptr = $E8; codeptr++ // INX //^codeptr = $E8; codeptr++ // INX codeptr, VX = resolveX(codeptr, VX + 2) @@ -310,7 +318,7 @@ def compiler(defptr)#0 i++ dest = i + *(bytecode+i) i++ - puts("BRNE "); puti(dest) + //puts("BRNE "); puti(dest) //^codeptr = $E8; codeptr++ // INX //^codeptr = $E8; codeptr++ // INX codeptr, VX = resolveX(codeptr, VX + 2) @@ -338,7 +346,7 @@ def compiler(defptr)#0 break is $26 i++ - puts("LA $"); puth(*(bytecode+i)) + //puts("LA $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -357,14 +365,18 @@ def compiler(defptr)#0 break is $28 i++ - puts("LLA "); puti(^(bytecode+i)) + //puts("LLA "); puti(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL fin VX-- //^codeptr = $CA; codeptr++ // DEX - ^codeptr = $A9; codeptr++ // LDA #imm - ^codeptr = ^(bytecode+i); codeptr++ + if ^(bytecode+i) == 0 + ^codeptr = $98; codeptr++ // TYA -> LDA #$00 + else + ^codeptr = $A9; codeptr++ // LDA #imm + ^codeptr = ^(bytecode+i); codeptr++ + fin ^codeptr = $18; codeptr++ // CLC ^codeptr = $65; codeptr++ // ADC zp ^codeptr = $E0; codeptr++ // IFPL @@ -379,7 +391,7 @@ def compiler(defptr)#0 break is $2A i++ - puts("CB $"); putb(^(bytecode+i)) + //puts("CB $"); putb(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -395,7 +407,7 @@ def compiler(defptr)#0 break is $2C i++ - puts("CW $"); puth(*(bytecode+i)) + //puts("CW $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -405,8 +417,12 @@ def compiler(defptr)#0 ^codeptr = ^(bytecode+i+1); codeptr++ ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - ^codeptr = $A9; codeptr++ // LDA #imm - ^codeptr = ^(bytecode+i); codeptr++ + if ^(bytecode+i) == 0 + ^codeptr = $98; codeptr++ // TYA -> LDA #$00 + else + ^codeptr = $A9; codeptr++ // LDA #imm + ^codeptr = ^(bytecode+i); codeptr++ + fin //^codeptr = $95; codeptr++ // STA zp,X //^codeptr = $D0+VX; codeptr++ // ESTKL A_IS_TOSL = TRUE @@ -416,7 +432,7 @@ def compiler(defptr)#0 i++ j = ^(bytecode+i) dest = i + j + 1 - puts("CS "); puts(bytecode+i); puts("-->"); puti(dest) + //puts("CS "); //puts(bytecode+i); //puts("-->"); puti(dest) if isule(codeptr + 12 + j, codemax) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X @@ -447,19 +463,19 @@ def compiler(defptr)#0 break // DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E is $30 - puts("DROP") + //puts("DROP") VX++ //^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $32 - puts("DROP2") + //puts("DROP2") //^codeptr = $E8; codeptr++ // INX //^codeptr = $E8; codeptr++ // INX VX = VX + 2 A_IS_TOSL = FALSE break is $34 - puts("DUP") + //puts("DUP") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -476,14 +492,14 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $36 - puts("DIVMOD") + //puts("DIVMOD") // // Should never happen // break is $38 i++ - puts("ADDI $"); putb(^(bytecode+i)) + //puts("ADDI $"); putb(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -501,7 +517,7 @@ def compiler(defptr)#0 break is $3A i++ - puts("SUBI $"); putb(^(bytecode+i)) + //puts("SUBI $"); putb(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -519,7 +535,7 @@ def compiler(defptr)#0 break is $3C i++ - puts("ANDI $"); putb(^(bytecode+i)) + //puts("ANDI $"); putb(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -534,7 +550,7 @@ def compiler(defptr)#0 break is $3E i++ - puts("ORI $"); putb(^(bytecode+i)) + //puts("ORI $"); putb(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -547,7 +563,7 @@ def compiler(defptr)#0 break // ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E is $40 - puts("ISEQ") + //puts("ISEQ") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -566,9 +582,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -577,7 +590,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $42 - puts("ISNE") + //puts("ISNE") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -596,9 +609,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -607,7 +617,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $44 - puts("ISGT") + //puts("ISGT") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -628,9 +638,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -639,7 +646,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $46 - puts("ISLT") + //puts("ISLT") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -662,9 +669,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -673,7 +677,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $48 - puts("ISGE") + //puts("ISGE") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -696,9 +700,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -707,7 +708,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $4A - puts("ISLE") + //puts("ISLE") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -728,9 +729,6 @@ def compiler(defptr)#0 ^codeptr = $98; codeptr++ // TYA ^codeptr = $94; codeptr++ // STY zp,X ^codeptr = $C0+1+VX; codeptr++ // ESTKH+1 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 VX++ //^codeptr = $E8; codeptr++ // INX @@ -742,7 +740,7 @@ def compiler(defptr)#0 i++ dest = i + *(bytecode+i) i++ - puts("BRFLS "); puti(dest) + //puts("BRFLS "); puti(dest) //VX++ //^codeptr = $E8; codeptr++ // INX codeptr, VX = resolveX(codeptr, VX + 1) if not A_IS_TOSL @@ -765,7 +763,7 @@ def compiler(defptr)#0 i++ dest = i + *(bytecode+i) i++ - puts("BRTRU "); puti(dest) + //puts("BRTRU "); puti(dest) //VX++ //^codeptr = $E8; codeptr++ // INX codeptr, VX = resolveX(codeptr, VX + 1) if not A_IS_TOSL @@ -789,7 +787,7 @@ def compiler(defptr)#0 i++ dest = i + *(bytecode+i) i++ - puts("BRNCH "); puti(dest) + //puts("BRNCH "); puti(dest) ^codeptr = $4C; codeptr++ // JMP abs *codeptr = addrxlate=>[dest] if not (*codeptr & $8000) // Unresolved address list @@ -802,7 +800,7 @@ def compiler(defptr)#0 i++ case = i + *(bytecode+i) i++ - puts("SEL "); puti(case); putln + //puts("SEL "); puti(case); putln j = ^(bytecode+case) dest = codeptr + 8 + case * 11) if isule(dest, codemax) @@ -817,7 +815,7 @@ def compiler(defptr)#0 //VX++ //^codeptr = $E8; codeptr++ // INX codeptr, VX = resolveX(codeptr, VX + 1) repeat - puts(" $"); puth(*(bytecode+case)) + //puts(" $"); puth(*(bytecode+case)) ^codeptr = $C9; codeptr++ // CMP #imm ^codeptr = ^(bytecode+case); codeptr++ ^codeptr = $D0; codeptr++ // BNE rel @@ -829,10 +827,7 @@ def compiler(defptr)#0 *(bytecode+case) = $FEFE case = case + 2 dest = case + *(bytecode+case) - puts("-->"); puti(dest); putln - // - // Reload zero into Y - // + //puts("-->"); puti(dest); putln ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 ^codeptr = $4C; codeptr++ // JMP abs @@ -845,9 +840,6 @@ def compiler(defptr)#0 case = case + 2 j-- until not j - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 ^codeptr = $4C; codeptr++ // JMP abs @@ -863,22 +855,19 @@ def compiler(defptr)#0 break is $54 i++ - puts("CALL $"); puth(*(bytecode+i)) + //puts("CALL $"); puth(*(bytecode+i)) // // Call address // ^codeptr = $20; codeptr++ // JSR abs *codeptr = *(bytecode+i); codeptr = codeptr + 2 - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE i++ break is $56 - puts("ICAL") + //puts("ICAL") // // Pull address off stack // @@ -900,16 +889,13 @@ def compiler(defptr)#0 ^codeptr = $20; codeptr++ // JSR abs ^codeptr = $E6; codeptr++ // JMPTMP - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $58 i++ - puts("ENTER "); puti(^(bytecode+i)); putc(',');puti(^(bytecode+i+1)) + //puts("ENTER "); puti(^(bytecode+i)); putc(',');puti(^(bytecode+i+1)) // // Call into VM // @@ -920,16 +906,13 @@ def compiler(defptr)#0 i++ ^codeptr = ^(bytecode+i); codeptr++ // ENTER ARG COUNT ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $5A i++ - puts("LEAVE "); puti(^(bytecode+i)) + //puts("LEAVE "); puti(^(bytecode+i)) // // Call into VM // @@ -940,13 +923,13 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $5C - puts("RET") + //puts("RET") ^codeptr = $60; codeptr++ // RTS A_IS_TOSL = FALSE break is $5E i++ - puts("CFFB $FF"); putb(^(bytecode+i)) + //puts("CFFB $FF"); putb(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -964,7 +947,7 @@ def compiler(defptr)#0 break // LB,LW,LLB,LLW,LAB,LAW,DLB,DLW ; 60 62 64 66 68 6A 6C 6E is $60 - puts("LB") + //puts("LB") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -980,7 +963,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $62 - puts("LW") + //puts("LW") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1005,7 +988,7 @@ def compiler(defptr)#0 break is $64 i++ - puts("LLB "); puti(^(bytecode+i)) + //puts("LLB "); puti(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1017,9 +1000,6 @@ def compiler(defptr)#0 fin ^codeptr = $B1; codeptr++ // LDA (zp),Y ^codeptr = $E0; codeptr++ // IFP - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1032,7 +1012,7 @@ def compiler(defptr)#0 break is $66 i++ - puts("LLW "); puti(^(bytecode+i)) + //puts("LLW "); puti(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1051,9 +1031,6 @@ def compiler(defptr)#0 ^codeptr = $E0; codeptr++ // IFP ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1064,7 +1041,7 @@ def compiler(defptr)#0 break is $68 i++ - puts("LAB $"); puth(*(bytecode+i)) + //puts("LAB $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1081,7 +1058,7 @@ def compiler(defptr)#0 break is $6A i++ - puts("LAW $"); puth(*(bytecode+i)) + //puts("LAW $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1100,7 +1077,7 @@ def compiler(defptr)#0 break is $6C i++ - puts("DLB "); puti(^(bytecode+i)) + //puts("DLB "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1111,9 +1088,6 @@ def compiler(defptr)#0 fin ^codeptr = $91; codeptr++ // STA (zp),Y ^codeptr = $E0; codeptr++ // IFP - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1122,7 +1096,7 @@ def compiler(defptr)#0 break is $6E i++ - puts("DLW "); puti(^(bytecode+i)) + //puts("DLW "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1138,9 +1112,6 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $91; codeptr++ // STA (zp),Y ^codeptr = $E0; codeptr++ // IFP - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1151,7 +1122,7 @@ def compiler(defptr)#0 break // SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E is $70 - puts("SB") + //puts("SB") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1168,7 +1139,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $72 - puts("SW") + //puts("SW") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1196,7 +1167,7 @@ def compiler(defptr)#0 break is $74 i++ - puts("SLB "); puti(^(bytecode+i)) + //puts("SLB "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1207,9 +1178,6 @@ def compiler(defptr)#0 fin ^codeptr = $91; codeptr++ // STA (zp),Y ^codeptr = $E0; codeptr++ // IFP - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1219,7 +1187,7 @@ def compiler(defptr)#0 break is $76 i++ - puts("SLW "); puti(^(bytecode+i)) + //puts("SLW "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1235,9 +1203,6 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $91; codeptr++ // STA (zp),Y ^codeptr = $E0; codeptr++ // IFP - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1249,7 +1214,7 @@ def compiler(defptr)#0 break is $78 i++ - puts("SAB $"); puth(*(bytecode+i)) + //puts("SAB $"); puth(*(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1262,7 +1227,7 @@ def compiler(defptr)#0 break is $7A i++ - puts("SAW $"); puth(*(bytecode+i)) + //puts("SAW $"); puth(*(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1279,7 +1244,7 @@ def compiler(defptr)#0 break is $7C i++ - puts("DAB $"); puth(*(bytecode+i)) + //puts("DAB $"); puth(*(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1291,7 +1256,7 @@ def compiler(defptr)#0 break is $7E i++ - puts("DAW $"); puth(*(bytecode+i)) + //puts("DAW $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1309,7 +1274,7 @@ def compiler(defptr)#0 break // LNOT,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 80 82 84 86 88 8A 8C 8E is $80 - puts("NOT") + //puts("NOT") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1329,7 +1294,7 @@ def compiler(defptr)#0 A_IS_TOSL = TRUE break is $82 - puts("ADD") + //puts("ADD") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1349,7 +1314,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $84 - puts("SUB") + //puts("SUB") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1371,7 +1336,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $86 - puts("MUL") + //puts("MUL") // // Call into VM // @@ -1379,15 +1344,12 @@ def compiler(defptr)#0 *codeptr = $3D0; codeptr = codeptr + 2 ^codeptr = $86; codeptr++ // MUL CODE ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $88 - puts("DIV") + //puts("DIV") // // Call into VM // @@ -1395,15 +1357,12 @@ def compiler(defptr)#0 *codeptr = $3D0; codeptr = codeptr + 2 ^codeptr = $88; codeptr++ // DIV CODE ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $8A - puts("MOD") + //puts("MOD") // // Call into VM // @@ -1411,15 +1370,12 @@ def compiler(defptr)#0 *codeptr = $3D0; codeptr = codeptr + 2 ^codeptr = $8A; codeptr++ // MOD CODE ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $8C - puts("INCR") + //puts("INCR") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1433,13 +1389,15 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $8E - puts("DECR") + //puts("DECR") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL else - ^codeptr = $C9; codeptr++ // CMP #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $95; codeptr++ // STA zp,X + ^codeptr = $D0+VX; codeptr++ // ESTKL + ^codeptr = $C9; codeptr++ // CMP #imm + ^codeptr = $00; codeptr++ // $00 fin ^codeptr = $D0; codeptr++ // BNE rel ^codeptr = $02; codeptr++ // +2 @@ -1451,7 +1409,7 @@ def compiler(defptr)#0 break // NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 90 92 94 96 98 9A 9C 9E is $90 - puts("NEG") + //puts("NEG") if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1470,7 +1428,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $92 - puts("COMP") + //puts("COMP") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1488,7 +1446,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $94 - puts("AND") + //puts("AND") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1507,7 +1465,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $96 - puts("OR") + //puts("OR") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1526,7 +1484,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $98 - puts("XOR") + //puts("XOR") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1545,7 +1503,7 @@ def compiler(defptr)#0 A_IS_TOSL = FALSE break is $9A - puts("SHL") + //puts("SHL") // // Call into VM // @@ -1553,15 +1511,12 @@ def compiler(defptr)#0 *codeptr = $3D0; codeptr = codeptr + 2 ^codeptr = $9A; codeptr++ // SHL CODE ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $9C - puts("SHR") + //puts("SHR") // // Call into VM // @@ -1569,15 +1524,12 @@ def compiler(defptr)#0 *codeptr = $3D0; codeptr = codeptr + 2 ^codeptr = $9C; codeptr++ // SHR CODE ^codeptr = $C0; codeptr++ // NATV CODE - // - // Reload zero into Y - // ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $9E - puts("IDXW") + //puts("IDXW") if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1603,7 +1555,7 @@ def compiler(defptr)#0 is $A0 i++ dest = i + *(bytecode+i) - puts("BRGT "); puti(dest) + //puts("BRGT "); puti(dest) i++ codeptr, VX = resolveX(codeptr, VX) if A_IS_TOSL @@ -1631,18 +1583,21 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 + codeptr = codeptr + 2 A_IS_TOSL = FALSE break is $A2 i++ dest = i + *(bytecode+i) - puts("BRLT "); puti(dest) + //puts("BRLT "); puti(dest) i++ codeptr, VX = resolveX(codeptr, VX) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL + else + ^codeptr = $95; codeptr++ // STA zp,X + ^codeptr = $D0+VX; codeptr++ // ESTKL fin ^codeptr = $D5; codeptr++ // CMP zp,X ^codeptr = $D0+1+VX; codeptr++ // ESTKL+1 @@ -1663,13 +1618,13 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 + codeptr = codeptr + 2 A_IS_TOSL = FALSE break is $A4 i++ dest = i + *(bytecode+i) - puts("INCBRLE "); puti(dest) + //puts("INCBRLE "); puti(dest) i++ // // INCR @@ -1707,15 +1662,15 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $A6 i++ dest = i + *(bytecode+i) - puts("ADDBRLE "); puti(dest) + //puts("ADDBRLE "); puti(dest) i++ // // ADD @@ -1759,15 +1714,15 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $A8 i++ dest = i + *(bytecode+i) - puts("DECBRGE "); puti(dest) + //puts("DECBRGE "); puti(dest) i++ // // DECR @@ -1776,8 +1731,10 @@ def compiler(defptr)#0 ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL else - ^codeptr = $C9; codeptr++ // CMP #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $95; codeptr++ // STA zp,X + ^codeptr = $D0+VX; codeptr++ // ESTKL + ^codeptr = $C9; codeptr++ // CMP #imm + ^codeptr = $00; codeptr++ // $00 fin ^codeptr = $D0; codeptr++ // BNE rel ^codeptr = $02; codeptr++ // +2 @@ -1808,15 +1765,15 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $AA i++ dest = i + *(bytecode+i) - puts("SUBBRGE "); puti(dest) + //puts("SUBBRGE "); puti(dest) i++ // // SUB @@ -1862,16 +1819,16 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $AC i++ dest = i + *(bytecode+i) i++ - puts("BRAND "); puti(dest) + //puts("BRAND "); puti(dest) codeptr, VX = resolveX(codeptr, VX) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X @@ -1886,15 +1843,15 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break is $AE i++ dest = i + *(bytecode+i) i++ - puts("BROR "); puti(dest) + //puts("BROR "); puti(dest) codeptr, VX = resolveX(codeptr, VX) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X @@ -1909,14 +1866,14 @@ def compiler(defptr)#0 if not (*codeptr & $8000) // Unresolved address list addrxlate=>[dest] = codeptr - *jitcodeptr fin - codeptr = codeptr + 2 - ^codeptr = $E8; codeptr++ // INX + codeptr = codeptr + 2 + ^codeptr = $E8; codeptr++ // INX A_IS_TOSL = FALSE break // ADDLB,ADDLW,ADDAB,ADDAW,IDXLB,IDXLW,IDXAB,IDXAW ; B0 B2 B4 B6 B8 BA BC BE is $B0 i++ - puts("ADDLB "); puti(^(bytecode+i)) + //puts("ADDLB "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1928,24 +1885,21 @@ def compiler(defptr)#0 ^codeptr = $18; codeptr++ // CLC ^codeptr = $71; codeptr++ // ADC (zp),Y ^codeptr = $E0; codeptr++ // IFP - ^codeptr = $95; codeptr++ // STA zp,X - ^codeptr = $D0+VX; codeptr++ // ESTKL ^codeptr = $90; codeptr++ // BCC rel ^codeptr = $02; codeptr++ // +2 ^codeptr = $F6; codeptr++ // INC zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 fin + //^codeptr = $95; codeptr++ // STA zp,X + //^codeptr = $D0+VX; codeptr++ // ESTKL A_IS_TOSL = TRUE break is $B2 i++ - puts("ADDLW "); puti(^(bytecode+i)) + //puts("ADDLW "); puti(^(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1966,9 +1920,6 @@ def compiler(defptr)#0 ^codeptr = $E0; codeptr++ // IFP ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // if ^(bytecode+i) <> 0 ^codeptr = $A0; codeptr++ // LDY #imm ^codeptr = $00; codeptr++ // $00 @@ -1979,7 +1930,7 @@ def compiler(defptr)#0 break is $B4 i++ - puts("ADDAB $"); puth(*(bytecode+i)) + //puts("ADDAB $"); puth(*(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -1998,7 +1949,7 @@ def compiler(defptr)#0 break is $B6 i++ - puts("ADDAW $"); puth(*(bytecode+i)) + //puts("ADDAW $"); puth(*(bytecode+i)) if not A_IS_TOSL ^codeptr = $B5; codeptr++ // LDA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -2019,7 +1970,7 @@ def compiler(defptr)#0 break is $B8 i++ - puts("IDXLB "); puti(^(bytecode+i)) + //puts("IDXLB "); puti(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -2048,16 +1999,13 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // - ^codeptr = $A0; codeptr++ // LDY #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $A0; codeptr++ // LDY #imm + ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $BA i++ - puts("IDXLW "); puti(^(bytecode+i)) + //puts("IDXLW "); puti(^(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -2088,16 +2036,13 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // - ^codeptr = $A0; codeptr++ // LDY #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $A0; codeptr++ // LDY #imm + ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE break is $BC i++ - puts("IDXAB $"); puth(*(bytecode+i)) + //puts("IDXAB $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -2118,17 +2063,14 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // - ^codeptr = $A0; codeptr++ // LDY #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $A0; codeptr++ // LDY #imm + ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE i++ break is $BE i++ - puts("IDXAW $"); puth(*(bytecode+i)) + //puts("IDXAW $"); puth(*(bytecode+i)) if A_IS_TOSL ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $D0+VX; codeptr++ // ESTKL @@ -2154,11 +2096,8 @@ def compiler(defptr)#0 ^codeptr = $C0+VX; codeptr++ // ESTKH ^codeptr = $95; codeptr++ // STA zp,X ^codeptr = $C0+VX; codeptr++ // ESTKH - // - // Reload zero into Y - // - ^codeptr = $A0; codeptr++ // LDY #imm - ^codeptr = $00; codeptr++ // $00 + ^codeptr = $A0; codeptr++ // LDY #imm + ^codeptr = $00; codeptr++ // $00 A_IS_TOSL = FALSE i++ break @@ -2168,7 +2107,7 @@ def compiler(defptr)#0 //putc('$'); puth(^(bytecode+i)) wend fin - putln + //putln i++ if i >= defptr->bytecodesize // @@ -2181,11 +2120,11 @@ def compiler(defptr)#0 // Free working bufffers // //heaprelease(addrxlate) - puts("Done compiling: $"); puth(defptr=>interpaddr); putln - getc + //puts("Done compiling: $"); puth(defptr=>interpaddr); putln + //getc return fin - getc + //getc loop // // If we got here. we ran out of code buffer space. Overwrite interpreter @@ -2196,7 +2135,7 @@ def compiler(defptr)#0 // Free working bufffers // //heaprelease(addrxlate) - puts("Ran out of code buffer\n") + //puts("Ran out of code buffer\n") //getc end //