3 #include <stdio.h> /* temp */
16 /* .globl _main, _write, _close, _execl, __exit, _brk */
17 /* .globl _read, _signal, _stat, _open, _mkstemp, _calloc, _realloc */
19 /* .globl error, errore, errora, checkeos, pass1, aexit, argb */
20 /* .globl overlaid, defund, a.outp, errflg, passno, filerr, outmod */
21 /* .globl wrterr, argb, hshsiz, dot, dotdot, savdot, ch, outbuf */
22 /* .globl line, savop, inbuf, fbptr, fbtbl, symnum, hshtab, symblk */
23 /* .globl symleft, dotrel, symtab, fin, fout, curfb, nxtfb, ibufp */
24 /* .globl ibufc, a.tmp1, usymtab, SYMENTSZ, SYMBLKSZ, PSTENTSZ */
25 /* .globl obufp, Newsym, symbol,csv */
27 /* This assembler supports _both_ the old style object files (with */
28 /* fixed 8 character symbols) and the new style (with a strings table). */
29 /* The variable 'Newsym' defined below specifies which format will be */
30 /* emitted, if the value is '0' the old style is output, if non-zero */
31 /* then the new 'string table' format is output. */
33 /* The old style on disc symbol table entries looked like this: */
41 /* The new style of on disc symbol table entry looks like: */
44 /* off_t offset_in_string_table; */
55 struct symbol *pdot = symtab;
56 struct symbol *pdotdot = symtab + 1;
57 intptr_t numbertoken; /* r0 */
58 int numbervalue; /* r0 */
60 int indirect; /* r0 */
61 int optoken; /* (sp) */
62 int rightflags; /* r0 */
63 int rightvalue; /* r1 */
64 int leftvalue; /* r2 */
65 int leftflags; /* r3 */
66 intptr_t token; /* r4 */
69 static char xbuf[0x1000];
70 static char *xbufp = xbuf, *xwhitep, *xstartp;
71 static char *xstartpsave, *xbufpsave;
72 static size_t xsavestartn, xsavebufn;
73 static char xsave[0x1000];
75 static char xrest[0x1000];
76 static int xlab, xlabnext;
77 static int xlabb[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
78 static int xlabf[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
81 /* PDP-11 assembler */
85 int main(argc, argv) int argc; char **argv; {
88 struct symbol *psymbol;
90 struct symbol **ppsymbol;
92 /* mov $1,-(sp) / signal(SIGINT, SIG_IGN) */
99 /* mov $aexit,-(sp) / signal(SIGINT, aexit) */
102 /* cmp (sp)+,(sp)+ */
104 oldsig = signal(SIGINT, SIG_IGN);
105 if (oldsig != SIG_IGN) /*((int)oldsig & 1) == 0)*/
106 signal(SIGINT, (sig_t)aexit);
109 /* mov 4(r5),r0 / argc */
110 /* mov 6(r5),curarg / argv */
117 /* dec r0 / argc-- */
118 /* add $2,curarg / argv++ */
136 /* cmpb (r1),$'- / is this "--"? */
137 /* bne 8f / no - br */
138 /* tstb 1(r1) / check for null terminator */
139 /* beq 1f / got it, the "--" means read 'stdin' */
141 if (*p == '-' && p[1] == 0)
145 /* add $2,curarg / argv++ */
146 /* dec r0 / argc-- */
167 if (*p == 'u' || *p == 0) {
174 /* mov *curarg,a.outp */
187 /* The new object file format puts a ceiling of 32 characters on symbols. */
188 /* If it is desired to raise this limit all that need be done is increase */
189 /* the same ceiling in the C compiler and linker (ld). */
199 /* mov r0,nargs / # of remaining args */
200 /* bne 8f / br if any left */
201 /* inc nargs / fake at least one arg */
202 /* mov $dash, curarg / of '-' so we read stdin */
210 /* mov $a.tmp1,-(sp) */
211 /* jsr pc,_mkstemp / fout = mkstemp(a.tmp1); */
216 fout = mkstemp(a_tmp1);
220 /* the symbol table is a single linked list of dynamically allocated */
221 /* 'SYMBLKSZ' byte blocks. Allocate the first one now. */
222 /* mov $SYMBLKSZ+2,-(sp) / symblk = calloc(1, SYMBLKSZ+2) */
225 /* cmp (sp)+,(sp)+ */
227 /* mov r0,usymtab / pointer to first block */
228 /* tst (r0)+ / skip link word */
229 /* mov r0,symend / current end in block */
230 /* mov $SYMBLKSZ,symleft / number of bytes left in block */
232 symblk = (struct symblk *)calloc(1, sizeof(struct symblk));
234 nomem(); /* don't use oops(), want to delete temp file */
236 symend = symblk->data;
239 /* The string portion of symbol table entries is now allocated dynamically. */
240 /* We allocate the strings in 1kb chunks to cut down the number of times */
241 /* the string table needs to be extended (besides, long variable names are */
242 /* coming real soon now). */
244 /* NOTE: the string blocks are linked together for debugging purposes only, */
245 /* nothing depends on the link. */
247 /* mov $STRBLKSZ+2,-(sp) */
249 /* jsr pc,_calloc / strblk = calloc(1, STRBLKSZ+2) */
250 /* / check for failure??? */
251 /* cmp (sp)+,(sp)+ */
252 /* mov r0,strblk / save pointer to string block */
253 /* tst (r0)+ / skip link word */
254 /* mov r0,strend / set available string pointer */
255 /* mov $STRBLKSZ,strleft / set amount left in block */
257 strblk = (struct strblk *)calloc(1, sizeof(struct strblk));
259 nomem(); /* don't use oops(), want to delete temp file */
260 strend = strblk->data;
263 /* the hash table is now dynamically allocated so that it can be */
264 /* reused in pass 2 and re-alloced if necessary. */
265 /* mov $2,-(sp) / hshtab = calloc($hshsiz, sizeof(int)) */
266 /* mov $hshsiz,-(sp) */
268 /* cmp (sp)+,(sp)+ */
271 hshtab = (struct symbol **)calloc(hshsiz, sizeof(struct symbol *));
273 nomem(); /* don't use oops(), want to delete temp file */
282 /* mov (r1),r2 / pointer to PST symbol's string */
300 hash = ((hash >> 8) & 0377) | ((hash & 0377) << 8);
308 ppsymbol = hshtab + (hash % hshsiz);
315 /* add $2*hshsiz,r3 */
320 /* add $PSTENTSZ,r1 */
321 /* cmp r1,$ebsymtab */
326 if (ppsymbol <= hshtab)
328 } while (*--ppsymbol);
329 *ppsymbol = psymbol++;
330 } while (psymbol < symtab + ebsymtab);
332 /* perform pass 0 processing */
340 write(1, xbuf, xbufp - xbuf);
343 /* flush the intermediate object file */
344 /* mov $1024.,-(sp) / write(fout, outbuf, 1024) */
345 /* mov $outbuf,-(sp) */
350 write(fout, outbuf, 512 * sizeof(short));
352 /* tst errflg / any errors? */
353 /* beq 1f / yes - br */
361 /* inc passno / go from -1 to 0 */
362 /* clr line / reset line number */
363 /* jmp pass1 / pass1 does both passes 1, 2, exit */
374 /* mov $9f-8f,-(sp) / write(fileno(stderr),8f,strlen()) */
382 /* <as: can't create tmpfile\n> */
388 write(2, "as: can't create tmpfile\n", 25);
393 write(2, "as: out of memory\n", 18);
399 void error(code) int code; {
401 static char report[] = "f xxxx\n";
403 /* tst passno / on pass1,2 ? */
420 /* mov *curarg,-(sp) */
446 /* mov $666,outmod / make nonexecutable */
455 /* tst -(sp) / write(1, argb, strlen(argb)) */
456 /* mov $argb,-(sp) */
471 write(1, argb, strlen(argb));
472 *argb = 0; /* a nick innovation */
503 for (i = 0; i < 4; i++) {
504 report[5 - i] = (j % 10) + '0';
508 /* mov $7,-(sp) / write(1, 9f, 7) */
514 write (1, report, 7);
527 void p0putw(word) int word; {
535 /* printf("p0putw(0%o)\n", word); */
536 if (ifflg == 0 || word == TNEWLINE)
541 /* cmp obufp,$outbuf+1024. */
543 /* mov $outbuf,obufp */
546 if (obufp >= outbuf + 512) {
549 /* mov r1,-(sp) / protect r1 from library */
550 /* mov $1024.,-(sp) / write(fout, outbuf, 1024) */
551 /* mov $outbuf,-(sp) */
560 if (write(fout, outbuf, 512 * sizeof(short)) < 0)
573 /* jsr pc,p0readop */
574 /* jsr pc,checkeos */
579 struct symbol *psymbol;
591 /* cmpb (r4),$21 /if */
595 /* cmpb (r4),$22 /endif */
602 if (token < 0 || token >= TASCII) {
603 psymbol = (struct symbol *)token;
604 switch (psymbol->flags) {
617 /* jsr pc,p0readop */
629 xstartpsave = xstartp;
639 xsavestartn = xstartp - xbufpsave;
640 xsavebufn = xbufp - xbufpsave;
641 memcpy(xsave, xbufpsave, xsavebufn);
645 xstartp = xstartpsave;
655 /* cmp r4,$1 / digit */
663 if (tokensave >= 0 && tokensave < TASCII) {
664 if (tokensave != TABS) {
677 psymbol = (struct symbol *)tokensave;
678 if (psymbol->flags & 037)
681 /* bisb dot-2,(r4) */
685 psymbol->flags |= pdot->flags;
686 psymbol->value = pdot->value;
689 // for asxlat, -u means local labels will be changed to ordinary labels
690 // (use this when there is an inconvenient ordinary label within locals)
691 if (defund != FGLOBAL) {
693 memset(xlabb, 0xff, 10 * sizeof(int));
694 memset(xlabf, 0xff, 10 * sizeof(int));
702 /* movb dotrel,curfbr(r0) */
704 /* movb dotrel,nxtfb */
705 /* mov dot,nxtfb+2 */
706 /* movb r0,nxtfb+1 */
707 /* mov dot,curfb(r0) */
710 label = fbcheck(numval);
711 curfbr[label] = pdot->flags;
712 curfb[label] = pdot->value;
714 if (xlabf[label] == -1)
721 if (xstartpsave >= xbuf + 0xff0)
723 // for asxlat, -u means local labels will be changed to ordinary labels
724 // (use this when there is an inconvenient ordinary label within locals)
725 if (defund == FGLOBAL)
726 xbufp = xstartpsave + sprintf(xstartpsave, "_%d:", xlab);
728 xbufp = xstartpsave + sprintf(xstartpsave, "%d$:", xlab);
731 /* cmp fbfree,$4 / room for another fb entry? */
732 /* bge 5f / yes - br */
733 /* jsr pc,growfb / no - grow the table */
738 /* sub $4,fbfree / four bytes less available */
739 /* mov nxtfb,*fbptr / store first word */
740 /* add $2,fbptr / advance to next */
741 /* mov nxtfb+2,*fbptr / store second word */
742 /* add $2,fbptr / point to next entry */
747 fbptr->flags = pdot->flags;
748 fbptr->value = pdot->value;
749 fbptr->number = label;
754 /* jsr pc,p0readop */
767 if (tokensave >= 0 && tokensave < TASCII) {
780 psymbol = (struct symbol *)tokensave;
781 if (psymbol == pdot) {
782 leftflags &= ~FGLOBAL;
783 /* printf("leftflags 0%o pdot->flags 0%o\n", leftflags, pdot->flags); */
784 if (leftflags != pdot->flags)
787 xrestn = xbufp - xwhitep;
788 memcpy(xrest, xwhitep, xrestn);
789 if (xstartpsave + xrestn >= xbuf + 0xff0)
791 xbufp = xstartpsave + sprintf(xstartpsave, ".ds\t%d", leftvalue);
792 memcpy(xbufp, xrest, xrestn);
803 psymbol->flags &= ~037;
812 psymbol->flags |= leftflags;
813 psymbol->value = leftvalue;
835 /* printf("ealoop token = 0x%08x\n", token); */
836 if (token == TSEMICOLON)
841 // read and ignore whitespace after ;
845 if (label != '\t' && label != ' ')
853 if (token == TNEWLINE) {
870 if (token == TENDFILE) {
878 /* jsr pc,checkeos */
880 /* jsr pc,p0readop */
885 while (checkeos() == 0)
900 int fbcheck(label) int label; {
907 /* the 'fb' table never grows to be large. In fact all of the assemblies */
908 /* of C compiler generated code which were processed by 'c2' never */
909 /* produced a table larger than 0 bytes. So we 'realloc' because */
910 /* this is not done enough to matter. */
913 /* mov r1,-(sp) / save r1 from library */
914 /* add $256.,fbtblsz / new size of fb table */
915 /* mov $256.,fbfree / number available now */
921 /* mov fbtblsz,-(sp) / fbtbl = realloc(fbtbl, fbtblsz); */
922 /* mov fbtbl,-(sp) */
923 /* bne 1f / extending table - br */
924 /* mov $1,(sp) / r0 = calloc(1, fbtblsz); */
928 /* jsr pc,_realloc */
930 /* cmp (sp)+,(sp)+ */
934 fbtbl = (struct symbol *)calloc(fbtblsz, sizeof(struct symbol));
936 fbtbl = (struct symbol *)realloc(fbtbl, fbtblsz * sizeof(struct symbol));
939 /* iot / Can never happen (I hope) */
945 /* add fbtblsz,r0 / fbptr starts 256 bytes from */
946 /* sub $256.,r0 / end of new region */
948 /* mov (sp)+,r1 / restore register */
951 fbptr = fbtbl + fbtblsz - 64;
954 /* Symbol table lookup and hashtable maintenance. */
967 struct symbol *psymbol;
968 struct symbol **ppsymbol;
971 /* movb Ncps,r5 / Max num of chars to accept */
975 /* printf("rname()\n"); */
986 /* cmp r0,$'~ / symbol not for hash table? */
987 /* bne 1f / no - br */
995 // in C compiler output, local symbols are debugging information
996 // and are only defined not referenced, comment the definitions
997 if (xbufp >= xbuf + 0x1000)
1005 /* movb chartab(r0),r3 */
1017 if (chartab[c] <= 0)
1020 hash = ((hash >> 8) & 0377) | ((hash & 0377) << 8);
1025 /* bug!! should stop accumulating hash when count == 0 */
1028 /* clrb (r2)+ / null terminate string */
1032 /* printf("symbol = \"%s\"\n", symbol); */
1039 /* if (ch) printf("a push 0x%02x\n", ch); */
1046 /* br 4f / go insert into symtable (!hashtbl) */
1050 psymbol = isroom(symend); /* symend; */
1054 /* div $hshsiz,r0 */
1057 /* clr timesaround */
1059 ppsymbol = hshtab + (hash % hshsiz);
1067 /* add $2*hshsiz,r1 */
1071 if (ppsymbol <= hshtab) {
1074 /* tst timesaround */
1076 /* mov $8f-9f,-(sp) / write(fileno(stdout),9f,8f-9f); */
1085 write(2, "as: symbol table overflow\n", 26);
1090 /* timesaround: 0 */
1092 /* <as: symbol table overflow\n> */
1097 /* inc timesaround */
1103 /* mov $symbol,r2 */
1106 /* mov (r4)+,r3 / ptr to symbol's name */
1108 /* cmpb (r2),(r3)+ */
1109 /* bne 1b / not the right symbol - br */
1110 /* tstb (r2)+ / at end of symbol? */
1111 /* bne 9b / nope - keep looking */
1112 /* br 1f / yep - br */
1114 psymbol = *--ppsymbol;
1115 if (psymbol == NULL)
1117 if (!strcmp(symbol, psymbol->name))
1123 /* jsr pc,isroom / make sure there's room in block */
1126 /* jsr pc,isroom / check for room in current block */
1128 psymbol = isroom(symend);
1129 *ppsymbol = psymbol;
1131 /* isroom(psymbol); */
1133 /* mov $symbol,r2 / length of string (including null) */
1137 /* sub $symbol,r2 */
1138 /* jsr pc,astring / allocate string space */
1139 /* mov r0,(r4)+ / save string pointer in symtab entry */
1140 /* mov $symbol,r1 */
1142 /* movb (r1)+,(r0)+ / copy symbol name to string block */
1144 /* sub $SYMENTSZ,symleft */
1146 len = strlen(symbol) + 1;
1149 memcpy(p, symbol, len);
1152 /* each new symbol is assigned a unique one up number. This is done because */
1153 /* the user symbol table is no longer contiguous - the symbol number can */
1154 /* not be calculated by subtracting a base address and dividing by the */
1155 /* size of a symbol. */
1157 /* clr (r4)+ / flags word */
1158 /* clr (r4)+ / value word */
1159 /* mov symnum,(r4)+ */
1162 /* sub $6,r4 / point to flags word */
1164 psymbol->flags = 0; /* redundant */
1165 psymbol->value = 0; /* redundant */
1166 psymbol->number = symnum++;
1167 symend = psymbol + 1;
1172 /* tst -(r3) / back to beginning of entry */
1173 /* cmp r3,$ebsymtab / Permanent Symbol Table(opcode, etc)? */
1174 /* blo 1f / yes - br */
1175 /* mov 6(r3),r4 / get symbol number */
1176 /* add $4000,r4 / user symbol flag */
1180 /* PST entries are PSTENTSZ bytes each because they do not have a 'symnum' */
1181 /* entry associated with them. */
1183 /* sub $symtab,r3 */
1185 /* div $PSTENTSZ,r2 */
1187 /* add $1000,r4 / builtin symbol */
1193 if (psymbol >= symtab + ebsymtab)
1194 p0putw(04000 + psymbol->number);
1196 p0putw(01000 + (psymbol - symtab));
1205 token = (intptr_t)psymbol;
1209 /* cmp symleft,$SYMENTSZ / room for another symbol? */
1210 /* bge 1f / yes - br */
1212 struct symbol *isroom(psymbol) struct symbol *psymbol; {
1213 struct symblk *psymblk;
1215 /* printf("isroom(0x%08x) symleft = %d\n", psymbol, symleft); */
1218 /* mov r1,-(sp) / save from library */
1219 /* mov $SYMBLKSZ+2,-(sp) / size of sym block plus link word */
1220 /* mov $1,-(sp) / number of blocks to allocate */
1221 /* jsr pc,_calloc / calloc(1, SYMBLKSZ+2); */
1222 /* cmp (sp)+,(sp)+ */
1223 /* / check for failure? */
1225 psymblk = (struct symblk *)calloc(1, sizeof(struct symblk));
1226 if (psymblk == NULL)
1229 /* mov r0,*symblk / link new block to old */
1230 /* mov r0,symblk / this is now the current block */
1231 /* tst (r0)+ / skip link word */
1232 /* mov $SYMBLKSZ,symleft / number of bytes available */
1233 /* mov r0,r4 / put where it's expected */
1235 symblk->next = psymblk;
1238 return psymblk->data;
1240 /* mov (sp)+,r1 / restore saved register */
1242 /* rts pc / return */
1248 /* allocate room for a string, the length is in R2 and includes room for */
1249 /* a terminating null byte. */
1252 /* cmp r2,strleft / room in current block? */
1253 /* ble 1f / yes - go carve out a chunk */
1255 char *astring(len) int len; {
1256 struct strblk *pstrblk;
1259 /* printf("astring(%d) strleft = %d\n", len, strleft); */
1260 if (len > strleft) {
1262 /* mov $STRBLKSZ+2,-(sp) */
1264 /* jsr pc,_calloc / symblk = calloc(1,STRBLKSZ+2) */
1265 /* / check for failure? */
1266 /* cmp (sp)+,(sp)+ */
1268 pstrblk = (struct strblk *)calloc(1, sizeof(struct strblk));
1269 if (pstrblk == NULL)
1272 /* mov r0,*strblk / update forward link between blocks */
1273 /* mov r0,strblk / update current string block pointer */
1274 /* tst (r0)+ / skip link word */
1275 /* mov r0,strend / current data pointer */
1276 /* mov $STRBLKSZ,strleft / amount of space left */
1278 strblk->next = pstrblk;
1281 strend = strblk->data;
1284 /* mov strend,r0 / string address */
1285 /* add r2,strend / update current end point */
1286 /* sub r2,strleft / update amount of space left */
1329 if (c < '0' || c > '9')
1332 decimal = decimal * 10 + c;
1333 octal = octal * 8 + c;
1347 if (c == 'b' || c == 'f')
1351 if (xstartp >= xbuf + 0xff0)
1353 xbufp = xstartp + sprintf(xstartp, "%d", decimal);
1360 if (xstartp >= xbuf + 0xff0)
1362 xbufp = xstartp + sprintf(xstartp, "%s%o", (octal & ~7) ? "0o" : "", octal);
1370 #if 0 //def TRANSLATE
1377 /* if (ch) printf("b push 0x%02x\n", ch); */
1378 numbervalue = octal;
1390 /* jsr pc,fbcheck */
1398 numbertoken = fbcheck(decimal) + TLABEL;
1422 /* printf("rch() ch = 0x%02x\n", ch); */
1427 //if (xbufp > xbuf && xbufp[-1] == '\n') {
1428 // write(1, xbuf, xbufp - xbuf);
1432 if (xbufp >= xbuf + 0x1000)
1442 /* movb *ibufp,r0 */
1452 c = *p0ibufp++ & 0177;
1457 //if (xbufp > xbuf && xbufp[-1] == '\n') {
1458 // write(1, xbuf, xbufp - xbuf);
1462 if (xbufp >= xbuf + 0x1000)
1475 /* mov r1,-(sp) / protect r1 from library */
1476 /* mov $1024.,-(sp) / read(fin, inbuf, 1024) */
1477 /* mov $inbuf,-(sp) */
1483 ibufc = read(fin, inbuf, 1024);
1488 /* mov $inbuf,ibufp */
1497 /* mov r1,-(sp) / protect r1 from library */
1498 /* mov fin,-(sp) / close(r0) */
1532 /* check for the filename arguments of "-" or "--", these mean to read 'stdin'. */
1533 /* Additional filenames are permitted and will be processed when EOF */
1534 /* is detected on stdin. */
1535 /* mov *curarg,r0 */
1536 /* cmpb (r0)+,$'- */
1537 /* bne 5f / not the special case - br */
1538 /* tstb (r0) / must be '-' by itself */
1540 /* cmpb (r0)+,$'- / check for "--" */
1541 /* bne 5f / not a double -, must be a filename */
1542 /* tstb (r0) / null terminated? */
1543 /* bne 5f / no - must be a filename */
1545 /* clr fin / file descriptor is 0 for stdin */
1550 if (*p++ == '-' && (*p == 0 || (*p++ == '-' && *p == 0))) {
1555 /* mov r1,-(sp) / protect r1 from library */
1556 /* clr -(sp) / open((r0), O_RDONLY, 0) */
1558 /* mov *curarg,-(sp) */
1563 fin = open(*curarg, O_RDONLY);
1567 /* mov *curarg,-(sp) */
1590 /* mov *curarg,r1 */
1630 /* printf("p0readop() savop = 0x%08x\n", savop); */
1638 if (xbufp + xsavebufn >= xbuf + 0x1000)
1640 memcpy(xbufp, xsave, xsavebufn);
1641 xstartp = xbufp + xsavestartn;
1642 xbufp = xbufp + xsavebufn;
1650 /* movb chartab(r0),r1 */
1659 switch (chartab[c]) {
1669 #if 1 /* modifications for dec syntax */
1731 case -004: /* can never get here */
1756 /* mov $esctab,r1 */
1776 /* .byte '\<, 035 */
1810 void retread(c) int c; {
1824 void rdname(c) int c; {
1831 /* if (ch) printf("c push 0x%02x\n", ch); */
1832 if (c >= '0' && c <= '9')
1845 retnum(numbervalue);
1847 retread(numbertoken);
1869 retnum(rsch() | (c << 8));
1882 void retnum(value) int value; {
1908 } while (c != '\n');
1975 if (c != 004 && c != '\n') {
2038 return 0; /* keep compiler happy */
2074 struct symbol *psymbol;
2077 /* printf("p0opline() token 0x%08x\n", token); */
2078 #if 0 //def TRANSLATE
2080 printf("p0opline() token 0x%08x xstartp \"%s\"\n", token, xstartp);
2084 if (token >= 0 && token < TASCII) {
2085 if (token == TSTRING)
2088 xrestn = xbufp - xstartp;
2089 memcpy(xrest, xstartp, xrestn);
2091 xrest[xrestn - 1] = '/';
2092 if (xstartp + xrestn >= xbuf + 0xff0)
2094 xbufp = xstartp + sprintf(xstartp, ".ascii ");
2095 memcpy(xbufp, xrest, xrestn);
2103 xrestn = xbufp - xstartp;
2104 memcpy(xrest, xstartp, xrestn);
2105 if (xstartp + xrestn >= xbuf + 0xff0)
2107 xbufp = xstartp + sprintf(xstartp, ".dw ");
2108 xstartp = xbufp; // for local labels
2109 memcpy(xbufp, xrest, xrestn);
2125 psymbol = (struct symbol *)token;
2126 flags = psymbol->flags;
2127 if (flags <= FBSS || flags == FREGISTER || flags > FJCOND) {
2129 if (flags != FABS) { // assume for now that ABS symbol can only be an opcode
2130 xrestn = xbufp - xstartp;
2131 memcpy(xrest, xstartp, xrestn);
2132 if (xstartp + xrestn >= xbuf + 0xff0)
2134 xbufp = xstartp + sprintf(xstartp, ".dw ");
2135 xstartp = xbufp; // for local labels
2136 memcpy(xbufp, xrest, xrestn);
2144 if (xstartp >= xbuf + 0xff0)
2148 xbufp = xstartp + sprintf(xstartp, ".area text");
2151 xbufp = xstartp + sprintf(xstartp, ".area data");
2154 xbufp = xstartp + sprintf(xstartp, ".area bss");
2161 /* jsr pc,p0readop */
2164 /* jmp *1f-12(r0) */
2171 /* opl13 / map fop freg,fdst to double */
2201 /* opl13 / map fld/fst to double */
2203 /* opl13 / map fop fsrc,freg to double */
2221 if (xstartp >= xbuf + 0xff0)
2223 xbufp = xstartp + sprintf(xstartp, ".db");
2228 #if 1 /* modifications for dec syntax */
2231 if (xstartp >= xbuf + 0xff0)
2233 xbufp = xstartp + sprintf(xstartp, ".dw");
2271 case FREGISTER: /* can never get here */
2293 /* opl13 / map mul s,r to double */
2344 /* opl36: / jeq, etc */
2364 void relative(size) int size; {
2366 if (leftflags == pdot->flags) {
2367 leftvalue -= pdot->value;
2368 if (leftvalue < 0 && leftvalue >= -0376)
2371 pdot->value += size;
2392 /* jsr pc,p0readop */
2394 if (token != TCOMMA) {
2402 /* opl15: / single operand */
2418 /* jsr pc,p0readop */
2422 if (token != TCOMMA) {
2442 /* opl11: /branch */
2452 /* opl16: / .byte */
2457 /* jsr pc,p0readop */
2466 if (token != TCOMMA)
2472 #if 1 /* modifications for dec syntax */
2473 void p0opldotword() {
2477 if (token != TCOMMA)
2484 /* opl17: / < (.ascii) */
2485 /* add numval,dot */
2486 /* jsr pc,p0readop */
2490 pdot->value += numval;
2500 pdot->value = (pdot->value + 1) & ~1;
2527 /* opl23: /.globl */
2531 /* jsr pc,p0readop */
2534 /* jsr pc,p0readop */
2540 struct symbol *psymbol;
2543 if (token >= 0 && token < TASCII)
2545 psymbol = (struct symbol *)token;
2546 psymbol->flags |= FGLOBAL;
2548 if (token != TCOMMA)
2559 /* mov dot,savdot-4(r1) */
2560 /* mov savdot-[2*25](r0),dot */
2567 savdot[pdot->flags - FTEXT] = pdot->value;
2568 pdot->value = savdot[0];
2569 pdot->flags = FTEXT;
2573 savdot[pdot->flags - FTEXT] = pdot->value;
2574 pdot->value = savdot[1];
2575 pdot->flags = FDATA;
2579 savdot[pdot->flags - FTEXT] = pdot->value;
2580 pdot->value = savdot[2];
2584 /* opl32: / .common */
2588 /* jsr pc,p0readop */
2591 /* jsr pc,p0readop */
2600 struct symbol *psymbol;
2602 if (token >= 0 && token < TASCII) {
2606 psymbol = (struct symbol *)token;
2607 psymbol->flags |= FGLOBAL;
2609 if (token != TCOMMA) {
2628 /* printf("p0addres() token = 0x%08x\n", token); */
2653 /* jsr pc,p0readop */
2655 /* jsr pc,checkreg */
2656 /* jsr pc,checkrp */
2662 /* cmp r3,$24 / register type */
2664 /* jsr pc,checkreg */
2670 if (token == TLPAREN) {
2677 else if (leftflags == FREGISTER)
2685 /* jsr pc,p0readop */
2687 /* jsr pc,checkrp */
2688 /* jsr pc,checkreg */
2691 /* jsr pc,p0readop */
2703 if (token == TPLUS) {
2712 /* jsr pc,p0readop */
2719 /* jsr pc,p0readop */
2721 /* jsr pc,checkrp */
2722 /* jsr pc,checkreg */
2728 xstartpsave = xstartp;
2732 if (token != TLPAREN) {
2735 xsavestartn = xstartp - xbufpsave;
2736 xsavebufn = xbufp - xbufpsave;
2737 memcpy(xsave, xbufpsave, xsavebufn);
2741 xstartp = xstartpsave;
2756 /* jsr pc,p0readop */
2770 /* jsr pc,p0readop */
2785 pdot->value += indirect;
2810 if (leftvalue > 7 || (leftflags != FABS && leftflags <= FBSS))
2830 /* jsr pc,p0readop */
2834 if (token != TRPAREN)
2849 struct symbol *psymbol;
2851 /* printf("p0expres()\n"); */
2859 /* jsr pc,p0readop */
2876 if (token < 0 || token >= TASCII) {
2877 psymbol = (struct symbol *)token;
2878 rightflags = psymbol->flags;
2879 rightvalue = psymbol->value;
2886 /* cmp r4,$141+10. */
2888 /* movb curfbr-141(r4),r0 */
2890 /* mov curfb-[2*141](r4),r2 */
2902 if (token >= TLABEL) {
2903 if (token < TLABEL + 10) {
2905 if (xstartp >= xbuf + 0xff0)
2907 // for asxlat, -u means local labels will be changed to ordinary labels
2908 // (use this when there is an inconvenient ordinary label within locals)
2909 if (defund == FGLOBAL)
2910 xbufp = xstartp + sprintf(xstartp, "_%d", xlabb[token - TLABEL]);
2912 xbufp = xstartp + sprintf(xstartp, "%d$", xlabb[token - TLABEL]);
2914 rightflags = curfbr[token - TLABEL];
2915 /* bug!! should be rightvalue / rightflags below: */
2916 leftvalue = curfb[token - TLABEL];
2917 if (leftvalue == -1)
2922 xlab = token - (TLABEL + 10);
2924 if (xlabf[xlab] == -1)
2925 xlabf[xlab] = xlabnext++;
2926 if (xstartp >= xbuf + 0xff0)
2928 // for asxlat, -u means local labels will be changed to ordinary labels
2929 // (use this when there is an inconvenient ordinary label within locals)
2930 if (defund == FGLOBAL)
2931 xbufp = xstartp + sprintf(xstartp, "_%d", xlabf[xlab]);
2933 xbufp = xstartp + sprintf(xstartp, "%d$", xlabf[xlab]);
3032 if (optoken != TPLUS)
3043 /* printf("p0exnum() numval = 0%o\n", numval); */
3044 rightvalue = numval;
3052 /* jsr pc,p0readop */
3069 tempvalue = leftvalue;
3070 tempflags = leftflags;
3071 temptoken = optoken;
3074 if (token != TRBRACK)
3076 rightflags = leftflags;
3077 rightvalue = leftvalue;
3078 leftflags = tempflags;
3079 leftvalue = tempvalue;
3080 optoken = temptoken;
3088 /* cmp (sp),(r5)+ */
3178 /* mov r0,r3 / give left flag of right */
3182 leftflags = rightflags;
3200 leftvalue = ((unsigned int)leftvalue & 0177777) >> rightvalue;
3206 leftvalue <<= rightvalue;
3224 temp = rightvalue & 0177777;
3226 leftvalue = (leftvalue & 0177777) % temp;
3228 error('0'); /* a nick innovation */
3242 leftvalue += rightvalue;
3254 leftvalue -= rightvalue;
3267 leftvalue &= rightvalue;
3279 leftvalue |= rightvalue;
3292 leftvalue *= rightvalue;
3310 temp = rightvalue & 0177777;
3312 leftvalue = (leftvalue & 0177777) / temp;
3314 error('0'); /* a nick innovation */
3329 leftvalue += ~rightvalue;
3354 void p0combin(minflag) int minflag; {
3358 global = (rightflags | leftflags) & FGLOBAL;
3361 if (rightflags > leftflags) {
3363 rightflags = leftflags;
3382 if (minflag && rightflags == leftflags)
3388 leftflags |= global;
3393 /* .byte -14,-14,-14,-14,-02,-14,-14,-14 */
3394 /* .byte -14,-22, -2,-14,-14,-22,-14,-14 */
3395 /* .byte -14,-14,-14,-14,-14,-14,-14,-14 */
3396 /* .byte -14,-14,-14,-14,-14,-14,-14,-14 */
3397 /* .byte -22,-20,-16,-14,-20,-20,-20,-12 */
3398 /* .byte -20,-20,-20,-20,-20,-20,056,-06 */
3399 /* .byte 060,061,062,063,064,065,066,067 */
3400 /* .byte 070,071,-20,-02,-00,-20,-14,-14 */
3401 /* .byte -14,101,102,103,104,105,106,107 */
3402 /* .byte 110,111,112,113,114,115,116,117 */
3403 /* .byte 120,121,122,123,124,125,126,127 */
3404 /* .byte 130,131,132,-20,-24,-20,-20,137 */
3405 /* .byte -14,141,142,143,144,145,146,147 */
3406 /* .byte 150,151,152,153,154,155,156,157 */
3407 /* .byte 160,161,162,163,164,165,166,167 */
3408 /* .byte 170,171,172,-14,-26,-14,176,-14 */
3410 char chartab[TASCII] = {
3411 -014,-014,-014,-014,-002,-014,-014,-014,
3412 -014,-022,0 -2,-014,-014,-022,-014,-014,
3413 -014,-014,-014,-014,-014,-014,-014,-014,
3414 -014,-014,-014,-014,-014,-014,-014,-014,
3415 #if 1 /* modifications for dec syntax */
3416 -022,-020,-016,-026,-020,-020,-020,-012,
3418 -022,-020,-016,-014,-020,-020,-020,-012,
3420 -020,-020,-020,-020,-020,-020,0056,-006,
3421 0060,0061,0062,0063,0064,0065,0066,0067,
3422 0070,0071,-020,-002,-000,-020,-014,-014,
3423 #if 1 /* modifications for dec syntax */
3424 -026,0101,0102,0103,0104,0105,0106,0107,
3426 -014,0101,0102,0103,0104,0105,0106,0107,
3428 0110,0111,0112,0113,0114,0115,0116,0117,
3429 0120,0121,0122,0123,0124,0125,0126,0127,
3430 0130,0131,0132,-020,-024,-020,-020,0137,
3431 -014,0141,0142,0143,0144,0145,0146,0147,
3432 0150,0151,0152,0153,0154,0155,0156,0157,
3433 0160,0161,0162,0163,0164,0165,0166,0167,
3434 0170,0171,0172,-014,-026,-014,0176,-014
3437 /* a.tmp1: </tmp/atm1XX\0> */
3440 char a_tmp1[] = "/tmp/atm1XX";
3442 char a_tmp1[] = "/tmp/atm1XXXXXX"; /* linux requires 6 X's */
3445 /* Ncps: .byte 8. */
3463 /* The next two _must_ be adjacent! Not sure why, but then this whole */
3464 /* assembler is weird beyond belief. */
3465 /* curfb: -1;-1;-1;-1;-1;-1;-1;-1;-1;-1 */
3467 /* THEY HAD TO BE ADJACENT BECAUSE PASS 2 p0expres() READS curfb[token - 0141] */
3468 /* THIS HAS BEEN SPLIT INTO curfb[token - 0141], nxtfb[token - (0141 + 10)] */
3469 /* BY THE WAY, THE ASSEMBLER IS NOT REALLY WEIRD, IT'S KIND OF ELEGANT !!! */
3470 intptr_t curfb[10] = {
3471 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
3474 /* nxtfb: .=.+20. / first 4 used by pass0, all 20. by pass1+2 */
3476 /* FIRST 4 AREN'T USED BY PASS 0 ANYMORE, IT WAS ONLY TEMPORARY SCRATCH !!!! */
3480 /* curfbr: .=.+10. */
3488 /* hshtab: .=.+2 / dynamically allocated */
3490 struct symbol **hshtab;
3496 /* symnum: .=.+2 / symbol number */
3500 /* symbol: .=.+32. / XXX */
3501 /* .=.+2 / paranoia to make sure a null is present */
3505 /* inbuf: .=.+1024. */
3547 struct symbol *fbptr;
3551 struct symbol *fbtbl;
3553 /* usymtab:.=.+2 / ptr to first block of symbols */
3555 struct symblk *usymtab;
3557 /* symleft:.=.+2 / bytes left in current symbol block */
3561 /* symend: .=.+2 / ptr to next symbol space in block */
3563 struct symbol *symend;
3565 /* symblk: .=.+2 / ptr to beginning of current sym block */
3567 struct symblk *symblk;
3569 /* strleft:.=.+2 / amount left in string block */
3573 /* strend: .=.+2 / ptr to next available string byte */
3577 /* strblk: .=.+2 / ptr to current string block link word */
3579 struct strblk *strblk;
3584 /* 1 absolute (nop, reset, bpt, ...) */
3588 /* 5 flop freg,dst (movfo, = stcfd) */
3593 /* 12 movf (=ldf,stf) */
3594 /* 13 double operand (mov) */
3595 /* 14 flop fsrc,freg (addf) */
3596 /* 15 single operand (clr) */
3598 /* 17 string (.ascii, "<") */
3607 /* 30 mul,div, etc */
3610 /* 33 estimated text */
3611 /* 34 estimated data */
3613 /* 36 jeq, jne, etc */
3616 /* the format of PST entries was changed. rather than fixed 8 byte strings */
3617 /* (often with many trailing nulls) a pointer to a null terminated string */
3618 /* is now used. This saves quite a bit of space since most PST entries are */
3619 /* only 3 or 4 characters long. we had to do this the hard way since there */
3620 /* is no macro capability in the assembler and i'd chuck out the SDI [Span */
3621 /* Dependent Instruction] stuff and use my own assembler before trying to */
3622 /* add macros to this one. Symbols beginning with 'L' are used since the */
3623 /* linker can be told to discard those. */
3626 /* special symbols */
3628 /* L1; dotrel: 02; dot: 0000000 */
3629 /* L2; 01; dotdot: 0000000 */
3633 /* L3; 24; 000000 */
3634 /* L4; 24; 000001 */
3635 /* L5; 24; 000002 */
3636 /* L6; 24; 000003 */
3637 /* L7; 24; 000004 */
3638 /* L8; 24; 000005 */
3639 /* L9; 24; 000006 */
3640 /* L10; 24; 000007 */
3642 /* double operand */
3644 /* L11; 13; 0010000 */
3645 /* L12; 13; 0110000 */
3646 /* L13; 13; 0020000 */
3647 /* L14; 13; 0120000 */
3648 /* L15; 13; 0030000 */
3649 /* L16; 13; 0130000 */
3650 /* L17; 13; 0040000 */
3651 /* L18; 13; 0140000 */
3652 /* L19; 13; 0050000 */
3653 /* L20; 13; 0150000 */
3654 /* L21; 13; 0060000 */
3655 /* L22; 13; 0160000 */
3659 /* L23; 06; 0000400 */
3660 /* L24; 06; 0001000 */
3661 /* L25; 06; 0001400 */
3662 /* L26; 06; 0002000 */
3663 /* L27; 06; 0002400 */
3664 /* L28; 06; 0003000 */
3665 /* L29; 06; 0003400 */
3666 /* L30; 06; 0100000 */
3667 /* L31; 06; 0100400 */
3668 /* L32; 06; 0101000 */
3669 /* L33; 06; 0101400 */
3670 /* L34; 06; 0102000 */
3671 /* L35; 06; 0102400 */
3672 /* L36; 06; 0103000 */
3673 /* L37; 06; 0103000 */
3674 /* L38; 06; 0103000 */
3675 /* L39; 06; 0103400 */
3676 /* L40; 06; 0103400 */
3677 /* L41; 06; 0103400 */
3679 /* jump/branch type */
3681 /* L42; 35; 0000400 */
3682 /* L43; 36; 0001000 */
3683 /* L44; 36; 0001400 */
3684 /* L45; 36; 0002000 */
3685 /* L46; 36; 0002400 */
3686 /* L47; 36; 0003000 */
3687 /* L48; 36; 0003400 */
3688 /* L49; 36; 0100000 */
3689 /* L50; 36; 0100400 */
3690 /* L51; 36; 0101000 */
3691 /* L52; 36; 0101400 */
3692 /* L53; 36; 0102000 */
3693 /* L54; 36; 0102400 */
3694 /* L55; 36; 0103000 */
3695 /* L56; 36; 0103000 */
3696 /* L57; 36; 0103000 */
3697 /* L58; 36; 0103400 */
3698 /* L59; 36; 0103400 */
3699 /* L60; 36; 0103400 */
3701 /* single operand */
3703 /* L61; 15; 0005000 */
3704 /* L62; 15; 0105000 */
3705 /* L63; 15; 0005100 */
3706 /* L64; 15; 0105100 */
3707 /* L65; 15; 0005200 */
3708 /* L66; 15; 0105200 */
3709 /* L67; 15; 0005300 */
3710 /* L68; 15; 0105300 */
3711 /* L69; 15; 0005400 */
3712 /* L70; 15; 0105400 */
3713 /* L71; 15; 0005500 */
3714 /* L72; 15; 0105500 */
3715 /* L73; 15; 0005600 */
3716 /* L74; 15; 0105600 */
3717 /* L75; 15; 0005700 */
3718 /* L76; 15; 0105700 */
3719 /* L77; 15; 0006000 */
3720 /* L78; 15; 0106000 */
3721 /* L79; 15; 0006100 */
3722 /* L80; 15; 0106100 */
3723 /* L81; 15; 0006200 */
3724 /* L82; 15; 0106200 */
3725 /* L83; 15; 0006300 */
3726 /* L84; 15; 0106300 */
3727 /* L85; 15; 0000100 */
3728 /* L86; 15; 0000300 */
3729 /* L87; 15; 0006500 */
3730 /* L88; 15; 0006600 */
3731 /* L89; 15; 0106500 */
3732 /* L90; 15; 0106600 */
3733 /* L91; 15; 0170300 */
3734 /* L92; 15; 0106700 */
3735 /* L93; 15; 0106400 */
3736 /* L94; 15; 0007000 */
3737 /* L95; 15; 0007200 */
3738 /* L96; 15; 0007300 */
3742 /* L97; 07; 0004000 */
3746 /* L98; 010; 000200 */
3748 /* simple operand */
3750 /* L99; 011; 104400 */
3751 /* L102; 011; 000230 */
3755 /* L103; 01; 0000240 */
3756 /* L104; 01; 0000241 */
3757 /* L105; 01; 0000242 */
3758 /* L106; 01; 0000244 */
3759 /* L107; 01; 0000250 */
3760 /* L108; 01; 0000257 */
3761 /* L109; 01; 0000261 */
3762 /* L110; 01; 0000262 */
3763 /* L111; 01; 0000264 */
3764 /* L112; 01; 0000270 */
3765 /* L113; 01; 0000277 */
3766 /* L114; 01; 0000000 */
3767 /* L115; 01; 0000001 */
3768 /* L116; 01; 0000002 */
3769 /* L117; 01; 0000003 */
3770 /* L118; 01; 0000004 */
3771 /* L119; 01; 0000005 */
3772 /* L120; 01; 0000006 */
3773 /* L121; 01; 0000007 */
3775 /* floating point ops */
3777 /* L122; 01; 170000 */
3778 /* L123; 01; 170001 */
3779 /* L124; 01; 170011 */
3780 /* L125; 01; 170002 */
3781 /* L126; 01; 170012 */
3782 /* L127; 15; 170400 */
3783 /* L128; 15; 170700 */
3784 /* L129; 15; 170600 */
3785 /* L130; 15; 170500 */
3786 /* L131; 12; 172400 */
3787 /* L132; 14; 177000 */
3788 /* L133; 05; 175400 */
3789 /* L134; 14; 177400 */
3790 /* L135; 05; 176000 */
3791 /* L136; 14; 172000 */
3792 /* L137; 14; 173000 */
3793 /* L138; 14; 171000 */
3794 /* L139; 14; 174400 */
3795 /* L140; 14; 173400 */
3796 /* L141; 14; 171400 */
3797 /* L142; 14; 176400 */
3798 /* L143; 05; 175000 */
3799 /* L144; 15; 170100 */
3800 /* L145; 15; 170200 */
3801 /* L146; 24; 000000 */
3802 /* L147; 24; 000001 */
3803 /* L148; 24; 000002 */
3804 /* L149; 24; 000003 */
3805 /* L150; 24; 000004 */
3806 /* L151; 24; 000005 */
3808 /* L152; 30; 070000 */
3809 /* L153; 30; 071000 */
3810 /* L154; 30; 072000 */
3811 /* L155; 30; 073000 */
3812 /* L156; 07; 074000 */
3813 /* L157; 15; 006700 */
3814 /* L158; 11; 006400 */
3815 /* L159; 31; 077000 */
3819 /* L160; 16; 000000 */
3820 /* L161; 20; 000000 */
3821 /* L162; 21; 000000 */
3822 /* L163; 22; 000000 */
3823 /* L164; 23; 000000 */
3824 /* L165; 25; 000000 */
3825 /* L166; 26; 000000 */
3826 /* L167; 27; 000000 */
3827 /* L168; 32; 000000 */
3925 /* L95: <tstset\0> */
3926 /* L96: <wrtlck\0> */
3942 /* L114: <halt\0> */
3943 /* L115: <wait\0> */
3947 /* L119: <reset\0> */
3949 /* L121: <mfpt\0> */
3950 /* L122: <cfcc\0> */
3951 /* L123: <setf\0> */
3952 /* L124: <setd\0> */
3953 /* L125: <seti\0> */
3954 /* L126: <setl\0> */
3955 /* L127: <clrf\0> */
3956 /* L128: <negf\0> */
3957 /* L129: <absf\0> */
3958 /* L130: <tstf\0> */
3959 /* L131: <movf\0> */
3960 /* L132: <movif\0> */
3961 /* L133: <movfi\0> */
3962 /* L134: <movof\0> */
3963 /* L135: <movfo\0> */
3964 /* L136: <addf\0> */
3965 /* L137: <subf\0> */
3966 /* L138: <mulf\0> */
3967 /* L139: <divf\0> */
3968 /* L140: <cmpf\0> */
3969 /* L141: <modf\0> */
3970 /* L142: <movie\0> */
3971 /* L143: <movei\0> */
3972 /* L144: <ldfps\0> */
3973 /* L145: <stfps\0> */
3983 /* L155: <ashc\0> */
3986 /* L158: <mark\0> */
3988 /* L160: <.byte\0> */
3989 /* L161: <.even\0> */
3991 /* L163: <.endif\0> */
3992 /* L164: <.globl\0> */
3993 /* L165: <.text\0> */
3994 /* L166: <.data\0> */
3995 /* L167: <.bss\0> */
3996 /* L168: <.comm\0> */
3999 struct symbol symtab[] = {
4000 { ".", FTEXT, 0000000, 0 },
4001 { "..", FABS, 0000000, 0 },
4005 { "r0", FREGISTER, 0000000, 0 },
4006 { "r1", FREGISTER, 0000001, 0 },
4007 { "r2", FREGISTER, 0000002, 0 },
4008 { "r3", FREGISTER, 0000003, 0 },
4009 { "r4", FREGISTER, 0000004, 0 },
4010 { "r5", FREGISTER, 0000005, 0 },
4011 { "sp", FREGISTER, 0000006, 0 },
4012 { "pc", FREGISTER, 0000007, 0 },
4014 /* double operand */
4016 { "mov", FDOUBLE, 0010000, 0 },
4017 { "movb", FDOUBLE, 0110000, 0 },
4018 { "cmp", FDOUBLE, 0020000, 0 },
4019 { "cmpb", FDOUBLE, 0120000, 0 },
4020 { "bit", FDOUBLE, 0030000, 0 },
4021 { "bitb", FDOUBLE, 0130000, 0 },
4022 { "bic", FDOUBLE, 0040000, 0 },
4023 { "bicb", FDOUBLE, 0140000, 0 },
4024 { "bis", FDOUBLE, 0050000, 0 },
4025 { "bisb", FDOUBLE, 0150000, 0 },
4026 { "add", FDOUBLE, 0060000, 0 },
4027 { "sub", FDOUBLE, 0160000, 0 },
4031 { "br", FBRANCH, 0000400, 0 },
4032 { "bne", FBRANCH, 0001000, 0 },
4033 { "beq", FBRANCH, 0001400, 0 },
4034 { "bge", FBRANCH, 0002000, 0 },
4035 { "blt", FBRANCH, 0002400, 0 },
4036 { "bgt", FBRANCH, 0003000, 0 },
4037 { "ble", FBRANCH, 0003400, 0 },
4038 { "bpl", FBRANCH, 0100000, 0 },
4039 { "bmi", FBRANCH, 0100400, 0 },
4040 { "bhi", FBRANCH, 0101000, 0 },
4041 { "blos", FBRANCH, 0101400, 0 },
4042 { "bvc", FBRANCH, 0102000, 0 },
4043 { "bvs", FBRANCH, 0102400, 0 },
4044 { "bhis", FBRANCH, 0103000, 0 },
4045 { "bec", FBRANCH, 0103000, 0 },
4046 { "bcc", FBRANCH, 0103000, 0 },
4047 { "blo", FBRANCH, 0103400, 0 },
4048 { "bcs", FBRANCH, 0103400, 0 },
4049 { "bes", FBRANCH, 0103400, 0 },
4051 /* jump/branch type */
4053 { "jbr", FJBR, 0000400, 0 },
4054 { "jne", FJCOND, 0001000, 0 },
4055 { "jeq", FJCOND, 0001400, 0 },
4056 { "jge", FJCOND, 0002000, 0 },
4057 { "jlt", FJCOND, 0002400, 0 },
4058 { "jgt", FJCOND, 0003000, 0 },
4059 { "jle", FJCOND, 0003400, 0 },
4060 { "jpl", FJCOND, 0100000, 0 },
4061 { "jmi", FJCOND, 0100400, 0 },
4062 { "jhi", FJCOND, 0101000, 0 },
4063 { "jlos", FJCOND, 0101400, 0 },
4064 { "jvc", FJCOND, 0102000, 0 },
4065 { "jvs", FJCOND, 0102400, 0 },
4066 { "jhis", FJCOND, 0103000, 0 },
4067 { "jec", FJCOND, 0103000, 0 },
4068 { "jcc", FJCOND, 0103000, 0 },
4069 { "jlo", FJCOND, 0103400, 0 },
4070 { "jcs", FJCOND, 0103400, 0 },
4071 { "jes", FJCOND, 0103400, 0 },
4073 /* single operand */
4075 { "clr", FSINGLE, 0005000, 0 },
4076 { "clrb", FSINGLE, 0105000, 0 },
4077 { "com", FSINGLE, 0005100, 0 },
4078 { "comb", FSINGLE, 0105100, 0 },
4079 { "inc", FSINGLE, 0005200, 0 },
4080 { "incb", FSINGLE, 0105200, 0 },
4081 { "dec", FSINGLE, 0005300, 0 },
4082 { "decb", FSINGLE, 0105300, 0 },
4083 { "neg", FSINGLE, 0005400, 0 },
4084 { "negb", FSINGLE, 0105400, 0 },
4085 { "adc", FSINGLE, 0005500, 0 },
4086 { "adcb", FSINGLE, 0105500, 0 },
4087 { "sbc", FSINGLE, 0005600, 0 },
4088 { "sbcb", FSINGLE, 0105600, 0 },
4089 { "tst", FSINGLE, 0005700, 0 },
4090 { "tstb", FSINGLE, 0105700, 0 },
4091 { "ror", FSINGLE, 0006000, 0 },
4092 { "rorb", FSINGLE, 0106000, 0 },
4093 { "rol", FSINGLE, 0006100, 0 },
4094 { "rolb", FSINGLE, 0106100, 0 },
4095 { "asr", FSINGLE, 0006200, 0 },
4096 { "asrb", FSINGLE, 0106200, 0 },
4097 { "asl", FSINGLE, 0006300, 0 },
4098 { "aslb", FSINGLE, 0106300, 0 },
4099 { "jmp", FSINGLE, 0000100, 0 },
4100 { "swab", FSINGLE, 0000300, 0 },
4101 { "mfpi", FSINGLE, 0006500, 0 },
4102 { "mtpi", FSINGLE, 0006600, 0 },
4103 { "mfpd", FSINGLE, 0106500, 0 },
4104 { "mtpd", FSINGLE, 0106600, 0 },
4105 { "stst", FSINGLE, 0170300, 0 },
4106 { "mfps", FSINGLE, 0106700, 0 },
4107 { "mtps", FSINGLE, 0106400, 0 },
4108 { "csm", FSINGLE, 0007000, 0 },
4109 { "tstset", FSINGLE, 0007200, 0 },
4110 { "wrtlck", FSINGLE, 0007300, 0 },
4114 { "jsr", FJSR, 0004000, 0 },
4118 { "rts", FRTS, 0000200, 0 },
4120 /* simple operand */
4122 { "sys", FSYSTRAP, 0104400, 0 },
4123 { "spl", FSYSTRAP, 0000230, 0 },
4127 { "nop", FABS, 0000240, 0 },
4128 { "clc", FABS, 0000241, 0 },
4129 { "clv", FABS, 0000242, 0 },
4130 { "clz", FABS, 0000244, 0 },
4131 { "cln", FABS, 0000250, 0 },
4132 { "ccc", FABS, 0000257, 0 },
4133 { "sec", FABS, 0000261, 0 },
4134 { "sev", FABS, 0000262, 0 },
4135 { "sez", FABS, 0000264, 0 },
4136 { "sen", FABS, 0000270, 0 },
4137 { "scc", FABS, 0000277, 0 },
4138 { "halt", FABS, 0000000, 0 },
4139 { "wait", FABS, 0000001, 0 },
4140 { "rti", FABS, 0000002, 0 },
4141 { "bpt", FABS, 0000003, 0 },
4142 { "iot", FABS, 0000004, 0 },
4143 { "reset", FABS, 0000005, 0 },
4144 { "rtt", FABS, 0000006, 0 },
4145 { "mfpt", FABS, 0000007, 0 },
4147 /* floating point ops */
4149 { "cfcc", FABS, 0170000, 0 },
4150 { "setf", FABS, 0170001, 0 },
4151 { "setd", FABS, 0170011, 0 },
4152 { "seti", FABS, 0170002, 0 },
4153 { "setl", FABS, 0170012, 0 },
4154 { "clrf", FSINGLE, 0170400, 0 },
4155 { "negf", FSINGLE, 0170700, 0 },
4156 { "absf", FSINGLE, 0170600, 0 },
4157 { "tstf", FSINGLE, 0170500, 0 },
4158 { "movf", FMOVF, 0172400, 0 },
4159 { "movif", FFLOP, 0177000, 0 },
4160 { "movfi", FMOVFO, 0175400, 0 },
4161 { "movof", FFLOP, 0177400, 0 },
4162 { "movfo", FMOVFO, 0176000, 0 },
4163 { "addf", FFLOP, 0172000, 0 },
4164 { "subf", FFLOP, 0173000, 0 },
4165 { "mulf", FFLOP, 0171000, 0 },
4166 { "divf", FFLOP, 0174400, 0 },
4167 { "cmpf", FFLOP, 0173400, 0 },
4168 { "modf", FFLOP, 0171400, 0 },
4169 { "movie", FFLOP, 0176400, 0 },
4170 { "movei", FMOVFO, 0175000, 0 },
4171 { "ldfps", FSINGLE, 0170100, 0 },
4172 { "stfps", FSINGLE, 0170200, 0 },
4173 { "fr0", FREGISTER, 0000000, 0 },
4174 { "fr1", FREGISTER, 0000001, 0 },
4175 { "fr2", FREGISTER, 0000002, 0 },
4176 { "fr3", FREGISTER, 0000003, 0 },
4177 { "fr4", FREGISTER, 0000004, 0 },
4178 { "fr5", FREGISTER, 0000005, 0 },
4180 { "mul", FMULDIV, 0070000, 0 },
4181 { "div", FMULDIV, 0071000, 0 },
4182 { "ash", FMULDIV, 0072000, 0 },
4183 { "ashc", FMULDIV, 0073000, 0 },
4184 { "xor", FJSR, 0074000, 0 },
4185 { "sxt", FSINGLE, 0006700, 0 },
4186 { "mark", FSYSTRAP, 0006400, 0 },
4187 { "sob", FSOB, 0077000, 0 },
4191 { ".byte", FDOTBYTE, 0000000, 0 },
4192 #if 1 /* modifications for dec syntax */
4193 { ".word", FDOTWORD, 0000000, 0 },
4195 { ".even", FDOTEVEN, 0000000, 0 },
4196 { ".if", FDOTIF, 0000000, 0 },
4197 { ".endif", FDOTENDIF, 0000000, 0 },
4198 { ".globl", FDOTGLOBL, 0000000, 0 },
4199 { ".text", FDOTTEXT, 0000000, 0 },
4200 { ".data", FDOTDATA, 0000000, 0 },
4201 { ".bss", FDOTBSS, 0000000, 0 },
4202 { ".comm", FDOTCOMM, 0000000, 0 }
4205 int ebsymtab = sizeof(symtab) / sizeof(struct symbol);