2 // RMAC - Reboot's Macro Assembler for all Atari computers
3 // DIRECT.C - Directive Handling
4 // Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
27 TOKEN exprbuf[128]; // Expression buffer
28 SYM * symbolPtr[1000000]; // Symbol pointers table
29 static long unused; // For supressing 'write' warnings
30 char buffer[256]; // Scratch buffer for messages
32 // Function prototypes
69 int d_equrundef(void);
81 // Directive handler table
92 (void *)d_init, // 9 init
94 (void *)d_goto, // 11 goto
95 (void *)d_dc, // 12 dc
96 (void *)d_ds, // 13 ds
97 d_undmac, // 14 undefmac
100 (void *)d_dcb, // 17 dcb
104 d_incbin, // 21 .incbin //load
105 d_unimpl, // 22 disable
106 d_unimpl, // 23 enable
108 d_regbank0, // 25 .regbank0
109 d_regbank1, // 26 .regbank1
111 d_assert, // 28 assert
113 d_unimpl, // 30* endif
114 d_unimpl, // 31* endc
116 d_include, // 33 include
118 d_unimpl, // 35* macro
119 ExitMacro, // 36* exitm
120 d_unimpl, // 37* endm
124 d_phrase, // 41* endr
125 d_dphrase, // 42 struct
126 d_qphrase, // 43 ends
128 d_subttl, // 45 subttl
132 d_noclear, // 49 .noclear
133 d_equrundef, // 50 .equrundef/.regundef
134 d_ccundef, // 51 .ccundef
135 d_print, // 52 .print
136 d_cstruct, // 53 .cstruct
137 d_jpad, // 54 .jpad (deprecated)
138 d_nojpad, // 55 .nojpad (deprecated)
139 d_gpumain, // 56 .gpumain (deprecated)
140 d_prgflags, // 57 .prgflags
141 d_68020, // 58 .68020
142 d_68030, // 59 .68030
143 d_68040, // 60 .68040
144 d_68060, // 61 .68060
145 d_68881, // 62 .68881
146 d_68882, // 63 .68882
147 d_56001, // 64 .56001
154 // .error - Abort compilation, printing an error message
156 int d_error(char *str)
159 return error("error directive encountered - aborting assembling");
165 return error(string[tok[1]]);
168 return error("error directive encountered--aborting assembly");
175 // .warn - Just display a warning on screen
177 int d_warn(char *str)
180 return warn("WARNING WARNING WARNING");
186 return warn(string[tok[1]]);
189 return warn("WARNING WARNING WARNING");
202 if (!rgpu && !rdsp && !m6502)
203 return error(".org permitted only in gpu/dsp and 6502 sections");
205 if (abs_expr(&address) == ERROR)
207 error("cannot determine org'd address");
218 // 6502. We also kludge `lsloc' so the listing generator doesn't try
219 // to spew out megabytes.
220 if (address > 0xFFFF)
221 return error(range_error);
223 if (sloc != currentorg[0])
225 currentorg[1] = sloc;
229 currentorg[0] = address;
231 lsloc = sloc = address;
232 chptr = scode->chptr + address;
247 char prntstr[LNSIZ]; // String for PRINT directive
248 char format[LNSIZ]; // Format for PRINT directive
249 int formatting = 0; // Formatting on/off
250 int wordlong = 0; // WORD = 0, LONG = 1
251 int outtype = 0; // 0:hex, 1:decimal, 2:unsigned
253 VALUE eval; // Expression value
254 WORD eattr; // Expression attributes
255 SYM * esym; // External symbol involved in expr.
256 TOKEN r_expr[EXPRSIZE];
263 sprintf(prntstr, "%s", string[tok[1]]);
264 printf("%s", prntstr);
267 unused = write(list_fd, prntstr, (LONG)strlen(prntstr));
274 if (tok[1] != SYMBOL)
277 // strcpy(prntstr, (char *)tok[2]);
278 strcpy(prntstr, string[tok[2]]);
282 case 'l': case 'L': wordlong = 1; break;
283 case 'w': case 'W': wordlong = 0; break;
284 case 'x': case 'X': outtype = 0; break;
285 case 'd': case 'D': outtype = 1; break;
286 case 'u': case 'U': outtype = 2; break;
288 error("unknown print format flag");
298 if (expr(r_expr, &eval, &eattr, &esym) != OK)
304 case 0: strcpy(format, "%X"); break;
305 case 1: strcpy(format, "%d" ); break;
306 case 2: strcpy(format, "%u" ); break;
310 sprintf(prntstr, format, eval);
312 sprintf(prntstr, format, eval & 0xFFFF);
314 printf("%s", prntstr);
317 unused = write(list_fd, prntstr, (LONG)strlen(prntstr));
333 error("illegal print token");
339 // Undefine an equated condition code
345 // Check that we are in a RISC section
348 error(".ccundef must be defined in .gpu/.dsp section");
354 error("syntax error; expected symbol");
358 ccname = lookup(string[tok[1]], LABEL, 0);
360 // Make sure symbol is a valid ccdef
361 if (!ccname || !(ccname->sattre & EQUATEDCC))
363 error("invalid equated condition name specified");
367 ccname->sattre |= UNDEF_CC;
374 // Undefine an equated register
376 int d_equrundef(void)
380 // Check that we are in a RISC section
382 return error(".equrundef/.regundef must be defined in .gpu/.dsp section");
386 // Skip preceeding or seperating commas (if any)
390 // Check we are dealing with a symbol
392 return error("syntax error; expected symbol");
394 // Lookup and undef if equated register
395 regname = lookup(string[tok[1]], LABEL, 0);
397 if (regname && (regname->sattre & EQUATEDREG))
399 // Reset the attributes of this symbol...
401 regname->sattre &= ~(EQUATEDREG | BANK_0 | BANK_1);
402 regname->sattre |= UNDEF_EQUR;
405 // Skip over symbol token and address
414 // Do not allow use of the CLR.L opcode
418 warn("CLR.L opcode ignored...");
424 // Include binary file
430 long pos, size, bytesRead;
434 // Check to see if we're in BSS, and, if so, throw an error
437 error("cannot include binary file \"%s\" in BSS section", string[tok[1]]);
443 error("syntax error; string missing");
447 // Attempt to open the include file in the current directory, then (if that
448 // failed) try list of include files passed in the enviroment string or by
450 if ((fd = open(string[tok[1]], _OPEN_INC)) < 0)
452 for(i=0; nthpath("RMACPATH", i, buf1)!=0; i++)
456 // Append path char if necessary
457 if (fd > 0 && buf1[fd - 1] != SLASHCHAR)
458 strcat(buf1, SLASHSTRING);
460 strcat(buf1, string[tok[1]]);
462 if ((fd = open(buf1, _OPEN_INC)) >= 0)
466 return error("cannot open: \"%s\"", string[tok[1]]);
471 size = lseek(fd, 0L, SEEK_END);
472 pos = lseek(fd, 0L, SEEK_SET);
475 DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); }
477 char * fileBuffer = (char *)malloc(size);
478 bytesRead = read(fd, fileBuffer, size);
480 if (bytesRead != size)
482 error("was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[tok[1]], size);
486 memcpy(chptr, fileBuffer, size);
501 // Set RISC register banks
505 // Set active register bank zero
513 // Set active register bank one
520 // Helper function, to cut down on mistakes & typing
522 static inline void SkipBytes(unsigned bytesToSkip)
527 if ((scattr & SBSS) == 0)
529 chcheck(bytesToSkip);
530 D_ZEROFILL(bytesToSkip);
537 orgaddr += bytesToSkip;
543 // Adjust location to an EVEN value
548 return error(in_6502mode);
550 unsigned skip = (rgpu || rdsp ? orgaddr : sloc) & 0x01;
554 if ((scattr & SBSS) == 0)
573 // Adjust location to a LONG value
577 unsigned lower2Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x03;
578 unsigned bytesToSkip = (0x04 - lower2Bits) & 0x03;
579 SkipBytes(bytesToSkip);
586 // Adjust location to a PHRASE value
588 // N.B.: We have to handle the GPU/DSP cases separately because you can embed
589 // RISC code in the middle of a regular 68K section. Also note that all
590 // of the alignment pseudo-ops will have to be fixed this way.
592 // This *must* behave differently when in a RISC section, as following sloc
593 // (instead of orgaddr) will fuck things up royally. Note that we do it this
594 // way because you can embed RISC code in a 68K section, and have the origin
595 // pointing to a different alignment in the RISC section than the 68K section.
599 unsigned lower3Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x07;
600 unsigned bytesToSkip = (0x08 - lower3Bits) & 0x07;
601 SkipBytes(bytesToSkip);
608 // Adjust location to a DPHRASE value
612 unsigned lower4Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x0F;
613 unsigned bytesToSkip = (0x10 - lower4Bits) & 0x0F;
614 SkipBytes(bytesToSkip);
621 // Adjust location to a QPHRASE value
625 unsigned lower5Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x1F;
626 unsigned bytesToSkip = (0x20 - lower5Bits) & 0x1F;
627 SkipBytes(bytesToSkip);
634 // Do auto-even. This must be called ONLY if 'sloc' is odd.
636 // This is made hairy because, if there was a label on the line, we also have
637 // to adjust its value. This won't work with more than one label on the line,
638 // which is OK since multiple labels are only allowed in AS68 kludge mode, and
639 // the C compiler is VERY paranoid and uses ".even" whenever it can
641 // N.B.: This probably needs the same fixes as above...
645 if (cursect != M6502)
648 sloc++; // Bump BSS section
650 D_byte(0); // Deposit 0.b in non-BSS
652 if (lab_sym != NULL) // Bump label if we have to
659 // Unimplemened directive error
663 return error("unimplemented directive");
668 // Return absolute (not TDB) and defined expression or return an error
670 int abs_expr(VALUE * a_eval)
674 if (expr(exprbuf, a_eval, &eattr, NULL) < 0)
677 if (!(eattr & DEFINED))
678 return error(undef_error);
681 return error(rel_error);
688 // Hand symbols in a symbol-list to a function (kind of like mapcar...)
690 int symlist(int(* func)())
692 const char * em = "symbol list syntax";
699 if ((*func)(string[tok[1]]) != OK)
718 // .include "filename"
728 if (*tok == STRING) // Leave strings ALONE
730 else if (*tok == SYMBOL) // Try to append ".s" to symbols
732 strcpy(buf, string[*++tok]);
736 else // Punt if no STRING or SYMBOL
737 return error("missing filename");
739 // Make sure the user didn't try anything like:
740 // .include equates.s
742 return error("extra stuff after filename--enclose it in quotes");
744 // Attempt to open the include file in the current directory, then (if that
745 // failed) try list of include files passed in the enviroment string or by
747 if ((j = open(fn, 0)) < 0)
749 for(i=0; nthpath("RMACPATH", i, buf1)!=0; i++)
753 // Append path char if necessary
754 if (j > 0 && buf1[j - 1] != SLASHCHAR)
755 strcat(buf1, SLASHSTRING);
759 if ((j = open(buf1, 0)) >= 0)
763 return error("cannot open: \"%s\"", fn);
773 // .assert expression [, expression...]
780 for(; expr(exprbuf, &eval, &eattr, NULL)==OK; ++tok)
782 if (!(eattr & DEFINED))
783 return error("forward or undefined .assert");
786 return error("assert failure");
798 // .globl symbol [, symbol] <<<cannot make local symbols global>>>
805 return error("cannot .globl local symbol");
807 if ((sy = lookup(p, LABEL, 0)) == NULL)
809 sy = NewSymbol(p, LABEL, 0);
812 //printf("glob1: Making global symbol: attr=%04X, eattr=%08X, %s\n", sy->sattr, sy->sattre, sy->sname);
824 return error(in_6502mode);
832 // .prgflags expression
839 return error("PRGFLAGS requires value");
840 else if (abs_expr(&eval) == OK)
847 return error("PRGFLAGS requires value");
860 return error(in_6502mode);
866 else if (abs_expr(&eval) != OK)
881 return error("directive forbidden in gpu/dsp mode");
883 return error(in_6502mode);
898 return error("directive forbidden in gpu/dsp mode");
900 return error(in_6502mode);
915 return error("directive forbidden in gpu/dsp mode");
917 return error(in_6502mode);
930 // .ds[.size] expression
934 DEBUG { printf("Directive: .ds.[size] = %u, sloc = $%X\n", siz, sloc); }
938 if (cursect != M6502)
940 if ((siz != SIZB) && (sloc & 1)) // Automatic .even
944 if (abs_expr(&eval) != OK)
947 // Check to see if the value being passed in is negative (who the hell does
948 // that?--nobody does; it's the code gremlins, or rum, that does it)
949 // N.B.: Since VALUE is of type uint32_t, if it goes negative, it will have
951 if (eval & 0x80000000)
952 return error("negative sizes not allowed");
954 // In non-TDB section (BSS, ABS and M6502) just advance the location
955 // counter appropriately. In TDB sections, deposit (possibly large) chunks
956 // of zeroed memory....
957 if ((scattr & SBSS) || cursect == M6502)
963 if (cursect == M6502)
966 just_bss = 1; // No data deposited (8-bit CPU mode)
970 dep_block(eval, siz, (VALUE)0, (WORD)(DEFINED | ABS), NULL);
979 // dc.b, dc.w / dc, dc.l, dc.i
987 if ((scattr & SBSS) != 0)
988 return error("illegal initialization of section");
990 // Do an auto_even if it's not BYTE sized (hmm, should we be doing this???)
991 if (cursect != M6502 && (siz != SIZB) && (sloc & 1))
994 // Check to see if we're trying to set LONGS on a non 32-bit aligned
995 // address in a GPU or DSP section, in their local RAM
996 if ((siz == SIZL) && (orgaddr & 0x03)
997 && ((rgpu && (orgaddr >= 0xF03000) && (orgaddr <= 0xF03FFFF))
998 || (rdsp && (orgaddr >= 0xF1B000) && (orgaddr <= 0xF1CFFFF))))
999 warn("depositing LONGs on a non-long address in local RAM");
1003 // dc.b 'string' [,] ...
1004 if (siz == SIZB && (*tok == STRING || *tok == STRINGA8) && (tok[2] == ',' || tok[2] == EOL))
1006 uint32_t i = strlen(string[tok[1]]);
1008 if ((challoc - ch_size) < i)
1013 for(p=string[tok[1]]; *p!=EOS; p++)
1016 else if(*tok == STRINGA8)
1018 for(p=string[tok[1]]; *p!=EOS; p++)
1019 D_byte(strtoa8[*p]);
1023 error("String format not supported... yet");
1030 int movei = 0; // MOVEI flag for dc.i
1039 // dc.x <expression>
1042 if (expr(exprbuf, &eval, &eattr, &esym) != OK)
1045 uint16_t tdb = eattr & TDB;
1046 uint16_t defined = eattr & DEFINED;
1048 if ((challoc - ch_size) < 4)
1056 AddFixup(FU_BYTE | FU_SEXT, sloc, exprbuf);
1062 return error("non-absolute byte value");
1064 if (eval + 0x100 >= 0x200)
1065 return error("%s (value = $%X)", range_error, eval);
1075 AddFixup(FU_WORD | FU_SEXT, sloc, exprbuf);
1080 if (eval + 0x10000 >= 0x20000)
1081 return error(range_error);
1084 MarkRelocatable(cursect, sloc, tdb, MWORD, NULL);
1086 // Deposit 68000 or 6502 (byte-reversed) word
1087 if (cursect != M6502)
1096 return error(in_6502mode);
1101 AddFixup(FU_LONG | FU_MOVEI, sloc, exprbuf);
1103 AddFixup(FU_LONG, sloc, exprbuf);
1110 MarkRelocatable(cursect, sloc, tdb, MLONG, NULL);
1113 eval = WORDSWAP32(eval);
1131 // dcb[.siz] expr1,expr2 - Make 'expr1' copies of 'expr2'
1138 DEBUG { printf("dcb: section is %s%s%s (scattr=$%X)\n", (cursect & TEXT ? "TEXT" : ""), (cursect & DATA ? " DATA" : ""), (cursect & BSS ? "BSS" : ""), scattr); }
1140 if ((scattr & SBSS) != 0)
1141 return error("illegal initialization of section");
1143 if (abs_expr(&evalc) != OK)
1147 return error("missing comma");
1149 if (expr(exprbuf, &eval, &eattr, NULL) < 0)
1152 if (cursect != M6502 && (siz != SIZB) && (sloc & 1))
1155 dep_block(evalc, siz, eval, eattr, exprbuf);
1161 // Generalized initialization directive
1163 // .init[.siz] [#count,] expression [.size] , ...
1165 // The size suffix on the ".init" directive becomes the default size of the
1166 // objects to deposit. If an item is preceeded with a sharp (immediate) sign
1167 // and an expression, it specifies a repeat count. The value to be deposited
1168 // may be followed by a size suffix, which overrides the default size.
1170 int d_init(WORD def_siz)
1177 if ((scattr & SBSS) != 0)
1178 return error(".init not permitted in BSS or ABS");
1181 return error("directive forbidden in gpu/dsp mode");
1185 // Get repeat count (defaults to 1)
1190 if (abs_expr(&count) != OK)
1194 return error(comma_error);
1199 // Evaluate expression to deposit
1200 if (expr(exprbuf, &eval, &eattr, NULL) < 0)
1203 switch ((int)*tok++)
1204 { // Determine size of object to deposit
1205 case DOTB: siz = SIZB; break;
1206 case DOTW: siz = SIZB; break;
1207 case DOTL: siz = SIZL; break;
1214 dep_block(count, siz, eval, eattr, exprbuf);
1224 return error(comma_error);
1231 // Deposit 'count' values of size 'siz' in the current (non-BSS) segment
1233 int dep_block(VALUE count, WORD siz, VALUE eval, WORD eattr, TOKEN * exprbuf)
1238 tdb = (WORD)(eattr & TDB);
1239 defined = (WORD)(eattr & DEFINED);
1243 if ((challoc - ch_size) < 4)
1251 AddFixup(FU_BYTE | FU_SEXT, sloc, exprbuf);
1257 return error("non-absolute byte value");
1259 if (eval + 0x100 >= 0x200)
1260 return error(range_error);
1270 AddFixup(FU_WORD | FU_SEXT, sloc, exprbuf);
1276 MarkRelocatable(cursect, sloc, tdb, MWORD, NULL);
1278 if (eval + 0x10000 >= 0x20000)
1279 return error(range_error);
1281 // Deposit 68000 or 6502 (byte-reversed) word
1282 if (cursect != M6502)
1292 return error(in_6502mode);
1296 AddFixup(FU_LONG, sloc, exprbuf);
1302 MarkRelocatable(cursect, sloc, tdb, MLONG, NULL);
1316 // .comm symbol, size
1325 return error(in_6502mode);
1328 return error("missing symbol");
1333 if (*p == '.') // Cannot .comm a local symbol
1334 return error(locgl_error);
1336 if ((sym = lookup(p, LABEL, 0)) == NULL)
1337 sym = NewSymbol(p, LABEL, 0);
1340 if (sym->sattr & DEFINED)
1341 return error(".comm symbol already defined");
1344 sym->sattr = GLOBAL | COMMON | BSS;
1347 return error(comma_error);
1349 if (abs_expr(&eval) != OK) // Parse size of common region
1352 sym->svalue = eval; // Install common symbol's size
1359 // .list - Turn listing on
1371 // .nlist - Turn listing off
1383 // .68000 - Back to 68000 TEXT segment
1388 // Switching from gpu/dsp sections should reset any ORG'd Address
1392 SwitchSection(TEXT);
1393 activecpu = CPU_68000;
1399 // .68020 - Back to 68000 TEXT segment and select 68020
1404 activecpu = CPU_68020;
1410 // .68030 - Back to 68000 TEXT segment and select 68030
1415 activecpu = CPU_68030;
1421 // .68040 - Back to 68000 TEXT segment and select 68040
1426 activecpu = CPU_68040;
1427 activefpu = FPU_68040;
1433 // .68060 - Back to 68000 TEXT segment and select 68060
1438 activecpu = CPU_68060;
1439 activefpu = FPU_68040;
1445 // .68881 - Back to 68000 TEXT segment and select 68881 FPU
1450 activefpu = FPU_68881;
1456 // .68882 - Back to 68000 TEXT segment and select 68882 FPU
1461 activefpu = FPU_68881;
1467 // nofpu - Deselect FPUs.
1471 activefpu = FPU_NONE;
1481 return error("Not yet, child. Be patient.");
1486 // .gpu - Switch to GPU assembler
1490 if ((cursect != TEXT) && (cursect != DATA))
1492 error(".gpu can only be used in the TEXT or DATA segments");
1496 // If previous section was dsp or 68000 then we need to reset ORG'd Addresses
1499 //printf("Resetting ORG...\n");
1503 //else printf("NOT resetting ORG!\n");
1505 rgpu = 1; // Set GPU assembly
1506 rdsp = 0; // Unset DSP assembly
1507 regbank = BANK_N; // Set no default register bank
1513 // .dsp - Switch to DSP assembler
1517 if ((cursect != TEXT) && (cursect != DATA))
1519 error(".dsp can only be used in the TEXT or DATA segments");
1523 // If previous section was gpu or 68000 then we need to reset ORG'd Addresses
1530 rdsp = 1; // Set DSP assembly
1531 rgpu = 0; // Unset GPU assembly
1532 regbank = BANK_N; // Set no default register bank
1538 // .cargs [#offset], symbol[.size], ...
1540 // Lists of registers may also be mentioned; they just take up space. Good for
1541 // "documentation" purposes:
1543 // .cargs a6, .arg1, .arg2, .arg3...
1545 // Symbols thus created are ABS and EQUATED.
1549 VALUE eval = 4; // Default to 4 if no offset specified (to account for
1558 return error("directive forbidden in gpu/dsp mode");
1564 if (abs_expr(&eval) != OK)
1567 // Eat the comma, if it's there
1578 // Set env to either local (dot prefixed) or global scope
1579 env = (*p == '.' ? curenv : 0);
1580 symbol = lookup(p, LABEL, env);
1584 symbol = NewSymbol(p, LABEL, env);
1587 else if (symbol->sattr & DEFINED)
1588 return error("multiply-defined label '%s'", p);
1590 // Put symbol in "order of definition" list
1591 AddToSymbolDeclarationList(symbol);
1593 symbol->sattr |= (ABS | DEFINED | EQUATED);
1594 symbol->svalue = eval;
1597 // What this does is eat any dot suffixes attached to a symbol. If
1598 // it's a .L, it adds 4 to eval; if it's .W or .B, it adds 2. If
1599 // there is no dot suffix, it assumes a size of 2.
1611 else if (*tok >= KW_D0 && *tok <= KW_A7)
1613 if (reglist(&rlist) < 0)
1616 for(i=0; i<16; i++, rlist>>=1)
1639 return error(".cargs syntax");
1643 // Eat commas in between each argument, if they exist
1651 // .cstruct [#offset], symbol[.size], ...
1653 // Lists of registers may also be mentioned; they just take up space. Good for
1654 // "documentation" purposes:
1656 // .cstruct a6, .arg1, .arg2, .arg3...
1658 // Symbols thus created are ABS and EQUATED. Note that this is for
1659 // compatibility with VBCC and the Remover's library. Thanks to GroovyBee for
1664 VALUE eval = 0; // Default, if no offset specified, is zero
1672 return error("directive forbidden in gpu/dsp mode");
1678 if (abs_expr(&eval) != OK)
1681 // Eat the comma, if it's there
1690 symbolName = string[tok[1]];
1692 // Set env to either local (dot prefixed) or global scope
1693 env = (symbolName[0] == '.' ? curenv : 0);
1694 symbol = lookup(symbolName, LABEL, env);
1696 // If the symbol wasn't found, then define it. Otherwise, throw an
1700 symbol = NewSymbol(symbolName, LABEL, env);
1703 else if (symbol->sattr & DEFINED)
1704 return error("multiply-defined label '%s'", symbolName);
1706 // Put symbol in "order of definition" list
1707 AddToSymbolDeclarationList(symbol);
1711 // Adjust label start address if it's a word or a long, as a byte
1712 // label might have left us on an odd address.
1717 eval += eval & 0x01;
1720 symbol->sattr |= (ABS | DEFINED | EQUATED);
1721 symbol->svalue = eval;
1723 // Check for dot suffixes and adjust space accordingly (longs and
1724 // words on an odd boundary get bumped to the next word aligned
1725 // address). If no suffix, then throw an error.
1738 return error("Symbol missing dot suffix in .cstruct construct");
1743 else if (*tok >= KW_D0 && *tok <= KW_A7)
1745 if (reglist(&rlist) < 0)
1748 for(i=0; i<16; i++, rlist>>=1)
1771 return error(".cstruct syntax");
1775 // Eat commas in between each argument, if they exist
1783 // Undefine a macro - .undefmac macname [, macname...]
1785 int undmac1(char * p)
1787 SYM * symbol = lookup(p, MACRO, 0);
1789 // If the macro symbol exists, cause it to disappear
1791 symbol->stype = (BYTE)SY_UNDEF;
1806 warn("JPAD directive is deprecated/non-functional");
1813 warn("NOJPAD directive is deprecated/non-functional");
1820 return error("What the hell? Do you think we adhere to the Goof standard?");
1825 // .opt - turn a specific (or all) optimisation on or off
1834 char * tmpstr = string[*tok++];
1836 if (ParseOptimization(tmpstr) != OK)
1837 return error("unknown optimization flag '%s'", tmpstr);
1840 return error(".opt directive needs every switch enclosed inside quotation marks");
1848 // .if, Start conditional assembly
1855 IFENT * rif = f_ifent;
1859 rif = (IFENT *)malloc(sizeof(IFENT));
1861 f_ifent = rif->if_prev;
1863 rif->if_prev = ifent;
1868 if (expr(exprbuf, &eval, &eattr, &esym) != OK)
1871 if ((eattr & DEFINED) == 0)
1872 return error(undef_error);
1877 rif->if_state = (WORD)disabled;
1883 // .else, Do alternate case for .if
1887 IFENT * rif = ifent;
1889 if (rif->if_prev == NULL)
1890 return error("mismatched .else");
1893 disabled = rif->if_prev->if_state;
1897 rif->if_state = (WORD)disabled;
1903 // .endif, End of conditional assembly block
1904 // This is also called by fpop() to pop levels of IFENTs in case a macro or
1905 // include file exits early with `exitm' or `end'.
1909 IFENT * rif = ifent;
1911 if (rif->if_prev == NULL)
1912 return error("mismatched .endif");
1914 ifent = rif->if_prev;
1915 disabled = rif->if_prev->if_state;
1916 rif->if_prev = f_ifent;