-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmult27.a
56 lines (50 loc) · 875 Bytes
/
mult27.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
51
52
53
54
55
56
; mult27.a
; from https://sites.google.com/site/h2obsession/programming/6502
; tweaked slightly
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 46.49
; 1312 bytes
temp = $02
* = $0200
; 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)
}
idTab
!for i, 0, 255 {
!byte i
}
; ***************************************************************************************
; On Entry:
; A = multiplicand
; X = multiplier
; On Exit:
; temp: low byte of product
; A: high byte of product
mult
sta getLow+1
sta getHigh+1
sec
sbc idTab,x
bcs doMult
sbc #0
eor #255
doMult
tay
getLow
lda sqrLow,x
sbc sqrLow,y
sta temp
getHigh
lda sqrHigh,x
sbc sqrHigh,y
; tax
;temp = *+1
; lda #0
rts