Better divisions/products
The compiler could improve the generated code for math by supporting shift operations when you multiply/divide by powers of two. Version 0.70 use generic mul/div functions even when those optimization is possible
@artrag Are you sure? https://github.com/nanochess/CVBasic/blob/a4464d255b7c6c3068fe52440db9fe68604a0fb7/cpuz80.c#L468 https://github.com/nanochess/CVBasic/blob/a4464d255b7c6c3068fe52440db9fe68604a0fb7/cpuz80.c#L631
yes, I get this for frame/16
; call TCOPY($3000 + (12+(FRAME/16 and 3))*32)
LD HL,(frame)
LD DE,16
CALL _div16
LD A,L
AND 3
LD L,A
LD H,0
LD DE,12
ADD HL,DE
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD DE,12288
ADD HL,DE
CALL TCOPY
In attach the complete ASM file where the basic code is in the comments output.asm.txt
A better conversion would have been ; call TCOPY($3000 + (12+(FRAME/16 and 3))*32) LD HL,(frame) ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL LD A,H AND 3 LD L,A LD H,0 LD DE,12 ADD HL,DE ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL LD DE,12288 ADD HL,DE CALL TCOPY
An even better conversion, using the fact that the result of the division is AND 3, could have been:
; call TCOPY($3000 + (12+(FRAME/16 and 3))*32) LD A,(frame) RRCA RRCA RRCA RRCA AND 3 ADD A,12 LD L,A LD H,0 ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL LD DE,12288 ADD HL,DE CALL TCOPY