+#ifndef _AS_H_
+#define _AS_H_
+
+#include <a.out.h>
+#include <stdio.h>
+/*#include <sys/exec.h> a.out.h*/
+/*#include <sys/types.h> asnumber.h*/
+#include "asnumber.h"
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* @(#)as.h 5.3 (Berkeley) 7/6/85
*/
-#include <sys/types.h>
-#include <a.out.h>
-#include <stab.h>
+/*#include <sys/types.h>*/
+/*#include <a.out.h>*/
+/*#include <stab.h>*/
#define NINST 300
*/
#ifndef STRPOOLDALLOP
# define STRPOOLDALLOP 8192
-#endif not STRPOOLDALLOP
+#endif
#define NCPName NCPS
#ifndef NCPS
# undef NCPName
# define NCPName 4096
-#endif not NCPS
+#endif
/* note: STRPOOLDALLOP has to be at least as large as NCPName */
*/
struct symtab{
+#ifdef X_
+ char *s_name; /* for use when in-core */
+ unsigned char s_type; /* type flag, i.e. N_TEXT etc; see below */
+ char s_other; /* unused */
+ short s_desc; /* see <stab.h> */
+ unsigned long s_value; /* value of this symbol (or sdb offset) */
+#else
struct nlist s_nm;
+#endif
u_char s_tag; /* assembler tag */
u_char s_ptype; /* if tag == NAME */
u_char s_jxoveralign; /* if a JXXX, jumped over align */
* one saves typing, and so that they conform
* with the old naming conventions.
*/
+#ifndef X_
#define s_name s_nm.n_un.n_name
+#endif
#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 STRPLACE(sp) (((struct strdesc *)(sp)->s_name)->sd_place)
+#ifndef X_
#define s_nmx s_nm.n_un.n_strx /* string table index */
#define s_type s_nm.n_type /* type of the symbol */
#define s_other s_nm.n_other /* other information for sdb */
#define s_desc s_nm.n_desc /* type descriptor */
#define s_value s_nm.n_value /* value of the symbol, or sdb delta */
+#endif
struct instab{
+#ifdef X_
+ char *s_name; /* for use when in-core */
+unsigned char s_type; /* type flag, i.e. N_TEXT etc; see below */
+ char s_other; /* unused */
+ short s_desc; /* see <stab.h> */
+unsigned long s_value; /* value of this symbol (or sdb offset) */
+#else
struct nlist s_nm; /* instruction name, type (opcode) */
+#endif
u_char s_tag;
u_char s_eopcode;
char s_pad[2]; /* round to 20 bytes */
* Redefinitions of fields in the struct nlist for instructions so that
* one saves typing, and conforms to the old naming conventions
*/
+#ifdef X_
+#define i_popcode s_type /* use the same field as symtab.type */
+#else
#define i_popcode s_nm.n_type /* use the same field as symtab.type */
+#endif
#define i_eopcode s_eopcode
+#ifdef X_
+#define i_nargs s_other /* number of arguments */
+#else
#define i_nargs s_nm.n_other /* number of arguments */
+#endif
#define fetcharg(ptr, n) ((struct Instab *)ptr)->I_args[n]
struct arg { /*one argument to an instruction*/
/*
* Definitions for numbers and expressions.
*/
-#include "asnumber.h"
+/*#include "asnumber.h"*/
struct exp {
Bignum e_number; /* 128 bits of #, plus tag */
char e_xtype;
#define STR_CORE 0x2
#define STR_BOTH 0x3
-struct strdesc *savestr();
+/*struct strdesc *savestr();*/
/*
* Assertions
*/
* Information about the instructions
*/
extern struct instab **itab[NINST]; /*maps opcodes to instructions*/
- extern readonly struct Instab instab[];
+ extern struct Instab instab[];
extern int curlen; /*current literal storage size*/
extern int d124; /*current pointer storage size*/
*/
extern struct relbufdesc *rusefile[NLOC + NLOC];
extern struct relbufdesc *relfil;
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+#ifndef NORETURN
+#ifdef __GNUC__
+#define NORETURN __attribute__ ((__noreturn__))
+#else
+#define NORETURN
+#endif
+#endif
+
+/* ascode.c */
+void insout __P((struct Opcode opcode, struct arg *ap, int nact));
+void putins __P((struct Opcode opcode, register struct arg *ap, int n));
+int immconstant __P((register struct exp *xp, int argtype, int *valuep));
+
+/* asio.c */
+void Flushfield __P((register int n));
+void bopen __P((struct biobuf *bp, off_t off));
+void bwrite __P((register char *p, register int cnt, register struct biobuf *bp));
+void bflush __P((void));
+void bflush1 __P((register struct biobuf *bp));
+void bflushc __P((register struct biobuf *bp, int c));
+
+/* asjxxx.c */
+void initijxxx __P((void));
+void ijxout __P((struct Opcode opcode, struct arg *ap, int nact));
+void jalign __P((register struct exp *xp, register struct symtab *sp));
+void jxxxfix __P((void));
+void jxxxbump __P((int segno, struct symtab **starthint));
+
+/* asmain.c */
+int main __P((int argc, char **argv));
+void argprocess __P((int argc, char *argv[]));
+void selfwhat __P((FILE *place));
+void initialize __P((void));
+void zeroorigins __P((void));
+void zerolocals __P((void));
+void i_pass1 __P((void));
+FILE *tempopen __P((char *tname, char *part));
+void pass1 __P((void));
+void testlocals __P((void));
+void pass1_5 __P((void));
+void open_a_out __P((void));
+void roundsegments __P((void));
+void build_hdr __P((void));
+void i_pass2 __P((void));
+void pass2 __P((void));
+void fillsegments __P((void));
+void reloc_syms __P((void));
+void fix_a_out __P((void));
+int delexit __P((void)) NORETURN;
+void delete __P((void));
+int sawabort __P((void)) NORETURN;
+int panic __P((char *fmt, ...)) NORETURN;
+
+/* assyms.c */
+void symtabinit __P((void));
+void syminstall __P((void));
+void freezesymtab __P((void));
+void stabfix __P((void));
+char *Calloc __P((int number, int size));
+char *ClearCalloc __P((int number, int size));
+struct symtab *symalloc __P((void));
+void strpoolalloc __P((void));
+int symcmp __P((struct symtab **Pptr, struct symtab **Qptr));
+void sortsymtab __P((void));
+int dumpsymtab __P((void));
+char *tagstring __P((int tag));
+void htaballoc __P((void));
+struct symtab **lookup __P((int instflg));
+struct strdesc *savestr __P((char *str, int len, int place));
+void initoutrel __P((void));
+void outrel __P((register struct exp *xp, int reloc_how));
+off_t closeoutrel __P((BFILE *relocfile));
+u_long Closeoutrel __P((struct relbufdesc *relfil, BFILE *relocfile));
+int sizesymtab __P((void));
+void symwrite __P((BFILE *symfile));
+
+/* floattab.c */
+void cfloattab __P((void));
+
+#endif
+/*#include <stdio.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)ascode.c 5.1 (Berkeley) 4/24/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
-#include "assyms.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
+/*#include "assyms.h"*/
-insout(opcode, ap, nact)
- struct Opcode opcode;
- struct arg *ap;
- int nact;
-{
+void insout(opcode, ap, nact) struct Opcode opcode; struct arg *ap; int nact; {
int jxxflg;
- reg struct instab *ip; /* the instruction */
- reg struct arg *ap_walk; /* actual param walk */
- reg int i;
- reg int ap_type; /* actual param type */
- reg int ap_type_mask; /* masked actual param */
+ register struct instab *ip; /* the instruction */
+ register struct arg *ap_walk; /* actual param walk */
+ register int i;
+ register int ap_type; /* actual param type */
+ register int ap_type_mask; /* masked actual param */
jxxflg = nact;
if (nact < 0)
extern int d124;
-putins(opcode, ap, n)
- struct Opcode opcode;
- register struct arg *ap;
- int n; /* Must be positive */
-{
- reg struct exp *xp;
- reg int argtype;
+void putins(opcode, ap, n) struct Opcode opcode; register struct arg *ap; int n; /* Must be positive */ {
+ register struct exp *xp;
+ register int argtype;
int i;
int reloc_how;
int value;
#define IMMFLT 1 /* these flags are not used by anybody (yet) */
#define IMMINT 2
-int immconstant(xp, argtype, valuep)
- reg struct exp *xp;
- int argtype;
- int *valuep;
-{
- reg int back = 0;
+int immconstant(xp, argtype, valuep) register struct exp *xp; int argtype; int *valuep; {
+ register int back = 0;
int numtype;
- reg int fits;
+ register int fits;
if ((xp->e_xtype & XTYPE) != XABS)
return(0);
+/*#include <stdio.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asscan.h" asexpr.h*/
+/*#include "astoks.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asexpr.c 5.2 (Berkeley) 6/19/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
-#include "asscan.h"
-#include "asexpr.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
+/*#include "asscan.h"*/
+/*#include "asexpr.h"*/
/*
* Tables for combination of operands.
/*
* table for +
*/
-readonly char pltab[6][6] = {
+char pltab[6][6] = {
/* UND ABS TXT DAT BSS EXT */
-/*UND*/ XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
-/*ABS*/ XUNDEF, XABS, XTEXT, XDATA, XBSS, XXTRN,
-/*TXT*/ XUNDEF, XTEXT, ERR, ERR, ERR, ERR,
-/*DAT*/ XUNDEF, XDATA, ERR, ERR, ERR, ERR,
-/*BSS*/ XUNDEF, XBSS, ERR, ERR, ERR, ERR,
-/*EXT*/ XUNDEF, XXTRN, ERR, ERR, ERR, ERR,
+/*UND*/ {XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF},
+/*ABS*/ {XUNDEF, XABS, XTEXT, XDATA, XBSS, XXTRN},
+/*TXT*/ {XUNDEF, XTEXT, ERR, ERR, ERR, ERR},
+/*DAT*/ {XUNDEF, XDATA, ERR, ERR, ERR, ERR},
+/*BSS*/ {XUNDEF, XBSS, ERR, ERR, ERR, ERR},
+/*EXT*/ {XUNDEF, XXTRN, ERR, ERR, ERR, ERR}
};
/*
* table for -
*/
-readonly char mintab[6][6] = {
+char mintab[6][6] = {
/* UND ABS TXT DAT BSS EXT */
-/*UND*/ XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
-/*ABS*/ XUNDEF, XABS, ERR, ERR, ERR, ERR,
-/*TXT*/ XUNDEF, XTEXT, XABS, ERR, ERR, ERR,
-/*DAT*/ XUNDEF, XDATA, ERR, XABS, ERR, ERR,
-/*BSS*/ XUNDEF, XBSS, ERR, ERR, XABS, ERR,
-/*EXT*/ XUNDEF, XXTRN, ERR, ERR, ERR, ERR,
+/*UND*/ {XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF},
+/*ABS*/ {XUNDEF, XABS, ERR, ERR, ERR, ERR},
+/*TXT*/ {XUNDEF, XTEXT, XABS, ERR, ERR, ERR},
+/*DAT*/ {XUNDEF, XDATA, ERR, XABS, ERR, ERR},
+/*BSS*/ {XUNDEF, XBSS, ERR, ERR, XABS, ERR},
+/*EXT*/ {XUNDEF, XXTRN, ERR, ERR, ERR, ERR}
};
/*
* table for other operators
*/
-readonly char othtab[6][6] = {
+char othtab[6][6] = {
/* UND ABS TXT DAT BSS EXT */
-/*UND*/ XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
-/*ABS*/ XUNDEF, XABS, ERR, ERR, ERR, ERR,
-/*TXT*/ XUNDEF, ERR, ERR, ERR, ERR, ERR,
-/*DAT*/ XUNDEF, ERR, ERR, ERR, ERR, ERR,
-/*BSS*/ XUNDEF, ERR, ERR, ERR, ERR, ERR,
-/*EXT*/ XUNDEF, ERR, ERR, ERR, ERR, ERR,
+/*UND*/ {XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF},
+/*ABS*/ {XUNDEF, XABS, ERR, ERR, ERR, ERR},
+/*TXT*/ {XUNDEF, ERR, ERR, ERR, ERR, ERR},
+/*DAT*/ {XUNDEF, ERR, ERR, ERR, ERR, ERR},
+/*BSS*/ {XUNDEF, ERR, ERR, ERR, ERR, ERR},
+/*EXT*/ {XUNDEF, ERR, ERR, ERR, ERR, ERR},
};
-struct exp *combine(op, exp1, exp2)
- reg struct exp *exp1, *exp2;
-{
- reg e1_type, e2_type;
- reg back_type;
+struct exp *combine(op, exp1, exp2) int op; register struct exp *exp1; register struct exp *exp2; {
+ register e1_type, e2_type;
+ register back_type;
char *btype = "The assembler can only do arithmetic on 1,2, or 4 byte integers";
lastnam=0; /* kludge for jxxx instructions */
return(exp1);
}
-buildtokensets()
-{
+void buildtokensets() {
#define clobber(val, set) tokensets[(val)] |= (set)
clobber(SEMI, LINSTBEGIN);
* themselves, and so that we may use the macros shift and shift over
*/
-extern int yylval; /*the value of the lexical value*/
+extern intptr_t yylval; /*the value of the lexical value*/
extern struct exp *xp; /*the next free expression slot*/
static inttoktype val;
/*
* return the value the read head is sitting on
*/
-inttoktype exprparse(inval, backexpr)
- inttoktype inval;
- struct exp **backexpr;
-{
- reg struct exp *lexpr;
+inttoktype exprparse(inval, backexpr) inttoktype inval; struct exp **backexpr; {
+ register struct exp *lexpr;
inttoktype op;
val = inval;
lexpr = boolterm();
while (INTOKSET(val, ADDOPS)){
op = val;
- shift;
+ val = yylex();
lexpr = combine(op, lexpr, boolterm());
}
*backexpr = lexpr;
return(val);
}
-struct exp *boolterm()
-{
- reg struct exp *lexpr;
+struct exp *boolterm() {
+ register struct exp *lexpr;
inttoktype op;
lexpr = term();
while(INTOKSET(val, BOOLOPS)){
op = val;
- shift;
+ val = yylex();
lexpr = combine(op, lexpr, term());
}
return(lexpr);
}
-struct exp *term()
-{
- reg struct exp *lexpr;
+struct exp *term() {
+ register struct exp *lexpr;
inttoktype op;
lexpr = factor();
while(INTOKSET(val, MULOPS)){
op = val;
- shift;
+ val = yylex();
lexpr = combine(op, lexpr, factor());
}
return(lexpr);
}
-struct exp *factor()
-{
+struct exp *factor() {
struct exp *lexpr;
inttoktype op;
extern int droppedLP; /*called exprparse after consuming an LP*/
if (droppedLP)
droppedLP = 0;
else
- shift; /*the LP*/
+ val = yylex(); /*the LP*/
val = exprparse(val, &lexpr);
if (val != RP)
yyerror("right parenthesis expected");
else
- shift;
+ val = yylex();
} else
if (INTOKSET(val, YUKKYEXPRBEG)){
lexpr = yukkyexpr(val, yylval);
- shift;
+ val = yylex();
}
else if (INTOKSET(val, SAFEEXPRBEG)){
lexpr = (struct exp *)yylval;
- shift;
+ val = yylex();
}
else if ( (val == TILDE) || (val == MINUS) ){
op = val;
- shift;
+ val = yylex();
lexpr = xp++;
lexpr->e_xtype = XABS;
lexpr->e_number = Znumber;
return(lexpr);
}
-struct exp *yukkyexpr(val, np)
- int val;
- reg np;
-{
- reg struct exp *locxp;
+struct exp *yukkyexpr(val, np) int val; register intptr_t np; {
+ register struct exp *locxp;
extern int exprisname; /*last factor is a name*/
int off = 0;
genref[yylval] = 1;
}
(void)sprintf(yytext, "L%d\001%d", yylval, lgensym[yylval] + off);
- yylval = np = (int)*lookup(passno == 1);
+ yylval = np = (intptr_t)*lookup(passno == 1);
lastnam = (struct symtab *)np;
/* FALLTHROUGH */
case NAME:
struct Tok_Desc *tok_name[LASTTOKEN - FIRSTTOKEN + 1];
struct Tok_Desc tok_desc[] = {
- FIRSTTOKEN, DIRECT, "first token",
-
- IBYTE, DIRECT, ".byte",
- IWORD, DIRECT, ".word",
- IINT, DIRECT, ".int",
- ILONG, DIRECT, ".long",
- IQUAD, DIRECT, ".quad",
- IOCTA, DIRECT, ".octa",
- IFFLOAT, DIRECT, ".ffloat",
- IDFLOAT, DIRECT, ".dfloat",
- IGFLOAT, DIRECT, ".gfloat",
- IHFLOAT, DIRECT, ".hfloat",
- IASCII, DIRECT, ".ascii",
- IASCIZ, DIRECT, ".asciz",
- IFILL, DIRECT, ".fill",
- ISPACE, DIRECT, ".space",
-
- IDATA, DIRECT, ".data",
- ITEXT, DIRECT, ".text",
- IGLOBAL, DIRECT, ".global",
- IALIGN, DIRECT, ".align",
-
- ISET, DIRECT, ".set",
- ICOMM, DIRECT, ".comm",
- ILCOMM, DIRECT, ".lcomm",
- IORG, DIRECT, ".org",
- ILSYM, DIRECT, ".lsym",
-
- ISTAB, DIRECT, ".stab",
- ISTABSTR, DIRECT, ".stabstr",
- ISTABNONE, DIRECT, ".stabnone",
- ISTABDOT, DIRECT, ".stabdot",
-
- IFILE, DIRECT, ".file",
- ILINENO, DIRECT, ".lineno",
- IABORT, DIRECT, ".abort",
-
- IJXXX, INSTR, "jump pseudo",
- INST0, INSTR, "0 argument inst",
- INSTn, INSTR, "n argument inst",
-
- PARSEEOF, CNTRL, "parse end of file",
- ILINESKIP, CNTRL, "skip lines",
- VOID, CNTRL, "void",
- SKIP, CNTRL, "skip",
- NL, CNTRL, "new line",
- SCANEOF, CNTRL, "scanner end of file",
- BADCHAR, CNTRL, "bad character",
- SH, CNTRL, "comment, #",
-
- INT, HUNK, "int",
- BFINT, HUNK, "local label",
- BIGNUM, HUNK, "big number",
- NAME, HUNK, "name",
- STRING, HUNK, "string",
- REG, HUNK, "register specifier",
-
- SIZESPEC, SMALL, "size specifier, [BWLbwl]",
- SIZEQUOTE, SMALL, "sizequote, [^']",
- LITOP, SMALL, "litop",
-
- MP, SMALL, "minus parenthesis, -(",
- REGOP, SMALL, "register operator, %",
-
- SP, SMALL, "space",
- ALPH, SMALL, "alphabetic character, [A-Za-z_]",
- DIG, SMALL, "digit character, [A-Fa-f0-9]",
-
- SQ, SMALL, "single quote, '",
- DQ, SMALL, "double quote, \"",
-
- LSH, SMALL, "arithmetic left shift, <",
- RSH, SMALL, "arithmetic right shift, >",
- XOR, SMALL, "exclusive or, ^",
-
- PLUS, SMALL, "plus, +",
- MINUS, SMALL, "minus, -",
- MUL, SMALL, "multiply, *",
- DIV, SMALL, "divide, /",
- SEMI, SMALL, "semi colon, ;",
- COLON, SMALL, "colon, :",
- IOR, SMALL, "inclusive or, |",
- AND, SMALL, "and, &",
-
- TILDE, SMALL, "one's complement, ~",
- ORNOT, SMALL, "ornot, !",
- CM, SMALL, "comma",
-
- LB, SMALL, "left bracket, [",
- RB, SMALL, "right bracket, ]",
- LP, SMALL, "left parenthesis, (",
- RP, SMALL, "right parentheis, )",
-
- LASTTOKEN, SMALL, "last token",
+ {FIRSTTOKEN, DIRECT, "first token"},
+
+ {IBYTE, DIRECT, ".byte"},
+ {IWORD, DIRECT, ".word"},
+ {IINT, DIRECT, ".int"},
+ {ILONG, DIRECT, ".long"},
+ {IQUAD, DIRECT, ".quad"},
+ {IOCTA, DIRECT, ".octa"},
+ {IFFLOAT, DIRECT, ".ffloat"},
+ {IDFLOAT, DIRECT, ".dfloat"},
+ {IGFLOAT, DIRECT, ".gfloat"},
+ {IHFLOAT, DIRECT, ".hfloat"},
+ {IASCII, DIRECT, ".ascii"},
+ {IASCIZ, DIRECT, ".asciz"},
+ {IFILL, DIRECT, ".fill"},
+ {ISPACE, DIRECT, ".space"},
+
+ {IDATA, DIRECT, ".data"},
+ {ITEXT, DIRECT, ".text"},
+ {IGLOBAL, DIRECT, ".global"},
+ {IALIGN, DIRECT, ".align"},
+
+ {ISET, DIRECT, ".set"},
+ {ICOMM, DIRECT, ".comm"},
+ {ILCOMM, DIRECT, ".lcomm"},
+ {IORG, DIRECT, ".org"},
+ {ILSYM, DIRECT, ".lsym"},
+
+ {ISTAB, DIRECT, ".stab"},
+ {ISTABSTR, DIRECT, ".stabstr"},
+ {ISTABNONE, DIRECT, ".stabnone"},
+ {ISTABDOT, DIRECT, ".stabdot"},
+
+ {IFILE, DIRECT, ".file"},
+ {ILINENO, DIRECT, ".lineno"},
+ {IABORT, DIRECT, ".abort"},
+
+ {IJXXX, INSTR, "jump pseudo"},
+ {INST0, INSTR, "0 argument inst"},
+ {INSTn, INSTR, "n argument inst"},
+
+ {PARSEEOF, CNTRL, "parse end of file"},
+ {ILINESKIP, CNTRL, "skip lines"},
+ {VOID, CNTRL, "void"},
+ {SKIP, CNTRL, "skip"},
+ {NL, CNTRL, "new line"},
+ {SCANEOF, CNTRL, "scanner end of file"},
+ {BADCHAR, CNTRL, "bad character"},
+ {SH, CNTRL, "comment, #"},
+
+ {INT, HUNK, "int"},
+ {BFINT, HUNK, "local label"},
+ {BIGNUM, HUNK, "big number"},
+ {NAME, HUNK, "name"},
+ {STRING, HUNK, "string"},
+ {REG, HUNK, "register specifier"},
+
+ {SIZESPEC, SMALL, "size specifier, [BWLbwl]"},
+ {SIZEQUOTE, SMALL, "sizequote, [^']"},
+ {LITOP, SMALL, "litop"},
+
+ {MP, SMALL, "minus parenthesis, -("},
+ {REGOP, SMALL, "register operator, %"},
+
+ {SP, SMALL, "space"},
+ {ALPH, SMALL, "alphabetic character, [A-Za-z_]"},
+ {DIG, SMALL, "digit character, [A-Fa-f0-9]"},
+
+ {SQ, SMALL, "single quote, '"},
+ {DQ, SMALL, "double quote, \""},
+
+ {LSH, SMALL, "arithmetic left shift, <"},
+ {RSH, SMALL, "arithmetic right shift, >"},
+ {XOR, SMALL, "exclusive or, ^"},
+
+ {PLUS, SMALL, "plus, +"},
+ {MINUS, SMALL, "minus, -"},
+ {MUL, SMALL, "multiply, *"},
+ {DIV, SMALL, "divide, /"},
+ {SEMI, SMALL, "semi colon, ;"},
+ {COLON, SMALL, "colon, :"},
+ {IOR, SMALL, "inclusive or, |"},
+ {AND, SMALL, "and, &"},
+
+ {TILDE, SMALL, "one's complement, ~"},
+ {ORNOT, SMALL, "ornot, !"},
+ {CM, SMALL, "comma"},
+
+ {LB, SMALL, "left bracket, ["},
+ {RB, SMALL, "right bracket, ]"},
+ {LP, SMALL, "left parenthesis, ("},
+ {RP, SMALL, "right parentheis, )"},
+
+ {LASTTOKEN, SMALL, "last token"}
};
/*
* turn a token type into a string
*/
-char *tok_to_name(token)
-{
+char *tok_to_name(token) int token; {
static int fixed = 0;
static char buf[64];
static struct Tok_Desc NA = {0, (char *)0, "NOT ASSIGNED"};
int i;
- char *cp;
if (!fixed){
for (i = FIRSTTOKEN; i <= LASTTOKEN; i++)
tok_name[i] = &NA;
- for (i = 0; i <= sizeof(tok_desc)/sizeof(struct Tok_Desc); i++){
+ for (i = 0; i < sizeof(tok_desc)/sizeof(struct Tok_Desc); i++){
tok_name[tok_desc[i].tok_which] = &tok_desc[i];
}
fixed = 1;
+#ifndef _ASEXPR_H_
+#define _ASEXPR_H_
+
+#ifdef __STDC__
+#include <stdarg.h>
+#endif
+#include "as.h"
+#include "asscan.h"
+/*#include "astoks.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
/*
* Functional forwards for expression utility routines
*/
-struct exp *combine();
-struct exp *boolterm();
-struct exp *term();
-struct exp *factor();
-struct exp *yukkyexpr();
+/*struct exp *combine();*/
+/*struct exp *boolterm();*/
+/*struct exp *term();*/
+/*struct exp *factor();*/
+/*struct exp *yukkyexpr();*/
/*
* The set definitions
#define INTOKSET(val, set) (tokensets[(val)] & (set) )
-inttoktype exprparse();
-inttoktype funnyreg();
-inttoktype yylex();
+/*inttoktype exprparse();*/
+/*inttoktype funnyreg();*/
+/*inttoktype yylex();*/
#define expr(xp, val) { \
if ( (!INTOKSET(val, EBEGOPS)) && (!INTOKSET(peekahead, ADDOPS+BOOLOPS+MULOPS))) { \
if (INTOKSET(val, YUKKYEXPRBEG)) xp = yukkyexpr(val, yylval); \
else xp = (struct exp *) yylval; \
- shift; \
+ val = yylex(); \
} else { \
val = exprparse(val, ptrloc1xp); \
xp = loc1xp; \
#define findreg(regno) \
if (val == REG) { \
regno = yylval; \
- shift; \
+ val = yylex(); \
} else \
if (val == REGOP) { \
- shift; /*over the REGOP*/ \
+ val = yylex(); /*over the REGOP*/ \
val = funnyreg(val, ptrregno); \
} \
else { ERROR ("register expected"); }
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* asexpr.c */
+struct exp *combine __P((int op, register struct exp *exp1, register struct exp *exp2));
+void buildtokensets __P((void));
+inttoktype exprparse __P((inttoktype inval, struct exp **backexpr));
+struct exp *boolterm __P((void));
+struct exp *term __P((void));
+struct exp *factor __P((void));
+struct exp *yukkyexpr __P((int val, register intptr_t np));
+char *tok_to_name __P((int token));
+
+/* asparse.c */
+void yyparse __P((void));
+inttoktype funnyreg __P((inttoktype val, int *regnoback));
+void shiftoerror __P((int token));
+void vyyerror __P((char *s, va_list argp));
+void yyerror __P((char *s, ...));
+void yywarning __P((char *s, ...));
+
+#endif
+#include <memory.h>
+#include <sys/file.h>
+/*#include <sys/types.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asio.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
/*
* Block I/O routines for logical I/O concurrently in
* more than one place in the same file.
#define error(severity, message) \
{yyerror(message); if (severity) delexit();}
-Flushfield(n)
- register int n;
-{
+void Flushfield(n) register int n; {
while (n>0) {
outb(bitfield);
bitfield >>= 8;
/*
* Block I/O Routines
*/
-bopen(bp, off)
- struct biobuf *bp;
- off_t off;
-{
+void bopen(bp, off) struct biobuf *bp; off_t off; {
bp->b_ptr = bp->b_buf = Calloc(1, biobufsize);
bp->b_nleft = biobufsize - (off % biobufsize);
int bwrerror;
-bwrite(p, cnt, bp)
- register char *p;
- register int cnt;
- register struct biobuf *bp;
-{
+void bwrite(p, cnt, bp) register char *p; register int cnt; register struct biobuf *bp; {
register int put;
register char *to;
to = bp->b_ptr;
#ifdef lint
*to = *to;
-#endif lint
-#ifdef __STDC__ /* this is a bit non-ideal, revisit later */
+#endif
+#ifdef X_
memcpy(to, p, put);
#else
asm("movc3 r8,(r11),(r7)");
goto top;
}
-bflush()
-{
+void bflush() {
register struct biobuf *bp;
if (bwrerror)
bflush1(bp);
}
-bflush1(bp)
- register struct biobuf *bp;
-{
+void bflush1(bp) register struct biobuf *bp; {
register int cnt = bp->b_ptr - bp->b_buf;
if (cnt == 0)
bp->b_nleft = biobufsize;
}
-bflushc(bp, c)
- register struct biobuf *bp;
- char c;
-{
+void bflushc(bp, c) register struct biobuf *bp; int c; {
bflush1(bp);
bputc(c, bp);
}
+/*#include <stdio.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+#include "assyms.h"
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asjxxx.c 5.2 (Berkeley) 6/19/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
-#include "assyms.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
+/*#include "assyms.h"*/
#define JBR 0x11
#define BRW 0x31
struct symtab *lastnam;
struct symtab *lastjxxx;
-initijxxx()
-{
+void initijxxx() {
jbrfsize = jxxxJUMP ? JBRJDELTA : JBRDELTA;
jxxxfsize = jxxxJUMP ? JXXXJDELTA : JXXXDELTA;
/*
/*
* Handle jxxx instructions
*/
-ijxout(opcode, ap, nact)
- struct Opcode opcode;
- struct arg *ap;
- int nact;
-{
+void ijxout(opcode, ap, nact) struct Opcode opcode; struct arg *ap; int nact; {
if (passno == 1){
/*
* READ THIS BEFORE LOOKING AT jxxxfix()
/*
* READ THIS AFTER LOOKING AT jxxxfix()
*/
- reg long oxvalue;
- reg struct exp *xp;
- reg struct symtab *tunnel;
- reg struct arg *aplast;
+ register long oxvalue;
+ register struct exp *xp;
+ register struct symtab *tunnel;
+ register struct arg *aplast;
struct Opcode nopcode;
aplast = ap + nact - 1;
}
}
-jalign(xp, sp)
- register struct exp *xp;
- register struct symtab *sp;
-{
+void jalign(xp, sp) register struct exp *xp; register struct symtab *sp; {
register int mask;
#ifdef DEBUG
static struct strdesc noname;
/*
* Pass 1.5, resolve jxxx instructions and .align in .text
*/
-jxxxfix()
-{
+void jxxxfix() {
register struct symtab *jumpfrom;
struct symtab **cojumpfrom, *ubjumpfrom;
register struct symtab *dest;
for (topono = 1, nchange = 1; nchange != 0; topono++){
#ifdef lint
topno = topno;
-#endif lint
+#endif
#ifdef DEBUG
if (debug)
printf("\nSegment %d, topo iteration %d\n",
* increased
*/
-jxxxbump(segno, starthint)
- int segno;
- struct symtab **starthint;
-{
+void jxxxbump(segno, starthint) int segno; struct symtab **starthint; {
register struct symtab **cosp, *sp;
register struct symtab *ub;
register int cum_bump;
+/*#include <ctype.h> gen.h*/
+#include <gen.h>
+/*#include <stdio.h> as.h*/
+/*#include <strings.h> gen.h*/
+/*#include <sys/exec.h> as.h*/
+#include <sys/file.h>
+/*#include <sys/proc.h> gen.h*/
+/*#include <sys/signal.h> gen.h*/
+#include <sys/stat.h>
+/*#include <sys/types.h> as.h*/
+#ifdef __STDC__
+#include <stdarg.h>
+#define _va_start(argp, arg) va_start(argp, arg)
+#else
+#include <varargs.h>
+#define _va_start(argp, arg) va_start(argp)
+#endif
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asscan.h" asexpr.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOCOPYRIGHT) && !defined(lint)
char copyright[] =
"@(#) Copyright (c) 1982 Regents of the University of California.\n\
All rights reserved.\n";
-#endif not lint
+#endif
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asmain.c 5.2 (Berkeley) 10/21/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include <varargs.h>
+/*#include <stdio.h>*/
+/*#include <ctype.h>*/
+/*#include <signal.h>*/
+/*#include <varargs.h>*/
-#include "as.h"
-#include "assyms.h"
-#include "asscan.h"
-#include "asexpr.h"
+/*#include "as.h"*/
+/*#include "assyms.h"*/
+/*#include "asscan.h"*/
+/*#include "asexpr.h"*/
-#include <sys/stat.h>
+/*#include <sys/stat.h>*/
#define unix_lang_name "VAX/UNIX Assembler V10/21/85 5.2"
/*
* We use relfil to output the symbol table information.
*/
char *tmpdirprefix = "/tmp/";
-int delexit();
+/*int delexit();*/
-main(argc, argv)
- int argc;
- char **argv;
-{
+int main(argc, argv) int argc; char **argv; {
void *sbrk();
tokfilename[0] = 0;
exit(anyerrs != 0);
}
-argprocess(argc, argv)
- int argc;
- char *argv[];
-{
+void argprocess(argc, argv) int argc; char *argv[]; {
register char *cp;
ninfiles = 0;
* segment (true, if one is using the new version of cmgt.crt0.c)
* b) that the sccsid's have not been put into text space.
*/
-selfwhat(place)
- FILE *place;
-{
+void selfwhat(place) FILE *place; {
extern char **environ;
register char *ub;
register char *cp;
- register char *pat;
void *sbrk();
for (cp = (char *)&environ, ub = sbrk(0); cp < ub; cp++){
}
}
-initialize()
-{
+void initialize() {
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- signal(SIGINT, delexit);
+ signal(SIGINT, (void (*) __P((int sig)))delexit);
/*
* Install symbols in the table
*/
buildtokensets();
}
-zeroorigins()
-{
+void zeroorigins() {
register int locindex;
/*
* Mark usedot: the first NLOC slots are for named text segments,
}
}
-zerolocals()
-{
+void zerolocals() {
register int i;
for (i = 0; i <= 9; i++) {
}
}
-i_pass1()
-{
+void i_pass1() {
FILE *tempopen();
if (useVM == 0)
tokfile = tempopen(tokfilename, "T");
initijxxx();
}
-FILE *tempopen(tname, part)
- char *tname;
- char *part;
-{
+FILE *tempopen(tname, part) char *tname; char *part; {
FILE *file;
sprintf(tname, "%s%sas%s%05d",
tmpdirprefix,
return(file);
}
-pass1()
-{
+void pass1() {
register int i;
passno = 1;
closetokfile(); /*kick out the last buffered intermediate text*/
}
-testlocals()
-{
+void testlocals() {
register int i;
for (i = 0; i <= 9; i++) {
if (genref[i])
}
}
-pass1_5()
-{
+void pass1_5() {
sortsymtab();
#ifdef DEBUG
if (debug) dumpsymtab();
#endif
}
-open_a_out()
-{
+void open_a_out() {
struct stat stb;
/*
a_out_off = 0;
}
-roundsegments()
-{
+void roundsegments() {
register int locindex;
register long v;
/*
}
}
-build_hdr()
-{
+void build_hdr() {
/*
* Except for the text and data relocation sizes,
* calculate the final values for the header
bwrite((char *)&hdr, sizeof(hdr), usefile[0]);
}
-i_pass2()
-{
+void i_pass2() {
if (useVM == 0) {
fclose(tokfile);
tokfile = fopen(tokfilename, "r");
strfile = fopen(strfilename, "r");
}
-pass2()
-{
+void pass2() {
#ifdef DEBUG
if (debug)
printf("\n\n\n\t\tPASS 2\n\n\n\n");
-#endif DEBUG
+#endif
passno = 2;
lineno = 1;
dotp = &usedot[0];
closetokfile();
}
-fillsegments()
-{
+void fillsegments() {
int locindex;
/*
* Round text and data segments to FW by appending zeros
}
}
-reloc_syms()
-{
+void reloc_syms() {
u_long closerelfil();
/*
* Move the relocation information to a.out
symwrite(relocfile);
}
-fix_a_out()
-{
+void fix_a_out() {
if (lseek(a_out_file->_file, 0L, 0) < 0L)
yyerror("Reposition for header rewrite fails");
if (write(a_out_file->_file, (char *)&hdr, sizeof (struct exec)) < 0)
yyerror("Rewrite of header fails");
}
-delexit()
-{
+int delexit() {
delete();
if (passno == 2){
unlink(outfile);
exit(1);
}
-delete()
-{
+void delete() {
if (useVM == 0 || tokfilename[0])
unlink(tokfilename);
if (strfilename[0])
unlink(strfilename);
}
-sawabort()
-{
+int sawabort() {
#if 0 /* I don't see why this is necessary... and fillinbuffer() is now void */
char *fillinbuffer();
while (fillinbuffer() != (char *)0)
exit(1); /*although the previous pass will also exit non zero*/
}
-panic(fmt, va_alist)
- char *fmt;
- va_dcl
+#ifdef __STDC__
+int panic(char *fmt, ...)
+#else
+int panic(fmt, va_alist) char *fmt; va_dcl
+#endif
{
va_list argp;
yyerror("Assembler panic: bad internal data structure.");
- va_start(argp);
+ _va_start(argp, fmt);
vyyerror(fmt, argp);
va_end(argp);
delete();
+#ifndef _ASNUMBER_H_
+#define _ASNUMBER_H_
+
+#include <sys/types.h>
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
#define MAXINT_1 ((unsigned)(1<<(CH_BITS - 1)))
#define MAXINT_10 ((unsigned)((MAXINT_1/(unsigned)10)))
#define MAXINT_5 ((unsigned)((MAXINT_1/(unsigned)5)))
-#else not 0
+#else
/*
* These values were computed using dc, so are exact.
* Only MAXINT_10 and MAXINT_5 are used in the programs.
#define MAXINT_1 2147483648
#define MAXINT_10 214748364
#define MAXINT_5 429496729
-#endif not 0
-
-Bignum as_atoi(); /* converts string to integer */
-Bignum as_atof(); /* converts string to float */
-Bignum bigatof(); /* converts string to float */
-Bignum floatconvert(); /* converts amongst float #s */
-Bignum intconvert(); /* converts amongst float #s */
-Bignum bignumconvert(); /* converts amongst float #s */
-Bignum bignumpack(); /* converts UNPACKED bignum to bignum */
-Bignum bignumunpack(); /* converts bignum to UNPACKED bignum */
+#endif
+
+/*Bignum as_atoi();*/ /* converts string to integer */
+/*Bignum as_atof();*/ /* converts string to float */
+/*Bignum bigatof();*/ /* converts string to float */
+/*Bignum floatconvert();*/ /* converts amongst float #s */
+/*Bignum intconvert();*/ /* converts amongst float #s */
+/*Bignum bignumconvert();*/ /* converts amongst float #s */
+/*Bignum bignumpack();*/ /* converts UNPACKED bignum to bignum */
+/*Bignum bignumunpack();*/ /* converts bignum to UNPACKED bignum */
\f
/*
* Definitions for overflows.
#define OVF_OVERFLOW (1<<9) /* overflow in conversion */
#define OVF_UNDERFLOW (1<<10) /* underflow in conversion */
-Ovf posovf();
-Ovf numclear();
-Ovf numshift();
-Ovf numaddv();
-Ovf numaddd();
-Ovf num1comp();
-Ovf numnegate();
+/*Ovf posovf();*/
+/*Ovf numclear();*/
+/*Ovf numshift();*/
+/*Ovf numaddv();*/
+/*Ovf numaddd();*/
+/*Ovf num1comp();*/
+/*Ovf numnegate();*/
\f
/*
* Definitions to unpack big numbers numbers into
* Bit manipulations
*/
#define ONES(n) ((1 << (n)) - 1)
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* bignum1.c */
+Bignum as_atof __P((char *numbuf, int radix, Ovf *ovfp));
+Bignum as_atoi __P((register char *ccp, int radix, Ovf *ovfp));
+Ovf posovf __P((register chptr src));
+int isclear __P((register chptr dst));
+int isunequal __P((register chptr src1, register chptr src2));
+Ovf numclear __P((register chptr dst));
+Ovf numshift __P((int n, register chptr dst, register chptr src));
+Ovf numaddd __P((chptr dst, chptr src1, int val));
+Ovf numaddv __P((register chptr dst, register chptr src1, register chptr src2));
+Ovf numnegate __P((chptr dst, chptr src));
+Ovf num1comp __P((register chptr dst, register chptr src));
+int slitflt __P((Bignum number, int argtype, int *valuep));
+void bignumwrite __P((Bignum number, int toconv));
+
+/* bignum2.c */
+Bignum intconvert __P((Bignum number, int convto));
+Bignum floatconvert __P((Bignum number, int convto));
+Bignum bignumconvert __P((Bignum number, int toconv, Ovf *ovfp));
+Bignum bignumunpack __P((Bignum Packed, Ovf *ovfp));
+Bignum bignumpack __P((Bignum Unpacked, int toconv, Ovf *ovfp));
+void mapnumber __P((chptr chp1, chptr chp2, int nbytes, char *themap));
+int upround __P((register Bignum *numberp, register struct ty_bigdesc *p, int exponent));
+int bignumprint __P((Bignum number));
+int numprintovf __P((Ovf ovf));
+
+/* natof.c */
+Bignum bigatof __P((register char *str, int radix));
+unsigned int ediv __P((register unsigned int high, register unsigned int low, register unsigned int divisor, unsigned int *qp, int i));
+
+#endif
+#include <memory.h>
+#include <stab.h>
+/*#include <stdio.h> as.h*/
+#ifdef __STDC__
+#include <stdarg.h>
+#define _va_start(argp, arg) va_start(argp, arg)
+#else
+#include <varargs.h>
+#define _va_start(argp, arg) va_start(argp)
+#endif
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "asscan.h" asexpr.h*/
+#include "assyms.h"
+/*#include "astoks.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asparse.c 5.2 (Berkeley) 6/19/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include <varargs.h>
-#include "as.h"
-#include "asscan.h"
-#include "assyms.h"
-#include "asexpr.h"
+/*#include <stdio.h>*/
+/*#include <varargs.h>*/
+/*#include "as.h"*/
+/*#include "asscan.h"*/
+/*#include "assyms.h"*/
+/*#include "asexpr.h"*/
int lgensym[10];
char genref[10];
/*shifted. (Used to parse (<expr>)(rn)*/
char yytext[NCPName+2]; /*the lexical image*/
-int yylval; /*the lexical value; sloppy typing*/
+intptr_t yylval; /*the lexical value; sloppy typing*/
struct Opcode yyopcode; /* lexical value for an opcode */
Bignum yybignum; /* lexical value for a big number */
/*
static char UDotsname[64]; /*name of the assembly source*/
-yyparse()
-{
- reg struct exp *locxp;
+void yyparse() {
+ register struct exp *locxp;
/*
* loc1xp and ptrloc1xp are used in the
* expression lookahead
struct exp **ptrloc1xp = & loc1xp;
struct exp *pval; /*hacking expr:expr*/
- reg struct symtab *np;
- reg int argcnt;
+ register struct symtab *np;
+ register int argcnt;
- reg inttoktype val; /*what yylex gives*/
- reg inttoktype auxval; /*saves val*/
+ register inttoktype val; /*what yylex gives*/
+ register inttoktype auxval; /*saves val*/
- reg struct arg *ap; /*first free argument*/
+ register struct arg *ap; /*first free argument*/
- reg struct symtab *p;
- reg struct symtab *stpt;
+ register struct symtab *p;
+ register struct symtab *stpt;
struct strdesc *stringp; /*handles string lists*/
int field_width; /*how wide a field is to be*/
int field_value; /*the value to stuff in a field*/
char *stabname; /*name of stab dealing with*/
- ptrall stabstart; /*where the stab starts in the buffer*/
+ void *stabstart; /*where the stab starts in the buffer*/
int reloc_how; /* how to relocate expressions */
int toconv; /* how to convert bignums */
int incasetable; /* set if in a case table */
while (INTOKSET(val, LINSTBEGIN)){
if (val == INT) {
int i = ((struct exp *)yylval)->e_xvalue;
- shift;
+ val = yylex();
if (val != COLON){
yyerror("Local label %d is not followed by a ':' for a label definition",
i);
(void)sprintf(yytext, "L%d\001%d", i, lgensym[i]);
lgensym[i]++;
genref[i] = 0;
- yylval = (int)*lookup(passno == 1);
+ yylval = (intptr_t)*lookup(passno == 1);
val = NAME;
np = (struct symtab *)yylval;
goto restlab;
}
if (val == NL){
lineno++;
- shift;
+ val = yylex();
} else
if (val == SEMI)
- shift;
+ val = yylex();
else { /*its a name, so we have a label or def */
if (val != NAME){
ERROR("Name expected for a label");
goto errorfix;
}
restlab:
- shift;
+ val = yylex();
flushfield(NBWD/4);
if ((np->s_type&XTYPE)!=XUNDEF) {
if ( (np->s_type&XTYPE) != dotp->e_xtype
ERROR("Unrecognized instruction or directive");
case IABORT:
- shift;
+ val = yylex();
sawabort();
/*NOTREACHED*/
break;
break;
case IFILE:
- shift;
+ val = yylex();
stringp = (struct strdesc *)yylval;
shiftover(STRING);
dotsname = &UDotsname[0];
- movestr(dotsname, stringp->sd_string,
+ memcpy(dotsname, stringp->sd_string,
min(stringp->sd_strlen, sizeof(UDotsname)));
break;
case ILINENO:
- shift; /*over the ILINENO*/
+ val = yylex(); /*over the ILINENO*/
expr(locxp, val);
lineno = locxp->e_xvalue;
break;
case ISET: /* .set <name> , <expr> */
- shift;
+ val = yylex();
np = (struct symtab *)yylval;
shiftover(NAME);
shiftover(CM);
break;
case ILSYM: /*.lsym name , expr */
- shift;
+ val = yylex();
np = (struct symtab *)yylval;
shiftover(NAME);
shiftover(CM);
break;
case IGLOBAL: /*.globl <name> */
- shift;
+ val = yylex();
np = (struct symtab *)yylval;
shiftover(NAME);
np->s_type |= XXTRN;
case IDATA: /*.data [ <expr> ] */
case ITEXT: /*.text [ <expr> ] */
seg_type = -val;
- shift;
+ val = yylex();
if (INTOKSET(val, EBEGOPS+YUKKYEXPRBEG+SAFEEXPRBEG)){
expr(locxp, val);
seg_type = -seg_type; /*now, it is positive*/
elist:
seg_type = val;
- shift;
+ val = yylex();
/*
* Expression List processing
}
xp = explist;
if (auxval = (val == CM))
- shift;
+ val = yylex();
} while (auxval);
} /* there existed an expression at all */
/*end of case IBYTE, IWORD, ILONG, IINT*/
case ISPACE: /* .space <expr> */
- shift;
+ val = yylex();
expr(locxp, val);
if ((locxp->e_xtype & XTYPE) != XABS) /* tekmdp */
yyerror("Space size not absolute");
space_value = locxp->e_xvalue;
ospace:
- flushfield(NBWD/4);
- {
+ flushfield(NBWD/4); {
static char spacebuf[128];
while (space_value > sizeof(spacebuf)){
outs(spacebuf, sizeof(spacebuf));
* size must be between 1 and 8
*/
case IFILL:
- shift;
+ val = yylex();
expr(locxp, val);
if ( (locxp->e_xtype & XTYPE) != XABS) /* tekmdp */
yyerror("Fill repetition count not absolute");
case IASCII: /* .ascii [ <stringlist> ] */
case IASCIZ: /* .asciz [ <stringlist> ] */
auxval = val;
- shift;
+ val = yylex();
/*
* Code to consume a string list
*
} else {
dotp->e_xvalue += mystrlen;
}
- shift; /*over the STRING*/
+ val = yylex(); /*over the STRING*/
if (val == CM) /*could be a split string*/
- shift;
+ val = yylex();
}
break;
case IORG: /* .org <expr> */
- shift;
+ val = yylex();
expr(locxp, val);
if ((locxp->e_xtype & XTYPE) == XABS) /* tekmdp */
* so that we can resolve its final value
*/
stabstart = tokptr;
- shift; /*over the ISTABDOT*/
+ val = yylex(); /*over the ISTABDOT*/
if (passno == 1){
expr(locxp, val);
if (! (locxp->e_xvalue & STABTYPS)){
stabstart = tokptr;
*(bytetoktype **)&stabstart -= sizeof(struct symtab *);
*(bytetoktype **)&stabstart -= sizeof(bytetoktype);
- shift;
+ val = yylex();
if (auxval == ISTABSTR){
stringp = (struct strdesc *)yylval;
shiftover(STRING);
case ICOMM: /* .comm <name> , <expr> */
case ILCOMM: /* .lcomm <name> , <expr> */
auxval = val;
- shift;
+ val = yylex();
np = (struct symtab *)yylval;
shiftover(NAME);
shiftover(CM);
case IALIGN: /* .align <expr> */
stpt = (struct symtab *)yylval;
- shift;
+ val = yylex();
expr(locxp, val);
jalign(locxp, stpt);
break;
case INST0: /* instructions w/o arguments*/
incasetable = 0;
insout(yyopcode, (struct arg *)0, 0);
- shift;
+ val = yylex();
break;
case INSTn: /* instructions with arguments*/
ap = arglist;
xp = explist;
- shift; /* bring in the first token for the arg list*/
+ val = yylex(); /* bring in the first token for the arg list*/
for (argcnt = 1; argcnt <= 6; argcnt++, ap++){
/*
* code to process an argument proper
*/
- sawindex = sawmul = sawsize = 0;
- {
+ sawindex = sawmul = sawsize = 0; {
switch(val) {
default:
case SIZESPEC:
sizespec:
sawsize = yylval;
- shift;
+ val = yylex();
goto disp;
case REG:
case MUL:
sawmul = 1;
- shift;
+ val = yylex();
if (val == LP) goto base;
if (val == LITOP) goto imm;
if (val == SIZESPEC) goto sizespec;
case LP:
base:
- shift; /*consume the LP*/
+ val = yylex(); /*consume the LP*/
/*
* hack the ambiguity of
* movl (expr) (rn), ...
findreg(regno);
shiftover(RP);
if (val == PLUS){
- shift;
+ val = yylex();
ap->a_atype = AINCR;
} else
ap->a_atype = ABASE;
case LITOP:
imm:
- shift;
+ val = yylex();
expr(locxp, val);
ap->a_atype = AIMM;
ap->a_areg1 = 0;
goto index;
case MP:
- shift; /* -(reg) */
+ val = yylex(); /* -(register) */
findreg(regno);
shiftover(RP);
ap->a_atype = ADECR;
ap->a_areg1 = regno;
- index: /*look for [reg] */
+ index: /*look for [register] */
if (val == LB){
- shift;
+ val = yylex();
findreg(regno);
shiftover(RB);
sawindex = 1;
* The value of the numbers is coming back
* as an expression, NOT in yybignum.
*/
- shift; /* over the opener */
+ val = yylex(); /* over the opener */
if ((val == BIGNUM) || (val == INT)){
do{
if ((val != BIGNUM) && (val != INT)){
toconv);
}
xp = explist;
- shift; /* over this number */
+ val = yylex(); /* over this number */
if (auxval = (val == CM))
- shift; /* over the comma */
+ val = yylex(); /* over the comma */
} while (auxval); /* as long as there are commas */
}
break;
&& (val != SEMI)
&& (val != PARSEEOF)
){
- shift;
+ val = yylex();
}
if (val == NL)
lineno++;
- shift;
+ val = yylex();
} /*end of the loop to read the entire file, line by line*/
* the digit, the scanner wouldn't have recognized it, so we
* hack it out here.
*/
-inttoktype funnyreg(val, regnoback) /*what the read head will sit on*/
- inttoktype val; /*what the read head is sitting on*/
- int *regnoback; /*call by return*/
-{
- reg struct exp *locxp;
+inttoktype funnyreg(val, regnoback) /*what the read head will sit on*/ inttoktype val; /*what the read head is sitting on*/ int *regnoback; /*call by return*/ {
+ register struct exp *locxp;
struct exp *loc1xp;
struct exp **ptrloc1xp = & loc1xp;
/*
* Shift over error
*/
-shiftoerror(token)
- int token;
-{
+void shiftoerror(token) int token; {
char *tok_to_name();
yyerror("%s expected", tok_to_name(token));
}
-vyyerror(s, argp)
- char *s;
- va_list argp;
-{
+void vyyerror(s, argp) char *s; va_list argp; {
if (anyerrs == 0 && anywarnings == 0 && ! silent)
printf("Assembler:\n");
anyerrs++;
printf("\n");
}
-yyerror(s, va_alist)
- char *s;
- va_dcl
+#ifdef __STDC__
+void yyerror(char *s, ...)
+#else
+void yyerror(s, va_alist) char *s; va_dcl
+#endif
{
va_list argp;
- va_start(argp);
+ _va_start(argp, s);
vyyerror(s, argp);
va_end(argp);
}
-yywarning(s, va_alist)
- char *s;
- va_dcl
+#ifdef __STDC__
+void yywarning(char *s, ...)
+#else
+void yywarning(s, va_alist) char *s; va_dcl
+#endif
{
va_list argp;
if (silent)
return;
printf("\"%s\", line %d: WARNING: ", dotsname, lineno);
- va_start(argp);
+ _va_start(argp, s);
vprintf(s, argp);
va_end(argp);
printf("\n");
+#include "as.h"
+#include "asscan.h"
+/*#include "astoks.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)aspseudo.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
#define OP(name, eopcode, popcode, nargs, arg1, arg2, arg3, arg4, arg5, arg6) \
{ \
- name, popcode, nargs, arg1, arg2, arg3, arg4, arg5, arg6, \
- (nargs == 0 ? INST0:INSTn), eopcode \
+ name, popcode, nargs, {arg1, arg2, arg3, arg4, arg5, arg6}, \
+ (nargs == 0 ? INST0:INSTn), eopcode, {0, 0} \
}
#define PSEUDO(name, type, tag) \
{ \
- name, type, 0, 0, 0, 0, 0, 0, 0, \
- tag, CORE \
+ name, type, 0, {0, 0, 0, 0, 0, 0}, \
+ tag, CORE, {0, 0} \
}
-readonly struct Instab instab[] = {
+struct Instab instab[] = {
#include "instrs.as"
PSEUDO("\0\0\0\0\0\0\0\0\0\0", 0, 0)
};
+#ifndef _ASSCAN_H_
+#define _ASSCAN_H_
+
+/*#include <sys/types.h> asnumber.h*/
+#include "asnumber.h"
+
+#ifdef __STDC__
+#include <stdint.h>
+#else
+typedef int intptr_t;
+#endif
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
/*
* defintions for putting various typed values
* into the intermediate buffers
- * ptr will ALWAYS be of type ptrall
+ * ptr will ALWAYS be of type void *
*/
#define pchar(ptr,val) (*(*(char **)&(ptr))++ = (val))
#define pnumber(ptr,val) (*(*(Bignum **)&(ptr))++ = (val))
#define popcode(ptr,val) (*(*(struct Opcode **)&(ptr))++ = (val))
-#define pptr(ptr,val) (*(*(int **)&(ptr))++ = (val))
+#define pptr(ptr,val) (*(*(intptr_t **)&(ptr))++ = (val))
#define ptoken(ptr,val) (*(*(char **)&(ptr))++ = (val))
#define pskiplg(ptr,val) (*(*(lgtype **)&(ptr))++ = (val))
#define gnumber(val, ptr) ((val) = *(*(Bignum **)&(ptr))++)
#define gopcode(val, ptr) ((val) = *(*(struct Opcode **)&(ptr))++)
-#define gptr(val, ptr) ((val) = *(*(int **)&(ptr))++)
+#define gptr(val, ptr) ((val) = *(*(intptr_t **)&(ptr))++)
#define gtoken(val, ptr) ((val) = *(*(char **)&(ptr))++)
#define gskiplg(val, ptr) ((val) = *(*(lgtype **)&(ptr))++)
-extern ptrall tokptr; /*the next token to consume, call by copy*/
-extern ptrall tokub; /*current upper bound in the current buffer*/
+extern void *tokptr; /*the next token to consume, call by copy*/
+extern void *tokub; /*current upper bound in the current buffer*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* asscan1.c */
+void inittokfile __P((void));
+void closetokfile __P((void));
+inttoktype yylex __P((void));
+void buildskip __P((void *from, void *to));
+void new_dot_s __P((char *namep));
+int min __P((int a, int b));
+
+/* asscan2.c */
+void fillinbuffer __P((void));
+void scan_dot_s __P((struct tokbufdesc *bufferbox));
+
+/* asscan4.c */
+int number __P((register int ch));
+Bignum floatnumber __P((int fltradix));
+int scanint __P((int signOK, char **dstcpp));
+
+#endif
+/*#include <stdio.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "asscan.h" asexpr.h*/
+#include "asscanl.h"
+/*#include "astoks.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asscan1.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include "asscanl.h"
+/*#include "asscanl.h"*/
/* moved here from asscanl.h: */
struct tokbufdesc *bufstart; /*where the buffer list begins*/
int bufno; /*which buffer number: 0,1 for tmp file*/
struct tokbufdesc tokbuf[2]; /*our initial increment of buffers*/
-ptrall tokptr; /*where the current token comes from*/
-ptrall tokub; /*the last token in the current token buffer*/
+void *tokptr; /*where the current token comes from*/
+void *tokub; /*the last token in the current token buffer*/
#ifdef DEBUG
-ptrall firsttoken;
-#endif DEBUG
+void *firsttoken;
+#endif
-int yylval; /* normal semantic value */
+intptr_t yylval; /* normal semantic value */
Bignum yybignum; /* a big number */
struct Opcode yyopcode; /* a structure opcode */
char *newfname;
int scanlineno; /*the scanner's linenumber*/
-inittokfile()
-{
+void inittokfile() {
if (passno == 1){
if (useVM){
bufstart = &tokbuf[0];
tokub = 0;
}
-closetokfile()
-{
+void closetokfile() {
if (passno == 1){
if (useVM){
emptybuf->toks[emptybuf->tok_count++] = PARSEEOF;
} /*end of being pass 1*/
}
-inttoktype yylex()
-{
- register ptrall bufptr;
+inttoktype yylex() {
+ void *bufptr;
register inttoktype val;
register struct exp *locxp;
/*
* No local variables to be allocated; this saves
* one piddling instruction..
*/
- static int Lastjxxx;
+ static intptr_t Lastjxxx;
bufptr = tokptr; /*copy in the global value*/
top:
locxp->e_xtype = XABS;
locxp->e_xloc = 0;
locxp->e_xname = NULL;
- yylval = (int)locxp;
+ yylval = (intptr_t)locxp;
break;
case BIGNUM:
if (xp >= &explist[NEXP])
} /*end of the debug switch*/
printf("\n");
}
-#endif DEBUG
+#endif
} else { /* start a new buffer */
if (useVM){
if (debug)
printf("created buffernumber %d with %d tokens\n",
bufno, emptybuf->tok_count);
-#endif DEBUG
+#endif
goto top;
} /*end of reading/creating a new buffer*/
tokptr = bufptr; /*copy back the global value*/
return(val);
} /*end of yylex*/
-
-buildskip(from, to)
- register ptrall from, to;
-{
+void buildskip(from, to) void *from; void *to; {
int diff;
register struct tokbufdesc *middlebuf;
/*
}
}
-new_dot_s(namep)
- char *namep;
-{
+void new_dot_s(namep) char *namep; {
newfflag = 1;
newfname = namep;
dotsname = namep;
scanlineno = 1;
}
-min(a, b)
-{
+int min(a, b) int a; int b; {
return(a < b ? a : b);
}
+/*#include <stdio.h> as.h*/
+#include <strings.h>
+/*#include <sys/file.h> asscanl.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asscan.h" asexpr.h*/
+#include "asscanl.h"
+/*#include "astoks.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asscan2.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include "asscanl.h"
+/*#include "asscanl.h"*/
static inttoktype oval = NL;
#define ASINBUFSIZ 4096
int Ginbufcnt = 0;
int scannerhadeof;
-fillinbuffer()
-{
+void fillinbuffer() {
int nread;
int goal;
int got;
Ginbufptr = inbuffer + 1;
}
-scan_dot_s(bufferbox)
- struct tokbufdesc *bufferbox;
-{
- reg char *inbufptr;
- reg int inbufcnt;
- reg int ryylval; /* local copy of lexical value */
- extern int yylval; /* global copy of lexical value */
- reg int val; /* the value returned */
+void scan_dot_s(bufferbox) struct tokbufdesc *bufferbox; {
+ register char *inbufptr;
+ register int inbufcnt;
+ register intptr_t ryylval; /* local copy of lexical value */
+ extern intptr_t yylval; /* global copy of lexical value */
+ register int val; /* the value returned */
int i; /* simple counter */
- reg char *rcp;
+ register char *rcp;
int ch; /* treated as a character */
int ch1; /* shadow value */
struct symtab *op;
- ptrall lgbackpatch; /* where to stuff a string length */
- reg ptrall bufptr; /* where to stuff tokens */
- ptrall bufub; /* where not to stuff tokens */
+ void *bufptr; /* where to stuff tokens */
+ void *bufub; /* where not to stuff tokens */
long intval; /* value of int */
int linescrossed; /* when doing strings and comments */
struct Opcode opstruct;
- reg int strlg; /* the length of a string */
+ register int strlg; /* the length of a string */
*(bytetoktype **)&bufptr = (bytetoktype *) & (bufferbox->toks[0]);
*(bytetoktype **)&bufub = &(bufferbox->toks[AVAILTOKS]);
MEMTOREGBUF;
if (newfflag){
newfflag = 0;
- ryylval = (int)savestr(newfname, strlen(newfname)+1, STR_BOTH);
+ ryylval = (intptr_t)savestr(newfname, strlen(newfname)+1, STR_BOTH);
ptoken(bufptr, IFILE);
ptoken(bufptr, STRING);
/*
* Its a name... (Labels are subsets of name)
*/
- ryylval = (int)op;
+ ryylval = (intptr_t)op;
val = NAME;
break;
case INST0:
* the trailing null, the client can just change STRLEN
*/
putc(0, strfile);
- ryylval = (int)savestr((char *)0, strlg + 1, STR_FILE);
+ ryylval = (intptr_t)savestr((char *)0, strlg + 1, STR_FILE);
val = STRING;
((struct strdesc *)ryylval)->sd_strlen -= 1;
goto ret;
break;
case BIGNUM: pnumber(bufptr, yybignum);
break;
- case STRING: pptr(bufptr, (int)(char *)ryylval);
+ case STRING: pptr(bufptr, ryylval);
break;
- case NAME: pptr(bufptr, (int)(struct symtab *)ryylval);
+ case NAME: pptr(bufptr, ryylval);
break;
case REG: pchar(bufptr, ryylval);
break;
break;
case IJXXX:
popcode(bufptr, opstruct);
- pptr(bufptr, (int)(struct symtab *)symalloc());
+ pptr(bufptr, (intptr_t)symalloc());
break;
case ISTAB:
case ISTABSTR:
case ISTABNONE:
case ISTABDOT:
case IALIGN:
- pptr(bufptr, (int)(struct symtab *)symalloc());
+ pptr(bufptr, (intptr_t)symalloc());
break;
/*
* default:
*/
}
- builtval: ;
} /*end of the while to stuff the buffer*/
done:
bufferbox->tok_count = (bytetoktype *)bufptr - &(bufferbox->toks[0]);
+#include "asscanl.h"
+/*#include "astoks.h" asscanl.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asscan3.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include "asscanl.h"
+/*#include "asscanl.h"*/
-readonly short type[] = {
+short type[] = {
/*hit the hard end of file*/ SCANEOF,
/* '^@' 0x00 0000 */ SP,
0
};
-readonly short charsets[] = {
+short charsets[] = {
/* '^@' 0x00 0000 */ 0,
/* '^A' 0x01 0001 */ 0,
/* '^B' 0x02 0002 */ 0,
+/*#include <stdio.h> asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" asexpr.h*/
+/*#include "asscan.h" asexpr.h*/
+#include "asscanl.h"
+/*#include "astoks.h" asexpr.h*/
+/*#include "instrs.h" asexpr.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)asscan4.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include "asscanl.h"
+/*#include "asscanl.h"*/
#define NUMSIZE 128 /* how many characters long a number can be */
#define FLTCHAR(x) (INCHARSET((x),(DIGIT|SIGN|FLOATEXP|POINT)))
#define BACK(backval) intval = backval; goto stuffback;
-int number(ch)
- reg int ch;
-{
+int number(ch) register int ch; {
int radix;
int digit; /* part of number being constructed */
- reg int intval; /* number being constructed */
- reg char *cp;
- reg char *inbufptr;
- reg int inbufcnt;
+ register int intval; /* number being constructed */
+ register char *cp;
+ register char *inbufptr;
+ register int inbufcnt;
char ch1;
Bignum floatnumber();
Ovf overflow; /* overflow flag */
ch = getchar(); \
TOOLONG;
-Bignum floatnumber(fltradix)
- int fltradix;
-{
+Bignum floatnumber(fltradix) int fltradix; {
char *cp;
int ch;
char *toolong = "Floating number too long.";
Ovf overflow;
int error;
int fractOK;
- reg char *inbufptr;
- reg int inbufcnt;
+ register char *inbufptr;
+ register int inbufcnt;
MEMTOREGBUF;
cp = numbuf;
* Scan an optionally signed integer, putting back the lookahead
* character when finished scanning.
*/
-int scanint(signOK, dstcpp)
- int signOK;
- char **dstcpp;
-{
+int scanint(signOK, dstcpp) int signOK; char **dstcpp; {
int ch;
int back = 0;
- reg char *inbufptr;
- reg int inbufcnt;
+ register char *inbufptr;
+ register int inbufcnt;
MEMTOREGBUF;
ch = getchar();
+#ifndef _ASSCANL_H_
+#define _ASSCANL_H_
+
+/*#include <stdio.h> as.h*/
+#include <sys/file.h>
+#include "as.h"
+/*#include "asnumber.h" as.h*/
+#include "asscan.h"
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* assembler.
* The file ``asscan.h'' is shared with other parts of the assembler
*/
-#include <stdio.h>
-#include "as.h"
-#include "asscan.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
+/*#include "asscan.h"*/
#define EOFCHAR (-1)
/*
*/
extern int bufno; /*which buffer number: 0,1 for tmp file*/
extern struct tokbufdesc tokbuf[2]; /*our initial increment of buffers*/
-extern ptrall tokptr; /*where the current token comes from*/
-extern ptrall tokub; /*the last token in the current token buffer*/
+extern void *tokptr; /*where the current token comes from*/
+extern void *tokub; /*the last token in the current token buffer*/
/*
* as does not use fread and fwrite for the token buffering.
* The token buffers are integrals of BUFSIZ
*(bytetoktype **)&from += sizeof(lgtype) + *(lgtype *)from
#ifdef DEBUG
-extern ptrall firsttoken;
-#endif DEBUG
+extern void *firsttoken;
+#endif
/*
* The following three variables are the slots for global
* They are the semantic values associated with a particular token.
* The token itself is the return value from yylex()
*/
-extern int yylval; /* normal semantic value */
+extern intptr_t yylval; /* normal semantic value */
extern Bignum yybignum; /* a big number */
extern struct Opcode yyopcode; /* a structure opcode */
/*
* Definitions for sets of characters
*/
-extern readonly short charsets[];
-extern readonly short type[];
+extern short charsets[];
+extern short type[];
+
+#endif
+/*#include "as.h" assyms.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+#if defined(DOSCCS) && !defined(lint)
#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)assizetab.c 5.1 (Berkeley) 4/30/85";
#endif
+#endif
#ifdef AS
-#include <stdio.h>
-#include "as.h"
+/*#include <stdio.h> as.h*/
+/*#include "as.h"*/
#include "assyms.h"
/*
+/*#include <a.out.h> as.h*/
+#include <gen.h>
+#include <memory.h>
+/*#include <stdio.h> as.h*/
+/*#include <strings.h> gen.h*/
+/*#include <sys/exec.h> as.h*/
+/*#include <sys/proc.h> gen.h*/
+/*#include <sys/types.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "asscan.h" asexpr.h*/
+#include "assyms.h"
+/*#include "astoks.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)assyms.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include <ctype.h>
-#include "as.h"
-#include "asscan.h"
-#include "assyms.h"
+/*#include <stdio.h>*/
+/*#include <ctype.h>*/
+/*#include "as.h"*/
+/*#include "asscan.h"*/
+/*#include "assyms.h"*/
/*
* Managers for chunks of symbols allocated from calloc()
*/
struct strpool *strplhead = 0;
-symtabinit()
-{
+void symtabinit() {
allochead = 0;
alloctail = 0;
nextsym = 0;
/*
* Install all known instructions in the symbol table
*/
-syminstall()
-{
+void syminstall() {
register Iptr ip;
register struct symtab **hp;
register char *p1, *p2;
*/
extern struct exec hdr;
-freezesymtab()
-{
+void freezesymtab() {
register struct symtab *sp;
long bs;
register int relpos = 0;
register struct symtab *ubsp;
register struct allocbox *allocwalk;
- DECLITERATE(allocwalk, sp, ubsp)
- {
+ DECLITERATE(allocwalk, sp, ubsp) {
if (sp->s_tag >= IGNOREBOUND)
continue; /*totally ignore jxxx entries */
/*
* Iteration order doesn't matter.
*/
-stabfix()
-{
+void stabfix() {
register struct symtab *sp, **cosp;
register struct symtab *p;
}
}
-char *Calloc(number, size)
- int number, size;
-{
+char *Calloc(number, size) int number; int size; {
register char *newstuff;
void *sbrk();
newstuff = sbrk(number*size);
return(newstuff);
}
-char *ClearCalloc(number, size)
- int number, size;
-{
+char *ClearCalloc(number, size) int number; int size; {
register char *newstuff; /* r11 */
register int length = number * size; /* r10 */
#ifdef lint
length = length;
-#endif length
+#endif
newstuff = Calloc(number, size);
-#ifdef __STDC__ /* this is a bit non-ideal, revisit later */
+#ifdef X_
bzero(newstuff, length);
#else
asm("movc5 $0, (r0), $0, r10, (r11)");
return(newstuff);
}
-struct symtab *symalloc()
-{
+struct symtab *symalloc() {
if (symsleft == 0){
newbox = (struct allocbox *)ClearCalloc(1,ALLOCQTY);
symsleft = SYMDALLOP;
return(nextsym++);
}
-strpoolalloc()
-{
+void strpoolalloc() {
register struct strpool *new;
new = (struct strpool *)Calloc(1, sizeof (struct strpool));
strplhead = new;
}
-symcmp(Pptr, Qptr)
- struct symtab **Pptr, **Qptr;
-{
+int symcmp(Pptr, Qptr) struct symtab **Pptr; struct symtab **Qptr; {
register struct symtab *p = *Pptr;
register struct symtab *q = *Qptr;
if (p->s_index < q->s_index)
* already have an estimated final value
*/
-sortsymtab()
-{
+void sortsymtab() {
register struct symtab *sp;
register struct symtab **cowalk;
register struct allocbox *allocwalk;
yyerror("INTERNAL ERROR: installed %d syms, should have installed %d",
symsin, nsyms);
symptrub = &symptrs[nsyms ];
- qsort(symptrs, nsyms, sizeof *symptrs, symcmp);
+ qsort(symptrs, nsyms, sizeof *symptrs, (int (*) __P((void *p0, void *p1)))symcmp);
symdelim[0] = symptrs;
for (cowalk = symptrs, sp = *cowalk, segno = 0, slotno = 1;
segno < NLOC + NLOC;
} /*end of sortsymtab*/
#ifdef DEBUG
-dumpsymtab()
-{
+int dumpsymtab() {
register int segno;
register struct symtab *sp, **cosp, *ub;
char *tagstring();
static char tagbuff[4];
-char *tagstring(tag)
- unsigned char tag;
-{
+char *tagstring(tag) int tag; {
switch(tag){
case JXACTIVE: return("active");
case JXNOTYET: return("notyet");
return(tagbuff);
}
}
-#endif DEBUG
+#endif
-htaballoc()
-{
+void htaballoc() {
register struct hashdallop *new;
new = (struct hashdallop *)ClearCalloc(1, sizeof (struct hashdallop));
if (htab == 0)
* in the vax contributes significantly to the overall
* execution speed of as.
*/
-struct symtab **lookup(instflg)
- int instflg; /* 0: don't install */
-{
+struct symtab **lookup(instflg) int instflg; /* 0: don't install */ {
static int initialprobe;
register struct symtab **hp;
register char *from;
(*hp) && (nprobes < NHASH);
hp += nprobes,
hp -= (hp >= hp_ub) ? NHASH:0,
- nprobes += 2)
- {
+ nprobes += 2) {
from = yytext;
to = FETCHNAME(*hp);
while (*from && *to)
/*
* save a string str with len in the places indicated by place
*/
-struct strdesc *savestr(str, len, place)
- char *str;
- int len;
- int place;
-{
- reg struct strdesc *res;
+struct strdesc *savestr(str, len, place) char *str; int len; int place; {
+ register struct strdesc *res;
int tlen;
/*
* Compute the total length of the record to live in core
* the characters have already been dumped to the file
*/
if ((place & STR_CORE) && str)
- movestr(res[0].sd_string, str, len);
+ memcpy(res[0].sd_string, str, len);
if (place & STR_FILE){
if (str){
fwrite(str, 1, len, strfile);
struct relocation_info r_can_1PC;
struct relocation_info r_can_0PC;
-initoutrel()
-{
+void initoutrel() {
r_can_0PC.r_address = 0;
r_can_0PC.r_symbolnum = 0;
r_can_0PC.r_pcrel = 0;
r_can_1PC.r_pcrel = 1;
}
-outrel(xp, reloc_how)
- register struct exp *xp;
- int reloc_how; /* TYPB..TYPH + (possibly)RELOC_PCREL */
-{
+void outrel(xp, reloc_how) register struct exp *xp; int reloc_how; /* TYPB..TYPH + (possibly)RELOC_PCREL */ {
struct relocation_info reloc;
register int x_type_mask;
int pcrel;
* Note that the individual lists of buffers are in
* reverse order, so we must reverse them
*/
-off_t closeoutrel(relocfile)
- BFILE *relocfile;
-{
+off_t closeoutrel(relocfile) BFILE *relocfile; {
int locindex;
u_long Closeoutrel();
return(trsize + drsize);
}
-u_long Closeoutrel(relfil, relocfile)
- struct relbufdesc *relfil;
- BFILE *relocfile;
-{
+u_long Closeoutrel(relfil, relocfile) struct relbufdesc *relfil; BFILE *relocfile; {
u_long tail;
if (relfil == 0)
return(0L);
}
#define NOUTSYMS (nsyms - njxxx - nforgotten - (savelabels ? 0 : nlabels))
-int sizesymtab()
-{
+int sizesymtab() {
return (sizeof (struct nlist) * NOUTSYMS);
}
/*
* ignoring symbols that are obsolete, jxxx instructions, and
* possibly, labels
*/
-int symwrite(symfile)
- BFILE *symfile;
-{
+void symwrite(symfile) BFILE *symfile; {
int symsout; /*those actually written*/
int symsdesired = NOUTSYMS;
- reg struct symtab *sp, *ub;
+ register struct symtab *sp, *ub;
+#ifdef X_
+ struct nlist temp;
+#else
char *name; /* temp to save the name */
+#endif
int totalstr;
/*
* We use sp->s_index to hold the length of the
if (ISLABEL(sp))
continue;
symsout++;
+#ifdef X_
+ /*
+ * the length of the symbol table string
+ * always includes the trailing null;
+ * blast the pointer to its a.out value.
+ */
+ if (sp->s_name && (sp->s_index = STRLEN(sp))){
+ temp.n_un.n_strx = totalstr;
+ totalstr += sp->s_index;
+ } else {
+ temp.n_un.n_strx = 0;
+ }
+ if (sp->s_ptype != 0)
+ sp->s_type = sp->s_ptype;
+ else
+ sp->s_type = (sp->s_type & (~XFORW));
+ if (readonlydata && (sp->s_type&~N_EXT) == N_DATA)
+ sp->s_type = N_TEXT | (sp->s_type & N_EXT);
+ temp.n_type = sp->s_type;
+ temp.n_other = sp->s_other;
+ temp.n_desc = sp->s_desc;
+ temp.n_value = sp->s_value;
+ bwrite((char *)&temp, sizeof (struct nlist), symfile);
+#else
name = sp->s_name; /* save pointer */
/*
* the length of the symbol table string
sp->s_type = N_TEXT | (sp->s_type & N_EXT);
bwrite((char *)&sp->s_nm, sizeof (struct nlist), symfile);
sp->s_name = name; /* restore pointer */
+#endif
}
if (symsout != symsdesired)
yyerror("INTERNAL ERROR: Wrote %d symbols, wanted to write %d symbols\n",
* possibly fetching from the string file if the string
* is not core resident.
*/
- bwrite(&totalstr, sizeof(totalstr), symfile);
+ bwrite((char *)&totalstr, sizeof(totalstr), symfile);
symsout = 0;
DECLITERATE(allocwalk, sp, ub) {
if (sp->s_tag >= IGNOREBOUND)
+#ifndef _ASSYMS_H_
+#define _ASSYMS_H_
+
+#include "as.h"
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
struct hashdallop *h_next;
struct symtab *h_htab[NHASH];
};
+
+#endif
+#ifndef _ASTOKS_H_
+#define _ASTOKS_H_
+
# define FIRSTTOKEN 0
# define ISPACE 1
# define IBYTE 2
# define RB 74
# define RP 75
# define LASTTOKEN 76
+
+#endif
+#include <math.h>
+#include <sys/errno.h>
+/*#include <sys/types.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)bignum1.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <errno.h>
-#include <stdio.h>
-#include "as.h"
+/*#include <errno.h>*/
+/*#include <stdio.h>*/
+/*#include "as.h"*/
/*
* Construct a floating point number
*/
-Bignum as_atof(numbuf, radix, ovfp)
- char *numbuf;
- int radix;
- Ovf *ovfp;
-{
+Bignum as_atof(numbuf, radix, ovfp) char *numbuf; int radix; Ovf *ovfp; {
Bignum number;
extern int errno;
double atof();
* Construct an integer.
*/
-Bignum as_atoi(ccp, radix, ovfp)
- reg char *ccp; /* character cp */
- int radix;
- Ovf *ovfp;
-{
- reg chptr bcp;
+Bignum as_atoi(ccp, radix, ovfp) register char *ccp; /* character cp */ int radix; Ovf *ovfp; {
+ register chptr bcp;
chptr tcp;
- reg int i;
+ register int i;
int val;
Bignum n_n;
Bignum t_n;
for (i = 0; i < CH_N; i++){
if (bcp[i] == val)
break;
- }
- {
+ } {
static u_char tagtab[4][16] = {
{ TYPB,
TYPW,
return(n_n);
}
-Ovf posovf(src)
- reg chptr src;
-{
- reg int i;
+Ovf posovf(src) register chptr src; {
+ register int i;
Ovf overflow = 0;
if (src[HOC] & SIGNBIT)
/*
* check if the number is clear
*/
-int isclear(dst)
- reg chptr dst;
-{
+int isclear(dst) register chptr dst; {
return(!isunequal(dst, CH_FIELD(Znumber)));
}
-int isunequal(src1, src2)
- reg chptr src1, src2;
-{
- reg int i;
+int isunequal(src1, src2) register chptr src1; register chptr src2; {
+ register int i;
i = CH_N;
do{
return(0);
}
-Ovf numclear(dst)
- reg chptr dst;
-{
- reg int i;
+Ovf numclear(dst) register chptr dst; {
+ register int i;
i = CH_N;
do{
*dst++ = 0;
return(0);
}
-Ovf numshift(n, dst, src)
- int n;
- reg chptr dst, src;
-{
- reg int i;
- reg u_int carryi, carryo;
- reg u_int mask;
- reg u_int value;
+Ovf numshift(n, dst, src) int n; register chptr dst; register chptr src; {
+ register int i;
+ register u_int carryi, carryo;
+ register u_int mask;
+ register u_int value;
i = CH_N;
if (n == 0){
}
}
-Ovf numaddd(dst, src1, val)
- chptr dst, src1;
- int val;
-{
+Ovf numaddd(dst, src1, val) chptr dst; chptr src1; int val; {
static Bignum work;
work.num_uchar[0] = val;
return (numaddv(dst, src1, CH_FIELD(work)));
}
-Ovf numaddv(dst, src1, src2)
- reg chptr dst, src1, src2;
-{
- reg int i;
- reg int carry;
- reg u_int A,B,value;
+Ovf numaddv(dst, src1, src2) register chptr dst; register chptr src1; register chptr src2; {
+ register int i;
+ register int carry;
+ register u_int A,B,value;
carry = 0;
i = CH_N;
return(carry ? OVF_ADDV : 0);
}
-Ovf numnegate(dst, src)
- chptr dst, src;
-{
+Ovf numnegate(dst, src) chptr dst; chptr src; {
Ovf ovf;
ovf = num1comp(dst, src) ;
return(ovf);
}
-Ovf num1comp(dst, src)
- reg chptr dst, src;
-{
- reg int i;
+Ovf num1comp(dst, src) register chptr dst; register chptr src; {
+ register int i;
i = CH_N;
do{
*dst++ = ~ *src++;
* If it is, then stuff the value into *valuep.
* argtype is how the instruction will interpret the number.
*/
-int slitflt(number, argtype, valuep)
- Bignum number; /* number presented */
- int argtype; /* what the instruction expects */
- int *valuep;
-{
+int slitflt(number, argtype, valuep) Bignum number; /* number presented */ int argtype; /* what the instruction expects */ int *valuep; {
#define EXPPREC 3
#define MANTPREC 3
int mask;
- reg int i;
+ register int i;
Bignum unpacked;
Ovf ovf;
* is not the same type, then we complain, but do the conversion anyway.
* The conversion is strict.
*/
-bignumwrite(number, toconv)
- Bignum number;
- int toconv; /* one of TYP[QO FDGH] */
-{
- reg u_int *bp;
+void bignumwrite(number, toconv) Bignum number; int toconv; /* one of TYP[QO FDGH] */ {
+ register u_int *bp;
if (passno != 2)
return;
}
bwrite((char *)bp, ty_nbyte[toconv], txtfil);
}
-#endif STANDALONE
+#endif
+/*#include <stdio.h> as.h*/
+/*#include <sys/types.h> as.h*/
+/*#include "as.h" asexpr.h*/
+#include "asexpr.h"
+/*#include "asnumber.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)bignum2.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
Bignum Znumber; /* zero reference */
#define MINEXP -32768 /* never generate; reserved for id 0 */
-Bignum intconvert(number, convto)
- Bignum number;
- int convto;
-{
- reg int i;
+Bignum intconvert(number, convto) Bignum number; int convto; {
+ register int i;
if (number.num_tag == convto)
return(number);
if (ty_nbyte[number.num_tag] > ty_nbyte[convto] && (passno == 2)){
#define CONV(src, dst) (((src) << TYPLG) + (dst))
-Bignum floatconvert(number, convto)
- Bignum number;
- int convto;
-{
- reg u_int *bp; /* r11 */
+Bignum floatconvert(number, convto) Bignum number; int convto; {
+ register u_int *bp; /* r11 */
int loss = 0;
int gain = 0;
int mixs = 0;
bp = &number.num_uint[0];
#ifdef lint
*bp = *bp;
-#endif lint
+#endif
switch(CONV(number.num_tag, convto)){
/*
* Convert a big number between various representations
*/
-Bignum bignumconvert(number, toconv, ovfp)
- Bignum number;
- int toconv;
- Ovf *ovfp;
-{
+Bignum bignumconvert(number, toconv, ovfp) Bignum number; int toconv; Ovf *ovfp; {
int tag;
*ovfp = 0;
return(bignumpack(bignumunpack(number, ovfp), toconv, ovfp));
}
-Bignum bignumunpack(Packed, ovfp)
- Bignum Packed;
- Ovf *ovfp;
-{
+Bignum bignumunpack(Packed, ovfp) Bignum Packed; Ovf *ovfp; {
Bignum Mantissa;
Bignum Enumber;
- reg int i;
+ register int i;
int j;
int k;
- reg struct ty_bigdesc *p;
- reg chptr packed;
- reg chptr mantissa;
- reg chptr enumber;
+ register struct ty_bigdesc *p;
+ register chptr packed;
+ register chptr mantissa;
+ register chptr enumber;
u_short exponent;
int sign;
int mask;
return(Mantissa);
}
-Bignum bignumpack(Unpacked, toconv, ovfp)
- Bignum Unpacked;
- int toconv;
- Ovf *ovfp;
-{
+Bignum bignumpack(Unpacked, toconv, ovfp) Bignum Unpacked; int toconv; Ovf *ovfp; {
Bignum Back;
Bignum Enumber;
Bignum Temp;
short exponent;
char sign;
- reg struct ty_bigdesc *p;
- reg chptr back;
- reg chptr enumber;
- reg chptr temp;
- reg chptr unpacked;
+ register struct ty_bigdesc *p;
+ register chptr back;
+ register chptr enumber;
+ register chptr temp;
+ register chptr unpacked;
int i,j;
/*NOTREACHED*/
}
-mapnumber(chp1, chp2, nbytes, themap)
- chptr chp1, chp2;
- int nbytes;
- char *themap;
-{
- reg int i;
- reg u_char *p1, *p2;
+void mapnumber(chp1, chp2, nbytes, themap) chptr chp1; chptr chp2; int nbytes; char *themap; {
+ register int i;
+ register u_char *p1, *p2;
p1 = (u_char *)chp1;
p2 = (u_char *)chp2;
* the binary exponent if there was total carry out.
* Return the modified exponent
*/
-int upround(numberp, p, exponent)
- reg Bignum *numberp;
- reg struct ty_bigdesc *p;
- int exponent;
-{
- reg u_char *bytep;
+int upround(numberp, p, exponent) register Bignum *numberp; register struct ty_bigdesc *p; int exponent; {
+ register u_char *bytep;
int nbytes;
int byteindex;
int hofractionbit;
int ovffractionbit;
- reg int ovfbitindex;
- reg chptr number;
+ register int ovfbitindex;
+ register chptr number;
static Bignum ulp;
/*
return(exponent);
}
#ifdef DEBUG
-bignumprint(number)
- Bignum number;
-{
+int bignumprint(number) Bignum number; {
printf("Bignum: %s (exp: %d, sign: %d) 0x%08x%08x%08x%08x",
ty_string[number.num_tag],
number.num_exponent,
}
}
-numprintovf(ovf)
- Ovf ovf;
-{
+int numprintovf(ovf) Ovf ovf; {
int i;
static struct ovftab{
Ovf which;
printf("Overflow(%s) ", ovftab[i].print);
}
}
-#endif DEBUG
+#endif
+/*#include <stdio.h> as.h*/
+#include "as.h"
+/*#include "asnumber.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)floattab.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include "as.h"
+/*#include <stdio.h>*/
+/*#include "as.h"*/
#define N NOTAKE
struct ty_bigdesc ty_bigdesc[] = {
15, /* exponent sig bits */
16384 /* exponent excess */
},
-{0} /* TYPNONE */
+{ /* TYPNONE */
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ 0, /* mantissa lshift */
+ 0, /* exponent rshift */
+ 0, /* mantissa sig bits */
+ 0, /* exponent sig bits */
+ 0 /* exponent excess */
+}
};
-cfloattab()
-{
- reg struct ty_bigdesc *p;
- reg int i;
- reg int j;
- reg int k;
+void cfloattab() {
+ register struct ty_bigdesc *p;
+ register int i;
+ register int j;
+ register int k;
extern int ty_float[];
for (i = 0; i < TYPNONE - 1; i++){
+#ifndef _INSTRS_H_
+#define _INSTRS_H_
+
+#include <sys/types.h>
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
#define NEW 1
#define ESCD 0xfd
#define ESCF 0xff
+
+#endif
+#include <ctype.h>
+/*#include <stdio.h> as.h*/
+#include <sys/errno.h>
+/*#include <sys/types.h> as.h*/
+#include "as.h"
+/*#include "asnumber.h" as.h*/
+/*#include "instrs.h" as.h*/
+
/*
* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)natof.c 5.1 (Berkeley) 4/30/85";
-#endif not lint
+#endif
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
+/*#include <stdio.h>*/
+/*#include <ctype.h>*/
+/*#include <errno.h>*/
-#include "as.h"
+/*#include "as.h"*/
-Bignum bigatof(str, radix)
- reg char *str; /* r11 */
- int radix; /* TYPF ... TYPH */
-{
+Bignum bigatof(str, radix) register char *str; /* r11 */ int radix; /* TYPF ... TYPH */ {
int msign;
int esign;
int decpt;
- reg chptr temp; /* r10 */
- reg u_int quotient; /* r9 */ /* must be here */
- reg u_int remainder; /* r8 */ /* must be here */
- reg chptr acc;
- reg int dividend; /* for doing division */
- reg u_int i;
+ register chptr temp; /* r10 */
+ register u_int quotient; /* r9 */ /* must be here */
+ register u_int remainder; /* r8 */ /* must be here */
+ register chptr acc;
+ register int dividend; /* for doing division */
+ register u_int i;
short *sptr; /* for doing division */
int ch;
int dexponent; /* decimal exponent */
#ifdef lint
quotient = 0;
remainder = 0;
-#endif lint
+#endif
msign = 0;
esign = 0;
decpt = 0;
printf("Dividing: ");
bignumprint(Acc);
printf("\n");
-#endif DEBUGNATOF
+#endif
sptr = (short *)acc;
for (i = (CH_N * 2 - 1); i >= 1; --i){
/*
printf("Octal number: ");
bignumprint(Acc);
printf("\n");
-#endif DEBUGNATOF
+#endif
Acc = bignumunpack(Acc, &ovf);
if (ovf)
printf("Unpacked octal number: ");
bignumprint(Acc);
printf("bexponent == %d\n", bexponent);
-#endif DEBUGNATOF
+#endif
Acc.num_exponent += bexponent;
assert(Acc.num_sign == 0, "unpacked integer is < 0");
Acc.num_sign = msign;
printf("packed number: ");
bignumprint(Acc);
printf("\n");
-#endif DEBUGNATOF
+#endif
return(Acc);
}
#if 0
* if the quotient is an unsigned number > 2^31,
* ediv sets integer overflow.
*/
-unsigned int ediv(high, low, divisor, qp, i)
- register unsigned int high; /* r11 */
- register unsigned int low; /* r10 */
- register unsigned int divisor; /* r9 */
- unsigned int *qp;
-{
+unsigned int ediv(high, low, divisor, qp, i) register unsigned int high; /* r11 */ register unsigned int low; /* r10 */ register unsigned int divisor; /* r9 */ unsigned int *qp; int i; {
register unsigned int remainder; /* r8 */
register unsigned int quotient; /* r7 */
*qp = quotient;
return(remainder);
}
-#endif 0
+#endif
*/
struct nlist {
union {
+#ifndef X_
char *n_name; /* for use when in-core */
+#endif
long n_strx; /* index into file string table */
} n_un;
unsigned char n_type; /* type flag, i.e. N_TEXT etc; see below */