-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmult17.a
More file actions
46 lines (40 loc) · 687 Bytes
/
mult17.a
File metadata and controls
46 lines (40 loc) · 687 Bytes
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
39
40
41
42
43
44
45
46
; mult17.a
; from Elite: https://www.bbcelite.com/cassette/main/subroutine/mu11.html
; tweaked to handle X=0 on input
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 150.47
; 28 bytes
T = $02
P = $03
* = $0200
; ***************************************************************************************
; 8 bit multiply
;
; On Entry:
; A: multiplier
; P: multiplicand
; On Exit:
; A: high byte of product
; P: low byte of product
mult
cpx #0
beq zero ; Special case: handle X=0 separately
dex
stx T
lda #0
ldx #8
lsr P
loop
bcc +
adc T
+
ror
ror P
dex
bne loop
rts
zero
txa
sta P
rts