mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-01-10 21:30:30 +00:00
tiny refactoring, preparing to get rid of another fn
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@187 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
0173eaf777
commit
486febcef4
24
src/alu.c
24
src/alu.c
@ -2017,13 +2017,13 @@ static int parse_expression(struct expression *expression)
|
||||
}
|
||||
|
||||
|
||||
// return int value (if undefined, return zero)
|
||||
// store int value (if undefined, store zero)
|
||||
// For empty expressions, an error is thrown.
|
||||
// OPEN_PARENTHESIS: complain
|
||||
// EMPTY: complain
|
||||
// UNDEFINED: allow
|
||||
// FLOAT: convert to int
|
||||
intval_t ALU_any_int(void) // ACCEPT_UNDEFINED
|
||||
void ALU_any_int(intval_t *target) // ACCEPT_UNDEFINED
|
||||
{
|
||||
struct expression expression;
|
||||
|
||||
@ -2033,13 +2033,13 @@ intval_t ALU_any_int(void) // ACCEPT_UNDEFINED
|
||||
if (expression.is_empty)
|
||||
Throw_error(exception_no_value);
|
||||
if (expression.result.type == &type_int)
|
||||
return expression.result.u.number.val.intval;
|
||||
|
||||
if (expression.result.type == &type_float)
|
||||
return expression.result.u.number.val.fpval;
|
||||
|
||||
Throw_error("Expression did not return a number."); // TODO - add to docs!
|
||||
return 0; // inhibit compiler warning
|
||||
*target = expression.result.u.number.val.intval;
|
||||
else if (expression.result.type == &type_float)
|
||||
*target = expression.result.u.number.val.fpval;
|
||||
else {
|
||||
*target = 0;
|
||||
Throw_error("Expression did not return a number."); // TODO - add to docs!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2150,7 +2150,7 @@ void ALU_defined_int(struct number *intresult)
|
||||
when parsing loop conditions make bool serious
|
||||
pseudoopcodes.c
|
||||
*= (FIXME, allow undefined) needvalue!
|
||||
!initmem serious
|
||||
!initmem error
|
||||
!fill (1st arg) (maybe allow undefined?) needvalue!
|
||||
!skip (maybe allow undefined?) needvalue!
|
||||
!align (1st + 2nd arg) (maybe allow undefined?) needvalue!
|
||||
@ -2160,8 +2160,8 @@ void ALU_defined_int(struct number *intresult)
|
||||
twice for !binary (maybe allow undefined?) needvalue!
|
||||
//!enum
|
||||
|
||||
// returns int value (0 if result was undefined)
|
||||
intval_t ALU_any_int(void)
|
||||
// store int value (0 if result was undefined)
|
||||
void ALU_any_int(intval_t *target)
|
||||
pseudoopcodes.c
|
||||
!xor needvalue!
|
||||
iterator for !by, !wo, etc. needvalue!
|
||||
|
@ -65,8 +65,8 @@ extern void ALU_init(void);
|
||||
// do I need ACCEPT_NONADDR and/or ACCEPT_ADDRESS?
|
||||
*/
|
||||
|
||||
// returns int value (0 if result was undefined)
|
||||
extern intval_t ALU_any_int(void);
|
||||
// stores int value (0 if result was undefined)
|
||||
extern void ALU_any_int(intval_t *target);
|
||||
// stores int value and flags (floats are transformed to int)
|
||||
// if result was undefined, serious error is thrown
|
||||
extern void ALU_defined_int(struct number *intresult);
|
||||
|
@ -116,7 +116,7 @@ static enum eos po_xor(void)
|
||||
intval_t change;
|
||||
|
||||
old_value = output_get_xor();
|
||||
change = ALU_any_int();
|
||||
ALU_any_int(&change);
|
||||
if ((change > 0xff) || (change < -0x80)) {
|
||||
Throw_error(exception_number_out_of_range);
|
||||
change = 0;
|
||||
@ -176,9 +176,12 @@ static enum eos po_to(void)
|
||||
// helper function for !8, !16, !24 and !32 pseudo opcodes
|
||||
static enum eos iterate(void (*fn)(intval_t))
|
||||
{
|
||||
do
|
||||
fn(ALU_any_int());
|
||||
while (Input_accept_comma());
|
||||
intval_t value;
|
||||
|
||||
do {
|
||||
ALU_any_int(&value);
|
||||
fn(value);
|
||||
} while (Input_accept_comma());
|
||||
return ENSURE_EOS;
|
||||
}
|
||||
|
||||
@ -368,6 +371,7 @@ static enum eos encode_string(const struct encoder *inner_encoder, char xor)
|
||||
{
|
||||
const struct encoder *outer_encoder = encoder_current; // buffer encoder
|
||||
int offset;
|
||||
intval_t value;
|
||||
|
||||
// make given encoder the current one (for ALU-parsed values)
|
||||
encoder_current = inner_encoder;
|
||||
@ -390,7 +394,8 @@ static enum eos encode_string(const struct encoder *inner_encoder, char xor)
|
||||
// Parse value. No problems with single characters
|
||||
// because the current encoding is
|
||||
// temporarily set to the given one.
|
||||
output_8(ALU_any_int());
|
||||
ALU_any_int(&value);
|
||||
output_8(value);
|
||||
}
|
||||
} while (Input_accept_comma());
|
||||
encoder_current = outer_encoder; // reactivate buffered encoder
|
||||
@ -419,13 +424,14 @@ static enum eos po_scr(void)
|
||||
// insert screencode string, XOR'd
|
||||
static enum eos po_scrxor(void)
|
||||
{
|
||||
intval_t num = ALU_any_int();
|
||||
intval_t xor;
|
||||
|
||||
ALU_any_int(&xor);
|
||||
if (Input_accept_comma() == FALSE) {
|
||||
Throw_error(exception_syntax);
|
||||
return SKIP_REMAINDER;
|
||||
}
|
||||
return encode_string(&encoder_scr, num);
|
||||
return encode_string(&encoder_scr, xor);
|
||||
}
|
||||
|
||||
// Include binary file ("!binary" pseudo opcode)
|
||||
@ -514,7 +520,7 @@ static enum eos po_fill(void)
|
||||
|
||||
ALU_defined_int(&sizeresult); // FIXME - forbid addresses!
|
||||
if (Input_accept_comma())
|
||||
fill = ALU_any_int(); // FIXME - forbid addresses!
|
||||
ALU_any_int(&fill); // FIXME - forbid addresses!
|
||||
while (sizeresult.val.intval--)
|
||||
output_8(fill);
|
||||
return ENSURE_EOS;
|
||||
@ -554,7 +560,7 @@ static enum eos po_align(void)
|
||||
Throw_error(exception_syntax);
|
||||
ALU_defined_int(&equalresult); // ...allow addresses (unlikely, but possible)
|
||||
if (Input_accept_comma())
|
||||
fill = ALU_any_int();
|
||||
ALU_any_int(&fill);
|
||||
else
|
||||
fill = CPU_state.type->default_align_value;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.96.5" // update before release FIXME
|
||||
#define CODENAME "Fenchurch" // update before release
|
||||
#define CHANGE_DATE "22 May" // update before release FIXME
|
||||
#define CHANGE_DATE "24 May" // 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…
x
Reference in New Issue
Block a user