-
Notifications
You must be signed in to change notification settings - Fork 6
/
mult79.a
50 lines (46 loc) · 876 Bytes
/
mult79.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
46
47
48
49
50
; mult79.a
; from a NASA Report (1981) https://archive.org/details/NASA_NTRS_Archive_19820015020/page/n65/mode/2up
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 399.00
; 39 bytes
mplr = $02
mpcnd = $03
prodl = $04
prodh = $05
temp = $06
* = $0200
; 8 bit x 8 bit unsigned multiply, 16 bit result
;
; No branches based on data are allowed in this routine, I think so it can be run
; simultaneously across multiple processors and they all finish at exactly the same time.
;
; On Entry:
; mplr: multiplier
; mpcnd: multiplicand
; On Exit:
; (prodl, prodh): 16 bit product
mult
lda #0
sta prodl
sta prodh
ldx #8
loop
asl prodl
rol prodh
asl mplr
lda #0
sbc #0
eor #$ff
and mpcnd
sta temp
clc
adc prodl
sta prodl
lda prodh
adc #0
sta prodh
dex
bne loop
end
rts