diff options
| author | Charles.Forsyth <devnull@localhost> | 2007-12-27 12:25:32 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2007-12-27 12:25:32 +0000 |
| commit | b43c1ca5eb5fc65b93ae935a568432712797b049 (patch) | |
| tree | 512e88b4fcf815e911ff4eab8f850427b93f9afa /emu/NetBSD/asm-386.S | |
| parent | 45a14cc6b60b02e58eb1b271508ccc2fa3c52b8f (diff) | |
20071227-1230
Diffstat (limited to 'emu/NetBSD/asm-386.S')
| -rw-r--r-- | emu/NetBSD/asm-386.S | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/emu/NetBSD/asm-386.S b/emu/NetBSD/asm-386.S new file mode 100644 index 00000000..ca701782 --- /dev/null +++ b/emu/NetBSD/asm-386.S @@ -0,0 +1,107 @@ + .file "asm-NetBSD-386.S" +#include <sys/syscall.h> + +/* + * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) + */ + + .type ournewstack,@function + .global executeonnewstack +executeonnewstack: + pushl %ebp + movl %esp, %ebp + pushl %esi + + movl 8(%ebp), %esi /* get tos */ + subl $4, %esi + movl 16(%ebp), %eax + movl %eax, (%esi) /* stash arg on new stack */ + subl $4, %esi + movl 12(%ebp), %eax + movl %eax, (%esi) /* stash tramp on new stack */ + mov %esi, %esp /* swap stacks pronto */ + popl %eax /* recover the tramp address */ + call *%eax /* and jump to it (ho ho) */ + + /* if we return here, tramp didn't do it's job */ + + addl $8, %esp /* clean up for pose value */ + + leal SYS_exit, %eax + int $0x80 + +/* + * unlockandexit(int *key) + * + * NB: the return status may be rubbish if the stack is reused + * between the unlock and the system call, but this should + * not matter since no task is waiting for the result + */ + + .type unlockandexit,@function + .global unlockandexit +unlockandexit: + pushl %ebp + movl %esp, %ebp + + movl 8(%ebp), %esi /* get the key address */ + pushl $0 /* exit status 0 */ + movl $0, %eax /* unlock the stack allocator */ + movl %eax, (%esi) + leal SYS_exit, %eax /* call exit */ + int $0x80 + +/* + * umult(ulong m1, ulong m2, ulong *hi) + */ + + .type umult,@function + .global umult +umult: + pushl %ebp + movl %esp, %ebp + pushl %ebx + + movl 8(%ebp), %eax + movl 12(%ebp), %ebx + mull %ebx + movl 16(%ebp), %ebx + movl %edx, (%ebx) + + popl %ebx + popl %ebp + ret + + .type FPsave,@function + .global FPsave +FPsave: + pushl %ebp + movl %esp, %ebp + movl 8(%ebp), %eax + fstenv (%eax) + popl %ebp + ret + + .type FPrestore,@function + .global FPrestore +FPrestore: + pushl %ebp + movl %esp, %ebp + movl 8(%ebp), %eax + fldenv (%eax) + popl %ebp + ret + + .type getcallerpc,@function + .global getcallerpc +getcallerpc: + movl 4(%ebp), %eax + ret + + .type _tas,@function + .globl _tas +_tas: + movl $1, %eax + movl 4(%esp), %ecx + xchgl %eax, 0(%ecx) + ret |
