Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_sparc32.s @ 188:44ae5b653086
- more endian detection in macros
author | Tassilo Philipp |
---|---|
date | Mon, 13 Mar 2017 13:23:10 +0100 |
parents | de5ed248757f |
children | 06ee88ce4962 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_callback_sparc32.s | |
187 | 6 Description: Callback - Implementation for Sparc 32-bit |
0 | 7 License: |
8 | |
155 | 9 Copyright (c) 2007-2016 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 | |
155 | 26 /* input: |
27 $i0 -> thunk | |
28 $i0+24 -> cb handler | |
29 $i0+28 -> userdata | |
30 */ | |
31 | |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
32 .text |
15
03c516772c65
- consistency in filenames that have cpp logic .s -> .S
cslag
parents:
0
diff
changeset
|
33 .globl dcCallbackThunkEntry |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
34 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
35 /* Called by thunk - thunk stores pointer to DCCallback */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
36 /* in %g1, and pointer to called function in %g2 */ |
0 | 37 dcCallbackThunkEntry: |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
38 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
39 /* Prolog. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
40 /* Frame size of 80b comes from needing storage space for the following: */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
41 /* DCargs(sparc_req_reg_save_area:64 + argptr:4) + pad:4 + retval:8 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
42 save %sp, -80, %sp |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
43 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
44 /* Spill register args. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
45 st %i0, [ %fp + 68 ] /* reg arg 0 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
46 st %i1, [ %fp + 72 ] /* reg arg 1 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
47 st %i2, [ %fp + 76 ] /* reg arg 2 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
48 st %i3, [ %fp + 80 ] /* reg arg 3 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
49 st %i4, [ %fp + 84 ] /* reg arg 4 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
50 st %i5, [ %fp + 88 ] /* reg arg 5 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
51 add %fp, 68, %l0 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
52 st %l0, [ %sp + 64 ] /* init arg_ptr */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
53 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
54 /* Zero retval store (for data < word size). */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
55 st %g0, [ %sp + 72 ] |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
56 st %g0, [ %sp + 76 ] |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
57 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
58 /* Prepare callback handler call. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
59 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
60 add %sp, 64, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
61 add %sp, 72, %o2 /* Param 2 = results ptr to 8b of local stack data */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
62 ld [ %g1 + 28 ], %o3 /* Param 3 = userdata ptr */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
63 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
64 ld [ %g1 + 24 ], %l0 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
65 call %l0 |
155 | 66 nop |
0 | 67 |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
68 /* Put retval in %i0/%i1 (to be in caller's %o0/%o1), and %f0/%f1. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
69 ld [ %sp + 72 ], %i0 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
70 ld [ %sp + 76 ], %i1 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
71 ld [ %sp + 72 ], %f0 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
72 ld [ %sp + 76 ], %f1 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
73 |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
74 /* Epilog. */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
75 restore /* unshift reg window */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
76 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
77 nop |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
155
diff
changeset
|
78 |