two more test files and a tiny bit of cleanup

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@345 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-02-23 16:46:40 +00:00
parent 2e2eb5e60c
commit 1b33ca7ae7
14 changed files with 45 additions and 35 deletions

View File

@ -18,7 +18,7 @@ acme: $(OBJS)
strip acme
acme.o: config.h platform.h acme.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
acme.o: config.h platform.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
alu.o: config.h platform.h cpu.h dynabuf.h encoding.h global.h input.h section.h symbol.h tree.h alu.h alu.c
@ -36,7 +36,7 @@ global.o: config.h platform.h acme.h cpu.h dynabuf.h encoding.h input.h macro.h
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
macro.o: config.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
mnemo.o: config.h alu.h cpu.h dynabuf.h global.h input.h output.h tree.h mnemo.h mnemo.c
@ -44,7 +44,7 @@ output.o: config.h global.h output.h output.c
platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
pseudoopcodes.o: alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c

View File

@ -18,7 +18,7 @@ acme: $(OBJS)
djp acme.exe
djp acmepmod.exe
acme.o: config.h platform.h acme.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
acme.o: config.h platform.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
alu.o: config.h platform.h cpu.h dynabuf.h encoding.h global.h input.h section.h symbol.h tree.h alu.h alu.c
@ -36,7 +36,7 @@ global.o: config.h platform.h acme.h cpu.h dynabuf.h encoding.h input.h macro.h
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
macro.o: config.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
mnemo.o: config.h alu.h cpu.h dynabuf.h global.h input.h output.h tree.h mnemo.h mnemo.c
@ -44,7 +44,7 @@ output.o: config.h global.h output.h output.c
platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
pseudoopcodes.o: alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c

View File

@ -21,7 +21,7 @@ acme.exe: acme.o alu.o cliargs.o cpu.o dynabuf.o encoding.o flow.o global.o inpu
acme.o: config.h platform.h acme.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h _dos.h acme.c
acme.o: config.h platform.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h _dos.h acme.c
alu.o: config.h platform.h cpu.h dynabuf.h encoding.h global.h input.h section.h symbol.h tree.h alu.h alu.c
@ -39,7 +39,7 @@ global.o: config.h platform.h acme.h cpu.h dynabuf.h encoding.h input.h macro.h
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
macro.o: config.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
mnemo.o: config.h alu.h cpu.h dynabuf.h global.h input.h output.h tree.h mnemo.h mnemo.c
@ -47,7 +47,7 @@ output.o: config.h global.h output.h output.c
platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
pseudoopcodes.o: alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c

View File

@ -17,7 +17,7 @@ acme: $(OBJS)
$(CC) $(LINKFLAGS) -o acme $(OBJS) $(LIBS)
Squeeze -f -v acme ^.^.output.!ACME.!RunImage
acme.o: config.h platform.h acme.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
acme.o: config.h platform.h alu.h cpu.h dynabuf.h encoding.h flow.h global.h input.h macro.h mnemo.h output.h pseudoopcodes.h section.h symbol.h version.h acme.h acme.c
alu.o: config.h platform.h cpu.h dynabuf.h encoding.h global.h input.h section.h symbol.h tree.h alu.h alu.c
@ -35,7 +35,7 @@ global.o: config.h platform.h acme.h cpu.h dynabuf.h encoding.h input.h macro.h
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
macro.o: config.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
mnemo.o: config.h alu.h cpu.h dynabuf.h global.h input.h output.h tree.h mnemo.h mnemo.c
@ -43,7 +43,7 @@ output.o: config.h global.h output.h output.c
platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
pseudoopcodes.o: alu.h flow.h global.h input.h macro.h output.h symbol.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c

View File

@ -80,9 +80,6 @@ static const char arg_vicelabels[] = "VICE labels filename";
// variables
static const char **toplevel_sources;
static int toplevel_src_count = 0;
// maximum recursion depth for macro calls and "!source"
signed long macro_recursions_left = MAX_NESTING;
signed long source_recursions_left = MAX_NESTING;
// show release and platform info (and exit, if wanted)
@ -364,6 +361,9 @@ static boolean do_actual_work(void)
if (config.process_verbosity > 1)
puts("Further pass.");
perform_pass();
if (--sanity.passes_left < 0) {
// FIXME - exit with error
}
}
// any errors left?
if (pass.undefined_count == 0) { // FIXME - use pass.needvalue_count instead!
@ -599,9 +599,7 @@ static const char *long_option(const char *string)
else if (strcmp(string, OPTION_MAXERRORS) == 0)
config.max_errors = string_to_number(cliargs_safe_get_next("maximum error count"));
else if (strcmp(string, OPTION_MAXDEPTH) == 0)
macro_recursions_left = (source_recursions_left = string_to_number(cliargs_safe_get_next("recursion depth")));
// else if (strcmp(string, "strictsyntax") == 0)
// strict_syntax = TRUE;
config.sanity_limit = string_to_number(cliargs_safe_get_next("recursion depth"));
else if (strcmp(string, OPTION_USE_STDOUT) == 0)
config.msg_stream = stdout;
else if (strcmp(string, OPTION_MSVC) == 0)
@ -738,6 +736,10 @@ int main(int argc, const char *argv[])
exit(EXIT_FAILURE);
}
sanity.macro_recursions_left = config.sanity_limit;
sanity.source_recursions_left = config.sanity_limit;
sanity.passes_left = config.sanity_limit;
// init output buffer
output_createbuffer();
// do the actual work

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
// Copyright (C) 1998-2016 Marco Baye
// Copyright (C) 1998-2024 Marco Baye
// Have a look at "acme.c" for further info
//
// Main definitions
@ -7,12 +7,7 @@
#define acme_H
#include "config.h"
// maximum recursion depth for macro calls and "!source"
extern signed long macro_recursions_left;
extern signed long source_recursions_left;
//#include "config.h"
// Prototypes

View File

@ -69,9 +69,9 @@ struct listitem {
// debugging flag, should be undefined in release version
// #define FDEBUG
// maximum nesting depth of "!src" and macro calls
// maximum nesting depth of "!src" and macro calls, also max number of passes
// is not actually a limitation, but a means of finding recursions
#define MAX_NESTING 64
#define SANITY_LIMIT 64
// default value for "!fill"
#define FILLVALUE_FILL 0

View File

@ -103,6 +103,7 @@ char GotByte; // Last byte read (processed)
struct report *report = NULL;
struct config config;
struct pass pass;
struct sanity sanity;
// set configuration to default values
void config_default(struct config *conf)
@ -113,6 +114,7 @@ void config_default(struct config *conf)
conf->warn_on_type_mismatch = FALSE; // use type-checking system
conf->warn_bin_mask = 3; // %11 -> warn if not divisible by four
conf->max_errors = MAXERRORS; // errors before giving up
conf->sanity_limit = SANITY_LIMIT; // changed by --maxdepth
conf->format_msvc = FALSE; // enabled by --msvc
conf->format_color = FALSE; // enabled by --color
conf->msg_stream = stderr; // set to stdout by --use-stdout

View File

@ -81,7 +81,8 @@ struct config {
boolean warn_on_indented_labels; // warn if indented label is encountered
boolean warn_on_type_mismatch; // use type-checking system
int warn_bin_mask; // bitmask for digit counter of binary literals
signed long max_errors; // errors before giving up
int max_errors; // errors before giving up
int sanity_limit; // max recursion depth for "!src" and macro calls, also max number of passes
boolean format_msvc; // enabled by --msvc
boolean format_color; // enabled by --color
FILE *msg_stream; // defaults to stderr, changed to stdout by --use-stdout
@ -118,6 +119,13 @@ struct pass {
extern struct pass pass;
#define FIRST_PASS (pass.number == 0)
struct sanity {
int macro_recursions_left; // for macro calls
int source_recursions_left; // for "!src"
int passes_left;
};
extern struct sanity sanity;
// report stuff
#define REPORT_ASCBUFSIZE 1024
#define REPORT_BINBUFSIZE 9 // eight are shown, then "..."

View File

@ -7,7 +7,6 @@
#include <string.h> // needs strlen() + memcpy()
#include "config.h"
#include "platform.h"
#include "acme.h"
#include "alu.h"
#include "dynabuf.h"
#include "global.h"
@ -230,7 +229,7 @@ void macro_parse_call(void) // Now GotByte = first char of macro name
// Enter deeper nesting level
// Quit program if recursion too deep.
if (--macro_recursions_left < 0)
if (--sanity.macro_recursions_left < 0)
Throw_serious_error("Too deeply nested. Recursive macro calls?");
macro_scope = get_scope_and_title();
// now GotByte = first non-space after title
@ -348,5 +347,5 @@ void macro_parse_call(void) // Now GotByte = first char of macro name
input_ensure_EOS();
}
++macro_recursions_left; // leave this nesting level
++sanity.macro_recursions_left; // leave this nesting level
}

View File

@ -7,7 +7,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h> // for memcpy()
#include "acme.h"
#include "config.h"
#include "cpu.h"
#include "alu.h"
@ -920,7 +919,7 @@ static enum eos po_source(void) // now GotByte = illegal char
// enter new nesting level
// quit program if recursion too deep
if (--source_recursions_left < 0)
if (--sanity.source_recursions_left < 0)
Throw_serious_error("Too deeply nested. Recursive \"!source\"?");
// read file name. quit function on error
if (input_read_input_filename(&uses_lib))
@ -948,7 +947,7 @@ static enum eos po_source(void) // now GotByte = illegal char
#endif
}
// leave nesting level
++source_recursions_left;
++sanity.source_recursions_left;
return ENSURE_EOS;
}

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "17 Feb" // update before release FIXME
#define CHANGE_DATE "18 Feb" // update before release FIXME
#define CHANGE_YEAR "2024" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME

View File

@ -0,0 +1,4 @@
!macro recursive @dummy {
+recursive @dummy
}
+recursive 42 ; -> "Too deeply nested. Recursive macro calls?"

View File

@ -0,0 +1 @@
!src "recursive-src.a" ; -> "Too deeply nested. Recursive "!source"?"