fixed bug where a segment warning could cause another segment warning to disappear

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@418 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-09-03 09:49:12 +00:00
parent adb0852767
commit fc98be0ee1
3 changed files with 19 additions and 9 deletions

View File

@ -180,18 +180,17 @@ static void report_binary(char value)
}
//
static void border_crossed(int current_offset)
// complain about reaching another segment
static void breached_limit(int offending_offset)
{
// FIXME - find a way to make this a normal error instead of a serious one,
// so it can be suppressed until we are sure the program won't shrink any
// further:
if (current_offset >= OUTBUF_MAXSIZE)
if (offending_offset >= OUTBUF_MAXSIZE)
throw_serious_error("Reached memory limit.");
throwsegmentproblem("Segment reached another one, overwriting it."); // FIXME - add segment name to msg!
out->segm.limit = segmentlist_findlimit(&out->segm.list_head, current_offset + 1); // find new (next) limit
// FIXME - the line above adds 1 and the fn adds 1 ->
// one address of potential segment start is skipped!
// now that we breached the current limit, find the next one
out->segm.limit = segmentlist_findlimit(&out->segm.list_head, offending_offset);
}
@ -208,7 +207,7 @@ static void real_output(intval_t byte)
// TODO - add additional check for current segment's "limit" value
// did we reach next segment?
if (out->write_idx >= out->segm.limit)
border_crossed(out->write_idx);
breached_limit(out->write_idx);
// new minimum address?
if (out->write_idx < out->lowest_written)
out->lowest_written = out->write_idx;
@ -270,8 +269,16 @@ void output_skip(int size)
// CAUTION - there are two copies of these checks!
// TODO - add additional check for current segment's "limit" value
// did we reach next segment?
// FIXME - this checks whether the final "write that did not really happen"
// is already in another segment. but it does not check any of those before, and
// they could also have breached (small) segments. so either check all "writes"
// or none of them! - atm I prefer "none", because "!skip" does not write...
if (out->write_idx + size - 1 >= out->segm.limit)
border_crossed(out->write_idx + size - 1);
breached_limit(out->write_idx + size - 1);
// FIXME - the checks below do not make sense; why do we treat addresses that
// were skipped as if they have been written to? if a source ends on "!skip 20",
// why should those bytes be included in the file?
// new minimum address?
if (out->write_idx < out->lowest_written)
out->lowest_written = out->write_idx;

View File

@ -23,6 +23,9 @@
#include "typesystem.h"
// TODO - make new, keyword-based argument parser for !bin, !fill and !align
// different ways to handle end-of-statement:
enum eos {
SKIP_REMAINDER, // skip remainder of line - (after errors)

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "20 Aug" // update before release FIXME
#define CHANGE_DATE "21 Aug" // 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