Skip to content

Commit

Permalink
Final commit to v10.5, fixed some dead assignments, made anding to wo…
Browse files Browse the repository at this point in the history
…rk on Amiga (again).
  • Loading branch information
vhelin committed Jun 23, 2023
1 parent d4b792e commit 7461036
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 83 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG
Expand Up @@ -3,7 +3,7 @@
1... WLA GB-Z80/Z80/6502/65C02/65CE02/65816/68000/6800/6801/6809/8008/8080/HUC6280/SPC-700/SuperFX History
----------------------------------------------------------------------------------------------------------

v10.5 (19-Jun-2023) [ALL] .DSB, .DSW, .DSL and .DSD produced only one pending
v10.5 (23-Jun-2023) [ALL] .DSB, .DSW, .DSL and .DSD produced only one pending
calculation struct when encountered a pending calculation
thus the result was wrong.
[ALL] Added .ALIGN.
Expand Down Expand Up @@ -1483,7 +1483,7 @@ v1.0 (10-Jul-2000) The first public release.
------------------------------------------------------------------------------


v5.20 (07-May-2022) Added [sectionwriteorder] and [ramsectionwriteorder]
v5.20 (23-Jun-2023) Added [sectionwriteorder] and [ramsectionwriteorder]
to linkfile.
Added -pS and -pR that make WLALINK to ignore .SECTION
types when writing the .SECTIONs to output, only
Expand Down
7 changes: 4 additions & 3 deletions decode.c
Expand Up @@ -453,7 +453,8 @@ static int _mc68000_parse_ea(char *code, int *index, int *reg1, int *reg2, int *
if (code[i] == 0xA || code[i] == ',')
break;

c = toupper((int)code[i++]);
c = toupper((int)code[i]);
i++;
if (code[i] >= '0' && code[i] <= '7')
number = code[i++] - '0';
else {
Expand Down Expand Up @@ -487,7 +488,8 @@ static int _mc68000_parse_ea(char *code, int *index, int *reg1, int *reg2, int *
/* it's a range! */
i++;

c2 = toupper((int)code[i++]);
c2 = toupper((int)code[i]);
i++;

if (c2 != c) {
/* different register type */
Expand Down Expand Up @@ -3779,7 +3781,6 @@ int evaluate_token(void) {
if (done == NO)
break;

size = s_instruction_tmp->size;
opcode = s_instruction_tmp->hex;

if (_mc68000_parse_ea(g_buffer, &s_parser_source_index, &register_y1, &register_y2, &register_y_mode, &data_y, &data_type_y, label_y, NO) == FAILED)
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Expand Up @@ -18,7 +18,7 @@
project = u'wla-dx'
copyright = u'1998, vhelin'
version = '10.5' # The short X.Y version, can be used with |version|
release = '10.5a' # The full version, including alpha/beta/rc tags, |release|
release = '10.5' # The full version, including alpha/beta/rc tags, |release|
language = None
#today = ''
#today_fmt = '%B %d, %Y'
Expand Down
4 changes: 2 additions & 2 deletions main.c
Expand Up @@ -36,7 +36,7 @@ FILE *g_file_out_ptr = NULL;
__near long __stack = 200000;
#endif

char g_version_string[] = "$VER: wla-" WLA_NAME " 10.5a (19.6.2023)";
char g_version_string[] = "$VER: wla-" WLA_NAME " 10.5 (23.6.2023)";
char g_wla_version[] = "10.5";

extern struct incbin_file_data *g_incbin_file_data_first, *g_ifd_tmp;
Expand Down Expand Up @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) {
}

if (g_output_format == OUTPUT_NONE || parse_flags_result == FAILED) {
char title[] = "WLA " ARCH_STR " Macro Assembler v10.5a";
char title[] = "WLA " ARCH_STR " Macro Assembler v10.5";
int length, left, right;

length = (int)strlen(title);
Expand Down
1 change: 0 additions & 1 deletion parse.c
Expand Up @@ -980,7 +980,6 @@ int input_number(void) {
g_parsed_int = (g_parsed_int << 4) + e - 'a' + 10;
else if (e == 'h' || e == 'H') {
g_source_index++;
e = g_buffer[g_source_index];
break;
}
else
Expand Down
4 changes: 2 additions & 2 deletions phase_1.c
Expand Up @@ -4278,7 +4278,7 @@ int directive_incdir(void) {

static int _remember_namespace(char *name) {

struct namespace *nspace = NULL;
struct namespace *nspace;

nspace = calloc(sizeof(struct namespace), 1);
if (nspace == NULL) {
Expand Down Expand Up @@ -10827,7 +10827,7 @@ int parse_directive(void) {

/* get the isolation counter */
g_expect_calculations = NO;
q = input_number();
input_number();
g_expect_calculations = YES;

g_is_file_isolated_counter = g_parsed_int;
Expand Down
37 changes: 12 additions & 25 deletions stack.c
Expand Up @@ -3250,6 +3250,13 @@ static double _round(double d) {
}


/* we have trouble with "and" on Amiga thus this function - a bug in SAS/C? perhaps issues on other platforms as well? */
static int _perform_and(int a, int b) {

return a & b;
}


int compute_stack(struct stack *sta, int stack_item_count, double *result) {

struct stack_item *s;
Expand Down Expand Up @@ -3308,55 +3315,35 @@ int compute_stack(struct stack *sta, int stack_item_count, double *result) {
break;
case SI_OP_LOW_BYTE:
z = (int)v[t - 1];
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
#endif
v[t - 1] = z & 0xFF;
v[t - 1] = _perform_and(z, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE)
v[t - 1] = -v[t - 1];
sp[t - 1] = NULL;
break;
case SI_OP_HIGH_BYTE:
z = ((int)v[t - 1]) >> 8;
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
#endif
v[t - 1] = z & 0xFF;
v[t - 1] = _perform_and(z, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE)
v[t - 1] = -v[t - 1];
sp[t - 1] = NULL;
break;
case SI_OP_BANK_BYTE:
z = ((int)v[t - 1]) >> 16;
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
#endif
v[t - 1] = z & 0xFF;
v[t - 1] = _perform_and(z, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE)
v[t - 1] = -v[t - 1];
sp[t - 1] = NULL;
break;
case SI_OP_LOW_WORD:
z = (int)v[t - 1];
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFFFF;
#endif
v[t - 1] = z & 0xFFFF;
v[t - 1] = _perform_and(z, 0xFFFF);
if (s->sign == SI_SIGN_NEGATIVE)
v[t - 1] = -v[t - 1];
sp[t - 1] = NULL;
break;
case SI_OP_HIGH_WORD:
z = ((int)v[t - 1]) >> 16;
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFFFF;
#endif
v[t - 1] = z & 0xFFFF;
v[t - 1] = _perform_and(z, 0xFFFF);
if (s->sign == SI_SIGN_NEGATIVE)
v[t - 1] = -v[t - 1];
sp[t - 1] = NULL;
Expand Down
16 changes: 8 additions & 8 deletions wlalink/files.c
Expand Up @@ -250,7 +250,7 @@ int load_files(char *argv[], int argc) {
}
/* section write order? */
else if (state == STATE_SECTION_WRITE_ORDER) {
int statuses[SECTION_TYPES_COUNT_ALL], sum;
int statuses[SECTION_TYPES_COUNT_ALL], sum, j;

if (s_section_write_order_index > 0) {
fprintf(stderr, "%s:%d: LOAD_FILES: Excess data in [sectionwriteorder].\n", argv[argc - 2], line);
Expand All @@ -267,9 +267,9 @@ int load_files(char *argv[], int argc) {
for (i = 0; i < SECTION_TYPES_COUNT_ALL; i++)
statuses[i] = 0;

i = SUCCEEDED;
j = SUCCEEDED;

while (i == SUCCEEDED) {
while (j == SUCCEEDED) {
int status;

if (strcaselesscmp(token, "force") == 0)
Expand Down Expand Up @@ -326,7 +326,7 @@ int load_files(char *argv[], int argc) {
_process_tmp(tmp);

x = 0;
i = get_next_token(tmp, token, &x);
j = get_next_token(tmp, token, &x);
}

/* count the types */
Expand All @@ -346,7 +346,7 @@ int load_files(char *argv[], int argc) {
}
/* ramsection write order? */
else if (state == STATE_RAMSECTION_WRITE_ORDER) {
int statuses[SECTION_TYPES_COUNT_ALL], sum;
int statuses[SECTION_TYPES_COUNT_ALL], sum, j;

if (s_ramsection_write_order_index > 0) {
fprintf(stderr, "%s:%d: LOAD_FILES: Excess data in [ramsectionwriteorder].\n", argv[argc - 2], line);
Expand All @@ -363,9 +363,9 @@ int load_files(char *argv[], int argc) {
for (i = 0; i < SECTION_TYPES_COUNT_ALL; i++)
statuses[i] = 0;

i = SUCCEEDED;
j = SUCCEEDED;

while (i == SUCCEEDED) {
while (j == SUCCEEDED) {
int status;

if (strcaselesscmp(token, "force") == 0)
Expand Down Expand Up @@ -416,7 +416,7 @@ int load_files(char *argv[], int argc) {
_process_tmp(tmp);

x = 0;
i = get_next_token(tmp, token, &x);
j = get_next_token(tmp, token, &x);
}

/* count the types */
Expand Down
4 changes: 2 additions & 2 deletions wlalink/main.c
Expand Up @@ -32,7 +32,7 @@
#define WLALINK_DEBUG 1
*/

char g_version_string[] = "$VER: wlalink 5.20a (7.5.2023)";
char g_version_string[] = "$VER: wlalink 5.20 (23.6.2023)";

#ifdef AMIGA
__near long __stack = 200000;
Expand Down Expand Up @@ -353,7 +353,7 @@ int main(int argc, char *argv[]) {
i = FAILED;

if (i == FAILED) {
char title[] = "WLALINK - WLA DX Macro Assembler Linker v5.20a";
char title[] = "WLALINK - WLA DX Macro Assembler Linker v5.20";
int length, left, right;

length = (int)strlen(title);
Expand Down
57 changes: 20 additions & 37 deletions wlalink/write.c
Expand Up @@ -3065,12 +3065,20 @@ static double _round(double d) {
const char *get_stack_item_operator_name(int operator);
char *get_stack_item_description(struct stack_item *si, int file_id);


/* we have trouble with "and" on Amiga thus this function - a bug in SAS/C? perhaps issues on other platforms as well? */
static int _perform_and(int a, int b) {

return a & b;
}


int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int *result_slot, int *result_base, int *result_bank) {

int r, t, z, y, x, res_base, res_bank, res_slot, slot[256], base[256], bank[256];
double v_ram[256], v_rom[256], q, res_ram, res_rom;
struct stack_item *s = NULL;
struct stack *st = NULL;
struct stack_item *s;
struct stack *st;

if (sta->under_work == YES) {
fprintf(stderr, "%s: %s:%d: COMPUTE_STACK: A loop found in computation.\n", get_file_name(sta->file_id),
Expand Down Expand Up @@ -3529,13 +3537,8 @@ int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int
y += base[t - 1];
}

#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
y = y & 0xFF;
#endif
v_ram[t - 1] = z & 0xFF;
v_rom[t - 1] = y & 0xFF;
v_ram[t - 1] = _perform_and(z, 0xFF);
v_rom[t - 1] = _perform_and(y, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE) {
v_ram[t - 1] = -v_ram[t - 1];
v_rom[t - 1] = -v_rom[t - 1];
Expand All @@ -3544,13 +3547,8 @@ int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int
case SI_OP_LOW_BYTE:
z = (int)v_ram[t - 1];
y = (int)v_rom[t - 1];
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
y = y & 0xFF;
#endif
v_ram[t - 1] = z & 0xFF;
v_rom[t - 1] = y & 0xFF;
v_ram[t - 1] = _perform_and(z, 0xFF);
v_rom[t - 1] = _perform_and(y, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE) {
v_ram[t - 1] = -v_ram[t - 1];
v_rom[t - 1] = -v_rom[t - 1];
Expand All @@ -3559,13 +3557,8 @@ int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int
case SI_OP_HIGH_BYTE:
z = ((int)v_ram[t - 1]) >> 8;
y = ((int)v_rom[t - 1]) >> 8;
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFF;
y = y & 0xFF;
#endif
v_ram[t - 1] = z & 0xFF;
v_rom[t - 1] = y & 0xFF;
v_ram[t - 1] = _perform_and(z, 0xFF);
v_rom[t - 1] = _perform_and(y, 0xFF);
if (s->sign == SI_SIGN_NEGATIVE) {
v_ram[t - 1] = -v_ram[t - 1];
v_rom[t - 1] = -v_rom[t - 1];
Expand All @@ -3574,13 +3567,8 @@ int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int
case SI_OP_LOW_WORD:
z = (int)v_ram[t - 1];
y = (int)v_rom[t - 1];
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFFFF;
y = y & 0xFFFF;
#endif
v_ram[t - 1] = z & 0xFFFF;
v_rom[t - 1] = y & 0xFFFF;
v_ram[t - 1] = _perform_and(z, 0xFFFF);
v_rom[t - 1] = _perform_and(y, 0xFFFF);
if (s->sign == SI_SIGN_NEGATIVE) {
v_ram[t - 1] = -v_ram[t - 1];
v_rom[t - 1] = -v_rom[t - 1];
Expand All @@ -3589,13 +3577,8 @@ int compute_stack(struct stack *sta, double *result_ram, double *result_rom, int
case SI_OP_HIGH_WORD:
z = ((int)v_ram[t - 1]) >> 16;
y = ((int)v_rom[t - 1]) >> 16;
#ifdef AMIGA
/* on Amiga this needs to be done twice - a bug in SAS/C? */
z = z & 0xFFFF;
y = y & 0xFFFF;
#endif
v_ram[t - 1] = z & 0xFFFF;
v_rom[t - 1] = y & 0xFFFF;
v_ram[t - 1] = _perform_and(z, 0xFFFF);
v_rom[t - 1] = _perform_and(y, 0xFFFF);
if (s->sign == SI_SIGN_NEGATIVE) {
v_ram[t - 1] = -v_ram[t - 1];
v_rom[t - 1] = -v_rom[t - 1];
Expand Down

0 comments on commit 7461036

Please sign in to comment.