Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_thunk_arm32.c @ 412:beb15f1065e6
- comments cleanup
author | Tassilo Philipp |
---|---|
date | Thu, 07 Oct 2021 09:31:54 +0200 |
parents | f5577f6bf97a |
children |
comparison
equal
deleted
inserted
replaced
411:49bc10c99462 | 412:beb15f1065e6 |
---|---|
4 Library: dyncallback | 4 Library: dyncallback |
5 File: dyncallback/dyncall_thunk_arm32.c | 5 File: dyncallback/dyncall_thunk_arm32.c |
6 Description: Thunk - Implementation for ARM32 (ARM and THUMB mode) | 6 Description: Thunk - Implementation for ARM32 (ARM and THUMB mode) |
7 License: | 7 License: |
8 | 8 |
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, | 9 Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, |
10 Tassilo Philipp <tphilipp@potion-studios.com> | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | 11 |
12 Permission to use, copy, modify, and distribute this software for any | 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 | 13 purpose with or without fee is hereby granted, provided that the above |
14 copyright notice and this permission notice appear in all copies. | 14 copyright notice and this permission notice appear in all copies. |
31 void dcbInitThunk(DCThunk* p, void (*entry)()) | 31 void dcbInitThunk(DCThunk* p, void (*entry)()) |
32 { | 32 { |
33 /* | 33 /* |
34 # ARM32 (ARM mode) thunk code: | 34 # ARM32 (ARM mode) thunk code: |
35 .code 32 | 35 .code 32 |
36 sub %r12, %r15, #8 | 36 sub r12, r15, #8 |
37 ldr %r15, [%r15, #-4] | 37 ldr r15, [r15, #-4] |
38 */ | 38 */ |
39 | 39 |
40 /* This code stores a ptr to DCCallback in r12 (equals ptr to thunk, */ | 40 /* This code stores a ptr to DCCallback in r12 (equals ptr to thunk, */ |
41 /* which is PC (r15) minus 8, as PC points to current instruction+8. */ | 41 /* which is PC (r15) minus 8, as PC points to current instruction+8. */ |
42 /* Then it loads the callback 'entry' into PC. The -4 is needed, also bc */ | 42 /* Then it loads the callback 'entry' into PC. The -4 is needed, also bc */ |
43 /* of the PC pointing ahead. */ | 43 /* of the PC pointing ahead. */ |
44 p->code[0] = 0xe24fc008UL; /* sub %r12, %r15, #8 */ | 44 p->code[0] = 0xe24fc008UL; /* sub r12, r15, #8 */ |
45 p->code[1] = 0xe51ff004UL; /* ldr %r15, [%r15, #-4] */ | 45 p->code[1] = 0xe51ff004UL; /* ldr r15, [r15, #-4] */ |
46 p->entry = entry; | 46 p->entry = entry; |
47 } | 47 } |