2007-11-23 08:03:03 +08:00
|
|
|
/* ---------------------------------------------- */
|
|
|
|
/* alloca86.S */
|
|
|
|
|
2020-06-27 23:15:06 +08:00
|
|
|
#ifdef __leading_underscore
|
|
|
|
# define _(s) _##s
|
|
|
|
#else
|
|
|
|
# define _(s) s
|
|
|
|
#endif
|
2007-11-23 08:03:03 +08:00
|
|
|
|
2021-01-04 20:16:05 +08:00
|
|
|
.globl _(alloca), _(__alloca)
|
2020-06-27 23:15:06 +08:00
|
|
|
_(alloca):
|
2021-01-04 20:16:05 +08:00
|
|
|
_(__alloca):
|
|
|
|
push %ebp
|
|
|
|
mov %esp,%ebp
|
|
|
|
mov 8(%ebp),%eax
|
2007-11-23 08:03:03 +08:00
|
|
|
add $3,%eax
|
|
|
|
and $-4,%eax
|
2017-07-24 03:24:11 +08:00
|
|
|
#ifdef _WIN32
|
2021-01-04 20:16:05 +08:00
|
|
|
jmp .+16 #p2
|
2007-11-23 08:03:03 +08:00
|
|
|
p1:
|
|
|
|
sub $4096,%esp
|
|
|
|
sub $4096,%eax
|
2021-01-04 20:16:05 +08:00
|
|
|
test %eax,(%esp)
|
2007-11-23 08:03:03 +08:00
|
|
|
p2:
|
2021-01-04 20:16:05 +08:00
|
|
|
cmp $4096,%eax
|
|
|
|
jae p1
|
2008-01-17 04:16:35 +08:00
|
|
|
#endif
|
2007-11-23 08:03:03 +08:00
|
|
|
sub %eax,%esp
|
2021-01-04 20:16:05 +08:00
|
|
|
mov 4(%ebp),%eax
|
|
|
|
mov 0(%ebp),%ebp
|
|
|
|
add $8,%esp
|
|
|
|
push %eax
|
|
|
|
lea 8(%esp),%eax
|
2007-11-23 08:03:03 +08:00
|
|
|
ret
|
|
|
|
|
|
|
|
/* ---------------------------------------------- */
|