From 26eef8a795d76093e4fe9ebbf5ed201d1269881a Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Fri, 27 Jan 2017 01:48:16 +1100 Subject: [PATCH] Post-ansification changes for bin/as --- bin/as/as.h | 142 ++++++++++++++++++-- bin/as/ascode.c | 52 ++++---- bin/as/asexpr.c | 313 ++++++++++++++++++++++----------------------- bin/as/asexpr.h | 60 +++++++-- bin/as/asio.c | 45 +++---- bin/as/asjxxx.c | 48 +++---- bin/as/asmain.c | 137 ++++++++++---------- bin/as/asnumber.h | 81 +++++++++--- bin/as/asparse.c | 179 ++++++++++++++------------ bin/as/aspseudo.c | 23 ++-- bin/as/asscan.h | 49 ++++++- bin/as/asscan1.c | 56 ++++---- bin/as/asscan2.c | 56 ++++---- bin/as/asscan3.c | 13 +- bin/as/asscan4.c | 43 ++++--- bin/as/asscanl.h | 31 +++-- bin/as/assizetab.c | 9 +- bin/as/assyms.c | 158 ++++++++++++----------- bin/as/assyms.h | 7 + bin/as/astoks.h | 5 + bin/as/bignum1.c | 114 +++++++---------- bin/as/bignum2.c | 100 ++++++--------- bin/as/floattab.c | 36 ++++-- bin/as/instrs.h | 7 + bin/as/natof.c | 56 ++++---- include/a.out.h | 2 + 26 files changed, 1034 insertions(+), 788 deletions(-) diff --git a/bin/as/as.h b/bin/as/as.h index 8309bb6..0d5c591 100644 --- a/bin/as/as.h +++ b/bin/as/as.h @@ -1,3 +1,12 @@ +#ifndef _AS_H_ +#define _AS_H_ + +#include +#include +/*#include a.out.h*/ +/*#include asnumber.h*/ +#include "asnumber.h" + /* * Copyright (c) 1982 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -6,9 +15,9 @@ * @(#)as.h 5.3 (Berkeley) 7/6/85 */ -#include -#include -#include +/*#include */ +/*#include */ +/*#include */ #define NINST 300 @@ -28,13 +37,13 @@ */ #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 */ @@ -173,7 +182,15 @@ extern char *ty_string[]; /* {TYPB..TYPH} ==> printable */ */ 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 */ + 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 */ @@ -194,20 +211,32 @@ struct symtab{ * 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 */ +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 */ @@ -282,9 +311,17 @@ struct Instab{ * 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*/ @@ -297,7 +334,7 @@ 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; @@ -346,7 +383,7 @@ struct strdesc{ #define STR_CORE 0x2 #define STR_BOTH 0x3 -struct strdesc *savestr(); +/*struct strdesc *savestr();*/ /* * Assertions */ @@ -437,7 +474,7 @@ struct strdesc *savestr(); * 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*/ @@ -505,3 +542,92 @@ struct biobuf { */ 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 diff --git a/bin/as/ascode.c b/bin/as/ascode.c index 3676854..bb85daf 100644 --- a/bin/as/ascode.c +++ b/bin/as/ascode.c @@ -1,28 +1,30 @@ +/*#include 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 -#include "as.h" -#include "assyms.h" +/*#include */ +/*#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) @@ -109,13 +111,9 @@ insout(opcode, ap, nact) 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; @@ -355,14 +353,10 @@ PASS2: #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); diff --git a/bin/as/asexpr.c b/bin/as/asexpr.c index f1325c3..094b5e8 100644 --- a/bin/as/asexpr.c +++ b/bin/as/asexpr.c @@ -1,17 +1,24 @@ +/*#include 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 -#include "as.h" -#include "asscan.h" -#include "asexpr.h" +/*#include */ +/*#include "as.h"*/ +/*#include "asscan.h"*/ +/*#include "asexpr.h"*/ /* * Tables for combination of operands. @@ -21,50 +28,48 @@ static char sccsid[] = "@(#)asexpr.c 5.2 (Berkeley) 6/19/85"; /* * 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 */ @@ -162,8 +167,7 @@ struct exp *combine(op, exp1, exp2) return(exp1); } -buildtokensets() -{ +void buildtokensets() { #define clobber(val, set) tokensets[(val)] |= (set) clobber(SEMI, LINSTBEGIN); @@ -204,7 +208,7 @@ buildtokensets() * 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; @@ -212,54 +216,48 @@ 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*/ @@ -268,24 +266,24 @@ struct exp *factor() 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; @@ -301,11 +299,8 @@ struct exp *factor() 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; @@ -328,7 +323,7 @@ struct exp *yukkyexpr(val, np) 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: @@ -384,116 +379,114 @@ struct Tok_Desc{ 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; diff --git a/bin/as/asexpr.h b/bin/as/asexpr.h index 3215f3d..0204793 100644 --- a/bin/as/asexpr.h +++ b/bin/as/asexpr.h @@ -1,3 +1,13 @@ +#ifndef _ASEXPR_H_ +#define _ASEXPR_H_ + +#ifdef __STDC__ +#include +#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 @@ -34,11 +44,11 @@ /* * 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 @@ -56,15 +66,15 @@ extern char tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1]; #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; \ @@ -86,10 +96,38 @@ inttoktype yylex(); #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 diff --git a/bin/as/asio.c b/bin/as/asio.c index b46d2bc..8a52811 100644 --- a/bin/as/asio.c +++ b/bin/as/asio.c @@ -1,15 +1,21 @@ +#include +#include +/*#include 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 -#include "as.h" +/*#include */ +/*#include "as.h"*/ /* * Block I/O routines for logical I/O concurrently in * more than one place in the same file. @@ -22,9 +28,7 @@ BFILE *biobufs; /* the block I/O buffers */ #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; @@ -37,10 +41,7 @@ Flushfield(n) /* * 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); @@ -51,11 +52,7 @@ bopen(bp, off) 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; @@ -70,8 +67,8 @@ top: 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)"); @@ -101,8 +98,7 @@ top: goto top; } -bflush() -{ +void bflush() { register struct biobuf *bp; if (bwrerror) @@ -111,9 +107,7 @@ bflush() 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) @@ -130,10 +124,7 @@ bflush1(bp) 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); } diff --git a/bin/as/asjxxx.c b/bin/as/asjxxx.c index bd0619f..b9d4e09 100644 --- a/bin/as/asjxxx.c +++ b/bin/as/asjxxx.c @@ -1,16 +1,22 @@ +/*#include 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 -#include "as.h" -#include "assyms.h" +/*#include */ +/*#include "as.h"*/ +/*#include "assyms.h"*/ #define JBR 0x11 #define BRW 0x31 @@ -36,8 +42,7 @@ int jxxxfsize = JXXXDELTA; struct symtab *lastnam; struct symtab *lastjxxx; -initijxxx() -{ +void initijxxx() { jbrfsize = jxxxJUMP ? JBRJDELTA : JBRDELTA; jxxxfsize = jxxxJUMP ? JXXXJDELTA : JXXXDELTA; /* @@ -50,11 +55,7 @@ initijxxx() /* * 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() @@ -94,10 +95,10 @@ ijxout(opcode, ap, nact) /* * 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; @@ -133,10 +134,7 @@ ijxout(opcode, ap, nact) } } -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; @@ -212,8 +210,7 @@ jalign(xp, sp) /* * 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; @@ -238,7 +235,7 @@ jxxxfix() 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", @@ -475,10 +472,7 @@ jxxxfix() * 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; diff --git a/bin/as/asmain.c b/bin/as/asmain.c index 9b5a431..2429af5 100644 --- a/bin/as/asmain.c +++ b/bin/as/asmain.c @@ -1,30 +1,51 @@ +/*#include gen.h*/ +#include +/*#include as.h*/ +/*#include gen.h*/ +/*#include as.h*/ +#include +/*#include gen.h*/ +/*#include gen.h*/ +#include +/*#include as.h*/ +#ifdef __STDC__ +#include +#define _va_start(argp, arg) va_start(argp, arg) +#else +#include +#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 -#include -#include -#include +/*#include */ +/*#include */ +/*#include */ +/*#include */ -#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 +/*#include */ #define unix_lang_name "VAX/UNIX Assembler V10/21/85 5.2" /* @@ -172,12 +193,9 @@ BFILE *relocfile; /* concatnated relocation info */ * 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; @@ -229,10 +247,7 @@ main(argc, argv) exit(anyerrs != 0); } -argprocess(argc, argv) - int argc; - char *argv[]; -{ +void argprocess(argc, argv) int argc; char *argv[]; { register char *cp; ninfiles = 0; @@ -335,13 +350,10 @@ argprocess(argc, argv) * 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++){ @@ -360,10 +372,9 @@ selfwhat(place) } } -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 */ @@ -375,8 +386,7 @@ initialize() buildtokensets(); } -zeroorigins() -{ +void zeroorigins() { register int locindex; /* * Mark usedot: the first NLOC slots are for named text segments, @@ -390,8 +400,7 @@ zeroorigins() } } -zerolocals() -{ +void zerolocals() { register int i; for (i = 0; i <= 9; i++) { @@ -400,8 +409,7 @@ zerolocals() } } -i_pass1() -{ +void i_pass1() { FILE *tempopen(); if (useVM == 0) tokfile = tempopen(tokfilename, "T"); @@ -418,10 +426,7 @@ i_pass1() 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, @@ -436,8 +441,7 @@ FILE *tempopen(tname, part) return(file); } -pass1() -{ +void pass1() { register int i; passno = 1; @@ -467,8 +471,7 @@ pass1() closetokfile(); /*kick out the last buffered intermediate text*/ } -testlocals() -{ +void testlocals() { register int i; for (i = 0; i <= 9; i++) { if (genref[i]) @@ -478,8 +481,7 @@ testlocals() } } -pass1_5() -{ +void pass1_5() { sortsymtab(); #ifdef DEBUG if (debug) dumpsymtab(); @@ -490,8 +492,7 @@ pass1_5() #endif } -open_a_out() -{ +void open_a_out() { struct stat stb; /* @@ -510,8 +511,7 @@ open_a_out() a_out_off = 0; } -roundsegments() -{ +void roundsegments() { register int locindex; register long v; /* @@ -564,8 +564,7 @@ roundsegments() } } -build_hdr() -{ +void build_hdr() { /* * Except for the text and data relocation sizes, * calculate the final values for the header @@ -586,8 +585,7 @@ build_hdr() bwrite((char *)&hdr, sizeof(hdr), usefile[0]); } -i_pass2() -{ +void i_pass2() { if (useVM == 0) { fclose(tokfile); tokfile = fopen(tokfilename, "r"); @@ -600,12 +598,11 @@ i_pass2() 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]; @@ -620,8 +617,7 @@ pass2() closetokfile(); } -fillsegments() -{ +void fillsegments() { int locindex; /* * Round text and data segments to FW by appending zeros @@ -636,8 +632,7 @@ fillsegments() } } -reloc_syms() -{ +void reloc_syms() { u_long closerelfil(); /* * Move the relocation information to a.out @@ -667,16 +662,14 @@ reloc_syms() 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); @@ -684,16 +677,14 @@ delexit() 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) @@ -703,14 +694,16 @@ sawabort() 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(); diff --git a/bin/as/asnumber.h b/bin/as/asnumber.h index c388e5a..c533760 100644 --- a/bin/as/asnumber.h +++ b/bin/as/asnumber.h @@ -1,3 +1,8 @@ +#ifndef _ASNUMBER_H_ +#define _ASNUMBER_H_ + +#include + /* * Copyright (c) 1982 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -102,7 +107,7 @@ typedef u_int *chptr; /* basic data type */ #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. @@ -110,16 +115,16 @@ typedef u_int *chptr; /* basic data type */ #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 */ /* * Definitions for overflows. @@ -137,13 +142,13 @@ typedef u_int Ovf; #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();*/ /* * Definitions to unpack big numbers numbers into @@ -182,3 +187,43 @@ extern struct ty_bigdesc ty_bigdesc[]; * 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 diff --git a/bin/as/asparse.c b/bin/as/asparse.c index 5dd88c4..f752457 100644 --- a/bin/as/asparse.c +++ b/bin/as/asparse.c @@ -1,19 +1,37 @@ +#include +#include +/*#include as.h*/ +#ifdef __STDC__ +#include +#define _va_start(argp, arg) va_start(argp, arg) +#else +#include +#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 -#include -#include "as.h" -#include "asscan.h" -#include "assyms.h" -#include "asexpr.h" +/*#include */ +/*#include */ +/*#include "as.h"*/ +/*#include "asscan.h"*/ +/*#include "assyms.h"*/ +/*#include "asexpr.h"*/ int lgensym[10]; char genref[10]; @@ -34,7 +52,7 @@ int droppedLP; /*one is analyzing an expression beginning with*/ /*shifted. (Used to parse ()(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 */ /* @@ -50,9 +68,8 @@ char tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1]; 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 @@ -61,16 +78,16 @@ yyparse() 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*/ @@ -88,7 +105,7 @@ yyparse() 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 */ @@ -104,7 +121,7 @@ yyparse() 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); @@ -117,17 +134,17 @@ yyparse() (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"); @@ -140,7 +157,7 @@ yyparse() goto errorfix; } restlab: - shift; + val = yylex(); flushfield(NBWD/4); if ((np->s_type&XTYPE)!=XUNDEF) { if ( (np->s_type&XTYPE) != dotp->e_xtype @@ -182,7 +199,7 @@ restlab: ERROR("Unrecognized instruction or directive"); case IABORT: - shift; + val = yylex(); sawabort(); /*NOTREACHED*/ break; @@ -196,22 +213,22 @@ restlab: 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 , */ - shift; + val = yylex(); np = (struct symtab *)yylval; shiftover(NAME); shiftover(CM); @@ -226,7 +243,7 @@ restlab: break; case ILSYM: /*.lsym name , expr */ - shift; + val = yylex(); np = (struct symtab *)yylval; shiftover(NAME); shiftover(CM); @@ -253,7 +270,7 @@ restlab: break; case IGLOBAL: /*.globl */ - shift; + val = yylex(); np = (struct symtab *)yylval; shiftover(NAME); np->s_type |= XXTRN; @@ -262,7 +279,7 @@ restlab: case IDATA: /*.data [ ] */ case ITEXT: /*.text [ ] */ seg_type = -val; - shift; + val = yylex(); if (INTOKSET(val, EBEGOPS+YUKKYEXPRBEG+SAFEEXPRBEG)){ expr(locxp, val); seg_type = -seg_type; /*now, it is positive*/ @@ -303,7 +320,7 @@ restlab: elist: seg_type = val; - shift; + val = yylex(); /* * Expression List processing @@ -369,7 +386,7 @@ restlab: } xp = explist; if (auxval = (val == CM)) - shift; + val = yylex(); } while (auxval); } /* there existed an expression at all */ @@ -380,14 +397,13 @@ restlab: /*end of case IBYTE, IWORD, ILONG, IINT*/ case ISPACE: /* .space */ - 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)); @@ -403,7 +419,7 @@ restlab: * 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"); @@ -430,7 +446,7 @@ restlab: case IASCII: /* .ascii [ ] */ case IASCIZ: /* .asciz [ ] */ auxval = val; - shift; + val = yylex(); /* * Code to consume a string list * @@ -466,14 +482,14 @@ restlab: } 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 */ - shift; + val = yylex(); expr(locxp, val); if ((locxp->e_xtype & XTYPE) == XABS) /* tekmdp */ @@ -607,7 +623,7 @@ restlab: * 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)){ @@ -651,7 +667,7 @@ restlab: stabstart = tokptr; *(bytetoktype **)&stabstart -= sizeof(struct symtab *); *(bytetoktype **)&stabstart -= sizeof(bytetoktype); - shift; + val = yylex(); if (auxval == ISTABSTR){ stringp = (struct strdesc *)yylval; shiftover(STRING); @@ -672,7 +688,7 @@ restlab: case ICOMM: /* .comm , */ case ILCOMM: /* .lcomm , */ auxval = val; - shift; + val = yylex(); np = (struct symtab *)yylval; shiftover(NAME); shiftover(CM); @@ -695,7 +711,7 @@ restlab: case IALIGN: /* .align */ stpt = (struct symtab *)yylval; - shift; + val = yylex(); expr(locxp, val); jalign(locxp, stpt); break; @@ -703,7 +719,7 @@ restlab: case INST0: /* instructions w/o arguments*/ incasetable = 0; insout(yyopcode, (struct arg *)0, 0); - shift; + val = yylex(); break; case INSTn: /* instructions with arguments*/ @@ -715,14 +731,13 @@ restlab: 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: @@ -750,7 +765,7 @@ restlab: case SIZESPEC: sizespec: sawsize = yylval; - shift; + val = yylex(); goto disp; case REG: @@ -762,7 +777,7 @@ restlab: case MUL: sawmul = 1; - shift; + val = yylex(); if (val == LP) goto base; if (val == LITOP) goto imm; if (val == SIZESPEC) goto sizespec; @@ -775,7 +790,7 @@ restlab: case LP: base: - shift; /*consume the LP*/ + val = yylex(); /*consume the LP*/ /* * hack the ambiguity of * movl (expr) (rn), ... @@ -794,7 +809,7 @@ restlab: findreg(regno); shiftover(RP); if (val == PLUS){ - shift; + val = yylex(); ap->a_atype = AINCR; } else ap->a_atype = ABASE; @@ -803,7 +818,7 @@ restlab: case LITOP: imm: - shift; + val = yylex(); expr(locxp, val); ap->a_atype = AIMM; ap->a_areg1 = 0; @@ -811,14 +826,14 @@ restlab: 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; @@ -897,7 +912,7 @@ restlab: * 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)){ @@ -912,9 +927,9 @@ restlab: 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; @@ -933,11 +948,11 @@ restlab: && (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*/ @@ -954,11 +969,8 @@ restlab: * 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; @@ -978,17 +990,12 @@ inttoktype funnyreg(val, regnoback) /*what the read head will sit on*/ /* * 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++; @@ -999,20 +1006,24 @@ vyyerror(s, argp) 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; @@ -1022,7 +1033,7 @@ yywarning(s, va_alist) 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"); diff --git a/bin/as/aspseudo.c b/bin/as/aspseudo.c index 91427c8..1c8fac9 100644 --- a/bin/as/aspseudo.c +++ b/bin/as/aspseudo.c @@ -1,28 +1,33 @@ +#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 -#include "as.h" +/*#include */ +/*#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) }; diff --git a/bin/as/asscan.h b/bin/as/asscan.h index 65029ae..a66f9b4 100644 --- a/bin/as/asscan.h +++ b/bin/as/asscan.h @@ -1,3 +1,15 @@ +#ifndef _ASSCAN_H_ +#define _ASSCAN_H_ + +/*#include asnumber.h*/ +#include "asnumber.h" + +#ifdef __STDC__ +#include +#else +typedef int intptr_t; +#endif + /* * Copyright (c) 1982 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -47,7 +59,7 @@ typedef u_short lgtype; /*for storing length of strings or skiping*/ /* * 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)) @@ -63,7 +75,7 @@ typedef u_short lgtype; /*for storing length of strings or skiping*/ #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)) @@ -80,9 +92,36 @@ typedef u_short lgtype; /*for storing length of strings or skiping*/ #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 diff --git a/bin/as/asscan1.c b/bin/as/asscan1.c index b1aa723..1ddcfae 100644 --- a/bin/as/asscan1.c +++ b/bin/as/asscan1.c @@ -1,14 +1,23 @@ +/*#include 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*/ @@ -20,14 +29,14 @@ struct tokbufdesc *tok_temp; /* temporary for doing list manipulation */ 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 */ @@ -35,8 +44,7 @@ int newfflag; char *newfname; int scanlineno; /*the scanner's linenumber*/ -inittokfile() -{ +void inittokfile() { if (passno == 1){ if (useVM){ bufstart = &tokbuf[0]; @@ -55,8 +63,7 @@ inittokfile() tokub = 0; } -closetokfile() -{ +void closetokfile() { if (passno == 1){ if (useVM){ emptybuf->toks[emptybuf->tok_count++] = PARSEEOF; @@ -84,16 +91,15 @@ closetokfile() } /*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: @@ -116,7 +122,7 @@ inttoktype yylex() 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]) @@ -203,7 +209,7 @@ inttoktype yylex() } /*end of the debug switch*/ printf("\n"); } -#endif DEBUG +#endif } else { /* start a new buffer */ if (useVM){ @@ -263,17 +269,14 @@ inttoktype yylex() 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; /* @@ -327,9 +330,7 @@ buildskip(from, to) } } -new_dot_s(namep) - char *namep; -{ +void new_dot_s(namep) char *namep; { newfflag = 1; newfname = namep; dotsname = namep; @@ -337,7 +338,6 @@ new_dot_s(namep) scanlineno = 1; } -min(a, b) -{ +int min(a, b) int a; int b; { return(a < b ? a : b); } diff --git a/bin/as/asscan2.c b/bin/as/asscan2.c index 6e544bf..7946ec1 100644 --- a/bin/as/asscan2.c +++ b/bin/as/asscan2.c @@ -1,14 +1,23 @@ +/*#include as.h*/ +#include +/*#include 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 @@ -18,8 +27,7 @@ char *Ginbufptr = inbuffer; int Ginbufcnt = 0; int scannerhadeof; -fillinbuffer() -{ +void fillinbuffer() { int nread; int goal; int got; @@ -52,26 +60,23 @@ fillinbuffer() 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]); @@ -79,7 +84,7 @@ scan_dot_s(bufferbox) 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); @@ -250,7 +255,7 @@ scan_dot_s(bufferbox) /* * Its a name... (Labels are subsets of name) */ - ryylval = (int)op; + ryylval = (intptr_t)op; val = NAME; break; case INST0: @@ -377,7 +382,7 @@ scan_dot_s(bufferbox) * 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; @@ -414,9 +419,9 @@ scan_dot_s(bufferbox) 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; @@ -426,20 +431,19 @@ scan_dot_s(bufferbox) 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]); diff --git a/bin/as/asscan3.c b/bin/as/asscan3.c index 5c93e6b..a2055c1 100644 --- a/bin/as/asscan3.c +++ b/bin/as/asscan3.c @@ -1,16 +1,19 @@ +#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, @@ -144,7 +147,7 @@ readonly short type[] = { 0 }; -readonly short charsets[] = { +short charsets[] = { /* '^@' 0x00 0000 */ 0, /* '^A' 0x01 0001 */ 0, /* '^B' 0x02 0002 */ 0, diff --git a/bin/as/asscan4.c b/bin/as/asscan4.c index 79b9578..29cc465 100644 --- a/bin/as/asscan4.c +++ b/bin/as/asscan4.c @@ -1,14 +1,22 @@ +/*#include 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))) @@ -17,15 +25,13 @@ static char numbuf[NUMSIZE]; #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 */ @@ -186,9 +192,7 @@ int number(ch) ch = getchar(); \ TOOLONG; -Bignum floatnumber(fltradix) - int fltradix; -{ +Bignum floatnumber(fltradix) int fltradix; { char *cp; int ch; char *toolong = "Floating number too long."; @@ -201,8 +205,8 @@ Bignum floatnumber(fltradix) Ovf overflow; int error; int fractOK; - reg char *inbufptr; - reg int inbufcnt; + register char *inbufptr; + register int inbufcnt; MEMTOREGBUF; cp = numbuf; @@ -255,14 +259,11 @@ Bignum floatnumber(fltradix) * 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(); diff --git a/bin/as/asscanl.h b/bin/as/asscanl.h index f6d28b7..3db95e3 100644 --- a/bin/as/asscanl.h +++ b/bin/as/asscanl.h @@ -1,3 +1,12 @@ +#ifndef _ASSCANL_H_ +#define _ASSCANL_H_ + +/*#include as.h*/ +#include +#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 @@ -13,9 +22,9 @@ * assembler. * The file ``asscan.h'' is shared with other parts of the assembler */ -#include -#include "as.h" -#include "asscan.h" +/*#include */ +/*#include "as.h"*/ +/*#include "asscan.h"*/ #define EOFCHAR (-1) /* @@ -80,8 +89,8 @@ extern struct tokbufdesc *tok_temp; /* temporary for doing list manipulation */ */ 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 @@ -107,8 +116,8 @@ extern ptrall tokub; /*the last token in the current token buffer*/ *(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 @@ -116,7 +125,7 @@ extern ptrall firsttoken; * 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 */ @@ -127,5 +136,7 @@ extern int scanlineno; /*the scanner's linenumber*/ /* * Definitions for sets of characters */ -extern readonly short charsets[]; -extern readonly short type[]; +extern short charsets[]; +extern short type[]; + +#endif diff --git a/bin/as/assizetab.c b/bin/as/assizetab.c index e953011..42c9e50 100644 --- a/bin/as/assizetab.c +++ b/bin/as/assizetab.c @@ -1,16 +1,21 @@ +/*#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 -#include "as.h" +/*#include as.h*/ +/*#include "as.h"*/ #include "assyms.h" /* diff --git a/bin/as/assyms.c b/bin/as/assyms.c index 125d2f8..fad8413 100644 --- a/bin/as/assyms.c +++ b/bin/as/assyms.c @@ -1,18 +1,34 @@ +/*#include as.h*/ +#include +#include +/*#include as.h*/ +/*#include gen.h*/ +/*#include as.h*/ +/*#include gen.h*/ +/*#include 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 -#include -#include "as.h" -#include "asscan.h" -#include "assyms.h" +/*#include */ +/*#include */ +/*#include "as.h"*/ +/*#include "asscan.h"*/ +/*#include "assyms.h"*/ /* * Managers for chunks of symbols allocated from calloc() @@ -48,8 +64,7 @@ int nlabels; /* number of label entries */ */ struct strpool *strplhead = 0; -symtabinit() -{ +void symtabinit() { allochead = 0; alloctail = 0; nextsym = 0; @@ -62,8 +77,7 @@ symtabinit() /* * Install all known instructions in the symbol table */ -syminstall() -{ +void syminstall() { register Iptr ip; register struct symtab **hp; register char *p1, *p2; @@ -107,16 +121,14 @@ syminstall() */ 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 */ /* @@ -149,8 +161,7 @@ freezesymtab() * Iteration order doesn't matter. */ -stabfix() -{ +void stabfix() { register struct symtab *sp, **cosp; register struct symtab *p; @@ -173,9 +184,7 @@ stabfix() } } -char *Calloc(number, size) - int number, size; -{ +char *Calloc(number, size) int number; int size; { register char *newstuff; void *sbrk(); newstuff = sbrk(number*size); @@ -186,16 +195,14 @@ char *Calloc(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)"); @@ -203,8 +210,7 @@ char *ClearCalloc(number, size) return(newstuff); } -struct symtab *symalloc() -{ +struct symtab *symalloc() { if (symsleft == 0){ newbox = (struct allocbox *)ClearCalloc(1,ALLOCQTY); symsleft = SYMDALLOP; @@ -221,8 +227,7 @@ struct symtab *symalloc() return(nextsym++); } -strpoolalloc() -{ +void strpoolalloc() { register struct strpool *new; new = (struct strpool *)Calloc(1, sizeof (struct strpool)); @@ -231,9 +236,7 @@ strpoolalloc() 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) @@ -270,8 +273,7 @@ symcmp(Pptr, Qptr) * already have an estimated final value */ -sortsymtab() -{ +void sortsymtab() { register struct symtab *sp; register struct symtab **cowalk; register struct allocbox *allocwalk; @@ -303,7 +305,7 @@ sortsymtab() 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; @@ -314,8 +316,7 @@ sortsymtab() } /*end of sortsymtab*/ #ifdef DEBUG -dumpsymtab() -{ +int dumpsymtab() { register int segno; register struct symtab *sp, **cosp, *ub; char *tagstring(); @@ -337,9 +338,7 @@ dumpsymtab() 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"); @@ -359,10 +358,9 @@ char *tagstring(tag) return(tagbuff); } } -#endif DEBUG +#endif -htaballoc() -{ +void htaballoc() { register struct hashdallop *new; new = (struct hashdallop *)ClearCalloc(1, sizeof (struct hashdallop)); if (htab == 0) @@ -386,9 +384,7 @@ htaballoc() * 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; @@ -418,8 +414,7 @@ struct symtab **lookup(instflg) (*hp) && (nprobes < NHASH); hp += nprobes, hp -= (hp >= hp_ub) ? NHASH:0, - nprobes += 2) - { + nprobes += 2) { from = yytext; to = FETCHNAME(*hp); while (*from && *to) @@ -455,12 +450,8 @@ struct symtab **lookup(instflg) /* * 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 @@ -486,7 +477,7 @@ struct strdesc *savestr(str, len, place) * 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); @@ -522,8 +513,7 @@ static struct relbufdesc *rel_temp; 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; @@ -534,10 +524,7 @@ initoutrel() 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; @@ -610,9 +597,7 @@ outrel(xp, reloc_how) * 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(); @@ -627,10 +612,7 @@ off_t closeoutrel(relocfile) 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); @@ -642,8 +624,7 @@ u_long Closeoutrel(relfil, relocfile) } #define NOUTSYMS (nsyms - njxxx - nforgotten - (savelabels ? 0 : nlabels)) -int sizesymtab() -{ +int sizesymtab() { return (sizeof (struct nlist) * NOUTSYMS); } /* @@ -651,13 +632,15 @@ int sizesymtab() * 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 @@ -673,6 +656,30 @@ int symwrite(symfile) 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 @@ -693,6 +700,7 @@ int symwrite(symfile) 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", @@ -702,7 +710,7 @@ int symwrite(symfile) * 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) diff --git a/bin/as/assyms.h b/bin/as/assyms.h index 0b9f5cb..8262d60 100644 --- a/bin/as/assyms.h +++ b/bin/as/assyms.h @@ -1,3 +1,8 @@ +#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 @@ -96,3 +101,5 @@ struct hashdallop { struct hashdallop *h_next; struct symtab *h_htab[NHASH]; }; + +#endif diff --git a/bin/as/astoks.h b/bin/as/astoks.h index a727a94..ea90a40 100644 --- a/bin/as/astoks.h +++ b/bin/as/astoks.h @@ -1,3 +1,6 @@ +#ifndef _ASTOKS_H_ +#define _ASTOKS_H_ + # define FIRSTTOKEN 0 # define ISPACE 1 # define IBYTE 2 @@ -75,3 +78,5 @@ # define RB 74 # define RP 75 # define LASTTOKEN 76 + +#endif diff --git a/bin/as/bignum1.c b/bin/as/bignum1.c index 9451594..64a714b 100644 --- a/bin/as/bignum1.c +++ b/bin/as/bignum1.c @@ -1,25 +1,29 @@ +#include +#include +/*#include 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 -#include -#include "as.h" +/*#include */ +/*#include */ +/*#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(); @@ -48,14 +52,10 @@ Bignum as_atof(numbuf, radix, ovfp) * 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; @@ -132,8 +132,7 @@ Bignum as_atoi(ccp, radix, ovfp) for (i = 0; i < CH_N; i++){ if (bcp[i] == val) break; - } - { + } { static u_char tagtab[4][16] = { { TYPB, TYPW, @@ -163,10 +162,8 @@ Bignum as_atoi(ccp, radix, ovfp) 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) @@ -184,16 +181,12 @@ Ovf posovf(src) /* * 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{ @@ -203,10 +196,8 @@ int isunequal(src1, src2) 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; @@ -214,14 +205,11 @@ Ovf numclear(dst) 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){ @@ -260,22 +248,17 @@ Ovf numshift(n, dst, src) } } -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; @@ -291,9 +274,7 @@ Ovf numaddv(dst, src1, src2) 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) ; @@ -301,10 +282,8 @@ Ovf numnegate(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++; @@ -318,16 +297,12 @@ Ovf num1comp(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; @@ -372,11 +347,8 @@ int slitflt(number, argtype, valuep) * 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; @@ -396,4 +368,4 @@ bignumwrite(number, toconv) } bwrite((char *)bp, ty_nbyte[toconv], txtfil); } -#endif STANDALONE +#endif diff --git a/bin/as/bignum2.c b/bin/as/bignum2.c index 231b8c9..7cec57f 100644 --- a/bin/as/bignum2.c +++ b/bin/as/bignum2.c @@ -1,23 +1,27 @@ +/*#include as.h*/ +/*#include 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 -#include "as.h" +/*#include */ +/*#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)){ @@ -32,11 +36,8 @@ Bignum intconvert(number, convto) #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; @@ -47,7 +48,7 @@ Bignum floatconvert(number, convto) bp = &number.num_uint[0]; #ifdef lint *bp = *bp; -#endif lint +#endif switch(CONV(number.num_tag, convto)){ @@ -98,11 +99,7 @@ Bignum floatconvert(number, 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; @@ -118,19 +115,16 @@ Bignum bignumconvert(number, toconv, ovfp) 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; @@ -236,22 +230,18 @@ Bignum bignumunpack(Packed, ovfp) 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; @@ -403,13 +393,9 @@ Bignum bignumpack(Unpacked, toconv, ovfp) /*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; @@ -430,18 +416,14 @@ mapnumber(chp1, chp2, nbytes, themap) * 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; /* @@ -497,9 +479,7 @@ int upround(numberp, p, exponent) 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, @@ -528,9 +508,7 @@ bignumprint(number) } } -numprintovf(ovf) - Ovf ovf; -{ +int numprintovf(ovf) Ovf ovf; { int i; static struct ovftab{ Ovf which; @@ -553,4 +531,4 @@ numprintovf(ovf) printf("Overflow(%s) ", ovftab[i].print); } } -#endif DEBUG +#endif diff --git a/bin/as/floattab.c b/bin/as/floattab.c index 7f6ea39..6965a59 100644 --- a/bin/as/floattab.c +++ b/bin/as/floattab.c @@ -1,15 +1,20 @@ +/*#include 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 -#include "as.h" +/*#include */ +/*#include "as.h"*/ #define N NOTAKE struct ty_bigdesc ty_bigdesc[] = { @@ -112,15 +117,24 @@ 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++){ diff --git a/bin/as/instrs.h b/bin/as/instrs.h index 99768fb..26a2d31 100644 --- a/bin/as/instrs.h +++ b/bin/as/instrs.h @@ -1,3 +1,8 @@ +#ifndef _INSTRS_H_ +#define _INSTRS_H_ + +#include + /* * Copyright (c) 1982 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -143,3 +148,5 @@ extern struct insttab{ #define NEW 1 #define ESCD 0xfd #define ESCF 0xff + +#endif diff --git a/bin/as/natof.c b/bin/as/natof.c index 2cb3abf..775db8e 100644 --- a/bin/as/natof.c +++ b/bin/as/natof.c @@ -1,32 +1,37 @@ +#include +/*#include as.h*/ +#include +/*#include 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 -#include -#include +/*#include */ +/*#include */ +/*#include */ -#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 */ @@ -42,7 +47,7 @@ Bignum bigatof(str, radix) #ifdef lint quotient = 0; remainder = 0; -#endif lint +#endif msign = 0; esign = 0; decpt = 0; @@ -196,7 +201,7 @@ Bignum bigatof(str, radix) printf("Dividing: "); bignumprint(Acc); printf("\n"); -#endif DEBUGNATOF +#endif sptr = (short *)acc; for (i = (CH_N * 2 - 1); i >= 1; --i){ /* @@ -272,7 +277,7 @@ Bignum bigatof(str, radix) printf("Octal number: "); bignumprint(Acc); printf("\n"); -#endif DEBUGNATOF +#endif Acc = bignumunpack(Acc, &ovf); if (ovf) @@ -281,7 +286,7 @@ Bignum bigatof(str, radix) 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; @@ -298,7 +303,7 @@ Bignum bigatof(str, radix) printf("packed number: "); bignumprint(Acc); printf("\n"); -#endif DEBUGNATOF +#endif return(Acc); } #if 0 @@ -309,12 +314,7 @@ Bignum bigatof(str, radix) * 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 */ @@ -322,4 +322,4 @@ unsigned int ediv(high, low, divisor, qp, i) *qp = quotient; return(remainder); } -#endif 0 +#endif diff --git a/include/a.out.h b/include/a.out.h index 9aab698..65ed165 100644 --- a/include/a.out.h +++ b/include/a.out.h @@ -51,7 +51,9 @@ unsigned int r_symbolnum:24, /* local symbol ordinal */ */ 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 */ -- 2.34.1