alloca.S revision 1.5
11.5Sthorpej/* $NetBSD: alloca.S,v 1.5 1999/10/25 23:48:09 thorpej Exp $ */ 21.2Sthorpej 31.1Spaulus/*- 41.1Spaulus * Copyright (c) 1990 The Regents of the University of California. 51.1Spaulus * All rights reserved. 61.1Spaulus * 71.1Spaulus * This code is derived from software contributed to Berkeley by 81.1Spaulus * the Systems Programming Group of the University of Utah Computer 91.1Spaulus * Science Department. 101.1Spaulus * 111.1Spaulus * Redistribution and use in source and binary forms, with or without 121.1Spaulus * modification, are permitted provided that the following conditions 131.1Spaulus * are met: 141.1Spaulus * 1. Redistributions of source code must retain the above copyright 151.1Spaulus * notice, this list of conditions and the following disclaimer. 161.1Spaulus * 2. Redistributions in binary form must reproduce the above copyright 171.1Spaulus * notice, this list of conditions and the following disclaimer in the 181.1Spaulus * documentation and/or other materials provided with the distribution. 191.1Spaulus * 3. All advertising materials mentioning features or use of this software 201.1Spaulus * must display the following acknowledgement: 211.1Spaulus * This product includes software developed by the University of 221.1Spaulus * California, Berkeley and its contributors. 231.1Spaulus * 4. Neither the name of the University nor the names of its contributors 241.1Spaulus * may be used to endorse or promote products derived from this software 251.1Spaulus * without specific prior written permission. 261.1Spaulus * 271.1Spaulus * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 281.1Spaulus * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 291.1Spaulus * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 301.1Spaulus * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 311.1Spaulus * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 321.1Spaulus * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 331.1Spaulus * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 341.1Spaulus * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 351.1Spaulus * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 361.1Spaulus * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 371.1Spaulus * SUCH DAMAGE. 381.1Spaulus */ 391.1Spaulus 401.3Sthorpej#include <machine/asm.h> 411.2Sthorpej 421.1Spaulus#if defined(LIBC_SCCS) && !defined(lint) 431.2Sthorpej#if 0 441.2Sthorpej RCSID("from: @(#)alloca.s 5.1 (Berkeley) 5/12/90") 451.2Sthorpej#else 461.5Sthorpej RCSID("$NetBSD: alloca.S,v 1.5 1999/10/25 23:48:09 thorpej Exp $") 471.2Sthorpej#endif 481.1Spaulus#endif /* LIBC_SCCS and not lint */ 491.1Spaulus 501.1Spaulus/* like alloc, but automatic free in return */ 511.1Spaulus 521.1SpaulusENTRY(alloca) 531.5Sthorpej movl %sp@,%a1 /* save return addr */ 541.5Sthorpej movl %sp,%d0 /* get current SP value */ 551.5Sthorpej subl %sp@(4),%d0 /* allocate requested space */ 561.5Sthorpej andb #~3,%d0 /* longword align for efficiency */ 571.5Sthorpej addql #8,%d0 /* reuse space of call frame */ 581.5Sthorpej movl %d0,%sp /* set new SP value */ 591.5Sthorpej lea %sp@(-4),%sp /* account for argument pop in caller */ 601.4Skleink#ifdef __SVR4_ABI__ 611.5Sthorpej moveal %d0,%a0 621.4Skleink#endif 631.5Sthorpej jmp %a1@ /* funny return */ 64