mirror of
https://github.com/irmen/prog8.git
synced 2025-02-19 11:31:07 +00:00
added optimized mul 320 routine
This commit is contained in:
parent
5bedc1b333
commit
452c29574d
@ -774,6 +774,31 @@ stack_mul_word_100 .proc
|
|||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
stack_mul_word_320 .proc
|
||||||
|
; stackW = stackLo * 256 + stackLo * 64 (stackHi doesn't matter)
|
||||||
|
ldy P8ESTACK_LO+1,x
|
||||||
|
lda #0
|
||||||
|
sta P8ESTACK_HI+1,x
|
||||||
|
tya
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
asl a
|
||||||
|
rol P8ESTACK_HI+1,x
|
||||||
|
sta P8ESTACK_LO+1,x
|
||||||
|
tya
|
||||||
|
clc
|
||||||
|
adc P8ESTACK_HI+1,x
|
||||||
|
sta P8ESTACK_HI+1,x
|
||||||
|
rts
|
||||||
|
.pend
|
||||||
|
|
||||||
; ----------- optimized multiplications (in-place A (byte) and ?? (word)) : ---------
|
; ----------- optimized multiplications (in-place A (byte) and ?? (word)) : ---------
|
||||||
mul_byte_3 .proc
|
mul_byte_3 .proc
|
||||||
@ -1241,6 +1266,32 @@ mul_word_100 .proc
|
|||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
mul_word_320 .proc
|
||||||
|
; AY = A * 256 + A * 64 (msb doesn't matter)
|
||||||
|
sta P8ZP_SCRATCH_B1
|
||||||
|
ldy #0
|
||||||
|
sty P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
asl a
|
||||||
|
rol P8ZP_SCRATCH_REG
|
||||||
|
pha
|
||||||
|
clc
|
||||||
|
lda P8ZP_SCRATCH_B1
|
||||||
|
adc P8ZP_SCRATCH_REG
|
||||||
|
tay
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
.pend
|
||||||
|
|
||||||
; ----------- end optimized multiplications -----------
|
; ----------- end optimized multiplications -----------
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
|
|
||||||
// for expressions and augmented assignments:
|
// for expressions and augmented assignments:
|
||||||
val optimizedByteMultiplications = setOf(3,5,6,7,9,10,11,12,13,14,15,20,25,40,50,80,100)
|
val optimizedByteMultiplications = setOf(3,5,6,7,9,10,11,12,13,14,15,20,25,40,50,80,100)
|
||||||
val optimizedWordMultiplications = setOf(3,5,6,7,9,10,12,15,20,25,40,50,80,100)
|
val optimizedWordMultiplications = setOf(3,5,6,7,9,10,12,15,20,25,40,50,80,100,320)
|
||||||
|
|
||||||
private val assemblyLines = mutableListOf<String>()
|
private val assemblyLines = mutableListOf<String>()
|
||||||
private val globalFloatConsts = mutableMapOf<Double, String>() // all float values in the entire program (value -> varname)
|
private val globalFloatConsts = mutableMapOf<Double, String>() // all float values in the entire program (value -> varname)
|
||||||
|
@ -5,12 +5,59 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
const ubyte size = 100
|
uword uw
|
||||||
|
ubyte ub
|
||||||
|
|
||||||
ubyte[size+10] bytes
|
ub = 10
|
||||||
|
uw = ub * 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
ub = 100
|
||||||
|
uw = ub * 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
ub = 200
|
||||||
|
uw = ub * 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 10
|
||||||
|
uw *= 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 100
|
||||||
|
uw *= 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 200
|
||||||
|
uw *= 320
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 0
|
||||||
|
ub = 10
|
||||||
|
uw = uw + 320*ub
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 0
|
||||||
|
ub = 100
|
||||||
|
uw = uw + 320*ub
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uw = 0
|
||||||
|
ub = 200
|
||||||
|
uw = uw + 320*ub
|
||||||
|
txt.print_uw(uw)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
txt.print("hello\n")
|
txt.print("hello\n")
|
||||||
ubyte dummy = bytes[0]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1,4 @@
|
|||||||
TODO
|
A contributed syntax definition file for Sublime Text 3 can be obtained from:
|
||||||
|
|
||||||
|
https://github.com/akubiczek/Prog8-TmLanguage-VsCode/tree/master/sublime3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user