Skip to content

Commit e31849f

Browse files
committed
rt: Fix assembler for C calls to work more like a regular function call
1 parent 6dece91 commit e31849f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/rt/arch/i386/ccall.S

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
.text
22

33
// upcall_call_c_stack(void (*fn)(), void *new_esp)
4+
//
5+
// Note that we could use |enter| and |leave| but the manuals tell me they're
6+
// slower.
47
.globl _upcall_call_c_stack
58
_upcall_call_c_stack:
6-
movl %esp,%ecx // grab esp
7-
movl 8(%esp),%eax // save fn
9+
pushl %ebp
10+
movl %esp,%ebp // save esp
11+
movl 8(%esp),%eax // eax = callee
812
movl 12(%esp),%esp // switch stack
9-
pushl %ecx // save esp on stack
1013
calll *%eax
11-
popl %esp // restore esp
14+
movl %ebp,%esp // would like to use "leave" but it's slower
15+
popl %ebp
1216
ret
1317

14-

0 commit comments

Comments
 (0)