-/* $Id: yasm.c,v 1.3 2001/05/21 02:15:53 peter Exp $
+/* $Id: yasm.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Program entry point, command line parsing
*
* Copyright (C) 2001 Peter Johnson
unsigned int line_number = 1;
unsigned int mode_bits = 32;
-int main(void)
+int
+main (void)
{
yydebug = 1;
yyparse();
-/* $Id: bytecode.c,v 1.12 2001/07/11 04:07:10 peter Exp $
+/* $Id: bytecode.c,v 1.13 2001/07/11 23:16:50 peter Exp $
* Bytecode utility functions
*
* Copyright (C) 2001 Peter Johnson
#include "errwarn.h"
#include "expr.h"
+/* Static structures for when NULL is passed to conversion functions. */
+/* for Convert*ToEA() */
static effaddr eff_static;
+/* for Convert*ToImm() */
static immval im_static;
+/* for Convert*ToBytes() */
unsigned char bytes_static[16];
-effaddr *ConvertIntToEA(effaddr *ptr, unsigned long int_val)
-{
- if(!ptr)
- ptr = &eff_static;
-
- ptr->segment = 0;
-
- ptr->valid_modrm = 0;
- ptr->need_modrm = 1;
- ptr->valid_sib = 0;
- ptr->need_sib = 0;
-
- /* FIXME: this will leak expr's if static is used */
- ptr->disp = expr_new_ident(EXPR_NUM, ExprNum(int_val));
+static void BuildBC_Common(bytecode *bc);
- if((int_val & 0xFF) == int_val)
- ptr->len = 1;
- else if((int_val & 0xFFFF) == int_val)
- ptr->len = 2;
- else
- ptr->len = 4;
-
- return ptr;
-}
-
-effaddr *ConvertRegToEA(effaddr *ptr, unsigned long reg)
+effaddr *
+ConvertRegToEA (effaddr *ptr, unsigned long reg)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-effaddr *ConvertExprToEA(effaddr *ptr, expr *expr_ptr)
+effaddr *
+ConvertExprToEA (effaddr *ptr, expr *expr_ptr)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-effaddr *ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len)
+effaddr *
+ConvertImmToEA (effaddr *ptr, immval *im_ptr, unsigned char im_len)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-immval *ConvertIntToImm(immval *ptr, unsigned long int_val)
+immval *
+ConvertIntToImm (immval *ptr, unsigned long int_val)
{
if(!ptr)
ptr = &im_static;
return ptr;
}
-immval *ConvertExprToImm(immval *ptr, expr *expr_ptr)
+immval *
+ConvertExprToImm (immval *ptr, expr *expr_ptr)
{
if(!ptr)
ptr = &im_static;
return ptr;
}
-void SetEASegment(effaddr *ptr, unsigned char segment)
+void
+SetEASegment (effaddr *ptr, unsigned char segment)
{
if(!ptr)
return;
ptr->segment = segment;
}
-void SetEALen(effaddr *ptr, unsigned char len)
+void
+SetEALen (effaddr *ptr, unsigned char len)
{
if(!ptr)
return;
ptr->len = len;
}
-void SetInsnOperSizeOverride(bytecode *bc, unsigned char opersize)
+void
+SetInsnOperSizeOverride (bytecode *bc, unsigned char opersize)
{
if(!bc)
return;
}
}
-void SetInsnAddrSizeOverride(bytecode *bc, unsigned char addrsize)
+void
+SetInsnAddrSizeOverride (bytecode *bc, unsigned char addrsize)
{
if(!bc)
return;
}
}
-void SetInsnLockRepPrefix(bytecode *bc, unsigned char prefix)
+void
+SetInsnLockRepPrefix (bytecode *bc, unsigned char prefix)
{
unsigned char *lockrep_pre = (unsigned char *)NULL;
*lockrep_pre = prefix;
}
-void SetOpcodeSel(jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
+void
+SetOpcodeSel (jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
{
if(!old_sel)
return;
*old_sel = new_sel;
}
-static void BuildBC_Common(bytecode *bc)
+static void
+BuildBC_Common (bytecode *bc)
{
bc->len = 0;
bc->mode_bits = mode_bits;
}
-void BuildBC_Insn(bytecode *bc,
- unsigned char opersize,
- unsigned char opcode_len,
- unsigned char op0,
- unsigned char op1,
- unsigned char op2,
- effaddr *ea_ptr,
- unsigned char spare,
- immval *im_ptr,
- unsigned char im_len,
- unsigned char im_sign)
+void
+BuildBC_Insn (bytecode *bc,
+ unsigned char opersize,
+ unsigned char opcode_len,
+ unsigned char op0,
+ unsigned char op1,
+ unsigned char op2,
+ effaddr *ea_ptr,
+ unsigned char spare,
+ immval *im_ptr,
+ unsigned char im_len,
+ unsigned char im_sign)
{
bc->next = (bytecode *)NULL;
bc->type = BC_INSN;
BuildBC_Common(bc);
}
-void BuildBC_JmpRel(bytecode *bc,
- targetval *target,
- unsigned char short_valid,
- unsigned char short_opcode_len,
- unsigned char short_op0,
- unsigned char short_op1,
- unsigned char short_op2,
- unsigned char near_valid,
- unsigned char near_opcode_len,
- unsigned char near_op0,
- unsigned char near_op1,
- unsigned char near_op2,
- unsigned char addrsize)
+void
+BuildBC_JmpRel (bytecode *bc,
+ targetval *target,
+ unsigned char short_valid,
+ unsigned char short_opcode_len,
+ unsigned char short_op0,
+ unsigned char short_op1,
+ unsigned char short_op2,
+ unsigned char near_valid,
+ unsigned char near_opcode_len,
+ unsigned char near_op0,
+ unsigned char near_op1,
+ unsigned char near_op2,
+ unsigned char addrsize)
{
bc->next = (bytecode *)NULL;
bc->type = BC_JMPREL;
}
/* TODO: implement. Shouldn't be difficult. */
-unsigned char *ConvertBCInsnToBytes(unsigned char *ptr, bytecode *bc, int *len)
+unsigned char *
+ConvertBCInsnToBytes (unsigned char *ptr, bytecode *bc, int *len)
{
if(bc->type != BC_INSN)
return (unsigned char *)NULL;
return (unsigned char *)NULL;
}
-void DebugPrintBC(bytecode *bc)
+void
+DebugPrintBC (bytecode *bc)
{
unsigned long i;
bc->filename ? bc->filename : "<UNKNOWN>", bc->lineno);
printf("Offset=%lx BITS=%u\n", bc->offset, bc->mode_bits);
}
-
-/* $Id: bytecode.h,v 1.13 2001/07/11 04:07:10 peter Exp $
+/* $Id: bytecode.h,v 1.14 2001/07/11 23:16:50 peter Exp $
* Bytecode utility functions header file
*
* Copyright (C) 2001 Peter Johnson
unsigned int mode_bits;
} bytecode;
-effaddr *ConvertIntToEA(effaddr *ptr, unsigned long int_val);
effaddr *ConvertRegToEA(effaddr *ptr, unsigned long reg);
effaddr *ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len);
effaddr *ConvertExprToEA(effaddr *ptr, struct expr_s *expr_ptr);
-/* $Id: errwarn.c,v 1.15 2001/07/11 04:07:10 peter Exp $
+/* $Id: errwarn.c,v 1.16 2001/07/11 23:16:50 peter Exp $
* Error and warning reporting and related functions.
*
* Copyright (C) 2001 Peter Johnson
#include "errwarn.h"
#include "globals.h"
+/* Total error count for entire assembler run.
+ * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
unsigned int error_count = 0;
+
+/* Total warning count for entire assembler run.
+ * Should not affect exit value of assembler. */
unsigned int warning_count = 0;
+/* See errwarn.h for constants that match up to these strings.
+ * When adding a string here, keep errwarn.h in sync! */
+
+/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
static char *fatal_msgs[] = {
"unknown",
"out of memory"
};
+/* Error messages. Match up with err_num enum in errwarn.h. */
static char *err_msgs[] = {
"",
"parser error: %s",
"no %s form of that jump instruction exists"
};
+/* Warning messages. Match up with warn_num enum in errwarn.h. */
static char *warn_msgs[] = {
"",
"ignoring unrecognized character '%s'",
"multiple SHORT or NEAR specifiers, using leftmost"
};
-/* hate to define these as static buffers; better solution would be to use
- * vasprintf() to dynamically allocate, but that's not ANSI C */
+/* I hate to define these strings as static buffers; a better solution would be
+ * to use vasprintf() to dynamically allocate, but that's not ANSI C.
+ * FIXME! */
+
+/* Last error message string. Set by Error(), read by OutputError(). */
static char last_err[1024];
+
+/* Last warning message string. Set by Warning(), read by OutputWarning(). */
static char last_warn[1024];
+
+/* Last error number. Set by Error(), read and reset by OutputError(). */
static err_num last_err_num = ERR_NONE;
+
+/* Last warning number. Set by Warning(), read and reset by
+ * OutputWarning(). */
static warn_num last_warn_num = WARN_NONE;
-/* conv_unprint: convert a possibly unprintable character into a printable
- * string, using standard cat(1) convention for unprintable characters. */
+/* Static buffer for use by conv_unprint(). */
static char unprint[5];
-char *conv_unprint(char ch)
+
+/* Convert a possibly unprintable character into a printable string, using
+ * standard cat(1) convention for unprintable characters. */
+char *
+conv_unprint (char ch)
{
int pos=0;
return unprint;
}
-/* yyerror: parser error handler */
-void yyerror(char *s)
+/* Parser error handler. Moves error into our error handling system. */
+void
+yyerror (char *s)
{
Error(ERR_PARSER, (char *)NULL, s);
}
-void InternalError(unsigned int line, char *file, char *message)
+/* Report an internal error. Essentially a fatal error with trace info.
+ * Exit immediately because it's essentially an assert() trap. */
+void
+InternalError (unsigned int line, char *file, char *message)
{
fprintf(stderr, "INTERNAL ERROR at %s, line %d: %s\n", file, line,
message);
exit(EXIT_FAILURE);
}
-void Fatal(fatal_num num)
+/* Report a fatal error. These are unrecoverable (such as running out of
+ * memory), so just exit immediately. */
+void
+Fatal (fatal_num num)
{
fprintf(stderr, "FATAL: %s\n", fatal_msgs[num]);
exit(EXIT_FAILURE);
}
-/* replace %1, %2, etc in src with %c, %s, etc. in argtypes. */
-/* currently limits maximum number of args to 9 (%1-%9). */
-static char *process_argtypes(char *src, char *argtypes)
+/* Argument replacement function for use in error messages.
+ * Replaces %1, %2, etc in src with %c, %s, etc. in argtypes.
+ * Currently limits maximum number of args to 9 (%1-%9).
+ *
+ * We need this because messages that take multiple arguments become dependent
+ * on the order and type of the arguments passed to Error()/Warning().
+ *
+ * i.e. an error string "'%d' is not a valid specifier for '%s'" would require
+ * that the arguments passed to Error() always be an int and a char *, in that
+ * order. If the string was changed to be "'%s': invalid specifier '%d'", all
+ * the times Error() was called for that string would need to be changed to
+ * reorder the arguments. Or if the %d was not right in some circumstances,
+ * we'd have to add another string for that type.
+ *
+ * This function fixes this problem by allowing the string to be specified as
+ * "'%1' is not a valid specifier for '%2'" and then specifying at the time of
+ * the Error() call what the types of %1 and %2 are by passing a argtype string
+ * "%d%s" (to emulate the first behavior). If the string was changed to be
+ * "'%2': invalid specifier '%1'", no change would need to be made to the
+ * Error calls using that string. And as the type is specified with the
+ * argument list, mismatches are far less likely.
+ *
+ * For strings that only have one argument of a fixed type, it can be directly
+ * specified and NULL passed for the argtypes parameter when Error() is
+ * called. */
+static char *
+process_argtypes (char *src, char *argtypes)
{
char *dest;
char *argtype[9];
return dest;
}
-void Error(err_num num, char *argtypes, ...)
+/* Register an error. Uses argtypes as described above to specify the
+ * argument types. Does not print the error, only stores it for
+ * OutputError() to print. */
+void
+Error (err_num num, char *argtypes, ...)
{
va_list ap;
char *printf_str;
error_count++;
}
-void Warning(warn_num num, char *argtypes, ...)
+/* Register a warning. Uses argtypes as described above to specify the
+ * argument types. Does not print the warning, only stores it for
+ * OutputWarning() to print. */
+void
+Warning (warn_num num, char *argtypes, ...)
{
va_list ap;
char *printf_str;
warning_count++;
}
-void OutputError(void)
+/* Output a previously stored error (if any) to stderr. */
+void
+OutputError (void)
{
if(last_err_num != ERR_NONE)
fprintf(stderr, "filename:%u: %s\n", line_number, last_err);
last_err_num = ERR_NONE;
}
-void OutputWarning(void)
+/* Output a previously stored warning (if any) to stderr. */
+void
+OutputWarning (void)
{
if(last_warn_num != WARN_NONE)
fprintf(stderr, "filename:%u: warning: %s\n", line_number, last_warn);
-/* $Id: errwarn.h,v 1.9 2001/07/11 04:07:10 peter Exp $
+/* $Id: errwarn.h,v 1.10 2001/07/11 23:16:50 peter Exp $
* Error and warning reporting and related functions header file.
*
* Copyright (C) 2001 Peter Johnson
#ifndef YASM_ERRWARN_H
#define YASM_ERRWARN_H
-char *conv_unprint(char ch);
+/* See errwarn.c for strings that match up to these constants.
+ * When adding a constant here, keep errwarn.c in sync! */
+/* Fatal error constants. Match up with fatal_msgs in errwarn.c. */
typedef enum {
FATAL_UNKNOWN = 0,
FATAL_NOMEM
} fatal_num;
-void InternalError(unsigned int line, char *file, char *message);
-void Fatal(fatal_num);
-
+/* Error constants. Match up with err_msgs in errwarn.c. */
+/* FIXME: These shouldn't be ERR_* because they'll violate namespace
+ * constraints if errno.h is included. */
typedef enum {
ERR_NONE = 0,
ERR_PARSER,
ERR_NO_JMPREL_FORM
} err_num;
-void Error(err_num, char *, ...);
-
+/* Warning constants. Match up with warn_msgs in errwarn.c. */
typedef enum {
WARN_NONE = 0,
WARN_UNREC_CHAR,
WARN_MULT_SHORTNEAR
} warn_num;
+char *conv_unprint(char ch);
+
+void InternalError(unsigned int line, char *file, char *message);
+
+void Fatal(fatal_num);
+void Error(err_num, char *, ...);
void Warning(warn_num, char *, ...);
void OutputError(void);
-/* $Id: expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: expr.h,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.h,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling header file
*
* Copyright (C) 2001 Michael Urman
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _EXPR_H_
-#define _EXPR_H_
+#ifndef YASM_EXPR_H
+#define YASM_EXPR_H
typedef enum {
EXPR_ADD,
ExprItem ExprSym (struct symrec_s *);
ExprItem ExprExpr (expr *);
ExprItem ExprNum (unsigned long);
-ExprItem ExprNone ();
+ExprItem ExprNone (void);
#define expr_new_tree(l,o,r) \
expr_new (EXPR_EXPR, ExprExpr(l), (o), EXPR_EXPR, ExprExpr(r))
-/* $Id: symrec.c,v 1.4 2001/07/04 20:57:53 peter Exp $
+/* $Id: symrec.c,v 1.5 2001/07/11 23:16:50 peter Exp $
* Symbol table handling
*
* Copyright (C) 2001 Michael Urman
symtab *sym_table = (symtab *)NULL;
/* insert a symtab into the global sym_table */
-void symtab_insert (symtab *tab)
+void
+symtab_insert (symtab *tab)
{
tab->next = (symtab *)sym_table;
sym_table = tab;
}
/* find a symtab in the global sym_table */
-symtab *symtab_get (char *name)
+symtab *
+symtab_get (char *name)
{
symtab *tab;
for (tab = sym_table; tab != NULL; tab = tab->next)
}
/* call a function with each symrec. stop early if 0 returned */
-void sym_foreach (int(*mapfunc)(symrec *))
+void
+sym_foreach (int(*mapfunc)(symrec *))
{
symtab *tab;
for (tab = sym_table; tab != NULL; tab = tab->next)
}
/* create a new symtab */
-symtab *symtab_new (char *name, SymType type)
+symtab *
+symtab_new (char *name, SymType type)
{
symtab *tab;
tab = malloc(sizeof(symtab));
return tab;
}
-symtab *symtab_get_or_new (char *name, SymType type)
+symtab *
+symtab_get_or_new (char *name, SymType type)
{
symtab *tab;
tab = symtab_get (name);
return tab;
}
-symrec *sym_use_get (char *name, SymType type)
+symrec *
+sym_use_get (char *name, SymType type)
{
symtab *tab;
tab = symtab_get_or_new (name, type);
return &(tab->rec);
}
-symrec *sym_def_get (char *name, SymType type)
+symrec *
+sym_def_get (char *name, SymType type)
{
symtab *tab;
tab = symtab_get_or_new (name, type);
}
#if 0
-symrec *putsym(char *sym_name, int sym_type)
+symrec *
+putsym (char *sym_name, int sym_type)
{
symrec *ptr;
ptr = malloc(sizeof(symrec));
return ptr;
}
-symrec *getsym(char *sym_name)
+symrec *
+getsym (char *sym_name)
{
symrec *ptr;
for(ptr=sym_table; ptr != (symrec *)NULL; ptr=(symrec *)ptr->next)
-/* $Id: expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: x86expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: x86expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: x86expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: x86expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: bytecode.c,v 1.12 2001/07/11 04:07:10 peter Exp $
+/* $Id: bytecode.c,v 1.13 2001/07/11 23:16:50 peter Exp $
* Bytecode utility functions
*
* Copyright (C) 2001 Peter Johnson
#include "errwarn.h"
#include "expr.h"
+/* Static structures for when NULL is passed to conversion functions. */
+/* for Convert*ToEA() */
static effaddr eff_static;
+/* for Convert*ToImm() */
static immval im_static;
+/* for Convert*ToBytes() */
unsigned char bytes_static[16];
-effaddr *ConvertIntToEA(effaddr *ptr, unsigned long int_val)
-{
- if(!ptr)
- ptr = &eff_static;
-
- ptr->segment = 0;
-
- ptr->valid_modrm = 0;
- ptr->need_modrm = 1;
- ptr->valid_sib = 0;
- ptr->need_sib = 0;
-
- /* FIXME: this will leak expr's if static is used */
- ptr->disp = expr_new_ident(EXPR_NUM, ExprNum(int_val));
+static void BuildBC_Common(bytecode *bc);
- if((int_val & 0xFF) == int_val)
- ptr->len = 1;
- else if((int_val & 0xFFFF) == int_val)
- ptr->len = 2;
- else
- ptr->len = 4;
-
- return ptr;
-}
-
-effaddr *ConvertRegToEA(effaddr *ptr, unsigned long reg)
+effaddr *
+ConvertRegToEA (effaddr *ptr, unsigned long reg)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-effaddr *ConvertExprToEA(effaddr *ptr, expr *expr_ptr)
+effaddr *
+ConvertExprToEA (effaddr *ptr, expr *expr_ptr)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-effaddr *ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len)
+effaddr *
+ConvertImmToEA (effaddr *ptr, immval *im_ptr, unsigned char im_len)
{
if(!ptr)
ptr = &eff_static;
return ptr;
}
-immval *ConvertIntToImm(immval *ptr, unsigned long int_val)
+immval *
+ConvertIntToImm (immval *ptr, unsigned long int_val)
{
if(!ptr)
ptr = &im_static;
return ptr;
}
-immval *ConvertExprToImm(immval *ptr, expr *expr_ptr)
+immval *
+ConvertExprToImm (immval *ptr, expr *expr_ptr)
{
if(!ptr)
ptr = &im_static;
return ptr;
}
-void SetEASegment(effaddr *ptr, unsigned char segment)
+void
+SetEASegment (effaddr *ptr, unsigned char segment)
{
if(!ptr)
return;
ptr->segment = segment;
}
-void SetEALen(effaddr *ptr, unsigned char len)
+void
+SetEALen (effaddr *ptr, unsigned char len)
{
if(!ptr)
return;
ptr->len = len;
}
-void SetInsnOperSizeOverride(bytecode *bc, unsigned char opersize)
+void
+SetInsnOperSizeOverride (bytecode *bc, unsigned char opersize)
{
if(!bc)
return;
}
}
-void SetInsnAddrSizeOverride(bytecode *bc, unsigned char addrsize)
+void
+SetInsnAddrSizeOverride (bytecode *bc, unsigned char addrsize)
{
if(!bc)
return;
}
}
-void SetInsnLockRepPrefix(bytecode *bc, unsigned char prefix)
+void
+SetInsnLockRepPrefix (bytecode *bc, unsigned char prefix)
{
unsigned char *lockrep_pre = (unsigned char *)NULL;
*lockrep_pre = prefix;
}
-void SetOpcodeSel(jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
+void
+SetOpcodeSel (jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
{
if(!old_sel)
return;
*old_sel = new_sel;
}
-static void BuildBC_Common(bytecode *bc)
+static void
+BuildBC_Common (bytecode *bc)
{
bc->len = 0;
bc->mode_bits = mode_bits;
}
-void BuildBC_Insn(bytecode *bc,
- unsigned char opersize,
- unsigned char opcode_len,
- unsigned char op0,
- unsigned char op1,
- unsigned char op2,
- effaddr *ea_ptr,
- unsigned char spare,
- immval *im_ptr,
- unsigned char im_len,
- unsigned char im_sign)
+void
+BuildBC_Insn (bytecode *bc,
+ unsigned char opersize,
+ unsigned char opcode_len,
+ unsigned char op0,
+ unsigned char op1,
+ unsigned char op2,
+ effaddr *ea_ptr,
+ unsigned char spare,
+ immval *im_ptr,
+ unsigned char im_len,
+ unsigned char im_sign)
{
bc->next = (bytecode *)NULL;
bc->type = BC_INSN;
BuildBC_Common(bc);
}
-void BuildBC_JmpRel(bytecode *bc,
- targetval *target,
- unsigned char short_valid,
- unsigned char short_opcode_len,
- unsigned char short_op0,
- unsigned char short_op1,
- unsigned char short_op2,
- unsigned char near_valid,
- unsigned char near_opcode_len,
- unsigned char near_op0,
- unsigned char near_op1,
- unsigned char near_op2,
- unsigned char addrsize)
+void
+BuildBC_JmpRel (bytecode *bc,
+ targetval *target,
+ unsigned char short_valid,
+ unsigned char short_opcode_len,
+ unsigned char short_op0,
+ unsigned char short_op1,
+ unsigned char short_op2,
+ unsigned char near_valid,
+ unsigned char near_opcode_len,
+ unsigned char near_op0,
+ unsigned char near_op1,
+ unsigned char near_op2,
+ unsigned char addrsize)
{
bc->next = (bytecode *)NULL;
bc->type = BC_JMPREL;
}
/* TODO: implement. Shouldn't be difficult. */
-unsigned char *ConvertBCInsnToBytes(unsigned char *ptr, bytecode *bc, int *len)
+unsigned char *
+ConvertBCInsnToBytes (unsigned char *ptr, bytecode *bc, int *len)
{
if(bc->type != BC_INSN)
return (unsigned char *)NULL;
return (unsigned char *)NULL;
}
-void DebugPrintBC(bytecode *bc)
+void
+DebugPrintBC (bytecode *bc)
{
unsigned long i;
bc->filename ? bc->filename : "<UNKNOWN>", bc->lineno);
printf("Offset=%lx BITS=%u\n", bc->offset, bc->mode_bits);
}
-
-/* $Id: bytecode.h,v 1.13 2001/07/11 04:07:10 peter Exp $
+/* $Id: bytecode.h,v 1.14 2001/07/11 23:16:50 peter Exp $
* Bytecode utility functions header file
*
* Copyright (C) 2001 Peter Johnson
unsigned int mode_bits;
} bytecode;
-effaddr *ConvertIntToEA(effaddr *ptr, unsigned long int_val);
effaddr *ConvertRegToEA(effaddr *ptr, unsigned long reg);
effaddr *ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len);
effaddr *ConvertExprToEA(effaddr *ptr, struct expr_s *expr_ptr);
-/* $Id: errwarn.c,v 1.15 2001/07/11 04:07:10 peter Exp $
+/* $Id: errwarn.c,v 1.16 2001/07/11 23:16:50 peter Exp $
* Error and warning reporting and related functions.
*
* Copyright (C) 2001 Peter Johnson
#include "errwarn.h"
#include "globals.h"
+/* Total error count for entire assembler run.
+ * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
unsigned int error_count = 0;
+
+/* Total warning count for entire assembler run.
+ * Should not affect exit value of assembler. */
unsigned int warning_count = 0;
+/* See errwarn.h for constants that match up to these strings.
+ * When adding a string here, keep errwarn.h in sync! */
+
+/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
static char *fatal_msgs[] = {
"unknown",
"out of memory"
};
+/* Error messages. Match up with err_num enum in errwarn.h. */
static char *err_msgs[] = {
"",
"parser error: %s",
"no %s form of that jump instruction exists"
};
+/* Warning messages. Match up with warn_num enum in errwarn.h. */
static char *warn_msgs[] = {
"",
"ignoring unrecognized character '%s'",
"multiple SHORT or NEAR specifiers, using leftmost"
};
-/* hate to define these as static buffers; better solution would be to use
- * vasprintf() to dynamically allocate, but that's not ANSI C */
+/* I hate to define these strings as static buffers; a better solution would be
+ * to use vasprintf() to dynamically allocate, but that's not ANSI C.
+ * FIXME! */
+
+/* Last error message string. Set by Error(), read by OutputError(). */
static char last_err[1024];
+
+/* Last warning message string. Set by Warning(), read by OutputWarning(). */
static char last_warn[1024];
+
+/* Last error number. Set by Error(), read and reset by OutputError(). */
static err_num last_err_num = ERR_NONE;
+
+/* Last warning number. Set by Warning(), read and reset by
+ * OutputWarning(). */
static warn_num last_warn_num = WARN_NONE;
-/* conv_unprint: convert a possibly unprintable character into a printable
- * string, using standard cat(1) convention for unprintable characters. */
+/* Static buffer for use by conv_unprint(). */
static char unprint[5];
-char *conv_unprint(char ch)
+
+/* Convert a possibly unprintable character into a printable string, using
+ * standard cat(1) convention for unprintable characters. */
+char *
+conv_unprint (char ch)
{
int pos=0;
return unprint;
}
-/* yyerror: parser error handler */
-void yyerror(char *s)
+/* Parser error handler. Moves error into our error handling system. */
+void
+yyerror (char *s)
{
Error(ERR_PARSER, (char *)NULL, s);
}
-void InternalError(unsigned int line, char *file, char *message)
+/* Report an internal error. Essentially a fatal error with trace info.
+ * Exit immediately because it's essentially an assert() trap. */
+void
+InternalError (unsigned int line, char *file, char *message)
{
fprintf(stderr, "INTERNAL ERROR at %s, line %d: %s\n", file, line,
message);
exit(EXIT_FAILURE);
}
-void Fatal(fatal_num num)
+/* Report a fatal error. These are unrecoverable (such as running out of
+ * memory), so just exit immediately. */
+void
+Fatal (fatal_num num)
{
fprintf(stderr, "FATAL: %s\n", fatal_msgs[num]);
exit(EXIT_FAILURE);
}
-/* replace %1, %2, etc in src with %c, %s, etc. in argtypes. */
-/* currently limits maximum number of args to 9 (%1-%9). */
-static char *process_argtypes(char *src, char *argtypes)
+/* Argument replacement function for use in error messages.
+ * Replaces %1, %2, etc in src with %c, %s, etc. in argtypes.
+ * Currently limits maximum number of args to 9 (%1-%9).
+ *
+ * We need this because messages that take multiple arguments become dependent
+ * on the order and type of the arguments passed to Error()/Warning().
+ *
+ * i.e. an error string "'%d' is not a valid specifier for '%s'" would require
+ * that the arguments passed to Error() always be an int and a char *, in that
+ * order. If the string was changed to be "'%s': invalid specifier '%d'", all
+ * the times Error() was called for that string would need to be changed to
+ * reorder the arguments. Or if the %d was not right in some circumstances,
+ * we'd have to add another string for that type.
+ *
+ * This function fixes this problem by allowing the string to be specified as
+ * "'%1' is not a valid specifier for '%2'" and then specifying at the time of
+ * the Error() call what the types of %1 and %2 are by passing a argtype string
+ * "%d%s" (to emulate the first behavior). If the string was changed to be
+ * "'%2': invalid specifier '%1'", no change would need to be made to the
+ * Error calls using that string. And as the type is specified with the
+ * argument list, mismatches are far less likely.
+ *
+ * For strings that only have one argument of a fixed type, it can be directly
+ * specified and NULL passed for the argtypes parameter when Error() is
+ * called. */
+static char *
+process_argtypes (char *src, char *argtypes)
{
char *dest;
char *argtype[9];
return dest;
}
-void Error(err_num num, char *argtypes, ...)
+/* Register an error. Uses argtypes as described above to specify the
+ * argument types. Does not print the error, only stores it for
+ * OutputError() to print. */
+void
+Error (err_num num, char *argtypes, ...)
{
va_list ap;
char *printf_str;
error_count++;
}
-void Warning(warn_num num, char *argtypes, ...)
+/* Register a warning. Uses argtypes as described above to specify the
+ * argument types. Does not print the warning, only stores it for
+ * OutputWarning() to print. */
+void
+Warning (warn_num num, char *argtypes, ...)
{
va_list ap;
char *printf_str;
warning_count++;
}
-void OutputError(void)
+/* Output a previously stored error (if any) to stderr. */
+void
+OutputError (void)
{
if(last_err_num != ERR_NONE)
fprintf(stderr, "filename:%u: %s\n", line_number, last_err);
last_err_num = ERR_NONE;
}
-void OutputWarning(void)
+/* Output a previously stored warning (if any) to stderr. */
+void
+OutputWarning (void)
{
if(last_warn_num != WARN_NONE)
fprintf(stderr, "filename:%u: warning: %s\n", line_number, last_warn);
-/* $Id: errwarn.h,v 1.9 2001/07/11 04:07:10 peter Exp $
+/* $Id: errwarn.h,v 1.10 2001/07/11 23:16:50 peter Exp $
* Error and warning reporting and related functions header file.
*
* Copyright (C) 2001 Peter Johnson
#ifndef YASM_ERRWARN_H
#define YASM_ERRWARN_H
-char *conv_unprint(char ch);
+/* See errwarn.c for strings that match up to these constants.
+ * When adding a constant here, keep errwarn.c in sync! */
+/* Fatal error constants. Match up with fatal_msgs in errwarn.c. */
typedef enum {
FATAL_UNKNOWN = 0,
FATAL_NOMEM
} fatal_num;
-void InternalError(unsigned int line, char *file, char *message);
-void Fatal(fatal_num);
-
+/* Error constants. Match up with err_msgs in errwarn.c. */
+/* FIXME: These shouldn't be ERR_* because they'll violate namespace
+ * constraints if errno.h is included. */
typedef enum {
ERR_NONE = 0,
ERR_PARSER,
ERR_NO_JMPREL_FORM
} err_num;
-void Error(err_num, char *, ...);
-
+/* Warning constants. Match up with warn_msgs in errwarn.c. */
typedef enum {
WARN_NONE = 0,
WARN_UNREC_CHAR,
WARN_MULT_SHORTNEAR
} warn_num;
+char *conv_unprint(char ch);
+
+void InternalError(unsigned int line, char *file, char *message);
+
+void Fatal(fatal_num);
+void Error(err_num, char *, ...);
void Warning(warn_num, char *, ...);
void OutputError(void);
-/* $Id: expr.c,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling
*
* Copyright (C) 2001 Michael Urman
/* allocate a new expression node, with children as defined.
* If it's a unary operator, put the element on the right */
-expr *expr_new (ExprType ltype,
- ExprItem left,
- ExprOp op,
- ExprType rtype,
- ExprItem right)
+expr *
+expr_new (ExprType ltype,
+ ExprItem left,
+ ExprOp op,
+ ExprType rtype,
+ ExprItem right)
{
expr *ptr;
ptr = malloc (sizeof (expr));
}
/* helpers */
-ExprItem ExprSym (struct symrec_s *s) { ExprItem e; e.sym = s; return e; }
-ExprItem ExprExpr (expr *x) { ExprItem e; e.expr = x; return e; }
-ExprItem ExprNum (unsigned long n) { ExprItem e; e.num = n; return e; }
-ExprItem ExprNone () { ExprItem e; e.num = 0; return e; }
+ExprItem
+ExprSym (struct symrec_s *s)
+{
+ ExprItem e;
+ e.sym = s;
+ return e;
+}
+
+ExprItem
+ExprExpr (expr *x)
+{
+ ExprItem e;
+ e.expr = x;
+ return e;
+}
+
+ExprItem
+ExprNum (unsigned long n)
+{
+ ExprItem e;
+ e.num = n;
+ return e;
+}
+
+ExprItem
+ExprNone (void)
+{
+ ExprItem e;
+ e.num = 0;
+ return e;
+}
/* get rid of unnecessary branches if possible. report. */
-int expr_simplify (expr *e)
+int
+expr_simplify (expr *e)
{
int simplified = 0;
return simplified;
}
-int expr_get_value (expr *e, unsigned long *retval)
+int
+expr_get_value (expr *e, unsigned long *retval)
{
while (!(e->op == EXPR_IDENT && e->rtype == EXPR_NUM)
&& expr_simplify (e));
return 0;
}
-void expr_print (expr *e)
+void
+expr_print (expr *e)
{
if (e->op != EXPR_IDENT) {
switch (e->ltype) {
-/* $Id: expr.h,v 1.3 2001/07/05 09:32:58 mu Exp $
+/* $Id: expr.h,v 1.4 2001/07/11 23:16:50 peter Exp $
* Expression handling header file
*
* Copyright (C) 2001 Michael Urman
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _EXPR_H_
-#define _EXPR_H_
+#ifndef YASM_EXPR_H
+#define YASM_EXPR_H
typedef enum {
EXPR_ADD,
ExprItem ExprSym (struct symrec_s *);
ExprItem ExprExpr (expr *);
ExprItem ExprNum (unsigned long);
-ExprItem ExprNone ();
+ExprItem ExprNone (void);
#define expr_new_tree(l,o,r) \
expr_new (EXPR_EXPR, ExprExpr(l), (o), EXPR_EXPR, ExprExpr(r))
-/* $Id: main.c,v 1.3 2001/05/21 02:15:53 peter Exp $
+/* $Id: main.c,v 1.4 2001/07/11 23:16:50 peter Exp $
* Program entry point, command line parsing
*
* Copyright (C) 2001 Peter Johnson
unsigned int line_number = 1;
unsigned int mode_bits = 32;
-int main(void)
+int
+main (void)
{
yydebug = 1;
yyparse();
-/* $Id: symrec.c,v 1.4 2001/07/04 20:57:53 peter Exp $
+/* $Id: symrec.c,v 1.5 2001/07/11 23:16:50 peter Exp $
* Symbol table handling
*
* Copyright (C) 2001 Michael Urman
symtab *sym_table = (symtab *)NULL;
/* insert a symtab into the global sym_table */
-void symtab_insert (symtab *tab)
+void
+symtab_insert (symtab *tab)
{
tab->next = (symtab *)sym_table;
sym_table = tab;
}
/* find a symtab in the global sym_table */
-symtab *symtab_get (char *name)
+symtab *
+symtab_get (char *name)
{
symtab *tab;
for (tab = sym_table; tab != NULL; tab = tab->next)
}
/* call a function with each symrec. stop early if 0 returned */
-void sym_foreach (int(*mapfunc)(symrec *))
+void
+sym_foreach (int(*mapfunc)(symrec *))
{
symtab *tab;
for (tab = sym_table; tab != NULL; tab = tab->next)
}
/* create a new symtab */
-symtab *symtab_new (char *name, SymType type)
+symtab *
+symtab_new (char *name, SymType type)
{
symtab *tab;
tab = malloc(sizeof(symtab));
return tab;
}
-symtab *symtab_get_or_new (char *name, SymType type)
+symtab *
+symtab_get_or_new (char *name, SymType type)
{
symtab *tab;
tab = symtab_get (name);
return tab;
}
-symrec *sym_use_get (char *name, SymType type)
+symrec *
+sym_use_get (char *name, SymType type)
{
symtab *tab;
tab = symtab_get_or_new (name, type);
return &(tab->rec);
}
-symrec *sym_def_get (char *name, SymType type)
+symrec *
+sym_def_get (char *name, SymType type)
{
symtab *tab;
tab = symtab_get_or_new (name, type);
}
#if 0
-symrec *putsym(char *sym_name, int sym_type)
+symrec *
+putsym (char *sym_name, int sym_type)
{
symrec *ptr;
ptr = malloc(sizeof(symrec));
return ptr;
}
-symrec *getsym(char *sym_name)
+symrec *
+getsym (char *sym_name)
{
symrec *ptr;
for(ptr=sym_table; ptr != (symrec *)NULL; ptr=(symrec *)ptr->next)