-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmult57.a
More file actions
52 lines (45 loc) · 883 Bytes
/
mult57.a
File metadata and controls
52 lines (45 loc) · 883 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
47
48
49
50
51
52
; mult57.a
; from https://sites.google.com/site/h2obsession/programming/6502
; alternative smaller memory version (see mult27.a)
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 48.49
; 1058 bytes
* = $0200
prod_low = $02
; Tables must be aligned with page boundary
sqrLow
!for i, 0, 511 {
!byte <((i*i)/4)
}
sqrHigh
!for i, 0, 511 {
!byte >((i*i)/4)
}
; ***************************************************************************************
; On Entry:
; A = multiplicand
; X = multiplier
; On Exit:
; prod_low: low byte of product
; A: high byte of product
mult
sta getLow+1
sta getHigh+1
stx temp1
sec
temp1 = *+1
sbc #0
bcs doMult
sbc #0
eor #255
doMult
tay
getLow
lda sqrLow,x
sbc sqrLow,y
sta prod_low
getHigh
lda sqrHigh,x
sbc sqrHigh,y
rts