27 lines
702 B
ArmAsm
27 lines
702 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,X) :clobbers-arguments 2
|
|
|
|
;; https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication#Russian_peasant_multiplication
|
|
|
|
.include "arithmatic.inc"
|
|
|
|
LDA #$00
|
|
JMP start
|
|
loop:
|
|
ASL VAL_B
|
|
start:
|
|
ROR VAL_A; add to awnser if VAL_A is odd
|
|
BCC loop
|
|
CLC
|
|
ADC VAL_B; add val_b because val_a was odd.
|
|
LDX VAL_B
|
|
BNE loop
|
|
endloop:
|
|
RTS
|
|
.endproc
|