-
Notifications
You must be signed in to change notification settings - Fork 6
/
smult10.a
69 lines (61 loc) · 1.32 KB
/
smult10.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
57
58
59
60
61
62
63
64
65
66
67
68
69
; smult10.a
; from Piotr Fusik in the short lived Polish Atari Disk Magazine Syzygy 6 http://ftp.pigwa.net/stuff/collections/atari_forever/Ziny/Syzygy/ (1999)
; (for English version see https://forums.atariage.com/topic/78839-russian-multiplication/#comment-975865)
;
; 8 bit x 8 bit signed multiply, 16 bit result
; Average cycles: 53.99
; 2079 bytes (+ 3 unused bytes between tables)
* = 0x200
; Tables must be aligned to page boundary
square1_low
!for i, -256, 254 {
!byte <((i*i)/4)
}
unused1
!byte 0
square1_high
!for i, -256, 254 {
!byte >((i*i)/4)
}
unused2
!byte 0
square2_low
!for i, -255, 255 {
!byte <((i*i)/4)
}
unused3
!byte 0
square2_high
!for i, -255, 255 {
!byte >((i*i)/4)
}
; ----------------------------------------------------------------------------------
; Description: Signed 8-bit multiplication with signed 16-bit result.
;
; On Entry:
; A: 8-bit signed value
; X: 8-bit signed value
;
; On Exit:
; Y (low byte) and A (high byte): 16-bit signed product
mult_8bit_signed
eor #$80
sta sm1
sta sm3
eor #$ff
sta sm2
sta sm4
txa
eor #$80
tax
sec
sm1 = * + 1
lda square1_low,x
sm2 = * + 1
sbc square2_low,x
tay
sm3 = * + 1
lda square1_high,x
sm4 = * + 1
sbc square2_high,x
rts