X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=direct.c;h=100db425f7afe7bad4fad3a0e5e64603fcfbb587;hp=b1c368a4d2c8bd5b91ae3303fa60d97d3bc7c487;hb=bb94015a443a0aebaa93ee62f9f2738fa3a96784;hpb=11a78647f7f170e6ea39dd04a3734a359151debb diff --git a/direct.c b/direct.c index b1c368a..100db42 100644 --- a/direct.c +++ b/direct.c @@ -79,6 +79,7 @@ int (*dirtab[])() = { d_equrundef, // 50 .equrundef/.regundef d_ccundef, // 51 .ccundef d_print, // 52 .print + d_cstruct, // 53 .cstruct }; @@ -297,15 +298,15 @@ int d_noclear(void) // int d_incbin(void) { - int i, j; + int fd; int bytes = 0; - long pos, size; - char buf; + long pos, size, bytesRead; + char msg[256]; // 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]]); + errors("cannot include binary file \"%s\" in BSS section", string[tok[1]]); return ERROR; } @@ -315,7 +316,7 @@ int d_incbin(void) return ERROR; } -// if ((j = open((char *)tok[1], _OPEN_INC)) >= 0) +#if 0 if ((j = open(string[tok[1]], _OPEN_INC)) >= 0) { size = lseek(j, 0L, SEEK_END); @@ -336,12 +337,57 @@ int d_incbin(void) } else { -// errors("cannot open include binary file (%s)", (char *)tok[1]); errors("cannot open include binary file (%s)", string[tok[1]]); return ERROR; } +#else + if ((fd = open(string[tok[1]], _OPEN_INC)) < 0) + { + errors("cannot open include binary file (%s)", string[tok[1]]); + return ERROR; + } + + size = lseek(fd, 0L, SEEK_END); + pos = lseek(fd, 0L, SEEK_SET); + chcheck(size); + + DEBUG + { + printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); + } + +#if 0 + for(i=0; isattr = 0; + } + else if (symbol->sattr & DEFINED) + return errors("multiply-defined label '%s'", symbolName); + + // Put symbol in "order of definition" list + if (!(symbol->sattr & SDECLLIST)) + sym_decl(symbol); + + tok += 2; + + // Adjust label start address if it's a word or a long, as a byte + // label might have left us on an odd address. + switch ((int)*tok) + { + case DOTW: + case DOTL: + eval += eval & 0x01; + } + + symbol->sattr |= (ABS | DEFINED | EQUATED); + symbol->svalue = eval; + + // Check for dot suffixes and adjust space accordingly (longs and + // words on an odd boundary get bumped to the next word aligned + // address). If no suffix, then throw an error. + switch ((int)*tok) + { + case DOTL: + eval += 4; + break; + case DOTW: + eval += 2; + break; + case DOTB: + eval += 1; + break; + default: + return error("Symbol missing dot suffix in .cstruct construct"); + } + + tok++; + } + else if (*tok >= KW_D0 && *tok <= KW_A7) + { + if (reglist(&rlist) < 0) + return 0; + + for(i=0; i<16; i++, rlist>>=1) + { + if (rlist & 1) + eval += 4; + } + } + else + { + switch ((int)*tok) + { + case KW_USP: + case KW_SSP: + case KW_PC: + eval += 2; + // FALLTHROUGH + case KW_SR: + case KW_CCR: + eval += 2; + tok++; + break; + case EOL: + return 0; + default: + return error(".cstruct syntax"); + } + } + + // Eat commas in between each argument, if they exist + if (*tok == ',') + tok++; + } +} + + // // Undefine a macro - .undefmac macname [, macname...] //