c64-livecoding/wip-hugo/routines/arithmatic/mult.s

27 lines
681 B
ArmAsm

;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;I thoughtout russan thing
;;X * %1111001
;;= X + X*%1111000
;;= X + X*%1000 *%11111
;; to remember this for later, for duuqnds papper
.proc mult; user-procedure :clobbers A :clobbers-arguments 2
;; https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication#Russian_peasant_multiplication
.include "arithmatic.inc"
LDA #$00
loop:
ASL VAL_B
ROR VAL_A; add to awnser if VAL_A is odd
BCC loop
LSR VAL_B
ADC VAL_B; add val_b because val_a was odd.
ASL VAL_B
BNE loop
endloop:
RTS
.endproc