Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_mips_n64.S @ 336:3c6bc720bc1f r1.1-RC1
- doc: added mips64/n32 stub
author | Tassilo Philipp |
---|---|
date | Sat, 30 Nov 2019 15:57:28 +0100 |
parents | b104c5beec8b |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
5 File: dyncall/dyncall_call_mips_n64.S |
0 | 6 Description: mips "n64" abi call kernel implementation in GNU Assembler |
7 License: | |
8 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 .section .mdebug.abi64 | |
27 .previous | |
28 .abicalls | |
29 .text | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
30 .align 2 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
31 .globl dcCall_mips_n64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
32 .ent dcCall_mips_n64 |
0 | 33 dcCall_mips_n64: |
34 | |
35 /* Stack-frame prolog */ | |
36 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
37 # .frame $fp,64,$31 /* vars=16, regs=3/0, args=0, extra=16 */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
38 # .mask 0xd0000000,-8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
39 # .fmask 0x00000000,0 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
40 dsubu $sp,$sp,64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
41 sd $31,48($sp) /* save return address register (ra) */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
42 sd $30,40($sp) /* save frame pointer register (fp) */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
43 sd $28,32($sp) /* save global pointer register (gp) */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
44 move $fp,$sp |
0 | 45 |
46 | |
47 /* arguments: */ | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
48 |
0 | 49 /* $4 target function */ |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
50 /* $5 register data */ |
0 | 51 /* $6 stack size */ |
52 /* $7 stack data */ | |
53 | |
54 | |
55 /* allocate argument stack space */ | |
56 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
57 dsubu $sp, $sp, $6 |
0 | 58 |
59 /* copy stack data */ | |
60 | |
61 /* n64 abi call assumptions: | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
62 - stack data is 16-byte aligned. |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
63 - no extra-storage for arguments passed via registers. |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
64 */ |
0 | 65 |
66 /* $12 source pointer (parameter stack data) */ | |
67 /* $14 destination (stack pointer) */ | |
68 /* $6 byte count */ | |
69 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
70 move $12, $7 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
71 move $14, $sp |
0 | 72 |
73 .next: | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
74 beq $6, $0, .skip |
0 | 75 # nop |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
76 daddiu $6, $6, -8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
77 ld $2, 0($12) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
78 sd $2, 0($14) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
79 daddiu $12,$12, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
80 daddiu $14,$14, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
81 b .next |
0 | 82 .skip: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
83 move $25, $4 |
0 | 84 |
85 /* load registers */ | |
86 | |
87 /* locals: */ | |
88 /* $13 = register data */ | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
89 move $13, $5 |
0 | 90 |
305 | 91 /* load parameter registers (only ints on hardfloat) */ |
0 | 92 |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
93 ld $4 , 0($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
94 ld $5 , 8($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
95 ld $6 ,16($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
96 ld $7 ,24($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
97 ld $8 ,32($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
98 ld $9 ,40($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
99 ld $10,48($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
100 ld $11,56($13) |
0 | 101 |
305 | 102 #if defined(DC__ABI_HARDFLOAT) |
103 | |
104 /* $14 = useDouble flags */ | |
105 ld $14, 128($13) | |
106 | |
0 | 107 /* load float-or-double floating pointer parameter registers |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
108 a 64-bit bitmask given at byte offset 128 of regdata indicates |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
109 if loading a float (bit cleared) or double (bit set), starting |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
110 at bit position 0 in bitmask. |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
111 */ |
0 | 112 .t0: |
113 and $15, $14, 1 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
114 bgtz $15, .d0 |
0 | 115 .f0: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
116 l.s $f12, 64($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
117 j .t1 |
0 | 118 .d0: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
119 l.d $f12, 64($13) |
0 | 120 |
121 .t1: | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
122 and $15, $14, 2 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
123 bgtz $15, .d1 |
0 | 124 .f1: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
125 l.s $f13, 72($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
126 j .t2 |
0 | 127 .d1: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
128 l.d $f13, 72($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
129 .t2: |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
130 and $15, $14, 4 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
131 bgtz $15, .d2 |
0 | 132 .f2: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
133 l.s $f14, 80($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
134 j .t3 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
135 .d2: |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
136 l.d $f14, 80($13) |
0 | 137 .t3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
138 and $15, $14, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
139 bgtz $15, .d3 |
0 | 140 .f3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
141 l.s $f15, 88($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
142 j .t4 |
0 | 143 .d3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
144 l.d $f15, 88($13) |
0 | 145 .t4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
146 and $15, $14, 16 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
147 bgtz $15, .d4 |
0 | 148 .f4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
149 l.s $f16, 96($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
150 j .t5 |
0 | 151 .d4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
152 l.d $f16, 96($13) |
0 | 153 .t5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
154 and $15, $14, 32 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
155 bgtz $15, .d5 |
0 | 156 .f5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
157 l.s $f17,104($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
158 j .t6 |
0 | 159 .d5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
160 l.d $f17,104($13) |
0 | 161 .t6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
162 and $15, $14, 64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
163 bgtz $15, .d6 |
0 | 164 .f6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
165 l.s $f18,112($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
166 j .t7 |
0 | 167 .d6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
168 l.d $f18,112($13) |
0 | 169 .t7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
170 and $15, $14, 128 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
171 bgtz $15, .d7 |
0 | 172 .f7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
173 l.s $f19,120($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
174 j .fregend |
0 | 175 .d7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
176 l.d $f19,120($13) |
0 | 177 |
305 | 178 #endif /* DC__ABI_HARDFLOAT) */ |
179 | |
0 | 180 .fregend: |
181 | |
182 /* jump-and-link to register $25 */ | |
183 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
184 jal $31, $25 |
124 | 185 nop /* branch-delay slot - no nop according to gcc assembly */ |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
186 /* output, but let's play safe */ |
0 | 187 |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
188 /* Stack-frame epilog */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
189 move $sp,$fp |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
190 ld $ra,48($sp) /* restore ra register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
191 ld $fp,40($sp) /* restore fp register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
192 ld $gp,32($sp) /* restore gp register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
193 daddu $sp,$sp,64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
194 j $ra |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
195 .end dcCall_mips_n64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
124
diff
changeset
|
196 .size dcCall_mips_n64, .-dcCall_mips_n64 |
0 | 197 |