1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-08 09:28:57 +00:00

Check for H/W/ access on BYTE loads

This commit is contained in:
David Schmenk 2018-04-15 14:47:14 -07:00
parent bbac311c4f
commit 8d119d3d8c
3 changed files with 70 additions and 26 deletions

Binary file not shown.

View File

@ -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

View File

@ -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