]> gitweb.factorcode.org Git - factor.git/blob - vm/cpu-x86.32.S
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / vm / cpu-x86.32.S
1 #include "asm.h"
2
3 #define ARG0 %eax
4 #define ARG1 %edx
5 #define STACK_REG %esp
6 #define DS_REG %esi
7 #define RETURN_REG %eax
8
9 #define NV_TEMP_REG %ebx
10
11 #define ARITH_TEMP_1 %ebp
12 #define ARITH_TEMP_2 %ebx
13 #define DIV_RESULT %eax
14
15 #define CELL_SIZE 4
16 #define STACK_PADDING 12
17
18 #define PUSH_NONVOLATILE \
19         push %ebx ; \
20         push %ebp ; \
21         push %ebp
22
23 #define POP_NONVOLATILE \
24         pop %ebp ; \
25         pop %ebp ; \
26         pop %ebx
27
28 #define QUOT_XT_OFFSET 12
29
30 /* We pass a function pointer to memcpy to work around a Mac OS X
31 ABI limitation which would otherwise require us to do a bizzaro PC-relative
32 trampoline to retrieve the function address */
33 DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
34         mov 4(%esp),%ebp                   /* to */
35         mov 8(%esp),%edx                   /* from */
36         mov 12(%esp),%ecx                  /* length */
37         mov 16(%esp),%eax                  /* memcpy */
38         sub %ecx,%ebp                      /* compute new stack pointer */
39         mov %ebp,%esp
40         push %ecx                          /* pass length */
41         push %edx                          /* pass src */
42         push %ebp                          /* pass dst */
43         call *%eax                         /* call memcpy */
44         add $12,%esp                       /* pop args from the stack */
45         ret                                /* return _with new stack_ */
46
47 DEF(long long,read_timestamp_counter,(void)):
48         rdtsc
49         ret
50
51 DEF(void,primitive_inline_cache_miss,(void)):
52         mov (%esp),%ebx
53 DEF(void,primitive_inline_cache_miss_tail,(void)):
54         sub $8,%esp
55         push %ebx
56         call MANGLE(inline_cache_miss)
57         add $12,%esp
58         jmp *%eax
59
60 DEF(void,get_sse_env,(void*)):
61     movl 4(%esp), %eax
62     stmxcsr (%eax)
63     ret
64
65 DEF(void,set_sse_env,(const void*)):
66     movl 4(%esp), %eax
67     ldmxcsr (%eax)
68     ret
69
70 DEF(void,get_x87_env,(void*)):
71     movl 4(%esp), %eax
72     fnstsw (%eax)
73     fnstcw 2(%eax)
74     ret
75
76 DEF(void,set_x87_env,(const void*)):
77     movl 4(%esp), %eax
78     fldcw 2(%eax)
79     movb 4(%eax), %dl
80     test %dl, %dl
81     jz 1f
82     fnclex
83 1:
84     ret
85
86 #include "cpu-x86.S"
87
88 #ifdef WINDOWS
89         .section .drectve
90         .ascii " -export:read_timestamp_counter"
91         .ascii " -export:get_sse_env"
92         .ascii " -export:set_sse_env"
93         .ascii " -export:get_x87_env"
94         .ascii " -export:set_x87_env"
95 #endif