]> git.sur5r.net Git - cc65/blob - ca65/macpack.c
Fixed _textcolor definition.
[cc65] / ca65 / macpack.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 macpack.c                                 */
4 /*                                                                           */
5 /*           Predefined macro packages for the ca65 macroassembler           */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
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 #include "error.h"
37 #include "scanner.h"
38 #include "macpack.h"
39
40
41
42 /*****************************************************************************/
43 /*                                   Data                                    */
44 /*****************************************************************************/
45
46
47
48 /* Predefined packages */
49 static const char MacGeneric [] =       /* Generic macros */
50     ".macro  add     Arg\n"
51     "        clc\n"
52     "        adc     Arg\n"
53     ".endmacro\n\n"
54     ".macro  sub     Arg\n"
55     "        sec\n"
56     "        sbc     Arg\n"
57     ".endmacro\n\n";
58
59
60
61 static const char MacLongBranch [] =    /* Long branch macros */
62     ".macro  jeq     Target\n"
63     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
64     "        beq     Target\n"
65     "        .else\n"
66     "        bne     *+5\n"
67     "        jmp     Target\n"
68     "        .endif\n"
69     ".endmacro\n\n"
70     ".macro  jne     Target\n"
71     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
72     "        bne     Target\n"
73     "        .else\n"
74     "        beq     *+5\n"
75     "        jmp     Target\n"
76     "        .endif\n"
77     ".endmacro\n\n"
78     ".macro  jmi     Target\n"
79     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
80     "        bmi     Target\n"
81     "        .else\n"
82     "        bpl     *+5\n"
83     "        jmp     Target\n"
84     "        .endif\n"
85     ".endmacro\n\n"
86     ".macro  jpl     Target\n"
87     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
88     "        bpl     Target\n"
89     "        .else\n"
90     "        bmi     *+5\n"
91     "        jmp     Target\n"
92     "        .endif\n"
93     ".endmacro\n\n"
94     ".macro  jcs     Target\n"
95     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
96     "        bcs     Target\n"
97     "        .else\n"
98     "        bcc     *+5\n"
99     "        jmp     Target\n"
100     "        .endif\n"
101     ".endmacro\n\n"
102     ".macro  jcc     Target\n"
103     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
104     "        bcc     Target\n"
105     "        .else\n"
106     "        bcs     *+5\n"
107     "        jmp     Target\n"
108     "        .endif\n"
109     ".endmacro\n\n"
110     ".macro  jvs     Target\n"
111     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
112     "        bvs     Target\n"
113     "        .else\n"
114     "        bvc     *+5\n"
115     "        jmp     Target\n"
116     "        .endif\n"
117     ".endmacro\n\n"
118     ".macro  jvc     Target\n"
119     "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
120     "        bvc     Target\n"
121     "        .else\n"
122     "        bvs     *+5\n"
123     "        jmp     Target\n"
124     "        .endif\n"
125     ".endmacro\n\n";
126
127
128
129 /* Table with pointers to the different packages */
130 static const char* MacPackages [] = {
131     MacGeneric,
132     MacLongBranch,
133 };
134
135
136
137 /*****************************************************************************/
138 /*                                   Code                                    */
139 /*****************************************************************************/
140
141
142
143 void InsertMacPack (unsigned Id)
144 /* Insert the macro package with the given id in the input stream */
145 {
146     /* Check the parameter */
147     CHECK (Id < sizeof (MacPackages) / sizeof (MacPackages [0]));
148
149     /* Insert the package */
150     NewInputData (MacPackages [Id], 0);
151 }
152
153
154