mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-22 01:30:45 +00:00
JIT16 WIP
This commit is contained in:
parent
07733cc5a6
commit
11ee2feed5
@ -1041,308 +1041,251 @@ def compiler(defptr)#0
|
||||
dest = i + *(bytecode+i)
|
||||
i++
|
||||
if not A_IS_TOS
|
||||
*codeptr = $D0B5+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if opcode == $A4
|
||||
//
|
||||
// INCR
|
||||
//
|
||||
//puts("INCBRLE "); puti(dest)
|
||||
codeptr->0 = $18 // CLC
|
||||
codeptr=>1 = $0169 // ADC #$01
|
||||
codeptr=>3 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr=>5 = $0290 // BCC +2
|
||||
codeptr=>7 = $C0F6+(VX<<8) // INC ESTKH,X
|
||||
codeptr, VX = resolveX(codeptr + 9, VX)
|
||||
codeptr=>0 = $481A // INC A; PHA
|
||||
codeptr = codeptr + 2
|
||||
else
|
||||
//
|
||||
// ADD
|
||||
//
|
||||
//puts("ADDBRLE "); puti(dest)
|
||||
codeptr->0 = $18 // CLC
|
||||
codeptr=>1 = $D075+$0100+(VX<<8) // ADC ESTKL+1,X
|
||||
codeptr=>3 = $D095+$0100+(VX<<8) // STA ESTKL+1,X
|
||||
codeptr=>5 = $C0B5+(VX<<8) // LDA ESTKH,X
|
||||
codeptr=>7 = $C075+$0100+(VX<<8) // ADC ESTKH+1,X
|
||||
codeptr=>9 = $C095+$0100+(VX<<8) // STA ESTKH+1,X
|
||||
codeptr, VX = resolveX(codeptr + 11, VX + 1) // INX
|
||||
codeptr->0 = $18 // CLC
|
||||
codeptr=>1 = $63+(TOS<<8) // ADC S,TOS
|
||||
codeptr=>3 = $83+(TOS<<8) // STA S,TOS
|
||||
codeptr = codeptr + 5
|
||||
fin
|
||||
//
|
||||
// BRLE
|
||||
//
|
||||
codeptr=>0 = $D0B5+$0100//+(VX<<8) // LDA ESTKL+1,X
|
||||
codeptr=>2 = $D0D5//+(VX<<8) // CMP ESTKL,X
|
||||
codeptr=>4 = $C0B5+$0100//+(VX<<8) // LDA ESTKH+1,X
|
||||
codeptr=>6 = $C0F5//+(VX<<8) // SBC ESTKH
|
||||
codeptr=>8 = $0250 // BVC +2
|
||||
codeptr=>10 = $8049 // EOR #$80
|
||||
codeptr=>12 = $0330 // BMI +3
|
||||
codeptr->14 = $4C // JMP abs
|
||||
codeptr=>15 = addrxlate=>[dest]
|
||||
if not (codeptr->16 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 15 - *jitcodeptr
|
||||
codeptr=>0 = $A3+(NOS<<8) // LDA S,NOS
|
||||
codeptr->2 = $38 // SEC
|
||||
codeptr=>3 = $E3+(TOS<<8) // SBC S,TOS
|
||||
codeptr=>5 = $0250 // BVC +3
|
||||
codeptr->7 = $49 // EOR #$8000
|
||||
codeptr=>8 = $8000
|
||||
codeptr=>10 = $0330 // BMI +3
|
||||
codeptr->12 = $4C // JMP abs
|
||||
codeptr=>13 = addrxlate=>[dest]
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
fin
|
||||
codeptr=>15 = $6868 // PLA; PLA
|
||||
codeptr = codeptr + 17
|
||||
VX = VX + 2 // INX; INX
|
||||
A_IS_TOS = FALSE
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $A8 // DECBRGR - FOR/NEXT SPECIFIC DEC & TEST & BRANCH
|
||||
is $AA // SUBBRGE - FOR/NEXT SPECIFIC SUB & TEST & BRANCH
|
||||
i++
|
||||
dest = i + *(bytecode+i)
|
||||
i++
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if opcode == $A8
|
||||
//
|
||||
// DECR
|
||||
//
|
||||
//puts("DECBRGE "); puti(dest)
|
||||
if not A_IS_TOS
|
||||
*codeptr = $D0B5+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
fin
|
||||
codeptr->0 = $38 // SEC
|
||||
codeptr=>1 = $01E9 // SBC #$01
|
||||
codeptr=>3 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr=>5 = $02B0 // BCS +2
|
||||
codeptr=>7 = $C0D6+(VX<<8) // DEC ESTKH,X
|
||||
codeptr, VX = resolveX(codeptr + 9, VX)
|
||||
codeptr=>0 = $483A // DEC A; PHA
|
||||
codeptr = codeptr + 2
|
||||
else
|
||||
//
|
||||
// SUB
|
||||
//
|
||||
//puts("SUBBRGE "); puti(dest)
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
*codeptr = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
fin
|
||||
codeptr=>0 = $D0B5+$0100+(VX<<8) // LDA ESTKL+1,X
|
||||
codeptr->2 = $38 // SEC
|
||||
codeptr=>3 = $D0F5+(VX<<8) // SBC ESTKL,X
|
||||
codeptr=>5 = $D095+$0100+(VX<<8) // STA ESTKL+1,X
|
||||
codeptr=>7 = $C0B5+$0100+(VX<<8) // LDA ESTKH+1,X
|
||||
codeptr=>9 = $C0F5+(VX<<8) // SBC ESTKH,X
|
||||
codeptr=>11 = $C095+$0100+(VX<<8) // STA ESTKH+1,X
|
||||
codeptr, VX = resolveX(codeptr + 13, VX + 1) // INX
|
||||
*codeptr = $D0B5//+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
codeptr=>0 = $E685 // STA TMP
|
||||
codeptr=>2 = $A3+(TOS<<8) // LDA S,TOS
|
||||
codeptr->4 = $68 // SEC
|
||||
codeptr=>5 = $E6E5 // SBC TMP
|
||||
codeptr=>3 = $83+(TOS<<8) // STA S,TOS
|
||||
codeptr = codeptr + 6
|
||||
fin
|
||||
//
|
||||
// BRGE
|
||||
//
|
||||
codeptr=>0 = $D0D5+$0100//+(VX<<8) // CMP ESTKL+1,X
|
||||
codeptr=>2 = $C0B5//+(VX<<8) // LDA ESTKH,X
|
||||
codeptr=>4 = $C0F5+$0100//+(VX<<8) // SBC ESTKH+1,X
|
||||
codeptr=>6 = $0250 // BVC +2
|
||||
codeptr=>8 = $8049 // EOR #$80
|
||||
codeptr=>10 = $0330 // BMI +3
|
||||
codeptr->12 = $4C // JMP abs
|
||||
codeptr=>13 = addrxlate=>[dest]
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
codeptr->0 = $38 // SEC
|
||||
codeptr=>1 = $E3+(NOS<<8) // SBC S,NOS
|
||||
codeptr=>3 = $0250 // BVC +3
|
||||
codeptr->5 = $49 // EOR #$8000
|
||||
codeptr=>6 = $8000
|
||||
codeptr=>8 = $0330 // BMI +3
|
||||
codeptr->10 = $4C // JMP abs
|
||||
codeptr=>11 = addrxlate=>[dest]
|
||||
if not (codeptr->12 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 11 - *jitcodeptr
|
||||
fin
|
||||
codeptr=>13 = $6868 // PLA; PLA
|
||||
codeptr = codeptr + 15
|
||||
VX = VX + 2 // INX; INX
|
||||
A_IS_TOS = FALSE
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $AC // BRAND - LOGICAL AND SPECIFIC BRANCH
|
||||
is $AE // BROR - LOGICAL OR SPECIFIC BRANCH
|
||||
i++
|
||||
dest = i + *(bytecode+i)
|
||||
i++
|
||||
codeptr, VX = resolveX(codeptr, VX)
|
||||
if not A_IS_TOS
|
||||
*codeptr = $D0B5//+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
elsif A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
codeptr->0 = $68 // PLA
|
||||
else
|
||||
codeptr->0 = $A8 // TAY
|
||||
fin
|
||||
codeptr=>0 = $C015//+(VX<<8) // ORA ESTKH,X
|
||||
if opcode == $AC
|
||||
//puts("BRAND "); puti(dest)
|
||||
codeptr=>2 = $03D0 // BNE +3
|
||||
codeptr=>1 = $03D0 // BNE +3
|
||||
else
|
||||
//puts("BROR "); puti(dest)
|
||||
codeptr=>2 = $03F0 // BEQ +3
|
||||
codeptr=>1 = $03F0 // BEQ +3
|
||||
fin
|
||||
codeptr->4 = $4C // JMP abs
|
||||
codeptr=>3 = $4C48 // PHA; JMP abs
|
||||
codeptr=>5 = addrxlate=>[dest]
|
||||
if not (codeptr->6 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 5 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 7
|
||||
VX++ // INX
|
||||
A_IS_TOS = FALSE
|
||||
codeptr = codeptr + 7
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $B0 // ADDLB
|
||||
is $B2 // ADDLW
|
||||
//puts("ADDLB "); puti(j)
|
||||
i++
|
||||
j = ^(bytecode+i)
|
||||
if not A_IS_TOS
|
||||
*codeptr = $D0B5+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if VY <> j
|
||||
*codeptr = $A0+(j<<8) // LDY #imm
|
||||
if not X_IS_IFP
|
||||
*codeptr = $E0A6 // LDX IFP
|
||||
codeptr = codeptr + 2
|
||||
VY = j
|
||||
X_IS_IFP = TRUE
|
||||
fin
|
||||
codeptr->0 = $18 // CLC
|
||||
codeptr=>1 = $E071 // ADC (IFP),Y
|
||||
if opcode == $B0
|
||||
//puts("ADDLB "); puti(j)
|
||||
codeptr=>3 = $0290 // BCC +2
|
||||
codeptr=>5 = $C0F6+(VX<<8) // INC ESTKH,X
|
||||
codeptr = codeptr + 7
|
||||
A_IS_TOS = TOS_DIRTY // STA ESTKL,X
|
||||
else
|
||||
codeptr=>0 = $E685 // STA TMP
|
||||
codeptr=>2 = $B5+(J<<8) // LDA dp,X
|
||||
codeptr->4 = $29 // AND #$00FF
|
||||
codeptr=>5 = $00FF
|
||||
codeptr->7 = $18 // CLC
|
||||
codeptr=>8 = $E665 // ADC TMP
|
||||
codeptr = codeptr + 10
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $B2 // ADDLW
|
||||
i++
|
||||
j = ^(bytecode+i)
|
||||
//puts("ADDLW "); puti(j)
|
||||
codeptr=>3 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr=>5 = $C0B5+(VX<<8) // LDA ESTKH,X
|
||||
codeptr->7 = $C8 // INY
|
||||
codeptr=>8 = $E071 // ADC (IFP),Y
|
||||
codeptr=>10 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 12
|
||||
VY++
|
||||
A_IS_TOS = FALSE
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if not X_IS_IFP
|
||||
*codeptr = $E0A6 // LDX IFP
|
||||
codeptr = codeptr + 2
|
||||
X_IS_IFP = TRUE
|
||||
fin
|
||||
codeptr->0 = $18 // CLC
|
||||
codeptr=>1 = $75+(J<<8) // ADC dp,X
|
||||
codeptr = codeptr + 3
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $B4 // ADDAB
|
||||
dest = *(bytecode+i+1)
|
||||
i = i + 2
|
||||
//puts("ADDAB $"); puth(dest)
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
codeptr=>0 = $E685 // STA TMP
|
||||
codeptr=>2 = $20E2 // SEP #$20 -> 8 BIT ACCUM/MEM
|
||||
codeptr->4 = $AD // LDA abs
|
||||
codeptr=>5 = dest
|
||||
codeptr=>7 = $20C2 // REP #$20 -> 16 BIT ACCUM/MEM
|
||||
codeptr->9 = $29 // AND #$00FF
|
||||
codeptr=>10 = $00FF
|
||||
codeptr->12 = $18 // CLC
|
||||
codeptr=>13 = $E665 // ADC TMP
|
||||
codeptr = codeptr + 15
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $B6 // ADDAW
|
||||
dest = *(bytecode+i+1)
|
||||
i = i + 2
|
||||
if not A_IS_TOS
|
||||
*codeptr = $D0B5+(VX<<8) // LDA ESTKL,X
|
||||
codeptr = codeptr + 2
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
codeptr=>0 = $6D18 // CLC; ADC abs
|
||||
codeptr=>0 = $6D18 // CLC; ADC abs
|
||||
codeptr=>2 = dest
|
||||
if opcode == $B4
|
||||
//puts("ADDAB $"); puth(dest)
|
||||
codeptr=>4 = $0290 // BCC +2
|
||||
codeptr=>6 = $C0F6+(VX<<8) // INC ESTKH,X
|
||||
codeptr = codeptr + 8
|
||||
A_IS_TOS = TOS_DIRTY // STA ESTKL,X
|
||||
else
|
||||
//puts("ADDAW $"); puth(dest)
|
||||
codeptr=>4 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr=>6 = $C0B5+(VX<<8) // LDA ESTKH,X
|
||||
codeptr->8 = $6D // ADC abs
|
||||
codeptr=>9 = dest+1
|
||||
codeptr=>11 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 13
|
||||
A_IS_TOS = FALSE
|
||||
fin
|
||||
codeptr = codeptr + 4
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $B8 // IDXLB
|
||||
i++
|
||||
j = ^(bytecode+i)
|
||||
//puts("IDXLB "); puti(j)
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if VY <> j
|
||||
*codeptr = $A0+(j<<8) // LDY #imm
|
||||
if not X_IS_IFP
|
||||
*codeptr = $E0A6 // LDX IFP
|
||||
codeptr = codeptr + 2
|
||||
X_IS_IFP = TRUE
|
||||
fin
|
||||
*codeptr = $E0B1 // LDA (IFP),Y
|
||||
codeptr = codeptr + 2
|
||||
if j <> 0
|
||||
*codeptr = $00A0 // LDY #$00
|
||||
codeptr = codeptr + 2
|
||||
fin
|
||||
codeptr->0 = $0A // ASL
|
||||
codeptr=>1 = $0290 // BCC +2
|
||||
codeptr=>3 = $18C8 // INY; CLC
|
||||
codeptr=>5 = $D075+(VX<<8) // ADC ESTKL,X
|
||||
codeptr=>7 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr->9 = $98 // TYA
|
||||
codeptr=>10 = $C075+(VX<<8) // ADC ESTKH,X
|
||||
codeptr=>12 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 14
|
||||
VY = UNKNOWN
|
||||
A_IS_TOS = FALSE
|
||||
codeptr=>0 = $E685 // STA TMP
|
||||
codeptr=>2 = $B5+(J<<8) // LDA dp,X
|
||||
codeptr->4 = $29 // AND #$00FF
|
||||
codeptr=>5 = $00FF
|
||||
codeptr=>7 = $180A // ASL; CLC
|
||||
codeptr=>9 = $E665 // ADC TMP
|
||||
codeptr = codeptr + 11
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $BA // IDXLW
|
||||
i++
|
||||
j = ^(bytecode+i)
|
||||
//puts("IDXLW "); puti(j)
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if VY <> j
|
||||
*codeptr = $A0+(j<<8) // LDY #imm
|
||||
if not X_IS_IFP
|
||||
*codeptr = $E0A6 // LDX IFP
|
||||
codeptr = codeptr + 2
|
||||
X_IS_IFP = TRUE
|
||||
fin
|
||||
codeptr=>0 = $E0B1 // LDA (IFP),Y
|
||||
codeptr->2 = $0A // ASL
|
||||
codeptr=>3 = $E785 // STA $E7:TMPL
|
||||
codeptr->5 = $C8 // INY
|
||||
codeptr=>6 = $E0B1 // LDA (IFP),Y
|
||||
codeptr=>8 = $A82A // ROL; TAY
|
||||
codeptr=>10 = $E7A5 // LDA $E7:TMPL
|
||||
codeptr->12 = $18 // CLC
|
||||
codeptr=>13 = $D075+(VX<<8) // ADC ESTKL,X
|
||||
codeptr=>15 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr->17 = $98 // TYA
|
||||
codeptr=>18 = $C075+(VX<<8) // ADC ESTKH,X
|
||||
codeptr=>20 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 22
|
||||
VY = UNKNOWN
|
||||
A_IS_TOS = FALSE
|
||||
codeptr=>0 = $180A // ASL; CLC
|
||||
codeptr=>2 = $75+(J<<8) // ADC dp,X
|
||||
codeptr = codeptr + 4
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $BC // IDXAB
|
||||
dest = *(bytecode+i+1)
|
||||
i = i + 2
|
||||
//puts("IDXAB $"); puth(*(bytecode+i))
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
if VY <> 0
|
||||
*codeptr = $00A0 // LDY #$00
|
||||
codeptr = codeptr + 2
|
||||
fin
|
||||
codeptr->0 = $AD // LDA abs
|
||||
codeptr=>1 = dest
|
||||
codeptr->3 = $0A // ASL
|
||||
codeptr=>4 = $0290 // BCC +2
|
||||
codeptr=>6 = $18C8 // INY; CLC
|
||||
codeptr=>8 = $D075+(VX<<8) // ADC ESTKL,X
|
||||
codeptr=>10 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr->12 = $98 // TYA
|
||||
codeptr=>13 = $C075+(VX<<8) // ADC ESTKH,X
|
||||
codeptr=>15 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 17
|
||||
VY = UNKNOWN
|
||||
A_IS_TOS = FALSE
|
||||
codeptr=>0 = $E685 // STA TMP
|
||||
codeptr=>2 = $20E2 // SEP #$20 -> 8 BIT ACCUM/MEM
|
||||
codeptr->4 = $AD // LDA abs
|
||||
codeptr=>5 = dest
|
||||
codeptr=>7 = $20C2 // REP #$20 -> 16 BIT ACCUM/MEM
|
||||
codeptr->9 = $29 // AND #$00FF
|
||||
codeptr=>10 = $00FF
|
||||
codeptr=>12 = $180A // ASL; CLC
|
||||
codeptr=>14 = $E665 // ADC TMP
|
||||
codeptr = codeptr + 16
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $BE // IDXAW
|
||||
dest = *(bytecode+i+1)
|
||||
i = i + 2
|
||||
//puts("IDXAW $"); puth(dest)
|
||||
if A_IS_TOS & TOS_DIRTY
|
||||
^codeptr = $48; codeptr++ // PHA
|
||||
if not A_IS_TOS
|
||||
^codeptr = $68; codeptr++ // PLA
|
||||
fin
|
||||
codeptr->0 = $AD // LDA abs
|
||||
codeptr=>1 = dest
|
||||
codeptr->3 = $0A // ASL
|
||||
codeptr=>4 = $E785 // STA $E7:TMPL
|
||||
codeptr->6 = $AD // LDA abs+1
|
||||
codeptr=>7 = dest+1
|
||||
codeptr=>9 = $A82A // ROL; TAY
|
||||
codeptr=>11 = $E7A5 // LDA $E7:TMPL
|
||||
codeptr->13 = $18 // CLC
|
||||
codeptr=>14 = $D075+(VX<<8) // ADC ESTKL,X
|
||||
codeptr=>16 = $D095+(VX<<8) // STA ESTKL,X
|
||||
codeptr->18 = $98 // TYA
|
||||
codeptr=>19 = $C075+(VX<<8) // ADC ESTKH,X
|
||||
codeptr=>21 = $C095+(VX<<8) // STA ESTKH,X
|
||||
codeptr = codeptr + 23
|
||||
VY = UNKNOWN
|
||||
A_IS_TOS = FALSE
|
||||
codeptr=>0 = $180A // ASL; CLC
|
||||
codeptr->2 = $6D // ADC abs
|
||||
codeptr=>3 = dest
|
||||
codeptr = codeptr + 5
|
||||
A_IS_TOS = TRUE // PHA
|
||||
break
|
||||
is $FE // NOPed out earlier by SELect
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user