mirror of
https://github.com/irmen/prog8.git
synced 2025-03-04 05:33:07 +00:00
fix codegen for @(ptr-offset)=value writing bogus values
This commit is contained in:
parent
125b66c929
commit
9d49589d73
@ -1352,13 +1352,14 @@ $repeatLabel""")
|
||||
if(pointervar!=null && isZpVar(pointervar)) {
|
||||
val varname = asmSymbolName(pointervar)
|
||||
out(" ldy #${256-constOffset} ; negative offset $constOffset")
|
||||
out(" dec $varname+1 | sta ($varname),y | inc $varname+1") // temporarily make MSB 1 less
|
||||
out(" dec $varname+1 | sta ($varname),y | inc $varname+1") // temporarily make MSB 1 less to be able to use the negative Y offset
|
||||
return true
|
||||
} else {
|
||||
// copy the pointer var to zp first
|
||||
out(" pha")
|
||||
assignExpressionToVariable(ptrAndIndex.first, "P8ZP_SCRATCH_W2", DataType.forDt(BaseDataType.UWORD))
|
||||
out(" ldy #${256-constOffset} ; negative offset $constOffset")
|
||||
out(" dec P8ZP_SCRATCH_W2+1 | sta (P8ZP_SCRATCH_W2),y | inc P8ZP_SCRATCH_W2+1") // temporarily make MSB 1 less
|
||||
out(" dec P8ZP_SCRATCH_W2+1 | pla | sta (P8ZP_SCRATCH_W2),y") // temporarily make MSB 1 less to be able to use the negative Y offset
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -1382,13 +1383,13 @@ $repeatLabel""")
|
||||
if(pointervar!=null && isZpVar(pointervar)) {
|
||||
val varname = asmSymbolName(pointervar)
|
||||
out(" ldy #${256-constOffset} ; negative offset $constOffset")
|
||||
out(" dec $varname+1 | lda ($varname),y | inc $varname+1") // temporarily make MSB 1 less
|
||||
out(" dec $varname+1 | lda ($varname),y | inc $varname+1") // temporarily make MSB 1 less to be able to use the negative Y offset
|
||||
return true
|
||||
} else {
|
||||
// copy the pointer var to zp first
|
||||
assignExpressionToVariable(ptrAndIndex.first, "P8ZP_SCRATCH_W2", DataType.forDt(BaseDataType.UWORD))
|
||||
out(" ldy #${256-constOffset} ; negative offset $constOffset")
|
||||
out(" dec P8ZP_SCRATCH_W2+1 | lda (P8ZP_SCRATCH_W2),y | inc P8ZP_SCRATCH_W2+1") // temporarily make MSB 1 less
|
||||
out(" dec P8ZP_SCRATCH_W2+1 | lda (P8ZP_SCRATCH_W2),y") // temporarily make MSB 1 less to be able to use the negative Y offset
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- fix scoping bug
|
||||
|
||||
- Look at github PR for improved romability (see github issue 149) Also search for "TODO: Romable"
|
||||
- Sorting module gnomesort_uw could be optimized more by fully rewriting it in asm? Shellshort seems consistently faster even if most of the words are already sorted.
|
||||
|
||||
|
@ -1,15 +1,52 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
%option no_sysinit
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
bool @shared pre_start, xxx
|
||||
const ubyte VALUE = 123
|
||||
|
||||
if (pre_start != false and xxx) {
|
||||
return
|
||||
} else if (pre_start != false and xxx) {
|
||||
return
|
||||
sub start() {
|
||||
uword @shared @nozp location = $4000
|
||||
|
||||
@($3fff) = 55
|
||||
@($4000) = 56
|
||||
@($4001) = 57
|
||||
|
||||
txt.print_ub(@($3fff))
|
||||
txt.spc()
|
||||
txt.print_ub(@($4000))
|
||||
txt.spc()
|
||||
txt.print_ub(@($4001))
|
||||
txt.nl()
|
||||
|
||||
for location in $4000 to $4002 {
|
||||
@(location-1) = VALUE
|
||||
txt.print_ub(@($3fff))
|
||||
txt.spc()
|
||||
txt.print_ub(@($4000))
|
||||
txt.spc()
|
||||
txt.print_ub(@($4001))
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** TODO scoping bug
|
||||
; scoping bug:
|
||||
|
||||
|
||||
main {
|
||||
|
||||
%option no_symbol_prefixing
|
||||
|
||||
sub start() {
|
||||
other.something()
|
||||
}
|
||||
}
|
||||
|
||||
other {
|
||||
sub something() {
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user