-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmult78.a
More file actions
37 lines (34 loc) · 673 Bytes
/
mult78.a
File metadata and controls
37 lines (34 loc) · 673 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
; mult78.a
; from 'Commodore 128 assembly language programming' by Mark Andrews (1986) https://archive.org/details/Commodore_128_Assembly_Language_Programming/page/n165/mode/2up
; I swapped names of prodh and prodl to avoid confusion
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 188.00
; 20 bytes
mpr = $02
mpd = $03
prodl = $04
* = $0200
; 8 bit unsigned multiply, 16 bit result
;
; On Entry:
; mpr: multiplier
; mpd: multiplicand
; On Exit:
; (A, prodl): product
mult
lda #0
sta prodl
ldx #8
loop
lsr mpr
bcc noadd
clc
adc mpd
noadd
ror
ror prodl
dex
bne loop
; sta prodh
rts