kolibrios-gitea/programs/develop/libraries/libmpg123/chkstk.S
Sergey Semyonov (Serge) a316fa7c9d libmpg123 1.9.0
git-svn-id: svn://kolibrios.org@1905 a494cfbc-eb01-0410-851d-a64ba20cac60
2011-03-11 10:57:03 +00:00

37 lines
1.1 KiB
ArmAsm

.global ___chkstk
.global __alloca
.section .text
___chkstk:
__alloca:
pushl %ecx /* save temp */
leal 8(%esp), %ecx /* point past return addr */
cmpl $0x1000, %eax /* > 4k ?*/
jb Ldone
Lprobe:
subl $0x1000, %ecx /* yes, move pointer down 4k*/
orl $0x0, (%ecx) /* probe there */
subl $0x1000, %eax /* decrement count */
cmpl $0x1000, %eax
ja Lprobe /* and do it again */
Ldone:
subl %eax, %ecx
orl $0x0, (%ecx) /* less than 4k, just peek here */
movl %esp, %eax /* save old stack pointer */
movl %ecx, %esp /* decrement stack */
movl (%eax), %ecx /* recover saved temp */
movl 4(%eax), %eax /* recover return address */
/* Push the return value back. Doing this instead of just
jumping to %eax preserves the cached call-return stack
used by most modern processors. */
pushl %eax
ret