-
Notifications
You must be signed in to change notification settings - Fork 6
/
mult8.a
38 lines (34 loc) · 1015 Bytes
/
mult8.a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; mult8.a
; from Apple Assembly Line, January 1986: FAST.8X8.SLYE at http://www.txbobsc.com/aal/1986/aal8601.html#a5
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 153.52
; 29 bytes
multiplicand = $02
multiplier = $03
* = $0200
; ***************************************************************************************
; multiply A*X
; returns product: X is the low byte, A is the high byte
mult
cpx #0 ;
beq zero ; a*0=0
dex ; decrement multiplicand to avoid the clc before 'adc multiplicand'
stx multiplicand ;
lsr ; prepare first bit
sta multiplier ;
lda #0 ;
ldx #8 ;
loop
bcc skip ; no add
adc multiplicand ;
skip
ror ;
ror multiplier ;
dex ;
bne loop ;
ldx multiplier ;
rts ;
zero
txa ; a = 0
rts ;