++/-- and @Pc without translateExpression()

This commit is contained in:
Irmen de Jong 2020-11-17 23:40:42 +01:00
parent edf5e69d39
commit d212f69d89
4 changed files with 28 additions and 34 deletions

View File

@ -210,17 +210,13 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
""")
}
else -> {
asmgen.translateExpression(value) // todo directly into A
asmgen.assignExpressionToRegister(value, RegisterOrPair.A)
asmgen.out("""
inx
pha
lda P8ESTACK_LO,x
beq +
sec
bcs ++
+ clc
+ pla
""")
beq +
sec
bcs ++
+ clc
+""")
}
}
}

View File

@ -54,14 +54,8 @@ internal class PostIncrDecrAsmGen(private val program: Program, private val asmg
asmgen.out("+\tdec ${'$'}ffff\t; modified")
}
else -> {
asmgen.translateExpression(addressExpr) // todo directly into AY?
asmgen.out("""
inx
lda P8ESTACK_LO,x
sta (+) + 1
lda P8ESTACK_HI,x
sta (+) + 2
""")
asmgen.assignExpressionToRegister(addressExpr, RegisterOrPair.AY)
asmgen.out(" sta (+) + 1 | sty (+) + 2")
if(incr)
asmgen.out("+\tinc ${'$'}ffff\t; modified")
else

View File

@ -2,6 +2,7 @@
TODO
====
- reduce the amount of translateExpression() calls when the result can be directly assigned to register or variable
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
- see if we can group some errors together for instance the (now single) errors about unidentified symbols

View File

@ -6,27 +6,30 @@ main {
sub start() {
float f = 1.1
float[] farr = [2.2, 3.3]
ubyte ff = 10
floats.print_f(f)
txt.chrout('\n')
floats.print_f(farr[0])
txt.chrout(',')
floats.print_f(farr[1])
txt.chrout('\n')
swap(f, farr[1])
floats.print_f(f)
txt.chrout('\n')
floats.print_f(farr[0])
txt.chrout(',')
floats.print_f(farr[1])
txt.chrout('\n')
setflag(ff-10)
setflag(ff-9)
setflag(ff-10)
setflag(ff-9)
testX()
}
asmsub setflag(ubyte bitje @ Pc) {
%asm {{
bcs +
lda #'0'
jsr c64.CHROUT
lda #13
jmp c64.CHROUT
+ lda #'1'
jsr c64.CHROUT
lda #13
jmp c64.CHROUT
}}
}
asmsub testX() {
%asm {{
stx _saveX