X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=direct.c;h=2511473fb5c89953decbe40a3579943dfb84f8c0;hp=7447553694944895c62c5e94dd428ba34c62ca4f;hb=66b362fa203d0850e8dce8045adb454e354c22ce;hpb=29b32d134bc12831a8ddd098bf9aeeda26dcfe7c diff --git a/direct.c b/direct.c index 7447553..2511473 100644 --- a/direct.c +++ b/direct.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DIRECT.C - Directive Handling -// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -35,7 +35,6 @@ int largestAlign[3] = { 2, 2, 2 }; // Largest alignment value seen per section // Function prototypes int d_unimpl(void); int d_68000(void); -int d_68000(void); int d_68020(void); int d_68030(void); int d_68040(void); @@ -80,6 +79,7 @@ int d_cstruct(void); int d_prgflags(void); int d_opt(void); int d_dsp(void); +int d_objproc(void); void SetLargestAlignment(int); // Directive handler table @@ -150,7 +150,8 @@ int (*dirtab[])() = { d_68882, // 63 .68882 d_56001, // 64 .56001 d_nofpu, // 65 nofpu - d_opt, // 58 .opt + d_opt, // 66 .opt + d_objproc, // 67 .objproc }; @@ -217,8 +218,8 @@ int d_org(void) { uint64_t address; - if (!rgpu && !rdsp && !m6502) - return error(".org permitted only in gpu/dsp and 6502 sections"); + if (!rgpu && !rdsp && !robjproc && !m6502) + return error(".org permitted only in GPU/DSP/OP and 6502 sections"); if (abs_expr(&address) == ERROR) { @@ -226,7 +227,7 @@ int d_org(void) return ERROR; } - if (rgpu | rdsp) + if (rgpu | rdsp | robjproc) { orgaddr = address; orgactive = 1; @@ -1067,9 +1068,6 @@ int d_dc(WORD siz) uint16_t tdb = eattr & TDB; uint16_t defined = eattr & DEFINED; - if ((challoc - ch_size) < 4) - chcheck(4); - switch (siz) { case SIZB: @@ -1137,6 +1135,7 @@ int d_dc(WORD siz) D_long(eval); } + break; case SIZQ: // 64-bit size @@ -1145,7 +1144,17 @@ int d_dc(WORD siz) // Shamus: We only handle DC.Q type stuff, will have to add fixups // and stuff later (maybe... might not be needed...) - D_quad(eval); + // DEFINITELY NEED FIXUPS HERE! + if (!defined) + { + AddFixup(FU_QUAD, sloc, exprbuf); + D_quad(0LL); + } + else + { + D_quad(eval); + } + break; case SIZS: // 32-bit float size @@ -1159,8 +1168,9 @@ int d_dc(WORD siz) } else { - if (tdb) - MarkRelocatable(cursect, sloc, tdb, MSINGLE, NULL); +//Would this *ever* happen? +// if (tdb) +// MarkRelocatable(cursect, sloc, tdb, MSINGLE, NULL); PTR ptr; ptr.u64 = &eval; @@ -1181,8 +1191,9 @@ int d_dc(WORD siz) } else { - if (tdb) - MarkRelocatable(cursect, sloc, tdb, MDOUBLE, NULL); +//Would this *ever* happen? +// if (tdb) +// MarkRelocatable(cursect, sloc, tdb, MDOUBLE, NULL); PTR ptr; ptr.u64 = &eval; @@ -1205,8 +1216,9 @@ int d_dc(WORD siz) } else { - if (tdb) - MarkRelocatable(cursect, sloc, tdb, MEXTEND, NULL); +//Would this *ever* happen? +// if (tdb) +// MarkRelocatable(cursect, sloc, tdb, MEXTEND, NULL); PTR ptr; ptr.u64 = &eval; @@ -1430,7 +1442,7 @@ int d_comm(void) 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) @@ -1446,10 +1458,10 @@ int d_comm(void) 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 = (uint32_t)eval; // Install common symbol's size + sym->svalue = eval; // Install common symbol's size at_eol(); return 0; } @@ -1484,7 +1496,7 @@ int d_nlist(void) // int d_68000(void) { - rgpu = rdsp = 0; + rgpu = rdsp = robjproc = 0; // Switching from gpu/dsp sections should reset any ORG'd Address orgactive = 0; orgwarning = 0; @@ -1536,29 +1548,29 @@ int d_68060(void) { d_68000(); activecpu = CPU_68060; - activefpu = FPU_68040; + activefpu = FPU_68060; return 0; } // -// .68881 - Back to 68000 TEXT segment and select 68881 FPU +// .68881 - Back to 680x0 TEXT segment and select 68881 FPU // int d_68881(void) { - d_68000(); + //d_68000(); activefpu = FPU_68881; return 0; } // -// .68882 - Back to 68000 TEXT segment and select 68882 FPU +// .68882 - Back to 680x0 TEXT segment and select 68882 FPU // int d_68882(void) { - d_68000(); - activefpu = FPU_68881; + //d_68000(); + activefpu = FPU_68882; return 0; } @@ -1602,6 +1614,7 @@ int d_gpu(void) rgpu = 1; // Set GPU assembly rdsp = 0; // Unset DSP assembly + robjproc = 0; // Unset OP assembly regbank = BANK_N; // Set no default register bank return 0; } @@ -1627,6 +1640,7 @@ int d_dsp(void) rdsp = 1; // Set DSP assembly rgpu = 0; // Unset GPU assembly + robjproc = 0; // Unset OP assembly regbank = BANK_N; // Set no default register bank return 0; } @@ -1689,7 +1703,7 @@ int d_cargs(void) AddToSymbolDeclarationList(symbol); symbol->sattr |= (ABS | DEFINED | EQUATED); - symbol->svalue = (uint32_t)eval; + symbol->svalue = eval; tok += 2; // What this does is eat any dot suffixes attached to a symbol. If @@ -1816,7 +1830,7 @@ int d_cstruct(void) } symbol->sattr |= (ABS | DEFINED | EQUATED); - symbol->svalue = (uint32_t)eval; + 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 @@ -1877,6 +1891,32 @@ int d_cstruct(void) } +// +// Define start of OP object list (allows the use of ORG) +// +int d_objproc(void) +{ + if ((cursect != TEXT) && (cursect != DATA)) + { + error(".objproc 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 (!robjproc) + { + orgactive = 0; + orgwarning = 0; + } + + robjproc = 1; // Set OP assembly + rgpu = 0; // Unset GPU assembly + rdsp = 0; // Unset DSP assembly + return OK; +} + + // // Undefine a macro - .undefmac macname [, macname...] //