-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmult40.a
More file actions
44 lines (40 loc) · 763 Bytes
/
mult40.a
File metadata and controls
44 lines (40 loc) · 763 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
; mult40.a
; from https://gitlab.riscosopen.org/RiscOS/Sources/Apps/Diversions/Meteors/-/blob/master/Srce6502/MetSrc
; from 'Meteors' for the BBC Micro
;
; 8 bit x 8bit unsigned multiply, 16 bit result
; Average cycles: 278
; 35 bytes
_a = $02 ; two bytes
_x = $04
_y = $05 ; two bytes
* = $0200
; ***************************************************************************************
; On Entry:
; _x: multiplier
; _y: multiplicand
; On Exit:
; _a: low byte of product
; _a+1: high byte of product
mult
lda #0
sta _y+1
sta _a
sta _a+1
ldy #8
mloop
lsr _x
bcc noadd
clc
lda _a
adc _y
sta _a
lda _a+1
adc _y+1
sta _a+1
noadd
asl _y
rol _y+1
dey
bne mloop
rts