source: project/chicken/branches/prerelease/apply-hack.ppc.darwin.s @ 9381

Last change on this file since 9381 was 9381, checked in by Ivan Raikov, 12 years ago

Merged trunk into prerelease

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