From: Peter Johnson Date: Wed, 11 Jul 2001 16:57:25 +0000 (-0000) Subject: Repo-copied include files to src to make automake/autoconf build structure X-Git-Tag: v0.1.0~391 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06cce4e4cdf0f8f34d54b2486816eeb300dd33f5;p=yasm Repo-copied include files to src to make automake/autoconf build structure work properly. Changed Makefile.am, src/Makefile.am, and configure.in to match directory changes. svn path=/trunk/yasm/; revision=120 --- diff --git a/Makefile.am b/Makefile.am index c74acb44..59deea70 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1,2 @@ -SUBDIRS = include src +SUBDIRS = src +EXTRA_DIST = config/install-sh config/missing config/mkinstalldirs diff --git a/configure.ac b/configure.ac index b23d581b..1d0b9c6d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(config) -AM_CONFIG_HEADER(include/config.h) +AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(yasm, 0.0.1) @@ -30,4 +30,4 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS(memcpy toascii) AC_REPLACE_FUNCS(strdup strtoul) -AC_OUTPUT(Makefile src/Makefile include/Makefile) +AC_OUTPUT(Makefile src/Makefile) diff --git a/configure.in b/configure.in index b23d581b..1d0b9c6d 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(config) -AM_CONFIG_HEADER(include/config.h) +AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(yasm, 0.0.1) @@ -30,4 +30,4 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS(memcpy toascii) AC_REPLACE_FUNCS(strdup strtoul) -AC_OUTPUT(Makefile src/Makefile include/Makefile) +AC_OUTPUT(Makefile src/Makefile) diff --git a/include/.cvsignore b/include/.cvsignore deleted file mode 100644 index e9471d26..00000000 --- a/include/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.*.sw? -*.in -Makefile -stamp-h -config.h diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 62832edd..00000000 --- a/include/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST = \ - bytecode.h \ - errwarn.h \ - expr.h \ - globals.h \ - section.h \ - symrec.h \ - util.h diff --git a/include/bytecode.h b/include/bytecode.h deleted file mode 100644 index 21592850..00000000 --- a/include/bytecode.h +++ /dev/null @@ -1,162 +0,0 @@ -/* $Id: bytecode.h,v 1.13 2001/07/11 04:07:10 peter Exp $ - * Bytecode utility functions header file - * - * Copyright (C) 2001 Peter Johnson - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_BYTECODE_H -#define YASM_BYTECODE_H - -typedef struct effaddr_s { - struct expr_s *disp; /* address displacement */ - unsigned char len; /* length of disp (in bytes), 0 if none */ - - unsigned char segment; /* segment override, 0 if none */ - - unsigned char modrm; - unsigned char valid_modrm; /* 1 if Mod/RM byte currently valid, 0 if not */ - unsigned char need_modrm; /* 1 if Mod/RM byte needed, 0 if not */ - - unsigned char sib; - unsigned char valid_sib; /* 1 if SIB byte currently valid, 0 if not */ - unsigned char need_sib; /* 1 if SIB byte needed, 0 if not */ -} effaddr; - -typedef struct immval_s { - struct expr_s *val; - - unsigned char len; /* length of val (in bytes), 0 if none */ - unsigned char isneg; /* the value has been explicitly negated */ - - unsigned char f_len; /* final imm length */ - unsigned char f_sign; /* 1 if final imm should be signed */ -} immval; - -typedef enum jmprel_opcode_sel_e { - JR_NONE, - JR_SHORT, - JR_NEAR, - JR_SHORT_FORCED, - JR_NEAR_FORCED -} jmprel_opcode_sel; - -typedef struct targetval_s { - struct expr_s *val; - - jmprel_opcode_sel op_sel; -} targetval; - -typedef struct bytecode_s { - struct bytecode_s *next; - - enum { BC_INSN, BC_JMPREL, BC_DATA, BC_RESERVE } type; - - union { - struct { - effaddr ea; /* effective address */ - - immval imm; /* immediate or relative value */ - - unsigned char opcode[3]; /* opcode */ - unsigned char opcode_len; - - unsigned char addrsize; /* 0 indicates no override */ - unsigned char opersize; /* 0 indicates no override */ - unsigned char lockrep_pre; /* 0 indicates no prefix */ - } insn; - struct { - struct expr_s *target; /* target location */ - - struct { - unsigned char opcode[3]; - unsigned char opcode_len; - unsigned char valid; /* does the opcode exist? */ - } shortop, nearop; - - /* which opcode are we using? */ - /* The *FORCED forms are specified in the source as such */ - jmprel_opcode_sel op_sel; - - unsigned char addrsize; /* 0 indicates no override */ - unsigned char opersize; /* 0 indicates no override */ - unsigned char lockrep_pre; /* 0 indicates no prefix */ - } jmprel; - struct { - unsigned char *data; - } data; - } data; - - unsigned long len; /* total length of entire bytecode */ - - /* where it came from */ - char *filename; - unsigned int lineno; - - /* other assembler state info */ - unsigned long offset; - 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); - -immval *ConvertIntToImm(immval *ptr, unsigned long int_val); -immval *ConvertExprToImm(immval *ptr, struct expr_s *expr_ptr); - -void SetEASegment(effaddr *ptr, unsigned char segment); -void SetEALen(effaddr *ptr, unsigned char len); - -void SetInsnOperSizeOverride(bytecode *bc, unsigned char opersize); -void SetInsnAddrSizeOverride(bytecode *bc, unsigned char addrsize); -void SetInsnLockRepPrefix(bytecode *bc, unsigned char prefix); - -void SetOpcodeSel(jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel); - -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_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); - -unsigned char *ConvertBCInsnToBytes(unsigned char *ptr, bytecode *bc, int *len); - -void DebugPrintBC(bytecode *bc); - -#endif diff --git a/include/errwarn.h b/include/errwarn.h deleted file mode 100644 index 66098a9d..00000000 --- a/include/errwarn.h +++ /dev/null @@ -1,66 +0,0 @@ -/* $Id: errwarn.h,v 1.9 2001/07/11 04:07:10 peter Exp $ - * Error and warning reporting and related functions header file. - * - * Copyright (C) 2001 Peter Johnson - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_ERRWARN_H -#define YASM_ERRWARN_H - -char *conv_unprint(char ch); - -typedef enum { - FATAL_UNKNOWN = 0, - FATAL_NOMEM -} fatal_num; - -void InternalError(unsigned int line, char *file, char *message); -void Fatal(fatal_num); - -typedef enum { - ERR_NONE = 0, - ERR_PARSER, - ERR_MISSING, - ERR_MISSING_ARG, - ERR_INVALID_ARG, - ERR_INVALID_EA, - ERR_INVALID_LINE, - ERR_EXP_SYNTAX, - ERR_DUPLICATE_DEF, - ERR_OP_SIZE_MISMATCH, - ERR_NO_JMPREL_FORM -} err_num; - -void Error(err_num, char *, ...); - -typedef enum { - WARN_NONE = 0, - WARN_UNREC_CHAR, - WARN_VALUE_EXCEEDS_BOUNDS, - WARN_MULT_SEG_OVERRIDE, - WARN_MULT_LOCKREP_PREFIX, - WARN_NO_BASE_LABEL, - WARN_MULT_SHORTNEAR -} warn_num; - -void Warning(warn_num, char *, ...); - -void OutputError(void); -void OutputWarning(void); - -#endif diff --git a/include/expr.h b/include/expr.h deleted file mode 100644 index 8878d71d..00000000 --- a/include/expr.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: expr.h,v 1.3 2001/07/05 09:32:58 mu Exp $ - * Expression handling header file - * - * Copyright (C) 2001 Michael Urman - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * 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_ - -typedef enum { - EXPR_ADD, - EXPR_SUB, - EXPR_MUL, - EXPR_DIV, - EXPR_MOD, - EXPR_NEG, - EXPR_NOT, - EXPR_OR, - EXPR_AND, - EXPR_XOR, - EXPR_SHL, - EXPR_SHR, - EXPR_LOR, - EXPR_LAND, - EXPR_LNOT, - EXPR_LT, - EXPR_GT, - EXPR_EQ, - EXPR_LE, - EXPR_GE, - EXPR_NE, - EXPR_IDENT /* if right is IDENT, then the entire expr is just a num */ -} ExprOp; - -typedef enum { - EXPR_NONE, /* for left side of a NOT, NEG, etc. */ - EXPR_NUM, - EXPR_EXPR, - EXPR_SYM -} ExprType; - -typedef union expritem_u { - struct symrec_s *sym; - struct expr_s *expr; - unsigned long num; -} ExprItem; - -typedef struct expr_s { - ExprType ltype, rtype; - ExprItem left, right; - ExprOp op; -} expr; - -expr *expr_new (ExprType, ExprItem, ExprOp, ExprType, ExprItem); - -ExprItem ExprSym (struct symrec_s *); -ExprItem ExprExpr (expr *); -ExprItem ExprNum (unsigned long); -ExprItem ExprNone (); - -#define expr_new_tree(l,o,r) \ - expr_new (EXPR_EXPR, ExprExpr(l), (o), EXPR_EXPR, ExprExpr(r)) -#define expr_new_branch(o,r) \ - expr_new (EXPR_NONE, ExprNone(), (o), EXPR_EXPR, ExprExpr(r)) -#define expr_new_ident(t,r) \ - expr_new (EXPR_NONE, ExprNone(), EXPR_IDENT, (ExprType)(t), (r)) - -int expr_simplify (expr *); -void expr_print (expr *); - -/* get the value if possible. return value is IF POSSIBLE, not the val */ -int expr_get_value (expr *, unsigned long *); - -#endif diff --git a/include/globals.h b/include/globals.h deleted file mode 100644 index a5fe788f..00000000 --- a/include/globals.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $Id: globals.h,v 1.3 2001/06/28 21:22:01 peter Exp $ - * Globals header file - * - * Copyright (C) 2001 Peter Johnson - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_GLOBALS_H -#define YASM_GLOBALS_H - -extern unsigned int line_number; -extern unsigned int mode_bits; -extern struct symrec_s *locallabel_base; - -#endif diff --git a/include/section.h b/include/section.h deleted file mode 100644 index cf6e057d..00000000 --- a/include/section.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id: section.h,v 1.2 2001/06/28 21:22:01 peter Exp $ - * Section header file - * - * Copyright (C) 2001 Peter Johnson - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_SECTION_H -#define YASM_SECTION_H - -typedef struct section_s { - struct section_s *next; - - enum type { SECTION, ABSOLUTE }; - - union { - /* SECTION data */ - char *name; - /* ABSOLUTE data */ - unsigned long start; - } data; - - bytecode *bc; /* the bytecodes for the section's contents */ -} section; - -#endif diff --git a/include/symrec.h b/include/symrec.h deleted file mode 100644 index 7b4ac930..00000000 --- a/include/symrec.h +++ /dev/null @@ -1,60 +0,0 @@ -/* $Id: symrec.h,v 1.4 2001/06/28 21:22:01 peter Exp $ - * Symbol table handling header file - * - * Copyright (C) 2001 Michael Urman - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_SYMREC_H -#define YASM_SYMREC_H - -typedef enum { - SYM_NOSTATUS = 0, - SYM_USED = 1 << 0, /* for using variables before declared */ - SYM_DECLARED = 1 << 1, /* once it's been declared */ - SYM_VALUED = 1 << 2 /* once its value has been determined */ -} SymStatus; - -typedef enum { - SYM_CONSTANT, /* for EQU defined symbols */ - SYM_LABEL, /* for labels */ - SYM_DATA /* for variables */ -} SymType; - -typedef struct symrec_s { - char *name; - SymType type; - SymStatus status; - int line; - double value; -} symrec; - -typedef struct symtab_s { - symrec rec; - struct symtab_s *next; -} symtab; - -extern symtab *sym_table; - -/*symrec *putsym(char *, SymType);*/ -/*symrec *getsym(char *);*/ - -symrec *sym_use_get (char *, SymType); -symrec *sym_def_get (char *, SymType); -void sym_foreach (int(*)(symrec *)); - -#endif diff --git a/include/util.h b/include/util.h deleted file mode 100644 index dd5392a5..00000000 --- a/include/util.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $Id: util.h,v 1.4 2001/06/29 02:11:36 peter Exp $ - * Defines prototypes for replacement functions if needed. - * - * Copyright (C) 2001 Peter Johnson - * - * This file is part of YASM. - * - * YASM is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * YASM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef YASM_UTIL_H -#define YASM_UTIL_H - -#ifndef HAVE_STRDUP -char *strdup(const char *str); -#endif - -#ifndef HAVE_STRTOUL -unsigned long strtoul(const char *nptr, char **endptr, int base); -#endif - -#ifndef HAVE_TOASCII -# define toascii(c) ((c) & 0x7F) -#endif - -#endif diff --git a/src/Makefile.am b/src/Makefile.am index 80eacbb7..b0e468ab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,10 +4,16 @@ yasm_SOURCES = \ bison.y \ token.l \ bytecode.c \ + bytecode.h \ errwarn.c \ + errwarn.h \ expr.c \ + expr.h \ main.c \ - symrec.c + symrec.c \ + symrec.h \ + globals.h \ + util.h noinst_SCRIPTS = gen_instr.pl @@ -24,4 +30,7 @@ BUILT_SOURCES = token.l bison.y EXTRA_DIST = \ instrs.dat \ + token.l.in \ + bison.y.in \ + bison.h \ gen_instr.pl