-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// 68KGEN.C - Tool to Generate 68000 Opcode Table
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include <stdio.h>
#include <ctype.h>
int kwnum = 1; /* current op# for kwgen output */
-FILE *kfp; /* keyword file */
+FILE * kfp; /* keyword file */
int lineno = 0;
void error(char *, char *);
void procln(int, char **);
-void main(int argc, char **argv) {
- char *namv[256];
- char *s;
+void main(int argc, char ** argv)
+{
+ char * namv[256];
+ char * s;
int namcnt;
char ln[256];
if ((kfp = fopen(argv[1], "w")) == NULL)
error("Cannot create: %s", argv[1]);
- while (gets(ln) != NULL)
+// while (gets(ln) != NULL)
+ while (fgets(ln, 256, stdin) != NULL)
{
++lineno; /* bump line# */
if (*ln == '#') /* ignore comments */
*/
namcnt = 0;
s = ln;
+
while (*s)
+ {
if (isspace(*s))
++s;
else
{
namv[namcnt++] = s;
+
while (*s && !isspace(*s))
++s;
+
if (isspace(*s))
*s++ = EOS;
}
+ }
if (namcnt)
procln(namcnt, namv);
/*
* Parse line
*/
-void procln(int namc, char **namv) {
+void procln(int namc, char ** namv)
+{
int i, j;
- char *s;
+ char * s;
if (namc == 1) /* alias for previous entry */
{
if (*namv[4] == '%') /* enforce little fascist percent signs */
{
- for (i=1, j=0; i < 17; ++i)
+ for(i=1, j=0; i<17; ++i)
{
j <<= 1;
- if (namv[4][i] == '1' ||
- isupper(namv[4][i]))
+
+ if (namv[4][i] == '1' || isupper(namv[4][i]))
++j;
}
+
printf("0x%04x, ", j);
}
- else printf("%s, ", namv[4]);
+ else
+ printf("%s, ", namv[4]);
- if (namc == 7 &&
- *namv[6] == '+')
+ if (namc == 7 && *namv[6] == '+')
printf("%d, ", kwnum+1);
- else printf("0, ");
+ else
+ printf("0, ");
printf("%s},\n", namv[5]);
++kwnum;
}
-void error(char *s, char *s1) {
+void error(char * s, char * s1)
+{
fprintf(stderr, s, s1);
fprintf(stderr, "\n");
exit(1);
}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// AMODE.C - Addressing Modes
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "amode.h"
#include "error.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// AMODE.H - Addressing Modes
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __AMODE_H__
#define __AMODE_H__
LONG mn0, mn1; // Addressing modes
WORD mninst; // Instruction mask
WORD mncont; // Continuation (or -1)
- int (*mnfunc)(); // Mnemonic builder
+ int (*mnfunc)(WORD, WORD); // Mnemonic builder
};
// mnattr:
int amode(int);
int reglist(WORD *);
-#endif // __AMODE_H__
\ No newline at end of file
+#endif // __AMODE_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// DEBUG.C - Debugging Messages
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "debug.h"
#include "sect.h"
// --- Print 'c' Visibly ---------------------------------------------------------------------------
//
-int visprt(char c) {
- if(c < 0x20 || c >= 0x7f)
+int visprt(char c)
+{
+ if (c < 0x20 || c >= 0x7f)
putchar('.');
else
putchar(c);
- return(0);
+ return 0;
}
//
// --- Print expression, return ptr to just past the ENDEXPR ---------------------------------------
//
-TOKEN *printexpr(TOKEN *tp) {
- if(tp != NULL)
- while(*tp != ENDEXPR)
- switch((int)*tp++) {
+TOKEN * printexpr(TOKEN * tp)
+{
+ if (tp != NULL)
+ {
+ while (*tp != ENDEXPR)
+ {
+ switch ((int)*tp++)
+ {
case SYMBOL:
printf("`%s' ", ((SYM *)*tp)->sname);
++tp;
printf("%c ", (char)tp[-1]);
break;
}
+ }
+ }
+
printf(";\n");
- return(tp + 1);
+ return tp + 1;
}
//
// --- Dump data in a chunk (and maybe others) in the appropriate format ---------------------------
//
-int chdump(CHUNK *ch, int format) {
- while(ch != NULL) {
+int chdump(CHUNK * ch, int format)
+{
+ while (ch != NULL)
+ {
printf("chloc=$%08lx, chsize=$%lx\n", ch->chloc, ch->ch_size);
mdump(ch->chptr, ch->ch_size, format, ch->chloc);
ch = ch->chnext;
}
- return(0);
+ return 0;
}
//
// --- Dump fixup records in printable format ------------------------------------------------------
//
-int fudump(CHUNK *ch) {
+int fudump(CHUNK * ch)
+{
PTR p;
- char *ep;
+ char * ep;
WORD attr, esiz;
WORD line, file;
LONG loc;
- for(; ch != NULL;) {
+ for(; ch!=NULL;)
+ {
p.cp = ch->chptr;
ep = ch->chptr + ch->ch_size;
- while(p.cp < ep) {
+
+ while(p.cp < ep)
+ {
attr = *p.wp++;
loc = *p.lp++;
file = *p.wp++;
printf("$%04x $%08lx %d.%d: ", (int)attr, loc, (int)file, (int)line);
- if(attr & FU_EXPR) {
+ if (attr & FU_EXPR)
+ {
esiz = *p.wp++;
printf("(%d long) ", (int)esiz);
p.tk = printexpr(p.tk);
- } else {
+ }
+ else
+ {
printf("`%s' ;\n", (*p.sy)->sname);
++p.lp;
}
}
+
ch = ch->chnext;
}
- return(0);
+ return 0;
}
//
// --- Dump marks ----------------------------------------------------------------------------------
//
-int mudump(void) {
- MCHUNK *mch;
+int mudump(void)
+{
+ MCHUNK * mch;
PTR p;
WORD from;
WORD w;
LONG loc;
- SYM *symbol;
+ SYM * symbol;
from = 0;
- for(mch = firstmch; mch != NULL; mch = mch->mcnext) {
+
+ for(mch=firstmch; mch!=NULL; mch=mch->mcnext)
+ {
printf("mch=$%08lx mcptr=$%08lx mcalloc=$%lx mcused=$%x\n",
- mch,
- mch->mcptr,
+ (unsigned long int)mch,
+ (unsigned long int)(mch->mcptr.lw),
mch->mcalloc,
- mch->mcused);
+ (unsigned int)(mch->mcused));
p = mch->mcptr;
- for(;;) {
+
+ for(;;)
+ {
w = *p.wp++;
- if(w & MCHEND)
+
+ if (w & MCHEND)
break;
symbol = NULL;
loc = *p.lp++;
- if(w & MCHFROM)
+ if (w & MCHFROM)
from = *p.wp++;
- if(w & MSYMBOL)
+ if (w & MSYMBOL)
symbol = *p.sy++;
printf("m=$%04x to=%d loc=$%lx from=%d siz=%s",
w, w & 0x00ff, loc, from, (w & MLONG) ? "long" : "word");
- if(symbol != NULL)
+ if (symbol != NULL)
printf(" sym=`%s'", symbol->sname);
- printf("\n");
+
+ printf("\n");
}
}
- return(0);
+ return 0;
}
//
// --- Dump list of tokens on stdout in printable form ---------------------------------------------
//
-int dumptok(TOKEN *tk) {
+int dumptok(TOKEN * tk)
+{
int flg = 0;
- while(*tk != EOL) {
- if(flg++)
+ while (*tk != EOL)
+ {
+ if (flg++)
printf(" ");
- if(*tk >= 128) {
+ if (*tk >= 128)
+ {
printf("REG=%ld", *tk++ - 128);
continue;
}
- switch((int)*tk++) {
+ switch ((int)*tk++)
+ {
case CONST: // CONST <value>
printf("CONST=%ld", *tk++);
break;
case STRING: // STRING <address>
- printf("STRING='%s'", *tk++);
+ printf("STRING='%s'", (char *)*tk++);
break;
case SYMBOL: // SYMBOL <address>
- printf("SYMBOL='%s'", *tk++);
+ printf("SYMBOL='%s'", (char *)*tk++);
break;
case EOL: // End of line
printf("EOL");
printf("SHL");
break;
default:
- printf("%c", tk[-1]);
+ printf("%c", (int)tk[-1]);
break;
}
}
+
printf("\n");
- return(0);
+ return 0;
}
//
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// DEBUG.H - Debugging Messages
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __DEBUG_H__
#define __DEBUG_H__
int dumptok(TOKEN *);
int dump_everything(void);
-#endif // __DEBUG_H__
\ No newline at end of file
+#endif // __DEBUG_H__
// --- .org - Set origin ---------------------------------------------------------------------------
//
-int d_fail(void) {
+int d_fail(void)
+{
fatal("user abort");
return(0);
}
// --- .org - Set origin ---------------------------------------------------------------------------
//
-int d_org(void) {
+int d_org(void)
+{
VALUE address;
- if(!rgpu && !rdsp)
+ if (!rgpu && !rdsp)
return(error(".org permitted only in gpu/dsp section"));
orgaddr = 0;
- if(abs_expr(&address) == ERROR) {
+ if (abs_expr(&address) == ERROR)
+ {
error("cannot determine org'd address");
return(ERROR);
}
// --- NOP Padding Directive -----------------------------------------------------------------------
//
-int d_jpad(void) {
+int d_jpad(void)
+{
jpad = 1;
return(0);
}
-int d_nojpad(void) {
+int d_nojpad(void)
+{
jpad = 0;
return(0);
}
// --- Print Directive -----------------------------------------------------------------------------
//
-int d_print(void) {
+int d_print(void)
+{
char prntstr[LNSIZ]; // String for PRINT directive
char format[LNSIZ]; // Format for PRINT directive
int formatting = 0; // Formatting on/off
// --- .ds[.size] expression -----------------------------------------------------------------------
//
-int d_ds(WORD siz) {
+int d_ds(WORD siz)
+{
VALUE eval;
// This gets kind of stupid. This directive is disallowed in normal 68000 mode ("for your own
// good!"), but is permitted for 6502 and Alcyon-compatibility modes.
// For obvious reasons, no auto-even is done in 8-bit processor modes.
- if(as68_flag == 0 && (scattr & SBSS) == 0)
+ if (as68_flag == 0 && (scattr & SBSS) == 0)
return(error(".ds permitted only in BSS"));
- if(siz != SIZB && (sloc & 1)) // Automatic .even
+ if (siz != SIZB && (sloc & 1)) // Automatic .even
auto_even();
- if(abs_expr(&eval) != OK) return(0);
+ if (abs_expr(&eval) != OK)
+ return(0);
// In non-TDB section (BSS, ABS and M6502) just advance the location counter appropriately.
// In TDB sections, deposit (possibly large) chunks of zeroed memory....
- if((scattr & SBSS)) {
+ if ((scattr & SBSS))
+ {
listvalue(eval);
eval *= siz;
sloc += eval;
just_bss = 1; // No data deposited (8-bit CPU mode)
- } else {
+ }
+ else
+ {
dep_block(eval, siz, (VALUE)0, (WORD)(DEFINED|ABS), NULL);
}
// --- dc.b, dc.w / dc, dc.l -----------------------------------------------------------------------
//
-int d_dc(WORD siz) {
+int d_dc(WORD siz)
+{
WORD eattr;
VALUE eval;
WORD tdb;
WORD defined;
LONG i;
- char *p;
+ char * p;
int movei = 0; // movei flag for dc.i
- if((scattr & SBSS) != 0)
+ if ((scattr & SBSS) != 0)
return(error("illegal initialization of section"));
- if((siz != SIZB) && (sloc & 1))
+ if ((siz != SIZB) && (sloc & 1))
auto_even();
- for(;; ++tok) {
+ for(;; ++tok)
+ {
// dc.b 'string' [,] ...
- if (siz == SIZB && *tok == STRING && (tok[2] == ',' || tok[2] == EOL)) {
+ if (siz == SIZB && *tok == STRING && (tok[2] == ',' || tok[2] == EOL))
+ {
i = strlen((const char*)tok[1]);
- if((challoc - ch_size) < i)
+
+ if ((challoc - ch_size) < i)
chcheck(i);
- for(p = (char *)tok[1]; *p != EOS; ++p)
+
+ for(p=(char *)tok[1]; *p!=EOS; ++p)
D_byte(*p);
- tok += 2;
+
+ tok += 2;
goto comma;
}
- if(*tok == 'I') {
+ if (*tok == 'I')
+ {
movei = 1;
tok++;
siz = SIZL;
}
// dc.x <expression>
- if(expr(exprbuf, &eval, &eattr, NULL) != OK)
+ if (expr(exprbuf, &eval, &eattr, NULL) != OK)
return(0);
- tdb = (WORD)(eattr & TDB);
+
+ tdb = (WORD)(eattr & TDB);
defined = (WORD)(eattr & DEFINED);
- if((challoc - ch_size) < 4)
+
+ if ((challoc - ch_size) < 4)
chcheck(4L);
- switch(siz) {
+ switch (siz)
+ {
case SIZB:
- if(!defined) {
+ if (!defined)
+ {
fixup(FU_BYTE|FU_SEXT, sloc, exprbuf);
D_byte(0);
- } else {
- if(tdb)
+ }
+ else
+ {
+ if (tdb)
return(error("non-absolute byte value"));
- if(eval + 0x100 >= 0x200)
+
+ if (eval + 0x100 >= 0x200)
return(error(range_error));
- D_byte(eval);
+
+ D_byte(eval);
}
break;
case SIZW:
case SIZN:
- if(!defined) {
+ if (!defined)
+ {
fixup(FU_WORD|FU_SEXT, sloc, exprbuf);
D_word(0);
- } else {
- if(tdb)
+ }
+ else
+ {
+ if (tdb)
rmark(cursect, sloc, tdb, MWORD, NULL);
- if(eval + 0x10000 >= 0x20000)
+
+ if (eval + 0x10000 >= 0x20000)
return(error(range_error));
- // Deposit 68000 or 6502 (byte-reversed) word
+
+ // Deposit 68000 or 6502 (byte-reversed) word
D_word(eval);
}
break;
case SIZL:
- if(!defined) {
- if(movei)
+ if (!defined)
+ {
+ if (movei)
fixup(FU_LONG|FU_MOVEI, sloc, exprbuf);
else
fixup(FU_LONG, sloc, exprbuf);
- D_long(0);
- } else {
- if(tdb)
+
+ D_long(0);
+ }
+ else
+ {
+ if (tdb)
rmark(cursect, sloc, tdb, MLONG, NULL);
- if(movei)
+
+ if (movei)
eval = ((eval >> 16) & 0x0000FFFF) | ((eval << 16) & 0xFFFF0000);
- D_long(eval);
- }
+
+ D_long(eval);
+ }
break;
}
comma:
- if(*tok != ',')
+ if (*tok != ',')
break;
}
// --- dcb[.siz] expr1,expr2 - Make 'expr1' copies of 'expr2' --------------------------------------
//
-int d_dcb(WORD siz) {
+int d_dcb(WORD siz)
+{
VALUE evalc, eval;
WORD eattr;
- if((scattr & SBSS) != 0)
+ if ((scattr & SBSS) != 0)
return(error("illegal initialization of section"));
- if(abs_expr(&evalc) != OK)
+ if (abs_expr(&evalc) != OK)
return(0);
- if(*tok++ != ',')
+ if (*tok++ != ',')
return(error("missing comma"));
- if(expr(exprbuf, &eval, &eattr, NULL) < 0)
+ if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return(0);
- if((siz != SIZB) && (sloc & 1))
+ if ((siz != SIZB) && (sloc & 1))
auto_even();
dep_block(evalc, siz, eval, eattr, exprbuf);
// -------------------------------------------------------------------------------------------------
//
-int d_init(WORD def_siz) {
+int d_init(WORD def_siz)
+{
VALUE count;
VALUE eval;
WORD eattr;
WORD siz;
- if((scattr & SBSS) != 0)
+ if ((scattr & SBSS) != 0)
return(error(".init not permitted in BSS or ABS"));
- if(rgpu || rdsp)
+ if (rgpu || rdsp)
return(error("directive forbidden in gpu/dsp mode"));
- for(;;) {
+ for(;;)
+ {
// Get repeat count (defaults to 1)
- if(*tok == '#') {
+ if (*tok == '#')
+ {
++tok;
- if(abs_expr(&count) != OK)
+
+ if (abs_expr(&count) != OK)
return(0);
- if(*tok++ != ',')
+
+ if (*tok++ != ',')
return(error(comma_error));
- } else
+ }
+ else
count = 1;
// Evaluate expression to deposit
- if(expr(exprbuf, &eval, &eattr, NULL) < 0)
+ if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return(0);
- switch((int)*tok++) { // Determine size of object to deposit
+ switch ((int)*tok++)
+ { // Determine size of object to deposit
case DOTB: siz = SIZB; break;
case DOTW: siz = SIZB; break;
case DOTL: siz = SIZL; break;
dep_block(count, siz, eval, eattr, exprbuf);
- switch((int)*tok) {
+ switch ((int)*tok)
+ {
case EOL:
return(0);
case ',':
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// DIRECT.H - Directive Handling
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __DIRECT_H__
#define __DIRECT_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// EAGEN.C - Effective Address Code Generation
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "rmac.h"
#include "amode.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// EAGEN0.C - Effective Address Code Generation
// Generated Code for eaN (Included twice by "eagen.c")
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
-int eaNgen(WORD siz) {
+int eaNgen(WORD siz)
+{
WORD w;
VALUE v;
WORD tdb;
else printf("%s", buf);
exit(1);
-}
\ No newline at end of file
+}
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// EXPR.C - Expression Analyzer
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "expr.h"
#include "token.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// EXPR.H - Expression Analyzer
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __EXPR_H__
#define __EXPR_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// KWGEN.C - Keyword & Mnemonic Definition and State Machine Creation Tool
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
/*
* keyword transition-table generation utility
*
*/
s = strpool;
- while (gets(s) != NULL)
+
+// while (gets(s) != NULL)
+ while (fgets(s, STRPOOLSIZ, stdin) != NULL)
{
if (*s == '#' || !*s) /* ignore comment and empty lines */
continue;
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// LISTING.C - Listing Output
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// LISTING.H - Listing Output
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __LISTING_H__
#define __LISTING_H__
int d_subttl(void);
int d_title(void);
-#endif // __LISTING_H__
\ No newline at end of file
+#endif // __LISTING_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MACH.C - Code Generation
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "mach.h"
#include "error.h"
#include "kwtab.h"
// Common error messages
-char *range_error = "expression out of range";
-char *abs_error = "illegal absolute expression";
-char *seg_error = "bad (section) expression";
-char *rel_error = "illegal relative address";
-char *siz_error = "bad size specified";
-char *undef_error = "undefined expression";
-char *fwd_error = "forward or undefined expression";
+char * range_error = "expression out of range";
+char * abs_error = "illegal absolute expression";
+char * seg_error = "bad (section) expression";
+char * rel_error = "illegal relative address";
+char * siz_error = "bad size specified";
+char * undef_error = "undefined expression";
+char * fwd_error = "forward or undefined expression";
extern int ea0gen(WORD);
extern int ea1gen(WORD);
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MACH.H - Code Generation
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __MACH_H__
#define __MACH_H__
int m_movem(WORD, WORD);
int m_clra(WORD, WORD);
-#endif // __MACH_H__
\ No newline at end of file
+#endif // __MACH_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MACRO.C - Macro Definition and Invocation
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "macro.h"
#include "token.h"
// -------------------------------------------------------------------------------------------------
//
-void ib_macro(void) {
- SYM *mac;
+void ib_macro(void)
+{
+ SYM * mac;
curmac = mac = newsym("mjump", MACRO, 0);
mac->svalue = 0;
defmac1(" .rept (\\size/2)", -1);
defmac1(" nop", -1);
defmac1(" .endr", -1);
-}
\ No newline at end of file
+}
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MACRO.H - Macro Definition and Invocation
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __MACRO_H__
#define __MACRO_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MARK.C - A record of things that are defined relative to any of the sections
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "mark.h"
#include "error.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// MARK.H - A record of things that are defined relative to any of the sections
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __MARK_H__
#define __MARK_H__
#define MIN_MARK_MEM (3*sizeof(WORD)+2*sizeof(LONG))
// Globals, Externals etc
-extern MCHUNK *firstmch;
+extern MCHUNK * firstmch;
// Prototypes
void init_mark(void);
int amark(void);
LONG bsdmarkimg(char *, LONG, LONG, int);
-#endif // __MARK_H__
\ No newline at end of file
+#endif // __MARK_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// OBJECT.C - Writing Object Files
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "object.h"
#include "sect.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// OBJECT.H - Writing Object Files
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __OBJECT_H__
#define __OBJECT_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// PARMODE.C - Addressing Modes Parser Include
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
// This file is included (twice) to parse two addressing modes, into slightly different var names
{
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// PROCLN.C - Line Processing
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "procln.h"
#include "listing.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// PROCLN.H - Line Processing
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __PROCLN_H__
#define __PROCLN_H__
int d_endif(void);
int at_eol(void);
-#endif // __PROCLN_H__
\ No newline at end of file
+#endif // __PROCLN_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// RISCA.C - GPU/DSP Assembler
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "risca.h"
#include "error.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// RISCA.H - GPU/DSP Assembler
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __RISCA_H__
#define __RISCA_H__
int d_orgrisc(void);
#endif // __RISCA_H__
-
// As there is no command line, print a copyright message and prompt for command line
s = "*****************************************************\n";
- printf("\n%s* RMAC - Reboot's Macro Assembler for Atari Jaguar *\n", s);
+ printf("\n%s* RMAC - Reboot's Macro Assembler for Atari Jaguar *\n", s);
printf("* Copyright (C) 199x Landon Dyer, 2011 Reboot *\n");
- printf("* Version %01i.%01i.%01i Platform: %-9s *\n",MAJOR,MINOR,PATCH,PLATFORM);
+ printf("* Version %01i.%01i.%01i Platform: %-9s *\n",MAJOR,MINOR,PATCH,PLATFORM);
printf("* ------------------------------------------------- *\n");
- printf("* INTERACTIVE MODE *\n%s\n", s);
+ printf("* INTERACTIVE MODE (press ENTER by itself to quit) *\n%s\n", s);
perm_verb_flag = 1; // Enter permanent verbose mode
printf("* ");
fflush(stdout); // Make prompt visible
- if (gets(ln) == NULL || !*ln) // Get input line
+// if (gets(ln) == NULL || !*ln) // Get input line
+ if (fgets(ln, LNSIZ, stdin) == NULL || !*ln) // Get input line
break;
argcnt = 0; // Process input line
#define SYM struct _sym
SYM
{
- SYM *snext; // * -> Next symbol on hash-chain
- SYM *sorder; // * -> Next sym in order of refrence
- SYM *sdecl; // * -> Next sym in order of decleration
+ SYM * snext; // * -> Next symbol on hash-chain
+ SYM * sorder; // * -> Next sym in order of refrence
+ SYM * sdecl; // * -> Next sym in order of declaration
BYTE stype; // Symbol type
WORD sattr; // Attribute bits
LONG sattre; // Extended attribute bits
WORD senv; // Enviroment number
LONG svalue; // Symbol value
- char *sname; // * -> Symbol's print-name
+ char * sname; // * -> Symbol's print-name
};
// Pointer type that can point to (almost) anything
#define PTR union _ptr
PTR
{
- char *cp; // Char
- WORD *wp; // WORD
- LONG *lp; // LONG
+ char * cp; // Char
+ WORD * wp; // WORD
+ LONG * lp; // LONG
LONG lw; // LONG
- SYM **sy; // SYM
- TOKEN *tk; // TOKEN
+ SYM ** sy; // SYM
+ TOKEN * tk; // TOKEN
};
// Symbol spaces
extern int err_flag;
extern int err_fd;
extern int regbank;
-extern char *firstfname;
+extern char * firstfname;
extern int list_fd;
extern int as68_flag;
extern int list_flag;
// Prototypes
void init_sym(void);
-SYM *lookup(char *, int, int);
-SYM *newsym(char *, int, int);
-char *fext(char *, char *, int);
+SYM * lookup(char *, int, int);
+SYM * newsym(char *, int, int);
+char * fext(char *, char *, int);
void cantcreat(char *);
int kmatch(char *, int *, int *, int *, int *);
void autoeven(int);
int nthpath(char *, int, char *);
void clear(char *, LONG);
-char *copy(char *, char *, LONG);
-int rmac_qsort(char *, int, int, int (*)());
-char *amem(LONG);
+char * copy(char *, char *, LONG);
+int rmac_qsort(char *, int, int, int (*)());
+char * amem(LONG);
#endif // __RMAC_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// SECT.C - Code Generation, Fixups and Section Management
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "sect.h"
#include "error.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// SECT.H - Code Generation, Fixups and Section Management
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __SECT_H__
#define __SECT_H__
int fixups(void);
int resfix(int);
-#endif // __SECT_H__
\ No newline at end of file
+#endif // __SECT_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// SYMBOL.C - Symbol Handling
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "symbol.h"
#include "listing.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// SYMBOL.H - Symbol Handling
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __SYMBOL_H__
#define __SYMBOL_H__
extern char subttl[];
// Prototypes
-SYM *lookup(char *, int, int);
+SYM * lookup(char *, int, int);
void init_sym(void);
-SYM *newsym(char *, int, int);
-char *nstring(char *);
+SYM * newsym(char *, int, int);
+char * nstring(char *);
void sym_decl(SYM *);
int syg_fix(void);
int symtable(void);
int sy_assign(char *, char *(*)());
-#endif // __SYMBOL_H__
\ No newline at end of file
+#endif // __SYMBOL_H__
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// TOKEN.C - Token Handling
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#include "token.h"
#include "symbol.h"
int totlines; // Total # of lines
int mjump_align = 0; // mjump alignment flag
char lntag; // Line tag
-char *curfname; // Current filename
+char * curfname; // Current filename
char tolowertab[128]; // Uppercase ==> lowercase
char hextab[128]; // Table of hex values
char dotxtab[128]; // Table for ".b", ".s", etc.
char lnbuf[LNSIZ]; // Text of current line
WORD filecount; // Unique file number counter
WORD cfileno; // Current file number
-TOKEN *tok; // Ptr to current token
-TOKEN *etok; // Ptr past last token in tokbuf[]
+TOKEN * tok; // Ptr to current token
+TOKEN * etok; // Ptr past last token in tokbuf[]
TOKEN tokeol[1] = {EOL}; // Bailout end-of-line token
// File record, used to maintain a list of every include file ever visited
#define FILEREC struct _filerec
-FILEREC {
- FILEREC *frec_next;
- char *frec_name;
+FILEREC
+{
+ FILEREC * frec_next;
+ char * frec_name;
};
-FILEREC *filerec;
-FILEREC *last_fr;
+FILEREC * filerec;
+FILEREC * last_fr;
-INOBJ *cur_inobj; // Ptr current input obj (IFILE/IMACRO)
-static INOBJ *f_inobj; // Ptr list of free INOBJs
-static IFILE *f_ifile; // Ptr list of free IFILEs
-static IMACRO *f_imacro; // Ptr list of free IMACROs
+INOBJ * cur_inobj; // Ptr current input obj (IFILE/IMACRO)
+static INOBJ * f_inobj; // Ptr list of free INOBJs
+static IFILE * f_ifile; // Ptr list of free IFILEs
+static IMACRO * f_imacro; // Ptr list of free IMACROs
static TOKEN tokbuf[TOKBUFSIZE]; // Token buffer (stack-like, all files)
};
// Names of registers
-static char *regname[] = {
+static char * regname[] = {
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
"pc", "ssp", "usp", "sr", "ccr"
};
-static char *riscregname[] = {
+static char * riscregname[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
// --- Make `fnum' the Current `curfname' ----------------------------------------------------------
//
-void setfnum(WORD fnum) {
+void setfnum(WORD fnum)
+{
FILEREC *fr;
for(fr = filerec; fr != NULL && fnum--; fr = fr->frec_next)
// --- Allocate an IFILE or IMACRO -----------------------------------------------------------------
//
-INOBJ *a_inobj(int typ) {
+INOBJ * a_inobj(int typ)
+{
INOBJ *inobj;
IFILE *ifile;
IMACRO *imacro;
// -------------------------------------------------------------------------------------------------
//
-int mexpand(char *src, char *dest, int destsiz) {
+int mexpand(char * src, char * dest, int destsiz)
+{
char *s;
char *d = NULL;
char *dst; // Next dest slot
// --- Get Next Line of Text from a Macro ----------------------------------------------------------
//
-char *getmln(void) {
+char * getmln(void)
+{
IMACRO *imacro;
LONG *strp;
unsigned source_addr;
// --- Get Next Line of Text from a Repeat Block ---------------------------------------------------
//
-char *getrln(void) {
+char * getrln(void)
+{
IREPT *irept;
LONG *strp;
// Do repeat at end of .rept block's string list
if(strp == NULL) {
- DEBUG printf("back-to-top-of-repeat-block count=%d\n", irept->ir_count);
+ DEBUG printf("back-to-top-of-repeat-block count=%d\n", (int)irept->ir_count);
irept->ir_nextln = irept->ir_firstln; // copy first line
if(irept->ir_count-- == 0) {
DEBUG printf("end-repeat-block\n");
// --- Include a Source File used at the Root, and for ".include" Files ----------------------------
//
-int include(int handle, char *fname) {
+int include(int handle, char * fname)
+{
IFILE *ifile;
INOBJ *inobj;
FILEREC *fr;
// --- Initialize Tokenizer ------------------------------------------------------------------------
//
-void init_token(void) {
+void init_token(void)
+{
int i; // Iterator
char *htab = "0123456789abcdefABCDEF"; // Hex character table
//
// --- Pop the Current Input Level -----------------------------------------------------------------
//
-int fpop(void) {
+int fpop(void)
+{
INOBJ *inobj;
IFILE *ifile;
IMACRO *imacro;
// --- Get line from file into buf, return NULL on EOF or ptr to the start of a null-term line -----
//
-char *getln(void) {
+char * getln(void)
+{
IFILE *fl;
int i, j;
char *p, *d;
// --- Tokenize a Line -----------------------------------------------------------------------------
//
-int tokln(void) {
+int tokln(void)
+{
char *ln = NULL; // Ptr to current position in line
char *p; // Random character ptr
TOKEN *tk; // Token-deposit ptr
//
//int d_goto(WORD siz) {
-int d_goto(void) {
+int d_goto(void)
+{
char *sym; // Label to search for
LONG *defln; // Macro definition strings
char *s1; // Temps for string comparison
-////////////////////////////////////////////////////////////////////////////////////////////////////
+//
// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
// TOKEN.H - Token Handling
// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source Utilised with the Kind Permission of Landon Dyer
+//
#ifndef __TOKEN_H__
#define __TOKEN_H__
int d_goto(void);
INOBJ *a_inobj(int);
-#endif // __TOKEN_H__
\ No newline at end of file
+#endif // __TOKEN_H__