mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +00:00
removed double mul code
This commit is contained in:
parent
702cf304d0
commit
c0a5f8fef0
@ -49,10 +49,6 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
DataType.UWORD, DataType.WORD -> assignVariableWord(assign.target, variable)
|
DataType.UWORD, DataType.WORD -> assignVariableWord(assign.target, variable)
|
||||||
DataType.FLOAT -> assignVariableFloat(assign.target, variable)
|
DataType.FLOAT -> assignVariableFloat(assign.target, variable)
|
||||||
DataType.STR -> assignVariableString(assign.target, variable)
|
DataType.STR -> assignVariableString(assign.target, variable)
|
||||||
in PassByReferenceDatatypes -> {
|
|
||||||
// TODO what about when the name is a struct? name.firstStructVarName(program.namespace) ****************************************
|
|
||||||
assignAddressOf(assign.target, variable)
|
|
||||||
}
|
|
||||||
else -> throw AssemblyError("unsupported assignment target type ${assign.target.datatype}")
|
else -> throw AssemblyError("unsupported assignment target type ${assign.target.datatype}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -720,41 +720,22 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"*" -> {
|
"*" -> {
|
||||||
if(dt == DataType.UWORD){
|
// the mul code works for both signed and unsigned
|
||||||
if(value in asmgen.optimizedWordMultiplications) {
|
if(value in asmgen.optimizedWordMultiplications) {
|
||||||
asmgen.out(" lda $name | ldy $name+1 | jsr math.mul_word_$value | sta $name | sty $name+1")
|
asmgen.out(" lda $name | ldy $name+1 | jsr math.mul_word_$value | sta $name | sty $name+1")
|
||||||
} else {
|
|
||||||
asmgen.out("""
|
|
||||||
lda $name
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda $name+1
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
lda #<$value
|
|
||||||
ldy #>$value
|
|
||||||
jsr math.multiply_words
|
|
||||||
lda math.multiply_words.result
|
|
||||||
sta $name
|
|
||||||
lda math.multiply_words.result+1
|
|
||||||
sta $name+1""")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(value.absoluteValue in asmgen.optimizedWordMultiplications) {
|
asmgen.out("""
|
||||||
asmgen.out(" lda $name | ldy $name+1 | jsr math.mul_word_$value | sta $name | sty $name+1")
|
lda $name
|
||||||
} else {
|
sta P8ZP_SCRATCH_W1
|
||||||
// TODO does this work for signed words? if so the uword/word distinction can be removed altogether ****************************************
|
lda $name+1
|
||||||
asmgen.out("""
|
sta P8ZP_SCRATCH_W1+1
|
||||||
lda $name
|
lda #<$value
|
||||||
sta P8ZP_SCRATCH_W1
|
ldy #>$value
|
||||||
lda $name+1
|
jsr math.multiply_words
|
||||||
sta P8ZP_SCRATCH_W1+1
|
lda math.multiply_words.result
|
||||||
lda #<$value
|
sta $name
|
||||||
ldy #>$value
|
lda math.multiply_words.result+1
|
||||||
jsr math.multiply_words
|
sta $name+1""")
|
||||||
lda math.multiply_words.result
|
|
||||||
sta $name
|
|
||||||
lda math.multiply_words.result+1
|
|
||||||
sta $name+1""")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"/" -> {
|
"/" -> {
|
||||||
|
@ -7,20 +7,18 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
float[] array = [1111.1,2222.2,3333.3,4444.4,5555.5]
|
uword vv = 1111
|
||||||
|
vv *= 23
|
||||||
|
txt.print_uw(vv)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
float fw
|
word ww = -1111
|
||||||
ubyte i1 = 1
|
ww *= 23
|
||||||
ubyte i2 = 3
|
txt.print_w(ww)
|
||||||
ubyte zero = 0
|
txt.chrout('\n')
|
||||||
ubyte four = 4
|
ww = -1111
|
||||||
swap(array[i1], array[0])
|
ww *= -23
|
||||||
swap(array[4], array[i2])
|
txt.print_w(ww)
|
||||||
|
|
||||||
for i1 in 0 to len(array)-1 {
|
|
||||||
floats.print_f(array[i1])
|
|
||||||
txt.chrout(',')
|
|
||||||
}
|
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
testX()
|
testX()
|
||||||
|
Loading…
Reference in New Issue
Block a user