1 /*****************************************************************************/
5 /* Pseudo instructions for the ca65 macroassembler */
9 /* (C) 1998-2000 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 /*****************************************************************************/
69 /*****************************************************************************/
71 /*****************************************************************************/
75 /* Keyword we're about to handle */
76 static char Keyword [sizeof (SVal)+1] = ".";
80 /*****************************************************************************/
82 /*****************************************************************************/
86 static void DoUnexpected (void);
87 /* Got an unexpected keyword */
89 static void DoInvalid (void);
90 /* Handle a token that is invalid here, since it should have been handled on
91 * a much lower level of the expression hierarchy. Getting this sort of token
92 * means that the lower level code has bugs.
93 * This function differs to DoUnexpected in that the latter may be triggered
94 * by the user by using keywords in the wrong location. DoUnexpected is not
95 * an error in the assembler itself, while DoInvalid is.
100 /*****************************************************************************/
101 /* Helper functions */
102 /*****************************************************************************/
106 static void SetBoolOption (unsigned char* Flag)
107 /* Read a on/off/+/- option and set flag accordingly */
109 static const char* Keys[] = {
114 if (Tok == TOK_PLUS) {
117 } else if (Tok == TOK_MINUS) {
120 } else if (Tok == TOK_IDENT) {
121 /* Map the keyword to a number */
122 switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) {
123 case 0: *Flag = 0; NextTok (); break;
124 case 1: *Flag = 1; NextTok (); break;
125 default: ErrorSkip (ERR_ONOFF_EXPECTED); break;
127 } else if (Tok == TOK_SEP || Tok == TOK_EOF) {
128 /* Without anything assume switch on */
131 ErrorSkip (ERR_ONOFF_EXPECTED);
137 static void ExportImport (void (*SymFunc) (const char*, int), int ZP)
138 /* Export or import symbols */
141 if (Tok != TOK_IDENT) {
142 ErrorSkip (ERR_IDENT_EXPECTED);
147 if (Tok == TOK_COMMA) {
157 static long IntArg (long Min, long Max)
158 /* Read an integer argument and check a range. Accept the token "unlimited"
159 * and return -1 in this case.
162 if (Tok == TOK_IDENT && strcmp (SVal, "unlimited") == 0) {
166 long Val = ConstExpression ();
167 if (Val < Min || Val > Max) {
177 static void ConDes (const char* Name, unsigned Type)
178 /* Parse remaining line for constructor/destructor of the remaining type */
182 /* Optional constructor priority */
183 if (Tok == TOK_COMMA) {
184 /* Priority value follows */
186 Prio = ConstExpression ();
187 if (Prio < CD_PRIO_MIN || Prio > CD_PRIO_MAX) {
188 /* Value out of range */
193 /* Use the default priority value */
197 /* Define the symbol */
198 SymConDes (Name, Type, (unsigned) Prio);
203 /*****************************************************************************/
204 /* Handler functions */
205 /*****************************************************************************/
209 static void DoA16 (void)
210 /* Switch the accu to 16 bit mode (assembler only) */
212 if (GetCPU() != CPU_65816) {
213 Error (ERR_816_MODE_ONLY);
215 /* Immidiate mode has two extension bytes */
216 ExtBytes [AMI_IMM_ACCU] = 2;
222 static void DoA8 (void)
223 /* Switch the accu to 8 bit mode (assembler only) */
225 if (GetCPU() != CPU_65816) {
226 Error (ERR_816_MODE_ONLY);
228 /* Immidiate mode has one extension byte */
229 ExtBytes [AMI_IMM_ACCU] = 1;
235 static void DoAddr (void)
236 /* Define addresses */
239 if (GetCPU() == CPU_65816) {
240 EmitWord (ForceWordExpr (Expression ()));
242 /* Do a range check */
243 EmitWord (Expression ());
245 if (Tok != TOK_COMMA) {
255 static void DoAlign (void)
256 /* Align the PC to some boundary */
262 /* Read the alignment value */
263 Align = ConstExpression ();
264 if (Align <= 0 || Align > 0x10000) {
265 ErrorSkip (ERR_RANGE);
269 /* Optional value follows */
270 if (Tok == TOK_COMMA) {
272 Val = ConstExpression ();
273 /* We need a byte value here */
274 if (!IsByteRange (Val)) {
275 ErrorSkip (ERR_RANGE);
282 /* Check if the alignment is a power of two */
283 Bit = BitFind (Align);
284 if (Align != (0x01L << Bit)) {
287 SegAlign (Bit, (int) Val);
293 static void DoASCIIZ (void)
294 /* Define text with a zero terminator */
299 /* Must have a string constant */
300 if (Tok != TOK_STRCON) {
301 ErrorSkip (ERR_STRCON_EXPECTED);
305 /* Get the length of the string constant */
308 /* Translate into target charset and emit */
309 TgtTranslateBuf (SVal, Len);
310 EmitData ((unsigned char*) SVal, Len);
312 if (Tok == TOK_COMMA) {
323 static void DoAutoImport (void)
324 /* Mark unresolved symbols as imported */
326 SetBoolOption (&AutoImport);
331 static void DoBss (void)
332 /* Switch to the BSS segment */
339 static void DoByte (void)
343 if (Tok == TOK_STRCON) {
344 /* A string, translate into target charset and emit */
345 unsigned Len = strlen (SVal);
346 TgtTranslateBuf (SVal, Len);
347 EmitData ((unsigned char*) SVal, Len);
350 EmitByte (Expression ());
352 if (Tok != TOK_COMMA) {
356 /* Do smart handling of dangling comma */
357 if (Tok == TOK_SEP) {
358 Error (ERR_UNEXPECTED_EOL);
367 static void DoCase (void)
368 /* Switch the IgnoreCase option */
370 SetBoolOption (&IgnoreCase);
371 IgnoreCase = !IgnoreCase;
376 static void DoCode (void)
377 /* Switch to the code segment */
384 static void DoConDes (void)
385 /* Export a symbol as constructor/destructor */
387 static const char* Keys[] = {
391 char Name [sizeof (SVal)];
394 /* Symbol name follows */
395 if (Tok != TOK_IDENT) {
396 ErrorSkip (ERR_IDENT_EXPECTED);
402 /* Type follows. May be encoded as identifier or numerical */
404 if (Tok == TOK_IDENT) {
406 /* Map the following keyword to a number, then skip it */
407 Type = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
410 /* Check if we got a valid keyword */
419 /* Read the type as numerical value */
420 Type = ConstExpression ();
421 if (Type < CD_TYPE_MIN || Type > CD_TYPE_MAX) {
422 /* Value out of range */
429 /* Parse the remainder of the line and export the symbol */
430 ConDes (Name, (unsigned) Type);
435 static void DoConstructor (void)
436 /* Export a symbol as constructor */
438 char Name [sizeof (SVal)];
440 /* Symbol name follows */
441 if (Tok != TOK_IDENT) {
442 ErrorSkip (ERR_IDENT_EXPECTED);
448 /* Parse the remainder of the line and export the symbol */
449 ConDes (Name, CD_TYPE_CON);
454 static void DoData (void)
455 /* Switch to the data segment */
462 static void DoDbg (void)
463 /* Add debug information from high level code */
465 static const char* Keys[] = {
473 /* We expect a subkey */
474 if (Tok != TOK_IDENT) {
475 ErrorSkip (ERR_IDENT_EXPECTED);
479 /* Map the following keyword to a number */
480 Key = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
482 /* Skip the subkey */
485 /* Check the key and dispatch to a handler */
487 case 0: DbgInfoFile (); break;
488 case 1: DbgInfoLine (); break;
489 case 2: DbgInfoSym (); break;
490 default: ErrorSkip (ERR_SYNTAX); break;
496 static void DoDByt (void)
497 /* Output double bytes */
500 EmitWord (SwapExpr (Expression ()));
501 if (Tok != TOK_COMMA) {
511 static void DoDebugInfo (void)
512 /* Switch debug info on or off */
514 SetBoolOption (&DbgSyms);
519 static void DoDefine (void)
520 /* Define a one line macro */
522 MacDef (MAC_STYLE_DEFINE);
527 static void DoDestructor (void)
528 /* Export a symbol as destructor */
530 char Name [sizeof (SVal)];
532 /* Symbol name follows */
533 if (Tok != TOK_IDENT) {
534 ErrorSkip (ERR_IDENT_EXPECTED);
540 /* Parse the remainder of the line and export the symbol */
541 ConDes (Name, CD_TYPE_DES);
546 static void DoDWord (void)
550 EmitDWord (Expression ());
551 if (Tok != TOK_COMMA) {
561 static void DoEnd (void)
562 /* End of assembly */
569 static void DoEndProc (void)
570 /* Leave a lexical level */
577 static void DoError (void)
580 if (Tok != TOK_STRCON) {
581 ErrorSkip (ERR_STRCON_EXPECTED);
583 Error (ERR_USER, SVal);
590 static void DoExitMacro (void)
591 /* Exit a macro expansion */
593 if (!InMacExpansion ()) {
594 /* We aren't expanding a macro currently */
603 static void DoExport (void)
604 /* Export a symbol */
606 ExportImport (SymExport, 0);
611 static void DoExportZP (void)
612 /* Export a zeropage symbol */
614 ExportImport (SymExport, 1);
619 static void DoFarAddr (void)
620 /* Define far addresses (24 bit) */
623 EmitFarAddr (Expression ());
624 if (Tok != TOK_COMMA) {
634 static void DoFeature (void)
635 /* Switch the Feature option */
637 /* Allow a list of comma separated keywords */
640 /* We expect an identifier */
641 if (Tok != TOK_IDENT) {
642 ErrorSkip (ERR_IDENT_EXPECTED);
646 /* Make the string attribute lower case */
649 /* Set the feature and check for errors */
650 if (SetFeature (SVal) == FEAT_UNKNOWN) {
652 ErrorSkip (ERR_ILLEGAL_FEATURE);
655 /* Skip the keyword */
659 /* Allow more than one keyword */
660 if (Tok == TOK_COMMA) {
670 static void DoFileOpt (void)
671 /* Insert a file option */
675 /* The option type may be given as a keyword or as a number. */
676 if (Tok == TOK_IDENT) {
678 /* Option given as keyword */
679 static const char* Keys [] = {
680 "AUTHOR", "COMMENT", "COMPILER"
683 /* Map the option to a number */
684 OptNum = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
687 ErrorSkip (ERR_OPTION_KEY_EXPECTED);
691 /* Skip the keyword */
694 /* Must be followed by a comma */
697 /* We accept only string options for now */
698 if (Tok != TOK_STRCON) {
699 ErrorSkip (ERR_STRCON_EXPECTED);
703 /* Insert the option */
722 Internal ("Invalid OptNum: %l", OptNum);
731 /* Option given as number */
732 OptNum = ConstExpression ();
733 if (!IsByteRange (OptNum)) {
734 ErrorSkip (ERR_RANGE);
738 /* Must be followed by a comma */
741 /* We accept only string options for now */
742 if (Tok != TOK_STRCON) {
743 ErrorSkip (ERR_STRCON_EXPECTED);
747 /* Insert the option */
748 OptStr ((unsigned char) OptNum, SVal);
757 static void DoGlobal (void)
758 /* Declare a global symbol */
760 ExportImport (SymGlobal, 0);
765 static void DoGlobalZP (void)
766 /* Declare a global zeropage symbol */
768 ExportImport (SymGlobal, 1);
773 static void DoI16 (void)
774 /* Switch the index registers to 16 bit mode (assembler only) */
776 if (GetCPU() != CPU_65816) {
777 Error (ERR_816_MODE_ONLY);
779 /* Immidiate mode has two extension bytes */
780 ExtBytes [AMI_IMM_INDEX] = 2;
786 static void DoI8 (void)
787 /* Switch the index registers to 16 bit mode (assembler only) */
789 if (GetCPU() != CPU_65816) {
790 Error (ERR_816_MODE_ONLY);
792 /* Immidiate mode has one extension byte */
793 ExtBytes [AMI_IMM_INDEX] = 1;
799 static void DoImport (void)
800 /* Import a symbol */
802 ExportImport (SymImport, 0);
807 static void DoImportZP (void)
808 /* Import a zero page symbol */
810 ExportImport (SymImport, 1);
815 static void DoIncBin (void)
816 /* Include a binary file */
818 char Name [sizeof (SVal)];
824 /* Name must follow */
825 if (Tok != TOK_STRCON) {
826 ErrorSkip (ERR_STRCON_EXPECTED);
832 /* A starting offset may follow */
833 if (Tok == TOK_COMMA) {
835 Start = ConstExpression ();
837 /* And a length may follow */
838 if (Tok == TOK_COMMA) {
840 Count = ConstExpression ();
845 /* Try to open the file */
846 F = fopen (Name, "rb");
848 ErrorSkip (ERR_CANNOT_OPEN_INCLUDE, Name, strerror (errno));
852 /* Get the size of the file */
853 fseek (F, 0, SEEK_END);
856 /* If a count was not given, calculate it now */
858 Count = Size - Start;
860 /* Nothing to read - flag this as a range error */
861 ErrorSkip (ERR_RANGE);
865 /* Count was given, check if it is valid */
866 if (Start + Count > Size) {
867 ErrorSkip (ERR_RANGE);
872 /* Seek to the start position */
873 fseek (F, Start, SEEK_SET);
875 /* Read chunks and insert them into the output */
878 unsigned char Buf [1024];
880 /* Calculate the number of bytes to read */
881 size_t BytesToRead = (Count > (long)sizeof(Buf))? sizeof(Buf) : (size_t) Count;
884 size_t BytesRead = fread (Buf, 1, BytesToRead, F);
885 if (BytesToRead != BytesRead) {
886 /* Some sort of error */
887 ErrorSkip (ERR_CANNOT_READ_INCLUDE, Name, strerror (errno));
891 /* Insert it into the output */
892 EmitData (Buf, BytesRead);
894 /* Keep the counters current */
899 /* Close the file, ignore errors since it's r/o */
905 static void DoInclude (void)
906 /* Include another file */
908 char Name [MAX_STR_LEN+1];
910 /* Name must follow */
911 if (Tok != TOK_STRCON) {
912 ErrorSkip (ERR_STRCON_EXPECTED);
922 static void DoInvalid (void)
923 /* Handle a token that is invalid here, since it should have been handled on
924 * a much lower level of the expression hierarchy. Getting this sort of token
925 * means that the lower level code has bugs.
926 * This function differs to DoUnexpected in that the latter may be triggered
927 * by the user by using keywords in the wrong location. DoUnexpected is not
928 * an error in the assembler itself, while DoInvalid is.
931 Internal ("Unexpected token: %s", Keyword);
936 static void DoLineCont (void)
937 /* Switch the use of line continuations */
939 SetBoolOption (&LineCont);
944 static void DoList (void)
945 /* Enable/disable the listing */
947 /* Get the setting */
949 SetBoolOption (&List);
951 /* Manage the counter */
961 static void DoListBytes (void)
962 /* Set maximum number of bytes to list for one line */
964 SetListBytes (IntArg (MIN_LIST_BYTES, MAX_LIST_BYTES));
969 static void DoLocalChar (void)
970 /* Define the character that starts local labels */
972 if (Tok != TOK_CHARCON) {
973 ErrorSkip (ERR_CHARCON_EXPECTED);
975 if (IVal != '@' && IVal != '?') {
976 Error (ERR_ILLEGAL_LOCALSTART);
978 LocalStart = (char) IVal;
986 static void DoMacPack (void)
987 /* Insert a macro package */
989 /* Macro package names */
990 static const char* Keys [] = {
997 /* We expect an identifier */
998 if (Tok != TOK_IDENT) {
999 ErrorSkip (ERR_IDENT_EXPECTED);
1003 /* Map the keyword to a number */
1004 Package = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
1007 ErrorSkip (ERR_ILLEGAL_MACPACK);
1011 /* Skip the package name */
1014 /* Insert the package */
1015 InsertMacPack (Package);
1020 static void DoMacro (void)
1021 /* Start a macro definition */
1023 MacDef (MAC_STYLE_CLASSIC);
1028 static void DoNull (void)
1029 /* Switch to the NULL segment */
1036 static void DoOrg (void)
1037 /* Start absolute code */
1039 long PC = ConstExpression ();
1040 if (PC < 0 || PC > 0xFFFFFF) {
1049 static void DoOut (void)
1050 /* Output a string */
1052 if (Tok != TOK_STRCON) {
1053 ErrorSkip (ERR_STRCON_EXPECTED);
1055 /* Output the string and be sure to flush the output to keep it in
1056 * sync with any error messages if the output is redirected to a file.
1058 printf ("%s\n", SVal);
1066 static void DoP02 (void)
1067 /* Switch to 6502 CPU */
1074 static void DoPC02 (void)
1075 /* Switch to 65C02 CPU */
1082 static void DoP816 (void)
1083 /* Switch to 65816 CPU */
1090 static void DoPageLength (void)
1091 /* Set the page length for the listing */
1093 PageLength = IntArg (MIN_PAGE_LEN, MAX_PAGE_LEN);
1098 static void DoProc (void)
1099 /* Start a new lexical scope */
1101 if (Tok == TOK_IDENT) {
1102 /* The new scope has a name */
1103 SymDef (SVal, CurrentPC (), IsZPSeg (), 1);
1111 static void DoReloc (void)
1112 /* Enter relocatable mode */
1119 static void DoRepeat (void)
1120 /* Repeat some instruction block */
1127 static void DoRes (void)
1128 /* Reserve some number of storage bytes */
1133 Count = ConstExpression ();
1134 if (Count > 0xFFFF || Count < 0) {
1135 ErrorSkip (ERR_RANGE);
1138 if (Tok == TOK_COMMA) {
1140 Val = ConstExpression ();
1141 /* We need a byte value here */
1142 if (!IsByteRange (Val)) {
1143 ErrorSkip (ERR_RANGE);
1147 /* Emit constant values */
1149 Emit0 ((unsigned char) Val);
1153 /* Emit fill fragments */
1160 static void DoROData (void)
1161 /* Switch to the r/o data segment */
1168 static void DoSegment (void)
1169 /* Switch to another segment */
1171 static const char* AttrTab [] = {
1172 "ZEROPAGE", "DIRECT",
1176 char Name [sizeof (SVal)];
1179 if (Tok != TOK_STRCON) {
1180 ErrorSkip (ERR_STRCON_EXPECTED);
1183 /* Save the name of the segment and skip it */
1184 strcpy (Name, SVal);
1187 /* Check for an optional segment attribute */
1188 SegType = SEGTYPE_DEFAULT;
1189 if (Tok == TOK_COMMA) {
1191 if (Tok != TOK_IDENT) {
1192 ErrorSkip (ERR_IDENT_EXPECTED);
1194 int Attr = GetSubKey (AttrTab, sizeof (AttrTab) / sizeof (AttrTab [0]));
1200 SegType = SEGTYPE_ZP;
1205 SegType = SEGTYPE_ABS;
1211 SegType = SEGTYPE_FAR;
1215 Error (ERR_ILLEGAL_SEG_ATTR);
1221 /* Set the segment */
1222 UseSeg (Name, SegType);
1228 static void DoSmart (void)
1229 /* Smart mode on/off */
1231 SetBoolOption (&SmartMode);
1236 static void DoSunPlus (void)
1237 /* Switch to the SUNPLUS CPU */
1239 SetCPU (CPU_SUNPLUS);
1244 static void DoUnexpected (void)
1245 /* Got an unexpected keyword */
1247 Error (ERR_UNEXPECTED, Keyword);
1253 static void DoWarning (void)
1256 if (Tok != TOK_STRCON) {
1257 ErrorSkip (ERR_STRCON_EXPECTED);
1259 Warning (WARN_USER, SVal);
1266 static void DoWord (void)
1270 EmitWord (Expression ());
1271 if (Tok != TOK_COMMA) {
1281 static void DoZeropage (void)
1282 /* Switch to the zeropage segment */
1289 /*****************************************************************************/
1291 /*****************************************************************************/
1295 /* Control commands flags */
1297 ccNone = 0x0000, /* No special flags */
1298 ccKeepToken = 0x0001 /* Do not skip the current token */
1301 /* Control command table */
1303 unsigned Flags; /* Flags for this directive */
1304 void (*Handler) (void); /* Command handler */
1306 typedef struct CtrlDesc_ CtrlDesc;
1308 #define PSEUDO_COUNT (sizeof (CtrlCmdTab) / sizeof (CtrlCmdTab [0]))
1309 static CtrlDesc CtrlCmdTab [] = {
1312 { ccNone, DoAddr }, /* .ADDR */
1313 { ccNone, DoAlign },
1314 { ccNone, DoASCIIZ },
1315 { ccNone, DoAutoImport },
1316 { ccNone, DoUnexpected }, /* .BLANK */
1321 { ccNone, DoUnexpected, }, /* .CONCAT */
1322 { ccNone, DoConDes },
1323 { ccNone, DoUnexpected }, /* .CONST */
1324 { ccNone, DoConstructor },
1325 { ccNone, DoUnexpected }, /* .CPU */
1329 { ccNone, DoDebugInfo },
1330 { ccNone, DoDefine },
1331 { ccNone, DoUnexpected }, /* .DEFINED */
1332 { ccNone, DoDestructor },
1333 { ccNone, DoDWord },
1334 { ccKeepToken, DoConditionals }, /* .ELSE */
1335 { ccKeepToken, DoConditionals }, /* .ELSEIF */
1337 { ccKeepToken, DoConditionals }, /* .ENDIF */
1338 { ccNone, DoUnexpected }, /* .ENDMACRO */
1339 { ccNone, DoEndProc },
1340 { ccNone, DoUnexpected }, /* .ENDREPEAT */
1341 { ccNone, DoError },
1342 { ccNone, DoExitMacro },
1343 { ccNone, DoExport },
1344 { ccNone, DoExportZP },
1345 { ccNone, DoFarAddr },
1346 { ccNone, DoFeature },
1347 { ccNone, DoFileOpt },
1348 { ccNone, DoUnexpected }, /* .FORCEWORD */
1349 { ccNone, DoGlobal },
1350 { ccNone, DoGlobalZP },
1353 { ccKeepToken, DoConditionals }, /* .IF */
1354 { ccKeepToken, DoConditionals }, /* .IFBLANK */
1355 { ccKeepToken, DoConditionals }, /* .IFCONST */
1356 { ccKeepToken, DoConditionals }, /* .IFDEF */
1357 { ccKeepToken, DoConditionals }, /* .IFNBLANK */
1358 { ccKeepToken, DoConditionals }, /* .IFNCONST */
1359 { ccKeepToken, DoConditionals }, /* .IFNDEF */
1360 { ccKeepToken, DoConditionals }, /* .IFNREF */
1361 { ccKeepToken, DoConditionals }, /* .IFP02 */
1362 { ccKeepToken, DoConditionals }, /* .IFP816 */
1363 { ccKeepToken, DoConditionals }, /* .IFPC02 */
1364 { ccKeepToken, DoConditionals }, /* .IFREF */
1365 { ccNone, DoImport },
1366 { ccNone, DoImportZP },
1367 { ccNone, DoIncBin },
1368 { ccNone, DoInclude },
1369 { ccNone, DoInvalid }, /* .LEFT */
1370 { ccNone, DoLineCont },
1372 { ccNone, DoListBytes },
1373 { ccNone, DoUnexpected }, /* .LOCAL */
1374 { ccNone, DoLocalChar },
1375 { ccNone, DoMacPack },
1376 { ccNone, DoMacro },
1377 { ccNone, DoUnexpected }, /* .MATCH */
1378 { ccNone, DoInvalid }, /* .MID */
1384 { ccNone, DoPageLength },
1385 { ccNone, DoUnexpected }, /* .PARAMCOUNT */
1388 { ccNone, DoUnexpected }, /* .REFERENCED */
1389 { ccNone, DoReloc },
1390 { ccNone, DoRepeat },
1392 { ccNone, DoInvalid }, /* .RIGHT */
1393 { ccNone, DoROData },
1394 { ccNone, DoSegment },
1395 { ccNone, DoSmart },
1396 { ccNone, DoUnexpected }, /* .STRAT */
1397 { ccNone, DoUnexpected }, /* .STRING */
1398 { ccNone, DoUnexpected }, /* .STRLEN */
1399 { ccNone, DoSunPlus },
1400 { ccNone, DoUnexpected }, /* .TCOUNT */
1401 { ccNone, DoWarning },
1403 { ccNone, DoUnexpected }, /* .XMATCH */
1404 { ccNone, DoZeropage },
1409 /*****************************************************************************/
1411 /*****************************************************************************/
1415 int TokIsPseudo (unsigned Tok)
1416 /* Return true if the given token is a pseudo instruction token */
1418 return (Tok >= TOK_FIRSTPSEUDO && Tok <= TOK_LASTPSEUDO);
1423 void HandlePseudo (void)
1424 /* Handle a pseudo instruction */
1428 /* Calculate the index into the table */
1429 unsigned Index = Tok - TOK_FIRSTPSEUDO;
1432 if (PSEUDO_COUNT != (TOK_LASTPSEUDO - TOK_FIRSTPSEUDO + 1)) {
1433 Internal ("Pseudo mismatch: PSEUDO_COUNT = %u, actual count = %u\n",
1434 PSEUDO_COUNT, TOK_LASTPSEUDO - TOK_FIRSTPSEUDO + 1);
1436 CHECK (Index < PSEUDO_COUNT);
1438 /* Get the pseudo intruction descriptor */
1439 D = &CtrlCmdTab [Index];
1441 /* Remember the instruction, then skip it if needed */
1442 if ((D->Flags & ccKeepToken) == 0) {
1443 strcpy (Keyword+1, SVal);
1447 /* Call the handler */