// Multiplier by Olivier Lecluse %define statusRegister 252 %define buttonRegister 253 %define reslow 243 %define reshigh 244 %define n1 240 %define n2low 241 %define n2high 242 initsp copylr 63 n1 // first number copylr 67 n2low // second number copylr 0 n2high copylr 0 reslow // res (16 bits) = n1 x n2 copylr 0 reshigh :loop bcrsc 0 n1 call addn // adds n2 to res if n1 is odd cbr 1 statusRegister // Clear carry shiftrr n1 // shifts n1 right cbr 1 statusRegister // Clear carry shiftrl n2low // shifts n2 left shiftrl n2high copyla 255 andra n1 // tests if n1 is zero bcrss 0 statusRegister jump loop halt :addn // adds n2 to res (16 bits) copyra reslow addra n2low // 8 low bits bcrsc 1 statusRegister incr reshigh // adds carry copyar reslow copyra reshigh addra n2high // 8 high bits copyar reshigh return