-
Notifications
You must be signed in to change notification settings - Fork 13
/
rules.65c816
107 lines (96 loc) · 1.03 KB
/
rules.65c816
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# fetch/store rules when we need X
# Need rules for each form except ,x as we can't ldx ,x
lda #%1
tax
lda %2,x
=
ldx #%1
lda %2,x
lda _%1
tax
lda %2,x
=
ldx _%1
lda %2,x
lda T%1
tax
sta %2,x
=
ldx T%1
sta %2,x
lda %1,y
tax
lda %2,x
=
ldx %1,y
lda %2,x
# Optimize 32:16 compare
stz @hireg
lda %1
;invalregs
jsr __cc%2
=
lda %1
jsr __cc%2z
# Maths we didn't manage to clean up at tree level
pha
lda %1
sta @tmp
pla
clc
adc @tmp
=
clc
adc %1
# the rep clears the other half of A for free
rep #0x20
and #0xff
=
rep #0x20
# Remove double and masking cases (eg >> 8 and cast is the usual)
and #0xff
and #0xff
=
and #0xff
# Flip simple x operations around. Should do this in the compiler for
# such cases (eg << >> )
lda %1,y
pha
lda %2
plx
;invalregs
jsr %3
=
ldx %1,y
lda %2
jsr %3
lda #%1
pha
lda %2
plx
;invalregs
jsr %3
=
ldx #%1
lda %2
jsr %3
lda _%1
pha
lda %2
plx
;invalregs
jsr %3
=
ldx _%1
lda %2
jsr %3
lda #%1
pha
lda %2
plx
;invalregs
jsr %3
=
ldx #%1
lda %2
jsr %3