minor fix for output of segment list. no other change in functionality, only

internal cleanup (added some comments and TODOs)


git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@122 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-04-25 10:20:52 +00:00
parent 2ad798bef2
commit c6f443d581
8 changed files with 40 additions and 20 deletions

View File

@ -263,10 +263,13 @@ static int perform_pass(void)
++pass_real_errors;
}
}
Output_end_segment();
/* TODO:
if --save-start is given, parse arg string
if --save-limit is given, parse arg string
*/
if (pass_real_errors)
exit(ACME_finalize(EXIT_FAILURE));
else
Output_end_segment();
return pass_undefined_count;
}

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
// Copyright (C) 1998-2019 Marco Baye
// Copyright (C) 1998-2020 Marco Baye
// Have a look at "acme.c" for further info
//
// Arithmetic/logic unit
@ -391,7 +391,7 @@ static void parse_quoted_character(char closing_quote)
alu_state = STATE_ERROR;
}
}
PUSH_INTOPERAND(value, MVALUE_GIVEN | MVALUE_ISBYTE, 0);
PUSH_INTOPERAND(value, MVALUE_DEFINED | MVALUE_EXISTS | MVALUE_ISBYTE, 0);
// Now GotByte = char following closing quote (or CHAR_EOS on error)
}
@ -403,7 +403,7 @@ static void parse_binary_value(void) // Now GotByte = "%" or "b"
{
intval_t value = 0;
int go_on = TRUE, // continue loop flag
flags = MVALUE_GIVEN,
flags = MVALUE_DEFINED | MVALUE_EXISTS,
digits = -1; // digit counter
do {
@ -447,7 +447,7 @@ static void parse_hexadecimal_value(void) // Now GotByte = "$" or "x"
char byte;
int go_on, // continue loop flag
digits = -1, // digit counter
flags = MVALUE_GIVEN;
flags = MVALUE_DEFINED | MVALUE_EXISTS;
intval_t value = 0;
do {
@ -497,7 +497,7 @@ static void parse_frac_part(int integer_part) // Now GotByte = first digit after
GetByte();
}
// FIXME - add possibility to read 'e' and exponent!
PUSH_FPOPERAND(fpval / denominator, MVALUE_GIVEN);
PUSH_FPOPERAND(fpval / denominator, MVALUE_DEFINED | MVALUE_EXISTS);
}
@ -542,7 +542,7 @@ static void parse_decimal_value(void) // Now GotByte = first digit
GetByte();
parse_frac_part(intval);
} else {
PUSH_INTOPERAND(intval, MVALUE_GIVEN, 0);
PUSH_INTOPERAND(intval, MVALUE_DEFINED | MVALUE_EXISTS, 0);
}
// Now GotByte = non-decimal char
}
@ -553,7 +553,7 @@ static void parse_decimal_value(void) // Now GotByte = first digit
static void parse_octal_value(void) // Now GotByte = "&"
{
intval_t value = 0;
int flags = MVALUE_GIVEN,
int flags = MVALUE_DEFINED | MVALUE_EXISTS,
digits = 0; // digit counter
GetByte();
@ -1527,8 +1527,10 @@ int ALU_optional_defined_int(intval_t *target) // ACCEPT_EMPTY
if (parse_expression(&result))
Throw_error(exception_paren_open);
if ((result.flags & MVALUE_GIVEN) == MVALUE_EXISTS)
Throw_serious_error(value_not_defined());
// do not combine the next two checks, they were separated because EXISTS should move from result flags to expression flags...
if (result.flags & MVALUE_EXISTS)
if ((result.flags & MVALUE_DEFINED) == 0)
Throw_serious_error(value_not_defined());
if ((result.flags & MVALUE_EXISTS) == 0)
return 0;

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-2020 Marco Baye
// Have a look at "acme.c" for further info
//
// ALU stuff (the expression parser)
@ -12,10 +12,11 @@
// constants
// meaning of bits in "flags" of struct result: TODO - this is only for future "number" result type!
#define MVALUE_IS_FP (1u << 8) // floating point value
// meaning of bits in "flags" of struct result:
// TODO - this is only for future "number" result type, so move EXISTS and INDIRECT somewhere else (expression flags? make "nothing" its own result type!)
#define MVALUE_EXISTS (1u << 8) // 0: expression was empty. 1: there was *something* to parse.
#define MVALUE_INDIRECT (1u << 7) // needless parentheses indicate use of indirect addressing modes
#define MVALUE_EXISTS (1u << 6) // 0: expression was empty. 1: there was *something* to parse. TODO - get rid of this, make "nothing" its own result type instead!
#define MVALUE_IS_FP (1u << 6) // floating point value
#define MVALUE_UNSURE (1u << 5) // value once was related to undefined
// expression. Needed for producing the same addresses in all passes; because in
// the first pass there will almost for sure be labels that are undefined, you
@ -26,7 +27,7 @@
#define MVALUE_FORCE16 (1u << 1) // value usage forces 16-bit usage
#define MVALUE_FORCE08 (1u << 0) // value usage forces 8-bit usage
#define MVALUE_FORCEBITS (MVALUE_FORCE08|MVALUE_FORCE16|MVALUE_FORCE24)
#define MVALUE_GIVEN (MVALUE_DEFINED | MVALUE_EXISTS) // bit mask for fixed values (defined and existing)
//#define MVALUE_GIVEN (MVALUE_DEFINED | MVALUE_EXISTS) // bit mask for fixed values (defined and existing) TODO: remove this
// create dynamic buffer, operator/function trees and operator/operand stacks

View File

@ -55,7 +55,7 @@ void flow_forloop(struct for_loop *loop)
// (not yet useable; pointer and line number are still missing)
Input_now = &loop_input;
// init counter
loop_counter.flags = MVALUE_DEFINED | MVALUE_EXISTS;
loop_counter.flags = MVALUE_DEFINED | MVALUE_EXISTS; // TODO - remove EXISTS, it is never checked
loop_counter.val.intval = loop->counter.first;
loop_counter.addr_refs = loop->counter.addr_refs;
symbol_set_value(loop->symbol, &loop_counter, TRUE);

View File

@ -452,6 +452,7 @@ static void check_segment(intval_t new_pc)
// search ring for matching entry
while (test_segment->start <= new_pc) {
if ((test_segment->start + test_segment->length) > new_pc) {
// TODO - include overlap size in error message!
if (config.segment_warning_is_error)
Throw_error("Segment starts inside another one, overwriting it.");
else
@ -525,6 +526,8 @@ void Output_end_segment(void)
link_segment(out->segment.start, amount);
// announce
if (config.process_verbosity > 1)
// TODO - change output to start, limit, size, name:
// TODO - output hex numbers as %04x? What about limit 0x10000?
printf("Segment size is %ld (0x%lx) bytes (0x%lx - 0x%lx exclusive).\n",
amount, amount, out->segment.start, out->write_idx);
}

View File

@ -61,6 +61,12 @@ void notreallypo_setpc(void)
segment_flags |= SEGMENT_FLAG_OVERLAY;
} else if (strcmp(GlobalDynaBuf->buffer, "invisible") == 0) {
segment_flags |= SEGMENT_FLAG_INVISIBLE;
/*TODO } else if (strcmp(GlobalDynaBuf->buffer, "limit") == 0) {
skip '='
read memory limit
} else if (strcmp(GlobalDynaBuf->buffer, "name") == 0) {
skip '='
read segment name */
} else {
Throw_error("Unknown \"* =\" segment modifier.");
return;
@ -517,6 +523,10 @@ static enum eos po_align(void)
return SKIP_REMAINDER;
}
// TODO:
// now: !align ANDVALUE, EQUALVALUE [,FILLVALUE]
// new: !align BLOCKSIZE
// ...where block size must be a power of two
ALU_defined_int(&andresult); // FIXME - forbid addresses!
if (!Input_accept_comma())
Throw_error(exception_syntax);
@ -548,6 +558,7 @@ static enum eos po_pseudopc(void)
new_offset = (new_pc_result.val.intval - CPU_state.pc.val.intval) & 0xffff;
CPU_state.pc.val.intval = new_pc_result.val.intval;
CPU_state.pc.flags |= MVALUE_DEFINED; // FIXME - remove when allowing undefined!
// TODO - accept ", name=SECTIONNAME"
// if there's a block, parse that and then restore old value!
if (Parse_optional_block()) {
// restore old

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
// Copyright (C) 1998-2017 Marco Baye
// Copyright (C) 1998-2020 Marco Baye
// Have a look at "acme.c" for further info
//
// symbol stuff
@ -222,7 +222,7 @@ void symbol_define(intval_t value)
struct result result;
struct symbol *symbol;
result.flags = MVALUE_GIVEN;
result.flags = MVALUE_DEFINED | MVALUE_EXISTS; // TODO - remove EXISTS, it is never checked
result.val.intval = value;
symbol = symbol_find(SCOPE_GLOBAL, 0);
symbol_set_value(symbol, &result, TRUE);

View File

@ -9,7 +9,7 @@
#define RELEASE "0.96.5" // update before release FIXME
#define CODENAME "Fenchurch" // update before release
#define CHANGE_DATE "14 Apr" // update before release FIXME
#define CHANGE_DATE "25 Apr" // update before release FIXME
#define CHANGE_YEAR "2020" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME