source: project/chicken/trunk/apply-hack.ppc.darwin.s @ 5861

Last change on this file since 5861 was 5861, checked in by felix winkelmann, 12 years ago
  • added SYSV-specific ppc apply-hack [Thanks to Peter Bex]
  • added bsd makefile (untested!)
  • version is 2.702
File size: 2.7 KB
Line 
1/* apply-hack.ppc.s
2;
3; Copyright (c) 2007, Felix L. Winkelmann
4; All rights reserved.
5;
6; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
7; conditions are met:
8;
9;   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
10;     disclaimer.
11;   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
12;     disclaimer in the documentation and/or other materials provided with the distribution.
13;   Neither the name of the author nor the names of its contributors may be used to endorse or promote
14;     products derived from this software without specific prior written permission.
15;
16; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
17; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
19; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24; POSSIBILITY OF SUCH DAMAGE.
25;
26; Send bugs, suggestions and ideas to: 
27;
28; felix@call-with-current-continuation.org
29;
30; Felix L. Winkelmann
31; Unter den Gleichen 1
32; 37130 Gleichen
33; Germany
34*/
35
36        .text
37
38        .globl _C_do_apply_hack
39        .align 2
40       
41_C_do_apply_hack:
42        mr r13, r3              /* r13=proc */
43        mr r14, r4              /* r14=buf */
44        mr r15, r5              /* r15=count */
45        cmpwi r15, 8
46        bge l1
47        li r3, 8                /* offset is (8 - count) * 4 */
48        sub r15, r3, r15
49        slwi r15, r15, 2
50        bl l2                   /* compute branch address */
51l2:     mflr r4
52        add r15, r4, r15
53        addi r15, r15, lo16(l1 - l2)
54        mtctr r15
55        bctr
56l1:     lwz r10, 28(r14)        /* load register arguments */
57        lwz r9, 24(r14)
58        lwz r8, 20(r14)
59        lwz r7, 16(r14)
60        lwz r6, 12(r14)
61        lwz r5, 8(r14)
62        lwz r4, 4(r14)
63        lwz r3, 0(r14)
64        lwz r15, 20(r1)         /* save link area above faked argument area */
65        stw r15, -4(r14)        /* (start from end if destination overlaps) */
66        lwz r15, 16(r1)         /* is this needed at all? at least for proper gdb backtraces? */
67        stw r15, -8(r14)
68        lwz r15, 12(r1)
69        stw r15, -12(r14)
70        lwz r15, 8(r1)
71        stw r15, -16(r14)
72        lwz r15, 4(r1)
73        stw r15, -20(r14)
74        lwz r15, 0(r1)
75        stw r15, -24(r14)
76        addi r1, r14, -24       /* set frame-pointer to faked frame */
77        mtctr r13               /* jump to proc, lr is invalid, but we won't return anyway */
78        bctr
Note: See TracBrowser for help on using the repository browser.