-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmult81.a
45 lines (39 loc) · 1.44 KB
/
mult81.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
39
40
41
42
43
44
45
; mult81.a
; from the Graphics Extension ROM 1.2 at $B8D4
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 199
; 26 bytes
productLow = $02
productHigh = $03
* = $0200
; ***************************************************************************************
;
; 8 bit unsigned multiply, 16 bit result
;
; On Entry:
; X = multiplicand
; Y = multiplier
; On Exit:
; productLow/High: product (16 bit)
;
; ***************************************************************************************
mult
lda #0 ;
sta productHigh ;
tya ;
lsr ;
sta productLow ;
ldy #8 ;
multiplyLoop
bcc skipAdd ;
clc ;
txa ;
adc productHigh ;
sta productHigh ;
skipAdd
ror productHigh ;
ror productLow ;
dey ;
bne multiplyLoop ;
rts ;