1 /*****************************************************************************/
5 /* Predefined macro packages for the ca65 macroassembler */
9 /* (C) 1998 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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. */
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: */
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 */
32 /*****************************************************************************/
46 /*****************************************************************************/
48 /*****************************************************************************/
52 /* Predefined packages */
55 static char MacGeneric[] =
56 ".macro add Arg1, Arg2\n"
58 " .if .paramcount = 2\n"
64 ".macro sub Arg1, Arg2\n"
66 " .if .paramcount = 2\n"
73 /* Long branch macros */
74 static char MacLongBranch[] =
76 " .if .match(Target, 0)\n"
79 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
87 " .if .match(Target, 0)\n"
90 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
98 " .if .match(Target, 0)\n"
101 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
108 ".macro jpl Target\n"
109 " .if .match(Target, 0)\n"
112 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
119 ".macro jcs Target\n"
120 " .if .match(Target, 0)\n"
123 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
130 ".macro jcc Target\n"
131 " .if .match(Target, 0)\n"
134 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
141 ".macro jvs Target\n"
142 " .if .match(Target, 0)\n"
145 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
152 ".macro jvc Target\n"
153 " .if .match(Target, 0)\n"
156 " .elseif .def(Target,local) .and ((*+2)-(Target) <= 127)\n"
164 /* Commodore specific macros */
165 static char MacCBM[] =
166 ".macro scrcode str\n"
167 " .repeat .strlen(str), i\n"
168 " .if (.strat(str, i) >= '@' .and .strat(str, i) <= 'z')\n"
169 " .byte .strat(str, i) - '@'\n"
170 " .elseif (.strat(str, i) >= 'A' .and .strat(str, i) <= 'Z')\n"
171 " .byte .strat(str, i) - 'A' + 65\n"
172 " .elseif (.strat(str, i) = '[')\n"
174 " .elseif (.strat(str, i) = ']')\n"
176 " .elseif (.strat(str, i) = '^')\n"
178 " .elseif (.strat(str, i) = '_')\n"
181 " .byte .strat(str, i)\n"
189 /* Table with pointers to the different packages */
190 static char* MacPackages [] = {
198 /*****************************************************************************/
200 /*****************************************************************************/
204 void InsertMacPack (unsigned Id)
205 /* Insert the macro package with the given id in the input stream */
207 /* Check the parameter */
208 CHECK (Id < sizeof (MacPackages) / sizeof (MacPackages [0]));
210 /* Insert the package */
211 NewInputData (MacPackages [Id], 0);