make-image can now generate images with Unicode strings
[factor/jcg.git] / vm / cpu-x86.64.S
blob7b5b5f3167fdfb9eb0ef43bc4fa4b423b5cad0bc
1 #include "asm.h"
3 #define STACK_REG %rsp
4 #define DS_REG %r14
5 #define RETURN_REG %rax
7 #define CELL_SIZE 8
8 #define STACK_PADDING 56
10 #define NV_TEMP_REG %rbp
12 #define ARITH_TEMP_1 %r8
13 #define ARITH_TEMP_2 %r9
14 #define DIV_RESULT %rax
16 #ifdef WINDOWS
18         #define ARG0 %rcx
19         #define ARG1 %rdx
20         #define ARG2 %r8
21         #define ARG3 %r9
23         #define PUSH_NONVOLATILE \
24                 push %r12 ; \
25                 push %r13 ; \
26                 push %rdi ; \
27                 push %rsi ; \
28                 push %rbx ; \
29                 push %rbp ; \
30                 push %rbp
32         #define POP_NONVOLATILE \
33                 pop %rbp ; \
34                 pop %rbp ; \
35                 pop %rbx ; \
36                 pop %rsi ; \
37                 pop %rdi ; \
38                 pop %r13 ; \
39                 pop %r12
41 #else
43         #define ARG0 %rdi
44         #define ARG1 %rsi
45         #define ARG2 %rdx
46         #define ARG3 %rcx
48         #define PUSH_NONVOLATILE \
49                 push %rbx ; \
50                 push %rbp ; \
51                 push %r12 ; \
52                 push %r13 ; \
53                 push %r13
55         #define POP_NONVOLATILE \
56                 pop %r13 ; \
57                 pop %r13 ; \
58                 pop %r12 ; \
59                 pop %rbp ; \
60                 pop %rbx
62 #endif
64 #define QUOT_XT_OFFSET 21
66 /* We pass a function pointer to memcpy to work around a Mac OS X
67 ABI limitation which would otherwise require us to do a bizzaro PC-relative
68 trampoline to retrieve the function address */
69 DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
70         sub ARG2,ARG0                      /* compute new stack pointer */
71         mov ARG0,%rsp
72         call *ARG3                         /* call memcpy */
73         ret                                /* return _with new stack_ */
75 #include "cpu-x86.S"