static char sccsid
[] = " unixstart.c 4.2 84/05/05 ";
/* From Lou Salkind: compat/RCS/unixstart.c,v 1.2 84/01/31 13:34:27 */
/* Start up a version 6 or version 7 pdp-11 UNIX compatability mode
* program. Must set up the memory layout with args etc.
start(argv
, envp
) unsigned char **argv
, **envp
; {
register unsigned char *sp
, *ap
;
register unsigned short *ssp
;
register int i
, argc
, envc
;
unsigned char *envps
[MAXARGS
], *argps
[MAXARGS
], **av
, *p1
, *p2
;
extern unsigned char *progname
, *nameend
;
/* set up initial memory layout for unix */
/* set stack pointer to top of memory */
/* point to environment pointer list */
/* count up number of env elements */
/* last UNIX V7 env ptr is 0 */
envps
[envc
] = (unsigned char *)0;
/* copy actual environment (assume byte text) - last first */
for(i
=envc
-1; i
>=0; i
--) {
while(ap
!= envp
[i
]) *(--sp
) = *(--ap
);
/* force stack word alignment - required per arg in v7 */
while((*(ap
-1) = *ap
)) ap
++;
/* point to argument pointer list */
/* count up number of args */
/* last UNIX V7 arg ptr is 0 */
argps
[argc
] = (unsigned char *)0;
/* last UNIX V6 arg ptr is -1 */
argps
[argc
] = (unsigned char *)-1;
/* copy actual arguments (assume byte text) - last first */
for(i
=argc
-1; i
>=0; i
--) {
while(ap
!= argv
[i
]) *(--sp
) = *(--ap
);
/* force stack word alignment - required per arg in v7 */
while((*(ap
-1) = *ap
)) ap
++;
ssp
= (unsigned short *)sp
;
/* set up environment pointers */
*(--ssp
) = (short)(long)envps
[i
];
/* set up argument pointers */
*(--ssp
) = (short)(long)argps
[i
];
/* then argument count */
/* set up stack pointer */
/* set up a psl with cleared condition codes */
/* copy out part of the program name and args where ps can get them */
/* flag it with a * so it shows up as a compatability mode process */
/* check for case with no env and reset nameend */
if(nameend
< progname
) nameend
= (unsigned char *)2147483647;
for(p1
=progname
, *p1
++ = '*', i
=1, p2
=argv
[0]; p1
<nameend
; p1
++) {
while(p1
< nameend
) *p1
++ = ' ';
/* clear out registers other than sp */
/* finally get around to actually starting up in compatability mode */