mirror of
https://github.com/irmen/prog8.git
synced 2025-02-28 09:29:26 +00:00
fix direcetmemoryread invalid asm
This commit is contained in:
parent
22f8f4f359
commit
152888ee93
@ -1772,6 +1772,7 @@ _loop_hi ldy _index_first
|
||||
|
||||
ror2_mem_ub .proc
|
||||
; -- in-place 8-bit ror of byte at memory location on stack
|
||||
; TODO use self modifying code here
|
||||
inx
|
||||
lda c64.ESTACK_LO,x
|
||||
sta c64.SCRATCH_ZPWORD1
|
||||
@ -1788,7 +1789,7 @@ ror2_mem_ub .proc
|
||||
|
||||
rol2_mem_ub .proc
|
||||
; -- in-place 8-bit rol of byte at memory location on stack
|
||||
;" lda ${number.toHex()} | cmp #\$80 | rol a | sta ${number.toHex()}"
|
||||
; TODO use self modifying code here
|
||||
inx
|
||||
lda c64.ESTACK_LO,x
|
||||
sta c64.SCRATCH_ZPWORD1
|
||||
|
@ -40,6 +40,9 @@ fun compileProgram(filepath: Path,
|
||||
if (optimize)
|
||||
optimizeAst(programAst, errors)
|
||||
postprocessAst(programAst, errors, compilationOptions)
|
||||
|
||||
printAst(programAst) // TODO
|
||||
|
||||
if(writeAssembly)
|
||||
programName = writeAssembly(programAst, errors, outputDir, optimize, compilationOptions)
|
||||
}
|
||||
|
@ -127,8 +127,16 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
asmgen.out(" lda ${address.toHex()} | sta $ESTACK_LO_HEX,x | dex")
|
||||
}
|
||||
is IdentifierReference -> {
|
||||
// the identifier is a pointer variable, so read the value from the address in it
|
||||
val sourceName = asmgen.asmIdentifierName(expr.addressExpression as IdentifierReference)
|
||||
asmgen.out(" lda $sourceName | sta $ESTACK_LO_HEX,x | dex")
|
||||
asmgen.out("""
|
||||
lda $sourceName
|
||||
sta (+) +1
|
||||
lda $sourceName+1
|
||||
sta (+) +2
|
||||
+ lda ${'$'}ffff ; modified
|
||||
sta $ESTACK_LO_HEX,x
|
||||
dex""")
|
||||
}
|
||||
else -> {
|
||||
translateExpression(expr.addressExpression)
|
||||
|
@ -66,20 +66,11 @@ internal class PostIncrDecrAsmGen(private val program: Program, private val asmg
|
||||
}
|
||||
is IdentifierReference -> {
|
||||
val what = asmgen.asmIdentifierName(addressExpr)
|
||||
asmgen.out("""
|
||||
ldy $what
|
||||
sty ${C64Zeropage.SCRATCH_W1}
|
||||
ldy $what+1
|
||||
sty ${C64Zeropage.SCRATCH_W1 + 1}
|
||||
ldy #0
|
||||
lda (${C64Zeropage.SCRATCH_W1}),y
|
||||
""")
|
||||
asmgen.out(" lda $what | sta (+) +1 | lda $what+1 | sta (+) +2")
|
||||
if(incr)
|
||||
asmgen.out(" clc | adc #1")
|
||||
asmgen.out("+\tinc ${'$'}ffff\t; modified")
|
||||
else
|
||||
asmgen.out(" sec | sbc #1")
|
||||
|
||||
asmgen.out(" sta (${C64Zeropage.SCRATCH_W1}),y")
|
||||
asmgen.out("+\tdec ${'$'}ffff\t; modified")
|
||||
}
|
||||
else -> throw AssemblyError("weird target type $targetMemory")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user