X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=direct.c;h=623bae4a0ee7cf0332fa555de412766a613d0e2d;hp=95fd51befb5cc6b0ed1cc0b31e9371929b506ab4;hb=233e5e908f5a865233f775520dc35917f13d2d26;hpb=d09274f3e3d4dca122c308a621ea8edc100b7d99 diff --git a/direct.c b/direct.c index 95fd51b..623bae4 100644 --- a/direct.c +++ b/direct.c @@ -21,72 +21,73 @@ #define DEF_KW #include "kwtab.h" -TOKEN exprbuf[128]; // Expression buffer +TOKEN exprbuf[128]; // Expression buffer +SYM * symbolPtr[1000000]; // Symbol pointers table // Directive handler table int (*dirtab[])() = { - d_org, // 0 org - d_even, // 1 even - d_unimpl, // 2 .6502 - d_68000, // 3 .68000 - d_bss, // 4 bss - d_data, // 5 data - d_text, // 6 text - d_abs, // 7 abs - d_comm, // 8 comm - d_init, // 9 init - d_cargs, // 10 cargs - d_goto, // 11 goto - d_dc, // 12 dc - d_ds, // 13 ds - d_undmac, // 14 undefmac - d_gpu, // 15 .gpu - d_dsp, // 16 .dsp - d_dcb, // 17 dcb - d_unimpl, // 18* set - d_unimpl, // 19* reg - d_unimpl, // 20 dump - d_incbin, // 21 .incbin //load - d_unimpl, // 22 disable - d_unimpl, // 23 enable - d_globl, // 24 globl - d_regbank0, // 25 .regbank0 - d_regbank1, // 26 .regbank1 - d_unimpl, // 27 xdef - d_assert, // 28 assert - d_unimpl, // 29* if - d_unimpl, // 30* endif - d_unimpl, // 31* endc - d_unimpl, // 32* iif - d_include, // 33 include - fpop, // 34 end - d_unimpl, // 35* macro - exitmac, // 36* exitm - d_unimpl, // 37* endm - d_list, // 38 list - d_nlist, // 39 nlist - d_long, // 40* rept - d_phrase, // 41* endr - d_dphrase, // 42 struct - d_qphrase, // 43 ends - d_title, // 44 title - d_subttl, // 45 subttl - eject, // 46 eject - d_unimpl, // 47 error - d_unimpl, // 48 warn - d_noclear, // 49 .noclear - d_equrundef, // 50 .equrundef/.regundef - d_ccundef, // 51 .ccundef - d_print, // 52 .print - d_gpumain, // 53 .gpumain - d_jpad, // 54 .jpad - d_nojpad, // 55 .nojpad - d_fail, // 56 .fail + d_org, // 0 org + d_even, // 1 even + d_unimpl, // 2 .6502 + d_68000, // 3 .68000 + d_bss, // 4 bss + d_data, // 5 data + d_text, // 6 text + d_abs, // 7 abs + d_comm, // 8 comm + d_init, // 9 init + d_cargs, // 10 cargs + d_goto, // 11 goto + d_dc, // 12 dc + d_ds, // 13 ds + d_undmac, // 14 undefmac + d_gpu, // 15 .gpu + d_dsp, // 16 .dsp + d_dcb, // 17 dcb + d_unimpl, // 18* set + d_unimpl, // 19* reg + d_unimpl, // 20 dump + d_incbin, // 21 .incbin //load + d_unimpl, // 22 disable + d_unimpl, // 23 enable + d_globl, // 24 globl + d_regbank0, // 25 .regbank0 + d_regbank1, // 26 .regbank1 + d_unimpl, // 27 xdef + d_assert, // 28 assert + d_unimpl, // 29* if + d_unimpl, // 30* endif + d_unimpl, // 31* endc + d_unimpl, // 32* iif + d_include, // 33 include + fpop, // 34 end + d_unimpl, // 35* macro + exitmac, // 36* exitm + d_unimpl, // 37* endm + d_list, // 38 list + d_nlist, // 39 nlist + d_long, // 40* rept + d_phrase, // 41* endr + d_dphrase, // 42 struct + d_qphrase, // 43 ends + d_title, // 44 title + d_subttl, // 45 subttl + eject, // 46 eject + d_unimpl, // 47 error + d_unimpl, // 48 warn + d_noclear, // 49 .noclear + d_equrundef, // 50 .equrundef/.regundef + d_ccundef, // 51 .ccundef + d_print, // 52 .print + d_gpumain, // 53 .gpumain + d_jpad, // 54 .jpad + d_nojpad, // 55 .nojpad + d_fail, // 56 .fail }; // -// .org - Set origin +// .fail - User abort // int d_fail(void) { @@ -158,7 +159,8 @@ int d_print(void) switch(*tok) { case STRING: - sprintf(prntstr, "%s", (char *)tok[1]); +// sprintf(prntstr, "%s", (char *)tok[1]); + sprintf(prntstr, "%s", string[tok[1]]); printf("%s", prntstr); if (list_fd) @@ -172,7 +174,8 @@ int d_print(void) if (tok[1] != SYMBOL) goto token_err; - strcpy(prntstr, (char *)tok[2]); +// strcpy(prntstr, (char *)tok[2]); + strcpy(prntstr, string[tok[2]]); switch(prntstr[0]) { @@ -253,7 +256,8 @@ int d_ccundef(void) return ERROR; } - ccname = lookup((char *)tok[1], LABEL, 0); +// ccname = lookup((char *)tok[1], LABEL, 0); + ccname = lookup(string[tok[1]], LABEL, 0); // Make sure symbol is a valid ccdef if (!ccname || !(ccname->sattre & EQUATEDCC)) @@ -296,7 +300,8 @@ int d_equrundef(void) } // Lookup and undef if equated register - regname = lookup((char *)tok[1], LABEL, 0); +// regname = lookup((char *)tok[1], LABEL, 0); + regname = lookup(string[tok[1]], LABEL, 0); if (regname && (regname->sattre & EQUATEDREG)) regname->sattre |= UNDEF_EQUR; @@ -334,7 +339,8 @@ int d_incbin(void) return ERROR; } - if ((j = open((char *)tok[1], _OPEN_INC)) >= 0) +// if ((j = open((char *)tok[1], _OPEN_INC)) >= 0) + if ((j = open(string[tok[1]], _OPEN_INC)) >= 0) { size = lseek(j, 0L, SEEK_END); chcheck(size); @@ -349,7 +355,8 @@ int d_incbin(void) } else { - errors("cannot open include binary file (%s)", (char *)tok[1]); +// errors("cannot open include binary file (%s)", (char *)tok[1]); + errors("cannot open include binary file (%s)", string[tok[1]]); return ERROR; } @@ -595,7 +602,11 @@ int symlist(int(* func)()) if (*tok != SYMBOL) return error(em); +#if 0 if ((*func)(tok[1]) != OK) +#else + if ((*func)(string[tok[1]]) != OK) +#endif break; tok += 2; @@ -624,15 +635,23 @@ int d_include(void) char buf[128]; char buf1[128]; - if (*tok == STRING) // Leave strings ALONE + if (*tok == STRING) // Leave strings ALONE +#if 0 fn = (char *)*++tok; +#else + fn = string[*++tok]; +#endif else if (*tok == SYMBOL) // Try to append ".s" to symbols { +#if 0 strcpy(buf, (char *)*++tok); +#else + strcpy(buf, string[*++tok]); +#endif fext(buf, ".s", 0); fn = &buf[0]; } - else // Punt if no STRING or SYMBOL + else // Punt if no STRING or SYMBOL return error("missing filename"); // Make sure the user didn't try anything like: @@ -640,15 +659,16 @@ int d_include(void) if (*++tok != EOL) return error("extra stuff after filename -- enclose it in quotes"); - // Attempt to open the include file in the current directory, then (if that failed) try list - // of include files passed in the enviroment string or by the "-d" option. + // Attempt to open the include file in the current directory, then (if that + // failed) try list of include files passed in the enviroment string or by + // the "-d" option. if ((j = open(fn, 0)) < 0) { for(i=0; nthpath("RMACPATH", i, buf1)!=0; ++i) { j = strlen(buf1); - if (j > 0 && buf1[j-1] != SLASHCHAR) // Append path char if necessary + if (j > 0 && buf1[j-1] != SLASHCHAR) // Append path char if necessary strcat(buf1, SLASHSTRING); strcat(buf1, fn); @@ -703,7 +723,7 @@ int globl1(char * p) if ((sy = lookup(p, LABEL, 0)) == NULL) { - sy = newsym(p, LABEL, 0); + sy = NewSymbol(p, LABEL, 0); sy->svalue = 0; sy->sattr = GLOBAL; } @@ -854,12 +874,13 @@ int d_dc(WORD siz) // dc.b 'string' [,] ... if (siz == SIZB && *tok == STRING && (tok[2] == ',' || tok[2] == EOL)) { - i = strlen((const char*)tok[1]); +// i = strlen((const char*)tok[1]); + i = strlen(string[tok[1]]); if ((challoc - ch_size) < i) chcheck(i); - for(p=(char *)tok[1]; *p!=EOS; ++p) + for(p=string[tok[1]]; *p!=EOS; ++p) D_byte(*p); tok += 2; @@ -881,7 +902,7 @@ int d_dc(WORD siz) defined = (WORD)(eattr & DEFINED); if ((challoc - ch_size) < 4) - chcheck(4L); + chcheck(4); switch (siz) { @@ -1144,29 +1165,30 @@ int d_comm(void) if (*tok != SYMBOL) return error("missing symbol"); - p = (char *)tok[1]; +// p = (char *)tok[1]; + p = string[tok[1]]; tok += 2; - if (*p == '.') // Cannot .comm a local symbol + if (*p == '.') // Cannot .comm a local symbol return error(locgl_error); if ((sym = lookup(p, LABEL, 0)) == NULL) - sym = newsym(p, LABEL, 0); + sym = NewSymbol(p, LABEL, 0); else { if (sym->sattr & DEFINED) return error(".comm symbol already defined"); } - sym->sattr = GLOBAL|COMMON|BSS; + sym->sattr = GLOBAL | COMMON | BSS; if (*tok++ != ',') return error(comma_error); - if (abs_expr(&eval) != OK) // Parse size of common region + if (abs_expr(&eval) != OK) // Parse size of common region return 0; - sym->svalue = eval; // Install common symbol's size + sym->svalue = eval; // Install common symbol's size at_eol(); return 0; } @@ -1323,7 +1345,7 @@ int d_cargs(void) if (abs_expr(&eval) != OK) return 0; - if (*tok == ',') // Eat comma if it's there + if (*tok == ',') // Eat comma if it's there ++tok; } else @@ -1333,7 +1355,8 @@ int d_cargs(void) { if (*tok == SYMBOL) { - p = (char *)tok[1]; +// p = (char *)tok[1]; + p = string[tok[1]]; if (*p == '.') env = curenv; @@ -1344,7 +1367,7 @@ int d_cargs(void) if (sy == NULL) { - sy = newsym(p, LABEL, env); + sy = NewSymbol(p, LABEL, env); sy->sattr = 0; } else if (sy->sattr & DEFINED)