summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
93d846d)
names are in core and on the file; strings are just in the file. The file
is maintained as a string table per a.out(5), and tacked onto the a.out file
at the very end. The string table has more than need be, since discarde
labels and .ascii strings find their way (harmlessly) into the string table.
the string file maintained with stdio; nothing fancy, even if -V set
SCCS-vsn: old/as.vax/instrs 4.9
SCCS-vsn: old/as.vax/ascode.c 4.10
SCCS-vsn: old/as.vax/asjxxx.c 4.7
SCCS-vsn: old/as.vax/asmain.c 4.11
SCCS-vsn: old/as.vax/asparse.c 4.14
SCCS-vsn: old/as.vax/aspseudo.c 4.5
SCCS-vsn: old/as.vax/assyms.c 4.11
SCCS-vsn: old/as.vax/asscan1.c 4.5
SCCS-vsn: old/as.vax/as.h 4.15
SCCS-vsn: old/as.vax/asscan2.c 4.10
SCCS-vsn: old/as.vax/asscan.h 4.9
/*
* Copyright (c) 1982 Regents of the University of California
/*
* Copyright (c) 1982 Regents of the University of California
*/
#ifdef VMS
# define vax 1
*/
#ifdef VMS
# define vax 1
* with the old naming conventions.
*/
#ifdef FLEXNAMES
* with the old naming conventions.
*/
#ifdef FLEXNAMES
-#define s_name s_nm.n_un.n_name /* name pointer */
+#define s_name s_nm.n_un.n_name
+#define i_name s_name
+#define FETCHNAME(sp) (((struct strdesc *)(sp)->s_name)->sd_string)
+#define STRLEN(sp) (((struct strdesc *)(sp)->s_name)->sd_strlen)
+#define STROFF(sp) (((struct strdesc *)(sp)->s_name)->sd_stroff)
#define s_nmx s_nm.n_un.n_strx /* string table index */
#else not FLEXNAMES
#define s_name s_nm.n_name
#define s_nmx s_nm.n_un.n_strx /* string table index */
#else not FLEXNAMES
#define s_name s_nm.n_name
+#define i_name s_name
+#define FETCHNAME(sp) ((sp)->s_name)
#endif
#define s_type s_nm.n_type /* type of the symbol */
#define s_other s_nm.n_other /* other information for sdb */
#endif
#define s_type s_nm.n_type /* type of the symbol */
#define s_other s_nm.n_other /* other information for sdb */
#define ISUBYTE(x) (((x) >= MINUBYTE) && ((x) <= MAXUBYTE))
#define ISWORD(x) (((x) >= MINWORD) && ((x) <= MAXWORD))
#define ISUWORD(x) (((x) >= MINUWORD) && ((x) <= MAXUWORD))
#define ISUBYTE(x) (((x) >= MINUBYTE) && ((x) <= MAXUBYTE))
#define ISWORD(x) (((x) >= MINWORD) && ((x) <= MAXWORD))
#define ISUWORD(x) (((x) >= MINUWORD) && ((x) <= MAXUWORD))
+/*
+ * Definitions for strings.
+ *
+ * Strings are stored in the string pool; see strsave(str, length)
+ * Strings are known by their length and values.
+ * A string pointer points to the beginning of the value bytes;
+ *
+ * If this structure is changed, change insts also.
+ */
+struct strdesc{
+ int sd_stroff; /* offset into string file */
+ short sd_place; /* where string is */
+ u_short sd_strlen; /* string length */
+ char sd_string[1]; /* the string itself, flexible length */
+};
+/*
+ * Where a string can be. If these are changed, also change instrs.
+ */
+#define STR_FILE 0x1
+#define STR_CORE 0x2
+#define STR_BOTH 0x3
+struct strdesc *savestr();
+\f
+/*
+ * Global variables
+ */
extern struct arg arglist[NARG]; /*building operands in instructions*/
extern struct exp explist[NEXP]; /*building up a list of expressions*/
extern struct exp *xp; /*current free expression*/
extern struct arg arglist[NARG]; /*building operands in instructions*/
extern struct exp explist[NEXP]; /*building up a list of expressions*/
extern struct exp *xp; /*current free expression*/
extern int lgensym[10];
extern char genref[10];
extern int lgensym[10];
extern char genref[10];
- extern char tmpn1[TNAMESIZE]; /* Interpass temporary */
extern struct exp *dotp; /* the current dot location */
extern int loctr;
extern struct exp *dotp; /* the current dot location */
extern int loctr;
extern int lineno; /*the line number*/
extern char *dotsname; /*the name of the as source*/
extern int lineno; /*the line number*/
extern char *dotsname; /*the name of the as source*/
- extern FILE *tmpfil; /* interpass communication*/
+ extern FILE *tokfile; /* temp token communication*/
+ extern FILE *strfile; /* temp string file*/
+ extern char tokfilename[TNAMESIZE]; /* token file name */
+ extern char strfilename[TNAMESIZE]; /* string file name */
+ extern int strfilepos; /* position in string file */
extern int passno; /* 1 or 2 */
extern int passno; /* 1 or 2 */
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)ascode.c 4.9 %G%";
+static char sccsid[] = "@(#)ascode.c 4.10 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
xp->e_xvalue - (dotp->e_xvalue + 1);
if (xp->e_xtype & XXTRN)
yywarning("%s: destination label is external",
xp->e_xvalue - (dotp->e_xvalue + 1);
if (xp->e_xtype & XXTRN)
yywarning("%s: destination label is external",
- ITABFETCH(opcode)->s_name);
+ FETCHNAME(ITABFETCH(opcode)));
if (!ISBYTE(argtype))
yyerror("%s: Branch too far(%db): try -J flag",
if (!ISBYTE(argtype))
yyerror("%s: Branch too far(%db): try -J flag",
- ITABFETCH(opcode)->s_name,
+ FETCHNAME(ITABFETCH(opcode)),
-= dotp->e_xvalue + 2;
if (xp->e_xtype & XXTRN)
yywarning("%s: destination label is external",
-= dotp->e_xvalue + 2;
if (xp->e_xtype & XXTRN)
yywarning("%s: destination label is external",
- ITABFETCH(opcode)->s_name);
+ FETCHNAME(ITABFETCH(opcode)));
xp->e_xtype = XABS;
if (!ISWORD(argtype))
yyerror("%s: Branch too far(%db): try -J flag",
xp->e_xtype = XABS;
if (!ISWORD(argtype))
yyerror("%s: Branch too far(%db): try -J flag",
- ITABFETCH(opcode)->s_name,
+ FETCHNAME(ITABFETCH(opcode)),
argtype);
xp->e_xvalue = argtype>>8;
reloc_how = TYPB;
argtype);
xp->e_xvalue = argtype>>8;
reloc_how = TYPB;
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)asjxxx.c 4.6 %G%";
+static char sccsid[] = "@(#)asjxxx.c 4.7 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
#ifdef DEBUG
if(debug)
printf("Tunnel from %s from line %d\n",
#ifdef DEBUG
if(debug)
printf("Tunnel from %s from line %d\n",
- jumpfrom->s_name, lineno);
+ FETCHNAME(jumpfrom),
+ lineno);
#endif
continue;
} else { /*tunneling not possible*/
#endif
continue;
} else { /*tunneling not possible*/
if (debug){
if (sp->s_dest != 0)
printf("Explode jump to %s on line %d\n",
if (debug){
if (sp->s_dest != 0)
printf("Explode jump to %s on line %d\n",
- sp->s_dest->s_name, lineno);
+ FETCHNAME(sp->s_dest), lineno);
else
printf("Explode an align!\n");
}
else
printf("Explode an align!\n");
}
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)asmain.c 4.10 %G%";
+static char sccsid[] = "@(#)asmain.c 4.11 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
#include "asexpr.h"
#ifdef UNIX
#include "asexpr.h"
#ifdef UNIX
-#define unix_lang_name "VAX/UNIX Assembler V%G% 4.10"
+#define unix_lang_name "VAX/UNIX Assembler V%G% 4.11"
struct exp usedot[NLOC+NLOC]; /* info about all segments */
struct exp *dotp; /* data/text location pointer */
/*
struct exp usedot[NLOC+NLOC]; /* info about all segments */
struct exp *dotp; /* data/text location pointer */
/*
- * The inter pass temporary file is opened and closed by stdio, but
+ * The inter pass temporary token file is opened and closed by stdio, but
* is written to using direct read/write, as the temporary file
* is composed of buffers exactly BUFSIZ long.
*/
* is written to using direct read/write, as the temporary file
* is composed of buffers exactly BUFSIZ long.
*/
-FILE *tmpfil; /* interpass communication file */
+FILE *tokfile; /* interpass communication file */
+char tokfilename[TNAMESIZE];
+/*
+ * The string file is the string table
+ * cat'ed to the end of the built up a.out file
+ */
+FILE *strfile; /* interpass string file */
+char strfilename[TNAMESIZE];
+int strfilepos = 0; /* position within the string file */
/*
* a.out is created during the second pass.
* It is opened by stdio, but is filled with the parallel
/*
* a.out is created during the second pass.
* It is opened by stdio, but is filled with the parallel
-#define TMP_SUFFIX "asXXXXXX"
-char tmpn1[TNAMESIZE];
+ tokfilename[0] = 0;
+ strfilename[0] = 0;
endcore = sbrk(0);
argprocess(argc, argv); /* process argument lists */
endcore = sbrk(0);
argprocess(argc, argv); /* process argument lists */
- if (useVM == 0){
- strcat(tmpn1, tmpdirprefix);
- if (tmpdirprefix[strlen(tmpdirprefix)-1] != '/')
- strcat(tmpn1, "/");
- (void)strcat(tmpn1, TMP_SUFFIX);
- (void)mktemp(tmpn1);
- tmpfil = fopen(tmpn1, "w");
- if (tmpfil==NULL) {
- yyerror("Bad pass 1 temporary file for writing %s", tmpn1);
- delexit();
- }
- }
+ FILE *tempopen();
+ if (useVM == 0)
+ tokfile = tempopen(tokfilename, "T");
+ strfile = tempopen(strfilename, "S");
+ /*
+ * write out the string length.
+ * This will be overwritten when the
+ * strings are tacked onto the growing a.out file
+ */
+ strfilepos = sizeof(int);
+ fwrite(&strfilepos, sizeof(int), 1, strfile);
+FILE *tempopen(tname, part)
+ char *tname;
+ char *part;
+{
+ FILE *file;
+ sprintf(tname, "%s%sas%s%05d",
+ tmpdirprefix,
+ (tmpdirprefix[strlen(tmpdirprefix)-1] != '/') ? "/" : 0,
+ part,
+ getpid());
+ file = fopen(tname, "w");
+ if (file == NULL) {
+ yyerror("Bad pass 1 temporary file for writing %s", tname);
+ delexit();
+ }
+ return(file);
+}
+
pass1()
{
register int i;
pass1()
{
register int i;
- closetmpfile(); /*kick out the last buffered intermediate text*/
+ closetokfile(); /*kick out the last buffered intermediate text*/
i_pass2()
{
if (useVM == 0) {
i_pass2()
{
if (useVM == 0) {
- fclose(tmpfil);
- tmpfil = fopen(tmpn1, "r");
- if (tmpfil==NULL) {
- yyerror("Bad pass 2 temporary file for reading %s", tmpn1);
+ fclose(tokfile);
+ tokfile = fopen(tokfilename, "r");
+ if (tokfile==NULL) {
+ yyerror("Bad pass 2 temporary file for reading %s", tokfilename);
+ fclose(strfile);
+ strfile = fopen(strfilename, "r");
relfil = 0; /* outrel takes care of the rest */
initoutrel();
relfil = 0; /* outrel takes care of the rest */
initoutrel();
/*
* Output the symbol table
* and if FLEXNAMES is set, the string pool
/*
* Output the symbol table
* and if FLEXNAMES is set, the string pool
+ *
+ * We must first rewind the string pool file to its beginning,
+ * in case it was seek'ed into for fetching ascii and asciz
+ * strings.
- if (useVM == 0 || tmpn1[0])
- unlink(tmpn1);
+ if (useVM == 0 || tokfilename[0])
+ unlink(tokfilename);
+ if (strfilename[0])
+ unlink(strfilename);
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)asparse.c 4.13 %G%";
+static char sccsid[] = "@(#)asparse.c 4.14 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
*/
char tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
*/
char tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
-static char UDotsname[32]; /*name of the assembly source*/
+static char UDotsname[64]; /*name of the assembly source*/
reg struct symtab *p;
reg struct symtab *stpt;
reg struct symtab *p;
reg struct symtab *stpt;
- char *stringp; /*handles string lists*/
+ struct strdesc *stringp; /*handles string lists*/
int regno; /*handles arguments*/
int *ptrregno = ®no;
int regno; /*handles arguments*/
int *ptrregno = ®no;
yyerror("\"%.*s\" is not followed by a ':' for a label definition",
NCPName,
#endif not FLEXNAMES
yyerror("\"%.*s\" is not followed by a ':' for a label definition",
NCPName,
#endif not FLEXNAMES
goto errorfix;
}
restlab:
goto errorfix;
}
restlab:
- if (np->s_name[0] != 'L')
+ if (FETCHNAME(np)[0] != 'L')
#endif not DEBUG
{
if (passno == 1)
#endif not DEBUG
{
if (passno == 1)
yyerror("%.*s redefined",
NCPName,
#endif not FLEXNAMES
yyerror("%.*s redefined",
NCPName,
#endif not FLEXNAMES
else
#ifdef FLEXNAMES
yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
else
#ifdef FLEXNAMES
yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
NCPName,
#endif not FLEXNAMES
yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
NCPName,
#endif not FLEXNAMES
np->s_value,
dotp->e_xvalue);
}
np->s_value,
dotp->e_xvalue);
}
np->s_value = dotp->e_xvalue;
if (passno == 1){
np->s_index = dotp-usedot;
np->s_value = dotp->e_xvalue;
if (passno == 1){
np->s_index = dotp-usedot;
- if (np->s_name[0] == 'L'){
+ if (FETCHNAME(np)[0] == 'L'){
nlabels++;
}
np->s_tag = LABELID;
nlabels++;
}
np->s_tag = LABELID;
- stringp = (char *)yylval;
+ stringp = (struct strdesc *)yylval;
shiftover(STRING);
dotsname = &UDotsname[0];
shiftover(STRING);
dotsname = &UDotsname[0];
- movestr(dotsname, stringp, min(STRLEN(stringp), sizeof(dotsname)));
+ movestr(dotsname, stringp->sd_string,
+ min(stringp->sd_strlen, sizeof(UDotsname)));
#ifdef FLEXNAMES
stpt->s_name = np->s_name;
#else
#ifdef FLEXNAMES
stpt->s_name = np->s_name;
#else
- movestr(stpt->s_name, np->s_name, NCPName);
+ movestr(FETCHNAME(stpt), FETCHNAME(np), NCPName);
#endif
np->s_tag = OBSOLETE; /*invalidate original */
nforgotten++;
#endif
np->s_tag = OBSOLETE; /*invalidate original */
nforgotten++;
* stringlist: empty | STRING | stringlist STRING
*/
while (val == STRING){
* stringlist: empty | STRING | stringlist STRING
*/
while (val == STRING){
flushfield(NBPW/4);
if (bitoff)
dotp->e_xvalue++;
flushfield(NBPW/4);
if (bitoff)
dotp->e_xvalue++;
- stringp = (char *)yylval;
+ stringp = (struct strdesc *)yylval;
- * utilize the string scanner cheat,
- * where it appended a null byte on the string,
- * but didn't charge it to STRLEN
+ * utilize the string scanner cheat;
+ * the scanner appended a null byte on the string,
+ * but didn't charge it to sd_strlen
- STRLEN(stringp) += (auxval == IASCIZ) ? 1 : 0;
+ mystrlen = stringp->sd_strlen;
+ mystrlen += (auxval == IASCIZ) ? 1 : 0;
- outs(stringp, STRLEN(stringp));
+ if (passno == 2){
+ if (stringp->sd_place & STR_CORE){
+ outs(stringp->sd_string, mystrlen);
+ } else {
+ int i, nread;
+ fseek(strfile, stringp->sd_stroff, 0);
+ for (i = 0; i < mystrlen;/*VOID*/){
+ nread = fread(yytext, 1,
+ min(mystrlen - i,
+ sizeof(yytext)), strfile);
+ outs(yytext, nread);
+ i += nread;
+ }
+ }
+ } else {
+ dotp->e_xvalue += mystrlen;
+ }
shift;
for (argcnt = 0; argcnt < NCPName; argcnt++){
expr(locxp, val);
shift;
for (argcnt = 0; argcnt < NCPName; argcnt++){
expr(locxp, val);
- stpt->s_name[argcnt] = locxp->e_xvalue;
+ FETCHNAME(stpt)[argcnt] = locxp->e_xvalue;
xp = explist;
shiftover(CM);
}
xp = explist;
shiftover(CM);
}
(bytetoktype *)stabstart -= sizeof(bytetoktype);
shift;
if (auxval == ISTABSTR){
(bytetoktype *)stabstart -= sizeof(bytetoktype);
shift;
if (auxval == ISTABSTR){
- stringp = (char *)yylval;
+ stringp = (struct strdesc *)yylval;
shiftover(STRING);
#ifndef FLEXNAMES
shiftover(STRING);
#ifndef FLEXNAMES
- movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPName));
+ movestr(FETCHNAME(stpt), stringp,
+ min(stringp->sd_strlen, NCPName));
- stpt->s_name = stringp;
+ stpt->s_name = (char *)stringp;
/*
* We want the trailing null included in this string.
* We utilize the cheat the string scanner used,
* and merely increment the string length
*/
/*
* We want the trailing null included in this string.
* We utilize the cheat the string scanner used,
* and merely increment the string length
*/
+ stringp->sd_strlen += 1;
#endif
shiftover(CM);
} else {
#ifndef FLEXNAMES
static char nullstr[NCPName];
#endif
shiftover(CM);
} else {
#ifndef FLEXNAMES
static char nullstr[NCPName];
- movestr(stpt->s_name, nullstr, NCPName);
+ movestr(FETCHNAME(stpt), nullstr, NCPName);
#else
static char nullstr[1];
#else
static char nullstr[1];
- stpt->s_name = savestr(nullstr, 1);
+ static struct strdesc strdp;
+ strdp.sd_stroff = strfilepos;
+ strdp.sd_strlen = 0;
+ strdp.sd_place = STR_BOTH;
+ stpt->s_name = (char *)savestr(nullstr, &strdp);
yyerror("Redefinition of %.*s",
NCPName,
#endif not FLEXNAMES
yyerror("Redefinition of %.*s",
NCPName,
#endif not FLEXNAMES
if (passno==1) {
np->s_value = locxp->e_xvalue;
if (auxval == ICOMM)
if (passno==1) {
np->s_value = locxp->e_xvalue;
if (auxval == ICOMM)
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)aspseudo.c 4.4 %G%";
+static char sccsid[] = "@(#)aspseudo.c 4.5 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
readonly struct Instab instab[] = {
#include "instrs.as"
readonly struct Instab instab[] = {
#include "instrs.as"
+PSEUDO("\0\0\0\0\0\0\0\0\0\0", 0, 0)
/*
* Copyright (c) 1982 Regents of the University of California
/*
* Copyright (c) 1982 Regents of the University of California
*/
/*
* The character scanner is called to fill up one token buffer
*/
/*
* The character scanner is called to fill up one token buffer
extern ptrall tokptr; /*the next token to consume, call by copy*/
extern ptrall tokub; /*current upper bound in the current buffer*/
extern ptrall tokptr; /*the next token to consume, call by copy*/
extern ptrall tokub; /*current upper bound in the current buffer*/
-/*
- * Strings are stored in the string pool; see strsave(str, length)
- * Strings are known by their length and values.
- * A string pointer points to the beginning of the value bytes;
- * the preceding two bytes are the length.
- */
-#define STRLEN(str) (((lgtype *)str)[-1])
-char *savestr();
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)asscan1.c 4.4 %G%";
+static char sccsid[] = "@(#)asscan1.c 4.5 %G%";
#endif not lint
#include "asscanl.h"
#endif not lint
#include "asscanl.h"
{
if (passno == 1){
if (useVM){
{
if (passno == 1){
if (useVM){
{
if (passno == 1){
if (useVM){
{
if (passno == 1){
if (useVM){
* written out yet
*/
if (tokbuf[bufno ^ 1].tok_count >= 0){
* written out yet
*/
if (tokbuf[bufno ^ 1].tok_count >= 0){
- if (writeTEST((char *)&tokbuf[bufno ^ 1], sizeof *emptybuf, 1, tmpfil)){
+ if (writeTEST((char *)&tokbuf[bufno ^ 1], sizeof *emptybuf, 1, tokfile)){
badwrite:
yyerror("Unexpected end of file writing the interpass tmp file");
exit(2);
badwrite:
yyerror("Unexpected end of file writing the interpass tmp file");
exit(2);
* in the argument list
*/
tokbuf[bufno].toks[tokbuf[bufno].tok_count++] = PARSEEOF;
* in the argument list
*/
tokbuf[bufno].toks[tokbuf[bufno].tok_count++] = PARSEEOF;
- if (writeTEST((char *)&tokbuf[bufno], sizeof *emptybuf, 1, tmpfil))
+ if (writeTEST((char *)&tokbuf[bufno], sizeof *emptybuf, 1, tokfile))
goto badwrite;
}
} /*end of being pass 1*/
goto badwrite;
}
} /*end of being pass 1*/
case BIGNUM: bignumprint(((struct exp*)yylval)->e_number);
break;
case NAME: printf("\"%.8s\"",
case BIGNUM: bignumprint(((struct exp*)yylval)->e_number);
break;
case NAME: printf("\"%.8s\"",
- ((struct symtab *)yylval)->s_name);
+ FETCHNAME((struct symtab *)yylval));
break;
case REG: printf(" r%d",
yylval);
break;
case REG: printf(" r%d",
yylval);
case IJXXX:
case INST0:
case INSTn: if (ITABCHECK(yyopcode))
case IJXXX:
case INST0:
case INSTn: if (ITABCHECK(yyopcode))
- printf("%.8s", ITABFETCH(yyopcode)->s_name);
+ printf("%.8s",
+ FETCHNAME(ITABFETCH(yyopcode)));
else
printf("IJXXX or INST0 or INSTn can't get into the itab\n");
break;
else
printf("IJXXX or INST0 or INSTn can't get into the itab\n");
break;
* out at all
*/
if (emptybuf->tok_count >= 0){
* out at all
*/
if (emptybuf->tok_count >= 0){
- if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tmpfil)){
+ if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
yyerror("Unexpected end of file writing the interpass tmp file");
exit(2);
}
}
scan_dot_s(emptybuf);
} else { /*pass 2*/
yyerror("Unexpected end of file writing the interpass tmp file");
exit(2);
}
}
scan_dot_s(emptybuf);
} else { /*pass 2*/
- if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tmpfil)){
+ if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
badread:
yyerror("Unexpected end of file while reading the interpass tmp file");
exit(1);
badread:
yyerror("Unexpected end of file while reading the interpass tmp file");
exit(1);
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)asscan2.c 4.9 %G%";
+static char sccsid[] = "@(#)asscan2.c 4.10 %G%";
#endif not lint
#include "asscanl.h"
#endif not lint
#include "asscanl.h"
ptrall lgbackpatch; /* where to stuff a string length */
reg ptrall bufptr; /* where to stuff tokens */
ptrall bufub; /* where not to stuff tokens */
ptrall lgbackpatch; /* where to stuff a string length */
reg ptrall bufptr; /* where to stuff tokens */
ptrall bufub; /* where not to stuff tokens */
- reg int maxstrlg; /* how long a string can be */
+ reg int strlg; /* the length of a string */
long intval; /* value of int */
int linescrossed; /* when doing strings and comments */
struct Opcode opstruct;
long intval; /* value of int */
int linescrossed; /* when doing strings and comments */
struct Opcode opstruct;
+ struct strdesc strd; /* for building DQ strings */
(bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]);
(bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
(bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]);
(bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
MEMTOREGBUF;
if (newfflag){
newfflag = 0;
MEMTOREGBUF;
if (newfflag){
newfflag = 0;
- ryylval = (int)savestr(newfname, strlen(newfname) + 1);
+ strd.sd_stroff = strfilepos;
+ strd.sd_place = STR_BOTH;
+ strd.sd_strlen = strlen(newfname) + 1;
+ fputs(newfname, strfile);
+ putc(0, strfile);
+ strfilepos += strd.sd_strlen;
+ ryylval = (int)savestr(newfname, &strd);
ptoken(bufptr, IFILE);
ptoken(bufptr, STRING);
ptoken(bufptr, IFILE);
ptoken(bufptr, STRING);
- * Its a name... (Labels are subsets ofname)
+ * Its a name... (Labels are subsets of name)
*/
ryylval = (int)op;
val = NAME;
*/
ryylval = (int)op;
val = NAME;
case DQ:
eatstr:
linescrossed = 0;
case DQ:
eatstr:
linescrossed = 0;
- for(rcp = strtext, maxstrlg = NCPString; maxstrlg > 0; --maxstrlg){
+ strd.sd_stroff = strfilepos;
+ strd.sd_place = STR_FILE;
+ for (strd.sd_strlen = 0; /*VOID*/; strd.sd_strlen++){
switch(ch = getchar()){
case '"':
goto tailDQ;
default:
stuff:
switch(ch = getchar()){
case '"':
goto tailDQ;
default:
stuff:
break;
case '\n':
yywarning("New line in a string constant");
break;
case '\n':
yywarning("New line in a string constant");
ch = getchar();
switch(ch){
case EOFCHAR:
ch = getchar();
switch(ch){
case EOFCHAR:
ungetc(EOFCHAR);
goto tailDQ;
default:
ungetc(EOFCHAR);
goto tailDQ;
default:
/*
* put the string in strtext into the string pool
*
/*
* put the string in strtext into the string pool
*
- * The value in ryylval points to the string;
- * the previous 2 bytes is the length of the string
- *
* Cheat: append a trailing null to the string
* and then adjust the string length to ignore
* the trailing null. If any STRING client requires
* the trailing null, the client can just change STRLEN
*/
val = STRING;
* Cheat: append a trailing null to the string
* and then adjust the string length to ignore
* the trailing null. If any STRING client requires
* the trailing null, the client can just change STRLEN
*/
val = STRING;
- *rcp++ = 0;
- ryylval = (int)savestr(strtext, rcp - strtext);
- STRLEN(((char *)ryylval)) -= 1;
+ putc(0, strfile);
+ strd.sd_strlen += 1;
+ strfilepos += strd.sd_strlen;
+ ryylval = (int)savestr(strtext, &strd);
+ ((struct strdesc *)ryylval)->sd_strlen -= 1;
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
* Copyright (c) 1982 Regents of the University of California
*/
#ifndef lint
-static char sccsid[] = "@(#)assyms.c 4.10 %G%";
+static char sccsid[] = "@(#)assyms.c 4.11 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
for (i = 0; i < NINST; i++)
itab[i] = (Iptr*)BADPOINT;
for (i = 0; i < NINST; i++)
itab[i] = (Iptr*)BADPOINT;
-#ifdef FLEXNAMES
- for (ip = (Iptr)instab; ip->s_name != 0; ip++) {
-#else not FLEXNAMES
- for (ip = (Iptr)instab; ip->s_name[0] != '\0'; ip++){
-#endif not FLEXNAMES
- p1 = ip->s_name;
+ for (ip = (Iptr)instab; FETCHNAME(ip)[0]; ip++) {
+ p1 = FETCHNAME(ip);
p2 = yytext;
while (*p2++ = *p1++);
hp = lookup(0); /* 0 => don't install this*/
p2 = yytext;
while (*p2++ = *p1++);
hp = lookup(0); /* 0 => don't install this*/
hdr.a_bss += bs;
}
assignindex:
hdr.a_bss += bs;
}
assignindex:
- if ( (sp->s_name[0] != 'L')
+ if ( (FETCHNAME(sp)[0] != 'L')
|| (sp->s_tag != LABELID)
|| savelabels
) /*then, we will write it later on*/
|| (sp->s_tag != LABELID)
|| savelabels
) /*then, we will write it later on*/
SEGITERATE(segno, 0, 0, cosp, sp, ub, ++){
#ifdef FLEXNAMES
printf("\tSeg: %d \"%s\" value: %d index: %d tag %s\n",
SEGITERATE(segno, 0, 0, cosp, sp, ub, ++){
#ifdef FLEXNAMES
printf("\tSeg: %d \"%s\" value: %d index: %d tag %s\n",
sp->s_value, sp->s_index,
tagstring(sp->s_tag));
#else not FLEXNAMES
printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
sp->s_value, sp->s_index,
tagstring(sp->s_tag));
#else not FLEXNAMES
printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
- segno, NCPName, NCPName, sp->s_name,
+ segno, NCPName, NCPName, FETCHNAME(sp),
sp->s_value, sp->s_index,
tagstring(sp->s_tag));
#endif not FLEXNAMES
sp->s_value, sp->s_index,
tagstring(sp->s_tag));
#endif not FLEXNAMES
register char *to;
register int len;
register int nprobes;
register char *to;
register int len;
register int nprobes;
- static struct hashdallop *hdallop;
- static struct symtab **emptyslot;
- static struct hashdallop *emptyhd;
- static struct symtab **hp_ub;
+ static struct hashdallop *hdallop;
+ static struct symtab **emptyslot;
+ static struct hashdallop *emptyhd;
+ static struct symtab **hp_ub;
+ static struct strdesc strdp;
emptyslot = 0;
for (nprobes = 0, from = yytext;
emptyslot = 0;
for (nprobes = 0, from = yytext;
nprobes += 2)
{
from = yytext;
nprobes += 2)
{
from = yytext;
#ifndef FLEXNAMES
for (len = 0; (len<NCPName) && *from; len++)
if (*from++ != *to++)
#ifndef FLEXNAMES
for (len = 0; (len<NCPName) && *from; len++)
if (*from++ != *to++)
*hp = symalloc();
hdallop->h_nused++;
#ifndef FLEXNAMES
*hp = symalloc();
hdallop->h_nused++;
#ifndef FLEXNAMES
- strncpy((*hp)->s_name, yytext, NCPName);
+ strncpy(FETCHNAME(*hp), yytext, NCPName);
#else FLEXNAMES
for (from = yytext, len = 0; *from++; len++)
continue;
/*
#else FLEXNAMES
for (from = yytext, len = 0; *from++; len++)
continue;
/*
- * save string and trailing null
+ * save string and trailing null, both
+ * internally, and in the string temporary file
- (*hp)->s_name = savestr(yytext, len + 1);
+ strdp.sd_stroff = strfilepos;
+ strdp.sd_place = STR_BOTH;
+ strdp.sd_strlen = len + 1; /* length and null */
+ fputs(yytext, strfile); /* string */
+ putc(0, strfile); /* null */
+ strfilepos += strdp.sd_strlen;
+ (*hp)->s_name = (char *)savestr(yytext, &strdp);
#endif FLEXNAMES
}
return(hp);
} /*end of lookup*/
/*
#endif FLEXNAMES
}
return(hp);
} /*end of lookup*/
/*
- * save a string str, length len in the string pool.
- * string known just by its length; can have or not have trailing nulls.
- *
- * The length of the string occurs as a short just before
- * the character pointer returned.
+ * save a string str, descriptor strdp, in the string pool
+struct strdesc *savestr(str, strdp)
+ reg struct strdesc *res;
+ int tlen;
+
+ tlen = sizeof(struct strdesc) - sizeof(res->sd_string);
+ if (strdp->sd_place & STR_FILE)
+ tlen += strdp->sd_strlen;
- if (len + sizeof(lgtype) >= (STRPOOLDALLOP - strplhead->str_nalloc))
+ if (tlen >= (STRPOOLDALLOP - strplhead->str_nalloc))
- res = strplhead->str_names + strplhead->str_nalloc;
- plgtype(res, len);
- movestr(res, str, len);
- strplhead->str_nalloc += sizeof(lgtype) + len;
+ res = (struct strdesc *)(strplhead->str_names + strplhead->str_nalloc);
+ res[0] = *strdp;
+ if (strdp->sd_place & STR_FILE)
+ movestr(res[0].sd_string, str, strdp->sd_strlen);
+ strplhead->str_nalloc += tlen;
int symwrite(symfile)
BFILE *symfile;
{
int symwrite(symfile)
BFILE *symfile;
{
- int symsout; /*those actually written*/
- int symsdesired = NOUTSYMS;
- register struct symtab *sp, *ub;
+ int symsout; /*those actually written*/
+ int symsdesired = NOUTSYMS;
+ reg struct symtab *sp, *ub;
- char *name; /* temp to save the name */
- long stroff = sizeof (stroff);
+ char *name; /* temp to save the name */
+ int nread;
+ char rbuf[2048];
+ int i;
/*
* We use sp->s_index to hold the length of the
* name; it isn't used for anything else
/*
* We use sp->s_index to hold the length of the
* name; it isn't used for anything else
{
if (sp->s_tag >= IGNOREBOUND)
continue;
{
if (sp->s_tag >= IGNOREBOUND)
continue;
- if ((sp->s_name[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
+ if ((FETCHNAME(sp)[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
* the length of the symbol table string
* always includes the trailing null
*/
* the length of the symbol table string
* always includes the trailing null
*/
- if (sp->s_name && (sp->s_index = STRLEN(sp->s_name))){
- sp->s_nmx = stroff; /* clobber pointer */
- stroff += sp->s_index;
+ if (sp->s_name && (sp->s_index = STRLEN(sp))){
+ sp->s_nmx = STROFF(sp); /* clobber */
} else {
sp->s_nmx = 0;
}
} else {
sp->s_nmx = 0;
}
+#ifdef DEBUG
+ printf("symbol %d: nmx == %d\n", symsout, sp->s_nmx);
+#endif DEBUG
+#endif FLEXNAMES
sp->s_type = (sp->s_ptype != 0) ? sp->s_ptype : (sp->s_type & (~XFORW));
if (readonlydata && (sp->s_type&~N_EXT) == N_DATA)
sp->s_type = N_TEXT | (sp->s_type & N_EXT);
sp->s_type = (sp->s_ptype != 0) ? sp->s_ptype : (sp->s_type & (~XFORW));
if (readonlydata && (sp->s_type&~N_EXT) == N_DATA)
sp->s_type = N_TEXT | (sp->s_type & N_EXT);
symsout, symsdesired);
#ifdef FLEXNAMES
/*
symsout, symsdesired);
#ifdef FLEXNAMES
/*
- * Pass 2 through the string pool
+ * Copy the string temporary file to the symbol file,
+ * copying all the strings and symbols we ever saw,
+ * including labels, stabs strings, ascii strings, etc.
+ * This is slightly wasteful.
- symsout = 0;
- bwrite((char *)&stroff, sizeof (stroff), symfile);
- stroff = sizeof (stroff);
- symsout = 0;
- DECLITERATE(allocwalk, sp, ub)
- {
- if (sp->s_tag >= IGNOREBOUND)
- continue;
- if ((sp->s_name[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
- continue;
- if (sp->s_name && (sp->s_index = STRLEN(sp->s_name))){
- bwrite(sp->s_name, sp->s_index, symfile);
+ i = 0;
+ while((nread = read(strfile->_file, rbuf, sizeof(rbuf))) > 0){
+ if (i == 0){
+#ifdef DEBUG
+ printf("%d bytes of strings\n", strfilepos);
+#endif DEBUG
+ ((int *)rbuf)[0] = strfilepos;
+ bwrite(rbuf, nread, symfile);
+ i++;
##
## Copyright (c) 1982 Regents of the University of California
##
## Copyright (c) 1982 Regents of the University of California
##
## Robert R. Henry
## University of California, Berkeley
##
## Robert R. Henry
## University of California, Berkeley
+ ##
+ ## magic padding before the string for AS
+ ## 4 bytes of 0's: seek position of the string
+ ## 2 bytes, value 2, indicating core resident
+ ## 2 bytes, value 0, length
+ ##
+ ASpad = "\\0\\0\\0\\0" "\\2\\0";
if (flavor == "AS"){
if ($4 == "CBR")
$4 = "IJXXX";
if (flavor == "AS"){
if ($4 == "CBR")
$4 = "IJXXX";
- printf("PSEUDO(\"%s\", %s, %s),\n", $3, $7, $4);
+ printf("PSEUDO(\"%s\\0%o\\0%s\",", ASpad,length($3),$3);
+ printf("%s, %s),\n", $7, $4);
next;
}
if (flavor == "C2"){
next;
}
if (flavor == "C2"){
printf("T(%s,%s),\n", $4, $5); # special value
next;
}
printf("T(%s,%s),\n", $4, $5); # special value
next;
}
- if (flavor == "AS" || flavor == "ADB"){
+ if (flavor == "AS"){
+ printf("OP(\"%s\\0%o\\0%s\", ", ASpad, length($3), $3);
+ printf("%s, %s, %d", $6, $7, $8);
+ } else {
printf("OP(\"%s\", %s, %s, %d", $3, $6, $7, $8);
printf("OP(\"%s\", %s, %s, %d", $3, $6, $7, $8);
+ }
+ if (flavor == "AS" || flavor == "ADB"){
for (i = 9; i+1 <= NF; i = i + 2){
printf(", A_%s%s", $i, $(i+1));
}
for (i = 9; i+1 <= NF; i = i + 2){
printf(", A_%s%s", $i, $(i+1));
}