xref: /original-bsd/lib/libc/i386/gen/alloca.s (revision 4f00418d)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)alloca.s	8.1 (Berkeley) 06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15/* like alloc, but automatic automatic free in return */
16
17#include "DEFS.h"
18
19ENTRY(alloca)
20	popl	%edx		/*  pop return addr */
21	popl	%eax		/*  pop amount to allocate */
22	movl	%esp,%ecx
23	addl	$3,%eax		/*  round up to next word */
24	andl	$0xfffffffc,%eax
25	subl	%eax,%esp
26	movl	%esp,%eax	/* base of newly allocated space */
27	pushl	8(%ecx)		/* copy possible saved registers */
28	pushl	4(%ecx)
29	pushl	0(%ecx)
30	pushl	%eax		/* dummy to pop at callsite */
31	jmp	%edx		/* "return" */
32