Move aicasm to its own subdirectory.

This commit is contained in:
Justin T. Gibbs 2000-09-16 20:02:39 +00:00
parent 717d424718
commit 32da3127a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65943
8 changed files with 110 additions and 105 deletions

View file

@ -1,3 +1,5 @@
# $Id$
#
# $FreeBSD$ # $FreeBSD$
PROG= aicasm PROG= aicasm
@ -19,12 +21,12 @@ LDADD+= -ll
DEPENDFILE= DEPENDFILE=
.endif .endif
CFLAGS+= -nostdinc -I${.CURDIR}/../.. -I. -I/usr/include CFLAGS+= -nostdinc -I${.CURDIR}/../../.. -I. -I/usr/include
NOMAN= noman NOMAN= noman
.ifdef DEBUG .ifdef DEBUG
CFLAGS+= -DDEBUG -g CFLAGS+= -DDEBUG -g
YFLAGS+= -t YFLAGS+= -t -v
LFLAGS+= -d LFLAGS+= -d
.endif .endif

View file

@ -28,6 +28,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -82,12 +84,12 @@ extern int yy_flex_debug;
extern int yydebug; extern int yydebug;
#endif #endif
extern FILE *yyin; extern FILE *yyin;
extern int yyparse __P((void)); extern int yyparse(void);
int main(int argc, char *argv[]);
int int
main(argc, argv) main(int argc, char *argv[])
int argc;
char *argv[];
{ {
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
@ -350,7 +352,7 @@ ahc_patch%d_func(struct ahc_softc *ahc)
} }
fprintf(ofile, fprintf(ofile,
"typedef int patch_func_t __P((struct ahc_softc *)); "typedef int patch_func_t (struct ahc_softc *);
struct patch { struct patch {
patch_func_t *patch_func; patch_func_t *patch_func;
uint32_t begin :10, uint32_t begin :10,
@ -462,6 +464,7 @@ output_listing(char *ifilename)
cur_func = SLIST_NEXT(cur_func, links)) cur_func = SLIST_NEXT(cur_func, links))
func_count++; func_count++;
func_values = NULL;
if (func_count != 0) { if (func_count != 0) {
func_values = (int *)malloc(func_count * sizeof(int)); func_values = (int *)malloc(func_count * sizeof(int));
@ -589,9 +592,7 @@ check_patch(patch_t **start_patch, int start_instr,
* terminating the program. * terminating the program.
*/ */
void void
stop(string, err_code) stop(const char *string, int err_code)
const char *string;
int err_code;
{ {
if (string != NULL) { if (string != NULL) {
fprintf(stderr, "%s: ", appname); fprintf(stderr, "%s: ", appname);

View file

@ -28,10 +28,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
#ifdef __linux__
#include "../queue.h"
#else
#include <sys/queue.h> #include <sys/queue.h>
#endif
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1

View file

@ -29,6 +29,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
@ -38,7 +40,11 @@
#include <sysexits.h> #include <sysexits.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef __linux__
#include "../queue.h"
#else
#include <sys/queue.h> #include <sys/queue.h>
#endif
#include "aicasm.h" #include "aicasm.h"
#include "aicasm_symbol.h" #include "aicasm_symbol.h"
@ -57,24 +63,21 @@ static int instruction_ptr;
static int sram_or_scb_offset; static int sram_or_scb_offset;
static int download_constant_count; static int download_constant_count;
static void process_bitmask __P((int mask_type, symbol_t *sym, int mask)); static void process_bitmask(int mask_type, symbol_t *sym, int mask);
static void initialize_symbol __P((symbol_t *symbol)); static void initialize_symbol(symbol_t *symbol);
static void process_register __P((symbol_t **p_symbol)); static void process_register(symbol_t **p_symbol);
static void format_1_instr __P((int opcode, symbol_ref_t *dest, static void format_1_instr(int opcode, symbol_ref_t *dest,
expression_t *immed, symbol_ref_t *src, expression_t *immed, symbol_ref_t *src, int ret);
int ret)); static void format_2_instr(int opcode, symbol_ref_t *dest,
static void format_2_instr __P((int opcode, symbol_ref_t *dest, expression_t *places, symbol_ref_t *src, int ret);
expression_t *places, symbol_ref_t *src, static void format_3_instr(int opcode, symbol_ref_t *src,
int ret)); expression_t *immed, symbol_ref_t *address);
static void format_3_instr __P((int opcode, symbol_ref_t *src, static void test_readable_symbol(symbol_t *symbol);
expression_t *immed, symbol_ref_t *address)); static void test_writable_symbol(symbol_t *symbol);
static void test_readable_symbol __P((symbol_t *symbol)); static void type_check(symbol_t *symbol, expression_t *expression, int and_op);
static void test_writable_symbol __P((symbol_t *symbol)); static void make_expression(expression_t *immed, int value);
static void type_check __P((symbol_t *symbol, expression_t *expression, static void add_conditional(symbol_t *symbol);
int and_op)); static int is_download_const(expression_t *immed);
static void make_expression __P((expression_t *immed, int value));
static void add_conditional __P((symbol_t *symbol));
static int is_download_const __P((expression_t *immed));
#define YYDEBUG 1 #define YYDEBUG 1
#define SRAM_SYMNAME "SRAM_BASE" #define SRAM_SYMNAME "SRAM_BASE"
@ -530,6 +533,8 @@ scb:
} }
cur_symbol->type = SCBLOC; cur_symbol->type = SCBLOC;
initialize_symbol(cur_symbol); initialize_symbol(cur_symbol);
/* 64 bytes of SCB space */
cur_symbol->info.rinfo->size = 64;
} }
reg_address reg_address
{ {
@ -750,7 +755,6 @@ conditional:
'}' '}'
{ {
scope_t *scope_context; scope_t *scope_context;
scope_t *last_scope;
scope_context = SLIST_FIRST(&scope_stack); scope_context = SLIST_FIRST(&scope_stack);
if (scope_context->type == SCOPE_ROOT) { if (scope_context->type == SCOPE_ROOT) {
@ -999,10 +1003,7 @@ code:
%% %%
static void static void
process_bitmask(mask_type, sym, mask) process_bitmask(int mask_type, symbol_t *sym, int mask)
int mask_type;
symbol_t *sym;
int mask;
{ {
/* /*
* Add the current register to its * Add the current register to its
@ -1047,8 +1048,7 @@ process_bitmask(mask_type, sym, mask)
} }
static void static void
initialize_symbol(symbol) initialize_symbol(symbol_t *symbol)
symbol_t *symbol;
{ {
switch (symbol->type) { switch (symbol->type) {
case UNINITIALIZED: case UNINITIALIZED:
@ -1129,8 +1129,7 @@ initialize_symbol(symbol)
} }
static void static void
process_register(p_symbol) process_register(symbol_t **p_symbol)
symbol_t **p_symbol;
{ {
char buf[255]; char buf[255];
symbol_t *symbol = *p_symbol; symbol_t *symbol = *p_symbol;
@ -1153,12 +1152,8 @@ process_register(p_symbol)
} }
static void static void
format_1_instr(opcode, dest, immed, src, ret) format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed,
int opcode; symbol_ref_t *src, int ret)
symbol_ref_t *dest;
expression_t *immed;
symbol_ref_t *src;
int ret;
{ {
struct instruction *instr; struct instruction *instr;
struct ins_format1 *f1_instr; struct ins_format1 *f1_instr;
@ -1192,12 +1187,8 @@ format_1_instr(opcode, dest, immed, src, ret)
} }
static void static void
format_2_instr(opcode, dest, places, src, ret) format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places,
int opcode; symbol_ref_t *src, int ret)
symbol_ref_t *dest;
expression_t *places;
symbol_ref_t *src;
int ret;
{ {
struct instruction *instr; struct instruction *instr;
struct ins_format2 *f2_instr; struct ins_format2 *f2_instr;
@ -1257,11 +1248,8 @@ format_2_instr(opcode, dest, places, src, ret)
} }
static void static void
format_3_instr(opcode, src, immed, address) format_3_instr(int opcode, symbol_ref_t *src,
int opcode; expression_t *immed, symbol_ref_t *address)
symbol_ref_t *src;
expression_t *immed;
symbol_ref_t *address;
{ {
struct instruction *instr; struct instruction *instr;
struct ins_format3 *f3_instr; struct ins_format3 *f3_instr;
@ -1299,8 +1287,7 @@ format_3_instr(opcode, src, immed, address)
} }
static void static void
test_readable_symbol(symbol) test_readable_symbol(symbol_t *symbol)
symbol_t *symbol;
{ {
if (symbol->info.rinfo->mode == WO) { if (symbol->info.rinfo->mode == WO) {
stop("Write Only register specified as source", stop("Write Only register specified as source",
@ -1310,8 +1297,7 @@ test_readable_symbol(symbol)
} }
static void static void
test_writable_symbol(symbol) test_writable_symbol(symbol_t *symbol)
symbol_t *symbol;
{ {
if (symbol->info.rinfo->mode == RO) { if (symbol->info.rinfo->mode == RO) {
stop("Read Only register specified as destination", stop("Read Only register specified as destination",
@ -1321,10 +1307,7 @@ test_writable_symbol(symbol)
} }
static void static void
type_check(symbol, expression, opcode) type_check(symbol_t *symbol, expression_t *expression, int opcode)
symbol_t *symbol;
expression_t *expression;
int opcode;
{ {
symbol_node_t *node; symbol_node_t *node;
int and_op; int and_op;
@ -1373,17 +1356,14 @@ type_check(symbol, expression, opcode)
} }
static void static void
make_expression(immed, value) make_expression(expression_t *immed, int value)
expression_t *immed;
int value;
{ {
SLIST_INIT(&immed->referenced_syms); SLIST_INIT(&immed->referenced_syms);
immed->value = value & 0xff; immed->value = value & 0xff;
} }
static void static void
add_conditional(symbol) add_conditional(symbol_t *symbol)
symbol_t *symbol;
{ {
static int numfuncs; static int numfuncs;
@ -1420,15 +1400,13 @@ add_conditional(symbol)
} }
void void
yyerror(string) yyerror(const char *string)
const char *string;
{ {
stop(string, EX_DATAERR); stop(string, EX_DATAERR);
} }
static int static int
is_download_const(immed) is_download_const(expression_t *immed)
expression_t *immed;
{ {
if ((immed->referenced_syms.slh_first != NULL) if ((immed->referenced_syms.slh_first != NULL)
&& (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST)) && (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST))

View file

@ -29,10 +29,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
#if linux
#include <endian.h>
#else
#include <machine/endian.h> #include <machine/endian.h>
#endif
struct ins_format1 { struct ins_format1 {
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
@ -90,7 +96,7 @@ union ins_formats {
struct ins_format1 format1; struct ins_format1 format1;
struct ins_format2 format2; struct ins_format2 format2;
struct ins_format3 format3; struct ins_format3 format3;
uint8_t bytes[4]; uint8_t bytes[4];
uint32_t integer; uint32_t integer;
}; };
struct instruction { struct instruction {

View file

@ -29,6 +29,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
@ -38,7 +40,11 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sysexits.h> #include <sysexits.h>
#ifdef __linux__
#include "../queue.h"
#else
#include <sys/queue.h> #include <sys/queue.h>
#endif
#include "aicasm.h" #include "aicasm.h"
#include "aicasm_symbol.h" #include "aicasm_symbol.h"
@ -87,11 +93,20 @@ if[ \t]*\( {
} }
} }
<CEXPR>\n { ++yylineno; } <CEXPR>\n { ++yylineno; }
<CEXPR>[^()\n]+ { <CEXPR>[^()\n]+ {
char *yptr = yytext; char *yptr = yytext;
while (*yptr != '\0') while (*yptr != '\0') {
*string_buf_ptr++ = *yptr++; /* Remove duplicate spaces */
if (*yptr == '\t')
*yptr = ' ';
if (*yptr == ' '
&& string_buf_ptr != string_buf
&& string_buf_ptr[-1] == ' ')
yptr++;
else
*string_buf_ptr++ = *yptr++;
}
} }
{SPACE} ; {SPACE} ;
@ -210,9 +225,7 @@ typedef struct include {
SLIST_HEAD(, include) include_stack; SLIST_HEAD(, include) include_stack;
void void
include_file(file_name, type) include_file(char *file_name, include_type type)
char *file_name;
include_type type;
{ {
FILE *newfile; FILE *newfile;
include_t *include; include_t *include;

View file

@ -28,13 +28,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
#include <sys/types.h> #include <sys/types.h>
#ifdef __linux__
#include <db1/db.h>
#else
#include <db.h> #include <db.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -47,8 +52,7 @@
static DB *symtable; static DB *symtable;
symbol_t * symbol_t *
symbol_create(name) symbol_create(char *name)
char *name;
{ {
symbol_t *new_symbol; symbol_t *new_symbol;
@ -64,8 +68,7 @@ symbol_create(name)
} }
void void
symbol_delete(symbol) symbol_delete(symbol_t *symbol)
symbol_t *symbol;
{ {
if (symtable != NULL) { if (symtable != NULL) {
DBT key; DBT key;
@ -145,8 +148,7 @@ symtable_close()
* if a lookup fails. * if a lookup fails.
*/ */
symbol_t * symbol_t *
symtable_get(name) symtable_get(char *name)
char *name;
{ {
symbol_t *stored_ptr; symbol_t *stored_ptr;
DBT key; DBT key;
@ -185,9 +187,7 @@ symtable_get(name)
} }
symbol_node_t * symbol_node_t *
symlist_search(symlist, symname) symlist_search(symlist_t *symlist, char *symname)
symlist_t *symlist;
char *symname;
{ {
symbol_node_t *curnode; symbol_node_t *curnode;
@ -201,10 +201,7 @@ symlist_search(symlist, symname)
} }
void void
symlist_add(symlist, symbol, how) symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
symlist_t *symlist;
symbol_t *symbol;
int how;
{ {
symbol_node_t *newnode; symbol_node_t *newnode;
@ -270,8 +267,7 @@ symlist_add(symlist, symbol, how)
} }
void void
symlist_free(symlist) symlist_free(symlist_t *symlist)
symlist_t *symlist;
{ {
symbol_node_t *node1, *node2; symbol_node_t *node1, *node2;
@ -285,10 +281,8 @@ symlist_free(symlist)
} }
void void
symlist_merge(symlist_dest, symlist_src1, symlist_src2) symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
symlist_t *symlist_dest; symlist_t *symlist_src2)
symlist_t *symlist_src1;
symlist_t *symlist_src2;
{ {
symbol_node_t *node; symbol_node_t *node;
@ -304,8 +298,7 @@ symlist_merge(symlist_dest, symlist_src1, symlist_src2)
} }
void void
symtable_dump(ofile) symtable_dump(FILE *ofile)
FILE *ofile;
{ {
/* /*
* Sort the registers by address with a simple insertion sort. * Sort the registers by address with a simple insertion sort.
@ -400,7 +393,7 @@ symtable_dump(ofile)
*/\n"); */\n");
while (registers.slh_first != NULL) { while (registers.slh_first != NULL) {
symbol_node_t *curnode; symbol_node_t *curnode;
uint8_t value; u_int8_t value;
char *tab_str; char *tab_str;
char *tab_str2; char *tab_str2;

View file

@ -28,10 +28,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$
*
* $FreeBSD$ * $FreeBSD$
*/ */
#ifdef __linux__
#include "../queue.h"
#else
#include <sys/queue.h> #include <sys/queue.h>
#endif
typedef enum { typedef enum {
UNINITIALIZED, UNINITIALIZED,
@ -54,10 +60,10 @@ typedef enum {
}amode_t; }amode_t;
struct reg_info { struct reg_info {
uint8_t address; u_int8_t address;
int size; int size;
amode_t mode; amode_t mode;
uint8_t valid_bitmask; u_int8_t valid_bitmask;
int typecheck_masks; int typecheck_masks;
}; };
@ -65,11 +71,11 @@ typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
struct mask_info { struct mask_info {
symlist_t symrefs; symlist_t symrefs;
uint8_t mask; u_int8_t mask;
}; };
struct const_info { struct const_info {
uint8_t value; u_int8_t value;
int define; int define;
}; };