Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64 bit for expression, fixes issue #53 #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/avra.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <inttypes.h>
#include <string.h>

#include "misc.h"
Expand Down Expand Up @@ -259,7 +260,7 @@ assemble(struct prog_info *pi)
int
load_arg_defines(struct prog_info *pi)
{
int i;
int64_t i;
char *expr;
char buff[256];
struct data_list *define;
Expand All @@ -285,13 +286,13 @@ load_arg_defines(struct prog_info *pi)
if (def_const(pi, buff, i)==False)
return (False);
} else { /* Pass 2 */
int j;
int64_t j;
if (get_constant(pi, buff, &j)==False) { /* Defined in Pass 1 and now missing ? */
fprintf(stderr,"Constant %s is missing in pass 2\n",buff);
return (False);
}
if (i != j) {
fprintf(stderr,"Constant %s changed value from %d in pass1 to %d in pass 2\n",buff,j,i);
fprintf(stderr,"Constant %s changed value from %" PRId64 " in pass1 to %" PRId64 " in pass 2\n",buff,j,i);
return (False);
}
/* OK. Definition is unchanged */
Expand Down Expand Up @@ -458,7 +459,7 @@ print_msg(struct prog_info *pi, int type, char *fmt, ...)


int
def_const(struct prog_info *pi, const char *name, int value)
def_const(struct prog_info *pi, const char *name, int64_t value)
{
struct label *label;
label = malloc(sizeof(struct label));
Expand Down Expand Up @@ -651,7 +652,7 @@ test_orglist(struct segment_info *si)

/* Get the value of a label. Return FALSE if label was not found */
int
get_label(struct prog_info *pi,char *name,int *value)
get_label(struct prog_info *pi,char *name,int64_t *value)
{
struct label *label=search_symbol(pi,pi->first_label,name,NULL);
if (label==NULL) return False;
Expand All @@ -660,7 +661,7 @@ get_label(struct prog_info *pi,char *name,int *value)
}

int
get_constant(struct prog_info *pi,char *name,int *value)
get_constant(struct prog_info *pi,char *name,int64_t *value)
{
struct label *label=search_symbol(pi,pi->first_constant,name,NULL);
if (label==NULL) return False;
Expand All @@ -669,7 +670,7 @@ get_constant(struct prog_info *pi,char *name,int *value)
}

int
get_variable(struct prog_info *pi,char *name,int *value)
get_variable(struct prog_info *pi,char *name,int64_t *value)
{
struct label *label=search_symbol(pi,pi->first_variable,name,NULL);
if (label==NULL) return False;
Expand Down
17 changes: 9 additions & 8 deletions src/avra.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <stdio.h>
#include <time.h>
#include <stdint.h>

#define IS_HOR_SPACE(x) ((x == ' ') || (x == 9))
#define IS_LABEL(x) (isalnum(x) || (x == '%') || (x == '_'))
Expand Down Expand Up @@ -221,7 +222,7 @@ struct def {
struct label {
struct label *next;
char *name;
int value;
int64_t value;
};

struct macro {
Expand Down Expand Up @@ -286,17 +287,17 @@ void init_segment_size(struct prog_info *pi, struct device *device);
void rewind_segments(struct prog_info *pi);
void advance_ip(struct segment_info *si, int offset);

int def_const(struct prog_info *pi, const char *name, int value);
int def_const(struct prog_info *pi, const char *name, int64_t value);
int def_var(struct prog_info *pi, char *name, int value);
int def_orglist(struct segment_info *si);
int fix_orglist(struct segment_info *si);
void fprint_orglist(FILE *file, struct segment_info *si, struct orglist *orglist);
void fprint_sef_orglist(FILE *file, struct segment_info *si);
void fprint_segments(FILE *file, struct prog_info *pi);
int test_orglist(struct segment_info *si);
int get_label(struct prog_info *pi,char *name,int *value);
int get_constant(struct prog_info *pi,char *name,int *value);
int get_variable(struct prog_info *pi,char *name,int *value);
int get_label(struct prog_info *pi,char *name,int64_t *value);
int get_constant(struct prog_info *pi,char *name,int64_t *value);
int get_variable(struct prog_info *pi,char *name,int64_t *value);
struct label *test_label(struct prog_info *pi,char *name,char *message);
struct label *test_constant(struct prog_info *pi,char *name,char *message);
struct label *test_variable(struct prog_info *pi,char *name,char *message);
Expand All @@ -321,15 +322,15 @@ char *get_next_token(char *scratch, int term);
char *fgets_new(struct prog_info *pi, char *s, int size, FILE *stream);

/* expr.c */
int get_expr(struct prog_info *pi, char *data, int *value);
int get_symbol(struct prog_info *pi, char *label_name, int *data);
int get_expr(struct prog_info *pi, char *data, int64_t *value);
int get_symbol(struct prog_info *pi, char *label_name, int64_t *data);
int par_length(char *data);

/* mnemonic.c */
int parse_mnemonic(struct prog_info *pi);
int get_mnemonic_type(struct prog_info *pi);
int get_register(struct prog_info *pi, char *data);
int get_bitnum(struct prog_info *pi, char *data, int *ret);
int get_bitnum(struct prog_info *pi, char *data, int64_t *ret);
int get_indirect(struct prog_info *pi, char *operand);
int is_supported(struct prog_info *pi, char *name);
int count_supported_instructions(int flags);
Expand Down
15 changes: 9 additions & 6 deletions src/coff.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ int
stab_add_lineno(struct prog_info *pi, int LineNumber, char *pLabel, char *pFunction)
{

int Address;
int64_t Address;
struct lineno *pln;
struct syment *pEntry;
union auxent *pAux;
Expand Down Expand Up @@ -754,7 +754,7 @@ int
stab_add_lbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction)
{

int Address;
int64_t Address;
struct syment *pEntry;
union auxent *pAux;

Expand Down Expand Up @@ -790,7 +790,7 @@ int
stab_add_rbracket(struct prog_info *pi, int Level, char *pLabel, char *pFunction)
{

int Address;
int64_t Address;
struct syment *pEntry;
union auxent *pAux;

Expand Down Expand Up @@ -907,7 +907,8 @@ int
stab_add_function(struct prog_info *pi, char *pName, char *pLabel)
{

int n, Address;
int n;
int64_t Address;
unsigned short CoffType, Type;
struct syment *pEntry;
char *pType;
Expand Down Expand Up @@ -991,7 +992,8 @@ int
stab_add_global(struct prog_info *pi, char *pName, char *pType)
{

int n, Address, IsArray, SymbolIndex;
int n, IsArray, SymbolIndex;
int64_t Address;
unsigned short CoffType, Type;
struct syment *pEntry;
char *p;
Expand Down Expand Up @@ -1129,7 +1131,8 @@ int
stab_add_static_symbol(struct prog_info *pi, char *pName, char *pType, char *pLabel)
{

int n, Address;
int n;
int64_t Address;
unsigned short CoffType, Type;
struct syment *pEntry;

Expand Down
4 changes: 2 additions & 2 deletions src/coff.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ struct external_scnhdr {

struct lineno {
union {
long l_symndx; /* symtbl index of func name */
long l_paddr; /* paddr of line number */
int64_t l_symndx; /* symtbl index of func name */
int64_t l_paddr; /* paddr of line number */
} l_addr;
unsigned short l_lnno; /* line number */
};
Expand Down
7 changes: 4 additions & 3 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


#include <stdlib.h>
#include <inttypes.h>
#include <string.h>

#include "misc.h"
Expand Down Expand Up @@ -189,7 +190,7 @@ struct device *get_device(struct prog_info *pi, char *name)
int
predef_dev(struct prog_info *pi)
{
int i;
int64_t i;
char temp[MAX_DEV_NAME+1];
def_dev(pi);
for (i=0; (!i)||(device_list[i].name); i++) {
Expand All @@ -206,13 +207,13 @@ predef_dev(struct prog_info *pi)
if (def_const(pi, temp, i)==False)
return (False);
} else { /* Pass 2 */
int j;
int64_t j;
if (get_constant(pi, temp, &j)==False) { /* Defined in Pass 1 and now missing ? */
fprintf(stderr,"Constant %s is missing in pass 2\n",temp);
return (False);
}
if (i != j) {
fprintf(stderr,"Constant %s changed value from %d in pass1 to %d in pass 2\n",temp,j,i);
fprintf(stderr,"Constant %s changed value from %"PRId64" in pass1 to %"PRId64" in pass 2\n",temp,j,i);
return (False);
}
/* OK. definition is unchanged */
Expand Down
21 changes: 11 additions & 10 deletions src/directiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>

#include "misc.h"
Expand Down Expand Up @@ -157,7 +158,7 @@ parse_directive(struct prog_info *pi)
{
int directive, pragma;
int ok = True;
int i;
int64_t i;
char *next, *data, buf[140];
struct file_info *fi_bak;

Expand Down Expand Up @@ -329,7 +330,7 @@ parse_directive(struct prog_info *pi)
if (pi->list_line && pi->list_on) {
fprintf(pi->list_file, " %s\n", pi->list_line);
pi->list_line = NULL;
fprintf(pi->list_file, "%c:%06lx %04x\n",
fprintf(pi->list_file, "%c:%06lx %04"PRIx64"\n",
pi->segment->ident, pi->segment->addr, i);
}
if (pi->segment == pi->eseg) {
Expand Down Expand Up @@ -375,13 +376,13 @@ parse_directive(struct prog_info *pi)
if (def_const(pi, next, i)==False)
return (False);
} else { /* Pass 2 */
int j;
int64_t j;
if (get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */
print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next);
return (False);
}
if (i != j) {
print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i);
print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %"PRId64" in pass1 to %"PRId64" in pass 2", next,j,i);
return (False);
}
/* OK. Definition is unchanged */
Expand Down Expand Up @@ -556,13 +557,13 @@ parse_directive(struct prog_info *pi)
if (def_const(pi, next, i)==False)
return (False);
} else { /* Pass 2 */
int j;
int64_t j;
if (get_constant(pi, next, &j)==False) { /* Defined in Pass 1 and now missing ? */
print_msg(pi, MSGTYPE_ERROR, "Constant %s is missing in pass 2", next);
return (False);
}
if (i != j) {
print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %d in pass1 to %d in pass 2", next,j,i);
print_msg(pi, MSGTYPE_ERROR, "Constant %s changed value from %"PRId64" in pass1 to %"PRId64" in pass 2", next,j,i);
return (False);
}
/* OK. Definition is unchanged */
Expand Down Expand Up @@ -796,7 +797,7 @@ term_string(struct prog_info *pi, char *string)
int
parse_db(struct prog_info *pi, char *next)
{
int i;
int64_t i;
int count;
char *data;
char prev = 0;
Expand Down Expand Up @@ -831,8 +832,8 @@ parse_db(struct prog_info *pi, char *next)
if (!get_expr(pi, next, &i))
return (False);
if ((i < -128) || (i > 255))
print_msg(pi, MSGTYPE_WARNING, "Value %d is out of range (-128 <= k <= 255). Will be masked", i);
if (pi->list_on) fprintf(pi->list_file, "%02X", i);
print_msg(pi, MSGTYPE_WARNING, "Value %"PRId64" is out of range (-128 <= k <= 255). Will be masked", i);
if (pi->list_on) fprintf(pi->list_file, "%02"PRIX64, i);
}
count++;
write_db(pi, (char)i, &prev, count);
Expand Down Expand Up @@ -920,7 +921,7 @@ spool_conditional(struct prog_info *pi, int only_endif)
int
check_conditional(struct prog_info *pi, char *pbuff, int *current_depth, int *do_next, int only_endif)
{
int i = 0;
int64_t i = 0;
char *next;
char linebuff[LINEBUFFER_LENGTH];

Expand Down
Loading