mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-27 10:24:19 +00:00
Upload
Digital Research
This commit is contained in:
@@ -0,0 +1,724 @@
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "stdio.h"
|
||||
#include "acom.h"
|
||||
#include "obj.h"
|
||||
|
||||
/*
|
||||
* Version Z.3, 4/7/83. Added explicit fclose of LIST and OBJECT files,
|
||||
* in case of error exit.
|
||||
*
|
||||
* Version Z.2, 4/5/83. Added external declarations of the variables
|
||||
* segflg and oflag, which are used in chaining to xcon.
|
||||
*
|
||||
* Version Z.1, 10/14/82. killed profiling and made cpm changes.
|
||||
*
|
||||
* Version 3.7, 10/13/82. Changed dopass() so that the default section
|
||||
* at the beginning of each pass is "__text" rather than the absolute
|
||||
* section. This is a FUNCTIONAL CHANGE.
|
||||
*
|
||||
* Version 3.6, 8/20/82. Changed laboc() to accomodate the colon
|
||||
* as a legitimate token rather than as a part of a label, for the
|
||||
* 8086 assembler.
|
||||
*
|
||||
* Version 3.5, 8/19/82. Fixed two minor bugs: 1. Location counter
|
||||
* field sometimes came out too long on 32-bit machines. 2. Undefined
|
||||
* symbols sometimes went into the object file with non-zero values.
|
||||
*
|
||||
* Version 3.4, 7/5/82. Added hooks for profiling.
|
||||
*
|
||||
* Version 3.3, 5/27/82. Added uext (-u) switch.
|
||||
*
|
||||
* Version 3.2, 5/22/82. Moved closing of files into special exit()
|
||||
* routine in a.misc.c.
|
||||
*/
|
||||
static char ident[] = "@(#)a.ascom.c 3.6";
|
||||
|
||||
extern char segflg;
|
||||
extern char oflag;
|
||||
|
||||
char putfile[15];
|
||||
char optfile[15];
|
||||
|
||||
main(argc,argv) int argc; char *argv[]; {
|
||||
|
||||
static char errfmt[] = "%u errors, %u warnings\n";
|
||||
struct octab *ocp;
|
||||
int index;
|
||||
|
||||
init(argc,argv);
|
||||
dopass();
|
||||
interlude();
|
||||
pass2 = 1;
|
||||
dopass();
|
||||
oflush(); objtyp = OBOND; oflush();
|
||||
if(lflag) {
|
||||
pgcheck(); fputc('\n',LIST);
|
||||
pgcheck(); fprintf(LIST,errfmt,errct,warnct);
|
||||
if(xflag) putxref();
|
||||
}
|
||||
unlink("VM.TMP");
|
||||
if(errct) {
|
||||
fprintf(ERROR,errfmt,errct,warnct);
|
||||
fclose(LIST);
|
||||
fclose(OBJECT);
|
||||
exit(1);
|
||||
}
|
||||
argv[index = 0] = "xcon";
|
||||
index++;
|
||||
if (segflg)
|
||||
argv[index++] = "-s";
|
||||
if (oflag) {
|
||||
argv[index++] = "-o";
|
||||
argv[index++] = optfile;
|
||||
}
|
||||
argv[index++] = putfile;
|
||||
argv[index] = NULL;
|
||||
chain(argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* assem1 - Assembles a single statement.
|
||||
*/
|
||||
assem1() {
|
||||
|
||||
laboc();
|
||||
if(*opcstr) { /* we have an opcode field */
|
||||
opcode = oclook(opcstr);
|
||||
switch(opcode->oc_typ) {
|
||||
|
||||
case OTUND: /* undefined mnemonic */
|
||||
err('O'); skipeol();
|
||||
break;
|
||||
|
||||
case OTINS: /* machine instruction */
|
||||
instr(opcode->oc_val);
|
||||
break;
|
||||
|
||||
case OTDIR: /* assembler directive */
|
||||
direc(opcode->oc_val);
|
||||
break;
|
||||
|
||||
case OTMAC: /* macro call */
|
||||
macro(opcode->oc_val);
|
||||
break;
|
||||
|
||||
}
|
||||
} else if(*labstr) { /* we have a label field standing alone */
|
||||
label = sylook(labstr);
|
||||
assign(STLAB,curloc,cursec);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* assign - If a label is present, this routine gives it the specified type,
|
||||
* value, and relocation, checking for multiple definition and phase errors.
|
||||
* It also records a cross reference entry. The returned value is a pointer
|
||||
* to the label's sytab entry (in physical memory), or 0 if there was no
|
||||
* label or there was an error.
|
||||
*/
|
||||
struct sytab *
|
||||
assign(typ,val,rel) uns typ; exprval val; uns rel; {
|
||||
|
||||
struct sytab *syp;
|
||||
|
||||
sprintf(llloc,"%04x",(uns)(val&0xffff));
|
||||
if(label == 0) return(0); /* no label */
|
||||
xref(label,XRDEF);
|
||||
syp = wfetch(label);
|
||||
if(syp->sy_typ!=STVAR&&(pass2?syp->sy_atr&SADP2:syp->sy_typ!=STUND)) {
|
||||
err('M'); syp->sy_atr |= SAMUD;
|
||||
return(0);
|
||||
}
|
||||
if(syp->sy_typ == STUND) { /* assign a type */
|
||||
syp->sy_typ = typ; syp->sy_rel = RBUND;
|
||||
} else if(syp->sy_typ != typ) goto phaser;
|
||||
if(syp->sy_rel==RBUND || syp->sy_typ==STVAR) { /* assign a value */
|
||||
syp->sy_val = val; syp->sy_rel = rel;
|
||||
} else if(syp->sy_val!=val || syp->sy_rel!=rel) goto phaser;
|
||||
if(pass2) syp->sy_atr |= SADP2;
|
||||
return(syp);
|
||||
phaser:
|
||||
err('P');
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* def1 - Copies one statement into a macro definition.
|
||||
*/
|
||||
def1() {
|
||||
|
||||
int argno;
|
||||
|
||||
/*
|
||||
* Check for an ADMAC or ADENDM directive.
|
||||
*/
|
||||
laboc();
|
||||
if(*opcstr) { /* opcode field */
|
||||
opcode = oclook(opcstr);
|
||||
if(opcode->oc_typ == OTDIR) { /* directive */
|
||||
if(opcode->oc_val == ADMAC) { /* nested macro def */
|
||||
deflev++;
|
||||
} else if(opcode->oc_val == ADENDM) { /* end def */
|
||||
deflev--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(deflev > 0) { /* copy a line of the definition */
|
||||
scanpt = sline; /* reset scan to beginning of line */
|
||||
do {
|
||||
scanc();
|
||||
if(ch == escchr) { /* escaped character */
|
||||
scanc();
|
||||
*wfetch(valloc(1)) = ch;
|
||||
} else if(ch == argchr) { /* macro parameter */
|
||||
scanc();
|
||||
if(ch == mctchr) /* macro expansion ct */
|
||||
*wfetch(valloc(1)) = 0200;
|
||||
else if(ch == argchr) /* extra args */
|
||||
*wfetch(valloc(1)) = 0201;
|
||||
else if('0'<=ch && ch<='9') {
|
||||
argno = ch-'0';
|
||||
if(argno > curdef->oc_arg)
|
||||
curdef->oc_arg = argno;
|
||||
*wfetch(valloc(1)) = argno+0202;
|
||||
} else err('A');
|
||||
} else { /* normal character */
|
||||
*wfetch(valloc(1)) = ch;
|
||||
}
|
||||
} while(ch != '\n');
|
||||
unscanc(); token();
|
||||
} else { /* finish off the definition */
|
||||
*wfetch(valloc(1)) = '\0';
|
||||
}
|
||||
skipeol();
|
||||
}
|
||||
|
||||
/*
|
||||
* delim - Skips over a delimiter string if one is present.
|
||||
*/
|
||||
delim() {
|
||||
|
||||
if(toktyp == TKSPC) iilex();
|
||||
if(toktyp == TKCOM) iilex();
|
||||
if(toktyp == TKSPC) iilex();
|
||||
}
|
||||
|
||||
/*
|
||||
* dopass - Performs one pass of the source input.
|
||||
*/
|
||||
dopass() {
|
||||
|
||||
if(include(srcfile) != 0) {
|
||||
fprintf(ERROR,"Cannot open %s\n",srcfile);
|
||||
exit(1);
|
||||
}
|
||||
condlev = curatr = curloc = cursec = deflev = mexct =
|
||||
rptlev = sectab[0].se_loc = truelev = 0;
|
||||
curaln = minaln;
|
||||
curext = 32;
|
||||
reading = secct = 1;
|
||||
label = sylook("__text"); newsec(); /* set the default section */
|
||||
while(reading) { /* process statements one at a time */
|
||||
if(deflev > 0) { /* defining a macro */
|
||||
def1();
|
||||
} else if(rptlev > 0) { /* defining a repeat */
|
||||
rpt1();
|
||||
} else if(condlev > truelev) { /* skipping conditional code */
|
||||
skip1();
|
||||
} else { /* assembling statements normally */
|
||||
assem1();
|
||||
}
|
||||
if(toktyp == TKEOF) break;
|
||||
if(toktyp != TKEOL) {
|
||||
err('S'); skipeol();
|
||||
}
|
||||
putline();
|
||||
}
|
||||
setsec(0); /* update sectab info for last section */
|
||||
while(toktyp != TKEOF) token();
|
||||
}
|
||||
|
||||
/*
|
||||
* emitb - Emits a byte of object code.
|
||||
*/
|
||||
emitb(value,reloc) uns value, reloc; {
|
||||
|
||||
if(pass2) {
|
||||
/*
|
||||
* Check whether relocation is needed.
|
||||
*/
|
||||
if((reloc&RAMSK)==RANOP || (reloc&RBMSK)==RBABS) reloc = 0;
|
||||
/*
|
||||
* Output to the object file without breaking up a relocatable
|
||||
* item.
|
||||
*/
|
||||
if(relbot-objtop<(reloc?7:1)) oflush();
|
||||
setorg();
|
||||
if(reloc) {
|
||||
*--relbot = reloc>>8;
|
||||
*--relbot = reloc;
|
||||
*--relbot = objtop-objbuf;
|
||||
}
|
||||
oputb(value); objbuf[5]++;
|
||||
/*
|
||||
* Output to the listing.
|
||||
*/
|
||||
if(llobt >= llobj+LLOBJ) {
|
||||
putline();
|
||||
sprintf(llloc,"%04x",(uns)curloc);
|
||||
}
|
||||
sprintf(llobt,"%02x",value&0377);
|
||||
llobt = llobt + 2;
|
||||
}
|
||||
nxtloc = ++curloc;
|
||||
}
|
||||
|
||||
/*
|
||||
* emitl - Emits a long to the object file.
|
||||
*/
|
||||
emitl(value,reloc) long value; uns reloc; {
|
||||
|
||||
emitw((uns)value,reloc);
|
||||
emitw((uns)(value>>16),0);
|
||||
}
|
||||
|
||||
/*
|
||||
* emitw - Emits a word to the object file.
|
||||
*/
|
||||
emitw(value,reloc) uns value, reloc; {
|
||||
|
||||
emitb(value,reloc);
|
||||
emitb(value>>8,0);
|
||||
}
|
||||
|
||||
/*
|
||||
* err - Puts the specified error flag into the listing.
|
||||
*/
|
||||
err(c) int c; {
|
||||
|
||||
if(!pass2 || llert>=llerr+LLERR) return;
|
||||
if(c<=' ' || c>='\177') c = '?';
|
||||
*llert++ = c;
|
||||
*llert = '\0';
|
||||
errct++;
|
||||
}
|
||||
|
||||
/*
|
||||
* expression - Parses an expression and checks for various error conditions.
|
||||
* the expression's value and relocation are left in curop. At call time,
|
||||
* iilexeme should contain the first token of the expression.
|
||||
*/
|
||||
expression() {
|
||||
|
||||
if(iiparse() != 0) { /* error */
|
||||
curop.op_cls = 0L;
|
||||
while(toktyp!=TKCOM && toktyp!=TKEOL) token();
|
||||
}
|
||||
if(!(curop.op_cls&1L<<OCEXP)) { /* not expression */
|
||||
err('S'); curop.op_val = 0; curop.op_rel = RBUND;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* interlude - Performs processing between pass 1 and pass 2.
|
||||
*/
|
||||
interlude() {
|
||||
|
||||
struct sytab *syp;
|
||||
vmadr p;
|
||||
uns h;
|
||||
uns rel;
|
||||
char type;
|
||||
|
||||
objtyp = OBOST; oflush();
|
||||
for(rel=RBSEC ; rel<secct ; rel++) { /* output sections blocks */
|
||||
if(objtyp!=OBSEC || relbot-objtop<SYMSIZ+7) {
|
||||
oflush(); objtyp = OBSEC;
|
||||
}
|
||||
syp = (struct sytab *)rfetch(sectab[rel].se_sym);
|
||||
oputb(sectab[rel].se_aln);
|
||||
oputb(sectab[rel].se_ext);
|
||||
oputb(sectab[rel].se_atr);
|
||||
oputs(syp->sy_str);
|
||||
}
|
||||
rel = RBEXT;
|
||||
for(h=0 ; h<1<<SHSHLOG ; h++) {
|
||||
for(p=syhtab[h] ; p ; p=syp->sy_lnk) {
|
||||
syp = (struct sytab *)rfetch(p);
|
||||
if(syp->sy_typ==STKEY || syp->sy_typ==STSEC) continue;
|
||||
if(syp->sy_atr&SAGLO || uext&&syp->sy_typ==STUND)
|
||||
type = OBGLO;
|
||||
else
|
||||
type = OBLOC;
|
||||
if(objtyp!=type || relbot-objtop<SYMSIZ+7) {
|
||||
oflush(); objtyp = type;
|
||||
}
|
||||
if(syp->sy_typ == STUND) {
|
||||
oputl(0L);
|
||||
oputb(RBUND);
|
||||
if(syp->sy_atr&SAGLO || uext) {
|
||||
if(rel >= RBMSK) {
|
||||
fprintf(ERROR,"Too many externals\n");
|
||||
exit(1);
|
||||
}
|
||||
syp = (struct sytab *)wfetch(p);
|
||||
syp->sy_typ = STLAB;
|
||||
syp->sy_atr |= SAGLO;
|
||||
syp->sy_val = 0;
|
||||
syp->sy_rel = rel++;
|
||||
}
|
||||
} else {
|
||||
oputl((long)syp->sy_val);
|
||||
oputb(syp->sy_rel);
|
||||
}
|
||||
oputs(syp->sy_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* laboc - Scans the label and opcode fields from the next assembler
|
||||
* statement, and leaves their strings in global arrays labstr and
|
||||
* opcstr. Each string is set to null if its field is missing. Toktyp
|
||||
* is left on the token after the opcode (if it is present).
|
||||
*/
|
||||
laboc() {
|
||||
|
||||
labstr[0] = opcstr[0] = 0;
|
||||
if(token() == TKSYM) { /* label in column 1, possibly with colon */
|
||||
symcpy(labstr,tokstr); labstr[SYMSIZ] = '\0';
|
||||
if(token() == TKCOLON) /* colon label */
|
||||
token();
|
||||
if(toktyp == TKSPC) token();
|
||||
if(toktyp == TKSYM) { /* opcode */
|
||||
symcpy(opcstr,tokstr); opcstr[SYMSIZ] = '\0';
|
||||
token();
|
||||
}
|
||||
} else if(toktyp==TKSPC && token()==TKSYM) { /* colon label or opcode */
|
||||
symcpy(labstr,tokstr); labstr[SYMSIZ] = '\0';
|
||||
if(token() == TKCOLON) { /* was a label, check for opcode */
|
||||
if(token() == TKSPC) token();
|
||||
if(toktyp == TKSYM) { /* opcode */
|
||||
symcpy(opcstr,tokstr); opcstr[SYMSIZ] = '\0';
|
||||
token();
|
||||
}
|
||||
} else { /* oops, was opcode, not label */
|
||||
symcpy(opcstr,labstr);
|
||||
opcstr[SYMSIZ] = labstr[0] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* macro - Processes a macro call.
|
||||
*/
|
||||
macro(vp) vmadr vp; {
|
||||
|
||||
struct input *newfp;
|
||||
int brlev;
|
||||
int i;
|
||||
char **avp;
|
||||
char *sp;
|
||||
char mch;
|
||||
char nbuf[6];
|
||||
|
||||
/*
|
||||
* Create an input stack frame with room for argument pointers
|
||||
* at the beginning of the variable area.
|
||||
*/
|
||||
newfp = pushin(); avp = insp;
|
||||
insp += (opcode->oc_arg+3)*sizeof(char *); iovck();
|
||||
newfp->in_typ = INMAC;
|
||||
/*
|
||||
* Push the macro expansion count (?#) string, and initialize the
|
||||
* extra arguments (??) string to null.
|
||||
*/
|
||||
avp[0] = insp;
|
||||
sprintf(nbuf,"%u",++mexct);
|
||||
sp = nbuf;
|
||||
while(*sp != '\0') pushc(*sp++);
|
||||
avp[1] = insp;
|
||||
pushc('\0');
|
||||
/*
|
||||
* Push the label (?0) string.
|
||||
*/
|
||||
avp[2] = insp;
|
||||
sp = labstr;
|
||||
i = SYMSIZ;
|
||||
while(--i>=0 && *sp!='\0') pushc(*sp++);
|
||||
pushc('\0');
|
||||
/*
|
||||
* Push the operand field arguments.
|
||||
*/
|
||||
if(toktyp == TKSPC) scanc();
|
||||
for(i=1 ; i<=opcode->oc_arg||ch!='\n'&&ch!=';' ; i++) {
|
||||
if(i <= opcode->oc_arg) { /* an expected argument */
|
||||
avp[i+2] = insp;
|
||||
} else { /* an extra argument */
|
||||
if(i == opcode->oc_arg+1) { /* first extra arg */
|
||||
avp[1] = insp;
|
||||
} else { /* additional extra arg */
|
||||
insp[-1] = ',';
|
||||
}
|
||||
pushc(lbrchr);
|
||||
}
|
||||
if(ch == lbrchr) { /* argument enclosed in braces */
|
||||
brlev = 1;
|
||||
for(;;) {
|
||||
scanc();
|
||||
if(ch == lbrchr) brlev++;
|
||||
else if(ch == rbrchr) brlev--;
|
||||
if(brlev<=0 || ch=='\n') break;
|
||||
if(ch == escchr) scanc();
|
||||
pushc(ch);
|
||||
}
|
||||
if(ch == rbrchr) scanc();
|
||||
} else { /* normal argument (not in braces) */
|
||||
while(ch!=',' && !white(ch) && ch!='\n' && ch!=';') {
|
||||
pushc(ch); scanc();
|
||||
}
|
||||
}
|
||||
if(i > opcode->oc_arg) pushc(rbrchr);
|
||||
pushc('\0');
|
||||
while(white(ch)) scanc();
|
||||
if(ch == ',') scanc();
|
||||
while(white(ch)) scanc();
|
||||
}
|
||||
while(ch != '\n') scanc();
|
||||
toktyp = TKEOL;
|
||||
/*
|
||||
* Copy the macro body onto the input stack.
|
||||
*/
|
||||
newfp->in_ptr = insp;
|
||||
while(mch = *rfetch(vp++)) {
|
||||
pushc(mch); newfp->in_cnt++;
|
||||
}
|
||||
/*
|
||||
* Switch input source to macro stack frame.
|
||||
*/
|
||||
infp = newfp;
|
||||
if((curlst = infp->in_lst&0377) != 0) curlst--;
|
||||
}
|
||||
|
||||
/*
|
||||
* newsec - Creates a new section and makes it the current section.
|
||||
*/
|
||||
newsec() {
|
||||
|
||||
if(secct >= SECSIZ) {
|
||||
fprintf(ERROR,"Too many sections\n");
|
||||
exit(1);
|
||||
}
|
||||
assign(STSEC,(exprval)0,secct);
|
||||
sectab[secct].se_sym = label;
|
||||
setsec(secct++);
|
||||
curatr = curloc = 0;
|
||||
curaln = minaln;
|
||||
curext = 32;
|
||||
}
|
||||
|
||||
/*
|
||||
* oflush - Outputs an object block to the object file.
|
||||
*/
|
||||
oflush() {
|
||||
|
||||
char *op;
|
||||
|
||||
if(objtyp) {
|
||||
fputc(objtyp,OBJECT);
|
||||
fputc(OBJSIZ-(relbot-objtop),OBJECT);
|
||||
for(op=objbuf ; op<objtop ; op++) fputc(*op,OBJECT);
|
||||
for(op=relbot ; op<&objbuf[OBJSIZ] ; op++) fputc(*op,OBJECT);
|
||||
}
|
||||
objtop = objbuf; relbot = &objbuf[OBJSIZ]; objtyp = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* oputb - Puts a byte into the object buffer.
|
||||
*/
|
||||
oputb(c) char c; {
|
||||
|
||||
if(objtop >= relbot) {
|
||||
fprintf(ERROR,"Object buffer overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
*objtop++ = c;
|
||||
}
|
||||
|
||||
/*
|
||||
* oputl - Puts a long word into the object buffer.
|
||||
*/
|
||||
oputl(l) long l; {
|
||||
|
||||
oputw((uns)l);
|
||||
oputw((uns)(l>>16));
|
||||
}
|
||||
|
||||
/*
|
||||
* oputs - Puts a symbol into the object buffer.
|
||||
*/
|
||||
oputs(s) char *s; {
|
||||
|
||||
char i;
|
||||
|
||||
i = SYMSIZ;
|
||||
do {
|
||||
if(*s == '\0') break;
|
||||
oputb(*s++);
|
||||
} while(--i > 0);
|
||||
oputb('\0');
|
||||
}
|
||||
|
||||
/*
|
||||
* oputw - Puts a word into the object buffer.
|
||||
*/
|
||||
oputw(w) uns w; {
|
||||
|
||||
oputb(w);
|
||||
oputb(w>>8);
|
||||
}
|
||||
|
||||
/*
|
||||
* rpt1 - Copies one statement into a repeat definition.
|
||||
*/
|
||||
rpt1() {
|
||||
|
||||
struct input *newfp;
|
||||
vmadr vp;
|
||||
char rch;
|
||||
|
||||
laboc();
|
||||
if(*opcstr) { /* check opcode field for special cases */
|
||||
opcode = oclook(opcstr);
|
||||
if(opcode->oc_typ == OTDIR) { /* directive */
|
||||
if(opcode->oc_val == ADREPT) { /* nested repeat */
|
||||
rptlev++;
|
||||
} else if(opcode->oc_val == ADENDR) { /* end rpt */
|
||||
rptlev--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rptlev > 0) { /* copy a line of the repeat definition */
|
||||
scanpt = sline; /* reset scan to beginning of line */
|
||||
do { /* copy the line */
|
||||
scanc();
|
||||
*wfetch(valloc(1)) = ch;
|
||||
} while(ch != '\n');
|
||||
unscanc(); token();
|
||||
} else { /* finish off the repeat definition and start the repeat */
|
||||
*wfetch(valloc(1)) = '\0';
|
||||
newfp = pushin();
|
||||
newfp->in_typ = INRPT;
|
||||
newfp->in_rpt = rptct;
|
||||
vp = rptstr;
|
||||
while(rch = *rfetch(vp++)) { /* copy definition to stack */
|
||||
pushc(rch);
|
||||
}
|
||||
newfp->in_ptr = insp; /* set up as though at end of frame */
|
||||
virtop = rptstr; /* free up the virtual space */
|
||||
infp = newfp; /* switch to new input stack frame */
|
||||
if((curlst = infp->in_lst&0377) != 0) curlst--;
|
||||
}
|
||||
skipeol();
|
||||
}
|
||||
|
||||
/*
|
||||
* setorg - Sets up the next address for text output.
|
||||
*/
|
||||
setorg() {
|
||||
|
||||
if(objtyp!=OBTXT || nxtloc!=curloc || nxtsec!=cursec) {
|
||||
oflush(); objtyp = OBTXT;
|
||||
oputl((long)curloc); oputb(cursec); oputb(0);
|
||||
nxtloc = curloc; nxtsec = cursec;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* setsec - Changes to the specified section for code generation.
|
||||
*/
|
||||
setsec(sec) uns sec; {
|
||||
|
||||
sectab[cursec].se_aln = curaln;
|
||||
sectab[cursec].se_ext = curext;
|
||||
sectab[cursec].se_atr = curatr;
|
||||
sectab[cursec].se_loc = curloc;
|
||||
cursec = sec;
|
||||
curaln = sectab[cursec].se_aln;
|
||||
curext = sectab[cursec].se_ext;
|
||||
curatr = sectab[cursec].se_atr;
|
||||
curloc = sectab[cursec].se_loc;
|
||||
}
|
||||
|
||||
/*
|
||||
* skip1 - Skips one statement due to an unsatisfied conditional assembly.
|
||||
*/
|
||||
skip1() {
|
||||
|
||||
laboc();
|
||||
opcode = *opcstr?oclook(opcstr):0;
|
||||
if(opcode && opcode->oc_typ==OTDIR) {
|
||||
switch(opcode->oc_val) {
|
||||
|
||||
case ADIF: /* .if */
|
||||
condlev++;
|
||||
break;
|
||||
|
||||
case ADELSE: /* .else */
|
||||
if(truelev == condlev-1) truelev++;
|
||||
break;
|
||||
|
||||
case ADENDIF: /* .endif */
|
||||
condlev--;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if(condlev > truelev) { /* mark listing line as skipped */
|
||||
sprintf(llobj,"%8s","-"); /* 8 should be LLOBJ */
|
||||
llobt = llobj + LLOBJ;
|
||||
} else
|
||||
/*
|
||||
* End of the skip. List the directive regardless of
|
||||
* the condlst value.
|
||||
*/
|
||||
llfull = curlst;
|
||||
skipeol();
|
||||
}
|
||||
|
||||
/*
|
||||
* skipeol - Skips to the next end of line or end of file.
|
||||
*/
|
||||
skipeol() {
|
||||
|
||||
while(toktyp!=TKEOL && toktyp!=TKEOF) token();
|
||||
}
|
||||
|
||||
/*
|
||||
* title - Puts a title into the specified string, and fixes up the listing.
|
||||
*/
|
||||
title(s) char *s; {
|
||||
|
||||
if(!pass2) return;
|
||||
if(toktyp==TKSPC && token()==TKSTR) {
|
||||
tokstr[TITSIZ] = '\0';
|
||||
strcpy(s,tokstr);
|
||||
token();
|
||||
llfull = linect = 0;
|
||||
} else err('S');
|
||||
}
|
||||
|
||||
/*
|
||||
* warn - Puts the specified warning flag into the listing.
|
||||
*/
|
||||
warn(c) int c; {
|
||||
|
||||
if(!pass2 || llert>=llerr+LLERR) return;
|
||||
if(c<=' ' || c>='\177') c = '?';
|
||||
*llert++ = c;
|
||||
*llert = '\0';
|
||||
warnct++;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* @(#)a.com.h 3.5
|
||||
*
|
||||
* Declarations common to all of the cross assemblers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Version 3.5, 8/20/82. Added extensions for the 8086.
|
||||
*
|
||||
* Version 3.4, 7/5/82. Added scanc() and white() macros.
|
||||
*
|
||||
* Version 3.3, 5/27/82. Added uext switch.
|
||||
*
|
||||
* Version 3.2, 5/22/82. Added define for PDDIR.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Parameters.
|
||||
*/
|
||||
#define BLKLOG 9 /* log base 2 of disk block size */
|
||||
#define IISIZ 30 /* size of parse stack in frames */
|
||||
#define INSIZ 4096 /* size of input stack in bytes */
|
||||
#define LLERR 3 /* length of error field in listing line */
|
||||
#define LLLOC 4 /* length of location field in listing line */
|
||||
#define LLOBJ 8 /* length of object field in listing line */
|
||||
#define LLPP 58 /* listing lines/page (must be less than 64) */
|
||||
#define LLSEQ 5 /* length of sequence field in listing line */
|
||||
#define OBJSIZ 255 /* maximum object block length */
|
||||
#define OHSHLOG 6 /* log base 2 of opcode hash table size */
|
||||
|
||||
#ifndef PDDIR /* following define overridable in cc line */
|
||||
#define PDDIR "/usr/lib" /* directory containing the predef file */
|
||||
#endif PDDIR
|
||||
|
||||
#define SECSIZ 255 /* maximum number of sections including abs */
|
||||
#define SHSHLOG 9 /* log base 2 of symbol hash table size */
|
||||
#define SLINSIZ 128 /* maximum source line length */
|
||||
#define STRSIZ 128 /* maximum string length */
|
||||
#define SYMSIZ 8 /* maximum symbol length */
|
||||
#define TITSIZ 47 /* maximum title string length */
|
||||
/*
|
||||
* Assembler directive numbers.
|
||||
*/
|
||||
#define ADABS 19 /* .abs */
|
||||
#define ADALIGN 20 /* .align */
|
||||
#define ADBLOCK 7 /* .block */
|
||||
#define ADBYTE 4 /* .byte */
|
||||
#define ADCLIST 9 /* .clist */
|
||||
#define ADCOM 26 /* .common */
|
||||
#define ADEJECT 25 /* .eject */
|
||||
#define ADELSE 15 /* .else */
|
||||
#define ADEND 1 /* .end */
|
||||
#define ADENDIF 16 /* .endif */
|
||||
#define ADENDM 23 /* .endm */
|
||||
#define ADENDR 28 /* .endr */
|
||||
#define ADEQU 2 /* .equ */
|
||||
#define ADERROR 30 /* .error */
|
||||
#define ADEXIT 31 /* .exit */
|
||||
#define ADGLOB 18 /* .global */
|
||||
#define ADIF 17 /* .if */
|
||||
#define ADINPUT 3 /* .input */
|
||||
#define ADLIST 14 /* .list */
|
||||
#define ADLONG 24 /* .long */
|
||||
#define ADMAC 22 /* .macro */
|
||||
#define ADORG 8 /* .org */
|
||||
#define ADREPT 29 /* .repeat */
|
||||
#define ADSECT 10 /* .sect */
|
||||
#define ADSET 6 /* .set */
|
||||
#define ADSPACE 11 /* .space */
|
||||
#define ADSTITL 12 /* .stitle */
|
||||
#define ADTITLE 13 /* .title */
|
||||
#define ADWARN 33 /* .warn */
|
||||
#define ADWITHN 21 /* .within */
|
||||
#define ADWORD 5 /* .word */
|
||||
/*
|
||||
* Parsing constants and flags.
|
||||
*/
|
||||
#define IIAFLG 020000 /* alternate left parts flag */
|
||||
#define IIDSYM 0377 /* default symbol in scntab */
|
||||
#define IIESYM 0376 /* error symbol in scntab */
|
||||
#define IILMSK 0007 /* production length mask */
|
||||
#define IINFLG 0400 /* nonterminal symbol flag */
|
||||
#define IIRFLG 040000 /* read and reduce flag */
|
||||
#define IIXFLG 0100000 /* transition flag */
|
||||
/*
|
||||
* Input stack frame types (in in_typ).
|
||||
*/
|
||||
#define INFILE 1 /* file */
|
||||
#define INMAC 2 /* macro expansion */
|
||||
#define INRPT 3 /* repeat */
|
||||
#define INARG 4 /* macro argument */
|
||||
/*
|
||||
* Operand classes.
|
||||
*/
|
||||
#define OCNULL 0x00 /* no operand */
|
||||
#define OCNEX 0x01 /* nn */
|
||||
#define OCPEX 0x02 /* (nn) */
|
||||
#define OCEXP 0x03 /* {nn,(nn)} */
|
||||
/*
|
||||
* Operand flags (in op_flg and ps_flg).
|
||||
*/
|
||||
#define OFFOR 0x8000 /* operand contains a forward reference */
|
||||
/*
|
||||
* Opcode types (in oc_typ).
|
||||
*/
|
||||
#define OTUND 0 /* undefined */
|
||||
#define OTINS 1 /* instruction */
|
||||
#define OTDIR 2 /* directive */
|
||||
#define OTMAC 3 /* macro */
|
||||
/*
|
||||
* Symbol attribute flags (in sy_atr).
|
||||
*/
|
||||
#define SADP2 0001 /* defined in pass 2 */
|
||||
#define SAMUD 0002 /* multiply defined */
|
||||
#define SAGLO 0004 /* global */
|
||||
/*
|
||||
* Symbol types (in sy_typ).
|
||||
*/
|
||||
#define STUND 0 /* undefined */
|
||||
#define STKEY 1 /* keyword */
|
||||
#define STSEC 2 /* section */
|
||||
#define STLAB 3 /* label or equ */
|
||||
#define STVAR 4 /* variable (redefinable) */
|
||||
/*
|
||||
* Token types and values returned from the lexical scanner.
|
||||
*/
|
||||
#define TKEOF 0 /* end of file -- must be 0 */
|
||||
#define TKDOL 1 /* dollar sign */
|
||||
#define TKSYM 2 /* symbol */
|
||||
#define TKCON 3 /* constant */
|
||||
#define TKSTR 4 /* quoted string */
|
||||
#define TKUNOP 5 /* unary operator */
|
||||
#define TKMULOP 6 /* multiplicative operator */
|
||||
#define TVMUL 1 /* multiplication */
|
||||
#define TVDIV 2 /* division */
|
||||
#define TVMOD 3 /* modulo */
|
||||
#define TVSHL 4 /* shift left */
|
||||
#define TVSHR 5 /* shift right */
|
||||
#define TKADDOP 7 /* additive operator */
|
||||
#define TVADD 1 /* addition */
|
||||
#define TVSUB 2 /* subtraction */
|
||||
#define TKRELOP 8 /* relational operator */
|
||||
#define TVEQ 1 /* equal */
|
||||
#define TVNE 2 /* not equal */
|
||||
#define TVLT 3 /* less than */
|
||||
#define TVGT 4 /* greater than */
|
||||
#define TVLE 5 /* less than or equal */
|
||||
#define TVGE 6 /* greater than or equal */
|
||||
#define TKANDOP 9 /* logical and operator */
|
||||
#define TKXOROP 10 /* exclusive or operator */
|
||||
#define TKOROP 11 /* inclusive or operator */
|
||||
#define TKLPAR 12 /* left parenthesis */
|
||||
#define TKRPAR 13 /* right parenthesis */
|
||||
#define TKCOM 100 /* comma */
|
||||
#define TKCOLON 101 /* colon */
|
||||
#define TKEOL 102 /* end of line */
|
||||
#define TKSPC 103 /* white space */
|
||||
#define TKERR 127 /* erroneous token */
|
||||
/*
|
||||
* Virtual memory buffer flags (in vm_flg).
|
||||
*/
|
||||
#define VMDIR 01 /* dirty bit */
|
||||
/*
|
||||
* Cross reference masks (in xr_pl).
|
||||
*/
|
||||
#define XRDEF 0100000 /* Symbol defined at this reference */
|
||||
/*
|
||||
* Type definitions.
|
||||
*/
|
||||
#define exprval long /* expression value */
|
||||
#define reg register /* abbreviation for good tabbing */
|
||||
#define uns unsigned /* abbreviation for good tabbing */
|
||||
#define vmadr unsigned /* virtual memory address */
|
||||
/*
|
||||
* Pseudo-variables.
|
||||
*/
|
||||
#define ERROR stdout /* ERRORs go to standard output */
|
||||
FILE *LIST; /* pointer to listing FILE structure */
|
||||
FILE *OBJECT; /* pointer to object FILE structure */
|
||||
/*
|
||||
* Pseudo-functions.
|
||||
*/
|
||||
#define scanc() ((ch = *scanpt++)!='\0'&&ch!=escchr ? ch : xscanc())
|
||||
#define unscanc() (ch = *--scanpt)
|
||||
#define white(c) (c==' ' || c=='\t')
|
||||
/*
|
||||
* Structure declarations.
|
||||
*/
|
||||
struct aside { /* symbol lookaside table entry */
|
||||
struct aside *as_lnk; /* lru chain link */
|
||||
vmadr as_sym; /* symbol table entry pointer */
|
||||
char as_str[SYMSIZ]; /* symbol */
|
||||
};
|
||||
struct chent { /* single-character token table entry */
|
||||
char ch_chr; /* character */
|
||||
char ch_typ; /* token type */
|
||||
char ch_val; /* token value */
|
||||
};
|
||||
struct input { /* input stack frame */
|
||||
struct input *in_ofp; /* pointer to previous frame */
|
||||
char in_typ; /* frame type */
|
||||
char in_rpt; /* repeat count */
|
||||
char in_lst; /* listing level */
|
||||
char *in_ptr; /* pointer to next character */
|
||||
int in_cnt; /* number of characters left */
|
||||
int in_fd; /* file descriptor */
|
||||
uns in_seq; /* line number */
|
||||
char in_buf[1<<BLKLOG]; /* buffer area (variable size & use */
|
||||
};
|
||||
struct octab { /* opcode table entry */
|
||||
struct octab *oc_lnk; /* link to next entry in hash chain */
|
||||
uns oc_val; /* value of opcode */
|
||||
char oc_typ; /* type of opcode */
|
||||
char oc_arg; /* highest formal number for macro */
|
||||
char oc_str[SYMSIZ]; /* opcode mnemonic string */
|
||||
};
|
||||
struct operand { /* operand descriptor */
|
||||
long op_cls; /* set of classes (bit vector) */
|
||||
exprval op_val; /* value of operand */
|
||||
uns op_rel; /* relocation of operand */
|
||||
int op_flg; /* flags */
|
||||
};
|
||||
struct output { /* output buffering structure */
|
||||
char *ou_ptr; /* pointer to next character */
|
||||
int ou_cnt; /* number of characters left */
|
||||
int ou_fd; /* file descriptor */
|
||||
char ou_buf[1<<BLKLOG]; /* buffer */
|
||||
};
|
||||
struct psframe { /* parse stack frame */
|
||||
int *ps_state; /* parse state */
|
||||
int ps_sym; /* lookahead symbol */
|
||||
exprval ps_val0; /* usually subexpression value */
|
||||
uns ps_val1; /* usually subexpression relocation */
|
||||
int ps_flg; /* flags */
|
||||
};
|
||||
struct section { /* section table entry */
|
||||
vmadr se_sym; /* symbol table pointer */
|
||||
uns se_loc; /* location counter */
|
||||
char se_aln; /* alignment */
|
||||
char se_ext; /* extent */
|
||||
char se_atr; /* attributes */
|
||||
};
|
||||
struct sytab { /* symbol table entry */
|
||||
vmadr sy_lnk; /* link to next entry in hash chain */
|
||||
vmadr sy_xlk; /* link to rear of xref chain */
|
||||
exprval sy_val; /* value of symbol */
|
||||
uns sy_rel; /* relocation of symbol */
|
||||
char sy_typ; /* type of symbol */
|
||||
char sy_atr; /* attributes of symbol */
|
||||
char sy_str[SYMSIZ]; /* symbol mnemonic string */
|
||||
};
|
||||
struct vmbuf { /* virtual memory buffer */
|
||||
struct vmbuf *vm_lnk; /* lru link to next buffer */
|
||||
short vm_blk; /* disk block number */
|
||||
short vm_flg; /* flags */
|
||||
char vm_mem[1<<BLKLOG]; /* disk block data storage */
|
||||
};
|
||||
struct xref { /* cross reference entry */
|
||||
vmadr xr_lnk; /* circular link to next entry */
|
||||
int xr_pl; /* page and line number */
|
||||
};
|
||||
/*
|
||||
* Global variable declarations.
|
||||
*/
|
||||
char argchr; /* macro argument designator character */
|
||||
struct aside *ashead; /* symbol lookaside lru chain head */
|
||||
struct aside aspool[]; /* pool of symbol lookaside entries */
|
||||
int ch; /* current character from scanc */
|
||||
struct chent chtab[]; /* single-character token table */
|
||||
uns condlev; /* nesting level of conditionals */
|
||||
char condlst; /* flag enabling listing of skipped code */
|
||||
uns curaln; /* alignment for current section */
|
||||
uns curatr; /* attributes for current section */
|
||||
struct octab *curdef; /* current macro being defined */
|
||||
uns curext; /* extent for current section */
|
||||
exprval curloc; /* current location counter value */
|
||||
uns curlst; /* current listing level */
|
||||
struct operand curop; /* current operand information */
|
||||
uns cursec; /* current section number */
|
||||
int curxpl; /* current xref page and line */
|
||||
char datstr[]; /* string containing date and time */
|
||||
uns deflev; /* macro definition nesting level */
|
||||
char eflg; /* expression error flag */
|
||||
extern char oflag; /* Flag to Make Labled output file */
|
||||
extern char segflg; /* Flag to Make Segmented output file */
|
||||
uns errct; /* error count */
|
||||
char escchr; /* escape character */
|
||||
int extoff; /* offset of source extension in program name */
|
||||
struct psframe iilexeme; /* info returned from lexical scanner */
|
||||
int iilset; /* alternate left parts set */
|
||||
int iilsym; /* new left part symbol */
|
||||
struct psframe iips[]; /* parsing stack */
|
||||
struct psframe *iipsp; /* parsing stack pointer */
|
||||
struct psframe *iipspl; /* parsing left end pointer */
|
||||
struct input *infp; /* input frame pointer */
|
||||
char *insp; /* input stack pointer */
|
||||
int instk[]; /* input stack */
|
||||
vmadr label; /* sytab pointer for statement label */
|
||||
char labstr[]; /* label string */
|
||||
char lbrchr; /* left brace character for macro args */
|
||||
char lflag; /* flag set if listing being generated */
|
||||
uns linect; /* number of lines left on listing page */
|
||||
char llerr[]; /* error field of listing line */
|
||||
char *llert; /* top of error field */
|
||||
char llfull; /* flag indicating something to list */
|
||||
char llloc[]; /* location field in listing line */
|
||||
char llobj[]; /* object field in listing line */
|
||||
char *llobt; /* top of object field */
|
||||
char llseq[]; /* sequence field in listing line */
|
||||
char llsrc[]; /* source field in listing line */
|
||||
char mctchr; /* macro expansion count character */
|
||||
uns mexct; /* count of macro expansions */
|
||||
uns minaln; /* minimum section alignment value */
|
||||
int ntdflt[]; /* nonterminal default action table */
|
||||
exprval nxtloc; /* next location for text output */
|
||||
uns nxtsec; /* next section for text output */
|
||||
char objbuf[]; /* object block construction area */
|
||||
char *objtop; /* top of text info in objbuf */
|
||||
char objtyp; /* object block type being built */
|
||||
struct octab *ochtab[]; /* opcode hash table */
|
||||
struct octab *opcode; /* octab pointer for statement opcode */
|
||||
char opcstr[]; /* opcode string */
|
||||
struct operand optab[]; /* instruction operands description */
|
||||
uns pagect; /* listing page number */
|
||||
char parsing; /* flag indicating we are parsing */
|
||||
char pass2; /* flag indicating we are in pass 2 */
|
||||
char pflag; /* flag indicating local predef file */
|
||||
char *phylim; /* first unallocated memory location */
|
||||
char *phytop; /* first unused memory location */
|
||||
int prevsem; /* most recent semantic routine number */
|
||||
char *prname; /* name of this assembler */
|
||||
int ptab[]; /* parsing action table */
|
||||
char rbrchr; /* right brace character for macro args */
|
||||
char reading; /* flag indicating we are reading input */
|
||||
char *relbot; /* bottom of relocation info in objbuf */
|
||||
uns rmarg; /* listing right margin column */
|
||||
char rptct; /* repeat count for current repeat def */
|
||||
uns rptlev; /* repeat definition nesting level */
|
||||
vmadr rptstr; /* start of repeat definition in vm */
|
||||
int savlen; /* length of string in savstr */
|
||||
char savstr[]; /* first string of string comparison */
|
||||
char *scanpt; /* pointer to next character in sline */
|
||||
char scntab[]; /* symbol scanning table */
|
||||
uns secct; /* number of sections defined */
|
||||
struct section sectab[]; /* section table */
|
||||
int semtab[]; /* semantic action table */
|
||||
char sline[]; /* buffer holding current source line */
|
||||
char *srcfile; /* source file name pointer */
|
||||
vmadr syhtab[]; /* symbol hash table */
|
||||
char titl1[]; /* first title line */
|
||||
char titl2[]; /* second title line */
|
||||
char tokstr[]; /* string from token scanner */
|
||||
int toktyp; /* token type from token scanner */
|
||||
exprval tokval; /* value from token scanner */
|
||||
uns truelev; /* true conditional nesting level */
|
||||
char uext; /* flag turning undef. syms into externals */
|
||||
char uflg; /* undefined symbol in expression flag */
|
||||
vmadr virtop; /* first unused vm location */
|
||||
int vmfd; /* virtual memory file descriptor */
|
||||
struct vmbuf *vmhead; /* head of vm lru chain */
|
||||
struct vmbuf vmpool[]; /* pool of virtual memory buffers */
|
||||
uns warnct; /* warning count */
|
||||
char xflag; /* flag enabling cross referencing */
|
||||
|
||||
#ifdef STATS
|
||||
uns ashct; /* number of symbol lookaside hits */
|
||||
uns chnct; /* total sytab links followed */
|
||||
char stats; /* flag enabling statistics */
|
||||
uns sylct; /* number of calls to sylook */
|
||||
uns symct; /* number of symbols */
|
||||
uns vmgct; /* number of vm accesses */
|
||||
uns vmrct; /* number of vm disk reads */
|
||||
uns vmwct; /* number of vm disk writes */
|
||||
#endif
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
struct sytab *assign();
|
||||
uns hash();
|
||||
struct octab *oclook();
|
||||
struct input *pushin();
|
||||
char *rfetch();
|
||||
char *rindex();
|
||||
vmadr sylook();
|
||||
vmadr symerge();
|
||||
vmadr valloc();
|
||||
char *wfetch();
|
||||
@@ -0,0 +1,327 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
#include "obj.h"
|
||||
|
||||
/*
|
||||
* Version 3.4, 8/27/82. Changed this routine to dircom, and moved
|
||||
* direc to the as*.c files.
|
||||
*
|
||||
* Version 3.3, 6/9/82. Fixed .REPEAT bug.
|
||||
*
|
||||
* Version 3.2, 5/22/82. Fixed listing control.
|
||||
*/
|
||||
static char ident[] = "@(#)a.direc.c 3.4";
|
||||
|
||||
/*
|
||||
* dircom - Performs the assembler directives common to all versions.
|
||||
*/
|
||||
dircom(dirnum) int dirnum; {
|
||||
|
||||
reg struct sytab *syp;
|
||||
vmadr sym;
|
||||
exprval l;
|
||||
int i;
|
||||
char cond;
|
||||
char *sp;
|
||||
char llsave;
|
||||
|
||||
switch(dirnum) {
|
||||
|
||||
case ADABS: /* .abs */
|
||||
setsec(0);
|
||||
assign(STLAB,curloc,cursec);
|
||||
break;
|
||||
|
||||
case ADALIGN: /* .align */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel==RBABS && 0L<=curop.op_val &&
|
||||
curop.op_val<=32L) {
|
||||
i = (int)curop.op_val;
|
||||
if(i > curaln) curaln = i;
|
||||
l = -1L<<i;
|
||||
curloc = curloc-l-1&l;
|
||||
if(pass2) setorg();
|
||||
} else err('E');
|
||||
assign(STLAB,curloc,cursec);
|
||||
break;
|
||||
|
||||
case ADBLOCK: /* .block */
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel == RBABS) {
|
||||
curloc += curop.op_val;
|
||||
if(pass2) setorg();
|
||||
} else err('E');
|
||||
break;
|
||||
|
||||
case ADBYTE: /* .byte */
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
while(toktyp != TKEOL) {
|
||||
if(toktyp == TKSTR) {
|
||||
sp = tokstr; i = tokval;
|
||||
while(i-- > 0) emitb(*sp++,0);
|
||||
iilex();
|
||||
} else {
|
||||
expression();
|
||||
emitb((uns)curop.op_val,RAA8|curop.op_rel);
|
||||
}
|
||||
delim();
|
||||
}
|
||||
break;
|
||||
|
||||
case ADCLIST: /* .clist */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel) err('E');
|
||||
else condlst = curop.op_val!=0;
|
||||
break;
|
||||
|
||||
case ADCOM: /* .common */
|
||||
if(label) {
|
||||
syp = (struct sytab *)rfetch(label);
|
||||
if(syp->sy_typ==STSEC &&
|
||||
(!pass2||syp->sy_atr&SADP2)) { /* old section */
|
||||
setsec(syp->sy_rel);
|
||||
} else { /* start a new common section */
|
||||
newsec();
|
||||
}
|
||||
curatr |= SECOM;
|
||||
} else err('L');
|
||||
break;
|
||||
|
||||
case ADEJECT: /* .eject */
|
||||
llfull = linect = 0;
|
||||
break;
|
||||
|
||||
case ADELSE: /* .else */
|
||||
if(truelev) truelev--;
|
||||
else err('C');
|
||||
break;
|
||||
|
||||
case ADEND: /* .end */
|
||||
if(toktyp == TKSPC) { /* read transfer address */
|
||||
iilex();
|
||||
expression();
|
||||
if(pass2) { /* output transfer address */
|
||||
oflush(); objtyp = OBTRA;
|
||||
oputl((long)curop.op_val);
|
||||
oputw(curop.op_rel);
|
||||
}
|
||||
}
|
||||
reading = 0;
|
||||
break;
|
||||
|
||||
case ADENDIF: /* .endif */
|
||||
if(condlev) {
|
||||
condlev--; truelev--;
|
||||
} else err('C');
|
||||
break;
|
||||
|
||||
case ADEQU: /* .equ */
|
||||
equ(STLAB);
|
||||
break;
|
||||
|
||||
case ADERROR: /* .error */
|
||||
if(toktyp!=TKSPC || token()!=TKSTR) goto synerr;
|
||||
sp = tokstr;
|
||||
while(*sp != '\0') err(*sp++);
|
||||
token();
|
||||
break;
|
||||
|
||||
case ADEXIT: /* .exit */
|
||||
if(infp && (infp->in_typ==INMAC||infp->in_typ==INRPT)) popin();
|
||||
else err('O');
|
||||
break;
|
||||
|
||||
case ADGLOB: /* .global */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
token();
|
||||
while(toktyp == TKSYM) {
|
||||
syp = (struct sytab *)wfetch(sym = sylook(tokstr));
|
||||
syp->sy_atr |= SAGLO;
|
||||
xref(sym,0);
|
||||
token();
|
||||
delim();
|
||||
}
|
||||
break;
|
||||
|
||||
case ADIF: /* .if */
|
||||
condlev++;
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel) {
|
||||
cond = 0; err('E');
|
||||
} else cond = curop.op_val!=0;
|
||||
if(cond) truelev++;
|
||||
break;
|
||||
|
||||
case ADINPUT: /* .input */
|
||||
if(toktyp!=TKSPC || token()!=TKSTR) goto synerr;
|
||||
if(include(tokstr) == -1) err('E');
|
||||
token();
|
||||
break;
|
||||
|
||||
case ADLIST: /* .list */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel) err('E');
|
||||
else {
|
||||
if(0<=curop.op_val&&curop.op_val<=255) i = curop.op_val;
|
||||
else i = 255;
|
||||
if((curlst = infp->in_lst&0377) != 0) curlst--;
|
||||
if(i < curlst) curlst = i;
|
||||
}
|
||||
/*
|
||||
* We list the .list directive itself only if listing was
|
||||
* on before and is still on now.
|
||||
*/
|
||||
if(!curlst)
|
||||
llfull = 0;
|
||||
break;
|
||||
|
||||
case ADLONG: /* .long */
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
while(toktyp != TKEOL) {
|
||||
expression();
|
||||
emitl((long)curop.op_val,RAA32|curop.op_rel);
|
||||
delim();
|
||||
}
|
||||
break;
|
||||
|
||||
case ADMAC: /* .macro */
|
||||
if(*labstr) {
|
||||
curdef = oclook(labstr);
|
||||
curdef->oc_typ = OTMAC;
|
||||
curdef->oc_arg = 0;
|
||||
curdef->oc_val = virtop;
|
||||
deflev++;
|
||||
} else err('L');
|
||||
break;
|
||||
|
||||
case ADORG: /* .org */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel == cursec) {
|
||||
curloc = curop.op_val;
|
||||
assign(STLAB,curop.op_val,curop.op_rel);
|
||||
if(pass2) setorg();
|
||||
} else err('E');
|
||||
break;
|
||||
|
||||
case ADREPT: /* .repeat */
|
||||
rptlev++;
|
||||
rptstr = virtop; /* Set now in case of syntax error */
|
||||
rptct = 1;
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
/*
|
||||
* The expression may have generated some new xref entries,
|
||||
* changing virtop. So we set rptstr again to be sure it is
|
||||
* correct.
|
||||
*/
|
||||
rptstr = virtop;
|
||||
if(curop.op_rel!=RBABS || curop.op_val>255L) err('E');
|
||||
else rptct = curop.op_val>=0?curop.op_val:0;
|
||||
break;
|
||||
|
||||
case ADSECT: /* .sect */
|
||||
if(label) {
|
||||
syp = (struct sytab *)rfetch(label);
|
||||
if(syp->sy_typ==STSEC &&
|
||||
(!pass2||syp->sy_atr&SADP2)) { /* old section */
|
||||
setsec(syp->sy_rel);
|
||||
} else { /* start a new section */
|
||||
newsec();
|
||||
}
|
||||
} else err('L');
|
||||
break;
|
||||
|
||||
case ADSET: /* .set */
|
||||
equ(STVAR);
|
||||
break;
|
||||
|
||||
case ADSPACE: /* .space */
|
||||
llsave = llfull; /* save list/nolist flag */
|
||||
llfull = 0; /* suppress listing of source line */
|
||||
if(toktyp != TKSPC) i = 1;
|
||||
else {
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel != RBABS) err('E');
|
||||
i = (int) curop.op_val;
|
||||
}
|
||||
if(i >= linect) linect = 0; /* eject page */
|
||||
else if(i > 0) { /* space down specified number of lines */
|
||||
putline(); /* get rid of source line */
|
||||
llfull = llsave; /* reset list/nolist flag */
|
||||
while(--i > 0) /* note last line put automatically */
|
||||
putline();
|
||||
}
|
||||
break;
|
||||
|
||||
case ADSTITL: /* .stitle */
|
||||
title(titl2);
|
||||
break;
|
||||
|
||||
case ADTITLE: /* .title */
|
||||
title(titl1);
|
||||
break;
|
||||
|
||||
case ADWARN: /* .warn */
|
||||
if(toktyp!=TKSPC || token()!=TKSTR) goto synerr;
|
||||
sp = tokstr;
|
||||
while(*sp != '\0') warn(*sp++);
|
||||
token();
|
||||
break;
|
||||
|
||||
case ADWITHN: /* .within */
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
expression();
|
||||
if(curop.op_rel==RBABS && 0L<=curop.op_val &&
|
||||
curop.op_val<=32L) {
|
||||
i = (int)curop.op_val;
|
||||
if(i < curext) curext = i;
|
||||
} else err('E');
|
||||
assign(STLAB,curloc,cursec);
|
||||
break;
|
||||
|
||||
case ADWORD: /* .word */
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
while(toktyp != TKEOL) {
|
||||
expression();
|
||||
emitw((uns)curop.op_val,RAA16|curop.op_rel);
|
||||
delim();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err('O'); skipeol();
|
||||
break;
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
synerr:
|
||||
err('S'); skipeol();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
#define NOBSS
|
||||
|
||||
/*
|
||||
* Version 3.3, 9/19/82. Added conditional compilation on NOBSS to
|
||||
* avoid explicit initialization (and bulky load modules) where possible.
|
||||
*
|
||||
* Version 3.2, 5/27/82. Added uext switch.
|
||||
*/
|
||||
static char ident[] = "@(#)a.glocom.c 3.3";
|
||||
|
||||
/*
|
||||
* Global variable definitions and initializations common to all of the
|
||||
* cross assemblers.
|
||||
*/
|
||||
char argchr = '?';
|
||||
struct aside *ashead = &aspool[0];
|
||||
struct aside aspool[] = {
|
||||
{ &aspool[1] },
|
||||
{ &aspool[2] },
|
||||
{ &aspool[3] },
|
||||
{ &aspool[4] },
|
||||
{ &aspool[5] },
|
||||
{ &aspool[6] },
|
||||
{ &aspool[7] },
|
||||
{ &aspool[8] },
|
||||
{ &aspool[9] },
|
||||
{ &aspool[10] },
|
||||
{ &aspool[11] },
|
||||
{ &aspool[12] },
|
||||
{ &aspool[13] },
|
||||
{ &aspool[14] },
|
||||
{ &aspool[15] },
|
||||
{ &aspool[16] },
|
||||
{ &aspool[17] },
|
||||
{ &aspool[18] },
|
||||
{ &aspool[19] },
|
||||
{ &aspool[20] },
|
||||
{ &aspool[21] },
|
||||
{ &aspool[22] },
|
||||
{ &aspool[23] },
|
||||
{ &aspool[24] },
|
||||
{ &aspool[25] },
|
||||
{ &aspool[26] },
|
||||
{ &aspool[27] },
|
||||
{ &aspool[28] },
|
||||
{ &aspool[29] },
|
||||
{ 0 }
|
||||
};
|
||||
char condlst = 1;
|
||||
uns curext = 32;
|
||||
uns curlst = 255;
|
||||
struct output errout = { &errout.ou_buf[0], 0, 1 };
|
||||
char escchr = '\\';
|
||||
struct psframe *iipsp = &iips[0];
|
||||
struct psframe *iipspl = &iips[0];
|
||||
char *insp = instk;
|
||||
char lbrchr = '{';
|
||||
char *llert = &llerr[0];
|
||||
char *llobt = &llobj[0];
|
||||
struct output lstout = { &lstout.ou_buf[0], 0, -1 };
|
||||
char mctchr = '#';
|
||||
/* ntdflt is initialized in as*gram.c */
|
||||
struct output objout = { &objout.ou_buf[0], 0, -1 };
|
||||
char *objtop = &objbuf[0];
|
||||
char *phylim;
|
||||
char *phytop;
|
||||
/* ptab is initialized in as*gram.c */
|
||||
char rbrchr = '}';
|
||||
char reading = 1;
|
||||
char *relbot = &objbuf[OBJSIZ];
|
||||
uns rmarg = 80;
|
||||
char *scanpt = &sline[0];
|
||||
/* scntab is initialized in as*gram.c */
|
||||
uns secct = 1;
|
||||
/* semtab is initialized in as*gram.c */
|
||||
vmadr virtop = 2;
|
||||
struct vmbuf *vmhead = &vmpool[0];
|
||||
struct vmbuf vmpool[] = {
|
||||
{ &vmpool[1], -1 },
|
||||
{ &vmpool[2], -1 },
|
||||
{ &vmpool[3], -1 },
|
||||
{ &vmpool[4], -1 },
|
||||
{ &vmpool[5], -1 },
|
||||
{ &vmpool[6], -1 },
|
||||
{ &vmpool[7], -1 },
|
||||
{ &vmpool[8], -1 },
|
||||
{ &vmpool[9], -1 },
|
||||
{ &vmpool[10], -1 },
|
||||
{ &vmpool[11], -1 },
|
||||
{ 0, -1}
|
||||
};
|
||||
|
||||
/*
|
||||
* The following variables all have initial values of zero. We need
|
||||
* not explicitly initialize them if the loader we use has a BSS segment.
|
||||
*/
|
||||
#ifdef NOBSS
|
||||
|
||||
int ch = 0;
|
||||
uns condlev = 0;
|
||||
uns curaln = 0;
|
||||
uns curatr = 0;
|
||||
struct octab *curdef = 0;
|
||||
exprval curloc = 0;
|
||||
struct operand curop = { 0 };
|
||||
uns cursec = 0;
|
||||
int curxpl = 0;
|
||||
char datstr[26] = 0;
|
||||
uns deflev = 0;
|
||||
char eflg = 0;
|
||||
uns errct = 0;
|
||||
struct psframe iilexeme = { 0 };
|
||||
int iilset = 0;
|
||||
int iilsym = 0;
|
||||
struct psframe iips[IISIZ] = 0;
|
||||
struct input *infp = 0;
|
||||
int instk[INSIZ] = 0;
|
||||
vmadr label = 0;
|
||||
char labstr[SYMSIZ+1] = 0;
|
||||
char lflag = 0;
|
||||
uns linect = 0;
|
||||
char llerr[LLERR+1] = 0;
|
||||
char llfull = 0;
|
||||
char llloc[LLLOC+1] = 0;
|
||||
char llobj[LLOBJ+1] = 0;
|
||||
char llseq[LLSEQ+1] = 0;
|
||||
char llsrc[SLINSIZ+2] = 0;
|
||||
uns mexct = 0;
|
||||
exprval nxtloc = 0;
|
||||
uns nxtsec = 0;
|
||||
char objbuf[OBJSIZ] = 0;
|
||||
char objtyp = 0;
|
||||
struct octab *ochtab[1<<OHSHLOG] = 0;
|
||||
struct octab *opcode = 0;
|
||||
char opcstr[SYMSIZ+1] = 0;
|
||||
uns pagect = 0;
|
||||
char parsing = 0;
|
||||
char pass2 = 0;
|
||||
char pflag = 0;
|
||||
int prevsem = 0;
|
||||
char *prname = 0;
|
||||
char rptct = 0;
|
||||
uns rptlev = 0;
|
||||
vmadr rptstr = 0;
|
||||
int savlen = 0;
|
||||
char savstr[STRSIZ+1] = 0;
|
||||
struct section sectab[SECSIZ] = 0;
|
||||
char sline[SLINSIZ+2] = 0;
|
||||
char *srcfile = 0;
|
||||
vmadr syhtab[1<<SHSHLOG] = 0;
|
||||
char titl1[TITSIZ+1] = 0;
|
||||
char titl2[TITSIZ+1] = 0;
|
||||
char tokstr[STRSIZ+1] = 0;
|
||||
int toktyp = 0;
|
||||
exprval tokval = 0;
|
||||
uns truelev = 0;
|
||||
char uext = 0;
|
||||
char uflg = 0;
|
||||
int vmfd = 0;
|
||||
uns warnct = 0;
|
||||
char xflag = 0;
|
||||
|
||||
#ifdef STATS
|
||||
uns ashct = 0;
|
||||
uns chnct = 0;
|
||||
char stats = 0;
|
||||
uns sylct = 0;
|
||||
uns symct = 0;
|
||||
uns vmgct = 0;
|
||||
uns vmrct = 0;
|
||||
uns vmwct = 0;
|
||||
#endif STATS
|
||||
|
||||
#endif NOBSS
|
||||
@@ -0,0 +1,164 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
/*
|
||||
* Version Z.1, 4/5/83. Added external declarations of segflg and oflag.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Version 3.2, 5/27/82. Added uext (-u) switch.
|
||||
*/
|
||||
static char ident[] = "@(#)a.init.c 3.2";
|
||||
|
||||
extern char segflg;
|
||||
extern char oflag;
|
||||
|
||||
/*
|
||||
* badpre - Issues a fatal error for a bad PREDEF file.
|
||||
*/
|
||||
badpre() {
|
||||
|
||||
fprintf(ERROR,"PREDEF file error at line %u\n",infp->in_seq);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* getdat - Gets the date and time and puts them into datstr.
|
||||
* Disabled in CP/M version.
|
||||
*/
|
||||
getdat() {
|
||||
}
|
||||
#define BinFile 1
|
||||
#define AscFile 0
|
||||
|
||||
extern char putfile[];
|
||||
extern char optfile[];
|
||||
/*
|
||||
* init - Performs assembler initialization.
|
||||
*/
|
||||
init(argc,argv) int argc; char *argv[]; {
|
||||
|
||||
char **av;
|
||||
char *ap;
|
||||
char *ep;
|
||||
char *sp;
|
||||
char fname[15];
|
||||
int fd;
|
||||
FILE *newfile();
|
||||
|
||||
phytop = phylim = sbrk(0); /* needed only for monitoring */
|
||||
getdat();
|
||||
prname = "asz8k";
|
||||
while((ap = *++argv) && ap!=-1) { /* read command line arguments */
|
||||
if(*ap == '-') { /* switches */
|
||||
while(*++ap) switch(*ap) {
|
||||
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
oflag = 1;
|
||||
if ((**argv == '\0') || (*argv == NULL))
|
||||
{printf("called from case 'o'\n");
|
||||
usage();}
|
||||
strcpy(optfile,*++argv);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
segflg = 1;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
uext = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
xflag = lflag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("error case\n");
|
||||
usage();
|
||||
|
||||
}
|
||||
} else { /* file name */
|
||||
if(srcfile) {printf("srcfile != 0\n"); usage();}
|
||||
srcfile = ap;
|
||||
}
|
||||
}
|
||||
if(!srcfile) {printf("no srcfile\n"); usage();}
|
||||
if((sp = rindex(srcfile,'/')) == 0) sp = srcfile; else sp++;
|
||||
if(strlen(sp) > 14) sp[14] = '\0';
|
||||
strcpy(titl1,srcfile);
|
||||
strcpy(fname,sp);
|
||||
if((ep = rindex(fname,'.')) == 0)
|
||||
usage();
|
||||
else
|
||||
ep++;
|
||||
if( segflg ) { /* Prog name must end with "8ks". */
|
||||
if( strcmp (ep,"8ks") != 0) {
|
||||
printf("Segmented source file must end with '.8ks'\n");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
else /* Prog name must end in "8kn". */
|
||||
if( strcmp (ep,"8kn") != 0) {
|
||||
printf("Nonsegmented source file must end with '.8kn'\n");
|
||||
usage();
|
||||
}
|
||||
if((fd = opena(srcfile,0)) == -1) {
|
||||
fprintf(ERROR,"Cannot open %s\n",srcfile);
|
||||
exit(1);
|
||||
}
|
||||
strcpy(ep,"obj"); OBJECT = newfile(fname,BinFile);
|
||||
strcpy(putfile,fname);
|
||||
if(lflag) {
|
||||
strcpy(ep,"lst"); LIST = newfile(fname,AscFile);
|
||||
}
|
||||
vinit();
|
||||
predef();
|
||||
}
|
||||
|
||||
/*
|
||||
* newfile - Creates a new file of the specified name,
|
||||
* and returns the file descriptor.
|
||||
*/
|
||||
FILE *
|
||||
newfile(s,asci) char *s; char asci; {
|
||||
|
||||
FILE *fd;
|
||||
|
||||
if((fd = _fopen(s,"w",asci)) == NULL) {
|
||||
fprintf(ERROR,"Cannot create %s\n",s);
|
||||
exit(1);
|
||||
}
|
||||
return(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* preget - Gets a token, issues a fatal error if it is not the specified
|
||||
* type, and returns the token's value.
|
||||
*/
|
||||
preget(typ) int typ; {
|
||||
|
||||
if(token() != typ) badpre();
|
||||
return(tokval);
|
||||
}
|
||||
|
||||
/*
|
||||
* usage - Issues a fatal error for an illegal command line.
|
||||
*/
|
||||
usage() {
|
||||
|
||||
fprintf(ERROR,"Usage: asz8k [-o outfile] [-luxs] file.8k{n|s}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
/*
|
||||
* Version 3.2, 7/5/82. Performance enhancements.
|
||||
*/
|
||||
|
||||
static char ident[] = "@(#)a.input.c 3.2";
|
||||
|
||||
/*
|
||||
* fillin - Processes the end of an input stack frame.
|
||||
*/
|
||||
fillin() {
|
||||
|
||||
reg struct input *rinfp;
|
||||
|
||||
switch((rinfp = infp)->in_typ) {
|
||||
|
||||
case INFILE:
|
||||
rinfp->in_ptr = rinfp->in_buf;
|
||||
rinfp->in_cnt = read(rinfp->in_fd,rinfp->in_buf,
|
||||
1<<BLKLOG);
|
||||
if(rinfp->in_cnt == 0) {
|
||||
close(rinfp->in_fd);
|
||||
popin();
|
||||
}
|
||||
return;
|
||||
|
||||
case INARG:
|
||||
case INMAC:
|
||||
popin();
|
||||
return;
|
||||
|
||||
case INRPT:
|
||||
if(rinfp->in_rpt-- != 0) {
|
||||
rinfp->in_cnt = rinfp->in_ptr-rinfp->in_buf;
|
||||
rinfp->in_ptr = rinfp->in_buf;
|
||||
rinfp->in_seq = 0;
|
||||
} else popin();
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* include - Pushes the specified file into the input stream. Returns -1
|
||||
* if the file cannot be opened, 0 otherwise.
|
||||
*/
|
||||
include(file) char *file; {
|
||||
|
||||
int fd;
|
||||
|
||||
if((fd = opena(file,0)) == -1) return(-1);
|
||||
infp = pushin();
|
||||
insp += 1<<BLKLOG; iovck();
|
||||
infp->in_typ = INFILE;
|
||||
infp->in_fd = fd;
|
||||
if((curlst = infp->in_lst&0377) != 0) curlst--;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* iovck - Checks to make sure the input stack pointer is not beyond the
|
||||
* end of the input stack area.
|
||||
*/
|
||||
iovck() {
|
||||
|
||||
if(insp > instk+INSIZ) {
|
||||
fprintf(ERROR,"Input stack overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* macarg - Pushes a macro argument frame on the input stack. The parameter
|
||||
* is the argument designator.
|
||||
*/
|
||||
macarg(argno) int argno; {
|
||||
|
||||
reg struct input *rinfp;
|
||||
char *ap;
|
||||
char **avp;
|
||||
|
||||
avp = infp->in_buf;
|
||||
ap = avp[argno&0177];
|
||||
rinfp = infp = pushin();
|
||||
rinfp->in_typ = INARG;
|
||||
rinfp->in_ptr = ap;
|
||||
rinfp->in_cnt = strlen(ap);
|
||||
if((curlst = rinfp->in_lst&0377) != 0) curlst--;
|
||||
}
|
||||
|
||||
/*
|
||||
* popin - Pops the top frame off the input stack.
|
||||
*/
|
||||
popin() {
|
||||
|
||||
curlst = infp->in_lst&0377; insp = infp; infp = infp->in_ofp;
|
||||
}
|
||||
|
||||
/*
|
||||
* pushc - Pushes the specified character onto the input stack.
|
||||
*/
|
||||
pushc(c) char c; {
|
||||
|
||||
char *oldsp;
|
||||
|
||||
oldsp = insp++; iovck();
|
||||
*oldsp = c;
|
||||
}
|
||||
|
||||
/*
|
||||
* pushin - Pushes a new frame onto the input stack. The buffer area in_buf
|
||||
* is not allocated, since it is of variable size. The value returned is
|
||||
* the new frame pointer. Note that the global frame pointer infp is
|
||||
* not automatically adjusted.
|
||||
*/
|
||||
struct input *
|
||||
pushin() {
|
||||
|
||||
struct input *newfp;
|
||||
|
||||
if((int)insp&01) insp++; /* force integer alignment */
|
||||
newfp = insp;
|
||||
insp = &newfp->in_buf[0]; iovck();
|
||||
newfp->in_ofp = infp;
|
||||
newfp->in_seq = newfp->in_cnt = 0;
|
||||
newfp->in_lst = curlst;
|
||||
return(newfp);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
/*
|
||||
* Version 3.2, 8/19/82. Added initialization of the sy_val field
|
||||
* when adding a new symbol to the symbol table. It sometimes
|
||||
* came up nonzero, giving undefined externals nonzero values in
|
||||
* the object output.
|
||||
*/
|
||||
static char ident[] = "@(#)a.look.c 3.2";
|
||||
|
||||
/*
|
||||
* oclook - Returns a pointer to the operation table entry for the
|
||||
* specified opcode symbol. Creates a new entry in the operation
|
||||
* table if necessary.
|
||||
*/
|
||||
struct octab *
|
||||
oclook(s) char *s; {
|
||||
|
||||
struct octab *p, *q, *r;
|
||||
uns h;
|
||||
int cmp;
|
||||
|
||||
h = hash(s)>>(16-OHSHLOG)&(1<<OHSHLOG)-1;
|
||||
p = 0;
|
||||
q = ochtab[h];
|
||||
while(q && (cmp=symcmp(s,q->oc_str))>0) { /* follow hash chain */
|
||||
p = q;
|
||||
q = q->oc_lnk;
|
||||
}
|
||||
if(q && cmp==0) return(q); /* found */
|
||||
/*
|
||||
* Add a new entry to the table.
|
||||
*/
|
||||
if((uns)phytop&01) phytop++; /* force integer alignment */
|
||||
r = (struct octab *)palloc(sizeof(struct octab));
|
||||
symcpy(r->oc_str,s);
|
||||
r->oc_typ = 0;
|
||||
r->oc_lnk = q;
|
||||
if(p) p->oc_lnk = r; else ochtab[h] = r;
|
||||
return(r);
|
||||
}
|
||||
|
||||
/*
|
||||
* hash - Given a string, computes a partial hashing function of the string,
|
||||
* and returns its value.
|
||||
*/
|
||||
uns
|
||||
hash(s) char *s; {
|
||||
|
||||
uns h;
|
||||
|
||||
h = 0;
|
||||
while(*s) h = (h<<1)+*s++;
|
||||
return(h*40143);
|
||||
}
|
||||
|
||||
/*
|
||||
* sylook - Returns a virtual memory pointer to the symbol table entry
|
||||
* for the specified symbol. Creates a new entry in the symbol table
|
||||
* if necessary.
|
||||
*/
|
||||
vmadr
|
||||
sylook(s) char *s; {
|
||||
|
||||
struct aside *apt, **lpt;
|
||||
vmadr p, q, r;
|
||||
struct sytab *qp, *rp;
|
||||
uns h;
|
||||
int cmp;
|
||||
|
||||
#ifdef STATS
|
||||
sylct++;
|
||||
#endif
|
||||
/*
|
||||
* Check the lookaside table to see if the symbol is in it.
|
||||
*/
|
||||
lpt = &ashead; apt = ashead;
|
||||
while((cmp = symcmp(apt->as_str,s)) && apt->as_lnk) {
|
||||
apt = *(lpt = &apt->as_lnk);
|
||||
}
|
||||
/*
|
||||
* Whether we found a hit or not, move the entry to the front of the
|
||||
* lru chain.
|
||||
*/
|
||||
*lpt = apt->as_lnk; apt->as_lnk = ashead; ashead = apt;
|
||||
if(cmp == 0) { /* hit */
|
||||
#ifdef STATS
|
||||
ashct++;
|
||||
#endif
|
||||
return(apt->as_sym);
|
||||
}
|
||||
/*
|
||||
* No luck in the lookaside table, so search the hash chains in
|
||||
* the customary manner.
|
||||
*/
|
||||
symcpy(ashead->as_str,s); /* update lookaside table */
|
||||
h = hash(s)>>(16-SHSHLOG)&(1<<SHSHLOG)-1;
|
||||
p = 0;
|
||||
q = syhtab[h];
|
||||
while(q && (cmp=symcmp(s,(qp=(struct sytab *)rfetch(q))->sy_str))>0) {
|
||||
p = q;
|
||||
q = qp->sy_lnk;
|
||||
#ifdef STATS
|
||||
chnct++;
|
||||
#endif
|
||||
}
|
||||
if(q && cmp==0) return(ashead->as_sym = q); /* found */
|
||||
/*
|
||||
* Add a new entry to the table.
|
||||
*/
|
||||
#ifdef STATS
|
||||
symct++;
|
||||
#endif
|
||||
if((uns)virtop&01) virtop++; /* force integer alignment */
|
||||
rp = (struct sytab *)wfetch(r=valloc(sizeof(struct sytab)));
|
||||
symcpy(rp->sy_str,s);
|
||||
rp->sy_typ = rp->sy_atr = rp->sy_xlk = rp->sy_val = 0;
|
||||
rp->sy_lnk = q;
|
||||
if(p) ((struct sytab *)wfetch(p))->sy_lnk = r; else syhtab[h] = r;
|
||||
return(ashead->as_sym = r);
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
/*
|
||||
* Version 3.3, 7/5/82. Added hooks for profiling and performance
|
||||
* enhancements.
|
||||
*
|
||||
* Version 3.2, 5/22/82. Added exit routine to replace the standard one
|
||||
* in libc.a.
|
||||
*/
|
||||
static char ident[] = "@(#)a.misc.c 3.3";
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* ferr - Issues a fatal error message and terminates.
|
||||
* Used a variable number of parameters - replaced by in-line
|
||||
* calls to fprintf, followed everywhere by exit(1).
|
||||
* FZ 9/14/82
|
||||
*/
|
||||
/*
|
||||
*ferr(arglist) char *arglist; {
|
||||
*
|
||||
* fprintf(ERROR,"%r",&arglist);
|
||||
* exit(1);
|
||||
*}
|
||||
************************************************************************/
|
||||
|
||||
/*
|
||||
* getline - Reads the next line of source, and puts it into the global
|
||||
* array sline and into the listing buffer lline.
|
||||
*/
|
||||
getline() {
|
||||
|
||||
reg struct input *rinfp;
|
||||
reg int ch;
|
||||
reg char *slp;
|
||||
reg char *llp;
|
||||
|
||||
scanpt = slp = sline; llp = llsrc;
|
||||
for( ; ; ) {
|
||||
if((rinfp = infp) == 0) { /* end of file */
|
||||
sline[0] = -1;
|
||||
sline[1] = '\0';
|
||||
return;
|
||||
}
|
||||
if(rinfp->in_cnt-- <= 0) { /* end of input stack frame */
|
||||
fillin();
|
||||
continue;
|
||||
}
|
||||
if((ch = *rinfp->in_ptr++ & 0377) >= 0200 &&
|
||||
rinfp->in_typ == INMAC) { /* push macro argument frame */
|
||||
macarg(ch);
|
||||
continue;
|
||||
}
|
||||
ch &= 0177;
|
||||
if(ch == '\n') /* we have a line */
|
||||
break;
|
||||
if(ch == '\f') linect = 0; /* page eject */
|
||||
else if(slp < &sline[SLINSIZ]) *slp++ = *llp++ = ch;
|
||||
}
|
||||
*slp++ = *llp++ = '\n'; *slp = *llp = '\0';
|
||||
rinfp->in_seq++;
|
||||
if(rinfp == (struct input *)instk)
|
||||
sprintf(llseq," %4d",rinfp->in_seq);
|
||||
else sprintf(llseq,"+%4d",rinfp->in_seq);
|
||||
/*
|
||||
* Decide now whether listing of this line is enabled.
|
||||
*/
|
||||
llfull = curlst && (condlev<=truelev || condlst);
|
||||
curxpl = pagect<<6|LLPP-linect+1;
|
||||
if(linect == 0) curxpl += 64-LLPP; /* anticipate form feed */
|
||||
}
|
||||
|
||||
/*
|
||||
* palloc - Allocates a block of physical memory of the specified size,
|
||||
* and returns a pointer to the block.
|
||||
*/
|
||||
char *
|
||||
palloc(size) uns size; {
|
||||
|
||||
static char *oldtop;
|
||||
|
||||
oldtop = phytop; phytop += size;
|
||||
while(phytop > phylim) {
|
||||
if(sbrk(1024) == -1) {
|
||||
fprintf(ERROR,"Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
phylim += 1024;
|
||||
}
|
||||
return(oldtop);
|
||||
}
|
||||
|
||||
/*
|
||||
* pgcheck - Checks to see if a new listing page is needed, and starts one
|
||||
* if necessary. Then updates the line counter in anticipation of a line
|
||||
* of output.
|
||||
*/
|
||||
pgcheck() {
|
||||
|
||||
int i;
|
||||
|
||||
if(linect <= 0) { /* time for a new page */
|
||||
pagect++;
|
||||
fprintf(LIST,"\f\n\n%-8s%-48s%s\
|
||||
%-48s Page%4d\n\n",
|
||||
prname,titl1,datstr,titl2,pagect);
|
||||
linect = LLPP;
|
||||
}
|
||||
linect--;
|
||||
}
|
||||
|
||||
/*
|
||||
* putline - Outputs the next line of the assembly listing, provided
|
||||
* it is pass 2 and there is something to output.
|
||||
*/
|
||||
putline() {
|
||||
|
||||
static char lstfmt[] = "%-3s %-4s %-8s %-5s %s";
|
||||
|
||||
if(pass2) {
|
||||
if(*llerr) { /* put out an error listing line */
|
||||
fprintf(ERROR,lstfmt,llerr,llloc, llobj,llseq,llsrc);
|
||||
}
|
||||
if(lflag && (llfull||*llerr)) { /* put out assembly listing */
|
||||
pgcheck(); /* start a new page if necessary */
|
||||
if(*llerr == '\0') { /* put listing line number */
|
||||
sprintf(llerr," %2d",LLPP-linect);
|
||||
}
|
||||
fprintf(LIST,lstfmt,llerr,llloc,llobj,llseq,llsrc);
|
||||
}
|
||||
}
|
||||
llsrc[0] = '\n';
|
||||
*llerr = *llloc = *llobj = *llseq = llsrc[1] = '\0';
|
||||
llert = llerr; llobt = llobj;
|
||||
}
|
||||
|
||||
/*
|
||||
* symcmp - Compares two symbols, and returns a number which is:
|
||||
*
|
||||
* > 0, if a > b,
|
||||
* == 0, if a == b,
|
||||
* < 0, if a < b.
|
||||
*/
|
||||
symcmp(a,b) reg char *a, *b; {
|
||||
|
||||
reg int i;
|
||||
|
||||
i = SYMSIZ;
|
||||
while(--i>=0 && *a==*b++) {
|
||||
if(*a++ == '\0') return(0);
|
||||
}
|
||||
return(i<0 ? 0 : *a-*--b);
|
||||
}
|
||||
|
||||
/*
|
||||
* symcpy - Copies one symbol from source to destination.
|
||||
*/
|
||||
symcpy(d,s) reg char *d, *s; {
|
||||
|
||||
reg char i;
|
||||
|
||||
i = SYMSIZ;
|
||||
do {
|
||||
if((*d++ = *s++) == '\0') return;
|
||||
} while(--i > 0);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
static char ident[] = "@(#)a.output.c 3.1";
|
||||
@@ -0,0 +1,310 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
#include "obj.h"
|
||||
|
||||
/*
|
||||
* Version 3.2, 8/20/82. Added the forward reference flag (OFFOR).
|
||||
*/
|
||||
static char ident[] = "@(#)a.parse.c 3.2";
|
||||
|
||||
/*
|
||||
* iiaction - Given the state and symbol on the top of the stack, returns the
|
||||
* next action, or -1 if a syntax error was detected.
|
||||
*/
|
||||
iiaction() {
|
||||
|
||||
reg int *pp; /* ptab pointer */
|
||||
reg char *scp; /* scntab pointer */
|
||||
reg int sym; /* lookahead symbol */
|
||||
|
||||
scp = scntab; pp = iipsp->ps_state; sym = iipsp->ps_sym&0377;
|
||||
if(iipsp->ps_sym&IINFLG) { /* scan for a nonterminal symbol */
|
||||
scp += *--pp-1;
|
||||
do {
|
||||
pp--; scp++;
|
||||
} while((*scp&0377)!=sym && (*scp&0377)!=IIDSYM);
|
||||
if((*scp&0377) == IIDSYM) pp = ntdflt+(unsigned)sym;
|
||||
} else { /* scan for a terminal symbol */
|
||||
scp += *pp++;
|
||||
while((*scp&0377)!=sym && (*scp&0377)!=IIDSYM) {
|
||||
if((*scp&0377) == IIESYM) return(-1);
|
||||
pp++; scp++;
|
||||
}
|
||||
}
|
||||
return(*pp);
|
||||
}
|
||||
|
||||
/*
|
||||
* iiparse - Attempts to parse the input stream, and returns 0 if successful.
|
||||
* Expects iilexeme to contain the first symbol of the input at call time.
|
||||
* Returns -1 on failure to recover from a syntax error, -2 on parse stack
|
||||
* overflow.
|
||||
*/
|
||||
iiparse() {
|
||||
|
||||
reg int act; /* next action to take */
|
||||
reg int *smp; /* pointer into semtab */
|
||||
int semnum; /* semantic number */
|
||||
|
||||
eflg = prevsem = uflg = 0;
|
||||
iipsp = &iips[IISIZ];
|
||||
act = ptab[0];
|
||||
parsing = 1;
|
||||
do {
|
||||
/*
|
||||
* Push the current state and lookahead symbol on the stack.
|
||||
*/
|
||||
if(--iipsp < iips) return(-2);
|
||||
iipsp->ps_state = ptab+(act&~IIXFLG);
|
||||
iipsp->ps_sym = iilexeme.ps_sym;
|
||||
iipsp->ps_val0 = iilexeme.ps_val0;
|
||||
iipsp->ps_val1 = iilexeme.ps_val1;
|
||||
/*
|
||||
* Scan the tables to determine the next action.
|
||||
*/
|
||||
if((act = iiaction()) == -1) return(-1);
|
||||
/*
|
||||
* Perform a transition or start a reduction loop, depending
|
||||
* upon the action just found.
|
||||
*/
|
||||
if(act&IIXFLG) { /* transition */
|
||||
iilex();
|
||||
} else { /* reduction */
|
||||
if(act&IIRFLG) { /* combined read and reduce */
|
||||
iilex();
|
||||
} else { /* simple reduction */
|
||||
iipsp++;
|
||||
}
|
||||
do { /* reduce loop */
|
||||
smp = semtab+(act&0377);
|
||||
iipspl = iipsp+(act>>8&IILMSK)-1;
|
||||
iilsym = *smp>>8&0377;
|
||||
iilset = (act&IIAFLG) ? *(smp+1) : 0100000;
|
||||
if((semnum = *smp&0377) != 0) {
|
||||
if(semnum >= 51) sem51(semnum);
|
||||
else sem01(semnum);
|
||||
prevsem = semnum;
|
||||
}
|
||||
iipsp = iipspl;
|
||||
iipsp->ps_sym = iilsym|IINFLG;
|
||||
act = iiaction();
|
||||
} while(!(act&IIXFLG));
|
||||
}
|
||||
} while(parsing);
|
||||
return(iilexeme.ps_sym==TKEOF?0:-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* sem01 - Common semantic routines.
|
||||
*/
|
||||
sem01(sem) int sem; {
|
||||
|
||||
reg struct psframe *p, *pl;
|
||||
struct sytab *syp;
|
||||
char *dp, *sp;
|
||||
int c, i, j;
|
||||
|
||||
p = iipsp; pl = iipspl;
|
||||
switch(sem) {
|
||||
|
||||
case 1: /* <s> ::= <operand> */
|
||||
parsing = 0;
|
||||
break;
|
||||
|
||||
case 2: /* <expr1> ::= addop <expr1> */
|
||||
if(pl->ps_val1 == TVADD) { /* unary plus */
|
||||
pl->ps_val0 = p->ps_val0;
|
||||
pl->ps_val1 = p->ps_val1;
|
||||
} else { /* unary minus */
|
||||
if(p->ps_val1) goto experr;
|
||||
pl->ps_val0 = -p->ps_val0;
|
||||
pl->ps_val1 = 0;
|
||||
}
|
||||
pl->ps_flg = p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 3: /* <expr1> ::= unop <expr1> */
|
||||
if(p->ps_val1) goto experr;
|
||||
pl->ps_val0 = ~p->ps_val0;
|
||||
pl->ps_val1 = 0;
|
||||
pl->ps_flg = p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 4: /* <expr6> ::= <expr6> xorop <expr5> */
|
||||
if(pl->ps_val1 || p->ps_val1) goto experr;
|
||||
pl->ps_val0 ^= p->ps_val0;
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 5: /* <expr2> ::= <expr2> mulop <expr1> */
|
||||
if(pl->ps_val1 || p->ps_val1) goto experr;
|
||||
switch(p[1].ps_val1) {
|
||||
case TVMUL:
|
||||
pl->ps_val0 *= p->ps_val0;
|
||||
break;
|
||||
case TVDIV:
|
||||
pl->ps_val0 /= p->ps_val0;
|
||||
break;
|
||||
case TVMOD:
|
||||
pl->ps_val0 %= p->ps_val0;
|
||||
break;
|
||||
case TVSHL:
|
||||
pl->ps_val0 <<= p->ps_val0;
|
||||
break;
|
||||
case TVSHR:
|
||||
pl->ps_val0 >>= p->ps_val0;
|
||||
break;
|
||||
}
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 6: /* <expr3> ::= <expr3> addop <expr2> */
|
||||
if(p[1].ps_val1 == TVADD) { /* addition */
|
||||
pl->ps_val0 += p->ps_val0;
|
||||
if(pl->ps_val1) {
|
||||
if(p->ps_val1) goto experr;
|
||||
} else pl->ps_val1 = p->ps_val1;
|
||||
} else { /* subtraction */
|
||||
pl->ps_val0 -= p->ps_val0;
|
||||
if(pl->ps_val1 == p->ps_val1)
|
||||
pl->ps_val1 = 0;
|
||||
else if(p->ps_val1) goto experr;
|
||||
}
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 7: /* <expr5> ::= <expr5> andop <expr4> */
|
||||
if(pl->ps_val1 || p->ps_val1) goto experr;
|
||||
pl->ps_val0 &= p->ps_val0;
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 8: /* <expr> ::= <expr> orop <expr6> */
|
||||
if(pl->ps_val1 || p->ps_val1) goto experr;
|
||||
pl->ps_val0 |= p->ps_val0;
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 9: /* <expr4> ::= <expr3> relop <expr3> */
|
||||
switch(p[1].ps_val1) {
|
||||
case TVEQ:
|
||||
pl->ps_val0 = pl->ps_val1==p->ps_val1 &&
|
||||
pl->ps_val0==p->ps_val0;
|
||||
break;
|
||||
case TVNE:
|
||||
pl->ps_val0 = pl->ps_val1!=p->ps_val1 ||
|
||||
pl->ps_val0!=p->ps_val0;
|
||||
break;
|
||||
case TVLT:
|
||||
if(pl->ps_val1 != p->ps_val1) goto experr;
|
||||
pl->ps_val0 = pl->ps_val0<p->ps_val0;
|
||||
break;
|
||||
case TVGT:
|
||||
if(pl->ps_val1 != p->ps_val1) goto experr;
|
||||
pl->ps_val0 = pl->ps_val0>p->ps_val0;
|
||||
break;
|
||||
case TVLE:
|
||||
if(pl->ps_val1 != p->ps_val1) goto experr;
|
||||
pl->ps_val0 = pl->ps_val0<=p->ps_val0;
|
||||
break;
|
||||
case TVGE:
|
||||
if(pl->ps_val1 != p->ps_val1) goto experr;
|
||||
pl->ps_val0 = pl->ps_val0>=p->ps_val0;
|
||||
break;
|
||||
}
|
||||
if(pl->ps_val0) pl->ps_val0 = -1;
|
||||
pl->ps_val1 = 0;
|
||||
pl->ps_flg |= p->ps_flg&OFFOR;
|
||||
break;
|
||||
|
||||
case 10: /* <primary> ::= ( <expr7> ) */
|
||||
pl->ps_val0 = p[1].ps_val0;
|
||||
pl->ps_val1 = p[1].ps_val1;
|
||||
pl->ps_flg = p[1].ps_flg;
|
||||
break;
|
||||
|
||||
case 11: /* <primary> ::= constant */
|
||||
pl->ps_val1 = pl->ps_flg = 0;
|
||||
break;
|
||||
|
||||
case 12: /* <primary> ::= symbol */
|
||||
xref((vmadr)p->ps_val1,0);
|
||||
syp = rfetch((vmadr)p->ps_val1);
|
||||
if(syp->sy_typ == STSEC) goto experr;
|
||||
if(syp->sy_typ==STUND || syp->sy_rel==RBUND ||
|
||||
syp->sy_typ==STVAR&&pass2&&!(syp->sy_atr&SADP2)) {
|
||||
err('U'); uflg = 1;
|
||||
pl->ps_val0 = pl->ps_val1 = 0;
|
||||
pl->ps_flg = OFFOR;
|
||||
} else {
|
||||
pl->ps_val0 = syp->sy_val;
|
||||
pl->ps_val1 = syp->sy_rel;
|
||||
pl->ps_flg = pass2&&!(syp->sy_atr&SADP2) ? OFFOR : 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 13: /* <primary> ::= $ */
|
||||
pl->ps_val0 = curloc;
|
||||
pl->ps_val1 = cursec;
|
||||
pl->ps_flg = 0;
|
||||
break;
|
||||
|
||||
case 14: /* <string1> ::= string */
|
||||
i = savlen = p->ps_val0; sp = tokstr; dp = savstr;
|
||||
while(i-- > 0) *dp++ = *sp++;
|
||||
*dp = '\0';
|
||||
break;
|
||||
|
||||
case 15: /* <operand> ::= <expr> */
|
||||
curop.op_cls = (1L<<OCEXP)|(1L<<(prevsem==10?OCPEX:OCNEX));
|
||||
if(eflg) {
|
||||
curop.op_val = curop.op_rel = curop.op_flg = 0;
|
||||
} else {
|
||||
curop.op_val = p->ps_val0;
|
||||
curop.op_rel = p->ps_val1;
|
||||
curop.op_flg = p->ps_flg;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: /* <expr4> ::= <string1> relop string */
|
||||
sp = savstr; i = savlen;
|
||||
dp = tokstr; j = p->ps_val0;
|
||||
while(i>0 && j>0 && (c = *sp++ - *dp++)==0) {
|
||||
i--; j--;
|
||||
}
|
||||
if(c == 0) c = i-j; /* c reflects the comparison outcome */
|
||||
switch(p[1].ps_val1) {
|
||||
case TVEQ:
|
||||
pl->ps_val0 = c==0;
|
||||
break;
|
||||
case TVNE:
|
||||
pl->ps_val0 = c!=0;
|
||||
break;
|
||||
case TVLT:
|
||||
pl->ps_val0 = c<0;
|
||||
break;
|
||||
case TVGT:
|
||||
pl->ps_val0 = c>0;
|
||||
break;
|
||||
case TVLE:
|
||||
pl->ps_val0 = c<=0;
|
||||
break;
|
||||
case TVGE:
|
||||
pl->ps_val0 = c>=0;
|
||||
break;
|
||||
}
|
||||
if(pl->ps_val0) pl->ps_val0 = -1;
|
||||
pl->ps_val1 = pl->ps_flg = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
experr:
|
||||
err('E'); eflg = 1;
|
||||
pl->ps_val0 = pl->ps_val1 = 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,695 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
#include "asz8k.h"
|
||||
#include "obj.h"
|
||||
|
||||
/*
|
||||
* Version 3.4, 8/27/82. Changes to accomodate 8086 version.
|
||||
*
|
||||
* Version 3.3, 5/22/82. Added PDDIR define for predef directory.
|
||||
*/
|
||||
static char ident[] = "@(#)asz8k.c 3.4";
|
||||
|
||||
/*
|
||||
* direc - Processes assembler directives which are special to this
|
||||
* assembler. Calls dircom to process other directives.
|
||||
*/
|
||||
direc(dirnum) int dirnum; {
|
||||
|
||||
if(dirnum != ADMAC) { /* look up the label */
|
||||
label = *labstr?sylook(labstr):0;
|
||||
}
|
||||
switch(dirnum) {
|
||||
|
||||
case ADLONG: /* .long */
|
||||
if(curloc & 01) /* Force word alignment */
|
||||
curloc++;
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
while(toktyp != TKEOL) {
|
||||
expression();
|
||||
/*
|
||||
* If we are assembling for the segmented version, and
|
||||
* if the expression is relocatable, we generate a long
|
||||
* segmented address. Otherwise, we generate a normal
|
||||
* 32-bit value.
|
||||
*/
|
||||
if(segflg && curop.op_rel!=0)
|
||||
emitls((long)curop.op_val, curop.op_rel);
|
||||
else
|
||||
emitlm((long)curop.op_val, RAA32M|curop.op_rel);
|
||||
delim();
|
||||
}
|
||||
return;
|
||||
|
||||
case ADWORD: /* .word */
|
||||
if(curloc & 01) /* Force word alignment */
|
||||
curloc++;
|
||||
assign(STLAB,curloc,cursec);
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
while(toktyp != TKEOL) {
|
||||
expression();
|
||||
/*
|
||||
* For the segmented version, we generate the
|
||||
* offset portion of the expression. (Note that
|
||||
* if the expression is non-relocatable, its offset
|
||||
* is the same as its value.) For the non-segmented
|
||||
* version, we simply generate a normal 16-bit value.
|
||||
*/
|
||||
emitwm((uns)curop.op_val,
|
||||
(segflg?RAZOF:RAA16M)|curop.op_rel);
|
||||
delim();
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
dircom(dirnum);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
synerr:
|
||||
err('S'); skipeol();
|
||||
}
|
||||
|
||||
/*
|
||||
* emitlm - Emits a long to the object file, MSW first.
|
||||
*/
|
||||
emitlm(value, reloc) long value; uns reloc; {
|
||||
|
||||
emitwm((uns)(value>>16), reloc);
|
||||
emitwm((uns)value, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* emitls - Emits a long segmented address to the object file.
|
||||
*/
|
||||
emitls(value, reloc) long value; uns reloc; {
|
||||
|
||||
uns seg;
|
||||
|
||||
reloc &= RBMSK;
|
||||
seg = reloc<=0x7f ? reloc : 0x7f;
|
||||
value &= 0xffffL;
|
||||
emitlm(((long)(0x80|seg)<<24)|value, RAZLS|reloc);
|
||||
}
|
||||
|
||||
/*
|
||||
* emitss - Emits a short segmented address to the object file.
|
||||
*/
|
||||
emitss(value, reloc) uns value, reloc; {
|
||||
|
||||
uns seg;
|
||||
|
||||
reloc &= RBMSK;
|
||||
seg = reloc<=0x7f ? reloc : 0x7f;
|
||||
value &= 0xff;
|
||||
emitwm((seg<<8)|value, RAZSS|reloc);
|
||||
}
|
||||
|
||||
/*
|
||||
* emitwm - Emits a word to the object file, MSB first.
|
||||
*/
|
||||
emitwm(value, reloc) uns value, reloc; {
|
||||
|
||||
emitb(value>>8, reloc);
|
||||
emitb(value, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* equ - Handles the .equ and .set directives. The argument is the type
|
||||
* of symbol to define (label or variable). Some assemblers have special
|
||||
* interest code here to allow assigning symbols to registers or other
|
||||
* keywords.
|
||||
*/
|
||||
equ(symtype) int symtype; {
|
||||
|
||||
if(!label) err('L');
|
||||
if(toktyp != TKSPC) goto synerr;
|
||||
iilex();
|
||||
if(iiparse()!=0 || !(curop.op_cls&1L<<OCEXP)) goto synerr;
|
||||
if(!(eflg||uflg) || pass2)
|
||||
assign(symtype,curop.op_val,curop.op_rel);
|
||||
return;
|
||||
synerr:
|
||||
err('S'); skipeol();
|
||||
}
|
||||
|
||||
/*
|
||||
* iilex - Lexical scanner for expression parsing. Calls token and does
|
||||
* further processing as required by the isp parser.
|
||||
*/
|
||||
iilex() {
|
||||
|
||||
struct sytab *syp;
|
||||
|
||||
iilexeme.ps_sym = token();
|
||||
iilexeme.ps_val0 = tokval;
|
||||
if(iilexeme.ps_sym == TKSYM) { /* symbol */
|
||||
iilexeme.ps_val0 = (exprval)sylook(tokstr);
|
||||
syp = rfetch((vmadr)iilexeme.ps_val0);
|
||||
if(syp->sy_typ == STKEY) { /* keyword */
|
||||
iilexeme.ps_val0 = syp->sy_val&0377;
|
||||
iilexeme.ps_sym = syp->sy_val>>8&0377;
|
||||
}
|
||||
} else if(iilexeme.ps_sym==TKCOM || iilexeme.ps_sym==TKSPC ||
|
||||
iilexeme.ps_sym==TKEOL) iilexeme.ps_sym = TKEOF;
|
||||
iilexeme.ps_val1 = (uns)iilexeme.ps_val0;
|
||||
return(iilexeme.ps_sym);
|
||||
}
|
||||
|
||||
/*
|
||||
* inops - Reads the operands for a machine instruction and leaves their
|
||||
* descriptions in optab.
|
||||
*/
|
||||
inops() {
|
||||
|
||||
struct operand *opp;
|
||||
|
||||
if(toktyp == TKSPC) iilex();
|
||||
for(opp=optab ; opp<optab+OPMAX ; opp++) {
|
||||
opp->op_cls = 1L<<OCNULL;
|
||||
if(toktyp == TKEOL) continue;
|
||||
if(iiparse() != 0) {
|
||||
err('S');
|
||||
skipeol();
|
||||
continue;
|
||||
}
|
||||
if(curop.op_cls & (1L<<OCEXP))
|
||||
curop.op_cls |= (1L<<OCX);
|
||||
*opp = curop;
|
||||
delim();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* instr - Generates the specified machine instruction.
|
||||
*/
|
||||
instr(fmp) struct format *fmp; {
|
||||
|
||||
long v,
|
||||
dispval,
|
||||
immval;
|
||||
int displen,
|
||||
disprel,
|
||||
f,
|
||||
i,
|
||||
immlen,
|
||||
immrel,
|
||||
r,
|
||||
skel0,
|
||||
skel1,
|
||||
skel2,
|
||||
skel3,
|
||||
srel1;
|
||||
|
||||
if(curloc & 01) /* Force word alignment */
|
||||
curloc++;
|
||||
label = *labstr?sylook(labstr):0;
|
||||
assign(STLAB,curloc,cursec);
|
||||
inops(); /* read the instruction operands */
|
||||
while(!opmatch(fmp)) { /* scan for matching format entry */
|
||||
if(fmp->fm_flg&FMLAST) goto nomatch;
|
||||
fmp++;
|
||||
}
|
||||
displen = immlen = 0;
|
||||
/*
|
||||
* Build up the instruction's fields.
|
||||
*/
|
||||
skel0 = fmp->fm_skel>>8 & 0xff;
|
||||
skel1 = fmp->fm_skel & 0xff;
|
||||
skel2 = 0;
|
||||
skel3 = fmp->fm_flg & FMNIB7;
|
||||
srel1 = 0;
|
||||
for(i=0 ; i<OPMAX ; i++) {
|
||||
f = optab[i].op_flg;
|
||||
r = optab[i].op_rel;
|
||||
v = optab[i].op_val;
|
||||
switch(fmp->fm_op[i] & OAMSK) {
|
||||
|
||||
case OANIB1: /* Pack value into nibble 1 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel0 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OANIB2: /* Pack value into nibble 2 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel1 |= v<<4 & 0xf0;
|
||||
break;
|
||||
|
||||
case OANIB3: /* Pack value into nibble 3 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel1 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OANIB5: /* Pack value into nibble 5 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel2 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OANIB6: /* Pack value into nibble 6 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel3 |= v<<4 & 0xf0;
|
||||
break;
|
||||
|
||||
case OANIB7: /* Pack value into nibble 7 */
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel3 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OABYT1: /* Pack value into byte 1 */
|
||||
skel1 = v;
|
||||
srel1 = r;
|
||||
break;
|
||||
|
||||
case OAX2: /* Generate indexed addr using nibble 2 */
|
||||
skel1 |= (f & OFXMSK) << 4;
|
||||
dispval = v;
|
||||
disprel = r;
|
||||
if(segflg)
|
||||
displen = f&OFSHORT ? 2 : 4;
|
||||
else
|
||||
displen = 2;
|
||||
break;
|
||||
|
||||
case OAX3: /* Generate indexed addr using nibble 3 */
|
||||
skel1 |= f & OFXMSK;
|
||||
dispval = v;
|
||||
disprel = r;
|
||||
if(segflg)
|
||||
displen = f&OFSHORT ? 2 : 4;
|
||||
else
|
||||
displen = 2;
|
||||
break;
|
||||
|
||||
case OABA2: /* Generate based addr using nibble 2 */
|
||||
skel1 |= (f & OFXMSK) << 4;
|
||||
dispval = v;
|
||||
disprel = r;
|
||||
displen = 2;
|
||||
break;
|
||||
|
||||
case OABA3: /* Generate based addr using nibble 3 */
|
||||
skel1 |= f & OFXMSK;
|
||||
dispval = v;
|
||||
disprel = r;
|
||||
displen = 2;
|
||||
break;
|
||||
|
||||
case OABX2: /* Generate based-indexed addr using nibble 2 */
|
||||
skel1 |= (f & OFXMSK) << 4;
|
||||
skel2 |= v;
|
||||
break;
|
||||
|
||||
case OABX3: /* Generate based-indexed addr using nibble 3 */
|
||||
skel1 |= f & OFXMSK;
|
||||
skel2 |= v;
|
||||
break;
|
||||
|
||||
case OACFLAG: /* OR condition flag into nibble 2 */
|
||||
skel1 |= 1<<v;
|
||||
break;
|
||||
|
||||
case OANIB3S: /* Pack into low 3 bits of nibble 3 */
|
||||
if(r!=0 || v<0 || v>7)
|
||||
err('E');
|
||||
skel1 |= v & 0x07;
|
||||
break;
|
||||
|
||||
case OANIB3A: /* AND into nibble 3 */
|
||||
skel1 &= 0xf0 | v;
|
||||
break;
|
||||
|
||||
case OANIB3D: /* Decrement and pack into nibble 3 */
|
||||
v--;
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel1 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OANIB7D: /* Decrement and pack into nibble 7 */
|
||||
v--;
|
||||
if(r!=0 || v<0 || v>15)
|
||||
err('E');
|
||||
skel3 |= v & 0x0f;
|
||||
break;
|
||||
|
||||
case OARA7: /* Generate 7-bit relative address */
|
||||
v = curloc+2 - v;
|
||||
if(r!=cursec || v&01 || v<0 || v>=(2*128))
|
||||
err('E');
|
||||
skel1 |= v >> 1;
|
||||
break;
|
||||
|
||||
case OARA8: /* Generate 8-bit relative address */
|
||||
v -= curloc+2;
|
||||
if(r!=cursec || v&01 || v<(2*-128) || v>=(2*128))
|
||||
err('E');
|
||||
skel1 |= v >> 1;
|
||||
break;
|
||||
|
||||
case OARA12: /* Generate 12-bit relative address */
|
||||
v = curloc+2 - v;
|
||||
if(r!=cursec || v&01 || v<(2*-2048) || v>=(2*2048))
|
||||
err('E');
|
||||
skel0 |= (v>>9) & 0x0f;
|
||||
skel1 = (v>>1) & 0xff;
|
||||
break;
|
||||
|
||||
case OARA16: /* Generate 16-bit relative address */
|
||||
v -= curloc+4;
|
||||
if(r!=cursec || v&01)
|
||||
err('E');
|
||||
/*
|
||||
* We treat this as an immediate because we don't
|
||||
* want a segmented form of address for the segmented
|
||||
* version.
|
||||
*/
|
||||
immlen = 2;
|
||||
immrel = 0;
|
||||
immval = v & 0xffff;
|
||||
break;
|
||||
|
||||
case OAIMM8: /* Generate 8-bit immediate */
|
||||
immlen = 1;
|
||||
immrel = r;
|
||||
immval = v & 0xff;
|
||||
break;
|
||||
|
||||
case OAIMM16: /* Generate 16-bit immediate */
|
||||
immlen = 2;
|
||||
immrel = r;
|
||||
immval = v & 0xffff;
|
||||
break;
|
||||
|
||||
case OAIMM32: /* Generate 32-bit immediate */
|
||||
immlen = 4;
|
||||
immrel = r;
|
||||
immval = v;
|
||||
break;
|
||||
|
||||
case OASHFT: /* Generate shift count of 1 or 2 */
|
||||
if(r!=0 || v<1 || v>2)
|
||||
err('E');
|
||||
if(v == 2)
|
||||
skel1 |= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
emitb(skel0, 0);
|
||||
emitb(skel1, RAA8|srel1);
|
||||
if(fmp->fm_flg & FMSKEL2) {
|
||||
if(fmp->fm_flg & FMNEGI) /* Fake -1 immed. for R shift */
|
||||
skel2 = skel3 = 0xff;
|
||||
emitb(skel2, 0);
|
||||
emitb(skel3, 0);
|
||||
}
|
||||
if(displen == 2) {
|
||||
if(segflg)
|
||||
emitss((uns)dispval, disprel);
|
||||
else
|
||||
emitwm((uns)dispval, RAA16M|disprel);
|
||||
} else if(displen == 4)
|
||||
emitls((long)dispval, disprel);
|
||||
if(immlen == 1) {
|
||||
emitb((uns)immval, RAA8|immrel);
|
||||
emitb((uns)immval, RAA8|immrel);
|
||||
} else if(immlen == 2) {
|
||||
if(fmp->fm_flg & FMNEGI) {
|
||||
/*
|
||||
* Negate immediate value for right shift instrucions.
|
||||
*/
|
||||
if(immrel != 0)
|
||||
err('E');
|
||||
immval = -immval;
|
||||
}
|
||||
/*
|
||||
* For the segmented version, we generate the
|
||||
* offset portion of the expression. (Note that
|
||||
* if the expression is non-relocatable, its offset
|
||||
* is the same as its value.) For the non-segmented
|
||||
* version, we simply generate a normal 16-bit value.
|
||||
*/
|
||||
emitwm((uns)immval, (segflg?RAZOF:RAA16M)|immrel);
|
||||
} else if(immlen == 4) {
|
||||
/*
|
||||
* If we are assembling for the segmented version, and if
|
||||
* the expression is relocatable, we generate a long
|
||||
* segmented address. Otherwise, we generate a normal
|
||||
* 32-bit value.
|
||||
*/
|
||||
if(segflg && immrel!=0)
|
||||
emitls((long)immval, immrel);
|
||||
else
|
||||
emitlm(immval, RAA32M|immrel);
|
||||
}
|
||||
return;
|
||||
|
||||
nomatch:
|
||||
err('O');
|
||||
}
|
||||
|
||||
/*
|
||||
* opmatch - Returns 1 if the specified format entry matches the operands
|
||||
* in optab, 0 otherwise.
|
||||
*/
|
||||
opmatch(fmp) struct format *fmp; {
|
||||
|
||||
int i;
|
||||
|
||||
for(i=0 ; i<OPMAX ; i++) {
|
||||
if(!(1L<<(fmp->fm_op[i]&OCMSK)&optab[i].op_cls)) return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* predef - Reads the predefined symbols into the symbol table.
|
||||
*/
|
||||
predef() {
|
||||
|
||||
struct format *fmp;
|
||||
struct octab *ocp;
|
||||
struct sytab *syp;
|
||||
int i, val;
|
||||
char predef[30];
|
||||
|
||||
/*
|
||||
* Open the predef file and read in the definitions.
|
||||
*/
|
||||
sprintf(predef,"%s.pd",prname); /* use local predef file */
|
||||
if(include(predef) == -1) {
|
||||
fprintf(ERROR,"No PREDEF file (%s)\n",predef);
|
||||
exit(1);
|
||||
}
|
||||
while(token() == TKCON) { /* read machine instructions */
|
||||
if((uns)phytop&01) phytop++; /* force alignment */
|
||||
val = phytop;
|
||||
for(;;) { /* read format table entries */
|
||||
fmp = palloc(sizeof(struct format));
|
||||
for(i=0 ; i<OPMAX ; i++) { /* operand descriptors */
|
||||
fmp->fm_op[i] = tokval;
|
||||
preget(TKSPC); preget(TKCON);
|
||||
}
|
||||
fmp->fm_skel = tokval;
|
||||
preget(TKSPC);
|
||||
fmp->fm_flg = preget(TKCON);
|
||||
if(token() != TKEOL) break;
|
||||
preget(TKCON);
|
||||
}
|
||||
fmp->fm_flg |= FMLAST;
|
||||
while(toktyp == TKSPC) { /* read instruction mnemonics */
|
||||
preget(TKSYM); ocp = oclook(tokstr);
|
||||
ocp->oc_typ = OTINS; ocp->oc_val = val;
|
||||
token();
|
||||
}
|
||||
if(toktyp != TKEOL) badpre();
|
||||
}
|
||||
if(toktyp != TKEOL) badpre();
|
||||
while(token() == TKCON) { /* read assembler directives */
|
||||
val = tokval;
|
||||
while(token() == TKSPC) { /* read directive mnemonics */
|
||||
preget(TKSYM); ocp = oclook(tokstr);
|
||||
ocp->oc_typ = OTDIR; ocp->oc_val = val;
|
||||
}
|
||||
if(toktyp != TKEOL) badpre();
|
||||
}
|
||||
if(toktyp != TKEOL) badpre();
|
||||
while(token() == TKCON) { /* read predefined symbols */
|
||||
val = tokval;
|
||||
while(token() == TKSPC) { /* read symbol mnemonics */
|
||||
preget(TKSYM); syp = wfetch(sylook(tokstr));
|
||||
syp->sy_typ = STKEY;
|
||||
syp->sy_val = val;
|
||||
syp->sy_atr = SADP2;
|
||||
}
|
||||
if(toktyp != TKEOL) badpre();
|
||||
}
|
||||
preget(TKEOF);
|
||||
}
|
||||
|
||||
/*
|
||||
* sem51 - Parser semantic routines specific to asz8k.
|
||||
*/
|
||||
sem51(sem) int sem; {
|
||||
|
||||
reg struct psframe *p, *pl;
|
||||
|
||||
p = iipsp; pl = iipspl;
|
||||
switch(sem) {
|
||||
|
||||
case 51: /* <operand> ::= reg8 */
|
||||
curop.op_cls = (1L<<OCREG8);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 52: /* <operand> ::= reg16 */
|
||||
curop.op_cls = (1L<<OCREG16);
|
||||
if(!segflg)
|
||||
curop.op_cls |= (1L<<OCREGA);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 53: /* <operand> ::= reg32 */
|
||||
curop.op_cls = (1L<<OCREG32);
|
||||
if(segflg)
|
||||
curop.op_cls |= (1L<<OCREGA);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 54: /* <operand> ::= reg64 */
|
||||
curop.op_cls = (1L<<OCREG64);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 55: /* <operand> ::= pound <expr> */
|
||||
curop.op_cls = (1L<<OCIMM);
|
||||
if(eflg)
|
||||
curop.op_val = curop.op_rel = curop.op_flg = 0;
|
||||
else {
|
||||
curop.op_val = p->ps_val0;
|
||||
curop.op_rel = p->ps_val1;
|
||||
curop.op_flg = p->ps_flg;
|
||||
}
|
||||
return;
|
||||
|
||||
case 56: /* <operand> ::= <indexed> */
|
||||
curop.op_cls = (1L<<OCX);
|
||||
if(eflg)
|
||||
curop.op_val = curop.op_rel = curop.op_flg = 0;
|
||||
else {
|
||||
curop.op_val = pl->ps_val0;
|
||||
curop.op_rel = pl->ps_val1;
|
||||
curop.op_flg = pl->ps_flg;
|
||||
}
|
||||
return;
|
||||
|
||||
case 57: /* <operand> ::= @ reg16 */
|
||||
curop.op_cls = (1L<<OCIRIO);
|
||||
if(!segflg)
|
||||
curop.op_cls |= (1L<<OCIR);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 58: /* <operand> ::= @ reg32 */
|
||||
if(segflg)
|
||||
curop.op_cls = (1L<<OCIR);
|
||||
else
|
||||
curop.op_cls = 0;
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 59: /* <operand> ::= <basereg> ( pound <expr> ) */
|
||||
curop.op_cls = (1L<<OCBA);
|
||||
if(eflg)
|
||||
curop.op_val = curop.op_rel = curop.op_flg = 0;
|
||||
else {
|
||||
curop.op_val = p[1].ps_val0;
|
||||
curop.op_rel = p[1].ps_val1;
|
||||
curop.op_flg = p[1].ps_flg | pl->ps_val1;
|
||||
}
|
||||
return;
|
||||
|
||||
case 60: /* <operand> ::= <basereg> ( reg16 ) */
|
||||
curop.op_cls = (1L<<OCBX);
|
||||
if(p[1].ps_val1 == 0)
|
||||
err('E');
|
||||
curop.op_val = p[1].ps_val1;
|
||||
curop.op_rel = 0;
|
||||
curop.op_flg = pl->ps_val1;
|
||||
return;
|
||||
|
||||
case 61: /* <operand> ::= ccode */
|
||||
curop.op_cls = (1L<<OCCCODE);
|
||||
if(4 <= p->ps_val1 && p->ps_val1 < 8)
|
||||
curop.op_cls |= (1L<<OCCFLAG);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 62: /* <operand> ::= int */
|
||||
curop.op_cls = (1L<<OCINT);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 63: /* <operand> ::= ctl */
|
||||
curop.op_cls = (1L<<OCCTL);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 64: /* <operand> ::= FLAGS */
|
||||
curop.op_cls = (1L<<OCFLAGS);
|
||||
curop.op_val = p->ps_val1;
|
||||
curop.op_rel = curop.op_flg = 0;
|
||||
return;
|
||||
|
||||
case 65: /* <basereg> ::= reg16 */
|
||||
if(segflg || p->ps_val1==0)
|
||||
err('E');
|
||||
return;
|
||||
|
||||
case 66: /* <basereg> ::= reg32 */
|
||||
if(!segflg || p->ps_val1==0)
|
||||
err('E');
|
||||
return;
|
||||
|
||||
case 67: /* <indexed> ::= <expr> ( reg16 ) */
|
||||
if(p[1].ps_val1 == 0)
|
||||
err('E');
|
||||
pl->ps_flg |= p[1].ps_val1;
|
||||
return;
|
||||
|
||||
case 68: /* <operand> ::= orop <expr> */
|
||||
case 69: /* <operand> ::= orop <indexed> */
|
||||
curop.op_cls = (1L<<OCX);
|
||||
if(eflg) {
|
||||
curop.op_val = curop.op_rel = 0;
|
||||
curop.op_flg = OFSHORT;
|
||||
} else {
|
||||
curop.op_val = p->ps_val0;
|
||||
curop.op_rel = p->ps_val1;
|
||||
curop.op_flg = p->ps_flg | OFSHORT;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* @(#)asz8k.h 3.1
|
||||
*
|
||||
* Declarations specific to asz8k.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Parameters.
|
||||
*/
|
||||
#define OPMAX 4 /* maximum number of instruction operands */
|
||||
/*
|
||||
* Instruction format table flags (in fm_flg).
|
||||
*/
|
||||
#define FMNIB7 0x000f /* value to OR into nibble 7 */
|
||||
#define FMSKEL2 0x0010 /* generate 2nd skeleton word */
|
||||
#define FMNEGI 0x0020 /* negate immediate value for right shift */
|
||||
#define FMLAST 0x8000 /* final entry for this instruction */
|
||||
/*
|
||||
* Operand actions (in fm_op[]).
|
||||
*/
|
||||
#define OANULL 0x0000 /* operand not used */
|
||||
#define OANIB1 0x0100 /* pack into nibble 1 */
|
||||
#define OANIB2 0x0200 /* pack into nibble 2 */
|
||||
#define OANIB3 0x0300 /* pack into nibble 3 */
|
||||
#define OANIB5 0x0500 /* pack into nibble 5 */
|
||||
#define OANIB6 0x0600 /* pack into nibble 6 */
|
||||
#define OANIB7 0x0700 /* pack into nibble 7 */
|
||||
#define OABYT1 0x0800 /* pack into byte 1 */
|
||||
#define OAX2 0x0900 /* generate indexed addr using nibble 2 */
|
||||
#define OAX3 0x0a00 /* generate indexed addr using nibble 3 */
|
||||
#define OABA2 0x0b00 /* generate based address using nibble 2 */
|
||||
#define OABA3 0x0c00 /* generate based address using nibble 3 */
|
||||
#define OABX2 0x0d00 /* generate based-indexed addr using nibble 2 */
|
||||
#define OABX3 0x0e00 /* generate based-indexed addr using nibble 3 */
|
||||
#define OACFLAG 0x0f00 /* OR condition flag bit into nibble 2 */
|
||||
#define OANIB3S 0x1100 /* pack into low 3 bits of nibble 3 */
|
||||
#define OANIB3A 0x1200 /* AND into nibble 3 */
|
||||
#define OANIB3D 0x1300 /* decrement and pack into nibble 3 */
|
||||
#define OANIB7D 0x1700 /* decrement and pack into nibble 7 */
|
||||
#define OARA7 0x1800 /* generate 7-bit relative address */
|
||||
#define OARA8 0x1900 /* generate 8-bit relative address */
|
||||
#define OARA12 0x1a00 /* generate 12-bit relative address */
|
||||
#define OARA16 0x1b00 /* generate 16-bit relative address */
|
||||
#define OAIMM8 0x1c00 /* generate 8-bit immediate */
|
||||
#define OAIMM16 0x1d00 /* generate 16-bit immediate */
|
||||
#define OAIMM32 0x1e00 /* generate 32-bit immediate */
|
||||
#define OASHFT 0x1f00 /* generate shift count of 1 or 2 */
|
||||
#define OAMSK 0x1f00 /* mask for operand action field */
|
||||
/*
|
||||
* Operand classes.
|
||||
*/
|
||||
#define OCREG8 0x0004 /* {rh0,rh1,rh2,rh3,...,rl4,rl5,rl6,rl7} */
|
||||
#define OCREG16 0x0005 /* {r0,r1,r2,r3,...,r14,r15} */
|
||||
#define OCREG32 0x0006 /* {rr0,rr2,rr4,rr6,rr8,rr10,rr12,rr14} */
|
||||
#define OCREG64 0x0007 /* {rq0,rq4,rq8,rq12} */
|
||||
#define OCIMM 0x0008 /* immediate value */
|
||||
#define OCIR 0x0009 /* indirect register */
|
||||
#define OCX 0x000a /* indexed address */
|
||||
#define OCBA 0x000b /* based address */
|
||||
#define OCBX 0x000c /* based-indexed address */
|
||||
#define OCCCODE 0x000d /* condition code */
|
||||
#define OCCFLAG 0x000e /* condition code flag bit */
|
||||
#define OCINT 0x000f /* {nvi,vi} */
|
||||
#define OCCTL 0x0010 /* control register for LDCTL */
|
||||
#define OCFLAGS 0x0011 /* FLAGS for LDCTLB */
|
||||
#define OCIRIO 0x0012 /* indirect register for I/O instruction */
|
||||
#define OCREGA 0x0013 /* address register (depends on seg mode) */
|
||||
#define OCMSK 0x001f /* mask for operand class field in fm_op */
|
||||
/*
|
||||
* Operand flags (in op_flg and ps_flg).
|
||||
*/
|
||||
#define OFXMSK 0x0f /* mask for index register code */
|
||||
#define OFSHORT 0x80 /* force short offset */
|
||||
/*
|
||||
* Token types.
|
||||
*/
|
||||
#define TKPOUND 14 /* '#' */
|
||||
#define TKAT 15 /* '@' */
|
||||
#define TKREG8 16 /* {rh0,rh1,rh2,rh3,...rl4,rl5,rl6,rl7} */
|
||||
#define TKREG16 17 /* {r0,r1,r2,r3,...,r12,r13,r14,r15} */
|
||||
#define TKREG32 18 /* {rr0,rr2,rr4,rr6,rr8,rr10,rr12,rr14} */
|
||||
#define TKREG64 19 /* {rq0,rq4,rq8,rq12} */
|
||||
#define TKCCODE 20 /* condition codes and flags */
|
||||
#define TKINT 21 /* {nvi,vi} */
|
||||
#define TKCTL 22 /* control registers for LDCTL */
|
||||
#define TKFLAGS 23 /* FLAGS for LDCTLB */
|
||||
/*
|
||||
* Structure declarations.
|
||||
*/
|
||||
struct format { /* instruction format table entry */
|
||||
int fm_op[OPMAX]; /* operand descriptions */
|
||||
int fm_skel; /* opcode skeleton word */
|
||||
int fm_flg; /* flags */
|
||||
};
|
||||
/*
|
||||
* Global variable declarations.
|
||||
*/
|
||||
char segflg; /* Generate code for segmented processor */
|
||||
@@ -0,0 +1,509 @@
|
||||
305h 205h 0 0 0b500h 0 adc ADC
|
||||
304h 204h 0 0 0b400h 0 adcb ADCB
|
||||
305h 205h 0 0 8100h 0
|
||||
305h 1d08h 0 0 100h 0
|
||||
305h 209h 0 0 100h 0
|
||||
305h 90ah 0 0 4100h 0 add ADD
|
||||
304h 204h 0 0 8000h 0
|
||||
304h 1c08h 0 0 0 0
|
||||
304h 209h 0 0 0 0
|
||||
304h 90ah 0 0 4000h 0 addb ADDB
|
||||
306h 206h 0 0 9600h 0
|
||||
306h 1e08h 0 0 1600h 0
|
||||
306h 209h 0 0 1600h 0
|
||||
306h 90ah 0 0 5600h 0 addl ADDL
|
||||
305h 205h 0 0 8700h 0
|
||||
305h 1d08h 0 0 700h 0
|
||||
305h 209h 0 0 700h 0
|
||||
305h 90ah 0 0 4700h 0 and AND
|
||||
304h 204h 0 0 8600h 0
|
||||
304h 1c08h 0 0 600h 0
|
||||
304h 209h 0 0 600h 0
|
||||
304h 90ah 0 0 4600h 0 andb ANDB
|
||||
205h 308h 0 0 0a700h 0
|
||||
209h 308h 0 0 2700h 0
|
||||
90ah 308h 0 0 6700h 0
|
||||
505h 305h 0 0 2700h 10h bit BIT
|
||||
204h 1108h 0 0 0a600h 0
|
||||
209h 1108h 0 0 2600h 0
|
||||
90ah 1108h 0 0 6600h 0
|
||||
504h 1105h 0 0 2600h 10h bitb BITB
|
||||
209h 0 0 0 1f00h 0
|
||||
90ah 0 0 0 5f00h 0 call CALL
|
||||
1a03h 0 0 0 0d000h 0 calr CALR
|
||||
205h 0 0 0 8d08h 0
|
||||
209h 0 0 0 0d08h 0
|
||||
90ah 0 0 0 4d08h 0 clr CLR
|
||||
204h 0 0 0 8c08h 0
|
||||
209h 0 0 0 0c08h 0
|
||||
90ah 0 0 0 4c08h 0 clrb CLRB
|
||||
205h 0 0 0 8d00h 0
|
||||
209h 0 0 0 0d00h 0
|
||||
90ah 0 0 0 4d00h 0 com COM
|
||||
204h 0 0 0 8c00h 0
|
||||
209h 0 0 0 0c00h 0
|
||||
90ah 0 0 0 4c00h 0 comb COMB
|
||||
0f0eh 0 0 0 8d05h 0
|
||||
0f0eh 0f0eh 0 0 8d05h 0
|
||||
0f0eh 0f0eh 0f0eh 0 8d05h 0
|
||||
0f0eh 0f0eh 0f0eh 0f0eh 8d05h 0 comflg COMFLG
|
||||
305h 205h 0 0 8b00h 0
|
||||
305h 1d08h 0 0 0b00h 0
|
||||
305h 209h 0 0 0b00h 0
|
||||
305h 90ah 0 0 4b00h 0
|
||||
209h 1d08h 0 0 0d01h 0
|
||||
90ah 1d08h 0 0 4d01h 0 cp CP
|
||||
304h 204h 0 0 8a00h 0
|
||||
304h 1c08h 0 0 0a00h 0
|
||||
304h 209h 0 0 0a00h 0
|
||||
304h 90ah 0 0 4a00h 0
|
||||
209h 1c08h 0 0 0c01h 0
|
||||
90ah 1c08h 0 0 4c01h 0 cpb CPB
|
||||
306h 206h 0 0 9000h 0
|
||||
306h 1e08h 0 0 1000h 0
|
||||
306h 209h 0 0 1000h 0
|
||||
306h 90ah 0 0 5000h 0 cpl CPL
|
||||
605h 209h 505h 70dh 0bb08h 10h cpd CPD
|
||||
604h 209h 505h 70dh 0ba08h 10h cpdb CPDB
|
||||
605h 209h 505h 70dh 0bb0ch 10h cpdr CPDR
|
||||
604h 209h 505h 70dh 0ba0ch 10h cpdrb CPDRB
|
||||
605h 209h 505h 70dh 0bb00h 10h cpi CPI
|
||||
604h 209h 505h 70dh 0ba00h 10h cpib CPIB
|
||||
605h 209h 505h 70dh 0bb04h 10h cpir CPIR
|
||||
604h 209h 505h 70dh 0ba04h 10h cpirb CPIRB
|
||||
609h 209h 505h 70dh 0bb0ah 10h cpsd CPSD
|
||||
609h 209h 505h 70dh 0ba0ah 10h cpsdb CPSDB
|
||||
609h 209h 505h 70dh 0bb0eh 10h cpsdr CPSDR
|
||||
609h 209h 505h 70dh 0ba0eh 10h cpsdrb CPSDRB
|
||||
609h 209h 505h 70dh 0bb02h 10h cpsi CPSI
|
||||
609h 209h 505h 70dh 0ba02h 10h cpsib CPSIB
|
||||
609h 209h 505h 70dh 0bb06h 10h cpsir CPSIR
|
||||
609h 209h 505h 70dh 0ba06h 10h cpsirb CPSIRB
|
||||
204h 0 0 0 0b000h 0 dab DAB
|
||||
205h 0 0 0 0ab00h 0
|
||||
209h 0 0 0 2b00h 0
|
||||
90ah 0 0 0 6b00h 0
|
||||
205h 1308h 0 0 0ab00h 0
|
||||
209h 1308h 0 0 2b00h 0
|
||||
90ah 1308h 0 0 6b00h 0 dec DEC
|
||||
204h 0 0 0 0aa00h 0
|
||||
209h 0 0 0 2a00h 0
|
||||
90ah 0 0 0 6a00h 0
|
||||
204h 1308h 0 0 0aa00h 0
|
||||
209h 1308h 0 0 2a00h 0
|
||||
90ah 1308h 0 0 6a00h 0 decb DECB
|
||||
120fh 0 0 0 7c03h 0
|
||||
120fh 120fh 0 0 7c03h 0 di DI
|
||||
306h 205h 0 0 9b00h 0
|
||||
306h 1d08h 0 0 1b00h 0
|
||||
306h 209h 0 0 1b00h 0
|
||||
306h 90ah 0 0 5b00h 0 div DIV
|
||||
307h 206h 0 0 9a00h 0
|
||||
307h 1e08h 0 0 1a00h 0
|
||||
307h 209h 0 0 1a00h 0
|
||||
307h 90ah 0 0 5a00h 0 divl DIVL
|
||||
105h 1803h 0 0 0f080h 0 djnz DJNZ
|
||||
104h 1803h 0 0 0f000h 0 dbjnz DBJNZ
|
||||
120fh 0 0 0 7c07h 0
|
||||
120fh 120fh 0 0 7c07h 0 ei EI
|
||||
305h 205h 0 0 0ad00h 0
|
||||
305h 209h 0 0 2d00h 0
|
||||
305h 90ah 0 0 6d00h 0 ex EX
|
||||
304h 204h 0 0 0ac00h 0
|
||||
304h 209h 0 0 2c00h 0
|
||||
304h 90ah 0 0 6c00h 0 exb EXB
|
||||
206h 0 0 0 0b10ah 0 exts EXTS
|
||||
205h 0 0 0 0b100h 0 extsb EXTSB
|
||||
207h 0 0 0 0b107h 0 extsl EXTSL
|
||||
0 0 0 0 7a00h 0 halt HALT
|
||||
305h 212h 0 0 3d00h 0
|
||||
205h 1d03h 0 0 3b04h 0 in IN
|
||||
304h 212h 0 0 3c00h 0
|
||||
204h 1d03h 0 0 3a04h 0 inb INB
|
||||
205h 0 0 0 0a900h 0
|
||||
209h 0 0 0 2900h 0
|
||||
90ah 0 0 0 6900h 0
|
||||
205h 1308h 0 0 0a900h 0
|
||||
209h 1308h 0 0 2900h 0
|
||||
90ah 1308h 0 0 6900h 0 inc INC
|
||||
204h 0 0 0 0a800h 0
|
||||
209h 0 0 0 2800h 0
|
||||
90ah 0 0 0 6800h 0
|
||||
204h 1308h 0 0 0a800h 0
|
||||
209h 1308h 0 0 2800h 0
|
||||
90ah 1308h 0 0 6800h 0 incb INCB
|
||||
609h 212h 505h 0 3b08h 18h ind IND
|
||||
609h 212h 505h 0 3a08h 18h indb INDB
|
||||
609h 212h 505h 0 3b08h 10h indr INDR
|
||||
609h 212h 505h 0 3a08h 10h indrb INDRB
|
||||
609h 212h 505h 0 3b00h 18h ini INI
|
||||
609h 212h 505h 0 3a00h 18h inib INIB
|
||||
609h 212h 505h 0 3b00h 10h inir INIR
|
||||
609h 212h 505h 0 3a00h 10h inirb INIRB
|
||||
0 0 0 0 7b00h 0 iret IRET
|
||||
209h 0 0 0 1e08h 0
|
||||
90ah 0 0 0 5e08h 0
|
||||
30dh 209h 0 0 1e00h 0
|
||||
30dh 90ah 0 0 5e00h 0 jp JP
|
||||
1903h 0 0 0 0e800h 0
|
||||
10dh 1903h 0 0 0e000h 0 jr JR
|
||||
305h 205h 0 0 0a100h 0
|
||||
305h 1d08h 0 0 2100h 0
|
||||
305h 209h 0 0 2100h 0
|
||||
305h 90ah 0 0 6100h 0
|
||||
305h 0b0bh 0 0 3100h 0
|
||||
305h 0d0ch 0 0 7100h 10h
|
||||
209h 305h 0 0 2f00h 0
|
||||
90ah 305h 0 0 6f00h 0
|
||||
209h 1d08h 0 0 0d05h 0
|
||||
90ah 1d08h 0 0 4d05h 0
|
||||
0b0bh 305h 0 0 3300h 0
|
||||
0d0ch 305h 0 0 7300h 10h ld LD
|
||||
304h 204h 0 0 0a000h 0
|
||||
104h 808h 0 0 0c000h 0
|
||||
304h 209h 0 0 2000h 0
|
||||
304h 90ah 0 0 6000h 0
|
||||
304h 0b0bh 0 0 3000h 0
|
||||
304h 0d0ch 0 0 7000h 10h
|
||||
209h 304h 0 0 2e00h 0
|
||||
90ah 304h 0 0 6e00h 0
|
||||
209h 1c08h 0 0 0c05h 0
|
||||
90ah 1c08h 0 0 4c05h 0
|
||||
0b0bh 304h 0 0 3200h 0
|
||||
0d0ch 304h 0 0 7200h 10h ldb LDB
|
||||
306h 206h 0 0 9400h 0
|
||||
306h 1e08h 0 0 1400h 0
|
||||
306h 209h 0 0 1400h 0
|
||||
306h 90ah 0 0 5400h 0
|
||||
306h 0b0bh 0 0 3500h 0
|
||||
306h 0d0ch 0 0 7500h 10h
|
||||
209h 306h 0 0 1d00h 0
|
||||
90ah 306h 0 0 5d00h 0
|
||||
0b0bh 306h 0 0 3700h 0
|
||||
0d0ch 306h 0 0 7700h 10h ldl LDL
|
||||
313h 90ah 0 0 7600h 0
|
||||
313h 0b0bh 0 0 3400h 0
|
||||
313h 0d0ch 0 0 7400h 10h lda LDA
|
||||
313h 1b03h 0 0 3400h 0 ldar LDAR
|
||||
11h 204h 0 0 8c09h 0
|
||||
204h 11h 0 0 8c01h 0 ldctlb LDCTLB
|
||||
310h 205h 0 0 7d08h 0
|
||||
205h 310h 0 0 7d00h 0 ldctl LDCTL
|
||||
609h 209h 505h 0 0bb09h 18h ldd LDD
|
||||
609h 209h 505h 0 0ba09h 18h lddb LDDB
|
||||
609h 209h 505h 0 0bb09h 10h lddr LDDR
|
||||
609h 209h 505h 0 0ba09h 10h lddrb LDDRB
|
||||
609h 209h 505h 0 0bb01h 18h ldi LDI
|
||||
609h 209h 505h 0 0ba01h 18h ldib LDIB
|
||||
609h 209h 505h 0 0bb01h 10h ldir LDIR
|
||||
609h 209h 505h 0 0ba01h 10h ldirb LDIRB
|
||||
205h 308h 0 0 0bd00h 0 ldk LDK
|
||||
505h 209h 1708h 0 1c01h 10h
|
||||
505h 90ah 1708h 0 5c01h 10h
|
||||
209h 505h 1708h 0 1c09h 10h
|
||||
90ah 505h 1708h 0 5c09h 10h ldm LDM
|
||||
209h 0 0 0 3900h 0
|
||||
90ah 0 0 0 7900h 0 ldps LDPS
|
||||
305h 1b03h 0 0 3100h 0
|
||||
1b03h 305h 0 0 3300h 0 ldr LDR
|
||||
304h 1b03h 0 0 3000h 0
|
||||
1b03h 304h 0 0 3200h 0 ldrb LDRB
|
||||
306h 1b03h 0 0 3500h 0
|
||||
1b03h 306h 0 0 3700h 0 ldrl LDRL
|
||||
0 0 0 0 7b0ah 0 mbit MBIT
|
||||
205h 0 0 0 7b0dh 0 mreq MREQ
|
||||
0 0 0 0 7b09h 0 mres MRES
|
||||
0 0 0 0 7b08h 0 mset MSET
|
||||
306h 205h 0 0 9900h 0
|
||||
306h 1d08h 0 0 1900h 0
|
||||
306h 209h 0 0 1900h 0
|
||||
306h 90ah 0 0 5900h 0 mult MULT
|
||||
307h 206h 0 0 9800h 0
|
||||
307h 1e08h 0 0 1800h 0
|
||||
307h 209h 0 0 1800h 0
|
||||
307h 90ah 0 0 5800h 0 multl MULTL
|
||||
205h 0 0 0 8d02h 0
|
||||
209h 0 0 0 0d02h 0
|
||||
90ah 0 0 0 4d02h 0 neg NEG
|
||||
204h 0 0 0 8c02h 0
|
||||
209h 0 0 0 0c02h 0
|
||||
90ah 0 0 0 4c02h 0 negb NEGB
|
||||
0 0 0 0 8d07h 0 nop NOP
|
||||
305h 205h 0 0 8500h 0
|
||||
305h 1d08h 0 0 500h 0
|
||||
305h 209h 0 0 500h 0
|
||||
305h 90ah 0 0 4500h 0 or OR
|
||||
304h 204h 0 0 8400h 0
|
||||
304h 1c08h 0 0 400h 0
|
||||
304h 209h 0 0 400h 0
|
||||
304h 90ah 0 0 4400h 0 orb ORB
|
||||
612h 209h 505h 0 3b0ah 10h otdr OTDR
|
||||
612h 209h 505h 0 3a0ah 10h otdrb OTDRB
|
||||
612h 209h 505h 0 3b02h 10h otir OTIR
|
||||
612h 209h 505h 0 3a02h 10h otirb OTIRB
|
||||
212h 305h 0 0 3f00h 0
|
||||
1d03h 205h 0 0 3b06h 0 out OUT
|
||||
212h 304h 0 0 3e00h 0
|
||||
1d03h 204h 0 0 3a06h 0 outb OUTB
|
||||
612h 209h 505h 0 3b0ah 18h outd OUTD
|
||||
612h 209h 505h 0 3a0ah 18h outdb OUTDB
|
||||
612h 209h 505h 0 3b02h 18h outi OUTI
|
||||
612h 209h 505h 0 3a02h 18h outib OUTIB
|
||||
305h 209h 0 0 9700h 0
|
||||
309h 209h 0 0 1700h 0
|
||||
0a0ah 209h 0 0 5700h 0 pop POP
|
||||
306h 209h 0 0 9500h 0
|
||||
309h 209h 0 0 1500h 0
|
||||
0a0ah 209h 0 0 5500h 0 popl POPL
|
||||
209h 305h 0 0 9300h 0
|
||||
209h 309h 0 0 1300h 0
|
||||
209h 0a0ah 0 0 5300h 0
|
||||
209h 1d08h 0 0 0d09h 0 push PUSH
|
||||
209h 306h 0 0 9100h 0
|
||||
209h 309h 0 0 1100h 0
|
||||
209h 0a0ah 0 0 5100h 0 pushl PUSHL
|
||||
205h 308h 0 0 0a300h 0
|
||||
209h 308h 0 0 2300h 0
|
||||
90ah 308h 0 0 6300h 0
|
||||
505h 305h 0 0 2300h 10h res RES
|
||||
204h 1108h 0 0 0a200h 0
|
||||
209h 1108h 0 0 2200h 0
|
||||
90ah 1108h 0 0 6200h 0
|
||||
504h 1105h 0 0 2200h 10h resb RESB
|
||||
0f0eh 0 0 0 8d03h 0
|
||||
0f0eh 0f0eh 0 0 8d03h 0
|
||||
0f0eh 0f0eh 0f0eh 0 8d03h 0
|
||||
0f0eh 0f0eh 0f0eh 0f0eh 8d03h 0 resflg RESFLG
|
||||
0 0 0 0 9e08h 0
|
||||
30dh 0 0 0 9e00h 0 ret RET
|
||||
205h 0 0 0 0b300h 0
|
||||
205h 1f08h 0 0 0b300h 0 rl RL
|
||||
204h 0 0 0 0b200h 0
|
||||
204h 1f08h 0 0 0b200h 0 rlb RLB
|
||||
205h 0 0 0 0b308h 0
|
||||
205h 1f08h 0 0 0b308h 0 rlc RLC
|
||||
204h 0 0 0 0b208h 0
|
||||
204h 1f08h 0 0 0b208h 0 rlcb RLCB
|
||||
304h 204h 0 0 0be00h 0 rldb RLDB
|
||||
205h 0 0 0 0b304h 0
|
||||
205h 1f08h 0 0 0b304h 0 rr RR
|
||||
204h 0 0 0 0b204h 0
|
||||
204h 1f08h 0 0 0b204h 0 rrb RRB
|
||||
205h 0 0 0 0b30ch 0
|
||||
205h 1f08h 0 0 0b30ch 0 rrc RRC
|
||||
204h 0 0 0 0b20ch 0
|
||||
204h 1f08h 0 0 0b20ch 0 rrcb RRCB
|
||||
304h 204h 0 0 0bc00h 0 rrdb RRDB
|
||||
305h 205h 0 0 0b700h 0 sbc SBC
|
||||
304h 204h 0 0 0b600h 0 sbcb SBCB
|
||||
808h 0 0 0 7f00h 0 sc SC
|
||||
205h 505h 0 0 0b30bh 10h sda SDA
|
||||
204h 505h 0 0 0b20bh 10h sdab SDAB
|
||||
206h 505h 0 0 0b30fh 10h sdal SDAL
|
||||
205h 505h 0 0 0b303h 10h sdl SDL
|
||||
204h 505h 0 0 0b203h 10h sdlb SDLB
|
||||
206h 505h 0 0 0b307h 10h sdll SDLL
|
||||
205h 308h 0 0 0a500h 0
|
||||
209h 308h 0 0 2500h 0
|
||||
90ah 308h 0 0 6500h 0
|
||||
505h 305h 0 0 2500h 10h set SET
|
||||
204h 1108h 0 0 0a400h 0
|
||||
209h 1108h 0 0 2400h 0
|
||||
90ah 1108h 0 0 6400h 0
|
||||
504h 1105h 0 0 2400h 10h setb SETB
|
||||
0f0eh 0 0 0 8d01h 0
|
||||
0f0eh 0f0eh 0 0 8d01h 0
|
||||
0f0eh 0f0eh 0f0eh 0 8d01h 0
|
||||
0f0eh 0f0eh 0f0eh 0f0eh 8d01h 0 setflg SETFLG
|
||||
205h 1d03h 0 0 3b05h 0 sin SIN
|
||||
204h 1d03h 0 0 3a05h 0 sinb SINB
|
||||
609h 212h 505h 0 3b09h 18h sind SIND
|
||||
609h 212h 505h 0 3a09h 18h sindb SINDB
|
||||
609h 212h 505h 0 3b09h 10h sindr SINDR
|
||||
609h 212h 505h 0 3a09h 10h sindrb SINDRB
|
||||
609h 212h 505h 0 3b01h 18h sini SINI
|
||||
609h 212h 505h 0 3a01h 18h sinib SINIB
|
||||
609h 212h 505h 0 3b01h 10h sinir SINIR
|
||||
609h 212h 505h 0 3a01h 10h sinirb SINIRB
|
||||
205h 0 0 0 0b309h 11h
|
||||
205h 1d08h 0 0 0b309h 0 sla SLA
|
||||
204h 0 0 0 0b209h 11h
|
||||
204h 1d08h 0 0 0b209h 0 slab SLAB
|
||||
206h 0 0 0 0b30dh 11h
|
||||
206h 1d08h 0 0 0b30dh 0 slal SLAL
|
||||
205h 0 0 0 0b301h 11h
|
||||
205h 1d08h 0 0 0b301h 0 sll SLL
|
||||
204h 0 0 0 0b201h 11h
|
||||
204h 1d08h 0 0 0b201h 0 sllb SLLB
|
||||
206h 0 0 0 0b305h 11h
|
||||
206h 1d08h 0 0 0b305h 0 slll SLLL
|
||||
612h 209h 505h 0 3b0bh 10h sotdr SOTDR
|
||||
612h 209h 505h 0 3a0bh 10h sotdrb SOTDRB
|
||||
612h 209h 505h 0 3b03h 10h sotir SOTIR
|
||||
612h 209h 505h 0 3a03h 10h sotirb SOTIRB
|
||||
1d03h 205h 0 0 3b07h 0 sout SOUT
|
||||
1d03h 204h 0 0 3a07h 0 soutb SOUTB
|
||||
612h 209h 505h 0 3b0bh 18h soutd SOUTD
|
||||
612h 209h 505h 0 3a0bh 18h soutdb SOUTDB
|
||||
612h 209h 505h 0 3b03h 18h souti SOUTI
|
||||
612h 209h 505h 0 3a03h 18h soutib SOUTIB
|
||||
205h 0 0 0 0b309h 31h
|
||||
205h 1d08h 0 0 0b309h 20h sra SRA
|
||||
204h 0 0 0 0b209h 31h
|
||||
204h 1d08h 0 0 0b209h 20h srab SRAB
|
||||
206h 0 0 0 0b30dh 31h
|
||||
206h 1d08h 0 0 0b30dh 20h sral SRAL
|
||||
205h 0 0 0 0b301h 31h
|
||||
205h 1d08h 0 0 0b301h 20h srl SRL
|
||||
204h 0 0 0 0b201h 31h
|
||||
204h 1d08h 0 0 0b201h 20h srlb SRLB
|
||||
206h 0 0 0 0b305h 31h
|
||||
206h 1d08h 0 0 0b305h 20h srll SRLL
|
||||
305h 205h 0 0 8300h 0
|
||||
305h 1d08h 0 0 300h 0
|
||||
305h 209h 0 0 300h 0
|
||||
305h 90ah 0 0 4300h 0 sub SUB
|
||||
304h 204h 0 0 8200h 0
|
||||
304h 1c08h 0 0 200h 0
|
||||
304h 209h 0 0 200h 0
|
||||
304h 90ah 0 0 4200h 0 subb SUBB
|
||||
306h 206h 0 0 9200h 0
|
||||
306h 1e08h 0 0 1200h 0
|
||||
306h 209h 0 0 1200h 0
|
||||
306h 90ah 0 0 5200h 0 subl SUBL
|
||||
30dh 205h 0 0 0af00h 0 tcc TCC
|
||||
30dh 204h 0 0 0ae00h 0 tccb TCCB
|
||||
205h 0 0 0 8d04h 0
|
||||
209h 0 0 0 0d04h 0
|
||||
90ah 0 0 0 4d04h 0 test TEST
|
||||
204h 0 0 0 8c04h 0
|
||||
209h 0 0 0 0c04h 0
|
||||
90ah 0 0 0 4c04h 0 testb TESTB
|
||||
206h 0 0 0 9c08h 0
|
||||
209h 0 0 0 1c08h 0
|
||||
90ah 0 0 0 5c08h 0 testl TESTL
|
||||
209h 609h 505h 0 0b808h 10h trdb TRDB
|
||||
209h 609h 505h 0 0b80ch 10h trdrb TRDRB
|
||||
209h 609h 505h 0 0b800h 10h trib TRIB
|
||||
209h 609h 505h 0 0b804h 10h trirb TRIRB
|
||||
209h 609h 505h 0 0b80ah 10h trtdb TRTDB
|
||||
209h 609h 505h 0 0b80eh 1eh trtdrb TRTDRB
|
||||
209h 609h 505h 0 0b802h 10h trtib TRTIB
|
||||
209h 609h 505h 0 0b806h 1eh trtirb TRTIRB
|
||||
205h 0 0 0 8d06h 0
|
||||
209h 0 0 0 0d06h 0
|
||||
90ah 0 0 0 4d06h 0 tset TSET
|
||||
204h 0 0 0 8c06h 0
|
||||
209h 0 0 0 0c06h 0
|
||||
90ah 0 0 0 4c06h 0 tsetb TSETB
|
||||
305h 205h 0 0 8900h 0
|
||||
305h 1d08h 0 0 900h 0
|
||||
305h 209h 0 0 900h 0
|
||||
305h 90ah 0 0 4900h 0 xor XOR
|
||||
304h 204h 0 0 8800h 0
|
||||
304h 1c08h 0 0 800h 0
|
||||
304h 209h 0 0 800h 0
|
||||
304h 90ah 0 0 4800h 0 xorb XORB
|
||||
|
||||
1 .end .END
|
||||
2 .equ .EQU
|
||||
3 .input .INPUT
|
||||
4 .byte .BYTE
|
||||
5 .word .WORD
|
||||
6 .set .SET
|
||||
7 .block .BLOCK
|
||||
8 .org .ORG
|
||||
9 .clist .CLIST
|
||||
10 .sect .SECT
|
||||
11 .space .SPACE
|
||||
12 .stitle .STITLE
|
||||
13 .title .TITLE
|
||||
14 .list .LIST
|
||||
15 .else .ELSE
|
||||
16 .endif .ENDIF
|
||||
17 .if .IF
|
||||
18 .global .GLOBAL
|
||||
19 .abs .ABS
|
||||
20 .align .ALIGN
|
||||
21 .within .WITHIN
|
||||
22 .macro .MACRO
|
||||
23 .endm .ENDM
|
||||
24 .long .LONG
|
||||
25 .eject .EJECT
|
||||
26 .common .COMMON
|
||||
28 .endr .ENDR
|
||||
29 .repeat .REPEAT
|
||||
30 .error .ERROR
|
||||
31 .exit .EXIT
|
||||
33 .warn .WARN
|
||||
|
||||
100h $
|
||||
1000h rh0 RH0
|
||||
1001h rh1 RH1
|
||||
1002h rh2 RH2
|
||||
1003h rh3 RH3
|
||||
1004h rh4 RH4
|
||||
1005h rh5 RH5
|
||||
1006h rh6 RH6
|
||||
1007h rh7 RH7
|
||||
1008h rl0 RL0
|
||||
1009h rl1 RL1
|
||||
100ah rl2 RL2
|
||||
100bh rl3 RL3
|
||||
100ch rl4 RL4
|
||||
100dh rl5 RL5
|
||||
100eh rl6 RL6
|
||||
100fh rl7 RL7
|
||||
1100h r0 R0
|
||||
1101h r1 R1
|
||||
1102h r2 R2
|
||||
1103h r3 R3
|
||||
1104h r4 R4
|
||||
1105h r5 R5
|
||||
1106h r6 R6
|
||||
1107h r7 R7
|
||||
1108h r8 R8
|
||||
1109h r9 R9
|
||||
110ah r10 R10
|
||||
110bh r11 R11
|
||||
110ch r12 R12
|
||||
110dh r13 R13
|
||||
110eh r14 R14
|
||||
110fh r15 R15
|
||||
1200h rr0 RR0
|
||||
1202h rr2 RR2
|
||||
1204h rr4 RR4
|
||||
1206h rr6 RR6
|
||||
1208h rr8 RR8
|
||||
120ah rr10 RR10
|
||||
120ch rr12 RR12
|
||||
120eh rr14 RR14
|
||||
1300h rq0 RQ0
|
||||
1304h rq4 RQ4
|
||||
1308h rq8 RQ8
|
||||
130ch rq12 RQ12
|
||||
1401h lt LT
|
||||
1402h le LE
|
||||
1403h ule ULE
|
||||
1404h ov OV pe PE p P v V
|
||||
1405h mi MI s S
|
||||
1406h z Z eq EQ
|
||||
1407h c C ult ULT
|
||||
1409h ge GE
|
||||
140ah gt GT
|
||||
140bh ugt UGT
|
||||
140ch nov NOV po PO
|
||||
140dh pl PL
|
||||
140eh nz NZ ne NE
|
||||
140fh nc NC uge UGE
|
||||
150eh nvi NVI
|
||||
150dh vi VI
|
||||
1602h fcw FCW
|
||||
1603h refresh REFRESH
|
||||
1604h psapseg PSAPSEG
|
||||
1605h psapoff PSAPOFF psap PSAP
|
||||
1606h nspseg NSPSEG
|
||||
1607h nspoff NSPOFF nsp NSP
|
||||
1701h flags FLAGS
|
||||
; @(#)asz8k.pdc 3.1
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
#include "asz8k.h"
|
||||
|
||||
/*
|
||||
* Version 3.3, 8/27/82. Changes to accomodate 8086 version.
|
||||
*/
|
||||
static char ident[] = "@(#)asz8kglo.c 3.3";
|
||||
|
||||
/*
|
||||
* Global variable definitions and initializations specific to asz8k.
|
||||
*/
|
||||
struct chent chtab[] = { /* table of single-character tokens */
|
||||
{'~',TKUNOP},
|
||||
{'*',TKMULOP,TVMUL},
|
||||
{'/',TKMULOP,TVDIV},
|
||||
{'%',TKMULOP,TVMOD},
|
||||
{'+',TKADDOP,TVADD},
|
||||
{'-',TKADDOP,TVSUB},
|
||||
{'=',TKRELOP,TVEQ},
|
||||
{'&',TKANDOP},
|
||||
{'^',TKXOROP},
|
||||
{'|',TKOROP},
|
||||
{'(',TKLPAR},
|
||||
{')',TKRPAR},
|
||||
{'#',TKPOUND},
|
||||
{'@',TKAT},
|
||||
{',',TKCOM},
|
||||
{':',TKCOLON},
|
||||
{'\n',TKEOL},
|
||||
{-1,TKEOF},
|
||||
{0,TKERR}
|
||||
};
|
||||
int extoff = 2;
|
||||
uns minaln = 1;
|
||||
struct operand optab[OPMAX] = 0;
|
||||
char segflg = 0;
|
||||
char oflag = 0;
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
int ptab[] {02,0,01,040400,040401,040402,040403,0100030,0100042,
|
||||
0100054,0100066,0100100,0100110,040404,0100113,0100116,040405,
|
||||
040406,040407,040410,040411,041012,041012,024,026,040400,
|
||||
040401,040402,0100030,0100042,0100066,041013,041013,024,
|
||||
026,040400,040401,040402,0100030,0100042,0100066,041014,
|
||||
0100150,035,040,040400,040401,040402,040403,0100030,0100042,
|
||||
0100066,0100153,050,040,040400,040401,040402,040403,0100030,
|
||||
0100042,0100066,041015,052,040,040400,040401,040402,040403,
|
||||
0100030,0100042,0100066,054,041016,041017,057,0420,0421,
|
||||
057,0422,0423,052,0100160,0424,062,0100173,0425,064,0100205,
|
||||
0426,066,0100221,0100232,0427,071,0100241,073,0100246,0430,
|
||||
057,0431,0100255,033,0100257,057,01032,0100255,075,0100160,
|
||||
041433,0100262,0100,040,040400,040401,040402,040403,0100030,
|
||||
0100042,0100066,0100265,0100265,0102,040,040400,040401,040402,
|
||||
040403,0100030,0100042,0100066,041434,0103,040,040400,040401,
|
||||
040402,040403,0100030,0100042,0100066,0100270,0100270,0100270,
|
||||
0105,026,040400,040401,040402,0100030,0100042,0100066,0100273,
|
||||
073,026,040400,040401,040402,0100030,0100042,0100066,0110,
|
||||
041435,041436,041436,024,026,040400,040401,040402,0100030,
|
||||
0100042,0100066,0112,0100276,0114,0100302,0100312,062,0100173,
|
||||
01437,064,0100205,01440,073,0100246,01441,0117,0100221,01442,
|
||||
076,042043,0100314,052,040,040400,040401,040402,040403,0100030,
|
||||
0100042,0100066,076,042044,076,042445};
|
||||
|
||||
int ntdflt[] {0100002,040446,0100121,0100124,0100127,0100127,0100132,
|
||||
0100136,0100140,0100140,0100140,0100143,040447,0100146};
|
||||
|
||||
int semtab[] {05015,05014,05013,03416,0463,0466,0475,0476,0477,0500,
|
||||
04403,04402,0505,0467,0471,0472,0464,06501,0465,06502,05400,
|
||||
01000,01400,02400,03000,0417,0504,05012,02007,02420,04005,
|
||||
01010,01404,03006,02411,06103,0474,0473,01,0470};
|
||||
|
||||
char scntab[] {0377,01,02,03,04,05,07,013,014,016,017,020,021,022,023,
|
||||
024,025,026,027,0376,011,012,01,02,03,05,07,014,0376,013,014,
|
||||
0377,01,02,03,04,05,07,014,0376,02,0377,013,0377,021,022,0376,
|
||||
0,014,0376,012,0377,011,0377,07,010,0377,010,0376,06,0377,013,
|
||||
015,0376,03,0377,04,05,0377,010,011,012,04,0376,021,0376,016,
|
||||
021,0376,07,0377};
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
/*
|
||||
* Version 3.3, 8/20/82. Made colon a real token and got rid of the TKLAB
|
||||
* token type, to accomodate 8086 version.
|
||||
*
|
||||
* Version 3.2, 7/5/82. Performance enhancements.
|
||||
*/
|
||||
|
||||
static char ident[] = "@(#)a.token.c 3.3";
|
||||
|
||||
/*
|
||||
* stresc - Processes a string escape. This routine is called after the
|
||||
* escape character (normally '\') has been seen. It scans off the remainder
|
||||
* of the escape and returns its value.
|
||||
*/
|
||||
stresc() {
|
||||
|
||||
int ct,
|
||||
val;
|
||||
|
||||
scanc();
|
||||
if('0'<=ch && ch<='7') { /* an octal escape */
|
||||
val = 0; ct = 3;
|
||||
do {
|
||||
val = (val<<3)+ch-'0';
|
||||
scanc();
|
||||
} while(--ct>0 && '0'<=ch && ch<='7');
|
||||
unscanc();
|
||||
return(val);
|
||||
}
|
||||
switch(ch) { /* a single-character escape */
|
||||
|
||||
case 'b':
|
||||
case 'B':
|
||||
return('\b');
|
||||
|
||||
case 'f':
|
||||
case 'F':
|
||||
return('\f');
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
return('\n');
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
return('\r');
|
||||
|
||||
case 't':
|
||||
case 'T':
|
||||
return('\t');
|
||||
|
||||
default:
|
||||
return(ch);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* token - Scans the next token and returns its type. Also sets up the
|
||||
* token's type and value information in the global cells toktyp, tokval,
|
||||
* and tokstr.
|
||||
*/
|
||||
token() {
|
||||
|
||||
int c;
|
||||
struct chent *chp;
|
||||
char radix;
|
||||
char *strp;
|
||||
|
||||
strp = tokstr;
|
||||
scanc();
|
||||
#ifdef DEBUG
|
||||
printf("%c(%o)",ch,ch);
|
||||
#endif
|
||||
if(white(ch)) { /* white space */
|
||||
do {
|
||||
scanc();
|
||||
} while(white(ch));
|
||||
if(ch!=';' && ch!='\n') {
|
||||
unscanc();
|
||||
return(toktyp = TKSPC);
|
||||
}
|
||||
}
|
||||
if(ch == ';') { /* comment */
|
||||
do {
|
||||
scanc();
|
||||
} while(ch != '\n');
|
||||
return(toktyp = TKEOL);
|
||||
}
|
||||
if('a'<=ch&&ch<='z' || 'A'<=ch&&ch<='Z' || ch=='$' || ch=='_'
|
||||
|| ch=='.') { /* symbol */
|
||||
do {
|
||||
if(strp < tokstr+SYMSIZ) *strp++ = ch;
|
||||
scanc();
|
||||
} while('a'<=ch&&ch<='z' || 'A'<=ch&&ch<='Z' ||
|
||||
'0'<=ch&&ch<='9' || ch=='$' || ch=='_' || ch=='.');
|
||||
*strp = '\0';
|
||||
unscanc();
|
||||
return(toktyp = TKSYM);
|
||||
}
|
||||
if('0'<=ch && ch<='9') { /* constant */
|
||||
do {
|
||||
*strp++ = ch;
|
||||
scanc();
|
||||
if('A'<=ch && ch<='Z') ch += 'a'-'A';
|
||||
} while('0'<=ch&&ch<='9' || 'a'<=ch&&ch<='z');
|
||||
unscanc();
|
||||
*strp = '\0';
|
||||
c = *--strp;
|
||||
if('0'<=c && c<='9') radix = 10;
|
||||
else {
|
||||
switch(c) {
|
||||
|
||||
case 'b':
|
||||
radix = 2;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
radix = 10;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
radix = 16;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'q':
|
||||
radix = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
return(toktyp = TKERR);
|
||||
}
|
||||
*strp = '\0';
|
||||
}
|
||||
tokval = 0; strp = tokstr;
|
||||
while(c = *strp++) {
|
||||
if('0'<=c && c<='9') c -= '0';
|
||||
else c += 10-'a';
|
||||
if(c >= radix) return(toktyp = TKERR);
|
||||
tokval = tokval*radix+c;
|
||||
}
|
||||
return(toktyp = TKCON);
|
||||
}
|
||||
if(ch == '\'') { /* character constant */
|
||||
scanc();
|
||||
if(ch == '\n') {
|
||||
unscanc();
|
||||
return(toktyp = TKERR);
|
||||
}
|
||||
tokval = (ch==escchr)?stresc():ch;
|
||||
scanc();
|
||||
if(ch != '\'') {
|
||||
unscanc();
|
||||
return(toktyp = TKERR);
|
||||
}
|
||||
return(toktyp = TKCON);
|
||||
}
|
||||
if(ch == '"') { /* quoted string */
|
||||
scanc();
|
||||
while(ch != '"') {
|
||||
if(ch == '\n') {
|
||||
unscanc();
|
||||
return(toktyp = TKERR);
|
||||
}
|
||||
if(strp < tokstr+STRSIZ) {
|
||||
*strp++ = (ch==escchr)?stresc():ch;
|
||||
}
|
||||
scanc();
|
||||
}
|
||||
*strp = '\0';
|
||||
tokval = strp-tokstr;
|
||||
return(toktyp = TKSTR);
|
||||
}
|
||||
if(ch == '<') {
|
||||
scanc();
|
||||
if(ch == '<') {
|
||||
tokval = TVSHL;
|
||||
return(toktyp = TKMULOP);
|
||||
}
|
||||
if(ch == '=') {
|
||||
tokval = TVLE;
|
||||
return(toktyp = TKRELOP);
|
||||
}
|
||||
unscanc();
|
||||
tokval = TVLT;
|
||||
return(toktyp = TKRELOP);
|
||||
}
|
||||
if(ch == '>') {
|
||||
scanc();
|
||||
if(ch == '>') {
|
||||
tokval = TVSHR;
|
||||
return(toktyp = TKMULOP);
|
||||
}
|
||||
if(ch == '=') {
|
||||
tokval = TVGE;
|
||||
return(toktyp = TKRELOP);
|
||||
}
|
||||
unscanc();
|
||||
tokval = TVGT;
|
||||
return(toktyp = TKRELOP);
|
||||
}
|
||||
if(ch == '!') {
|
||||
scanc();
|
||||
if(ch == '=') {
|
||||
tokval = TVNE;
|
||||
return(toktyp = TKRELOP);
|
||||
}
|
||||
unscanc();
|
||||
return(toktyp = TKERR);
|
||||
}
|
||||
/* single character token */
|
||||
for(chp=chtab ; chp->ch_chr ; chp++) {
|
||||
if(ch == chp->ch_chr) break;
|
||||
}
|
||||
tokval = chp->ch_val;
|
||||
return(toktyp = chp->ch_typ);
|
||||
}
|
||||
|
||||
/*
|
||||
* xscanc - Takes care of the cases of character scanning which would be
|
||||
* difficult for the macro scanc() to handle. Namely, these are end of line
|
||||
* processing and continuation processing.
|
||||
*/
|
||||
xscanc() {
|
||||
|
||||
top:
|
||||
if(ch == '\0') {
|
||||
getline();
|
||||
ch = *scanpt++;
|
||||
goto top;
|
||||
}
|
||||
if(ch==escchr && *scanpt=='\n') { /* continuation */
|
||||
scanpt++;
|
||||
putline();
|
||||
ch = *scanpt++;
|
||||
goto top;
|
||||
}
|
||||
return(ch);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
|
||||
static char ident[] = "@(#)a.vm.c 3.1";
|
||||
|
||||
/*
|
||||
* getbuf - Returns a pointer to a buffer which contains the specified
|
||||
* virtual address. Pages the buffers on a LRU basis.
|
||||
*/
|
||||
struct vmbuf *
|
||||
getbuf(adr) vmadr adr; {
|
||||
|
||||
static int limblk = 0; /* file high water mark */
|
||||
reg struct vmbuf *cb, *pb;
|
||||
reg uns vbn;
|
||||
|
||||
#ifdef STATS
|
||||
vmgct++;
|
||||
#endif
|
||||
vbn = adr>>BLKLOG;
|
||||
pb = &vmhead; cb = vmhead;
|
||||
while(cb->vm_blk!=vbn && cb->vm_lnk) {
|
||||
pb = cb; cb = cb->vm_lnk;
|
||||
}
|
||||
if(cb->vm_blk!=vbn) { /* must commandeer a buffer */
|
||||
if(cb->vm_flg&VMDIR) { /* write out old contents */
|
||||
lseek(vmfd,(long)cb->vm_blk<<BLKLOG,0);
|
||||
write(vmfd,cb->vm_mem,1<<BLKLOG);
|
||||
if(cb->vm_blk >= limblk) limblk = cb->vm_blk+1;
|
||||
cb->vm_flg &= ~VMDIR;
|
||||
#ifdef STATS
|
||||
vmwct++;
|
||||
#endif
|
||||
}
|
||||
if(vbn < limblk) { /* read from disk */
|
||||
lseek(vmfd,(long)vbn<<BLKLOG,0);
|
||||
read(vmfd,cb->vm_mem,1<<BLKLOG);
|
||||
#ifdef STATS
|
||||
vmrct++;
|
||||
#endif
|
||||
}
|
||||
cb->vm_blk = vbn;
|
||||
}
|
||||
pb->vm_lnk = cb->vm_lnk; cb->vm_lnk = vmhead; vmhead = cb;
|
||||
return(cb);
|
||||
}
|
||||
|
||||
/*
|
||||
* rfetch - Fetches a specified virtual address for reading, and returns
|
||||
* a pointer to the in-core copy of the address.
|
||||
*/
|
||||
char *
|
||||
rfetch(adr) vmadr adr; {
|
||||
|
||||
return(&getbuf(adr)->vm_mem[adr&(1<<BLKLOG)-1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* valloc - Allocates a region of virtual memory of the specified size,
|
||||
* and returns the vm address of it. The region is guaranteed to reside
|
||||
* entirely within a single block.
|
||||
*/
|
||||
vmadr
|
||||
valloc(size) uns size; {
|
||||
|
||||
vmadr base, blklim;
|
||||
|
||||
blklim = (virtop|(1<<BLKLOG)-1)+1;
|
||||
if(virtop+size > blklim) virtop = blklim;
|
||||
base = virtop; virtop += size;
|
||||
return(base);
|
||||
}
|
||||
|
||||
/*
|
||||
* vinit - Opens the virtual memory file.
|
||||
*/
|
||||
vinit() {
|
||||
|
||||
close(creatb("VM.TMP",0666));
|
||||
if((vmfd=openb("VM.TMP",2)) == -1) {
|
||||
fprintf(ERROR,"Cannot reopen vm file\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wfetch - Fetches a specified virtual address for writing, and returns
|
||||
* a pointer to the in-core copy of the address.
|
||||
*/
|
||||
char *
|
||||
wfetch(adr) vmadr adr; {
|
||||
|
||||
reg struct vmbuf *bp;
|
||||
|
||||
(bp=getbuf(adr))->vm_flg |= VMDIR;
|
||||
return(&bp->vm_mem[adr&(1<<BLKLOG)-1]);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "stdio.h"
|
||||
/*
|
||||
* Changed to use the Standard I/O library 9/13/82 FZ
|
||||
*/
|
||||
#include "acom.h"
|
||||
#include "obj.h"
|
||||
|
||||
static char ident[] = "@(#)a.xref.c 3.1";
|
||||
|
||||
/*
|
||||
* putxref - Prints out the cross reference listing.
|
||||
*/
|
||||
putxref() {
|
||||
|
||||
struct sytab *syp;
|
||||
struct xref *xrp;
|
||||
vmadr sym, xr, xrtail;
|
||||
uns llcol;
|
||||
char undef;
|
||||
|
||||
strcpy(titl2,"Cross Reference Listing"); linect = 0;
|
||||
sysort();
|
||||
for(sym=syhtab[0] ; sym!=0 ; sym=syp->sy_lnk) {
|
||||
syp = (struct sytab *)rfetch(sym);
|
||||
xrtail = syp->sy_xlk;
|
||||
undef = syp->sy_typ==STUND || syp->sy_rel==RBUND;
|
||||
if(syp->sy_typ==STKEY || syp->sy_typ==STSEC ||
|
||||
undef&&xrtail==0) continue;
|
||||
pgcheck();
|
||||
fprintf(LIST,"%-8.8s ",syp->sy_str);
|
||||
if(undef) fprintf(LIST," U");
|
||||
else if(syp->sy_atr&SAMUD) fprintf(LIST," M");
|
||||
else {
|
||||
fprintf(LIST,"%8X",(long)syp->sy_val);
|
||||
if(syp->sy_rel == RBABS) fputc(' ',LIST);
|
||||
else if(syp->sy_rel >= RBEXT) fputc('X',LIST);
|
||||
else fputc('\'',LIST);
|
||||
}
|
||||
if(xrtail != 0) { /* we have some xref entries */
|
||||
xrp = (struct xref *)rfetch(xrtail);
|
||||
llcol = 18;
|
||||
do {
|
||||
xr = xrp->xr_lnk;
|
||||
xrp = (struct xref *)rfetch(xr);
|
||||
if(llcol > rmarg-8) { /* start new line */
|
||||
fputc('\n',LIST);
|
||||
pgcheck();
|
||||
fprintf(LIST," ");
|
||||
llcol = 18;
|
||||
}
|
||||
fprintf(LIST," %3d-%2d%c",xrp->xr_pl>>6&0777,
|
||||
xrp->xr_pl&077,xrp->xr_pl&XRDEF?'*':' ');
|
||||
llcol += 8;
|
||||
} while(xr != xrtail);
|
||||
syp = (struct sytab *)rfetch(sym);
|
||||
}
|
||||
fputc('\n',LIST);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* symerge - Merges the two specified symbol table hash chains, and
|
||||
* returns a pointer to the resulting chain.
|
||||
*/
|
||||
vmadr
|
||||
symerge(a,b) vmadr a, b; {
|
||||
|
||||
struct sytab *ap, *bp;
|
||||
vmadr pa, r, t;
|
||||
|
||||
if(a == 0) return(b);
|
||||
if(b == 0) return(a);
|
||||
/*
|
||||
* Initialize so that the first element of chain a is less than the
|
||||
* first element of chain b.
|
||||
*
|
||||
* CAUTION -- This code requires an lru virtual memory buffer pool
|
||||
* of at least 3 blocks.
|
||||
*/
|
||||
if(symcmp((ap=(struct sytab *)rfetch(a))->sy_str,
|
||||
(bp=(struct sytab *)rfetch(b))->sy_str) > 0) { /* exchange a and b */
|
||||
t = a; a = b; b = t; ap = bp;
|
||||
}
|
||||
r = a; /* initialize result with smallest element */
|
||||
/*
|
||||
* Attach successive smallest portions of the chains onto the result
|
||||
* until there is nothing left.
|
||||
*/
|
||||
do {
|
||||
/*
|
||||
* Walk along chain a until its end is reached or it is
|
||||
* no longer the smaller of the two.
|
||||
*/
|
||||
do {
|
||||
pa = a;
|
||||
} while((a=ap->sy_lnk)!=0 &&
|
||||
symcmp((ap=(struct sytab *)rfetch(a))->sy_str,
|
||||
(bp=(struct sytab *)rfetch(b))->sy_str)<=0);
|
||||
/*
|
||||
* Link b to the end of the result, then exchange the chains
|
||||
* so that a again points to the smaller of the two.
|
||||
*/
|
||||
((struct sytab *)wfetch(pa))->sy_lnk = b;
|
||||
t = a; a = b; b = t; ap = bp;
|
||||
} while(b != 0);
|
||||
return(r);
|
||||
}
|
||||
|
||||
/*
|
||||
* sysort - Sorts the symbol table into a single alphabetical chain whose
|
||||
* head is syhtab[0].
|
||||
*/
|
||||
sysort() {
|
||||
|
||||
uns halfi, i, j;
|
||||
|
||||
for(i=1<<SHSHLOG ; i>1 ; i=halfi) {
|
||||
halfi = i>>1;
|
||||
for(j=0 ; j<halfi ; j++) {
|
||||
syhtab[j] = symerge(syhtab[j],syhtab[j+halfi]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* xref - Adds a cross reference entry of the specified type for the
|
||||
* specified symbol.
|
||||
*/
|
||||
xref(sym,type) vmadr sym; int type; {
|
||||
|
||||
struct sytab *syp;
|
||||
struct xref *oxp, *nxp;
|
||||
vmadr nxr;
|
||||
int pl;
|
||||
|
||||
if(!(xflag&&pass2)) return;
|
||||
pl = curxpl|type;
|
||||
/*
|
||||
* CAUTION -- This code requires an lru virtual memory buffer pool
|
||||
* of at least 3 blocks.
|
||||
*/
|
||||
syp = (struct sytab *)wfetch(sym);
|
||||
if(syp->sy_xlk == 0) { /* first xref entry for this symbol */
|
||||
if((uns)virtop&01) virtop++; /* force alignment */
|
||||
nxp = (struct xref *)wfetch(nxr=valloc(sizeof(struct xref)));
|
||||
nxp->xr_lnk = nxr;
|
||||
} else { /* add to existing circular list of xref entries */
|
||||
oxp = (struct xref *)wfetch(syp->sy_xlk);
|
||||
if(oxp->xr_pl == pl) return; /* no duplicate xrefs */
|
||||
if((uns)virtop&01) virtop++; /* force alignment */
|
||||
nxp = (struct xref *)wfetch(nxr=valloc(sizeof(struct xref)));
|
||||
nxp->xr_lnk = oxp->xr_lnk; oxp->xr_lnk = nxr;
|
||||
}
|
||||
nxp->xr_pl = pl;
|
||||
syp->sy_xlk = nxr;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* @(#)obj.h 3.3
|
||||
*
|
||||
* Unidot Object Format.
|
||||
*
|
||||
* Copyright 1981 by John D. Polstra and Robert M. McClure.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Object file block types.
|
||||
*/
|
||||
#define OBOST 1 /* object start block */
|
||||
#define OBLST 2 /* library start block */
|
||||
#define OBSEC 3 /* sections block */
|
||||
#define OBGLO 4 /* global symbols block */
|
||||
#define OBLOC 5 /* local symbols block */
|
||||
#define OBTXT 6 /* text block */
|
||||
#define OBBSZ 7 /* bssz block */
|
||||
#define OBTRA 8 /* transfer address block */
|
||||
#define OBLIX 9 /* library index block */
|
||||
#define OBLND 10 /* library end block */
|
||||
#define OBOND 11 /* object end block */
|
||||
#define OBMOD 12 /* module name block */
|
||||
/*
|
||||
* Object file relocation actions.
|
||||
*/
|
||||
#define RANOP 0 /* no relocation operation */
|
||||
#define RAA16 0x8000 /* add base to word field */
|
||||
#define RAA8 0x4000 /* add base to byte field */
|
||||
#define RAA32 0xc000 /* add base to long field */
|
||||
#define RAA16M 0x2000 /* add base to word field (MSB first) */
|
||||
#define RAA32M 0xa000 /* add base to long field (MSB first) */
|
||||
#define RAZSS 0x6000 /* relocate Z8001 short seg address */
|
||||
#define RAZLS 0xe000 /* relocate Z8001 long seg address */
|
||||
#define RASEG 0x1000 /* 8086 segment relocation */
|
||||
#define RAOFF 0x9000 /* 8086 offset relocation */
|
||||
#define RAJ11 0x5000 /* 8051 11-bit jump target relocation */
|
||||
#define RASOFF 0xd000 /* 8086 short offset relocation */
|
||||
#define RAZOF 0x3000 /* relocate Z8001 16-bit offset */
|
||||
#define RAMSK 0xf000 /* mask for relocation action field */
|
||||
/*
|
||||
* Object file relocation bases.
|
||||
*/
|
||||
#define RBABS 0 /* absolute */
|
||||
#define RBSEC 1 /* section */
|
||||
#define RBUND 255 /* undefined */
|
||||
#define RBEXT 256 /* external */
|
||||
#define RBMSK 0x0fff /* mask for relocation base field */
|
||||
/*
|
||||
* Section attributes.
|
||||
*/
|
||||
#define SENOX 0001 /* not executable */
|
||||
#define SENOW 0002 /* not writeable */
|
||||
#define SENOR 0004 /* not readable */
|
||||
#define SECOM 0010 /* common */
|
||||
#define SEFIX 0020 /* base address fixed */
|
||||
@@ -0,0 +1,489 @@
|
||||
.title "Asz8k Assembler Test Program"
|
||||
.stitle "Opcodes in Alphabetical Order"
|
||||
__text .sect
|
||||
|
||||
adc r3,r5
|
||||
adcb rh3,rh5
|
||||
add r3,#1234h
|
||||
add r3,@r5
|
||||
add r3,foo
|
||||
add r3,foo(r5)
|
||||
add r3,r5
|
||||
addb rh3,#12h
|
||||
addb rh3,@r5
|
||||
addb rh3,foo
|
||||
addb rh3,foo(r5)
|
||||
addb rh3,rh5
|
||||
addl rr2,#12345678h
|
||||
addl rr2,@r5
|
||||
addl rr2,foo
|
||||
addl rr2,foo(r5)
|
||||
addl rr2,rr6
|
||||
and r3,#12h
|
||||
and r3,@r5
|
||||
and r3,foo
|
||||
and r3,foo(r5)
|
||||
and r3,r5
|
||||
andb rh3,#12h
|
||||
andb rh3,@r5
|
||||
andb rh3,foo
|
||||
andb rh3,foo(r5)
|
||||
andb rh3,rh5
|
||||
bit @r3,#5
|
||||
bit foo(r3),#5
|
||||
bit foo,#5
|
||||
bit r3,#5
|
||||
bit r3,r5
|
||||
bitb @r3,#5
|
||||
bitb foo(r3),#5
|
||||
bitb foo,#5
|
||||
bitb rh3,#5
|
||||
bitb rh3,r5
|
||||
call @r3
|
||||
call foo
|
||||
call foo(r3)
|
||||
calr $
|
||||
clr @r3
|
||||
clr foo
|
||||
clr foo(r3)
|
||||
clr r3
|
||||
clrb @r3
|
||||
clrb foo
|
||||
clrb foo(r3)
|
||||
clrb rh3
|
||||
com @r3
|
||||
com foo
|
||||
com foo(r3)
|
||||
com r3
|
||||
comb @r3
|
||||
comb foo
|
||||
comb foo(r3)
|
||||
comb rh3
|
||||
comflg v
|
||||
comflg v,s
|
||||
comflg v,s,z
|
||||
comflg v,s,z,c
|
||||
cp @r3,#12
|
||||
cp foo(r3),#12
|
||||
cp foo,#12
|
||||
cp r3,#12
|
||||
cp r3,@r5
|
||||
cp r3,foo
|
||||
cp r3,foo(r5)
|
||||
cp r3,r5
|
||||
cpb @r3,#12
|
||||
cpb foo(r3),#12
|
||||
cpb foo,#12
|
||||
cpb rh3,#12
|
||||
cpb rh3,@r5
|
||||
cpb rh3,foo
|
||||
cpb rh3,foo(r5)
|
||||
cpb rh3,rh5
|
||||
cpd r3,@r5,r7,gt
|
||||
cpdb rh3,@r5,r7,gt
|
||||
cpdr r3,@r5,r7,gt
|
||||
cpdrb rh3,@r5,r7,gt
|
||||
cpi r3,@r5,r7,gt
|
||||
cpib rh3,@r5,r7,gt
|
||||
cpir r3,@r5,r7,gt
|
||||
cpirb rh3,@r5,r7,gt
|
||||
cpl rr4,#12
|
||||
cpl rr4,@r5
|
||||
cpl rr4,foo
|
||||
cpl rr4,foo(r5)
|
||||
cpl rr4,rr6
|
||||
cpsd @r3,@r5,r7,gt
|
||||
cpsdb @r3,@r5,r7,gt
|
||||
cpsdr @r3,@r5,r7,gt
|
||||
cpsdrb @r3,@r5,r7,gt
|
||||
cpsi @r3,@r5,r7,gt
|
||||
cpsib @r3,@r5,r7,gt
|
||||
cpsir @r3,@r5,r7,gt
|
||||
cpsirb @r3,@r5,r7,gt
|
||||
dab rh3
|
||||
dbjnz rh3,$
|
||||
dec @r3
|
||||
dec @r3,#16
|
||||
dec foo
|
||||
dec foo(r3)
|
||||
dec foo(r3),#16
|
||||
dec foo,#16
|
||||
dec r3
|
||||
dec r3,#16
|
||||
decb @r3
|
||||
decb @r3,#16
|
||||
decb foo
|
||||
decb foo(r3)
|
||||
decb foo(r3),#16
|
||||
decb foo,#16
|
||||
decb rh3
|
||||
decb rh3,#16
|
||||
di nvi
|
||||
di nvi,vi
|
||||
di vi
|
||||
div rr2,#1234h
|
||||
div rr2,@r5
|
||||
div rr2,foo
|
||||
div rr2,foo(r5)
|
||||
div rr2,r4
|
||||
divl rq4,#12345678h
|
||||
divl rq4,@r5
|
||||
divl rq4,foo
|
||||
divl rq4,foo(r5)
|
||||
divl rq4,rr8
|
||||
djnz r3,$
|
||||
ei nvi
|
||||
ei nvi,vi
|
||||
ei vi
|
||||
ex r3,@r5
|
||||
ex r3,foo
|
||||
ex r3,foo(r5)
|
||||
ex r3,r5
|
||||
exb rh3,@r5
|
||||
exb rh3,foo
|
||||
exb rh3,foo(r5)
|
||||
exb rh3,rh5
|
||||
exts rr2
|
||||
extsb r3
|
||||
extsl rq4
|
||||
halt
|
||||
in r3,1234h
|
||||
in r3,@r5
|
||||
inb rh3,1234h
|
||||
inb rh3,@r5
|
||||
inc @r3
|
||||
inc @r3,#16
|
||||
inc foo
|
||||
inc foo(r3)
|
||||
inc foo(r3),#16
|
||||
inc foo,#16
|
||||
inc r3
|
||||
inc r3,#16
|
||||
incb @r3
|
||||
incb @r3,#16
|
||||
incb foo
|
||||
incb foo(r3)
|
||||
incb foo(r3),#16
|
||||
incb foo,#16
|
||||
incb rh3
|
||||
incb rh3,#16
|
||||
ind @r3,@r5,r7
|
||||
indb @r3,@r5,r7
|
||||
indr @r3,@r5,r7
|
||||
indrb @r3,@r5,r7
|
||||
ini @r3,@r5,r7
|
||||
inib @r3,@r5,r7
|
||||
inir @r3,@r5,r7
|
||||
inirb @r3,@r5,r7
|
||||
iret
|
||||
jp @r3
|
||||
jp foo
|
||||
jp foo(r5)
|
||||
jr $
|
||||
jr gt,$
|
||||
ld @r3,#1234h
|
||||
ld @r3,r5
|
||||
ld foo(r3),#1234h
|
||||
ld foo(r3),r5
|
||||
ld foo,#1234h
|
||||
ld foo,r5
|
||||
ld r3(#1234h),r5
|
||||
ld r3(r7),r5
|
||||
ld r3,#1234h
|
||||
ld r3,@r5
|
||||
ld r3,foo
|
||||
ld r3,foo(r5)
|
||||
ld r3,r5
|
||||
ld r3,r5(#1234h)
|
||||
ld r3,r5(r7)
|
||||
lda r3,foo
|
||||
lda r3,foo(r5)
|
||||
lda r3,r5(#1234h)
|
||||
lda r3,r5(r7)
|
||||
ldar r3,$
|
||||
ldb @r3,#12h
|
||||
ldb @r3,rh5
|
||||
ldb foo(r3),#12h
|
||||
ldb foo(r3),rh5
|
||||
ldb foo,#12h
|
||||
ldb foo,rh5
|
||||
ldb r3(#1234h),rh5
|
||||
ldb r3(r7),rh5
|
||||
ldb rh3,#12h
|
||||
ldb rh3,@r5
|
||||
ldb rh3,foo
|
||||
ldb rh3,foo(r5)
|
||||
ldb rh3,r5(#1234h)
|
||||
ldb rh3,r5(r7)
|
||||
ldb rh3,rh5
|
||||
ldctl fcw,r5
|
||||
ldctl nsp,r5
|
||||
ldctl psap,r5
|
||||
ldctl r5,fcw
|
||||
ldctl r5,nsp
|
||||
ldctl r5,psap
|
||||
ldctl r5,refresh
|
||||
ldctl refresh,r5
|
||||
ldctlb flags,rh5
|
||||
ldctlb rh3,flags
|
||||
ldd @r3,@r5,r7
|
||||
lddb @r3,@r5,r7
|
||||
lddr @r3,@r5,r7
|
||||
lddrb @r3,@r5,r7
|
||||
ldi @r3,@r5,r7
|
||||
ldib @r3,@r5,r7
|
||||
ldir @r3,@r5,r7
|
||||
ldirb @r3,@r5,r7
|
||||
ldk r3,#15
|
||||
ldl @r3,rr6
|
||||
ldl foo(r3),rr6
|
||||
ldl foo,rr6
|
||||
ldl r3(#1234h),rr6
|
||||
ldl r3(r7),rr6
|
||||
ldl rr2,#12345678h
|
||||
ldl rr2,@r5
|
||||
ldl rr2,foo
|
||||
ldl rr2,foo(r5)
|
||||
ldl rr2,r5(#1234h)
|
||||
ldl rr2,r5(r7)
|
||||
ldl rr2,rr6
|
||||
ldm @r3,r10,#5
|
||||
ldm foo(r3),r10,#5
|
||||
ldm foo,r10,#5
|
||||
ldm r3,@r10,#5
|
||||
ldm r3,foo(r10),#5
|
||||
ldm r3,foo,#5
|
||||
ldps @r3
|
||||
ldps foo
|
||||
ldps foo(r5)
|
||||
ldr $,r7
|
||||
ldr r7,$
|
||||
mbit
|
||||
mreq r7
|
||||
mres
|
||||
mset
|
||||
mult rr2,#1234h
|
||||
mult rr2,@r5
|
||||
mult rr2,foo
|
||||
mult rr2,foo(r5)
|
||||
mult rr2,r4
|
||||
multl rq4,#12345678h
|
||||
multl rq4,@r5
|
||||
multl rq4,foo
|
||||
multl rq4,foo(r5)
|
||||
multl rq4,rr8
|
||||
neg @r3
|
||||
neg foo
|
||||
neg foo(r3)
|
||||
neg r3
|
||||
negb @r3
|
||||
negb foo
|
||||
negb foo(r3)
|
||||
negb rh3
|
||||
nop
|
||||
or r3,#12h
|
||||
or r3,@r5
|
||||
or r3,foo
|
||||
or r3,foo(r5)
|
||||
or r3,r5
|
||||
orb rh3,#12h
|
||||
orb rh3,@r5
|
||||
orb rh3,foo
|
||||
orb rh3,foo(r5)
|
||||
orb rh3,rh5
|
||||
otdr @r3,@r5,r7
|
||||
otdrb @r3,@r5,r7
|
||||
otir @r3,@r5,r7
|
||||
otirb @r3,@r5,r7
|
||||
out 1234h,r6
|
||||
out @r3,r9
|
||||
outb 1234h,rl4
|
||||
outb @r3,rl4
|
||||
outd @r3,@r5,r7
|
||||
outdb @r3,@r5,r7
|
||||
outi @r3,@r5,r7
|
||||
outib @r3,@r5,r7
|
||||
pop @r3,@r11
|
||||
pop foo(r5),@r11
|
||||
pop foo,@r11
|
||||
pop r3,@r11
|
||||
popl @r3,@r11
|
||||
popl foo(r5),@r11
|
||||
popl foo,@r11
|
||||
popl rr10,@r11
|
||||
push @r3,#1234h
|
||||
push @r3,@r5
|
||||
push @r3,foo
|
||||
push @r3,foo(r5)
|
||||
push @r3,r5
|
||||
pushl @r3,@r5
|
||||
pushl @r3,foo
|
||||
pushl @r3,foo(r5)
|
||||
pushl @r3,rr12
|
||||
res @r3,#5
|
||||
res foo(r3),#5
|
||||
res foo,#5
|
||||
res r3,#5
|
||||
res r3,r5
|
||||
resb @r3,#5
|
||||
resb foo(r3),#5
|
||||
resb foo,#5
|
||||
resb rh3,#5
|
||||
resb rh3,r5
|
||||
resflg v
|
||||
resflg v,s
|
||||
resflg v,s,z
|
||||
resflg v,s,z,c
|
||||
ret
|
||||
ret gt
|
||||
rl r3
|
||||
rl r3,#1
|
||||
rl r3,#2
|
||||
rlb rh3
|
||||
rlb rh3,#1
|
||||
rlb rh3,#2
|
||||
rlc r3
|
||||
rlc r3,#1
|
||||
rlc r3,#2
|
||||
rlcb rh3
|
||||
rlcb rh3,#1
|
||||
rlcb rh3,#2
|
||||
rldb rh3,rl5
|
||||
rr r3
|
||||
rr r3,#1
|
||||
rr r3,#2
|
||||
rrb rh3
|
||||
rrb rh3,#1
|
||||
rrb rh3,#2
|
||||
rrc r3
|
||||
rrc r3,#1
|
||||
rrc r3,#2
|
||||
rrcb rh3
|
||||
rrcb rh3,#1
|
||||
rrcb rh3,#2
|
||||
rrdb rh7,rl7
|
||||
sbc r14,r15
|
||||
sbcb rh1,rl2
|
||||
sc #12h
|
||||
sda r3,r5
|
||||
sdab rh3,r5
|
||||
sdal rr6,r7
|
||||
sdl r3,r5
|
||||
sdlb rh3,r5
|
||||
sdll rr6,r7
|
||||
set @r3,#5
|
||||
set foo(r3),#5
|
||||
set foo,#5
|
||||
set r3,#5
|
||||
set r3,r5
|
||||
setb @r3,#5
|
||||
setb foo(r3),#5
|
||||
setb foo,#5
|
||||
setb rh3,#5
|
||||
setb rh3,r5
|
||||
setflg v
|
||||
setflg v,s
|
||||
setflg v,s,z
|
||||
setflg v,s,z,c
|
||||
sin r3,1234h
|
||||
sinb rh3,1234h
|
||||
sind @r3,@r8,r12
|
||||
sindb @r3,@r8,r12
|
||||
sindr @r3,@r8,r12
|
||||
sindrb @r3,@r8,r12
|
||||
sini @r3,@r8,r12
|
||||
sinib @r3,@r8,r12
|
||||
sinir @r3,@r8,r12
|
||||
sinirb @r3,@r8,r12
|
||||
sla r2
|
||||
sla r2,#5
|
||||
slab rl2
|
||||
slab rl2,#5
|
||||
slal rr2
|
||||
slal rr2,#5
|
||||
sll r2
|
||||
sll r2,#5
|
||||
sllb rl2
|
||||
sllb rl2,#5
|
||||
slll rr2
|
||||
slll rr2,#5
|
||||
sotdr @r3,@r5,r7
|
||||
sotdrb @r3,@r5,r7
|
||||
sotir @r3,@r5,r7
|
||||
sotirb @r3,@r5,r7
|
||||
sout 1234h,r4
|
||||
soutb 1234h,rl4
|
||||
soutd @r4,@r6,r8
|
||||
soutdb @r4,@r6,r8
|
||||
souti @r4,@r6,r8
|
||||
soutib @r4,@r6,r8
|
||||
sra r2
|
||||
sra r2,#5
|
||||
srab rl2
|
||||
srab rl2,#5
|
||||
sral rr2
|
||||
sral rr2,#5
|
||||
srl r2
|
||||
srl r2,#5
|
||||
srlb rl2
|
||||
srlb rl2,#5
|
||||
srll rr2
|
||||
srll rr2,#5
|
||||
sub r3,#1234h
|
||||
sub r3,@r5
|
||||
sub r3,foo
|
||||
sub r3,foo(r5)
|
||||
sub r3,r5
|
||||
subb rh3,#12h
|
||||
subb rh3,@r5
|
||||
subb rh3,foo
|
||||
subb rh3,foo(r5)
|
||||
subb rh3,rh5
|
||||
subl rr2,#12345678h
|
||||
subl rr2,@r5
|
||||
subl rr2,foo
|
||||
subl rr2,foo(r5)
|
||||
subl rr2,rr6
|
||||
tcc ult,r1
|
||||
tccb uge,rl3
|
||||
test @r2
|
||||
test foo
|
||||
test foo(r5)
|
||||
test r2
|
||||
testb @r2
|
||||
testb foo
|
||||
testb foo(r5)
|
||||
testb rh2
|
||||
testl @r2
|
||||
testl foo
|
||||
testl foo(r5)
|
||||
testl rr2
|
||||
trdb @r5,@r7,r9
|
||||
trdrb @r5,@r7,r9
|
||||
trib @r5,@r7,r9
|
||||
trirb @r5,@r7,r9
|
||||
trtdb @r5,@r7,r9
|
||||
trtdrb @r5,@r7,r9
|
||||
trtib @r5,@r7,r9
|
||||
trtirb @r5,@r7,r9
|
||||
tset @r6
|
||||
tset foo
|
||||
tset foo(r6)
|
||||
tset r6
|
||||
tsetb @r6
|
||||
tsetb foo
|
||||
tsetb foo(r6)
|
||||
tsetb rl6
|
||||
xor r3,#12h
|
||||
xor r3,@r5
|
||||
xor r3,foo
|
||||
xor r3,foo(r5)
|
||||
xor r3,r5
|
||||
xorb rh3,#12h
|
||||
xorb rh3,@r5
|
||||
xorb rh3,foo
|
||||
xorb rh3,foo(r5)
|
||||
xorb rh3,rh5
|
||||
|
||||
__data .Iq
|
||||
This directory contains the source and object files for the Z8000 CP/M Bdos,
|
||||
@@ -0,0 +1,2 @@
|
||||
This directory contains the source and object files for the
|
||||
Z8000 CP/M assembler "asz8k" to run under CP/M.
|
||||
Reference in New Issue
Block a user