Skip to content

Commit

Permalink
optimize codegen for x += array[index] (and others)
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Jan 2, 2025
1 parent 68d5983 commit 3b4b37f
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 275 deletions.
15 changes: 15 additions & 0 deletions codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,21 @@ $repeatLabel""")
}
}

internal fun signExtendAXlsb(valueDt: BaseDataType) {
// sign extend signed byte in A to full word in AX
when(valueDt) {
BaseDataType.UBYTE -> out(" ldx #0")
BaseDataType.BYTE -> out("""
ldx #0
cmp #$80
bcc +
dex
+
""")
else -> throw AssemblyError("need byte type")
}
}

internal fun signExtendVariableLsb(asmvar: String, valueDt: BaseDataType) {
// sign extend signed byte in a var to a full word in that variable
when(valueDt) {
Expand Down
Loading

0 comments on commit 3b4b37f

Please sign in to comment.