diff --git a/PLASMA-SYS2.PO b/PLASMA-SYS2.PO index c3295a7..58a0af1 100755 Binary files a/PLASMA-SYS2.PO and b/PLASMA-SYS2.PO differ diff --git a/src/libsrc/apple/jit16.pla b/src/libsrc/apple/jit16.pla index 37e7ce1..ad443d9 100644 --- a/src/libsrc/apple/jit16.pla +++ b/src/libsrc/apple/jit16.pla @@ -37,6 +37,12 @@ def defcpy(dst, defptr)#0 *$0042 = dst call($C311, 0, 0, 0, $04) // CALL XMOVE with carry clear (AUX->MAIN) and ints disabled end +// +// Identify hardware addresses for certain byte sized access operations +// +def is_hwaddr(addr) + return addr >= $C000 and addr < $C100 +end include "libsrc/jit16core.pla" // // Install JIT compiler diff --git a/src/libsrc/jit16core.pla b/src/libsrc/jit16core.pla index 39de7be..4b87a8e 100644 --- a/src/libsrc/jit16core.pla +++ b/src/libsrc/jit16core.pla @@ -671,13 +671,24 @@ def compiler(defptr)#0 if A_IS_TOS ^codeptr = $48; codeptr++ // PHA fin - codeptr=>0 = $20E2 // SEP #$20 -> 8 BIT ACCUM/MEM - codeptr->2 = $AD // LDA abs - codeptr=>3 = dest - codeptr=>5 = $20C2 // REP #$20 -> 16 BIT ACCUM/MEM - codeptr->7 = $29 // AND #$00FF - codeptr=>8 = $00FF - codeptr = codeptr + 10 + if is_hwaddr(dest) + // + // Ensure we only do byte sized accesses to H/W + // + codeptr=>0 = $20E2 // SEP #$20 -> 8 BIT ACCUM/MEM + codeptr->2 = $AD // LDA abs + codeptr=>3 = dest + codeptr=>5 = $20C2 // REP #$20 -> 16 BIT ACCUM/MEM + codeptr->7 = $29 // AND #$00FF + codeptr=>8 = $00FF + codeptr = codeptr + 10 + else + codeptr->0 = $AD // LDA abs + codeptr=>1 = dest + codeptr->3 = $29 // AND #$00FF + codeptr=>4 = $00FF + codeptr = codeptr + 6 + fin A_IS_TOS = TRUE // PHA break is $6A // LAW @@ -1163,16 +1174,30 @@ def compiler(defptr)#0 if not A_IS_TOS ^codeptr = $68; codeptr++ // PLA fin - codeptr=>0 = $E785 // 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 = $E765 // ADC TMP - codeptr = codeptr + 15 + if is_hwaddr(dest) + // + // Ensure only byte sized accesses to H/W addresses + // + codeptr=>0 = $E785 // 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 = $E765 // ADC TMP + codeptr = codeptr + 15 + else + codeptr=>0 = $E785 // STA TMP + codeptr->2 = $AD // LDA abs + codeptr=>3 = dest + codeptr->5 = $29 // AND #$00FF + codeptr=>6 = $00FF + codeptr->8 = $18 // CLC + codeptr=>9 = $E765 // ADC TMP + codeptr = codeptr + 15 + fin A_IS_TOS = TRUE // PHA break is $B6 // ADDAW @@ -1233,15 +1258,28 @@ def compiler(defptr)#0 if not A_IS_TOS ^codeptr = $68; codeptr++ // PLA fin - codeptr=>0 = $E785 // 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 = $0A // ASL - codeptr=>13 = $E765 // ADC TMP + if is_hwaddr(dest) + // + // Ensure only byte sized accesses to H/W addresses + // + codeptr=>0 = $E785 // 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 = $0A // ASL + codeptr=>13 = $E765 // ADC TMP + else + codeptr=>0 = $E785 // STA TMP + codeptr->4 = $AD // LDA abs + codeptr=>5 = dest + codeptr->9 = $29 // AND #$00FF + codeptr=>10 = $00FF + codeptr->12 = $0A // ASL + codeptr=>13 = $E765 // ADC TMP + fin codeptr = codeptr + 15 A_IS_TOS = TRUE // PHA break