SCCS-vsn: usr.bin/pascal/src/put.c 1.24
SCCS-vsn: usr.bin/pascal/src/func.c 1.12
/* Copyright (c) 1979 Regents of the University of California */
/* Copyright (c) 1979 Regents of the University of California */
-static char sccsid[] = "@(#)put.c 1.26 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)put.c 1.24 8/19/83";
+#endif
#include "whoami.h"
#include "opcode.h"
#include "whoami.h"
#include "opcode.h"
#ifdef PC
# include "pc.h"
# include "align.h"
#ifdef PC
# include "pc.h"
# include "align.h"
-#endif PC
-
-short *obufp = obuf;
+#else
+ short *obufp = obuf;
+#endif
/*
* If DEBUG is defined, include the table
/*
* If DEBUG is defined, include the table
* generation. Since the interpreter is specifically designed
* for Pascal, little work is required here.
*/
* generation. Since the interpreter is specifically designed
* for Pascal, little work is required here.
*/
put(a)
{
register int *p, i;
register char *cp;
register short *sp;
register long *lp;
put(a)
{
register int *p, i;
register char *cp;
register short *sp;
register long *lp;
- int n, subop, suboppr, op, oldlc, w;
+ int n, subop, suboppr, op, oldlc;
char *string;
static int casewrd;
char *string;
static int casewrd;
* relational operators could be used
* etc.
*/
* relational operators could be used
* etc.
*/
+ oldlc = (int) lc; /* its either this or change put to return a char * */
if ( !CGENNING )
/*
* code disabled - do nothing
if ( !CGENNING )
/*
* code disabled - do nothing
+ short *sp = (short *) (&p[1]);
#ifdef DEBUG
if ( opt( 'k' ) )
#ifdef DEBUG
if ( opt( 'k' ) )
register struct nl *ap;
{
struct nl *next;
register struct nl *ap;
{
struct nl *next;
- register int oldlc, len;
+#ifdef OBJ
+ register int oldlc;
+#endif
+ register int len;
register unsigned w;
register char *strptr;
register unsigned w;
register char *strptr;
return( ap -> value[ NL_ELABEL ] );
}
# ifdef OBJ
return( ap -> value[ NL_ELABEL ] );
}
# ifdef OBJ
- oldlc = lc;
- put(2, O_TRA, lc);
- ap->value[ NL_ELABEL ] = lc;
+ oldlc = (int) lc; /* same problem as put */
+ (void) put(2, O_TRA, lc);
+ ap->value[ NL_ELABEL ] = (int) lc;
# endif OBJ
# ifdef PC
putprintf(" .data", 0);
aligndot(A_STRUCT);
# endif OBJ
# ifdef PC
putprintf(" .data", 0);
aligndot(A_STRUCT);
- ap -> value[ NL_ELABEL ] = getlab();
- putlab( ap -> value[ NL_ELABEL ] );
+ ap -> value[ NL_ELABEL ] = (int) getlab();
+ (void) putlab((char *) ap -> value[ NL_ELABEL ] );
# endif PC
/* number of scalars */
next = ap->type;
len = next->range[1]-next->range[0]+1;
# ifdef OBJ
# endif PC
/* number of scalars */
next = ap->type;
len = next->range[1]-next->range[0]+1;
# ifdef OBJ
+ (void) put(2, O_CASE2, len);
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
/* offsets of each scalar name */
len = (len+1)*sizeof(short);
# ifdef OBJ
/* offsets of each scalar name */
len = (len+1)*sizeof(short);
# ifdef OBJ
+ (void) put(2, O_CASE2, len);
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
continue;
len++;
# ifdef OBJ
continue;
len++;
# ifdef OBJ
+ (void) put(2, O_CASE2, len);
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
# endif OBJ
# ifdef PC
putprintf( " .word %d" , 0 , len );
# endif DEC11
if (!*strptr++)
strptr = getnext(next, &next);
# endif DEC11
if (!*strptr++)
strptr = getnext(next, &next);
} while (next);
/* jump over the mess */
} while (next);
/* jump over the mess */
+ patch((PTR_DCL) oldlc);
# endif OBJ
# ifdef PC
while ( next ) {
# endif OBJ
# ifdef PC
while ( next ) {
return( ap -> value[ NL_ELABEL ] );
}
return( ap -> value[ NL_ELABEL ] );
}
getnext(next, new)
struct nl *next, **new;
getnext(next, new)
struct nl *next, **new;
next = next->chain;
*new = next;
}
next = next->chain;
*new = next;
}
return("");
#ifdef OBJ
if (opt('k') && CGENNING )
return("");
#ifdef OBJ
if (opt('k') && CGENNING )
/*
* code disabled - do nothing
*/
/*
* code disabled - do nothing
*/
#ifdef DEBUG
if (opt('k'))
printf("%5d\t.=.+%d\n", lc - HEADER_BYTES, n);
#ifdef DEBUG
if (opt('k'))
printf("%5d\t.=.+%d\n", lc - HEADER_BYTES, n);
/*
* code disabled - do nothing
*/
/*
* code disabled - do nothing
*/
#ifdef DEBUG
if (opt('k'))
printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, strptr);
#ifdef DEBUG
if (opt('k'))
printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, strptr);
# else
w |= *++strptr;
# endif DEC11
# else
w |= *++strptr;
# endif DEC11
} while (*strptr++);
} else {
# ifdef DEC11
} while (*strptr++);
} else {
# ifdef DEC11
}
} while (*strptr++);
# else
}
} while (*strptr++);
# else
lenstr(sptr, padding)
char *sptr;
lenstr(sptr, padding)
char *sptr;
} while (*strptr++);
return((++cnt) & ~1);
}
} while (*strptr++);
return((++cnt) & ~1);
}
\f
/*
* Patch repairs the branch
\f
/*
* Patch repairs the branch
* lets here it for two pass assemblers.
*/
patch(loc)
* lets here it for two pass assemblers.
*/
patch(loc)
{
# ifdef OBJ
patchfil(loc, (long)(lc-loc-2), 1);
# endif OBJ
# ifdef PC
{
# ifdef OBJ
patchfil(loc, (long)(lc-loc-2), 1);
# endif OBJ
# ifdef PC
+ (void) putlab((char *) loc );
# endif PC
}
#ifdef OBJ
patch4(loc)
# endif PC
}
#ifdef OBJ
patch4(loc)
{
patchfil(loc, (long)(lc - HEADER_BYTES), 2);
}
{
patchfil(loc, (long)(lc - HEADER_BYTES), 2);
}
short val;
if ( !CGENNING )
short val;
if ( !CGENNING )
if (i >= 0 && i < 1024) {
obuf[i] = val;
} else {
if (i >= 0 && i < 1024) {
obuf[i] = val;
} else {
- lseek(ofil, (long) loc+2, 0);
- write(ofil, &val, 2);
- lseek(ofil, (long) 0, 2);
+ (void) lseek(ofil, (long) loc+2, 0);
+ write(ofil, (char *) (&val), 2);
+ (void) lseek(ofil, (long) 0, 2);
}
loc += 2;
# ifdef DEC11
}
loc += 2;
# ifdef DEC11
register i;
i = (obufp - ( ( short * ) obuf ) ) * 2;
register i;
i = (obufp - ( ( short * ) obuf ) ) * 2;
- if (i != 0 && write(ofil, obuf, i) != i)
+ if (i != 0 && write(ofil, (char *) obuf, i) != i)
perror(obj), pexit(DIED);
obufp = obuf;
}
perror(obj), pexit(DIED);
obufp = obuf;
}
* included here for the eventual code generator.
* for PC, thank you!
*/
* included here for the eventual code generator.
* for PC, thank you!
*/
# ifdef PC
static long lastlabel;
# ifdef PC
static long lastlabel;
- return ( ++lastlabel );
+ return ( (char *) ++lastlabel );
* Putlab - lay down a label.
* for PC, just print the label name with a colon after it.
*/
* Putlab - lay down a label.
* for PC, just print the label name with a colon after it.
*/
- putprintf( PREFIXFORMAT , 1 , LABELPREFIX , l );
+ putprintf( PREFIXFORMAT , 1 , (int) LABELPREFIX , (int) l );
putprintf( ":" , 0 );
# endif PC
return (l);
putprintf( ":" , 0 );
# endif PC
return (l);