mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-12-24 16:29:23 +00:00
internal cleanup, no change in functionality
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@127 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
c4a88fa738
commit
0a4c13bb2e
43
src/alu.c
43
src/alu.c
@ -398,25 +398,23 @@ static void parse_quoted_character(char closing_quote)
|
||||
static void parse_binary_value(void) // Now GotByte = "%" or "b"
|
||||
{
|
||||
intval_t value = 0;
|
||||
int go_on = TRUE, // continue loop flag
|
||||
flags = MVALUE_DEFINED,
|
||||
int flags = MVALUE_DEFINED,
|
||||
digits = -1; // digit counter
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
++digits;
|
||||
switch (GetByte()) {
|
||||
case '0':
|
||||
case '.':
|
||||
value <<= 1;
|
||||
break;
|
||||
continue;
|
||||
case '1':
|
||||
case '#':
|
||||
value = (value << 1) | 1;
|
||||
break;
|
||||
default:
|
||||
go_on = 0;
|
||||
continue;
|
||||
}
|
||||
} while (go_on);
|
||||
break; // found illegal character
|
||||
}
|
||||
// set force bits
|
||||
if (config.honor_leading_zeroes) {
|
||||
if (digits > 8) {
|
||||
@ -435,34 +433,33 @@ static void parse_binary_value(void) // Now GotByte = "%" or "b"
|
||||
|
||||
|
||||
// Parse hexadecimal value. It accepts "0" to "9", "a" to "f" and "A" to "F".
|
||||
// Capital letters will be converted to lowercase letters using the flagtable.
|
||||
// The current value is stored as soon as a character is read that is none of
|
||||
// those given above.
|
||||
static void parse_hexadecimal_value(void) // Now GotByte = "$" or "x"
|
||||
{
|
||||
char byte;
|
||||
int go_on, // continue loop flag
|
||||
digits = -1, // digit counter
|
||||
int digits = -1, // digit counter
|
||||
flags = MVALUE_DEFINED;
|
||||
intval_t value = 0;
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
++digits;
|
||||
go_on = 0;
|
||||
byte = GetByte();
|
||||
// first, convert "A-F" to "a-f"
|
||||
byte |= (BYTEFLAGS(byte) & BYTEIS_UPCASE);
|
||||
// if digit, add digit value
|
||||
// if digit or legal character, add value
|
||||
if ((byte >= '0') && (byte <= '9')) {
|
||||
value = (value << 4) + (byte - '0');
|
||||
go_on = 1; // keep going
|
||||
continue;
|
||||
}
|
||||
// if legal ("a-f") character, add character value
|
||||
if ((byte >= 'a') && (byte <= 'f')) {
|
||||
value = (value << 4) + (byte - 'a') + 10;
|
||||
go_on = 1; // keep going
|
||||
continue;
|
||||
}
|
||||
} while (go_on);
|
||||
if ((byte >= 'A') && (byte <= 'F')) {
|
||||
value = (value << 4) + (byte - 'A') + 10;
|
||||
continue;
|
||||
}
|
||||
break; // found illegal character
|
||||
}
|
||||
// set force bits
|
||||
if (config.honor_leading_zeroes) {
|
||||
if (digits > 2) {
|
||||
@ -636,7 +633,7 @@ static int expect_operand_or_monadic_operator(void)
|
||||
perform_negation = !perform_negation;
|
||||
} while (GetByte() == '-');
|
||||
SKIPSPACE();
|
||||
if (BYTEFLAGS(GotByte) & FOLLOWS_ANON) {
|
||||
if (BYTE_FOLLOWS_ANON(GotByte)) {
|
||||
DynaBuf_append(GlobalDynaBuf, '\0');
|
||||
get_symbol_value(section_now->local_scope, 0, GlobalDynaBuf->size - 1); // -1 to not count terminator
|
||||
goto now_expect_dyadic;
|
||||
@ -738,7 +735,7 @@ static int expect_operand_or_monadic_operator(void)
|
||||
goto now_expect_dyadic;
|
||||
}
|
||||
|
||||
if (BYTEFLAGS(GotByte) & STARTS_KEYWORD) {
|
||||
if (BYTE_STARTS_KEYWORD(GotByte)) {
|
||||
register int length;
|
||||
|
||||
// Read global label (or "NOT")
|
||||
@ -917,7 +914,7 @@ static void expect_dyadic_operator(void)
|
||||
// end of expression or text version of dyadic operator
|
||||
default:
|
||||
// check string versions of operators
|
||||
if (BYTEFLAGS(GotByte) & STARTS_KEYWORD) {
|
||||
if (BYTE_STARTS_KEYWORD(GotByte)) {
|
||||
Input_read_and_lower_keyword();
|
||||
// Now GotByte = illegal char
|
||||
// search for tree item
|
||||
|
@ -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
|
||||
//
|
||||
// Dynamic buffer stuff
|
||||
@ -123,6 +123,7 @@ void DynaBuf_to_lower(struct dynabuf *target, struct dynabuf *source)
|
||||
// But actually it doesn't matter, because only pre-defined
|
||||
// keywords are converted, and all of those are plain
|
||||
// old-fashioned 7-bit ASCII anyway. So I guess it'll do.
|
||||
// FIXME - use BYTE_ macro from global.h
|
||||
*write = '\0'; // terminate
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ const char exception_syntax[] = "Syntax error.";
|
||||
// ....3... preceding sequence of '-' characters is anonymous backward
|
||||
// label. Currently only set for ')', ',' and CHAR_EOS.
|
||||
// .....210 currently unused
|
||||
const char Byte_flags[256] = {
|
||||
const char global_byte_flags[256] = {
|
||||
/*$00*/ 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// control characters
|
||||
0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@ -281,7 +281,7 @@ void Parse_until_eob_or_eof(void)
|
||||
case '+':
|
||||
GetByte();
|
||||
if ((GotByte == LOCAL_PREFIX) // TODO - allow "cheap macros"?!
|
||||
|| (BYTEFLAGS(GotByte) & CONTS_KEYWORD))
|
||||
|| (BYTE_CONTINUES_KEYWORD(GotByte)))
|
||||
Macro_parse_call();
|
||||
else
|
||||
parse_forward_anon_def(&statement_flags);
|
||||
@ -296,7 +296,7 @@ void Parse_until_eob_or_eof(void)
|
||||
parse_local_symbol_def(&statement_flags, section_now->cheap_scope);
|
||||
break;
|
||||
default:
|
||||
if (BYTEFLAGS(GotByte) & STARTS_KEYWORD) {
|
||||
if (BYTE_STARTS_KEYWORD(GotByte)) {
|
||||
parse_mnemo_or_global_symbol_def(&statement_flags);
|
||||
} else {
|
||||
Throw_error(exception_syntax);
|
||||
|
14
src/global.h
14
src/global.h
@ -50,14 +50,12 @@ extern const char exception_number_out_of_range[];
|
||||
extern const char exception_pc_undefined[];
|
||||
extern const char exception_syntax[];
|
||||
// byte flags table
|
||||
extern const char Byte_flags[];
|
||||
#define BYTEFLAGS(c) (Byte_flags[(unsigned char) c])
|
||||
#define STARTS_KEYWORD (1u << 7) // Byte is allowed to start a keyword
|
||||
#define CONTS_KEYWORD (1u << 6) // Byte is allowed in a keyword
|
||||
#define BYTEIS_UPCASE (1u << 5) // Byte is upper case and can be
|
||||
// converted to lower case by OR-ing this bit(!)
|
||||
#define BYTEIS_SYNTAX (1u << 4) // special character for input syntax
|
||||
#define FOLLOWS_ANON (1u << 3) // preceding '-' are backward label
|
||||
extern const char global_byte_flags[];
|
||||
#define BYTE_STARTS_KEYWORD(b) (global_byte_flags[(unsigned char) b] & (1u << 7)) // byte is allowed at start of keyword (a-z, A-Z, _, everything>127)
|
||||
#define BYTE_CONTINUES_KEYWORD(b) (global_byte_flags[(unsigned char) b] & (1u << 6)) // byte is allowed in a keyword (as above, plus digits)
|
||||
//#define BYTE_TO_LOWER_CASE(b) bit 5 means: "byte is upper case, and can be converted to lower case by ORing this bit" - but this is not used at the moment!
|
||||
#define BYTE_IS_SYNTAX_CHAR(b) (global_byte_flags[(unsigned char) b] & (1u << 4)) // special character for input syntax
|
||||
#define BYTE_FOLLOWS_ANON(b) (global_byte_flags[(unsigned char) b] & (1u << 3)) // preceding '-' are backward label
|
||||
// bits 2, 1 and 0 are currently unused
|
||||
|
||||
// TODO - put in runtime struct:
|
||||
|
@ -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
|
||||
//
|
||||
// Input stuff
|
||||
@ -135,7 +135,7 @@ static char get_processed_from_file(void)
|
||||
// defined "from_file", trouble may arise...
|
||||
Input_now->state = INPUTSTATE_NORMAL;
|
||||
// EOF must be checked first because it cannot be used
|
||||
// as an index into Byte_flags[]
|
||||
// as an index into global_byte_flags[]
|
||||
if (from_file == EOF) {
|
||||
// remember to send an end-of-file
|
||||
Input_now->state = INPUTSTATE_EOF;
|
||||
@ -144,7 +144,7 @@ static char get_processed_from_file(void)
|
||||
|
||||
// check whether character is special one
|
||||
// if not, everything's cool and froody, so return it
|
||||
if ((BYTEFLAGS(from_file) & BYTEIS_SYNTAX) == 0)
|
||||
if (BYTE_IS_SYNTAX_CHAR(from_file) == 0)
|
||||
return (char) from_file;
|
||||
|
||||
// check special characters ("0x00 TAB LF CR SPC / : ; }")
|
||||
@ -423,7 +423,7 @@ int Input_append_keyword_to_global_dynabuf(void)
|
||||
int length = 0;
|
||||
|
||||
// add characters to buffer until an illegal one comes along
|
||||
while (BYTEFLAGS(GotByte) & CONTS_KEYWORD) {
|
||||
while (BYTE_CONTINUES_KEYWORD(GotByte)) {
|
||||
DYNABUF_APPEND(GlobalDynaBuf, GotByte);
|
||||
++length;
|
||||
GetByte();
|
||||
|
@ -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
|
||||
//
|
||||
// Input stuff
|
||||
@ -46,7 +46,7 @@ extern const char FILE_READBINARY[];
|
||||
#define CHAR_EOB '}' // end of block
|
||||
#define CHAR_SOL (10) // start of line (in high-level format)
|
||||
#define CHAR_EOF (13) // end of file (in high-level format)
|
||||
// If the characters above are changed, don't forget to adjust Byte_flags[]!
|
||||
// if the characters above are changed, don't forget to adjust global_byte_flags[]!
|
||||
|
||||
|
||||
// Variables
|
||||
|
@ -737,7 +737,7 @@ static enum eos po_zone(void)
|
||||
allocated = FALSE;
|
||||
// Check whether a zone title is given. If yes and it can be read,
|
||||
// get copy, remember pointer and remember to free it later on.
|
||||
if (BYTEFLAGS(GotByte) & CONTS_KEYWORD) {
|
||||
if (BYTE_CONTINUES_KEYWORD(GotByte)) {
|
||||
// Because we know of one character for sure,
|
||||
// there's no need to check the return value.
|
||||
Input_read_keyword();
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.96.5" // update before release FIXME
|
||||
#define CODENAME "Fenchurch" // update before release
|
||||
#define CHANGE_DATE "27 Apr" // update before release FIXME
|
||||
#define CHANGE_DATE "28 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
|
||||
|
Loading…
Reference in New Issue
Block a user