1* $Id: alloca.asm,v 1.1.1.1 2000/06/27 01:48:00 amura Exp $ 2* 3* alloca() For SAS/C 6.0 By H.Konishi. 4* 5* This routine was written by Stephen Walton, swalton@solar.stanford.edu, 6* a rank asm amateur, to attempt to provide the alloca() function for Manx 7* Aztec C on the Amiga. It probably does horrible illegal things to the 8* stack but seems to mostly work. 9* 10* This subroutine expects a single int as argument, and returns a pointer 11* to a block of memory of that size allocated off the local stack. Thus, 12* this memory is automatically freed when the current subroutine exits. 13* 14* This version for the default Manx settings (int = 16 bits). To use 15* with int=32 bits, simply change both the ".w" to ".l" 16* 17* $Log: alloca.asm,v $ 18* Revision 1.1.1.1 2000/06/27 01:48:00 amura 19* import to CVS 20* 21* 22 xdef _alloca 23 section code 24_alloca: 25 move.l a7,a1 ; Save current value of stack pointer 26 move.w 4(a7),d0 ; Number of bytes needed 27 suba.w d0,a7 ; Move stack up that many places 28 move.l (a1),(a7) ; Place return address in proper place 29 move.l a7,d0 ; Return value into d0 30 add.l #6,d0 ; plus amount by which stack is popped 31 rts ; And back we go 32 33 end