Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_args_mips.c @ 108:bf8aef292216
- mips clarifications in doc
author | cslag |
---|---|
date | Sat, 11 Jun 2016 21:38:46 +0200 |
parents | b7a9b524f0c3 |
children | 9e677d4c0b6b |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_args_mips.c | |
6 Description: Callback's Arguments VM - Implementation for MIPS | |
7 License: | |
8 | |
9 Copyright (c) 2013-2015 Daniel Adler <dadler@uni-goettingen.de>, | |
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 | |
27 #include "dyncall_args_mips.h" | |
28 | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
29 DCint dcbArgInt(DCArgs* p) |
0 | 30 { |
31 DCint value; | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
32 if(p->reg_count.i < DCARGS_MIPS_PARAM_REGS) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
33 value = p->reg_data.i[p->reg_count.i++]; |
0 | 34 else { |
35 value = *((int*)p->stackptr); | |
36 p->stackptr += sizeof(int); | |
37 } | |
38 return value; | |
39 } | |
40 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } | |
41 | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
42 DCulonglong dcbArgULongLong(DCArgs* p) |
0 | 43 { |
44 DCulonglong value; | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
45 p->reg_count.i += (p->reg_count.i & 1); // Skip one reg if not aligned. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
46 #if defined(DC__Endian_LITTLE) |
0 | 47 value = ((DCulonglong)dcbArgUInt(p)) << 32; |
48 value |= dcbArgUInt(p); | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
49 #else |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
50 value = dcbArgUInt(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
51 value |= ((DCulonglong)dcbArgUInt(p)) << 32; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
52 #endif |
0 | 53 return value; |
54 } | |
55 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } | |
56 | |
57 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } | |
58 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgUInt(p); } | |
59 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgUInt(p); } | |
60 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgUInt(p); } | |
61 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgUInt(p); } | |
62 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } | |
63 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } | |
64 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } | |
65 | |
66 DCfloat dcbArgFloat(DCArgs* p) | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
67 { |
0 | 68 DCfloat result; |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
69 if(p->reg_count.f < DCARGS_MIPS_PARAM_REGS) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
70 result = (DCfloat)p->reg_data.f[p->reg_count.f++]; |
0 | 71 else { |
72 result = *((float*)p->stackptr); | |
73 p->stackptr += sizeof(float); | |
74 } | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
75 return result; |
0 | 76 } |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
77 DCdouble dcbArgDouble(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
78 { |
0 | 79 union { |
80 DCdouble result; | |
81 DCfloat f[2]; | |
82 } d; | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
83 p->reg_count.f += (p->reg_count.f & 1); // Skip one reg if not aligned. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
84 #if defined(DC__Endian_LITTLE) |
0 | 85 d.f[0] = dcbArgFloat(p); |
86 d.f[1] = dcbArgFloat(p); | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
87 #else |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
88 d.f[1] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
89 d.f[0] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
90 #endif |
0 | 91 return d.result; |
92 } | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
93 |