]> git.sur5r.net Git - cc65/blob - src/cc65/coptptrstore.h
Added a forgotten header file.
[cc65] / src / cc65 / coptptrstore.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                               coptptrstore.h                              */
4 /*                                                                           */
5 /*                      Optimize stores through pointers                     */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2012,      Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef COPTPTRSTORE_H
37 #define COPTPTRSTORE_H
38
39
40
41 /* cc65 */
42 #include "codeseg.h"
43
44
45
46 /*****************************************************************************/
47 /*                                   Code                                    */
48 /*****************************************************************************/
49
50
51
52 unsigned OptPtrStore1 (CodeSeg* S);
53 /* Search for the sequence:
54  *
55  *      lda     #<(label+0)
56  *      ldx     #>(label+0)
57  *      clc
58  *      adc     xxx
59  *      bcc     L
60  *      inx
61  * L:   jsr     pushax
62  *      ldx     #$00
63  *      lda     yyy
64  *      ldy     #$00
65  *      jsr     staspidx
66  *
67  * and replace it by:
68  *
69  *      ldy     xxx
70  *      ldx     #$00
71  *      lda     yyy
72  *      sta     label,y
73  */
74
75 unsigned OptPtrStore2 (CodeSeg* S);
76 /* Search for the sequence:
77  *
78  *      lda     #<(label+0)
79  *      ldx     #>(label+0)
80  *      ldy     aaa
81  *      clc
82  *      adc     (sp),y
83  *      bcc     L
84  *      inx
85  * L:   jsr     pushax
86  *      ldx     #$00
87  *      lda     yyy
88  *      ldy     #$00
89  *      jsr     staspidx
90  *
91  * and replace it by:
92  *
93  *      ldy     aaa
94  *      ldx     #$00
95  *      lda     (sp),y
96  *      tay
97  *      lda     yyy
98  *      sta     label,y
99  */
100
101 unsigned OptPtrStore3 (CodeSeg* S);
102 /* Search for the sequence:
103  *
104  *      lda     #<(label+0)
105  *      ldx     #>(label+0)
106  *      ldy     aaa
107  *      clc
108  *      adc     (sp),y
109  *      bcc     L
110  *      inx
111  * L:   jsr     pushax
112  *      ldy     #bbb
113  *      ldx     #$00
114  *      lda     (sp),y
115  *      ldy     #$00
116  *      jsr     staspidx
117  *
118  * and replace it by:
119  *
120  *      ldy     aaa
121  *      lda     (sp),y
122  *      tax
123  *      ldy     #bbb-2
124  *      lda     (sp),y
125  *      sta     label,x
126  *      ldx     #$00
127  */
128
129 unsigned OptPtrStore4 (CodeSeg* S);
130 /* Search for the sequence:
131  *
132  *      ldy     #offs1
133  *      clc
134  *      adc     (sp),y
135  *      bcc     L
136  *      inx
137  * L:   jsr     pushax
138  *      ldy     #offs2
139  *      ldx     #$00
140  *      lda     (sp),y
141  *      ldy     #$00
142  *      jsr     staspidx
143  *
144  * and replace it by:
145  *
146  *      sta     ptr1
147  *      stx     ptr1+1
148  *      ldx     #$00
149  *      ldy     #offs2-2
150  *      lda     (sp),y
151  *      ldy     #offs1
152  *      sta     (ptr1),y
153  */
154
155 unsigned OptPtrStore5 (CodeSeg* S);
156 /* Search for the sequence:
157  *
158  *      jsr     pushax
159  *      ldy     xxx
160  *      jsr     ldauidx
161  *      subop
162  *      ldy     yyy
163  *      jsr     staspidx
164  *
165  * and replace it by:
166  *
167  *      sta     ptr1
168  *      stx     ptr1+1
169  *      ldy     xxx
170  *      ldx     #$00
171  *      lda     (ptr1),y
172  *      subop
173  *      ldy     yyy
174  *      sta     (ptr1),y
175  *
176  * In case a/x is loaded from the register bank before the pushax, we can even
177  * use the register bank instead of ptr1.
178  *
179  *
180  *      jsr     pushax
181  *      ldy     xxx
182  *      jsr     ldauidx
183  *      ldx     #$00
184  *      lda     (zp),y
185  *      subop
186  *      ldy     yyy
187  *      sta     (zp),y
188  *      jsr     staspidx
189  */
190
191
192
193 /* End of coptptrstore.h */
194 #endif
195
196
197
198