	.file	"alloca.s"
/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */


/*	Copyright (c) 1986 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

	.ident	"$Header: alloca.s 1.7 89/10/10 $@(#)libPW:i386/alloca.s	1.0"

/*
 *	Max caller register save area is:
 *	24*4 = weitek registers (%fp8 - %f31 inclusive)
 *	 3*4 = general registers (%ebx, %esi, %edi)
 *	====
 *	27*4 = 108 = total bytes
 */

#include "sys.s"

ENTRY(alloca)
	popl	%edx		/* %edx = return address */
	leal	4(%esp),%ecx	/* %ecx = saved register area */
	/* operate on a copy of %esp so it is always dword aligned */
	movl	%esp,%eax	/* %eax = current stack pointer */
	subl	(%esp),%eax	/* allocate the request */
	andl	$-4,%eax	/* round down to dword boundary */
	movl	%eax,%esp	/* update stack pointer */
	leal	4(%esp),%eax	/* %eax = return value */
	subl	$108,%esp	/* allocate new saved register area */
	pushl	%esi		/* save %esi */
	pushl	%edi		/* save %edi */
	movl	%ecx,%esi	/* source */
	leal	12(%esp),%edi	/* destination */
	movl	$26,%ecx	/* 26 words or 104 bytes max size of saved 
				/* registers */
	rep ;	smovl		/* copy saved registers */
	popl	%edi		/* restore %edi */
	popl	%esi		/* restore %esi */
	jmp	*%edx		/* return through register */
				/* BTW: caller will pop 4 bytes */
