minix/lib/libc/arch/i386/misc/alloca.s

34 lines
801 B
ArmAsm
Raw Normal View History

2005-04-21 16:53:53 +02:00
#
! alloca() - allocate space on the stack Author: Kees J. Bot
! 2 Dec 1993
.sect .text; .sect .rom; .sect .data; .sect .bss
.sect .text
.align 16
.define _alloca
_alloca:
#if __ACK__
pop ecx ! Return address
pop eax ! Bytes to allocate
add eax, 2*4+3 ! Add space for two saved register variables
andb al, 0xFC ! Align
mov ebx, esp ! Keep current esp
sub esp, eax ! Lower stack
mov eax, esp ! 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
add eax, 3
andb al, 0xFC ! Align
sub esp, eax ! Lower stack
mov eax, esp ! Return value
push eax ! Dummy argument
jmp ecx
#endif