From bdbf34766f4d074a5933eb1326fe4ce03d249e10 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 6 Aug 2019 10:16:20 -0500 Subject: [PATCH] Added in DSP fixups to sect.c, misc. fixes for 6502 assembler. --- 6502.c | 29 +++++++- 6502.h | 2 +- 68kgen.c | 2 +- amode.c | 2 +- amode.h | 2 +- debug.c | 2 +- debug.h | 2 +- direct.c | 6 +- direct.h | 2 +- dsp56k.c | 2 +- dsp56k.h | 2 +- dsp56k_amode.c | 4 +- dsp56k_amode.h | 2 +- dsp56k_mach.c | 4 +- dsp56k_mach.h | 2 +- dsp56kgen.c | 2 +- eagen.c | 2 +- eagen.h | 2 +- eagen0.c | 2 +- error.c | 2 +- error.h | 2 +- expr.c | 2 +- expr.h | 2 +- fltpoint.c | 2 +- fltpoint.h | 2 +- kwgen.c | 2 +- listing.c | 2 +- listing.h | 2 +- mach.c | 2 +- mach.h | 2 +- macro.c | 2 +- macro.h | 2 +- makefile | 2 +- mark.c | 2 +- mark.h | 2 +- object.c | 2 +- object.h | 2 +- op.c | 2 +- op.h | 2 +- parmode.h | 2 +- procln.c | 2 +- procln.h | 2 +- riscasm.c | 2 +- riscasm.h | 2 +- rmac.c | 2 +- rmac.h | 2 +- sect.c | 183 +++++++++++++++++++++++++++++++++++++++++++------ sect.h | 38 +++++----- symbol.c | 2 +- symbol.h | 2 +- token.c | 5 +- token.h | 2 +- version.h | 2 +- 53 files changed, 260 insertions(+), 101 deletions(-) diff --git a/6502.c b/6502.c index 55c6048..27a8e1a 100644 --- a/6502.c +++ b/6502.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // 6502.C - 6502 Assembler -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -344,6 +344,7 @@ void m6502cg(int op) { // (foo,x) tok++; +#if 0 p = string[tok[1]]; // Sleazo tolower() -----------------vvvvvvvvvvv @@ -351,17 +352,27 @@ void m6502cg(int op) goto badmode; tok += 2; - if (*tok++ != ')') goto badmode; amode = A65_INDX; +#else + if (tok[0] == KW_X) + amode = A65_INDX; + + if ((tok[1] != ')') || (tok[2] != EOL)) + goto badmode; + + tok += 2; +#endif } else goto badmode; break; + // I'm guessing that the form of this is @(X) or @(Y), which + // I've *never* seen before. :-/ case '@': tok++; @@ -371,6 +382,7 @@ void m6502cg(int op) if (*tok == '(') { tok++; +#if 0 p = string[tok[1]]; if (*tok != SYMBOL || p[1] != EOS || tok[2] != ')' || tok[3] != EOL) @@ -386,6 +398,19 @@ void m6502cg(int op) goto badmode; tok += 3; // Past SYMBOL ')' EOL +#else + if ((tok[1] != ')') || (tok[2] != EOL)) + goto badmode; + + if (tok[0] == KW_X) + amode = A65_INDX; + else if (tok[0] == KW_Y) + amode = A65_INDY; + else + goto badmode; + + tok += 2; +#endif zpreq = 1; // Request zeropage optimization } else if (*tok == EOL) diff --git a/6502.h b/6502.h index ccb2a57..72f3ff6 100644 --- a/6502.h +++ b/6502.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // 6502.H - 6502 assembler -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/68kgen.c b/68kgen.c index ca3ce71..497dbb4 100644 --- a/68kgen.c +++ b/68kgen.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // 68KGEN.C - Tool to Generate 68000 Opcode Table -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/amode.c b/amode.c index ccd86dd..8ac5392 100644 --- a/amode.c +++ b/amode.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // AMODE.C - Addressing Modes -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/amode.h b/amode.h index e46be37..5d9ff72 100644 --- a/amode.h +++ b/amode.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // AMODE.H - Addressing Modes -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/debug.c b/debug.c index 9ef0bcb..1b9b651 100644 --- a/debug.c +++ b/debug.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DEBUG.C - Debugging Messages -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/debug.h b/debug.h index 71a6c78..576b958 100644 --- a/debug.h +++ b/debug.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DEBUG.H - Debugging Messages -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/direct.c b/direct.c index 294ea4a..c42d8b8 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-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -280,7 +280,7 @@ int d_print(void) while (*tok != EOL) { - switch(*tok) + switch (*tok) { case STRING: sprintf(prntstr, "%s", string[tok[1]]); @@ -312,7 +312,7 @@ int d_print(void) { strcpy(prntstr, string[tok[2]]); - switch(prntstr[0]) + switch (prntstr[0]) { case 'l': case 'L': wordlong = 1; break; case 'w': case 'W': wordlong = 0; break; diff --git a/direct.h b/direct.h index dee418e..55959b3 100644 --- a/direct.h +++ b/direct.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DIRECT.H - Directive Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/dsp56k.c b/dsp56k.c index 50e8601..2960e24 100644 --- a/dsp56k.c +++ b/dsp56k.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DSP56K.C - General DSP56001 routines -// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/dsp56k.h b/dsp56k.h index c73e99e..18395fc 100644 --- a/dsp56k.h +++ b/dsp56k.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // DSP56K.H - General DSP56001 routines -// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/dsp56k_amode.c b/dsp56k_amode.c index c5644cc..6c8bc25 100644 --- a/dsp56k_amode.c +++ b/dsp56k_amode.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System // AMODE.C - DSP 56001 Addressing Modes -// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -753,7 +753,7 @@ int dsp_amode(int maxea) return ERROR; - // If caller wants only one mode, return just one (ignore comma); + // If caller wants only one mode, return just one (ignore comma); // If there is no second addressing mode (no comma), then return just one anyway. nmodes = 1; diff --git a/dsp56k_amode.h b/dsp56k_amode.h index 03ae962..0582d49 100644 --- a/dsp56k_amode.h +++ b/dsp56k_amode.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System // DSP56K_AMODE.H - Addressing Modes for Motorola DSP56001 -// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/dsp56k_mach.c b/dsp56k_mach.c index 20fc07a..f7e8c87 100644 --- a/dsp56k_mach.c +++ b/dsp56k_mach.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System // DSP56L_MACH.C - Code Generation for Motorola DSP56001 -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -75,7 +75,7 @@ static inline int dsp_extra_ea() { if (deposit_extra_ea == DEPOSIT_EXTRA_WORD) { - if (!(dspImmedEXATTR&FLOAT)) + if (!(dspImmedEXATTR & FLOAT)) { if (dspImmedEXATTR & DEFINED) { diff --git a/dsp56k_mach.h b/dsp56k_mach.h index 593ff9a..184fc63 100644 --- a/dsp56k_mach.h +++ b/dsp56k_mach.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System // DSP56L_MACH.C - Code Generation for Motorola DSP56001 -// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/dsp56kgen.c b/dsp56kgen.c index 3f263ad..06c6661 100644 --- a/dsp56kgen.c +++ b/dsp56kgen.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // 68KGEN.C - Tool to Generate 68000 Opcode Table -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/eagen.c b/eagen.c index 5c83aad..e416f23 100644 --- a/eagen.c +++ b/eagen.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // EAGEN.C - Effective Address Code Generation -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/eagen.h b/eagen.h index dcca6a6..a130639 100644 --- a/eagen.h +++ b/eagen.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // EAGEN.H - Effective address generation for 68K -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/eagen0.c b/eagen0.c index 5b3c4ab..11e648a 100644 --- a/eagen0.c +++ b/eagen0.c @@ -2,7 +2,7 @@ // RMAC - Reboot's Macro Assembler for all Atari computers // EAGEN0.C - Effective Address Code Generation // Generated Code for eaN (Included twice by "eagen.c") -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/error.c b/error.c index 9b5460b..6db7ad0 100644 --- a/error.c +++ b/error.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // ERROR.C - Error Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/error.h b/error.h index f433728..be072d5 100644 --- a/error.h +++ b/error.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // ERROR.H - Error Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/expr.c b/expr.c index 6db7435..d1ee1f5 100644 --- a/expr.c +++ b/expr.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // EXPR.C - Expression Analyzer -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/expr.h b/expr.h index 517c4a0..55ed1e6 100644 --- a/expr.h +++ b/expr.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // EXPR.H - Expression Analyzer -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/fltpoint.c b/fltpoint.c index 911e008..8739e88 100644 --- a/fltpoint.c +++ b/fltpoint.c @@ -2,7 +2,7 @@ // Floating point to IEEE-754 conversion routines // // by James Hammons -// (C) 2018 Underground Software +// (C) 2019 Underground Software // // Since there are no guarantees vis-a-vis floating point numbers in C, we have // to utilize routines like the following in order to guarantee that the thing diff --git a/fltpoint.h b/fltpoint.h index 558ad7b..6444ed3 100644 --- a/fltpoint.h +++ b/fltpoint.h @@ -2,7 +2,7 @@ // Cross-platform floating point handling (fixed point handling too!) // // by James Hammons -// (C) 2018 Underground Software +// (C) 2019 Underground Software // #ifndef __FLTPOINT_H__ diff --git a/kwgen.c b/kwgen.c index ae8e125..b3c209e 100644 --- a/kwgen.c +++ b/kwgen.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // KWGEN.C - Keyword & Mnemonic Definition and State Machine Creation Tool -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/listing.c b/listing.c index f6e7eb0..87956af 100644 --- a/listing.c +++ b/listing.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // LISTING.C - Listing Output -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/listing.h b/listing.h index d60793b..c7a42cc 100644 --- a/listing.h +++ b/listing.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // LISTING.H - Listing Output -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/mach.c b/mach.c index 9e124a9..f979c9e 100644 --- a/mach.c +++ b/mach.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MACH.C - Code Generation -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/mach.h b/mach.h index e9b7c82..5151210 100644 --- a/mach.h +++ b/mach.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MACH.H - Code Generation -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/macro.c b/macro.c index 4ca149d..8d5d88e 100644 --- a/macro.c +++ b/macro.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MACRO.C - Macro Definition and Invocation -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/macro.h b/macro.h index 49e387d..2180757 100644 --- a/macro.h +++ b/macro.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MACRO.H - Macro Definition and Invocation -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/makefile b/makefile index b69348f..ca6b7d1 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ # # RMAC - Reboot's Macro Assembler for all Atari computers -# Copyright (C) 199x Landon Dyer, 2011-2018 Reboot & Friends +# Copyright (C) 199x Landon Dyer, 2011-2019 Reboot & Friends # MAKEFILE for *nix # diff --git a/mark.c b/mark.c index a5e1975..1cb0f05 100644 --- a/mark.c +++ b/mark.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MARK.C - A record of things that are defined relative to any of the sections -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/mark.h b/mark.h index 2415a80..2d81f4d 100644 --- a/mark.h +++ b/mark.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // MARK.H - A record of things that are defined relative to any of the sections -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/object.c b/object.c index 9f9de01..bee4fd6 100644 --- a/object.c +++ b/object.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // OBJECT.C - Writing Object Files -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/object.h b/object.h index 4cac13b..46aef64 100644 --- a/object.h +++ b/object.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // OBJECT.H - Writing Object Files -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/op.c b/op.c index c73c72f..6a78fbc 100644 --- a/op.c +++ b/op.c @@ -2,7 +2,7 @@ // Jaguar Object Processor assembler // // by James Hammons -// (C) 2018 Underground Software +// (C) 2019 Underground Software // #include "op.h" diff --git a/op.h b/op.h index f7c31b8..51bdc8d 100644 --- a/op.h +++ b/op.h @@ -2,7 +2,7 @@ // Object Processor assembler // // by James Hammons -// (C) 2018 Underground Software +// (C) 2019 Underground Software // #ifndef __OP_H__ diff --git a/parmode.h b/parmode.h index 13b83fc..749d4e4 100644 --- a/parmode.h +++ b/parmode.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // PARMODE.C - Addressing Modes Parser Include -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/procln.c b/procln.c index 0bb52e6..fe13aa7 100644 --- a/procln.c +++ b/procln.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // PROCLN.C - Line Processing -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/procln.h b/procln.h index a8a1d95..07be91d 100644 --- a/procln.h +++ b/procln.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // PROCLN.H - Line Processing -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/riscasm.c b/riscasm.c index 0b09bf1..fea5153 100644 --- a/riscasm.c +++ b/riscasm.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // RISCA.C - GPU/DSP Assembler -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/riscasm.h b/riscasm.h index 91376dc..b71c38e 100644 --- a/riscasm.h +++ b/riscasm.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // RISCA.H - GPU/DSP Assembler -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/rmac.c b/rmac.c index 9dd75fd..ecc3adc 100644 --- a/rmac.c +++ b/rmac.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // RMAC.C - Main Application Code -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/rmac.h b/rmac.h index cf8aabc..10e7e59 100644 --- a/rmac.h +++ b/rmac.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // RMAC.H - Main Application Code -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/sect.c b/sect.c index b076ca6..9c1a586 100644 --- a/sect.c +++ b/sect.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // SECT.C - Code Generation, Fixups and Section Management -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -262,6 +262,14 @@ int AddFixup(uint32_t attr, uint32_t loc, TOKEN * fexpr) exprlen = ExpressionLength(fexpr); } + // Second, check to see if it's a DSP56001 fixup, and force the FU_56001 + // flag into the attributes if so; also save the current org address. + if (attr & FUMASKDSP) + { + attr |= FU_56001; + _orgaddr = orgaddr; + } + // Allocate space for the fixup + any expression FIXUP * fixup = malloc(sizeof(FIXUP) + (sizeof(TOKEN) * exprlen)); @@ -330,7 +338,7 @@ int ResolveFixups(int sno) FIXUP * fup = fixup; fixup = fixup->next; - uint32_t w = fup->attr; // Fixup long (type + modes + flags) + uint32_t dw = fup->attr; // Fixup long (type + modes + flags) uint32_t loc = fup->loc; // Location to fixup cfileno = fup->fileno; curlineno = fup->lineno; @@ -376,7 +384,7 @@ int ResolveFixups(int sno) // Compute expression/symbol value and attributes // Complex expression - if (w & FU_EXPR) + if (dw & FU_EXPR) { if (evexpr(fup->expr, &eval, &eattr, &esym) != OK) continue; @@ -418,7 +426,7 @@ int ResolveFixups(int sno) // // PC-relative fixups must be DEFINED and either in the same section // (whereupon the subtraction takes place) or ABS (with no subtract). - if (w & FU_PCREL) + if (dw & FU_PCREL) { if (eattr & DEFINED) { @@ -454,7 +462,7 @@ int ResolveFixups(int sno) } } - if (sbra_flag && (w & FU_LBRA) && (eval + 0x80 < 0x100)) + if (sbra_flag && (dw & FU_LBRA) && (eval + 0x80 < 0x100)) warn("unoptimized short branch"); } else if (obj_format == MWC) @@ -465,7 +473,7 @@ int ResolveFixups(int sno) } // Handle fixup classes - switch (w & FUMASK) + switch (dw & FUMASK) { // FU_BBRA fixes up a one-byte branch offset. case FU_BBRA: @@ -518,10 +526,10 @@ int ResolveFixups(int sno) continue; } - if ((w & FU_PCREL) && ((eval + 0x80) >= 0x100)) + if ((dw & FU_PCREL) && ((eval + 0x80) >= 0x100)) goto rangeErr; - if (w & FU_SEXT) + if (dw & FU_SEXT) { if ((eval + 0x100) >= 0x200) goto rangeErr; @@ -554,16 +562,20 @@ int ResolveFixups(int sno) break; // Fixup WORD forward references; the word could be unaligned in the - // section buffer, so we have to be careful. + // section buffer, so we have to be careful. (? careful about what?) case FU_WORD: - if ((w & FUMASKRISC) == FU_JR) + if ((dw & FUMASKRISC) == FU_JR) { +#if 0 int reg; if (fup->orgaddr) reg = (signed)((eval - (fup->orgaddr + 2)) / 2); else reg = (signed)((eval - (loc + 2)) / 2); +#else + int reg = (signed)((eval - ((fup->orgaddr ? fup->orgaddr : loc) + 2)) / 2); +#endif if ((reg < -16) || (reg > 15)) { @@ -576,7 +588,7 @@ int ResolveFixups(int sno) *locp |= ((uint8_t)reg & 0x07) << 5; break; } - else if ((w & FUMASKRISC) == FU_NUM15) + else if ((dw & FUMASKRISC) == FU_NUM15) { if (((int)eval < -16) || ((int)eval > 15)) { @@ -589,7 +601,7 @@ int ResolveFixups(int sno) *locp |= ((uint8_t)eval & 0x07) << 5; break; } - else if ((w & FUMASKRISC) == FU_NUM31) + else if ((dw & FUMASKRISC) == FU_NUM31) { if (eval > 31) { @@ -602,7 +614,7 @@ int ResolveFixups(int sno) *locp |= ((uint8_t)eval & 0x07) << 5; break; } - else if ((w & FUMASKRISC) == FU_NUM32) + else if ((dw & FUMASKRISC) == FU_NUM32) { if ((eval < 1) || (eval > 32)) { @@ -610,7 +622,7 @@ int ResolveFixups(int sno) break; } - if (w & FU_SUB32) + if (dw & FU_SUB32) eval = (32 - eval); eval = (eval == 32) ? 0 : eval; @@ -619,7 +631,7 @@ int ResolveFixups(int sno) *locp |= ((uint8_t)eval & 0x07) << 5; break; } - else if ((w & FUMASKRISC) == FU_REGONE) + else if ((dw & FUMASKRISC) == FU_REGONE) { if (eval > 31) { @@ -632,7 +644,7 @@ int ResolveFixups(int sno) *locp |= ((uint8_t)eval & 0x07) << 5; break; } - else if ((w & FUMASKRISC) == FU_REGTWO) + else if ((dw & FUMASKRISC) == FU_REGTWO) { if (eval > 31) { @@ -649,7 +661,7 @@ int ResolveFixups(int sno) { flags = MWORD; - if (w & FU_PCREL) + if (dw & FU_PCREL) flags |= MPCREL; MarkRelocatable(sno, loc, 0, flags, esym); @@ -659,7 +671,7 @@ int ResolveFixups(int sno) if (tdb) MarkRelocatable(sno, loc, tdb, MWORD, NULL); - if (w & FU_SEXT) + if (dw & FU_SEXT) { if (eval + 0x10000 >= 0x20000) goto rangeErr; @@ -667,7 +679,7 @@ int ResolveFixups(int sno) else { // Range-check BRA and DBRA - if (w & FU_ISBRA) + if (dw & FU_ISBRA) { if (eval + 0x8000 >= 0x10000) goto rangeErr; @@ -690,7 +702,7 @@ int ResolveFixups(int sno) case FU_LONG: flags = MLONG; - if ((w & FUMASKRISC) == FU_MOVEI) + if ((dw & FUMASKRISC) == FU_MOVEI) { // Long constant in MOVEI # is word-swapped, so fix it here eval = WORDSWAP32(eval); @@ -709,17 +721,18 @@ int ResolveFixups(int sno) // Fixup QUAD forward references (mainly used by the OP assembler) case FU_QUAD: - if (w & FU_OBJLINK) + if (dw & FU_OBJLINK) { uint64_t quad = GETBE64(locp, 0); uint64_t addr = eval; +//Hmm, not sure how this can be set, since it's only set if it's a DSP56001 fixup or a FU_JR... :-/ if (fup->orgaddr) addr = fup->orgaddr; eval = (quad & 0xFFFFFC0000FFFFFFLL) | ((addr & 0x3FFFF8) << 21); } - else if (w & FU_OBJDATA) + else if (dw & FU_OBJDATA) { // If it's in a TEXT or DATA section, be sure to mark for a // fixup later @@ -729,6 +742,7 @@ int ResolveFixups(int sno) uint64_t quad = GETBE64(locp, 0); uint64_t addr = eval; +//Hmm, not sure how this can be set, since it's only set if it's a DSP56001 fixup or a FU_JR... :-/ if (fup->orgaddr) addr = fup->orgaddr; @@ -763,6 +777,131 @@ int ResolveFixups(int sno) *locp = (uint8_t)eval; break; + // Fixup DSP56001 addresses + case FU_56001: + switch (dw & FUMASKDSP) + { + // DSPIMM5 actually is clamped from 0 to 23 for our purposes + // and does not use the full 5 bit range. + case FU_DSPIMM5: + if (eval > 23) + { + error("immediate value must be between 0 and 23"); + break; + } + + locp[2] |= eval; + break; + + // This is a 12-bit address encoded into the lower 12 + // bits of a DSP word + case FU_DSPADR12: + if (eval >= 0x1000) + { + error("address out of range ($000-$FFF)"); + break; + } + + locp[1] |= eval >> 8; + locp[2] = eval & 0xFF; + break; + + // This is a full DSP word containing Effective Address Extension + case FU_DSPADR24: + case FU_DSPIMM24: + if (eval >= 0x100000) + { + error("value out of range ($000-$FFFFFF)"); + break; + } + + *locp++ = (uint32_t)eval >> 16; + *locp++ = ((uint32_t)eval >> 8) & 0xFF; + *locp++ = (uint32_t)eval & 0xFF; + break; + + // This is a 16bit absolute address into a 24bit field + case FU_DSPADR16: + if (eval >= 0x10000) + { + error("address out of range ($0000-$FFFF)"); + break; + } + + locp[1] = (uint8_t)(eval >> 8); + locp[2] = (uint8_t)eval; + break; + + // This is 12-bit immediate short data + // The upper nibble goes into the last byte's low nibble + // while the remainder 8 bits go into the 2nd byte. + case FU_DSPIMM12: + if (eval >= 0x1000) + { + error("immediate out of range ($000-$FFF)"); + break; + } + + locp[1] = (uint8_t)eval; + locp[2] |= (uint8_t)(eval >> 8); + break; + + // This is 8-bit immediate short data + // which goes into the middle byte of a DSP word. + case FU_DSPIMM8: + if (eval >= 0x100) + { + error("immediate out of range ($00-$FF)"); + break; + } + + locp[1] = (uint8_t)eval; + break; + + // This is a 6 bit absoulte short address. It occupies + // the low 6 bits of the middle byte of a DSP word. + case FU_DSPADR06: + if (eval > 63) + { + error("address must be between 0 and 63"); + break; + } + + locp[1] |= eval; + break; + + // This is a 6 bit absoulte short address. It occupies + // the low 6 bits of the middle byte of a DSP word. + case FU_DSPPP06: + if (eval < 0xFFFFFFC0) + { + error("address must be between $FFC0 and $FFFF"); + break; + } + + locp[1] |= eval & 0x3F; + break; + + // Shamus: I'm pretty sure these don't make any sense... + case FU_DSPIMMFL8: + warn("FU_DSPIMMFL8 missing implementation\n%s", "And you may ask yourself, \"Self, how did I get here?\""); + break; + + case FU_DSPIMMFL16: + warn("FU_DSPIMMFL16 missing implementation\n%s", "And you may ask yourself, \"Self, how did I get here?\""); + break; + + case FU_DSPIMMFL24: + warn("FU_DSPIMMFL24 missing implementation\n%s", "And you may ask yourself, \"Self, how did I get here?\""); + break; + + // Bad fixup type--this should *never* happen! + default: + interror(4); + // NOTREACHED + } + break; + // Fixup a 4-byte float case FU_FLOATSING: warn("FU_FLOATSING missing implementation\n%s", "And you may ask yourself, \"Self, how did I get here?\""); diff --git a/sect.h b/sect.h index 83bc7b5..84ad789 100644 --- a/sect.h +++ b/sect.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // SECT.H - Code Generation, Fixups and Section Management -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilized with the kind permission of Landon Dyer // @@ -77,9 +77,8 @@ #define FU_6BRA 0x0007 // Fixup 6502-format branch offset #define FU_BYTEH 0x0008 // Fixup 6502 high byte of immediate word #define FU_BYTEL 0x0009 // Fixup 6502 low byte of immediate word -#define FU_QUAD 0x000A // Fixup quad-word (8 bytes) -#define FU_56001 0x000B // Generic fixup code for all 56001 modes -#define FU_56001_B 0x000C // Generic fixup code for all 56001 modes (ggn: I have no shame) +#define FU_QUAD 0x000A // Fixup quad-word (8 bytes, typically OP) +#define FU_56001 0x000B // Fixup code for all 56001 modes #define FU_SEXT 0x0010 // Ok to sign extend #define FU_PCREL 0x0020 // Subtract PC first @@ -111,24 +110,19 @@ #define FU_OBJDATA 0x20000 // Fixup OL data addr (bits 43-63, drop last 3) // DSP56001 fixups -// TODO: Sadly we don't have any spare bits left inside a 16-bit word -// so we use the 2nd nibble as control code and -// stick $B or $C in the lower nibble - then it's picked up as -// FU_56001 by the fixup routine and then a second switch -// selects fixup mode. Since we now have 32 bits, we can fix this! -// [N.B.: This isn't true anymore, we now have 32 bits! :-P] -#define FU_DSPIMM5 0x090B // Fixup 5-bit immediate -#define FU_DSPADR12 0x0A0B // Fixup 12-bit address -#define FU_DSPADR24 0x0B0B // Fixup 24-bit address -#define FU_DSPADR16 0x0C0B // Fixup 24-bit address -#define FU_DSPIMM12 0x0D0B // Fixup 12-bit immediate -#define FU_DSPIMM24 0x0E0B // Fixup 24-bit immediate -#define FU_DSPIMM8 0x0F0B // Fixup 8-bit immediate -#define FU_DSPADR06 0x090C // Fixup 6-bit address -#define FU_DSPPP06 0x0A0C // Fixup 6 bit pp address -#define FU_DSPIMMFL8 0x0B0C // Fixup 8-bit immediate float -#define FU_DSPIMMFL16 0x0C0C // Fixup 16-bit immediate float -#define FU_DSPIMMFL24 0x0D0C // Fixup 24-bit immediate float +#define FUMASKDSP 0xF00000 // Mask for DSP56001 fuckups^Wfixups +#define FU_DSPIMM5 0x100000 // Fixup 5-bit immediate +#define FU_DSPADR12 0x200000 // Fixup 12-bit address +#define FU_DSPADR24 0x300000 // Fixup 24-bit address +#define FU_DSPADR16 0x400000 // Fixup 16-bit address +#define FU_DSPIMM12 0x500000 // Fixup 12-bit immediate +#define FU_DSPIMM24 0x600000 // Fixup 24-bit immediate +#define FU_DSPIMM8 0x700000 // Fixup 8-bit immediate +#define FU_DSPADR06 0x800000 // Fixup 6-bit address +#define FU_DSPPP06 0x900000 // Fixup 6 bit pp address +#define FU_DSPIMMFL8 0xA00000 // Fixup 8-bit immediate float +#define FU_DSPIMMFL16 0xB00000 // Fixup 16-bit immediate float +#define FU_DSPIMMFL24 0xC00000 // Fixup 24-bit immediate float // Chunks are used to hold generated code and fixup records diff --git a/symbol.c b/symbol.c index 87f90c0..84d5e16 100644 --- a/symbol.c +++ b/symbol.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // SYMBOL.C - Symbol Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/symbol.h b/symbol.h index f985b1b..47ea3cd 100644 --- a/symbol.h +++ b/symbol.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // SYMBOL.H - Symbol Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/token.c b/token.c index 22bc64a..564ff0c 100644 --- a/token.c +++ b/token.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // TOKEN.C - Token Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -560,7 +560,8 @@ DEBUG { printf("ExM: SYMBOL=\"%s\"", d); } // to choke on legitimate code... Need to investigate this further // before changing anything else here! case CONST: - sprintf(numbuf, "$%lx", (uint64_t)*tk++); +// sprintf(numbuf, "$%lx", (uint64_t)*tk++); + sprintf(numbuf, "$%" PRIX64, (uint64_t)*tk++); tk++; d = numbuf; break; diff --git a/token.h b/token.h index 59e6ff5..832301c 100644 --- a/token.h +++ b/token.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // TOKEN.H - Token Handling -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // diff --git a/version.h b/version.h index bd1b4d3..1be65d8 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // VERSION.H - Version Information -// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // -- 2.37.2