ANSI C conversion

This commit is contained in:
carl 2019-05-11 01:10:47 +08:00
parent 04cb629159
commit 628dcb3cbf
2 changed files with 36 additions and 24 deletions

View file

@ -1,7 +1,3 @@
#ifndef NORCSID
static char rcsid[] = "$Id$";
#endif
/* /*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
@ -13,10 +9,12 @@ static char rcsid[] = "$Id$";
* machine dependent back end routines for the PDP-11 * machine dependent back end routines for the PDP-11
*/ */
/* #define REGPATCH /* save all registers in markblock */ /* #define REGPATCH */ /* save all registers in markblock */
con_part(sz,w) register sz; word w; {
void con_part(register int sz, word w)
{
while (part_size % sz) while (part_size % sz)
part_size++; part_size++;
if (part_size == TEM_WSIZE) if (part_size == TEM_WSIZE)
@ -33,8 +31,8 @@ con_part(sz,w) register sz; word w; {
part_size += sz; part_size += sz;
} }
con_mult(sz) word sz; { void con_mult(word sz) {
long l, atol(); long l;
if (sz != 4) if (sz != 4)
fatal("bad icon/ucon size"); fatal("bad icon/ucon size");
@ -63,8 +61,8 @@ struct regadm {
} regadm[2]; } regadm[2];
int n_regvars; int n_regvars;
regscore(off,size,typ,score,totyp) long off; { int regscore(long off,int size,int typ,int score,int totyp)
{
if (size != 2) if (size != 2)
return(-1); return(-1);
score -= 1; /* allow for save/restore */ score -= 1; /* allow for save/restore */
@ -79,14 +77,14 @@ regscore(off,size,typ,score,totyp) long off; {
return(score); /* estimated # of words of profit */ return(score); /* estimated # of words of profit */
} }
i_regsave() { void i_regsave(void) {
Rstring[0] = 0; Rstring[0] = 0;
n_regvars=0; n_regvars=0;
} }
f_regsave() { void f_regsave(void) {
register i; register int i;
if (n_regvars==0 || lbytes==0) { if (n_regvars==0 || lbytes==0) {
#ifdef REGPATCH #ifdef REGPATCH
@ -113,8 +111,8 @@ f_regsave() {
regadm[i].ra_str); regadm[i].ra_str);
} }
regsave(regstr,off,size) char *regstr; long off; { void regsave(char *regstr,long off,int size)
{
fprintf(codefile,"%c Local %ld into %s\n",COMMENTCHAR,off,regstr); fprintf(codefile,"%c Local %ld into %s\n",COMMENTCHAR,off,regstr);
/* commented away /* commented away
#ifndef REGPATCH #ifndef REGPATCH
@ -131,7 +129,7 @@ end of commented away */
n_regvars++; n_regvars++;
} }
regreturn() { void regreturn(void) {
#ifdef REGPATCH #ifdef REGPATCH
fprintf(codefile,"jmp eret\n"); fprintf(codefile,"jmp eret\n");
@ -142,7 +140,7 @@ regreturn() {
#endif #endif
prolog(nlocals) full nlocals; { void prolog(full nlocals) {
#ifndef REGVARS #ifndef REGVARS
#ifdef REGPATCH #ifdef REGPATCH
@ -160,8 +158,8 @@ prolog(nlocals) full nlocals; {
#endif #endif
} }
dlbdlb(as,ls) string as,ls; { void dlbdlb(string as,string ls)
{
if (strlen(as)+strlen(ls)+2<sizeof(labstr)) { if (strlen(as)+strlen(ls)+2<sizeof(labstr)) {
strcat(ls,":"); strcat(ls,":");
strcat(ls,as); strcat(ls,as);
@ -169,7 +167,8 @@ dlbdlb(as,ls) string as,ls; {
fatal("too many consecutive labels"); fatal("too many consecutive labels");
} }
mes(type) word type; { void mes(word type)
{
int argt; int argt;
switch ( (int)type ) { switch ( (int)type ) {

View file

@ -10,6 +10,10 @@
*/ */
#define ACK_ASS /* code for ACK assembler */ #define ACK_ASS /* code for ACK assembler */
#include "tables.h"
#include "types.h"
#ifdef ACK_ASS #ifdef ACK_ASS
#define COMMENTCHAR '!' #define COMMENTCHAR '!'
#define ex_ap(y) fprintf(codefile,".extern %s\n",y) #define ex_ap(y) fprintf(codefile,".extern %s\n",y)
@ -34,14 +38,14 @@
#define dlb_fmt "_%d" #define dlb_fmt "_%d"
#define hol_fmt "hol%d" #define hol_fmt "hol%d"
#define hol_off "%d+hol%d" #define hol_off "%ld+hol%d"
#ifdef ACK_ASS #ifdef ACK_ASS
#define con_cst(x) fprintf(codefile,".data2 %d\n",x) #define con_cst(x) fprintf(codefile,".data2 %ld\n",x)
#define con_ilb(x) fprintf(codefile,".data2 %s\n",x) #define con_ilb(x) fprintf(codefile,".data2 %s\n",x)
#define con_dlb(x) fprintf(codefile,".data2 %s\n",x) #define con_dlb(x) fprintf(codefile,".data2 %s\n",x)
#else #else
#define con_cst(x) fprintf(codefile,"%d\n",x) #define con_cst(x) fprintf(codefile,"%ld\n",x)
#define con_ilb(x) fprintf(codefile,"%s\n",x) #define con_ilb(x) fprintf(codefile,"%s\n",x)
#define con_dlb(x) fprintf(codefile,"%s\n",x) #define con_dlb(x) fprintf(codefile,"%s\n",x)
#endif #endif
@ -54,3 +58,12 @@
#endif #endif
#define BSS_INIT 0 #define BSS_INIT 0
void con_float(void);
void con_mult(word sz);
void con_part(register int sz, word w);
void dlbdlb(string as,string ls);
void mes(word type);
void prolog(full nlocals);