added typedef for "bits"

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@231 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-06-14 00:26:38 +00:00
parent 2671eef384
commit f64780a3bd
16 changed files with 68 additions and 67 deletions

View File

@ -23,7 +23,7 @@
// variables
int RISCOS_flags = 0; // used to store platform-specific flags
bits RISCOS_flags = 0; // used to store platform-specific flags
// exit handler: if throwback was used, de-register now

View File

@ -58,7 +58,7 @@ do { \
// variables
extern int RISCOS_flags; // Holds platform-specific flags
extern bits RISCOS_flags; // Holds platform-specific flags
#define RISCOSFLAG_THROWBACK (1u << 0) // use throwback protocol
#define RISCOSFLAG_THROWN (1u << 1) // throwback is active

View File

@ -459,8 +459,8 @@ fail:
static void parse_binary_literal(void) // Now GotByte = "%" or "b"
{
intval_t value = 0;
int flags = NUMBER_IS_DEFINED,
digits = -1; // digit counter
bits flags = NUMBER_IS_DEFINED;
int digits = -1; // digit counter
for (;;) {
++digits;
@ -501,8 +501,8 @@ static void parse_binary_literal(void) // Now GotByte = "%" or "b"
static void parse_hex_literal(void) // Now GotByte = "$" or "x"
{
char byte;
int digits = -1, // digit counter
flags = NUMBER_IS_DEFINED;
int digits = -1; // digit counter
bits flags = NUMBER_IS_DEFINED;
intval_t value = 0;
for (;;) {
@ -611,8 +611,8 @@ static void parse_number_literal(void) // Now GotByte = first digit
static void parse_octal_literal(void) // Now GotByte = first octal digit
{
intval_t value = 0;
int flags = NUMBER_IS_DEFINED,
digits = 0; // digit counter
bits flags = NUMBER_IS_DEFINED;
int digits = 0; // digit counter
while ((GotByte >= '0') && (GotByte <= '7')) {
value = (value << 3) + (GotByte & 7); // this works. it's ASCII.
@ -1189,7 +1189,7 @@ static inline boolean num_different(const struct object *self, const struct obje
// assign new value
static void number_assign(struct object *self, const struct object *new_value, boolean accept_change)
{
int own_flags = self->u.number.flags,
bits own_flags = self->u.number.flags,
other_flags = new_value->u.number.flags;
// local copies of the flags are used because
// self->...flags might get overwritten when copying struct over, and
@ -1451,7 +1451,7 @@ static void string_handle_monadic_operator(struct object *self, const struct op
// (used by both int and float handlers for comparison operators)
static void number_fix_result_after_comparison(struct object *self, const struct object *other, intval_t result)
{
int flags;
bits flags;
self->type = &type_int;
self->u.number.val.intval = result;

View File

@ -16,13 +16,14 @@
#endif
// types
typedef enum { FALSE = 0, TRUE } boolean; // yes, I could include <stdbool.h>, but this source should work with ancient compilers as well...
typedef unsigned int bits;
typedef unsigned int scope_t;
typedef signed long intval_t; // at least 32 bits
typedef unsigned long uintval_t; // just for logical shift right
// structure for ints/floats
struct number {
int flags; // DEFINED, FITS_IN_BYTE, etc. (see alu.h)
bits flags; // DEFINED, FITS_IN_BYTE, etc. (see alu.h)
union {
intval_t intval; // integer value
double fpval; // floating point value

View File

@ -14,9 +14,9 @@
struct cpu_type {
// This function is not allowed to change GlobalDynaBuf
// because that's where the mnemonic is stored!
boolean (*keyword_is_mnemonic)(int);
int flags; // see below for bit meanings
char default_align_value;
boolean (*keyword_is_mnemonic)(int);
bits flags; // see below for bit meanings
unsigned char default_align_value;
};
#define CPUFLAG_INDIRECTJMPBUGGY (1u << 0) // warn if "jmp ($xxff)" is assembled
#define CPUFLAG_SUPPORTSLONGREGS (1u << 1) // allow "!al" and "!rl" pseudo opcodes

View File

@ -19,7 +19,7 @@ struct block {
// struct to pass "!for" loop stuff from pseudoopcodes.c to flow.c
struct for_loop {
struct symbol *symbol;
int force_bit;
bits force_bit;
boolean use_old_algo;
struct {
intval_t first,

View File

@ -148,7 +148,7 @@ void *safe_malloc(size_t size)
// Check and return whether first label of statement. Complain if not.
static int first_label_of_statement(int *statement_flags)
static int first_label_of_statement(bits *statement_flags)
{
if ((*statement_flags) & SF_IMPLIED_LABEL) {
Throw_error(exception_syntax);
@ -164,7 +164,7 @@ static int first_label_of_statement(int *statement_flags)
// name must be held in GlobalDynaBuf.
// called by parse_symbol_definition, parse_backward_anon_def, parse_forward_anon_def
// "powers" is used by backward anons to allow changes
static void set_label(scope_t scope, int stat_flags, int force_bit, int powers)
static void set_label(scope_t scope, bits stat_flags, bits force_bit, bits powers)
{
struct symbol *symbol;
struct number pc;
@ -190,7 +190,7 @@ static void set_label(scope_t scope, int stat_flags, int force_bit, int powers)
// call with symbol name in GlobalDynaBuf and GotByte == '='
// "powers" is for "!set" pseudo opcode so changes are allowed (see symbol.h for powers)
void parse_assignment(scope_t scope, int force_bit, int powers)
void parse_assignment(scope_t scope, bits force_bit, bits powers)
{
struct symbol *symbol;
struct object result;
@ -213,9 +213,9 @@ void parse_assignment(scope_t scope, int force_bit, int powers)
// parse symbol definition (can be either global or local, may turn out to be a label).
// name must be held in GlobalDynaBuf.
static void parse_symbol_definition(scope_t scope, int stat_flags)
static void parse_symbol_definition(scope_t scope, bits stat_flags)
{
int force_bit;
bits force_bit;
force_bit = Input_get_force_bit(); // skips spaces after (yes, force bit is allowed for label definitions)
if (GotByte == '=') {
@ -230,7 +230,7 @@ static void parse_symbol_definition(scope_t scope, int stat_flags)
// Parse global symbol definition or assembler mnemonic
static void parse_mnemo_or_global_symbol_def(int *statement_flags)
static void parse_mnemo_or_global_symbol_def(bits *statement_flags)
{
boolean is_mnemonic;
@ -250,7 +250,7 @@ static void parse_mnemo_or_global_symbol_def(int *statement_flags)
// parse (cheap) local symbol definition
static void parse_local_symbol_def(int *statement_flags, scope_t scope)
static void parse_local_symbol_def(bits *statement_flags, scope_t scope)
{
if (!first_label_of_statement(statement_flags))
return;
@ -262,7 +262,7 @@ static void parse_local_symbol_def(int *statement_flags, scope_t scope)
// parse anonymous backward label definition. Called with GotByte == '-'
static void parse_backward_anon_def(int *statement_flags)
static void parse_backward_anon_def(bits *statement_flags)
{
if (!first_label_of_statement(statement_flags))
return;
@ -278,7 +278,7 @@ static void parse_backward_anon_def(int *statement_flags)
// parse anonymous forward label definition. called with GotByte == ?
static void parse_forward_anon_def(int *statement_flags)
static void parse_forward_anon_def(bits *statement_flags)
{
if (!first_label_of_statement(statement_flags))
return;
@ -301,7 +301,7 @@ static void parse_forward_anon_def(int *statement_flags)
// Has to be re-entrant.
void Parse_until_eob_or_eof(void)
{
int statement_flags;
bits statement_flags;
// // start with next byte, don't care about spaces
// NEXTANDSKIPSPACE();

View File

@ -137,7 +137,7 @@ extern void config_default(struct config *conf);
extern void *safe_malloc(size_t amount);
// call with symbol name in GlobalDynaBuf and GotByte == '='
// "powers" is for "!set" pseudo opcode so changes are allowed (see symbol.h for powers)
extern void parse_assignment(scope_t scope, int force_bit, int powers);
extern void parse_assignment(scope_t scope, bits force_bit, bits powers);
// Parse block, beginning with next byte.
// End reason (either CHAR_EOB or CHAR_EOF) can be found in GotByte afterwards
// Has to be re-entrant.

View File

@ -629,10 +629,10 @@ int Input_accept_comma(void)
// read optional info about parameter length
// FIXME - move to different file!
int Input_get_force_bit(void)
bits Input_get_force_bit(void)
{
char byte;
int force_bit = 0;
bits force_bit = 0;
if (GotByte == '+') {
byte = GetByte();

View File

@ -8,7 +8,7 @@
#include <stdio.h> // for FILE
#include "config.h" // for scope_t
#include "config.h" // for bits and scope_t
// type definitions
@ -120,7 +120,7 @@ extern int Input_read_filename(boolean library_allowed, boolean *uses_lib);
// found, otherwise FALSE.
extern int Input_accept_comma(void);
// read optional info about parameter length
extern int Input_get_force_bit(void);
extern bits Input_get_force_bit(void);
// include path stuff - should be moved to its own file:

View File

@ -538,7 +538,7 @@ void Mnemo_init(void)
// Address mode parsing
// utility function for parsing indices. result must be processed via AMB_PREINDEX() or AMB_INDEX() macro!
static int get_index(int next)
static int get_index(boolean next)
{
if (next)
GetByte();
@ -592,10 +592,10 @@ static void get_int_arg(struct number *result, boolean complain_about_indirect)
// wrapper function to detect addressing mode, and, if not IMPLIED, read arg.
// argument is stored in given result structure, addressing mode is returned.
static int get_addr_mode(struct number *result)
static bits get_addr_mode(struct number *result)
{
struct expression expression;
int address_mode_bits = 0;
bits address_mode_bits = 0;
SKIPSPACE();
switch (GotByte) {
@ -645,7 +645,7 @@ static int get_addr_mode(struct number *result)
// Helper function for calc_arg_size()
// Only call with "size_bit = NUMBER_FORCES_16" or "size_bit = NUMBER_FORCES_24"
static int check_oversize(int size_bit, struct number *argument)
static bits check_oversize(bits size_bit, struct number *argument)
{
// only check if value is *defined*
if ((argument->flags & NUMBER_IS_DEFINED) == 0)
@ -672,7 +672,7 @@ static int check_oversize(int size_bit, struct number *argument)
// argument value and flags of parameter
// addressing_modes adressing modes (8b, 16b, 24b or any combination)
// Return value = force bit for number of parameter bytes to send (0 = error)
static int calc_arg_size(int force_bit, struct number *argument, int addressing_modes)
static bits calc_arg_size(bits force_bit, struct number *argument, bits addressing_modes)
{
// if there are no possible addressing modes, complain
if (addressing_modes == MAYBE______) {
@ -841,7 +841,7 @@ static void far_branch(int preoffset)
// set addressing mode bits depending on which opcodes exist, then calculate
// argument size and output both opcode and argument
static void make_command(int force_bit, struct number *result, unsigned long opcodes)
static void make_command(bits force_bit, struct number *result, unsigned long opcodes)
{
int addressing_modes = MAYBE______;
@ -869,9 +869,9 @@ static void make_command(int force_bit, struct number *result, unsigned long opc
// check whether 16bit immediate addressing is allowed. If not, return given
// opcode. If it is allowed, set force bits according to CPU register length
// and return given opcode for both 8- and 16-bit mode.
static unsigned int imm_ops(int *force_bit, unsigned char opcode, int immediate_mode)
static unsigned int imm_ops(bits *force_bit, unsigned char opcode, bits immediate_mode)
{
int long_register = 0;
boolean long_register = FALSE;
switch (immediate_mode) {
case IM_FORCE8:
@ -911,11 +911,11 @@ static void check_zp_wraparound(struct number *result)
// The main accumulator stuff (ADC, AND, CMP, EOR, LDA, ORA, SBC, STA)
// plus PEI.
static void group_main(int index, int flags)
static void group_main(int index, bits flags)
{
unsigned long immediate_opcodes;
struct number result;
int force_bit = Input_get_force_bit(); // skips spaces after
bits force_bit = Input_get_force_bit(); // skips spaces after
switch (get_addr_mode(&result)) {
case IMMEDIATE_ADDRESSING: // #$ff or #$ffff (depending on accu length)
@ -975,11 +975,11 @@ static void group_main(int index, int flags)
}
// Various mnemonics with different addressing modes.
static void group_misc(int index, int immediate_mode)
static void group_misc(int index, bits immediate_mode)
{
unsigned long immediate_opcodes;
struct number result;
int force_bit = Input_get_force_bit(); // skips spaces after
bits force_bit = Input_get_force_bit(); // skips spaces after
switch (get_addr_mode(&result)) {
case IMPLIED_ADDRESSING: // implied addressing
@ -1095,7 +1095,7 @@ static void group_prefix(int opcode)
static void group_jump(int index)
{
struct number result;
int force_bit = Input_get_force_bit(); // skips spaces after
bits force_bit = Input_get_force_bit(); // skips spaces after
switch (get_addr_mode(&result)) {
case ABSOLUTE_ADDRESSING: // absolute16 or absolute24
@ -1121,11 +1121,11 @@ static void group_jump(int index)
}
// Work function
static int check_mnemo_tree(struct ronode *tree, struct dynabuf *dyna_buf)
static boolean check_mnemo_tree(struct ronode *tree, struct dynabuf *dyna_buf)
{
void *node_body;
int code,
flags;
int code;
bits flags;
// search for tree item
if (!Tree_easy_scan(tree, &node_body, dyna_buf))
@ -1185,7 +1185,7 @@ boolean keyword_is_6502_mnemo(int length)
// make lower case version of mnemonic in local dynamic buffer
DynaBuf_to_lower(mnemo_dyna_buf, GlobalDynaBuf);
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by NMOS 6502 cpu.
@ -1205,7 +1205,7 @@ boolean keyword_is_nmos6502_mnemo(int length)
return TRUE;
// ...then check original opcodes
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by C64DTV2 cpu.
@ -1225,7 +1225,7 @@ boolean keyword_is_c64dtv2_mnemo(int length)
return TRUE;
// ...then check original opcodes
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by 65c02 cpu.
@ -1241,7 +1241,7 @@ boolean keyword_is_65c02_mnemo(int length)
return TRUE;
// ...then check original opcodes
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_6502_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by Rockwell 65c02 cpu.
@ -1261,7 +1261,7 @@ boolean keyword_is_r65c02_mnemo(int length)
return TRUE;
// ...then check Rockwell extensions (rmb, smb, bbr, bbs)
return check_mnemo_tree(mnemo_bitmanips_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_bitmanips_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by WDC w65c02 cpu.
@ -1285,7 +1285,7 @@ boolean keyword_is_w65c02_mnemo(int length)
return TRUE;
// ...then check WDC extensions "stp" and "wai"
return check_mnemo_tree(mnemo_stp_wai_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_stp_wai_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by CSG 65CE02 cpu.
@ -1313,7 +1313,7 @@ boolean keyword_is_65ce02_mnemo(int length)
return TRUE;
// ...then check "aug"
return check_mnemo_tree(mnemo_aug_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_aug_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by CSG 4502 cpu.
@ -1341,7 +1341,7 @@ boolean keyword_is_4502_mnemo(int length)
return TRUE;
// ...then check "map" and "eom"
return check_mnemo_tree(mnemo_map_eom_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_map_eom_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by MEGA65 cpu.
@ -1373,7 +1373,7 @@ boolean keyword_is_m65_mnemo(int length)
return TRUE;
// ...then check "map" and "eom"
return check_mnemo_tree(mnemo_map_eom_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_map_eom_tree, mnemo_dyna_buf);
}
// check whether mnemonic in GlobalDynaBuf is supported by 65816 cpu.
@ -1397,5 +1397,5 @@ boolean keyword_is_65816_mnemo(int length)
return TRUE;
// ...then check WDC extensions "stp" and "wai"
return check_mnemo_tree(mnemo_stp_wai_tree, mnemo_dyna_buf) ? TRUE : FALSE;
return check_mnemo_tree(mnemo_stp_wai_tree, mnemo_dyna_buf);
}

View File

@ -47,7 +47,7 @@ struct output {
struct {
intval_t start; // start of current segment (or NO_SEGMENT_START)
intval_t max; // highest address segment may use
int 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
} segment;
char xor; // output modifier
@ -540,7 +540,7 @@ void Output_end_segment(void)
// change output pointer and enable output
void Output_start_segment(intval_t address_change, int segment_flags)
void Output_start_segment(intval_t address_change, bits segment_flags)
{
// properly finalize previous segment (link to list, announce)
Output_end_segment();
@ -573,7 +573,7 @@ void output_set_xor(char xor)
// set program counter to defined value (FIXME - allow for undefined!)
// if start address was given on command line, main loop will call this before each pass.
// in addition to that, it will be called on each "*= VALUE".
void vcpu_set_pc(intval_t new_pc, int segment_flags)
void vcpu_set_pc(intval_t new_pc, bits segment_flags)
{
intval_t new_offset;
@ -654,7 +654,7 @@ void vcpu_end_statement(void)
struct pseudopc {
struct pseudopc *outer; // next layer (to be able to "unpseudopc" labels by more than one level)
intval_t offset; // inner minus outer pc
int flags; // flags of outer pc
bits flags; // flags of outer pc
};
// start offset assembly
void pseudopc_start(struct number *new_pc)

View File

@ -84,14 +84,14 @@ extern int outputfile_set_filename(void);
// write smallest-possible part of memory buffer to file
extern void Output_save_file(FILE *fd);
// change output pointer and enable output
extern void Output_start_segment(intval_t address_change, int segment_flags);
extern void Output_start_segment(intval_t address_change, bits segment_flags);
// Show start and end of current segment
extern void Output_end_segment(void);
extern char output_get_xor(void);
extern void output_set_xor(char xor);
// set program counter to defined value (TODO - allow undefined!)
extern void vcpu_set_pc(intval_t new_pc, int flags);
extern void vcpu_set_pc(intval_t new_pc, bits flags);
// get program counter
extern void vcpu_read_pc(struct number *target);
// get size of current statement (until now) - needed for "!bin" verbose output

View File

@ -47,7 +47,7 @@ static struct ronode *pseudo_opcode_tree = NULL; // tree to hold pseudo opcodes
// called when "*= EXPRESSION" is parsed, to set the program counter
void notreallypo_setpc(void) // GotByte is '*'
{
int segment_flags = 0;
bits segment_flags = 0;
struct number intresult;
// next non-space must be '='

View File

@ -144,7 +144,7 @@ struct symbol *symbol_find(scope_t scope)
// explicit symbol assignments via "!set" (has all powers)
// loop counter var init via "!for" (has POWER_CHANGE_VALUE and POWER_CHANGE_NUMTYPE)
// CAUTION: actual incrementing of counter is then done directly without calls here!
void symbol_set_object(struct symbol *symbol, struct object *new_value, int powers)
void symbol_set_object(struct symbol *symbol, struct object *new_value, bits powers)
{
struct type *symbol_class, // helper vars to group
*newval_class; // ints and floats
@ -184,7 +184,7 @@ void symbol_set_object(struct symbol *symbol, struct object *new_value, int powe
// set force bit of symbol. trying to change to a different one will raise error.
void symbol_set_force_bit(struct symbol *symbol, int force_bit)
void symbol_set_force_bit(struct symbol *symbol, bits force_bit)
{
if (!force_bit)
Bug_found("ForceBitZero", 0); // FIXME - add to docs!

View File

@ -38,9 +38,9 @@ extern struct symbol *symbol_find(scope_t scope);
#define POWER_NONE 0
#define POWER_CHANGE_VALUE (1u << 0) // e.g. change 3 to 5 or 2.71
#define POWER_CHANGE_OBJTYPE (1u << 1) // e.g. change 3 to "somestring"
extern void symbol_set_object(struct symbol *symbol, struct object *new_obj, int powers);
extern void symbol_set_object(struct symbol *symbol, struct object *new_obj, bits powers);
// set force bit of symbol. trying to change to a different one will raise error.
extern void symbol_set_force_bit(struct symbol *symbol, int force_bit);
extern void symbol_set_force_bit(struct symbol *symbol, bits force_bit);
// set global symbol to value, no questions asked (for "-D" switch)
// name must be held in GlobalDynaBuf.
extern void symbol_define(intval_t value);