into one place, with documentation
SCCS-vsn: old/as.vax/asparse.c 4.13
SCCS-vsn: old/as.vax/assyms.c 4.10
SCCS-vsn: old/as.vax/assyms.h 4.5
SCCS-vsn: old/as.vax/as.h 4.13
SCCS-vsn: old/as.vax/asscan2.c 4.8
/*
* 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
#define NHASH 1103 /* hash table is dynamically extended */
#define TNAMESIZE 32 /* maximum length of temporary file names */
#define NLOC 4 /* number of location ctrs */
#define NHASH 1103 /* hash table is dynamically extended */
#define TNAMESIZE 32 /* maximum length of temporary file names */
#define NLOC 4 /* number of location ctrs */
+/*
+ * Sizes for character buffers.
+ * what size #define name comments
+ *
+ * source file reads ASINBUFSIZ integral of BUFSIZ
+ * string assembly NCPString large for .stabs
+ * name assembly NCPName depends on FLEXNAMES
+ * string save STRPOOLDALLOP
+ *
+ *
+ * -source file reads should be integral of BUFSIZ for efficient reads
+ * -string saving is a simple first fit
+ */
+#ifndef ASINBUFSIZ
+# define ASINBUFSIZ 4096
+#endif not ASINBUFSIZ
+#ifndef STRPOOLDALLOP
+# define STRPOOLDALLOP 8192
+#endif not STRPOOLDALLOP
+#ifndef NCPString
+# define NCPString 4080
+#endif not NCPString
+
+#define NCPName NCPS
-# ifndef FLEXNAMES
-# ifndef NCPS
-# define NCPS 8 /* number of characters per symbol*/
-# endif
-# else
-# ifdef NCPS
-# undef NCPS
-# endif
-# define NCPS 4096 /* needed to allocate yytext */
-# endif
+# ifndef FLEXNAMES
+# ifndef NCPS
+# undef NCPName
+# define NCPName 8
+# endif not NCPS
+# else FLEXNAMES
+# ifndef NCPS
+# undef NCPName
+# define NCPName 4096
+# endif not NCPS
+# endif FLEXNAMES
-# ifdef NCPS
-# undef NCPS
-# endif NCPS
-# define NCPS 15
+/*
+ * Check sizes, and compiler error if sizes botch
+ */
+#if ((ASINBUFSIZ < NCPString) || (ASINBUFSIZ < NCPName) || (STRPOOLDALLOP < NCPString) || (STRPOOLDALLOP < NCPName))
+ $$$botch with definition sizes
+#endif test botches
#ifdef FLEXNAMES
char *I_name;
#else not FLEXNAMES
#ifdef FLEXNAMES
char *I_name;
#else not FLEXNAMES
#endif
u_char I_popcode; /* basic op code */
char I_nargs;
#endif
u_char I_popcode; /* basic op code */
char I_nargs;
* The lexical analyzer builds up symbols in yytext. Lookup
* expects its argument in this buffer
*/
* The lexical analyzer builds up symbols in yytext. Lookup
* expects its argument in this buffer
*/
- extern char yytext[NCPS+2]; /* text buffer for lexical */
+ extern char yytext[NCPName+2]; /* text buffer for lexical */
/*
* Variables to manage the input assembler source file
*/
/*
* Variables to manage the input assembler source file
*/
* 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.12 %G%";
+static char sccsid[] = "@(#)asparse.c 4.13 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
/*a left parenthesis, which has already been*/
/*shifted. (Used to parse (<expr>)(rn)*/
/*a left parenthesis, which has already been*/
/*shifted. (Used to parse (<expr>)(rn)*/
-char yytext[NCPS+2]; /*the lexical image*/
+char yytext[NCPName+2]; /*the lexical image*/
int yylval; /*the lexical value; sloppy typing*/
struct Opcode yyopcode; /* lexical value for an opcode */
Bignum yybignum; /* lexical value for a big number */
int yylval; /*the lexical value; sloppy typing*/
struct Opcode yyopcode; /* lexical value for an opcode */
Bignum yybignum; /* lexical value for a big number */
yyerror("\"%s\" is not followed by a ':' for a label definition",
#else not FLEXNAMES
yyerror("\"%.*s\" is not followed by a ':' for a label definition",
yyerror("\"%s\" is not followed by a ':' for a label definition",
#else not FLEXNAMES
yyerror("\"%.*s\" is not followed by a ':' for a label definition",
#endif not FLEXNAMES
np->s_name);
goto errorfix;
#endif not FLEXNAMES
np->s_name);
goto errorfix;
yyerror("%s redefined",
#else not FLEXNAMES
yyerror("%.*s redefined",
yyerror("%s redefined",
#else not FLEXNAMES
yyerror("%.*s redefined",
#endif not FLEXNAMES
np->s_name);
else
#endif not FLEXNAMES
np->s_name);
else
yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
#else not FLEXNAMES
yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
#else not FLEXNAMES
yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
#endif not FLEXNAMES
np->s_name,
np->s_value,
#endif not FLEXNAMES
np->s_name,
np->s_value,
#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, NCPS);
+ movestr(stpt->s_name, np->s_name, NCPName);
#endif
np->s_tag = OBSOLETE; /*invalidate original */
nforgotten++;
#endif
np->s_tag = OBSOLETE; /*invalidate original */
nforgotten++;
* final expression is taken to be the current
* location counter, and is patched by the 2nd pass
*
* final expression is taken to be the current
* location counter, and is patched by the 2nd pass
*
- * .stab{<expr>,}*NCPS,<expr>, <expr>, <expr>, <expr>
+ * .stab{<expr>,}*NCPName,<expr>, <expr>, <expr>, <expr>
* .stabn <expr>, <expr>, <expr>, <expr>
* .stabs STRING, <expr>, <expr>, <expr>, <expr>
* .stabd <expr>, <expr>, <expr> # .
* .stabn <expr>, <expr>, <expr>, <expr>
* .stabs STRING, <expr>, <expr>, <expr>, <expr>
* .stabd <expr>, <expr>, <expr> # .
(char *)stabstart -= sizeof(struct symtab *);
(char *)stabstart -= sizeof(bytetoktype);
shift;
(char *)stabstart -= sizeof(struct symtab *);
(char *)stabstart -= sizeof(bytetoktype);
shift;
- for (argcnt = 0; argcnt < NCPS; argcnt++){
+ for (argcnt = 0; argcnt < NCPName; argcnt++){
expr(locxp, val);
stpt->s_name[argcnt] = locxp->e_xvalue;
xp = explist;
expr(locxp, val);
stpt->s_name[argcnt] = locxp->e_xvalue;
xp = explist;
stringp = (char *)yylval;
shiftover(STRING);
#ifndef FLEXNAMES
stringp = (char *)yylval;
shiftover(STRING);
#ifndef FLEXNAMES
- movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPS));
+ movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPName));
#else
stpt->s_name = stringp;
/*
#else
stpt->s_name = stringp;
/*
shiftover(CM);
} else {
#ifndef FLEXNAMES
shiftover(CM);
} else {
#ifndef FLEXNAMES
- static char nullstr[NCPS];
- movestr(stpt->s_name, nullstr, NCPS);
+ static char nullstr[NCPName];
+ movestr(stpt->s_name, nullstr, NCPName);
#else
static char nullstr[1];
stpt->s_name = savestr(nullstr, 1);
#else
static char nullstr[1];
stpt->s_name = savestr(nullstr, 1);
yyerror("Redefinition of %s",
#else not FLEXNAMES
yyerror("Redefinition of %.*s",
yyerror("Redefinition of %s",
#else not FLEXNAMES
yyerror("Redefinition of %.*s",
#endif not FLEXNAMES
np->s_name);
if (passno==1) {
#endif not FLEXNAMES
np->s_name);
if (passno==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.7 %G%";
+static char sccsid[] = "@(#)asscan2.c 4.8 %G%";
#endif not lint
#include "asscanl.h"
static inttoktype oval = NL;
#endif not lint
#include "asscanl.h"
static inttoktype oval = NL;
#define NINBUFFERS 2
#define INBUFLG NINBUFFERS*ASINBUFSIZ + 2
/*
#define NINBUFFERS 2
#define INBUFLG NINBUFFERS*ASINBUFSIZ + 2
/*
static char inbuffer[INBUFLG];
static char *InBufPtr = 0;
static char inbuffer[INBUFLG];
static char *InBufPtr = 0;
+#ifndef FLEXNAMES
+char strtext[NCPString + 1];
+#else FLEXNAMES
+# if NCPName < NCPString
+char strtext[NCPString + 1];
+# else
+#define strtext yytext
+# endif
+#endif FLEXNAMES
+
/*
* fill the inbuffer from the standard input.
* Assert: there are always n COMPLETE! lines in the buffer area.
/*
* fill the inbuffer from the standard input.
* Assert: there are always n COMPLETE! lines in the buffer area.
- if (rcp < &yytext[NCPS])
+ if (rcp < &yytext[NCPName])
*rcp++ = ch;
} while (INCHARSET ( (ch = getchar()), ALPHA | DIGIT));
*rcp = '\0';
*rcp++ = ch;
} while (INCHARSET ( (ch = getchar()), ALPHA | DIGIT));
*rcp = '\0';
case DQ:
eatstr:
linescrossed = 0;
case DQ:
eatstr:
linescrossed = 0;
- for(rcp = yytext, maxstrlg = NCPS; maxstrlg > 0; --maxstrlg){
+ for(rcp = strtext, maxstrlg = NCPString; maxstrlg > 0; --maxstrlg){
switch(ch = getchar()){
case '"':
goto tailDQ;
switch(ch = getchar()){
case '"':
goto tailDQ;
pint(bufptr, linescrossed);
}
/*
pint(bufptr, linescrossed);
}
/*
- * put the string in yytext 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
*
* The value in ryylval points to the string;
* the previous 2 bytes is the length of the string
*/
val = STRING;
*rcp++ = 0;
*/
val = STRING;
*rcp++ = 0;
- ryylval = (int)savestr(yytext, rcp - yytext);
+ ryylval = (int)savestr(strtext, rcp - strtext);
STRLEN(((char *)ryylval)) -= 1;
goto ret;
STRLEN(((char *)ryylval)) -= 1;
goto ret;
* 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.9 %G%";
+static char sccsid[] = "@(#)assyms.c 4.10 %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
/*
* Managers of the symbol literal storage.
/*
* Managers of the symbol literal storage.
- * If we have flexible names, then we allocate BUFSIZ long
- * string, and pack strings into that. Otherwise, we allocate
- * symbol storage in fixed hunks NCPS long when we allocate space
- * for other symbol attributes.
*/
struct strpool *strplhead = 0;
*/
struct strpool *strplhead = 0;
tagstring(sp->s_tag));
#else not FLEXNAMES
printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
tagstring(sp->s_tag));
#else not FLEXNAMES
printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
- segno, NCPS, NCPS, sp->s_name,
+ segno, NCPName, NCPName, sp->s_name,
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
from = yytext;
to = (*hp)->s_name;
#ifndef FLEXNAMES
from = yytext;
to = (*hp)->s_name;
#ifndef FLEXNAMES
- for (len = 0; (len<NCPS) && *from; len++)
+ for (len = 0; (len<NCPName) && *from; len++)
if (*from++ != *to++)
goto nextprobe;
if (*from++ != *to++)
goto nextprobe;
- if (len >= NCPS) /*both are maximal length*/
+ if (len >= NCPName) /*both are maximal length*/
return(hp);
if (*to == 0) /*assert *from == 0*/
return(hp);
return(hp);
if (*to == 0) /*assert *from == 0*/
return(hp);
*hp = symalloc();
hdallop->h_nused++;
#ifndef FLEXNAMES
*hp = symalloc();
hdallop->h_nused++;
#ifndef FLEXNAMES
- strncpy((*hp)->s_name, yytext, NCPS);
+ strncpy((*hp)->s_name, yytext, NCPName);
#else FLEXNAMES
for (from = yytext, len = 0; *from++; len++)
continue;
#else FLEXNAMES
for (from = yytext, len = 0; *from++; len++)
continue;
/*
* Copyright (c) 1982 Regents of the University of California
/*
* Copyright (c) 1982 Regents of the University of California
*/
/*
* To speed up walks through symbols defined in a particular
*/
/*
* To speed up walks through symbols defined in a particular
walkpointer = * ++ copointer)
/*
* Symbols are allocated in non contiguous chunks by extending
walkpointer = * ++ copointer)
/*
* Symbols are allocated in non contiguous chunks by extending
- * the data area. This way, it is extremely easy to
- * allow virtual memory temporary files, change the length
- * of NCPS, and allows for a much more flexible storage
- * allocation
- * Names are allocated in a string pool. String pools are linked
- * together and are allocated dynamically by Calloc.
+ * Names are allocated in a dynamically extensible string pool.
-#define STRPOOLDALLOP NCPS
struct strpool{
struct strpool *str_next;
int str_nalloc;
struct strpool{
struct strpool *str_next;
int str_nalloc;