renamed struct component, no change in functionality

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@397 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-08-16 21:19:02 +00:00
parent 3b2321c053
commit 3c390cbde7

View File

@ -38,7 +38,7 @@ struct output {
intval_t max; // highest address segment may use intval_t max; // highest address segment may use
bits flags; // segment flags ("overlay" and "invisible", see header file) bits flags; // segment flags ("overlay" and "invisible", see header file)
struct segment list_head; // head element of doubly-linked ring list struct segment list_head; // head element of doubly-linked ring list
} segment; // FIXME - rename either this component or "struct segment"! } segm;
char xor; // output modifier char xor; // output modifier
}; };
@ -74,19 +74,19 @@ static void report_binary(char value)
// just find the next segment start and subtract 1. // just find the next segment start and subtract 1.
static void find_segment_max(intval_t new_pc) static void find_segment_max(intval_t new_pc)
{ {
struct segment *test_segment = out->segment.list_head.next; struct segment *test_segment = out->segm.list_head.next;
// search for smallest segment start address that // search for smallest segment start address that
// is larger than given address // is larger than given address
// use list head as sentinel // use list head as sentinel
// FIXME - if +1 overflows intval_t, we have an infinite loop! // FIXME - if +1 overflows intval_t, we have an infinite loop!
out->segment.list_head.start = new_pc + 1; out->segm.list_head.start = new_pc + 1;
while (test_segment->start <= new_pc) while (test_segment->start <= new_pc)
test_segment = test_segment->next; test_segment = test_segment->next;
if (test_segment == &out->segment.list_head) if (test_segment == &out->segm.list_head)
out->segment.max = config.outbuf_size - 1; out->segm.max = config.outbuf_size - 1;
else else
out->segment.max = test_segment->start - 1; // last free address available out->segm.max = test_segment->start - 1; // last free address available
} }
@ -115,7 +115,7 @@ static void real_output(intval_t byte)
// CAUTION - there are two copies of these checks! // CAUTION - there are two copies of these checks!
// TODO - add additional check for current segment's "limit" value // TODO - add additional check for current segment's "limit" value
// did we reach next segment? // did we reach next segment?
if (out->write_idx > out->segment.max) if (out->write_idx > out->segm.max)
border_crossed(out->write_idx); border_crossed(out->write_idx);
// new minimum address? // new minimum address?
if (out->write_idx < out->lowest_written) if (out->write_idx < out->lowest_written)
@ -162,7 +162,7 @@ void output_skip(int size)
// CAUTION - there are two copies of these checks! // CAUTION - there are two copies of these checks!
// TODO - add additional check for current segment's "limit" value // TODO - add additional check for current segment's "limit" value
// did we reach next segment? // did we reach next segment?
if (out->write_idx + size - 1 > out->segment.max) if (out->write_idx + size - 1 > out->segm.max)
border_crossed(out->write_idx + size - 1); border_crossed(out->write_idx + size - 1);
// new minimum address? // new minimum address?
if (out->write_idx < out->lowest_written) if (out->write_idx < out->lowest_written)
@ -238,8 +238,8 @@ void output_createbuffer(void)
fill_completely(config.mem_init_value & 0xff); fill_completely(config.mem_init_value & 0xff);
} }
// init ring list of segments // init ring list of segments
out->segment.list_head.next = &out->segment.list_head; out->segm.list_head.next = &out->segm.list_head;
out->segment.list_head.prev = &out->segment.list_head; out->segm.list_head.prev = &out->segm.list_head;
} }
@ -247,15 +247,15 @@ void output_createbuffer(void)
static void link_segment(intval_t start, intval_t length) static void link_segment(intval_t start, intval_t length)
{ {
struct segment *new_segment, struct segment *new_segment,
*test_segment = out->segment.list_head.next; *test_segment = out->segm.list_head.next;
// init new segment // init new segment
new_segment = safe_malloc(sizeof(*new_segment)); new_segment = safe_malloc(sizeof(*new_segment));
new_segment->start = start; new_segment->start = start;
new_segment->length = length; new_segment->length = length;
// use ring head as sentinel // use ring head as sentinel
out->segment.list_head.start = start; out->segm.list_head.start = start;
out->segment.list_head.length = length + 1; // +1 to make sure sentinel exits loop out->segm.list_head.length = length + 1; // +1 to make sure sentinel exits loop
// walk ring to find correct spot // walk ring to find correct spot
while ((test_segment->start < new_segment->start) while ((test_segment->start < new_segment->start)
|| ((test_segment->start == new_segment->start) && (test_segment->length < new_segment->length))) || ((test_segment->start == new_segment->start) && (test_segment->length < new_segment->length)))
@ -273,11 +273,11 @@ static void link_segment(intval_t start, intval_t length)
// FIXME - do it the other way round and only complain if there were no other errors! // FIXME - do it the other way round and only complain if there were no other errors!
static void check_segment(intval_t new_pc) static void check_segment(intval_t new_pc)
{ {
struct segment *test_segment = out->segment.list_head.next; struct segment *test_segment = out->segm.list_head.next;
// use list head as sentinel // use list head as sentinel
out->segment.list_head.start = new_pc + 1; // +1 to make sure sentinel exits loop out->segm.list_head.start = new_pc + 1; // +1 to make sure sentinel exits loop
out->segment.list_head.length = 1; out->segm.list_head.length = 1;
// search ring for matching entry // search ring for matching entry
while (test_segment->start <= new_pc) { while (test_segment->start <= new_pc) {
if ((test_segment->start + test_segment->length) > new_pc) { if ((test_segment->start + test_segment->length) > new_pc) {
@ -311,9 +311,9 @@ void output_passinit(void)
// deactivate output - any byte written will trigger error: // deactivate output - any byte written will trigger error:
output_byte = no_output; output_byte = no_output;
out->write_idx = 0; // same as pc on pass init! out->write_idx = 0; // same as pc on pass init!
out->segment.start = NO_SEGMENT_START; // TODO - "no active segment" could be made a segment flag! out->segm.start = NO_SEGMENT_START; // TODO - "no active segment" could be made a segment flag!
out->segment.max = config.outbuf_size - 1; // TODO - use end of bank? out->segm.max = config.outbuf_size - 1; // TODO - use end of bank?
out->segment.flags = 0; out->segm.flags = 0;
out->xor = 0; out->xor = 0;
//vcpu stuff: //vcpu stuff:
@ -350,26 +350,26 @@ static void end_segment(void)
return; return;
// if there is no segment, there is nothing to do // if there is no segment, there is nothing to do
if (out->segment.start == NO_SEGMENT_START) if (out->segm.start == NO_SEGMENT_START)
return; return;
// ignore "invisible" segments // ignore "invisible" segments
if (out->segment.flags & SEGMENT_FLAG_INVISIBLE) if (out->segm.flags & SEGMENT_FLAG_INVISIBLE)
return; return;
// ignore empty segments // ignore empty segments
amount = out->write_idx - out->segment.start; amount = out->write_idx - out->segm.start;
if (amount == 0) if (amount == 0)
return; return;
// link to segment list // link to segment list
link_segment(out->segment.start, amount); link_segment(out->segm.start, amount);
// announce // announce
if (config.process_verbosity >= 2) if (config.process_verbosity >= 2)
// TODO - change output to start, limit, size, name: // TODO - change output to start, limit, size, name:
// TODO - output hex numbers as %04x? What about limit 0x10000? // TODO - output hex numbers as %04x? What about limit 0x10000?
printf("Segment size is %d (0x%x) bytes (0x%x - 0x%x exclusive).\n", printf("Segment size is %d (0x%x) bytes (0x%x - 0x%x exclusive).\n",
amount, amount, out->segment.start, out->write_idx); amount, amount, out->segm.start, out->write_idx);
} }
@ -390,15 +390,15 @@ static void start_segment(intval_t address_change, bits segment_flags)
// calculate start of new segment // calculate start of new segment
out->write_idx = (out->write_idx + address_change) & (config.outbuf_size - 1); out->write_idx = (out->write_idx + address_change) & (config.outbuf_size - 1);
out->segment.start = out->write_idx; out->segm.start = out->write_idx;
out->segment.flags = segment_flags; out->segm.flags = segment_flags;
// allow writing to output buffer // allow writing to output buffer
output_byte = real_output; output_byte = real_output;
// in first/last pass, check for other segments and maybe issue warning // in first/last pass, check for other segments and maybe issue warning
if (pass.flags.do_segment_checks) { if (pass.flags.do_segment_checks) {
if (!(segment_flags & SEGMENT_FLAG_OVERLAY)) if (!(segment_flags & SEGMENT_FLAG_OVERLAY))
check_segment(out->segment.start); check_segment(out->segm.start);
find_segment_max(out->segment.start); find_segment_max(out->segm.start);
} }
} }