mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-22 18:32:09 +00:00
cleanup concerning pc assignments
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@142 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
7d4200faa4
commit
38952534f4
17
src/global.c
17
src/global.c
@ -147,21 +147,6 @@ void *safe_malloc(size_t size)
|
||||
|
||||
// Parser stuff
|
||||
|
||||
// Parse (re-)definitions of program counter
|
||||
static void parse_pc_def(void) // Now GotByte = "*"
|
||||
{
|
||||
NEXTANDSKIPSPACE(); // proceed with next char
|
||||
// re-definitions of program counter change segment
|
||||
if (GotByte == '=') {
|
||||
GetByte(); // proceed with next char
|
||||
notreallypo_setpc();
|
||||
Input_ensure_EOS();
|
||||
} else {
|
||||
Throw_error(exception_syntax);
|
||||
Input_skip_remainder();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check and return whether first label of statement. Complain if not.
|
||||
static int first_label_of_statement(int *statement_flags)
|
||||
@ -284,7 +269,7 @@ void Parse_until_eob_or_eof(void)
|
||||
parse_forward_anon_def(&statement_flags);
|
||||
break;
|
||||
case '*':
|
||||
parse_pc_def();
|
||||
notreallypo_setpc(); // define program counter (fn is in pseudoopcodes.c)
|
||||
break;
|
||||
case LOCAL_PREFIX:
|
||||
parse_local_symbol_def(&statement_flags, section_now->local_scope);
|
||||
|
@ -43,20 +43,27 @@ static const char exception_unknown_pseudo_opcode[] = "Unknown pseudo opcode.";
|
||||
static struct ronode *pseudo_opcode_tree = NULL; // tree to hold pseudo opcodes
|
||||
|
||||
|
||||
// not really a pseudo opcode, but close enough to be put here:
|
||||
// called when "* = EXPRESSION" is parsed
|
||||
// setting program counter via "* = VALUE"
|
||||
void notreallypo_setpc(void)
|
||||
// this is not really a pseudo opcode, but similar enough to be put here:
|
||||
// called when "* = EXPRESSION" is parsed, to set the program counter
|
||||
void notreallypo_setpc(void) // GotByte is '*'
|
||||
{
|
||||
int segment_flags = 0;
|
||||
struct number intresult;
|
||||
|
||||
// next non-space must be '='
|
||||
NEXTANDSKIPSPACE();
|
||||
if (GotByte != '=') {
|
||||
Throw_error(exception_syntax);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
GetByte();
|
||||
ALU_defined_int(&intresult); // read new address
|
||||
// check for modifiers
|
||||
while (Input_accept_comma()) {
|
||||
// parse modifier. if no keyword given, give up
|
||||
if (Input_read_and_lower_keyword() == 0)
|
||||
return;
|
||||
goto fail;
|
||||
|
||||
if (strcmp(GlobalDynaBuf->buffer, "overlay") == 0) {
|
||||
segment_flags |= SEGMENT_FLAG_OVERLAY;
|
||||
@ -70,11 +77,16 @@ void notreallypo_setpc(void)
|
||||
read segment name (quoted string!) */
|
||||
} else {
|
||||
Throw_error("Unknown \"* =\" segment modifier.");
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
vcpu_set_pc(intresult.val.intval, segment_flags);
|
||||
// TODO - allow block syntax, so it is possible to put data "somewhere else" and then return to old position
|
||||
Input_ensure_EOS();
|
||||
return;
|
||||
|
||||
fail:
|
||||
Input_skip_remainder();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user