X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=direct.c;h=a14307dde1b9f335a1fb4569df03bdf7740f4bab;hp=8d4f3fdc53fc5dd601a9964f938db63402045704;hb=295836a17362d5f57e171018fb6658f845f419e8;hpb=49cce96fba11282e4244187f15be418d5ae5bb8d diff --git a/direct.c b/direct.c index 8d4f3fd..a14307d 100644 --- a/direct.c +++ b/direct.c @@ -21,7 +21,8 @@ #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[])() = { @@ -61,7 +62,7 @@ int (*dirtab[])() = { d_include, // 33 include fpop, // 34 end d_unimpl, // 35* macro - exitmac, // 36* exitm + ExitMacro, // 36* exitm d_unimpl, // 37* endm d_list, // 38 list d_nlist, // 39 nlist @@ -78,23 +79,13 @@ int (*dirtab[])() = { 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_gpumain, // 53 .gpumain +// d_jpad, // 54 .jpad +// d_nojpad, // 55 .nojpad +// d_fail, // 56 .fail }; -// -// .fail - User abort -// -int d_fail(void) -{ - fatal("user abort"); - return 0; -} - - // // .org - Set origin // @@ -120,23 +111,6 @@ int d_org(void) } -// -// NOP Padding Directive -// -int d_jpad(void) -{ - jpad = 1; - return 0; -} - - -int d_nojpad(void) -{ - jpad = 0; - return 0; -} - - // // Print Directive // @@ -158,7 +132,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 +147,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 +229,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 +273,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; @@ -328,18 +306,31 @@ int d_incbin(void) long pos, size; char buf; + // Check to see if we're in BSS, and, if so, throw an error + if (scattr & SBSS) + { + errors("Cannot include binary file \"%s\" in BSS section", string[tok[1]]); + return ERROR; + } + if (*tok != STRING) { error(syntax_error); 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); pos = lseek(j, 0L, SEEK_SET); - + + DEBUG + { + printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); + } + for(i=0; i 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 +708,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 +859,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; @@ -1144,29 +1150,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; } @@ -1202,7 +1209,7 @@ int d_nlist(void) int d_68000(void) { rgpu = rdsp = 0; - in_main = 0; +// in_main = 0; // Switching from gpu/dsp sections should reset any ORG'd Address orgactive = 0; orgwarning = 0; @@ -1233,36 +1240,8 @@ int d_gpu(void) rgpu = 1; // Set GPU assembly rdsp = 0; // Unset DSP assembly regbank = BANK_N; // Set no default register bank - in_main = 0; - jpad = 0; - return 0; -} - - -// -// GPU Main Code Directive -// - -int d_gpumain(void) -{ - if ((cursect != TEXT) && (cursect != DATA)) - { - error(".gpumain can only be used in the TEXT or DATA segments"); - return ERROR; - } - - // If previous section was dsp or 68000 then we need to reset ORG'd Addresses - if (!rgpu) - { - orgactive = 0; - orgwarning = 0; - } - - rgpu = 1; // Set GPU assembly - rdsp = 0; // Unset DSP assembly - regbank = BANK_N; // Set no default register bank - in_main = 1; // Enable main code execution rules - jpad = 0; +// in_main = 0; +// jpad = 0; return 0; } @@ -1288,8 +1267,8 @@ int d_dsp(void) rdsp = 1; // Set DSP assembly rgpu = 0; // Unset GPU assembly regbank = BANK_N; // Set no default register bank - in_main = 0; - jpad = 0; +// in_main = 0; +// jpad = 0; return 0; } @@ -1323,7 +1302,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 +1312,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 +1324,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)