Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_mips_n32.S @ 318:3124f4c4f293
- dynload_plain test code build fix for windows
author | Tassilo Philipp |
---|---|
date | Wed, 13 Nov 2019 01:21:02 +0100 |
parents | d55f9d508074 |
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:
131
diff
changeset
|
5 File: dyncall/dyncall_call_mips_n32.S |
131
21537652361e
- fixed mips64 n32 build (not sure if working, though)
cslag
parents:
124
diff
changeset
|
6 Description: mips64 "n32" abi call kernel implementation in GNU Assembler |
0 | 7 License: |
8 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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.abiN32 | |
27 .previous | |
28 .abicalls | |
29 .text | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
30 .align 2 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
31 .globl dcCall_mips_n32 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
32 .ent dcCall_mips_n32 |
0 | 33 dcCall_mips_n32: |
34 | |
35 /* Stack-frame prolog */ | |
36 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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:
131
diff
changeset
|
38 .mask 0xd0000000,-8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
39 .fmask 0x00000000,0 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
40 subu $sp,$sp,64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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:
131
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:
131
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:
131
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:
131
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:
131
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:
131
diff
changeset
|
57 subu $sp, $sp, $6 |
0 | 58 |
59 /* copy stack data */ | |
60 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
61 /* n32 abi call assumptions: |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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:
131
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:
131
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:
131
diff
changeset
|
70 move $12, $7 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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:
131
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:
131
diff
changeset
|
76 daddiu $6, $6, -8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
77 ld $2, 0($12) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
78 sd $2, 0($14) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
79 daddiu $12,$12, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
80 daddiu $14,$14, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
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:
131
diff
changeset
|
83 move $25, $4 |
0 | 84 |
85 /* load registers */ | |
86 | |
87 /* locals: */ | |
88 /* $13 = register data */ | |
89 /* $14 = useDouble flags */ | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
90 move $13, $5 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
91 ld $14, 128($13) |
0 | 92 |
93 /* load integer parameter registers */ | |
94 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
95 ld $4 , 0($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
96 ld $5 , 8($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
97 ld $6 ,16($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
98 ld $7 ,24($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
99 ld $8 ,32($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
100 ld $9 ,40($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
101 ld $10,48($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
102 ld $11,56($13) |
0 | 103 |
104 /* 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:
131
diff
changeset
|
105 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:
131
diff
changeset
|
106 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:
131
diff
changeset
|
107 at bit position 0 in bitmask. |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
108 */ |
0 | 109 .t0: |
110 and $15, $14, 1 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
111 bgtz $15, .d0 |
0 | 112 .f0: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
113 l.s $f12, 64($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
114 j .t1 |
0 | 115 .d0: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
116 l.d $f12, 64($13) |
0 | 117 |
118 .t1: | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
119 and $15, $14, 2 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
120 bgtz $15, .d1 |
0 | 121 .f1: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
122 l.s $f13, 72($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
123 j .t2 |
0 | 124 .d1: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
125 l.d $f13, 72($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
126 .t2: |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
127 and $15, $14, 4 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
128 bgtz $15, .d2 |
0 | 129 .f2: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
130 l.s $f14, 80($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
131 j .t3 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
132 .d2: |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
133 l.d $f14, 80($13) |
0 | 134 .t3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
135 and $15, $14, 8 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
136 bgtz $15, .d3 |
0 | 137 .f3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
138 l.s $f15, 88($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
139 j .t4 |
0 | 140 .d3: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
141 l.d $f15, 88($13) |
0 | 142 .t4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
143 and $15, $14, 16 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
144 bgtz $15, .d4 |
0 | 145 .f4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
146 l.s $f16, 96($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
147 j .t5 |
0 | 148 .d4: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
149 l.d $f16, 96($13) |
0 | 150 .t5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
151 and $15, $14, 32 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
152 bgtz $15, .d5 |
0 | 153 .f5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
154 l.s $f17,104($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
155 j .t6 |
0 | 156 .d5: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
157 l.d $f17,104($13) |
0 | 158 .t6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
159 and $15, $14, 64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
160 bgtz $15, .d6 |
0 | 161 .f6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
162 l.s $f18,112($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
163 j .t7 |
0 | 164 .d6: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
165 l.d $f18,112($13) |
0 | 166 .t7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
167 and $15, $14, 128 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
168 bgtz $15, .d7 |
0 | 169 .f7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
170 l.s $f19,120($13) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
171 j .fregend |
0 | 172 .d7: |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
173 l.d $f19,120($13) |
0 | 174 |
175 .fregend: | |
176 | |
177 /* jump-and-link to register $25 */ | |
178 | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
179 jal $31, $25 |
124 | 180 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:
131
diff
changeset
|
181 /* output, but let's play safe */ |
0 | 182 |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
183 /* Stack-frame epilog */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
184 move $sp,$fp |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
185 ld $31,48($sp) /* restore ra register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
186 ld $fp,40($sp) /* restore fp register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
187 ld $28,32($sp) /* restore gp register */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
188 daddu $sp,$sp,64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
189 j $31 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
190 .end dcCall_mips_n64 |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
131
diff
changeset
|
191 .size dcCall_mips_n64, .-dcCall_mips_n64 |
0 | 192 |