annotate dyncallback/dyncall_callback_mips_n64_gas.s @ 122:f63467916f98

- first draft of mips64 n64 callbacks, not everything working, though
author cslag
date Mon, 04 Jul 2016 01:11:08 +0200
parents c5cb02203df4
children 6bd0974d257b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
1 /*
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
2
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
3 Package: dyncall
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
4 Library: dyncallback
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
5 File: dyncallback/dyncall_callback_mips_n64_gas.s
101
1ce60358fbad - mips related cleanup, mostly comments, cpp macro lib
cslag
parents: 94
diff changeset
6 Description: Callback Thunk - Implementation for mips64 n64
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
7 License:
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
8
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
9 Copyright (c) 2016 Tassilo Philipp <tphilipp@potion-studios.com>
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
10
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
11 Permission to use, copy, modify, and distribute this software for any
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
12 purpose with or without fee is hereby granted, provided that the above
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
13 copyright notice and this permission notice appear in all copies.
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
14
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
22
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
23 @@@ NOT FULLY WORKING, YET
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
24 */
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
25
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
26 /* input:
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
27 $t8 -> thunk
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
28 $t8+56 -> cb handler
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
29 $t8+64 -> userdata
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
30 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
31
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
32 .section .mdebug.abi64
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
33 .previous
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
34 .abicalls
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
35 .text
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
36 .align 2
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
37 .globl dcCallbackThunkEntry
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
38 .ent dcCallbackThunkEntry
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
39 dcCallbackThunkEntry:
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
40 .set noreorder
94
ea17e6e6bd3a - stubs for mips callback support
cslag
parents:
diff changeset
41
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
42 /* Prolog. */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
43 /* Frame size of 160b comes from following: */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
44 /* DCargs(fregs:64 + iregs:64 + regcounts:8 + stackptr:8) + retval:8 + ra:8 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
45 subu $sp, 160 /* open frame */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
46 sd $ra, 152($sp) /* save link register */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
47
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
48 .frame $fp,160,$31 /* specify our frame: fp,size,lr; creates virt $fp */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
49 /* code below doesn't use $fp though, as n/a with -O1 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
50 /* Init return value */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
51 sd $zero, 144($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
52
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
53 /* Store float and int args where our DCargs member arrays are, in local area. */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
54 sd $4, 0($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
55 sd $5, 8($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
56 sd $6, 16($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
57 sd $7, 24($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
58 sd $8, 32($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
59 sd $9, 40($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
60 sd $10, 48($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
61 sd $11, 56($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
62 s.d $f12, 64($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
63 s.d $f13, 72($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
64 s.d $f14, 80($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
65 s.d $f15, 88($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
66 s.d $f16, 96($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
67 s.d $f17, 104($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
68 s.d $f18, 112($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
69 s.d $f19, 120($sp)
116
c5cb02203df4 - mips n64 working thunks
cslag
parents: 101
diff changeset
70
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
71 /* Init DCarg's reg_counts and stackptr. */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
72 sd $zero, 128($sp) /* reg_count */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
73 addiu $4, $sp, 160
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
74 sd $4, 136($sp) /* stackptr */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
75
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
76 /* Prepare callback handler call. */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
77 move $4, $24 /* Param 0 = DCCallback*, $24 ($t8) holds pointer to thunk */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
78 move $5, $sp /* Param 1 = DCArgs*, pointer to where pointer to args is stored */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
79 addiu $6, $sp, 144 /* Param 2 = results pointer to 8b of local data on stack */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
80 ld $7, 64($24) /* Param 3 = userdata pointer */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
81
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
82 ld $25, 56($24) /* store handler entry in $25 ($t9), required for PIC */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
83 jalr $25 /* jump */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
84 nop /* branch delay nop */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
85
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
86 /* Copy result in corresponding registers $2-$3 ($v0-$v1) and $f0 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
87 ld $2, 144($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
88 /*ld $3, 152($sp) @@@ ignoring second possible retval for now*/
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
89 l.d $f0, 144($sp)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
90
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
91 /* Epilog. Tear down frame and return. */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
92 ld $ra, 152($sp) /* restore return address */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
93 addiu $sp, $sp, 160 /* close frame */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
94 j $ra /* return */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
95 nop /* branch delay nop */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
96
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
97 .set reorder
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
98 .end dcCallbackThunkEntry
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
99 .ident "handwritten"
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents: 116
diff changeset
100