mirror of
https://github.com/irmen/prog8.git
synced 2024-11-27 03:50:27 +00:00
don't inc/dec a memory mapped register
This commit is contained in:
parent
14f9382cf9
commit
88d5c68b32
@ -405,8 +405,8 @@ internal class StatementOptimizer(private val program: Program,
|
||||
if (cv == 0.0) {
|
||||
return listOf(IAstModification.Remove(assignment, parent))
|
||||
} else if (targetDt in IntegerDatatypes && floor(cv) == cv) {
|
||||
if ((vardeclDt == VarDeclType.MEMORY && cv in 1.0..3.0) || (vardeclDt != VarDeclType.MEMORY && cv in 1.0..8.0)) {
|
||||
// replace by several INCs (a bit less when dealing with memory targets)
|
||||
if (vardeclDt != VarDeclType.MEMORY && cv in 1.0..4.0) {
|
||||
// replace by several INCs if it's not a memory address (inc on a memory mapped register doesn't work very well)
|
||||
val incs = AnonymousScope(mutableListOf(), assignment.position)
|
||||
repeat(cv.toInt()) {
|
||||
incs.statements.add(PostIncrDecr(assignment.target, "++", assignment.position))
|
||||
@ -419,8 +419,8 @@ internal class StatementOptimizer(private val program: Program,
|
||||
if (cv == 0.0) {
|
||||
return listOf(IAstModification.Remove(assignment, parent))
|
||||
} else if (targetDt in IntegerDatatypes && floor(cv) == cv) {
|
||||
if ((vardeclDt == VarDeclType.MEMORY && cv in 1.0..3.0) || (vardeclDt != VarDeclType.MEMORY && cv in 1.0..8.0)) {
|
||||
// replace by several DECs (a bit less when dealing with memory targets)
|
||||
if (vardeclDt != VarDeclType.MEMORY && cv in 1.0..4.0) {
|
||||
// replace by several DECs if it's not a memory address (dec on a memory mapped register doesn't work very well)
|
||||
val decs = AnonymousScope(mutableListOf(), assignment.position)
|
||||
repeat(cv.toInt()) {
|
||||
decs.statements.add(PostIncrDecr(assignment.target, "--", assignment.position))
|
||||
|
@ -7,44 +7,49 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
; byte A = 99
|
||||
; ubyte U = $18
|
||||
; word B = 9999
|
||||
; uword W = $18f0
|
||||
;
|
||||
; c64scr.print_b(A)
|
||||
; c64.CHROUT('\n')
|
||||
; A = -A
|
||||
; c64scr.print_b(A)
|
||||
; c64.CHROUT('\n')
|
||||
;
|
||||
; U = ~U
|
||||
; c64scr.print_ubhex(U, true)
|
||||
; c64.CHROUT('\n')
|
||||
; U = not U
|
||||
; c64scr.print_ubhex(U, true)
|
||||
; c64.CHROUT('\n')
|
||||
; U = not U
|
||||
; c64scr.print_ubhex(U, true)
|
||||
; c64.CHROUT('\n')
|
||||
;
|
||||
; c64scr.print_w(B)
|
||||
; c64.CHROUT('\n')
|
||||
; B = -B
|
||||
; c64scr.print_w(B)
|
||||
; c64.CHROUT('\n')
|
||||
;
|
||||
; W = ~W
|
||||
; c64scr.print_uwhex(W, true)
|
||||
; c64.CHROUT('\n')
|
||||
; W = not W
|
||||
; c64scr.print_uwhex(W, true)
|
||||
; c64.CHROUT('\n')
|
||||
; W = not W
|
||||
; c64scr.print_uwhex(W, true)
|
||||
; c64.CHROUT('\n')
|
||||
byte A = 99
|
||||
ubyte U = $18
|
||||
word B = 9999
|
||||
uword W = $18f0
|
||||
|
||||
uword W = 43210
|
||||
c64scr.print_b(A)
|
||||
c64.CHROUT('\n')
|
||||
A = -A
|
||||
c64scr.print_b(A)
|
||||
c64.CHROUT('\n')
|
||||
|
||||
U = ~U
|
||||
c64scr.print_ubhex(U, true)
|
||||
c64.CHROUT('\n')
|
||||
U = not U
|
||||
c64scr.print_ubhex(U, true)
|
||||
c64.CHROUT('\n')
|
||||
U = not U
|
||||
c64scr.print_ubhex(U, true)
|
||||
c64.CHROUT('\n')
|
||||
|
||||
c64scr.print_w(B)
|
||||
c64.CHROUT('\n')
|
||||
B = -B
|
||||
c64scr.print_w(B)
|
||||
c64.CHROUT('\n')
|
||||
|
||||
W = ~W
|
||||
c64scr.print_uwhex(W, true)
|
||||
c64.CHROUT('\n')
|
||||
W = not W
|
||||
c64scr.print_uwhex(W, true)
|
||||
c64.CHROUT('\n')
|
||||
W = not W
|
||||
c64scr.print_uwhex(W, true)
|
||||
c64.CHROUT('\n')
|
||||
|
||||
;@($d020) += @($d020) ; TODO fix compiler hang
|
||||
|
||||
W += 3
|
||||
@($d020) += 3
|
||||
|
||||
W = 43210
|
||||
W = W as ubyte
|
||||
c64scr.print_uw(W)
|
||||
c64.CHROUT('\n')
|
||||
|
Loading…
Reference in New Issue
Block a user