mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 23:03:55 +00:00
Move aicasm to its own subdirectory.
This commit is contained in:
parent
717d424718
commit
32da3127a3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65943
|
@ -1,3 +1,5 @@
|
|||
# $Id$
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= aicasm
|
||||
|
@ -19,12 +21,12 @@ LDADD+= -ll
|
|||
DEPENDFILE=
|
||||
.endif
|
||||
|
||||
CFLAGS+= -nostdinc -I${.CURDIR}/../.. -I. -I/usr/include
|
||||
CFLAGS+= -nostdinc -I${.CURDIR}/../../.. -I. -I/usr/include
|
||||
NOMAN= noman
|
||||
|
||||
.ifdef DEBUG
|
||||
CFLAGS+= -DDEBUG -g
|
||||
YFLAGS+= -t
|
||||
YFLAGS+= -t -v
|
||||
LFLAGS+= -d
|
||||
.endif
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
@ -82,12 +84,12 @@ extern int yy_flex_debug;
|
|||
extern int yydebug;
|
||||
#endif
|
||||
extern FILE *yyin;
|
||||
extern int yyparse __P((void));
|
||||
extern int yyparse(void);
|
||||
|
||||
int main(int argc, char *argv[]);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
@ -350,7 +352,7 @@ ahc_patch%d_func(struct ahc_softc *ahc)
|
|||
}
|
||||
|
||||
fprintf(ofile,
|
||||
"typedef int patch_func_t __P((struct ahc_softc *));
|
||||
"typedef int patch_func_t (struct ahc_softc *);
|
||||
struct patch {
|
||||
patch_func_t *patch_func;
|
||||
uint32_t begin :10,
|
||||
|
@ -462,6 +464,7 @@ output_listing(char *ifilename)
|
|||
cur_func = SLIST_NEXT(cur_func, links))
|
||||
func_count++;
|
||||
|
||||
func_values = NULL;
|
||||
if (func_count != 0) {
|
||||
func_values = (int *)malloc(func_count * sizeof(int));
|
||||
|
||||
|
@ -589,9 +592,7 @@ check_patch(patch_t **start_patch, int start_instr,
|
|||
* terminating the program.
|
||||
*/
|
||||
void
|
||||
stop(string, err_code)
|
||||
const char *string;
|
||||
int err_code;
|
||||
stop(const char *string, int err_code)
|
||||
{
|
||||
if (string != NULL) {
|
||||
fprintf(stderr, "%s: ", appname);
|
||||
|
|
|
@ -28,10 +28,16 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifdef __linux__
|
||||
#include "../queue.h"
|
||||
#else
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
@ -38,7 +40,11 @@
|
|||
#include <sysexits.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef __linux__
|
||||
#include "../queue.h"
|
||||
#else
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
|
||||
#include "aicasm.h"
|
||||
#include "aicasm_symbol.h"
|
||||
|
@ -57,24 +63,21 @@ static int instruction_ptr;
|
|||
static int sram_or_scb_offset;
|
||||
static int download_constant_count;
|
||||
|
||||
static void process_bitmask __P((int mask_type, symbol_t *sym, int mask));
|
||||
static void initialize_symbol __P((symbol_t *symbol));
|
||||
static void process_register __P((symbol_t **p_symbol));
|
||||
static void format_1_instr __P((int opcode, symbol_ref_t *dest,
|
||||
expression_t *immed, symbol_ref_t *src,
|
||||
int ret));
|
||||
static void format_2_instr __P((int opcode, symbol_ref_t *dest,
|
||||
expression_t *places, symbol_ref_t *src,
|
||||
int ret));
|
||||
static void format_3_instr __P((int opcode, symbol_ref_t *src,
|
||||
expression_t *immed, symbol_ref_t *address));
|
||||
static void test_readable_symbol __P((symbol_t *symbol));
|
||||
static void test_writable_symbol __P((symbol_t *symbol));
|
||||
static void type_check __P((symbol_t *symbol, expression_t *expression,
|
||||
int and_op));
|
||||
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));
|
||||
static void process_bitmask(int mask_type, symbol_t *sym, int mask);
|
||||
static void initialize_symbol(symbol_t *symbol);
|
||||
static void process_register(symbol_t **p_symbol);
|
||||
static void format_1_instr(int opcode, symbol_ref_t *dest,
|
||||
expression_t *immed, symbol_ref_t *src, int ret);
|
||||
static void format_2_instr(int opcode, symbol_ref_t *dest,
|
||||
expression_t *places, symbol_ref_t *src, int ret);
|
||||
static void format_3_instr(int opcode, symbol_ref_t *src,
|
||||
expression_t *immed, symbol_ref_t *address);
|
||||
static void test_readable_symbol(symbol_t *symbol);
|
||||
static void test_writable_symbol(symbol_t *symbol);
|
||||
static void type_check(symbol_t *symbol, expression_t *expression, int and_op);
|
||||
static void make_expression(expression_t *immed, int value);
|
||||
static void add_conditional(symbol_t *symbol);
|
||||
static int is_download_const(expression_t *immed);
|
||||
|
||||
#define YYDEBUG 1
|
||||
#define SRAM_SYMNAME "SRAM_BASE"
|
||||
|
@ -530,6 +533,8 @@ scb:
|
|||
}
|
||||
cur_symbol->type = SCBLOC;
|
||||
initialize_symbol(cur_symbol);
|
||||
/* 64 bytes of SCB space */
|
||||
cur_symbol->info.rinfo->size = 64;
|
||||
}
|
||||
reg_address
|
||||
{
|
||||
|
@ -750,7 +755,6 @@ conditional:
|
|||
'}'
|
||||
{
|
||||
scope_t *scope_context;
|
||||
scope_t *last_scope;
|
||||
|
||||
scope_context = SLIST_FIRST(&scope_stack);
|
||||
if (scope_context->type == SCOPE_ROOT) {
|
||||
|
@ -999,10 +1003,7 @@ code:
|
|||
%%
|
||||
|
||||
static void
|
||||
process_bitmask(mask_type, sym, mask)
|
||||
int mask_type;
|
||||
symbol_t *sym;
|
||||
int mask;
|
||||
process_bitmask(int mask_type, symbol_t *sym, int mask)
|
||||
{
|
||||
/*
|
||||
* Add the current register to its
|
||||
|
@ -1047,8 +1048,7 @@ process_bitmask(mask_type, sym, mask)
|
|||
}
|
||||
|
||||
static void
|
||||
initialize_symbol(symbol)
|
||||
symbol_t *symbol;
|
||||
initialize_symbol(symbol_t *symbol)
|
||||
{
|
||||
switch (symbol->type) {
|
||||
case UNINITIALIZED:
|
||||
|
@ -1129,8 +1129,7 @@ initialize_symbol(symbol)
|
|||
}
|
||||
|
||||
static void
|
||||
process_register(p_symbol)
|
||||
symbol_t **p_symbol;
|
||||
process_register(symbol_t **p_symbol)
|
||||
{
|
||||
char buf[255];
|
||||
symbol_t *symbol = *p_symbol;
|
||||
|
@ -1153,12 +1152,8 @@ process_register(p_symbol)
|
|||
}
|
||||
|
||||
static void
|
||||
format_1_instr(opcode, dest, immed, src, ret)
|
||||
int opcode;
|
||||
symbol_ref_t *dest;
|
||||
expression_t *immed;
|
||||
symbol_ref_t *src;
|
||||
int ret;
|
||||
format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed,
|
||||
symbol_ref_t *src, int ret)
|
||||
{
|
||||
struct instruction *instr;
|
||||
struct ins_format1 *f1_instr;
|
||||
|
@ -1192,12 +1187,8 @@ format_1_instr(opcode, dest, immed, src, ret)
|
|||
}
|
||||
|
||||
static void
|
||||
format_2_instr(opcode, dest, places, src, ret)
|
||||
int opcode;
|
||||
symbol_ref_t *dest;
|
||||
expression_t *places;
|
||||
symbol_ref_t *src;
|
||||
int ret;
|
||||
format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places,
|
||||
symbol_ref_t *src, int ret)
|
||||
{
|
||||
struct instruction *instr;
|
||||
struct ins_format2 *f2_instr;
|
||||
|
@ -1257,11 +1248,8 @@ format_2_instr(opcode, dest, places, src, ret)
|
|||
}
|
||||
|
||||
static void
|
||||
format_3_instr(opcode, src, immed, address)
|
||||
int opcode;
|
||||
symbol_ref_t *src;
|
||||
expression_t *immed;
|
||||
symbol_ref_t *address;
|
||||
format_3_instr(int opcode, symbol_ref_t *src,
|
||||
expression_t *immed, symbol_ref_t *address)
|
||||
{
|
||||
struct instruction *instr;
|
||||
struct ins_format3 *f3_instr;
|
||||
|
@ -1299,8 +1287,7 @@ format_3_instr(opcode, src, immed, address)
|
|||
}
|
||||
|
||||
static void
|
||||
test_readable_symbol(symbol)
|
||||
symbol_t *symbol;
|
||||
test_readable_symbol(symbol_t *symbol)
|
||||
{
|
||||
if (symbol->info.rinfo->mode == WO) {
|
||||
stop("Write Only register specified as source",
|
||||
|
@ -1310,8 +1297,7 @@ test_readable_symbol(symbol)
|
|||
}
|
||||
|
||||
static void
|
||||
test_writable_symbol(symbol)
|
||||
symbol_t *symbol;
|
||||
test_writable_symbol(symbol_t *symbol)
|
||||
{
|
||||
if (symbol->info.rinfo->mode == RO) {
|
||||
stop("Read Only register specified as destination",
|
||||
|
@ -1321,10 +1307,7 @@ test_writable_symbol(symbol)
|
|||
}
|
||||
|
||||
static void
|
||||
type_check(symbol, expression, opcode)
|
||||
symbol_t *symbol;
|
||||
expression_t *expression;
|
||||
int opcode;
|
||||
type_check(symbol_t *symbol, expression_t *expression, int opcode)
|
||||
{
|
||||
symbol_node_t *node;
|
||||
int and_op;
|
||||
|
@ -1373,17 +1356,14 @@ type_check(symbol, expression, opcode)
|
|||
}
|
||||
|
||||
static void
|
||||
make_expression(immed, value)
|
||||
expression_t *immed;
|
||||
int value;
|
||||
make_expression(expression_t *immed, int value)
|
||||
{
|
||||
SLIST_INIT(&immed->referenced_syms);
|
||||
immed->value = value & 0xff;
|
||||
}
|
||||
|
||||
static void
|
||||
add_conditional(symbol)
|
||||
symbol_t *symbol;
|
||||
add_conditional(symbol_t *symbol)
|
||||
{
|
||||
static int numfuncs;
|
||||
|
||||
|
@ -1420,15 +1400,13 @@ add_conditional(symbol)
|
|||
}
|
||||
|
||||
void
|
||||
yyerror(string)
|
||||
const char *string;
|
||||
yyerror(const char *string)
|
||||
{
|
||||
stop(string, EX_DATAERR);
|
||||
}
|
||||
|
||||
static int
|
||||
is_download_const(immed)
|
||||
expression_t *immed;
|
||||
is_download_const(expression_t *immed)
|
||||
{
|
||||
if ((immed->referenced_syms.slh_first != NULL)
|
||||
&& (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST))
|
||||
|
|
|
@ -29,10 +29,16 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if linux
|
||||
#include <endian.h>
|
||||
#else
|
||||
#include <machine/endian.h>
|
||||
#endif
|
||||
|
||||
struct ins_format1 {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
|
@ -90,7 +96,7 @@ union ins_formats {
|
|||
struct ins_format1 format1;
|
||||
struct ins_format2 format2;
|
||||
struct ins_format3 format3;
|
||||
uint8_t bytes[4];
|
||||
uint8_t bytes[4];
|
||||
uint32_t integer;
|
||||
};
|
||||
struct instruction {
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
@ -38,7 +40,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#ifdef __linux__
|
||||
#include "../queue.h"
|
||||
#else
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
|
||||
#include "aicasm.h"
|
||||
#include "aicasm_symbol.h"
|
||||
|
@ -87,11 +93,20 @@ if[ \t]*\( {
|
|||
}
|
||||
}
|
||||
<CEXPR>\n { ++yylineno; }
|
||||
<CEXPR>[^()\n]+ {
|
||||
<CEXPR>[^()\n]+ {
|
||||
char *yptr = yytext;
|
||||
|
||||
while (*yptr != '\0')
|
||||
*string_buf_ptr++ = *yptr++;
|
||||
while (*yptr != '\0') {
|
||||
/* 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} ;
|
||||
|
@ -210,9 +225,7 @@ typedef struct include {
|
|||
SLIST_HEAD(, include) include_stack;
|
||||
|
||||
void
|
||||
include_file(file_name, type)
|
||||
char *file_name;
|
||||
include_type type;
|
||||
include_file(char *file_name, include_type type)
|
||||
{
|
||||
FILE *newfile;
|
||||
include_t *include;
|
||||
|
|
|
@ -28,13 +28,18 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <db1/db.h>
|
||||
#else
|
||||
#include <db.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -47,8 +52,7 @@
|
|||
static DB *symtable;
|
||||
|
||||
symbol_t *
|
||||
symbol_create(name)
|
||||
char *name;
|
||||
symbol_create(char *name)
|
||||
{
|
||||
symbol_t *new_symbol;
|
||||
|
||||
|
@ -64,8 +68,7 @@ symbol_create(name)
|
|||
}
|
||||
|
||||
void
|
||||
symbol_delete(symbol)
|
||||
symbol_t *symbol;
|
||||
symbol_delete(symbol_t *symbol)
|
||||
{
|
||||
if (symtable != NULL) {
|
||||
DBT key;
|
||||
|
@ -145,8 +148,7 @@ symtable_close()
|
|||
* if a lookup fails.
|
||||
*/
|
||||
symbol_t *
|
||||
symtable_get(name)
|
||||
char *name;
|
||||
symtable_get(char *name)
|
||||
{
|
||||
symbol_t *stored_ptr;
|
||||
DBT key;
|
||||
|
@ -185,9 +187,7 @@ symtable_get(name)
|
|||
}
|
||||
|
||||
symbol_node_t *
|
||||
symlist_search(symlist, symname)
|
||||
symlist_t *symlist;
|
||||
char *symname;
|
||||
symlist_search(symlist_t *symlist, char *symname)
|
||||
{
|
||||
symbol_node_t *curnode;
|
||||
|
||||
|
@ -201,10 +201,7 @@ symlist_search(symlist, symname)
|
|||
}
|
||||
|
||||
void
|
||||
symlist_add(symlist, symbol, how)
|
||||
symlist_t *symlist;
|
||||
symbol_t *symbol;
|
||||
int how;
|
||||
symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
|
||||
{
|
||||
symbol_node_t *newnode;
|
||||
|
||||
|
@ -270,8 +267,7 @@ symlist_add(symlist, symbol, how)
|
|||
}
|
||||
|
||||
void
|
||||
symlist_free(symlist)
|
||||
symlist_t *symlist;
|
||||
symlist_free(symlist_t *symlist)
|
||||
{
|
||||
symbol_node_t *node1, *node2;
|
||||
|
||||
|
@ -285,10 +281,8 @@ symlist_free(symlist)
|
|||
}
|
||||
|
||||
void
|
||||
symlist_merge(symlist_dest, symlist_src1, symlist_src2)
|
||||
symlist_t *symlist_dest;
|
||||
symlist_t *symlist_src1;
|
||||
symlist_t *symlist_src2;
|
||||
symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
|
||||
symlist_t *symlist_src2)
|
||||
{
|
||||
symbol_node_t *node;
|
||||
|
||||
|
@ -304,8 +298,7 @@ symlist_merge(symlist_dest, symlist_src1, symlist_src2)
|
|||
}
|
||||
|
||||
void
|
||||
symtable_dump(ofile)
|
||||
FILE *ofile;
|
||||
symtable_dump(FILE *ofile)
|
||||
{
|
||||
/*
|
||||
* Sort the registers by address with a simple insertion sort.
|
||||
|
@ -400,7 +393,7 @@ symtable_dump(ofile)
|
|||
*/\n");
|
||||
while (registers.slh_first != NULL) {
|
||||
symbol_node_t *curnode;
|
||||
uint8_t value;
|
||||
u_int8_t value;
|
||||
char *tab_str;
|
||||
char *tab_str2;
|
||||
|
||||
|
|
|
@ -28,10 +28,16 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifdef __linux__
|
||||
#include "../queue.h"
|
||||
#else
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
UNINITIALIZED,
|
||||
|
@ -54,10 +60,10 @@ typedef enum {
|
|||
}amode_t;
|
||||
|
||||
struct reg_info {
|
||||
uint8_t address;
|
||||
u_int8_t address;
|
||||
int size;
|
||||
amode_t mode;
|
||||
uint8_t valid_bitmask;
|
||||
u_int8_t valid_bitmask;
|
||||
int typecheck_masks;
|
||||
};
|
||||
|
||||
|
@ -65,11 +71,11 @@ typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
|
|||
|
||||
struct mask_info {
|
||||
symlist_t symrefs;
|
||||
uint8_t mask;
|
||||
u_int8_t mask;
|
||||
};
|
||||
|
||||
struct const_info {
|
||||
uint8_t value;
|
||||
u_int8_t value;
|
||||
int define;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue