Init
This commit is contained in:
39
usr.etc/fpa/microassembler+/Makefile
Normal file
39
usr.etc/fpa/microassembler+/Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# @(#)Makefile 1.1 94/10/31 SMI;
|
||||
#
|
||||
|
||||
CFLAGS= -c
|
||||
SRCS= main.c sym.c scan.c ramtable.c assemble.c output.c version.c
|
||||
OBJS= main.o sym.o scan.o ramtable.o assemble.o output.o version.o
|
||||
|
||||
fpas+: ${OBJS}
|
||||
cc -o fpas+ ${OBJS}
|
||||
|
||||
fpas.r: ${OBJS}
|
||||
cc -g -o fpas.r ${OBJS}
|
||||
|
||||
main.o: main.c micro.h
|
||||
cc $(CFLAGS) main.c
|
||||
|
||||
sym.o: sym.c micro.h
|
||||
cc $(CFLAGS) sym.c
|
||||
|
||||
scan.o: scan.c micro.h
|
||||
cc $(CFLAGS) scan.c
|
||||
|
||||
ramtable.o: ramtable.c micro.h
|
||||
cc $(CFLAGS) ramtable.c
|
||||
|
||||
assemble.o: assemble.c micro.h
|
||||
cc $(CFLAGS) assemble.c
|
||||
|
||||
output.o: output.c micro.h
|
||||
cc $(CFLAGS) output.c
|
||||
|
||||
version.o: version.c
|
||||
cc $(CFLAGS) version.c
|
||||
|
||||
install: fpas+
|
||||
|
||||
clean:
|
||||
rm -f *.o fpas+ core *errs* a.out
|
||||
304
usr.etc/fpa/microassembler+/assemble.c
Normal file
304
usr.etc/fpa/microassembler+/assemble.c
Normal file
@@ -0,0 +1,304 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)assemble.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/* Microassembler instruction builder */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "micro.h"
|
||||
|
||||
extern CODE code[];
|
||||
extern CODE *curword;
|
||||
extern NODE n[];
|
||||
extern NODE *curnode;
|
||||
extern int curlineno;
|
||||
extern short curaddr;
|
||||
extern short maxaddr;
|
||||
extern char *curfilename;
|
||||
extern char *curline;
|
||||
|
||||
init_one(i)
|
||||
short i;
|
||||
{
|
||||
n[i].filename = 0;
|
||||
n[i].instr = NULL;
|
||||
n[i].lineno = 0;
|
||||
n[i].line = 0;
|
||||
n[i].sccsid = False;
|
||||
n[i].filled = False;
|
||||
n[i].org_pseudo = False;
|
||||
n[i].routine = False;
|
||||
n[i].jumpop = False;
|
||||
}
|
||||
|
||||
init_assm()
|
||||
{
|
||||
short i;
|
||||
|
||||
for (i = 0; i <= 1; i++) {
|
||||
init_one(i);
|
||||
}
|
||||
|
||||
/* clear the code array */
|
||||
memset( code, 0, NNODE * sizeof (CODE) );
|
||||
}
|
||||
|
||||
anext()
|
||||
{
|
||||
register NODE *rp;
|
||||
int i;
|
||||
|
||||
rp = ++curnode;
|
||||
if (curnode - n + 1 < NNODE) {
|
||||
init_one(curnode - n + 1);
|
||||
}
|
||||
if (curnode >= &n[NNODE]) {
|
||||
fatal("too many instructions!");
|
||||
}
|
||||
rp->filename = curfilename;
|
||||
rp->lineno = curlineno;
|
||||
rp->line = curline;
|
||||
}
|
||||
|
||||
acode()
|
||||
{
|
||||
curword = &code[ curaddr ];
|
||||
if ( curword->used ) {
|
||||
error( "code overlaps at %x", curaddr );
|
||||
}
|
||||
curword->used = True;
|
||||
curnode->instr = curword;
|
||||
}
|
||||
|
||||
Boolean
|
||||
aseq( brnch, condition, which, num, sym, state, latch )
|
||||
int brnch;
|
||||
int condition;
|
||||
SYMTYPE which;
|
||||
int num;
|
||||
char *sym;
|
||||
int state;
|
||||
int latch;
|
||||
{
|
||||
SYMBOL *sp;
|
||||
|
||||
curnode->filled = True;
|
||||
curword->word1 |= brnch << 14;
|
||||
curword->word1 |= condition << 10;
|
||||
curword->word2 |= ( state << 10 ) & 0xc00;
|
||||
curword->word3 |= ( state << 13 ) & 0x8000;
|
||||
curword->word2 |= latch;
|
||||
switch (which) {
|
||||
case NEITHER:
|
||||
break;
|
||||
case ALPHA:
|
||||
sp = lookup(sym);
|
||||
if (sp == 0) {
|
||||
curnode->symptr = enter(sym);
|
||||
} else
|
||||
curnode->symptr = sp;
|
||||
break;
|
||||
case NUMBER:
|
||||
curword->word1 |= (num >> 4) & 0x3ff;
|
||||
curword->word2 |= num << 12;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
ati8847( func, src, regctl, csrc, output, halt, conf )
|
||||
{
|
||||
curnode->filled = True;
|
||||
curword->word3 |= func << 1;
|
||||
curword->word3 |= ( src >> 7 ) & 1;
|
||||
curword->word4 |= src << 9;
|
||||
curword->word4 |= regctl << 3;
|
||||
curword->word4 |= csrc << 5;
|
||||
curword->word4 |= output << 7;
|
||||
curword->word4 |= halt << 2;
|
||||
curword->word4 |= conf;
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
adata ( dctrl)
|
||||
int dctrl;
|
||||
{
|
||||
curnode->filled = True;
|
||||
curword->word3 |= dctrl << 11;
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
arecreg ( recreg )
|
||||
int recreg;
|
||||
{
|
||||
curnode->filled = True;
|
||||
curword->word4 |= recreg << 4;
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
aram ( ramcs, ptr )
|
||||
int ramcs, ptr;
|
||||
{
|
||||
curnode->filled = True;
|
||||
curword->word3 |= ramcs << 10;
|
||||
curword->word2 |= ptr << 7;
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
aptr ( ptr, act, which, num, sym )
|
||||
int ptr, act;
|
||||
SYMTYPE which;
|
||||
int num;
|
||||
char *sym;
|
||||
{
|
||||
SYMBOL *sp;
|
||||
|
||||
curnode->filled = True;
|
||||
curword->word2 |= ptr << 4;
|
||||
curword->word2 |= act << 2;
|
||||
switch (which) {
|
||||
case NEITHER:
|
||||
break;
|
||||
case ALPHA:
|
||||
sp = lookup(sym);
|
||||
if (sp == 0) {
|
||||
curnode->symptr = enter(sym);
|
||||
} else
|
||||
curnode->symptr = sp;
|
||||
break;
|
||||
case NUMBER:
|
||||
curword->word1 |= (num >> 4) & 0x3ff;
|
||||
curword->word2 |= num << 12;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
asccs(cp)
|
||||
char *cp;
|
||||
{
|
||||
--cp;
|
||||
while (True) {
|
||||
curnode->filled = True;
|
||||
curnode->sccsid = True;
|
||||
curnode->org_pseudo = True;
|
||||
curnode->addr = curaddr;
|
||||
curword->word1 = 0;
|
||||
curword->word2 = 0;
|
||||
curword->word3 = 0;
|
||||
curword->word4 = 0;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word1 = '\0' << 8;
|
||||
break;
|
||||
} else {
|
||||
curword->word1 = *cp << 8;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word1 |= '\0';
|
||||
break;
|
||||
} else {
|
||||
curword->word1 |= *cp & 0xff;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word2 = '\0' << 8;
|
||||
break;
|
||||
} else {
|
||||
curword->word2 = *cp << 8;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word2 |= '\0';
|
||||
break;
|
||||
} else {
|
||||
curword->word2 |= *cp & 0xff;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word3 = '\0' << 8;
|
||||
break;
|
||||
} else {
|
||||
curword->word3 = *cp << 8;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word3 |= '\0';
|
||||
break;
|
||||
} else {
|
||||
curword->word3 |= *cp & 0xff;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word4 = '\0' << 8;
|
||||
break;
|
||||
} else {
|
||||
curword->word4 = *cp << 8;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
curword->word4 |= '\0';
|
||||
break;
|
||||
} else {
|
||||
curword->word4 |= *cp & 0xff;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
if (*(++cp) == '\n') {
|
||||
/* curword->word5 = '\0' << 8; */
|
||||
break;
|
||||
} else {
|
||||
/* curword->word5 = *cp << 8; */
|
||||
}
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
anext();
|
||||
curnode->line = NULL;
|
||||
curnode->org_pseudo = True;
|
||||
curaddr++;
|
||||
if ( curaddr > maxaddr ) {
|
||||
maxaddr = curaddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resolve_addrs()
|
||||
{
|
||||
NODE *nd, *ni;
|
||||
struct sym *sp;
|
||||
|
||||
for (nd = n; nd <= curnode; nd++) {
|
||||
if ( sp = nd->symptr ) {
|
||||
if (sp->defined) {
|
||||
ni = sp->node;
|
||||
while ( ni->org_pseudo == True || ni->routine == True ) ni++;
|
||||
nd->instr->word1 |= (ni->addr >> 4) & 0x3ff;
|
||||
nd->instr->word2 |= ni->addr << 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
restrict ( )
|
||||
{
|
||||
/******* Check for sematics here *******/
|
||||
}
|
||||
116
usr.etc/fpa/microassembler+/main.c
Normal file
116
usr.etc/fpa/microassembler+/main.c
Normal file
@@ -0,0 +1,116 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Micro-assembler -- main driver
|
||||
* main.c 1.1 31 May 1984
|
||||
*/
|
||||
|
||||
#include "micro.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char * curfilename = "<stdin>";
|
||||
short curaddr, maxaddr;
|
||||
int curlineno;
|
||||
Boolean dflag = False;
|
||||
Boolean waserror = False;
|
||||
Boolean Scanning = False;
|
||||
NODE n[NNODE];
|
||||
NODE *curnode = n-1;
|
||||
CODE code[ NNODE ];
|
||||
CODE *curword;
|
||||
char *abinfile = NULL;
|
||||
char *binfile = NULL;
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
char *ap;
|
||||
|
||||
for (c=1; c<argc; c++) {
|
||||
ap = argv[c];
|
||||
if (ap[0] == '-') {
|
||||
switch (ap[1]) {
|
||||
case 'o':
|
||||
if (freopen(argv[++c], "w", stdout) == NULL)
|
||||
fatal("could not open file %s",argv[c]);
|
||||
continue;
|
||||
case 'a':
|
||||
abinfile = argv[++c];
|
||||
continue;
|
||||
case 'b':
|
||||
binfile = argv[++c];
|
||||
continue;
|
||||
default:
|
||||
help();
|
||||
fatal("bad option %s", argv[c]);
|
||||
}
|
||||
} else {
|
||||
curfilename = argv[c];
|
||||
if (freopen(argv[c], "r", stdin) == NULL)
|
||||
fatal("could not open file %s",argv[c]);
|
||||
}
|
||||
}
|
||||
Scanning = True;
|
||||
curaddr = 4096;
|
||||
init_symtab();
|
||||
resw_hash(); /* hash keywords */
|
||||
init_assm();
|
||||
scanprog();
|
||||
Scanning = False;
|
||||
/* if (waserror) exit(1); */
|
||||
resolve_addrs();
|
||||
restrict(); /* rectriction checking */
|
||||
output();
|
||||
if (waserror) exit(1);
|
||||
}
|
||||
|
||||
fatal(s, a)
|
||||
char *s, *a;
|
||||
{
|
||||
if (Scanning) {
|
||||
printf("File %s, line %d: %s\n", curfilename, curlineno, s);
|
||||
}
|
||||
printf(s, a);
|
||||
printf("\n");
|
||||
exit(1);
|
||||
/*_cleanup();
|
||||
abort();*/
|
||||
}
|
||||
|
||||
error(s, a, b, c, d, e, f)
|
||||
char *s;
|
||||
{
|
||||
if (Scanning) {
|
||||
printf("File %s, line %d: ", curfilename, curlineno);
|
||||
}
|
||||
printf(s, a, b, c, d, e, f);
|
||||
printf("\n");
|
||||
waserror = True;
|
||||
}
|
||||
|
||||
warn(s, a, b, c, d, e, f)
|
||||
char *s;
|
||||
{
|
||||
printf("Warning:");
|
||||
if ( Scanning) {
|
||||
printf(" file %s, line %d: ", curfilename, curlineno);
|
||||
}
|
||||
printf(s, a, b, c, d, e, f);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
fprintf( stderr, "usage: fpas [-o file] [-a file] [-b file]\n" );
|
||||
fprintf( stderr, "\t-o: output listing to file\n" );
|
||||
fprintf( stderr, "\t-a: output ascii (pseudo binary) to file\n" );
|
||||
fprintf( stderr, "\t-b: output binary to file\n" );
|
||||
}
|
||||
74
usr.etc/fpa/microassembler+/micro.h
Normal file
74
usr.etc/fpa/microassembler+/micro.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* @(#)micro.h 1.1 94/10/31 SMI */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Micro-assembler global defines
|
||||
* micro.h 1.0 85/06/06
|
||||
*/
|
||||
|
||||
typedef enum {False=0, True} Boolean;
|
||||
typedef enum {NEITHER, NUMBER, ALPHA} SYMTYPE;
|
||||
typedef enum { Tnull, Pseudo, Branch1, Branch2, State, Regram,
|
||||
Function, Latch, Pointer, Ramcs, Source,
|
||||
Output, Csrc, Regctl, Halt, Config
|
||||
} Reswd_type;
|
||||
|
||||
#define NNODE 16384 /* max number of instructions */
|
||||
#define NSYM 2048 /* more than enough symbol-table space */
|
||||
#define NSTRING 8*NSYM /* really more than enough string space */
|
||||
#define NHASH 137
|
||||
|
||||
|
||||
/* code array descriptor */
|
||||
typedef struct code {
|
||||
unsigned short word1; /* 1st word of microcode instruction */
|
||||
unsigned short word2; /* 2nd word of microcode instruction */
|
||||
unsigned short word3; /* 3rd word of microcode instruction */
|
||||
unsigned short word4; /* 4th word of microcode instruction */
|
||||
Boolean used:1; /* this word contains an instruction */
|
||||
} CODE;
|
||||
|
||||
/* user-defined symbol bucket */
|
||||
typedef struct sym {
|
||||
char *name;
|
||||
Boolean defined:1;
|
||||
short addr;
|
||||
struct node *node;
|
||||
struct sym *next_hash;
|
||||
} SYMBOL;
|
||||
|
||||
/* instruction descriptor nodes */
|
||||
typedef struct node {
|
||||
char *filename; /* name of file in which encountered */
|
||||
SYMBOL *symptr; /* symbolic addr or value */
|
||||
short lineno; /* line number on which encountered */
|
||||
short addr; /* address we assign this instruction */
|
||||
char *line; /* defining text line */
|
||||
CODE *instr; /* points to instruction for this node */
|
||||
Boolean sccsid:1; /* part of the sccsid */
|
||||
Boolean filled:1; /* instr. has been filled */
|
||||
Boolean org_pseudo:1; /* it's a pseudo-op */
|
||||
Boolean routine:1; /* it's a routine pseudo-op */
|
||||
Boolean jumpop:1; /* the addr field is used by jump op */
|
||||
} NODE;
|
||||
|
||||
/* reserved-word bucket */
|
||||
typedef struct reswd {
|
||||
char *name;
|
||||
Reswd_type
|
||||
type;
|
||||
short value1,
|
||||
value2;
|
||||
struct reswd *next_hash;
|
||||
} RESERVED;
|
||||
|
||||
|
||||
extern Boolean dflag;
|
||||
#define DEBUG if(dflag) printf
|
||||
|
||||
extern RESERVED * resw_lookup();
|
||||
extern SYMBOL * enter();
|
||||
extern SYMBOL * lookup();
|
||||
225
usr.etc/fpa/microassembler+/output.c
Normal file
225
usr.etc/fpa/microassembler+/output.c
Normal file
@@ -0,0 +1,225 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)output.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Microassembler output routines
|
||||
*/
|
||||
|
||||
#include "micro.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern char *version();
|
||||
extern short curaddr;
|
||||
extern short maxaddr;
|
||||
extern NODE *curnode, n[];
|
||||
extern NODE *adr[];
|
||||
extern CODE code[];
|
||||
extern CODE *curword;
|
||||
extern SYMBOL *shash[];
|
||||
extern char *abinfile;
|
||||
extern char *binfile;
|
||||
|
||||
alpha_out(){
|
||||
/* print listing */
|
||||
register NODE *nd;
|
||||
register int i;
|
||||
CODE *cp;
|
||||
Boolean any_undef = False;
|
||||
SYMBOL *sp;
|
||||
|
||||
printf( "\nSun Microsystems FPA-3X Microassembler -- Version %s -- Company Confidential\n", version() );
|
||||
for (i = 0; i < NHASH; i++) {
|
||||
sp = shash[i];
|
||||
while (sp != 0) {
|
||||
if (!sp->defined) {
|
||||
if (!any_undef) {
|
||||
any_undef = True;
|
||||
error ("\nError: undefined symbols:\n");
|
||||
}
|
||||
printf(" %s\n",sp->name);
|
||||
}
|
||||
sp = sp->next_hash;
|
||||
}
|
||||
}
|
||||
/* Let it print for now
|
||||
if (any_undef) {
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
printf("Microcode Output\n");
|
||||
printf("\n uC jmp next ram ptr ptr abac ram 8847 op TI\n");
|
||||
printf( " ln# addr src cc addr src sel act bits op inst src bits conf\n");
|
||||
for( nd = n; nd <=curnode; nd++) {
|
||||
if (nd->org_pseudo) {
|
||||
printf("\t\t\t\t\t\t\t\t%s",nd->line);
|
||||
} else if (nd->sccsid) {
|
||||
printf("%7x ",nd->addr);
|
||||
printf("%04x%04x%04x%04x ",cp->word1,cp->word2,cp->word3,
|
||||
cp->word4 );
|
||||
printf("%s", nd->line != 0 ? nd->line : "\n");
|
||||
} else if (nd->filled) {
|
||||
cp = nd->instr;
|
||||
printf(" %4d%5x ",nd->lineno, nd->addr);
|
||||
printf(" %01x %01x %04x %01x %01x %01x %02x %01x %03x %02x %02x %01x\t",
|
||||
( cp->word1 >> 14 ) & 0x3,
|
||||
( cp->word1 >> 10 ) & 0xf,
|
||||
( ( cp->word1 << 4 ) & 0x3ff0 ) | ( ( cp->word2 >> 12 ) & 0xf ),
|
||||
( cp->word2 >> 7 ) & 0x7,
|
||||
( cp->word2 >> 4 ) & 0x7,
|
||||
( cp->word2 >> 2 ) & 0x3,
|
||||
( ( cp->word2 >> 6 ) & 0x20 ) | ( ( cp->word3 >> 14 ) & 0x2 ) |
|
||||
( ( cp->word2 << 2 ) & 0xc ) | ( ( cp->word3 >> 10 ) & 0x1 ),
|
||||
( cp->word3 >> 11 ) & 0xf,
|
||||
( cp->word3 >> 1 ) & 0x1ff,
|
||||
( ( cp->word3 << 7 ) & 0x80 ) | ( ( cp->word4 >> 9 ) & 0x7f ),
|
||||
( cp->word4 >> 2 ) & 0x7f,
|
||||
cp->word4 & 0x3 );
|
||||
printf("%s", nd->line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write pseudo binary output
|
||||
*/
|
||||
write_abinary()
|
||||
{
|
||||
int i, j, lastout;
|
||||
char name[ 256 ];
|
||||
FILE *f[ 16 ];
|
||||
|
||||
lastout = -1;
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
sprintf( name, "%s.%d", abinfile, i );
|
||||
f[ i ] = fopen( name, "w+" );
|
||||
if ( f[ i ] == NULL ) {
|
||||
fprintf( stderr, "%s ", name );
|
||||
perror( "open failed" );
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < maxaddr; i++ ) {
|
||||
if ( code[ i ].used ) {
|
||||
for ( j = lastout + 1; j <= i; j++ ) {
|
||||
write_code( &code[ j ], f );
|
||||
}
|
||||
lastout = i;
|
||||
}
|
||||
}
|
||||
|
||||
abort:
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
fprintf( f[ i ], "\n" );
|
||||
fclose( f[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
write_code( code, files )
|
||||
CODE *code;
|
||||
FILE *files[];
|
||||
{
|
||||
int i;
|
||||
unsigned short *word;
|
||||
|
||||
word = &code->word1;
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
if ( i % 4 == 0 ) {
|
||||
fprintf( files[ i >> 2 ], "\n" );
|
||||
}
|
||||
if ( *word & ( 0x8000 >> ( i % 16 ) ) ) {
|
||||
fprintf( files[ i >> 2 ], "1" );
|
||||
} else {
|
||||
fprintf( files[ i >> 2 ], "0" );
|
||||
}
|
||||
}
|
||||
word = &code->word2;
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
if ( i % 4 == 0 ) {
|
||||
fprintf( files[ (i >> 2) + 4 ], "\n" );
|
||||
}
|
||||
if ( *word & ( 0x8000 >> ( i % 16 ) ) ) {
|
||||
fprintf( files[ (i >> 2) + 4 ], "1" );
|
||||
} else {
|
||||
fprintf( files[ (i >> 2) + 4 ], "0" );
|
||||
}
|
||||
}
|
||||
word = &code->word3;
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
if ( i % 4 == 0 ) {
|
||||
fprintf( files[ (i >> 2) + 8 ], "\n" );
|
||||
}
|
||||
if ( *word & ( 0x8000 >> ( i % 16 ) ) ) {
|
||||
fprintf( files[ (i >> 2) + 8 ], "1" );
|
||||
} else {
|
||||
fprintf( files[ (i >> 2) + 8 ], "0" );
|
||||
}
|
||||
}
|
||||
word = &code->word4;
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
if ( i % 4 == 0 ) {
|
||||
fprintf( files[ (i >> 2) + 12 ], "\n" );
|
||||
}
|
||||
if ( *word & ( 0x8000 >> ( i % 16 ) ) ) {
|
||||
fprintf( files[ (i >> 2) + 12 ], "1" );
|
||||
} else {
|
||||
fprintf( files[ (i >> 2) + 12 ], "0" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write binary output
|
||||
*/
|
||||
write_binary()
|
||||
{
|
||||
int i, j;
|
||||
int lastout;
|
||||
FILE *binstream;
|
||||
|
||||
binstream = fopen( binfile, "w+" );
|
||||
if ( binstream == NULL ) {
|
||||
fprintf( stderr, "%s ", binfile );
|
||||
perror( "open failed" );
|
||||
return;
|
||||
}
|
||||
|
||||
lastout = -1;
|
||||
fwrite( &maxaddr, sizeof maxaddr, 1, binstream );
|
||||
for ( i = 0; i < maxaddr; i++ ) {
|
||||
if ( code[ i ].used ) {
|
||||
for ( j = lastout + 1; j <= i; j++ ) {
|
||||
fwrite( &code[ j ].word1, sizeof (short), 1, binstream );
|
||||
fwrite( &code[ j ].word2, sizeof (short), 1, binstream );
|
||||
fwrite( &code[ j ].word3, sizeof (short), 1, binstream );
|
||||
fwrite( &code[ j ].word4, sizeof (short), 1, binstream );
|
||||
}
|
||||
lastout = i;
|
||||
}
|
||||
}
|
||||
|
||||
fclose( binstream );
|
||||
}
|
||||
|
||||
output()
|
||||
{
|
||||
/* output the listing */
|
||||
alpha_out();
|
||||
|
||||
/* if ascii pseudo binary output is requested then do it */
|
||||
if ( abinfile != NULL ) {
|
||||
write_abinary();
|
||||
}
|
||||
|
||||
/* if binary output is requested then do it */
|
||||
if ( binfile != NULL ) {
|
||||
write_binary();
|
||||
}
|
||||
}
|
||||
443
usr.etc/fpa/microassembler+/ramtable.c
Normal file
443
usr.etc/fpa/microassembler+/ramtable.c
Normal file
@@ -0,0 +1,443 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)ramtable.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This module contains the functions that parse the routine pseudo op
|
||||
* for the FPA-3X Microcode Assembler.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "micro.h"
|
||||
|
||||
/* defines used to construct the call instruction with aseq() */
|
||||
#define RTN_BRANCH 0x2
|
||||
#define RTN_COND 0x0
|
||||
#define RTN_STATE 0x0
|
||||
#define RTN_LATCH 0x1
|
||||
|
||||
#define MAXMAP 4095 /* highest location of a map ram entry */
|
||||
|
||||
/* macros used to scan a line of code */
|
||||
#define scansp(c) while(isspace(c = *curpos)) curpos++
|
||||
#define scanb(c) scansp(c); if (c == ',' ){c=nextc(); scansp(c);}
|
||||
#define nextc() *++curpos
|
||||
#define peekc() *curpos
|
||||
|
||||
/* data used to assemble the call instruction */
|
||||
int func, src, regctl, csrc, outenable, conf, halt,
|
||||
dctrl, ramcs, ramptr, ptr, act, num;
|
||||
SYMTYPE which;
|
||||
char *sym;
|
||||
|
||||
/* forward declarations */
|
||||
Boolean rtn_tipart(), rtn_ramoppart(), rtn_ramctlpart(), rtn_ptrpart();
|
||||
|
||||
/* external functions */
|
||||
extern char *scansym();
|
||||
|
||||
/* external data */
|
||||
char *curpos;
|
||||
extern short curaddr;
|
||||
extern NODE *curnode;
|
||||
|
||||
doramtable()
|
||||
{
|
||||
register char c;
|
||||
register dontcare = 0;
|
||||
register mask = 0;
|
||||
RESERVED *rp;
|
||||
SYMBOL *sp;
|
||||
char *cp;
|
||||
char name[20];
|
||||
char addr[13];
|
||||
int i;
|
||||
Boolean first;
|
||||
int load;
|
||||
int saveaddr;
|
||||
|
||||
scanb(c);
|
||||
cp = scansym( ); /* routine name */
|
||||
cp = strcpy (name, cp);
|
||||
name[19] = '\0';
|
||||
|
||||
scanb( c );
|
||||
for ( i = 0; i <= 11; i++ ) {
|
||||
c = peekc();
|
||||
switch (c) {
|
||||
case '0':
|
||||
addr[i] = '0';
|
||||
dontcare = (dontcare << 1) + 1;
|
||||
mask = mask << 1;
|
||||
break;
|
||||
case '1':
|
||||
addr[i] = '1';
|
||||
dontcare = (dontcare << 1) + 1;
|
||||
mask = (mask << 1) + 1;
|
||||
break;
|
||||
case 'x':
|
||||
addr[i] = 'x';
|
||||
dontcare = dontcare << 1;
|
||||
mask = mask << 1;
|
||||
break;
|
||||
default:
|
||||
goto botch;
|
||||
}
|
||||
nextc();
|
||||
}
|
||||
addr[12] = '\0';
|
||||
scanb(c);
|
||||
|
||||
/* check for instruction to be encoded into the call */
|
||||
if ( rtn_tipart() == True ) {
|
||||
if ( rtn_ramoppart() == True ) {
|
||||
if ( rtn_ramctlpart() == True ) {
|
||||
rtn_ptrpart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveaddr = curaddr;
|
||||
for ( i = 0; i < MAXMAP; i++ ) {
|
||||
if ( ( i & dontcare ) == mask ) {
|
||||
curnode->addr = curaddr = i;
|
||||
curnode->routine = True;
|
||||
|
||||
/* assemble the instruction */
|
||||
acode();
|
||||
aseq( RTN_BRANCH, RTN_COND, ALPHA, 0, name, RTN_STATE, RTN_LATCH );
|
||||
ati8847( func, src, regctl, csrc, outenable, halt, conf );
|
||||
adata( dctrl );
|
||||
aram( ramcs, ramptr );
|
||||
aptr( ptr, act, which, num, sym );
|
||||
anext();
|
||||
}
|
||||
}
|
||||
curnode--; /* slight kludge to undo side effect of anext */
|
||||
curaddr = saveaddr;
|
||||
|
||||
/* enter name into symbol table */
|
||||
sp = lookup( name );
|
||||
if ( sp == 0 ) {
|
||||
sp = enter( name );
|
||||
}
|
||||
label( sp );
|
||||
|
||||
return;
|
||||
wbotch :
|
||||
error ("%s found in routine pseudo_op", rp );
|
||||
return;
|
||||
botch:
|
||||
error ("%c is not expected in routine pseudo_op", c );
|
||||
}
|
||||
|
||||
Boolean
|
||||
rtn_tipart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return True;} \
|
||||
rp = resw_lookup( cp = scansym( ) ); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
|
||||
func = 0x020; /* default to spass */
|
||||
src = 0xff; /* default to RA input register */
|
||||
regctl = 0;
|
||||
csrc = 0;
|
||||
outenable = 0x2;
|
||||
conf = 1;
|
||||
halt = 0;
|
||||
|
||||
scanb(c);
|
||||
|
||||
if ( c == '\0' || c == '|' ) {
|
||||
return True;
|
||||
}
|
||||
|
||||
if ( c == ';' ) { /* no TIinst field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if ( rp->type == Function ) {
|
||||
func = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
if ( rp->type == Source && rp->value2 == 1 ) {
|
||||
src = ( src & ~0x03 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 2 ) {
|
||||
src = ( src & ~0x0c ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 3 ) {
|
||||
src = ( src & ~0x30 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 4 ) {
|
||||
src = ( src & ~0xc0 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
}
|
||||
if ( rp->type == Regctl && rp->value2 == 1 ) {
|
||||
regctl = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Regctl && rp->value2 == 2 ) {
|
||||
regctl += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Csrc && rp->value2 == 1 ) {
|
||||
csrc = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Csrc && rp->value2 == 2 ) {
|
||||
csrc += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Output && rp->value2 == 1 ) {
|
||||
outenable = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Output && rp->value2 == 2 ) {
|
||||
outenable += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Config ) {
|
||||
conf = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Halt ) {
|
||||
halt = rp->value1;
|
||||
scanb( c );
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
wbotch :
|
||||
error ("%s found in TIinst field", cp );
|
||||
return False;
|
||||
botch:
|
||||
error ("TIinst syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
|
||||
#undef CHEK
|
||||
|
||||
}
|
||||
|
||||
Boolean
|
||||
rtn_ramoppart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return True;} \
|
||||
rp = resw_lookup( cp = scansym( ) ); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
|
||||
dctrl = 017; /* default to idle state */
|
||||
scanb(c);
|
||||
|
||||
if ( c == '\0' || c == '|' ) {
|
||||
return True;
|
||||
}
|
||||
|
||||
if ( c == ';' ) { /* no datamuxing field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if (rp->type == Regram ) {
|
||||
dctrl = rp->value1;
|
||||
scanb(c);
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
error ("ramop syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
wbotch :
|
||||
error ("%s found in ramop field", cp );
|
||||
return False;
|
||||
|
||||
#undef CHEK
|
||||
|
||||
}
|
||||
|
||||
Boolean
|
||||
rtn_ramctlpart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return True;} \
|
||||
rp = resw_lookup(cp=scansym( )); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
|
||||
ramcs = 0;
|
||||
ramptr = 0;
|
||||
scanb(c);
|
||||
|
||||
if ( c == '\0' || c == '|' ) {
|
||||
return True;
|
||||
}
|
||||
|
||||
if ( c == ';' ) { /* no ramctrl field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if (rp->type == Ramcs ) {
|
||||
ramcs = rp->value1;
|
||||
scanb(c);
|
||||
CHEK
|
||||
}
|
||||
if (rp->type == Pointer ) {
|
||||
if ( rp->value2 == 2 ) {
|
||||
error("pointer %s is not allowed here", cp);
|
||||
return False;
|
||||
}
|
||||
ramptr = rp->value1;
|
||||
scanb(c);
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
error ("ram control field syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
wbotch :
|
||||
error ("%s found in ram control field", cp );
|
||||
return False;
|
||||
|
||||
#undef CHEK
|
||||
}
|
||||
|
||||
Boolean
|
||||
rtn_ptrpart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED*rp;
|
||||
register char *cp;
|
||||
|
||||
ptr = 0;
|
||||
act = 0;
|
||||
which = NEITHER;
|
||||
scanb(c);
|
||||
|
||||
if ( c == '\0' || c == '|' ) {
|
||||
return True;
|
||||
}
|
||||
|
||||
if ( c== '|' || c == '\0' ) { /* no ptr_action field */
|
||||
if ( c == '|' ) {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
}
|
||||
return True;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if ( rp->type == Pointer ) {
|
||||
if ( rp->value2 == 1 ) {
|
||||
error("pointer %s is not allowed here", cp);
|
||||
return False;
|
||||
}
|
||||
ptr = rp->value1;
|
||||
scanb(c);
|
||||
switch (c) {
|
||||
case '=' : /* hold */
|
||||
act = 0;
|
||||
break;
|
||||
case '!':
|
||||
if ( ptr == 1 || ptr == 2 || ptr == 3 || ptr == 4) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 1; /* load */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if ( c == '|' || c == '\0' ) return True;
|
||||
if ( curnode->jumpop == True ) {
|
||||
error("overlap address field with load value");
|
||||
return False;
|
||||
}
|
||||
if (isdigit(c)) {
|
||||
which = NUMBER;
|
||||
num = getnum( );
|
||||
scanb(c);
|
||||
if ( c == '+') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if (! isdigit(c)) goto wbotch;
|
||||
num += getnum();
|
||||
curpos--;
|
||||
} else {
|
||||
curpos--;
|
||||
}
|
||||
} else if(isalpha(c)) {
|
||||
which = ALPHA;
|
||||
sym = scansym( );
|
||||
} else goto wbotch;
|
||||
break;
|
||||
case '+':
|
||||
if ( ptr == 6 || ptr == 7 ) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 3;
|
||||
break;
|
||||
case '-':
|
||||
if ( ptr == 7 ) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 2;
|
||||
break;
|
||||
default :
|
||||
error ("ptr control field syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
}
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if ( c == '|' || c == '\0' ) return True;
|
||||
}
|
||||
|
||||
wbotch :
|
||||
error ("%s found in ptr control field", cp );
|
||||
return False;
|
||||
|
||||
}
|
||||
724
usr.etc/fpa/microassembler+/scan.c
Normal file
724
usr.etc/fpa/microassembler+/scan.c
Normal file
@@ -0,0 +1,724 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)scan.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Microassembler scanner for FPA
|
||||
* scan.c 1.1 30 May 1985
|
||||
*/
|
||||
|
||||
#include "micro.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#define scansp(c) while(isspace(c = *curpos)) curpos++
|
||||
#define scanb(c) scansp(c); if (c == ',' ){c=nextc(); scansp(c);}
|
||||
#define nextc() *++curpos
|
||||
#define peekc() *curpos
|
||||
#define MAXSYMBOL 256
|
||||
#define MAXLINE 1024
|
||||
|
||||
int curlineno;
|
||||
char *curfilename;
|
||||
char *curpos;
|
||||
char *curline;
|
||||
char inputline[MAXLINE];
|
||||
|
||||
/* The following 2 lines added by PWC to count lines of ucode. */
|
||||
extern NODE n[];
|
||||
extern NODE *curnode;
|
||||
extern short curaddr;
|
||||
extern short maxaddr;
|
||||
extern CODE code[];
|
||||
extern CODE *curword;
|
||||
|
||||
extern Boolean aseq();
|
||||
extern Boolean ati8847();
|
||||
extern Boolean adata();
|
||||
extern Boolean arecreg();
|
||||
extern Boolean aram();
|
||||
extern Boolean aptr();
|
||||
extern char *strcpy();
|
||||
|
||||
Boolean
|
||||
newline(){
|
||||
/* glom a new input line.
|
||||
* clobber comments. do
|
||||
* continuation-line collection, as well.
|
||||
*/
|
||||
register char * maxpos = inputline + sizeof inputline - 1;
|
||||
register char *cp;
|
||||
char *end;
|
||||
register c;
|
||||
int len;
|
||||
|
||||
cp = inputline;
|
||||
restart:
|
||||
curlineno++;
|
||||
do {
|
||||
c = getchar();
|
||||
if (c == '&') {
|
||||
while ( getchar() != '\n' );
|
||||
goto restart;
|
||||
}
|
||||
*cp++ = c;
|
||||
} while ( c != '\n' && c != EOF && cp < maxpos );
|
||||
if ( c == EOF ) return False;
|
||||
end = cp;
|
||||
*cp = '\0';
|
||||
if (cp == maxpos){
|
||||
error("Sorry, line(s) too long");
|
||||
goto process;
|
||||
}
|
||||
process:
|
||||
curpos = inputline;
|
||||
len = end-inputline;
|
||||
curline = (char*)malloc(len+2);
|
||||
if (curline == 0) {
|
||||
error("unable to get sufficient storage\n");
|
||||
return False;
|
||||
}
|
||||
strcpy( curline, inputline );
|
||||
return True;
|
||||
}
|
||||
|
||||
char *
|
||||
scansym( )
|
||||
{
|
||||
static char stuff[MAXSYMBOL];
|
||||
register char *cp;
|
||||
register char c;
|
||||
Boolean ok = True;
|
||||
|
||||
cp = stuff;
|
||||
curpos -= 1; /*back up to get a running start*/
|
||||
while( ok ){
|
||||
while (isalnum(*cp++ = c = nextc()));
|
||||
switch(c){
|
||||
case '.':
|
||||
case '_':
|
||||
case '\\':
|
||||
continue;
|
||||
default:
|
||||
ok = False;
|
||||
}
|
||||
}
|
||||
*--cp = '\0';
|
||||
return( stuff );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
getnum( )
|
||||
{
|
||||
register char c = *curpos;
|
||||
register int val, base;
|
||||
int sign;
|
||||
|
||||
sign = 1;
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = nextc();
|
||||
} else if (c == '+') {
|
||||
c = nextc();
|
||||
}
|
||||
val = c - '0';
|
||||
base = (val==0)? 010 : 10;
|
||||
c = nextc();
|
||||
if ( val == 0 && (c == 'x' || c == 'X') ){
|
||||
base = 0x10;
|
||||
c = nextc();
|
||||
}
|
||||
while(isxdigit(c)){
|
||||
val *= base;
|
||||
if( isdigit(c) )
|
||||
val += c -'0';
|
||||
else if (islower(c))
|
||||
val += c -'a' + 10;
|
||||
else
|
||||
val += c -'A' + 10;
|
||||
c = nextc();
|
||||
}
|
||||
if (sign == -1) {
|
||||
val = -val;
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
|
||||
Boolean
|
||||
seqpart (name)
|
||||
char *name;
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
register char *cp;
|
||||
int brnch = 001; /* default to next */
|
||||
int condition = 0; /* default to never */
|
||||
int state = 0; /* default */
|
||||
int latch = 1;
|
||||
int offset;
|
||||
SYMTYPE which = NEITHER;
|
||||
int num = 0;
|
||||
static char buff[MAXSYMBOL];
|
||||
char *labl = buff;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return ASEQ;} \
|
||||
rp = resw_lookup( cp = scansym( ) ); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
#define ASEQ aseq( brnch, condition, which, num, labl, state, latch )
|
||||
|
||||
if ( name == 0 && peekc() == ';') { /* no seq field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ASEQ;
|
||||
}
|
||||
|
||||
start:
|
||||
rp = resw_lookup( cp = name );
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if ( rp->type == Branch1) {
|
||||
brnch = rp->value1;
|
||||
scanb(c);
|
||||
if ( rp->value2 == 2 ) {
|
||||
curnode->jumpop = True;
|
||||
if ( isdigit(c) || c == '.' ) goto address;
|
||||
if ( isalpha(c) ) {
|
||||
rp = resw_lookup(cp = scansym());
|
||||
if ( rp == 0 ) {
|
||||
which = ALPHA;
|
||||
strcpy (labl, cp);
|
||||
scanb(c);
|
||||
CHEK;
|
||||
}
|
||||
} else goto botch;
|
||||
} else {
|
||||
CHEK
|
||||
}
|
||||
}
|
||||
if ( rp->type == Branch2 ) {
|
||||
condition = rp->value1;
|
||||
address:
|
||||
curnode->jumpop = True;
|
||||
scanb(c);
|
||||
if (isdigit(c)) {
|
||||
which = NUMBER;
|
||||
num = getnum( );
|
||||
scanb(c);
|
||||
} else if (isalpha(c)) {
|
||||
which = ALPHA;
|
||||
strcpy (labl, scansym( ));
|
||||
scanb(c);
|
||||
} else if (c == '.') {
|
||||
which = NUMBER;
|
||||
offset = 0;
|
||||
c = nextc( );
|
||||
scanb(c);
|
||||
if (c == '+') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
offset = getnum();
|
||||
scanb(c);
|
||||
} else if (c == '-') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
offset = -getnum();
|
||||
scanb(c);
|
||||
}
|
||||
num = curaddr - 1 + offset;
|
||||
} else goto botch;
|
||||
CHEK
|
||||
}
|
||||
if ( rp->type == State ) {
|
||||
state = rp->value1;
|
||||
scanb(c);
|
||||
CHEK
|
||||
}
|
||||
if ( rp->type == Latch && rp->value2 == 1 ) {
|
||||
latch = rp->value1;
|
||||
scanb(c);
|
||||
CHEK
|
||||
if ( rp->type == Latch && rp->value2 == 2 ) {
|
||||
latch += rp->value1;
|
||||
scanb(c);
|
||||
CHEK
|
||||
}
|
||||
}
|
||||
if ( rp->type == Latch && rp->value2 == 3 ) {
|
||||
latch += rp->value1;
|
||||
scanb(c);
|
||||
if ( c == ';' ) {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ASEQ;
|
||||
}
|
||||
}
|
||||
wbotch :
|
||||
error ("%s found in seq_state field", cp );
|
||||
return False;
|
||||
botch:
|
||||
error ("seq_state field syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
|
||||
#undef ASEQ
|
||||
#undef CHEK
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
tipart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
int func = 0x020, /* default to spass */
|
||||
src = 0xff, /* default to RA input register */
|
||||
regctl = 0,
|
||||
csrc = 0,
|
||||
output = 0x2,
|
||||
conf = 1,
|
||||
halt = 0;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return ATI8847;} \
|
||||
rp = resw_lookup( cp = scansym( ) ); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
#define ATI8847 ati8847( func, src, regctl, csrc, output, halt, conf )
|
||||
|
||||
scanb(c);
|
||||
if ( c == ';' ) { /* no TIinst field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ATI8847;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if ( rp->type == Function ) {
|
||||
func = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
if ( rp->type == Source && rp->value2 == 1 ) {
|
||||
src = ( src & ~0x03 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 2 ) {
|
||||
src = ( src & ~0x0c ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 3 ) {
|
||||
src = ( src & ~0x30 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Source && rp->value2 == 4 ) {
|
||||
src = ( src & ~0xc0 ) | rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
}
|
||||
if ( rp->type == Regctl && rp->value2 == 1 ) {
|
||||
regctl = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Regctl && rp->value2 == 2 ) {
|
||||
regctl += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Csrc && rp->value2 == 1 ) {
|
||||
csrc = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Csrc && rp->value2 == 2 ) {
|
||||
csrc += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Output && rp->value2 == 1 ) {
|
||||
output = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Output && rp->value2 == 2 ) {
|
||||
output += rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Config ) {
|
||||
conf = rp->value1;
|
||||
scanb( c );
|
||||
CHEK;
|
||||
}
|
||||
if ( rp->type == Halt ) {
|
||||
halt = rp->value1;
|
||||
scanb( c );
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ATI8847;
|
||||
}
|
||||
}
|
||||
|
||||
wbotch :
|
||||
error ("%s found in TIinst field", cp );
|
||||
return False;
|
||||
botch:
|
||||
error ("TIinst syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
|
||||
#undef CHEK
|
||||
#undef ATI8847
|
||||
|
||||
}
|
||||
|
||||
Boolean
|
||||
ramoppart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
int dctrl = 017; /* default to idle state */
|
||||
|
||||
#define ADATA adata(dctrl)
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return ADATA;} \
|
||||
rp = resw_lookup( cp = scansym( ) ); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
|
||||
scanb(c);
|
||||
if ( c == ';' ) { /* no datamuxing field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ADATA;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if (rp->type == Regram ) {
|
||||
dctrl = rp->value1;
|
||||
scanb(c);
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ADATA;
|
||||
}
|
||||
}
|
||||
error ("ramop syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
wbotch :
|
||||
error ("%s found in ramop field", cp );
|
||||
return False;
|
||||
|
||||
#undef ADATA
|
||||
#undef CHEK
|
||||
|
||||
}
|
||||
|
||||
Boolean
|
||||
ramctlpart()
|
||||
{
|
||||
register char c;
|
||||
register RESERVED *rp;
|
||||
char *cp;
|
||||
int ramcs = 0,
|
||||
ptr = 0;
|
||||
|
||||
#define CHEK if(c==';') {c=nextc(); scanb(c); return ARAM;} \
|
||||
rp = resw_lookup(cp=scansym( )); \
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
#define ARAM aram ( ramcs, ptr )
|
||||
|
||||
scanb(c);
|
||||
if ( c == ';' ) { /* no ramctrl field */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ARAM;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if (rp->type == Ramcs ) {
|
||||
ramcs = rp->value1;
|
||||
scanb(c);
|
||||
CHEK
|
||||
}
|
||||
if (rp->type == Pointer ) {
|
||||
if ( rp->value2 == 2 ) {
|
||||
error("pointer %s is not allowed here", cp);
|
||||
return False;
|
||||
}
|
||||
ptr = rp->value1;
|
||||
scanb(c);
|
||||
if (c == ';') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
return ARAM;
|
||||
}
|
||||
}
|
||||
error ("ram control field syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
wbotch :
|
||||
error ("%s found in ram control field", cp );
|
||||
return False;
|
||||
|
||||
#undef CHEK
|
||||
#undef ARAM
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
ptrpart ( )
|
||||
{
|
||||
register char c;
|
||||
register RESERVED*rp;
|
||||
register char *cp;
|
||||
int ptr = 0;
|
||||
int act = 0;
|
||||
SYMTYPE which = NEITHER;
|
||||
int num;
|
||||
char *sym;
|
||||
|
||||
#define APTR aptr( ptr, act, which, num, sym)
|
||||
|
||||
scanb(c);
|
||||
if ( c== '|' || c == '\0' ) { /* no ptr_action field */
|
||||
if ( c == '|' ) {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
}
|
||||
return APTR;
|
||||
}
|
||||
rp = resw_lookup(cp=scansym( ));
|
||||
if ( rp == 0 ) goto wbotch;
|
||||
if ( rp->type == Pointer ) {
|
||||
if ( rp->value2 == 1 ) {
|
||||
error("pointer %s is not allowed here", cp);
|
||||
return False;
|
||||
}
|
||||
ptr = rp->value1;
|
||||
scanb(c);
|
||||
switch (c) {
|
||||
case '=' : /* hold */
|
||||
act = 0;
|
||||
break;
|
||||
case '!':
|
||||
if ( ptr == 1 || ptr == 2 || ptr == 3 || ptr == 4) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 1; /* load */
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if ( c == '|' || c == '\0' ) return APTR;
|
||||
if ( curnode->jumpop == True ) {
|
||||
error("overlap address field with load value");
|
||||
return False;
|
||||
}
|
||||
if (isdigit(c)) {
|
||||
which = NUMBER;
|
||||
num = getnum( );
|
||||
scanb(c);
|
||||
if ( c == '+') {
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if (! isdigit(c)) goto wbotch;
|
||||
num += getnum();
|
||||
curpos--;
|
||||
} else {
|
||||
curpos--;
|
||||
}
|
||||
} else if(isalpha(c)) {
|
||||
which = ALPHA;
|
||||
sym = scansym( );
|
||||
} else goto wbotch;
|
||||
break;
|
||||
case '+':
|
||||
if ( ptr == 6 || ptr == 7 ) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 3;
|
||||
break;
|
||||
case '-':
|
||||
if ( ptr == 7 ) {
|
||||
error("action is not allowed for the pointer");
|
||||
return False;
|
||||
}
|
||||
act = 2;
|
||||
break;
|
||||
default :
|
||||
error ("ptr control field syntax error, character %c is not expected", c);
|
||||
return False;
|
||||
}
|
||||
c = nextc();
|
||||
scanb(c);
|
||||
if ( c == '|' || c == '\0' ) return APTR;
|
||||
}
|
||||
|
||||
wbotch :
|
||||
error ("%s found in ptr control field", cp );
|
||||
return False;
|
||||
|
||||
#undef APTR
|
||||
|
||||
}
|
||||
|
||||
label(sp)
|
||||
SYMBOL *sp;
|
||||
{
|
||||
if (sp->defined){
|
||||
error("label %s already defined", sp->name );
|
||||
return;
|
||||
}
|
||||
sp->defined = True;
|
||||
sp->node = curnode+1;
|
||||
DEBUG("Label: defining %s\n", sp->name);
|
||||
}
|
||||
|
||||
Boolean
|
||||
cpp(){
|
||||
/* the scanner just saw a '#' -- treat as cpp leaving */
|
||||
register char c ;
|
||||
char *sp;
|
||||
int leng;
|
||||
int cln;
|
||||
|
||||
nextc();
|
||||
scanb(c);
|
||||
cln = curlineno;
|
||||
curlineno = getnum( ) - 1;
|
||||
scanb(c);
|
||||
if (c != '"') {
|
||||
curlineno = cln;
|
||||
error("#-line not of form output by C preprocessor");
|
||||
return False;
|
||||
}
|
||||
/* just saw the " */
|
||||
c = nextc(); /* skip it */
|
||||
sp = curpos;
|
||||
while( (c=nextc()) != '"' );
|
||||
*curpos = '\0';
|
||||
leng = strlen( sp );
|
||||
curfilename = (char *)malloc( leng+1 );
|
||||
if (curfilename == 0) {
|
||||
error("unable to get sufficient storage\n");
|
||||
return False;
|
||||
}
|
||||
strcpy( curfilename, sp );
|
||||
DEBUG("# %d \"%s\"\n", curlineno+1, curfilename);
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
scanprog()
|
||||
{
|
||||
/*
|
||||
for each line in the program text:
|
||||
if it is blank, continue.
|
||||
if it begins with a '#', its a cpp dropping
|
||||
look at the first symbol on the line.
|
||||
if it is followed by a :, its a label,
|
||||
so define the label and scan out the next symbol
|
||||
assemble the seq_state part
|
||||
assemble the Weitek instruction part
|
||||
assemble the datamuxing part
|
||||
assemble the recover reg ctrl part
|
||||
assemble the ram control part
|
||||
assemble the pointer actoin part
|
||||
|
||||
*/
|
||||
char c;
|
||||
char *name;
|
||||
SYMBOL *sp;
|
||||
Boolean stopsw = False;
|
||||
Boolean bkptsw = False;
|
||||
int debugsw = 0;
|
||||
register RESERVED *rp;
|
||||
Boolean checkeol();
|
||||
|
||||
while (newline()){
|
||||
if (*curpos == '#'){
|
||||
cpp();
|
||||
continue;
|
||||
}
|
||||
restart:
|
||||
scanb(c);
|
||||
if( c == '\0') {
|
||||
continue; /* blank line */
|
||||
}
|
||||
if (c == ';') {
|
||||
name = 0;
|
||||
anext();
|
||||
goto doseq;
|
||||
}
|
||||
if (!isalnum(c)) {
|
||||
if (c != '|') {
|
||||
error("character %c unexpected", c);
|
||||
}
|
||||
anext();
|
||||
curnode->org_pseudo = True;
|
||||
continue;
|
||||
}
|
||||
name = scansym( );
|
||||
scanb(c);
|
||||
if(c== ':') {
|
||||
/* what we have here is a label */
|
||||
sp = lookup( name );
|
||||
if (sp == 0)
|
||||
sp = enter( name );
|
||||
label( sp );
|
||||
nextc();
|
||||
scanb(c);
|
||||
(curnode+1)->addr = curaddr;
|
||||
if (c == '\0') {
|
||||
anext();
|
||||
curnode->org_pseudo = True;
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
anext();
|
||||
rp = resw_lookup( name );
|
||||
if (rp != 0 && rp->type == Pseudo) {
|
||||
/* it's a pseudo-op */
|
||||
switch (rp->value1) {
|
||||
case 1: /* org */
|
||||
scanb(c);
|
||||
if (!isdigit(c)) {
|
||||
error("expected digit; found %c", c);
|
||||
continue;
|
||||
}
|
||||
curnode->org_pseudo = True;
|
||||
curaddr = getnum();
|
||||
break;
|
||||
case 2: /* sccsid */
|
||||
scanb(c);
|
||||
acode();
|
||||
asccs(curpos);
|
||||
curnode->addr = curaddr++;
|
||||
if ( curaddr > maxaddr ) {
|
||||
maxaddr = curaddr;
|
||||
}
|
||||
break;
|
||||
case 3: /* routine */
|
||||
doramtable( );
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
doseq:
|
||||
acode();
|
||||
curnode->addr = curaddr++;
|
||||
if ( curaddr > maxaddr ) {
|
||||
maxaddr = curaddr;
|
||||
}
|
||||
if (seqpart(name) == False) continue;
|
||||
if (tipart( ) == False) continue;
|
||||
if (ramoppart( ) == False) continue;
|
||||
if (ramctlpart( ) == False) continue;
|
||||
ptrpart( );
|
||||
}
|
||||
}
|
||||
477
usr.etc/fpa/microassembler+/sym.c
Normal file
477
usr.etc/fpa/microassembler+/sym.c
Normal file
@@ -0,0 +1,477 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)sym.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Micro-assembler symbol-table management
|
||||
* sym.c 1.0 2 JUN. 85
|
||||
*/
|
||||
|
||||
#include "micro.h"
|
||||
|
||||
SYMBOL syms[NSYM], *cursym = syms;
|
||||
char strings[NSTRING], *curstring = strings;
|
||||
|
||||
RESERVED *rhash[NHASH];
|
||||
SYMBOL *shash[NHASH];
|
||||
|
||||
RESERVED words[] = {
|
||||
|
||||
/* Pseudo-ops */
|
||||
{ "org", Pseudo, 1, },
|
||||
{ "sccsid", Pseudo, 2, },
|
||||
{ "routine", Pseudo, 3, },
|
||||
|
||||
/* Microcode address source */
|
||||
{ "pipe", Branch1, 0x0, 0, },
|
||||
{ "next", Branch1, 0x1, 0, },
|
||||
{ "call", Branch1, 0x2, 2, },
|
||||
{ "rtn", Branch1, 0x3, 0, },
|
||||
|
||||
/* Jump contional code */
|
||||
{ "jmp", Branch2, 0x01, 1, },
|
||||
{ "jgt", Branch2, 0x02, 1, },
|
||||
{ "jge", Branch2, 0x03, 1, },
|
||||
{ "jlt", Branch2, 0x04, 1, },
|
||||
{ "jle", Branch2, 0x05, 1, },
|
||||
{ "jeq", Branch2, 0x06, 1, },
|
||||
{ "jne", Branch2, 0x07, 1, },
|
||||
{ "jloop0", Branch2, 0x08, 1, },
|
||||
{ "jloop", Branch2, 0x09, 1, },
|
||||
{ "jtierr", Branch2, 0x0a, 1, },
|
||||
{ "jnotierr", Branch2, 0x0b, 1, },
|
||||
{ "jclr", Branch2, 0x0c, 1, },
|
||||
{ "jtifast", Branch2, 0x0d, 1, },
|
||||
|
||||
/* State */
|
||||
{ "idl1", State, 0x2, },
|
||||
{ "idl2", State, 0x4, },
|
||||
{ "hng", State, 0x1, },
|
||||
|
||||
/* Register RAM operations */
|
||||
{ "regtoti", Regram, 0x0, },
|
||||
{ "titoreg", Regram, 0x1, },
|
||||
{ "regtotmp", Regram, 0x2, },
|
||||
{ "tmptoreg", Regram, 0x3, },
|
||||
{ "tmptoti", Regram, 0x4, },
|
||||
{ "titotmp", Regram, 0x5, },
|
||||
{ "adtoti", Regram, 0x6, },
|
||||
{ "adtoreg", Regram, 0x7, },
|
||||
{ "optoti", Regram, 0x8, },
|
||||
{ "optoreg", Regram, 0x9, },
|
||||
{ "readreg", Regram, 0xa, },
|
||||
{ "restore", Regram, 0xb, },
|
||||
{ "regtitmp", Regram, 0xc, },
|
||||
|
||||
/* Latch */
|
||||
{ "cstat", Latch, 0, 1, },
|
||||
{ "unimpl", Latch, 2, 2, },
|
||||
{ "cdata", Latch, 0, 3, },
|
||||
|
||||
/* Pointers */
|
||||
{ "lptr", Pointer, 0, 1, },
|
||||
{ "ptr1", Pointer, 1, 0, },
|
||||
{ "ptr2", Pointer, 2, 0, },
|
||||
{ "ptr3", Pointer, 3, 0, },
|
||||
{ "ptr4", Pointer, 4, 0, },
|
||||
{ "ptr5", Pointer, 5, 0, },
|
||||
{ "imm2", Pointer, 6, 1, },
|
||||
{ "imm3", Pointer, 7, 1, },
|
||||
{ "lpreg", Pointer, 6, 2, },
|
||||
{ "mreg", Pointer, 7, 2, },
|
||||
|
||||
/* Ram CS- */
|
||||
{ "rcsmsw", Ramcs, 0, },
|
||||
{ "rcslsw", Ramcs, 1, },
|
||||
{ "rcssp", Ramcs, 0, },
|
||||
|
||||
/* Instruction input */
|
||||
{ "sadd", Function, 0x000 },
|
||||
{ "ssub", Function, 0x001 },
|
||||
{ "scmp", Function, 0x002 },
|
||||
{ "srsub", Function, 0x003 },
|
||||
{ "ssum", Function, 0x004 },
|
||||
{ "sdiff", Function, 0x005 },
|
||||
{ "scmpym", Function, 0x006 },
|
||||
{ "srsubym", Function, 0x007 },
|
||||
{ "saddbm", Function, 0x008 },
|
||||
{ "ssubbm", Function, 0x009 },
|
||||
{ "scmpbm", Function, 0x00a },
|
||||
{ "srsubbm", Function, 0x00b },
|
||||
{ "saddbmym", Function, 0x00c },
|
||||
{ "ssubbmym", Function, 0x00d },
|
||||
{ "scmpbmym", Function, 0x00e },
|
||||
{ "srsubbmym", Function, 0x00f },
|
||||
{ "saddam", Function, 0x010 },
|
||||
{ "ssubam", Function, 0x011 },
|
||||
{ "scmpam", Function, 0x012 },
|
||||
{ "srsubam", Function, 0x013 },
|
||||
{ "saddamym", Function, 0x014 },
|
||||
{ "ssubamym", Function, 0x015 },
|
||||
{ "scmpamym", Function, 0x016 },
|
||||
{ "srsubamym", Function, 0x017 },
|
||||
{ "saddm", Function, 0x018 },
|
||||
{ "ssubm", Function, 0x019 },
|
||||
{ "scmpm", Function, 0x01a },
|
||||
{ "srsubm", Function, 0x01b },
|
||||
{ "saddmym", Function, 0x01c },
|
||||
{ "ssubmym", Function, 0x01d },
|
||||
{ "scmpmym", Function, 0x01e },
|
||||
{ "srsubmym", Function, 0x01f },
|
||||
{ "snop", Function, 0x020 },
|
||||
{ "sneg", Function, 0x021 },
|
||||
{ "sfloat", Function, 0x022 },
|
||||
{ "scvtint", Function, 0x023 },
|
||||
{ "scvtd", Function, 0x026 },
|
||||
{ "swdnrm", Function, 0x028 },
|
||||
{ "sexct", Function, 0x02c },
|
||||
{ "sinxct", Function, 0x02d },
|
||||
{ "srnd", Function, 0x02e },
|
||||
{ "sabs", Function, 0x030 },
|
||||
{ "snegym", Function, 0x031 },
|
||||
{ "sfloatym", Function, 0x032 },
|
||||
{ "scvtintym", Function, 0x033 },
|
||||
{ "scvtdym", Function, 0x036 },
|
||||
{ "swdnrmym", Function, 0x038 },
|
||||
{ "sexctym", Function, 0x03c },
|
||||
{ "sinxctym", Function, 0x03d },
|
||||
{ "srndym", Function, 0x03e },
|
||||
{ "smul", Function, 0x040 },
|
||||
{ "smwb", Function, 0x041 },
|
||||
{ "smwa", Function, 0x042 },
|
||||
{ "smwab", Function, 0x043 },
|
||||
{ "smn", Function, 0x044 },
|
||||
{ "smwbn", Function, 0x045 },
|
||||
{ "smwan", Function, 0x046 },
|
||||
{ "smwabn", Function, 0x047 },
|
||||
{ "smmb", Function, 0x048 },
|
||||
{ "smwbmb", Function, 0x049 },
|
||||
{ "smwamb", Function, 0x04a },
|
||||
{ "smwabmb", Function, 0x04b },
|
||||
{ "smmbn", Function, 0x04c },
|
||||
{ "smwbmbn", Function, 0x04d },
|
||||
{ "smwambn", Function, 0x04e },
|
||||
{ "smwabmbn", Function, 0x04f },
|
||||
{ "smma", Function, 0x050 },
|
||||
{ "smwbma", Function, 0x051 },
|
||||
{ "smwama", Function, 0x052 },
|
||||
{ "smwabma", Function, 0x053 },
|
||||
{ "smman", Function, 0x054 },
|
||||
{ "smwbman", Function, 0x055 },
|
||||
{ "smwaman", Function, 0x056 },
|
||||
{ "smwabman", Function, 0x057 },
|
||||
{ "smmab", Function, 0x058 },
|
||||
{ "smwbmab", Function, 0x059 },
|
||||
{ "smwamab", Function, 0x05a },
|
||||
{ "smwabmab", Function, 0x05b },
|
||||
{ "smmabn", Function, 0x05c },
|
||||
{ "smwbmabn", Function, 0x05d },
|
||||
{ "smwamabn", Function, 0x05e },
|
||||
{ "smwabmabn", Function, 0x05f },
|
||||
{ "sdiv", Function, 0x060 },
|
||||
{ "sdivb", Function, 0x061 },
|
||||
{ "sdiva", Function, 0x062 },
|
||||
{ "sdivab", Function, 0x063 },
|
||||
{ "sdn", Function, 0x064 },
|
||||
{ "sdbn", Function, 0x065 },
|
||||
{ "sdan", Function, 0x066 },
|
||||
{ "sdabn", Function, 0x067 },
|
||||
{ "sqrt", Function, 0x068 },
|
||||
{ "sqrta", Function, 0x06a },
|
||||
{ "sqrtn", Function, 0x06c },
|
||||
{ "sqrtan", Function, 0x06e },
|
||||
{ "sdivma", Function, 0x070 },
|
||||
{ "sdivmawb", Function, 0x071 },
|
||||
{ "sdivmawa", Function, 0x072 },
|
||||
{ "sdivmawab", Function, 0x073 },
|
||||
{ "sdivman", Function, 0x074 },
|
||||
{ "sdivmawbn", Function, 0x075 },
|
||||
{ "sdivmawan", Function, 0x076 },
|
||||
{ "sdivmawabn", Function, 0x077 },
|
||||
{ "sqrtma", Function, 0x078 },
|
||||
{ "sqrtwama", Function, 0x07a },
|
||||
{ "sqrtman", Function, 0x07c },
|
||||
{ "sqrtwaman", Function, 0x07e },
|
||||
{ "dadd", Function, 0x080 },
|
||||
{ "dsub", Function, 0x081 },
|
||||
{ "dcmp", Function, 0x082 },
|
||||
{ "drsub", Function, 0x083 },
|
||||
{ "dsum", Function, 0x084 },
|
||||
{ "ddiff", Function, 0x085 },
|
||||
{ "dcmpym", Function, 0x086 },
|
||||
{ "drsubym", Function, 0x087 },
|
||||
{ "daddbm", Function, 0x088 },
|
||||
{ "dsubbm", Function, 0x089 },
|
||||
{ "dcmpbm", Function, 0x08a },
|
||||
{ "drsubbm", Function, 0x08b },
|
||||
{ "daddbmym", Function, 0x08c },
|
||||
{ "dsubbmym", Function, 0x08d },
|
||||
{ "dcmpbmym", Function, 0x08e },
|
||||
{ "drsubbmym", Function, 0x08f },
|
||||
{ "daddam", Function, 0x090 },
|
||||
{ "dsubam", Function, 0x091 },
|
||||
{ "dcpmam", Function, 0x092 },
|
||||
{ "drsubam", Function, 0x093 },
|
||||
{ "daddamym", Function, 0x094 },
|
||||
{ "dsubamym", Function, 0x095 },
|
||||
{ "dcmpamym", Function, 0x096 },
|
||||
{ "drsubamym", Function, 0x097 },
|
||||
{ "daddm", Function, 0x098 },
|
||||
{ "dsubm", Function, 0x099 },
|
||||
{ "dcmpm", Function, 0x09a },
|
||||
{ "drsubm", Function, 0x09b },
|
||||
{ "daddmym", Function, 0x09c },
|
||||
{ "dsubmym", Function, 0x09d },
|
||||
{ "dcmpmym", Function, 0x09e },
|
||||
{ "drsubmym", Function, 0x09f },
|
||||
{ "dnop", Function, 0x0a0 },
|
||||
{ "dneg", Function, 0x0a1 },
|
||||
{ "dfloat", Function, 0x0a2 },
|
||||
{ "dcvtint", Function, 0x0a3 },
|
||||
{ "dcvts", Function, 0x0a6 },
|
||||
{ "dwdnrm", Function, 0x0a8 },
|
||||
{ "dinxct", Function, 0x0ad },
|
||||
{ "dinxctym", Function, 0x0bd },
|
||||
{ "dabs", Function, 0x0b0 },
|
||||
{ "dmul", Function, 0x0c0 },
|
||||
{ "dmwb", Function, 0x0c1 },
|
||||
{ "dmwa", Function, 0x0c2 },
|
||||
{ "dmwab", Function, 0x0c3 },
|
||||
{ "dmn", Function, 0x0c4 },
|
||||
{ "dmwbn", Function, 0x0c5 },
|
||||
{ "dmwan", Function, 0x0c6 },
|
||||
{ "dmwabn", Function, 0x0c7 },
|
||||
{ "dmmb", Function, 0x0c8 },
|
||||
{ "dmwbmb", Function, 0x0c9 },
|
||||
{ "dmwamb", Function, 0x0ca },
|
||||
{ "dmwabmb", Function, 0x0cb },
|
||||
{ "dmmbn", Function, 0x0cc },
|
||||
{ "dmwbmbn", Function, 0x0cd },
|
||||
{ "dmwambn", Function, 0x0ce },
|
||||
{ "dmwabmbn", Function, 0x0cf },
|
||||
{ "dmma", Function, 0x0d0 },
|
||||
{ "dmwbma", Function, 0x0d1 },
|
||||
{ "dmwama", Function, 0x0d2 },
|
||||
{ "dmwabma", Function, 0x0d3 },
|
||||
{ "dmman", Function, 0x0d4 },
|
||||
{ "dmwbman", Function, 0x0d5 },
|
||||
{ "dmwaman", Function, 0x0d6 },
|
||||
{ "dmwabman", Function, 0x0d7 },
|
||||
{ "dmmab", Function, 0x0d8 },
|
||||
{ "dmwbmab", Function, 0x0d9 },
|
||||
{ "dmwamab", Function, 0x0da },
|
||||
{ "dmwabmab", Function, 0x0db },
|
||||
{ "dmmabn", Function, 0x0dc },
|
||||
{ "dmwbmabn", Function, 0x0dd },
|
||||
{ "dmwamabn", Function, 0x0de },
|
||||
{ "dmwabmabn", Function, 0x0df },
|
||||
{ "dexct", Function, 0x0ac },
|
||||
{ "dexctym", Function, 0x0bc },
|
||||
{ "ddiv", Function, 0x0e0 },
|
||||
{ "ddivb", Function, 0x0e1 },
|
||||
{ "ddiva", Function, 0x0e2 },
|
||||
{ "ddivab", Function, 0x0e3 },
|
||||
{ "dadn", Function, 0x0e4 },
|
||||
{ "dadbn", Function, 0x0e5 },
|
||||
{ "dadan", Function, 0x0e6 },
|
||||
{ "dadabn", Function, 0x0e7 },
|
||||
{ "dsqrt", Function, 0x0e8 },
|
||||
{ "dsqrta", Function, 0x0ea },
|
||||
{ "dsqrtn", Function, 0x0ec },
|
||||
{ "dsqrtan", Function, 0x0ee },
|
||||
{ "ddivma", Function, 0x0f0 },
|
||||
{ "ddivmawb", Function, 0x0f1 },
|
||||
{ "ddivmawa", Function, 0x0f2 },
|
||||
{ "ddivmawab", Function, 0x0f3 },
|
||||
{ "ddivman", Function, 0x0f4 },
|
||||
{ "ddivmawbn", Function, 0x0f5 },
|
||||
{ "ddivmawan", Function, 0x0f6 },
|
||||
{ "ddivmawabn", Function, 0x0f7 },
|
||||
{ "dsqrtma", Function, 0x0f8 },
|
||||
{ "dsqrtwama", Function, 0x0fa },
|
||||
{ "dsqrtman", Function, 0x0fc },
|
||||
{ "dsqrtwaman", Function, 0x0fe },
|
||||
{ "i2add", Function, 0x100 },
|
||||
{ "i2sub", Function, 0x101 },
|
||||
{ "i2cmp", Function, 0x102 },
|
||||
{ "i2rsub", Function, 0x103 },
|
||||
{ "i2land", Function, 0x108 },
|
||||
{ "i2landnb", Function, 0x109 },
|
||||
{ "i2landna", Function, 0x10a },
|
||||
{ "i2lor", Function, 0x10c },
|
||||
{ "i2lxor", Function, 0x10d },
|
||||
{ "i2pass", Function, 0x120 },
|
||||
{ "i2negy2", Function, 0x121 },
|
||||
{ "i2negy1", Function, 0x122 },
|
||||
{ "i2sftll", Function, 0x128 },
|
||||
{ "i2sftrl", Function, 0x129 },
|
||||
{ "i2sftra", Function, 0x12d },
|
||||
{ "imul", Function, 0x140 },
|
||||
{ "idiv", Function, 0x160 },
|
||||
{ "isqrt", Function, 0x168 },
|
||||
{ "iuadd", Function, 0x180 },
|
||||
{ "iusub", Function, 0x181 },
|
||||
{ "iucmp", Function, 0x182 },
|
||||
{ "iursub", Function, 0x183 },
|
||||
{ "iuland", Function, 0x188 },
|
||||
{ "iulandnb", Function, 0x189 },
|
||||
{ "iulandna", Function, 0x18a },
|
||||
{ "iulor", Function, 0x18c },
|
||||
{ "iulxor", Function, 0x18d },
|
||||
{ "iupassy", Function, 0x1a0 },
|
||||
{ "iunegy2", Function, 0x1a1 },
|
||||
{ "iunegy1", Function, 0x1a2 },
|
||||
{ "iusftll", Function, 0x1a8 },
|
||||
{ "iusftrl", Function, 0x1a9 },
|
||||
{ "iusftra", Function, 0x1ad },
|
||||
{ "iumul", Function, 0x1c0 },
|
||||
{ "iudiv", Function, 0x1e0 },
|
||||
{ "iusqrt", Function, 0x1e8 },
|
||||
|
||||
/* Input source */
|
||||
{ "aluacreg", Source, 0x01, 1 },
|
||||
{ "aluamul", Source, 0x02, 1 },
|
||||
{ "aluara", Source, 0x03, 1 },
|
||||
{ "alubcreg", Source, 0x04, 2 },
|
||||
{ "alubalu", Source, 0x08, 2 },
|
||||
{ "alubrb", Source, 0x0c, 2 },
|
||||
{ "mulacreg", Source, 0x10, 3 },
|
||||
{ "mulaalu", Source, 0x20, 3 },
|
||||
{ "mulara", Source, 0x30, 3 },
|
||||
{ "mulbcreg", Source, 0x40, 4 },
|
||||
{ "mulbmul", Source, 0x80, 4 },
|
||||
{ "mulbrb", Source, 0xc0, 4 },
|
||||
|
||||
/* Output control */
|
||||
{ "tioe", Output, 0, 1 },
|
||||
{ "tilsw", Output, 0, 2 },
|
||||
{ "timsw", Output, 1, 2 },
|
||||
{ "tisp", Output, 1, 2 },
|
||||
|
||||
/* C register source */
|
||||
{ "srccalu", Csrc, 0, 1 },
|
||||
{ "srccmul", Csrc, 2, 1 },
|
||||
{ "clkcc", Csrc, 1, 2 },
|
||||
|
||||
/* Register control */
|
||||
{ "enra", Regctl, 2, 1 },
|
||||
{ "enrb", Regctl, 1, 2 },
|
||||
|
||||
/* Halt input */
|
||||
{ "halt", Halt, 1, },
|
||||
|
||||
/* Configuration */
|
||||
{ "loadrv", Config, 0 },
|
||||
{ "loadsp", Config, 1 },
|
||||
{ "loaddp", Config, 2 },
|
||||
{ "loadms", Config, 3 },
|
||||
|
||||
/* End of table */
|
||||
{ (char *)0, Tnull, 0, 0, }
|
||||
};
|
||||
|
||||
extern SYMBOL syms[];
|
||||
|
||||
init_symtab()
|
||||
{ int i;
|
||||
|
||||
for (i = 0; i < NSYM; i++) {
|
||||
syms[i].defined = False;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
hashval( s )
|
||||
char *s;
|
||||
{
|
||||
register int val = 0;
|
||||
|
||||
while (*s) {
|
||||
val = (val<<1) + *s++;
|
||||
}
|
||||
val %= NHASH;
|
||||
if (val < 0) val += NHASH;
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
resw_hash()
|
||||
{
|
||||
RESERVED *rp, **pp;
|
||||
|
||||
rp = words;
|
||||
while (rp->name) {
|
||||
pp = rhash + hashval(rp->name);
|
||||
rp->next_hash = *pp;
|
||||
*pp = rp;
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
RESERVED *
|
||||
resw_lookup( s )
|
||||
char *s;
|
||||
{
|
||||
register RESERVED *rp;
|
||||
|
||||
rp = rhash[hashval(s)];
|
||||
while (rp && strcmp(s,rp->name))
|
||||
rp = rp->next_hash;
|
||||
return rp;
|
||||
}
|
||||
|
||||
SYMBOL *
|
||||
lookup( s )
|
||||
char *s;
|
||||
{
|
||||
register SYMBOL *sp;
|
||||
|
||||
sp = shash[hashval(s)];
|
||||
while ( sp && strcmp( s, sp->name ))
|
||||
sp = sp->next_hash;
|
||||
return sp;
|
||||
}
|
||||
|
||||
SYMBOL *
|
||||
enter( s )
|
||||
char *s;
|
||||
{
|
||||
register SYMBOL *sp;
|
||||
SYMBOL **pp;
|
||||
register char *cp;
|
||||
int leng;
|
||||
|
||||
leng = strlen(s);
|
||||
cp = curstring;
|
||||
if ( curstring+leng > &strings[NSTRING-2])
|
||||
fatal( "out of string space");
|
||||
while( *cp++ = *s++)
|
||||
;
|
||||
if (cursym >= &syms[NSYM])
|
||||
fatal( "out of symbol space");
|
||||
sp = cursym++;
|
||||
pp = shash + hashval(sp->name = curstring);
|
||||
curstring = cp;
|
||||
sp->next_hash = *pp;
|
||||
*pp = sp;
|
||||
sp->node = 0;
|
||||
sp->addr = 0;
|
||||
return sp;
|
||||
}
|
||||
|
||||
SYMBOL *
|
||||
firstsym()
|
||||
{
|
||||
return (cursym == syms)? (SYMBOL *)0 : syms;
|
||||
}
|
||||
SYMBOL *
|
||||
nextsym( sp )
|
||||
SYMBOL *sp;
|
||||
{
|
||||
sp++;
|
||||
return (sp==cursym)? (SYMBOL *)0 : sp;
|
||||
}
|
||||
17
usr.etc/fpa/microassembler+/version.c
Normal file
17
usr.etc/fpa/microassembler+/version.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)version.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a small function that returns the current version of the assembler
|
||||
*/
|
||||
|
||||
char *
|
||||
version()
|
||||
{
|
||||
return "0.20 (October 14, 1988)";
|
||||
}
|
||||
Reference in New Issue
Block a user