2010-03-03 15:27:30 +01:00
|
|
|
/* */
|
|
|
|
/* alloca() - allocate space on the stack Author: Kees J. Bot */
|
|
|
|
/* 2 Dec 1993 */
|
|
|
|
|
2010-08-17 18:44:07 +02:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
|
|
|
ENTRY(alloca)
|
2010-03-03 15:27:30 +01:00
|
|
|
#if __ACK__
|
|
|
|
pop %ecx /* Return address */
|
|
|
|
pop %eax /* Bytes to allocate */
|
|
|
|
addl $2*4+3, %eax /* Add space for two saved register variables */
|
2010-05-04 23:02:44 +02:00
|
|
|
andb $0xF8, %al /* Align */
|
2010-03-03 15:27:30 +01:00
|
|
|
movl %esp, %ebx /* Keep current esp */
|
|
|
|
subl %eax, %esp /* Lower stack */
|
|
|
|
movl %esp, %eax /* Return value */
|
|
|
|
push 4(%ebx) /* Push what is probably the saved esi */
|
|
|
|
push (%ebx) /* Saved edi */
|
|
|
|
/* Now ACK can still do: */
|
|
|
|
/* pop edi; pop esi; leave; ret */
|
|
|
|
push %eax /* Dummy argument */
|
|
|
|
jmp *%ecx
|
|
|
|
#else
|
|
|
|
pop %ecx /* Return address */
|
|
|
|
pop %eax /* Bytes to allocate */
|
|
|
|
addl $3, %eax
|
2010-05-04 23:02:44 +02:00
|
|
|
andb $0xF8, %al /* Align */
|
2010-03-03 15:27:30 +01:00
|
|
|
subl %eax, %esp /* Lower stack */
|
|
|
|
movl %esp, %eax /* Return value */
|
|
|
|
push %eax /* Dummy argument */
|
|
|
|
jmp *%ecx
|
|
|
|
#endif
|