1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00
kickc/src/test/ref/multiply-2s.asm
2020-02-23 09:44:36 +01:00

46 lines
727 B
NASM

// Check that multiplication by factors of 2 is converted to shifts
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
.label SCREEN = $400
ldx #0
__b1:
// (SCREEN+0*40)[i] = i*1
txa
sta SCREEN,x
// i*2
txa
asl
// (SCREEN+1*40)[i] = i*2
sta SCREEN+1*$28,x
// i*4
txa
asl
asl
// (SCREEN+2*40)[i] = i*4
sta SCREEN+2*$28,x
// i*8
txa
asl
asl
asl
// (SCREEN+3*40)[i] = i*8
sta SCREEN+3*$28,x
// sb = -(signed byte)i
txa
eor #$ff
clc
adc #1
// sb*2
asl
// (SCREEN+5*40)[i] = (byte)(sb*2)
sta SCREEN+5*$28,x
// for(byte i: 0..10)
inx
cpx #$b
bne __b1
// }
rts
}