mirror of
https://github.com/irmen/prog8.git
synced 2024-12-26 14:29:35 +00:00
fixed X register corruption in some cases of rol() and ror()
This commit is contained in:
parent
10bf7f5d07
commit
dbb92881a1
@ -512,7 +512,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
|||||||
} else {
|
} else {
|
||||||
val ptrAndIndex = asmgen.pointerViaIndexRegisterPossible(what.addressExpression)
|
val ptrAndIndex = asmgen.pointerViaIndexRegisterPossible(what.addressExpression)
|
||||||
if(ptrAndIndex!=null) {
|
if(ptrAndIndex!=null) {
|
||||||
// TODO FIX X REGISTER CORRUPTION
|
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
||||||
asmgen.assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.X)
|
asmgen.assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.X)
|
||||||
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
||||||
asmgen.assignExpressionToRegister(ptrAndIndex.first, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(ptrAndIndex.first, RegisterOrPair.AY)
|
||||||
@ -521,6 +521,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
|||||||
sta (+) + 1
|
sta (+) + 1
|
||||||
sty (+) + 2
|
sty (+) + 2
|
||||||
+ ror ${'$'}ffff,x ; modified""")
|
+ ror ${'$'}ffff,x ; modified""")
|
||||||
|
asmgen.restoreRegisterLocal(CpuRegister.X)
|
||||||
} else {
|
} else {
|
||||||
asmgen.assignExpressionToRegister(what.addressExpression, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(what.addressExpression, RegisterOrPair.AY)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
@ -614,7 +615,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
|||||||
} else {
|
} else {
|
||||||
val ptrAndIndex = asmgen.pointerViaIndexRegisterPossible(what.addressExpression)
|
val ptrAndIndex = asmgen.pointerViaIndexRegisterPossible(what.addressExpression)
|
||||||
if(ptrAndIndex!=null) {
|
if(ptrAndIndex!=null) {
|
||||||
// TODO FIX X CORRUPTION
|
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
||||||
asmgen.assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.X)
|
asmgen.assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.X)
|
||||||
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
asmgen.saveRegisterLocal(CpuRegister.X, (fcall as Node).definingSubroutine!!)
|
||||||
asmgen.assignExpressionToRegister(ptrAndIndex.first, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(ptrAndIndex.first, RegisterOrPair.AY)
|
||||||
@ -623,6 +624,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
|||||||
sta (+) + 1
|
sta (+) + 1
|
||||||
sty (+) + 2
|
sty (+) + 2
|
||||||
+ rol ${'$'}ffff,x ; modified""")
|
+ rol ${'$'}ffff,x ; modified""")
|
||||||
|
asmgen.restoreRegisterLocal(CpuRegister.X)
|
||||||
} else {
|
} else {
|
||||||
asmgen.assignExpressionToRegister(what.addressExpression, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(what.addressExpression, RegisterOrPair.AY)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
|
@ -3,9 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- BUG in 6502 codegen: ubyte one = 1 | value = one+one+one+one+one is not 5 if rol(ptr[1]) is inbetween
|
|
||||||
caused by X register corruption in the ROL and ROR code
|
|
||||||
|
|
||||||
- add unit test for name error and name shadowing warning.
|
- add unit test for name error and name shadowing warning.
|
||||||
- optimize pointervar indexing codegen: writing (all sorts of things)
|
- optimize pointervar indexing codegen: writing (all sorts of things)
|
||||||
- pipe operator: (targets other than 'Virtual'): allow non-unary function calls in the pipe that specify the other argument(s) in the calls. Already working for VM target.
|
- pipe operator: (targets other than 'Virtual'): allow non-unary function calls in the pipe that specify the other argument(s) in the calls. Already working for VM target.
|
||||||
|
113
examples/test.p8
113
examples/test.p8
@ -39,70 +39,63 @@ main {
|
|||||||
ubyte[10] data = [11,22,33,4,5,6,7,8,9,10]
|
ubyte[10] data = [11,22,33,4,5,6,7,8,9,10]
|
||||||
uword bitmapbuf = &data
|
uword bitmapbuf = &data
|
||||||
|
|
||||||
rol(bitmapbuf[1])
|
value = bitmapbuf[2]
|
||||||
ror(bitmapbuf[1])
|
txt.print_ub(value) ;; 33
|
||||||
value = one+one+one
|
|
||||||
txt.print_ub(value) ; 3
|
|
||||||
txt.nl()
|
txt.nl()
|
||||||
|
|
||||||
|
; 11 22 33
|
||||||
|
txt.print_ub(bitmapbuf[0])
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[1])
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[2])
|
||||||
|
txt.nl()
|
||||||
|
rol(bitmapbuf[0])
|
||||||
|
rol(bitmapbuf[0])
|
||||||
|
txt.print_ub(bitmapbuf[0]) ; 44
|
||||||
|
txt.spc()
|
||||||
|
ror(bitmapbuf[0])
|
||||||
|
ror(bitmapbuf[0])
|
||||||
|
txt.print_ub(bitmapbuf[0]) ; 11
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
; 22 44 66
|
||||||
|
txt.print_ub(bitmapbuf[0]*2)
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[1]*2)
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[2]*2)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
value = one+one+one+one+one
|
||||||
|
txt.print_ub(value) ; 5
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
bitmapbuf[0] = one
|
||||||
|
bitmapbuf[1] = one+one
|
||||||
|
bitmapbuf[2] = one+one+one
|
||||||
|
bitmapbuf[2] += 4
|
||||||
|
bitmapbuf[2] -= 2
|
||||||
|
bitmapbuf[2] -= 2
|
||||||
|
swap(bitmapbuf[0], bitmapbuf[1])
|
||||||
|
|
||||||
|
; 2 1 3
|
||||||
|
txt.print_ub(bitmapbuf[0])
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[1])
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ub(bitmapbuf[2])
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
for value in data {
|
||||||
|
txt.print_ub(value)
|
||||||
|
txt.spc()
|
||||||
|
}
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
test_stack.test()
|
test_stack.test()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; value = bitmapbuf[2]
|
|
||||||
; txt.print_ub(value) ;; 33
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; ; 11 22 33
|
|
||||||
; txt.print_ub(bitmapbuf[0])
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[1])
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[2])
|
|
||||||
; txt.nl()
|
|
||||||
; rol(bitmapbuf[0])
|
|
||||||
; rol(bitmapbuf[0])
|
|
||||||
; txt.print_ub(bitmapbuf[0]) ; 44
|
|
||||||
; txt.spc()
|
|
||||||
; ror(bitmapbuf[0])
|
|
||||||
; ror(bitmapbuf[0])
|
|
||||||
; txt.print_ub(bitmapbuf[0]) ; 11
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; ; 22 44 66
|
|
||||||
; txt.print_ub(bitmapbuf[0]*2)
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[1]*2)
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[2]*2)
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
; value = one+one+one+one+one
|
|
||||||
; txt.print_ub(value) ; 5
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
; bitmapbuf[0] = one
|
|
||||||
; bitmapbuf[1] = one+one
|
|
||||||
; bitmapbuf[2] = one+one+one
|
|
||||||
; bitmapbuf[2] += 4
|
|
||||||
; bitmapbuf[2] -= 2
|
|
||||||
; bitmapbuf[2] -= 2
|
|
||||||
; swap(bitmapbuf[0], bitmapbuf[1])
|
|
||||||
;
|
|
||||||
; ; 2 1 3
|
|
||||||
; txt.print_ub(bitmapbuf[0])
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[1])
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(bitmapbuf[2])
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; for value in data {
|
|
||||||
; txt.print_ub(value)
|
|
||||||
; txt.spc()
|
|
||||||
; }
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
|
|
||||||
; ; a "pixelshader":
|
; ; a "pixelshader":
|
||||||
; sys.gfx_enable(0) ; enable lo res screen
|
; sys.gfx_enable(0) ; enable lo res screen
|
||||||
; ubyte shifter
|
; ubyte shifter
|
||||||
|
Loading…
Reference in New Issue
Block a user