
static char null_zap[8] = "\0\0\0\0\0\0\0";

char ** environ = 0;
void (*__cleanup)() = 0;

#asm
.text
entry __startup
__startup:
  mov	bx,sp
  mov	ax,[bx]
  shl	ax,#1
  add	ax,bx
  add	ax,#4
  push	ax
  mov	[_environ],ax
  mov	ax,[bx]
  add	bx,#2
  push	bx
  push	ax
  call	_main
  push	ax
Z:
  call	_exit
  jmp	Z

export _exit
export __exit
_exit:
  mov	bx,[___cleanup];
  test	bx,bx
  je	__exit
  call	[bx]
__exit:
  mov	bx,sp
  push	[bx+2]
  call  ___exit
  inc	sp
  inc	sp
  ret

#endasm

/* This is what the assembler for exit does. *
exit(rv)
{
   if(__cleanup) (*__cleanup)();
   __exit(rv);
}
/* */
