OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libc/] [sys/] [arm/] [setjmp.S] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* This is a simple version of setjmp and longjmp.
2
 
3
   Nick Clifton, Cygnus Solutions, 13 June 1997.  */
4
 
5
 
6
        .text
7
        .code 32
8
        .align 2
9
 
10
/* int setjmp (jmp_buf);  */
11
        .globl  _setjmp
12
_setjmp:
13
 
14
        /* Save all the callee-preserved registers into the jump buffer. */
15
        stmea           a1!, { v1-v7, fp, ip, sp, lr }
16
 
17
#if 0   /* Simulator does not cope with FP instructions yet.... */
18
#ifndef __SOFTFP__
19
        /* Save the floating point registers */
20
        sfmea           f4, 4, [a1]
21
#endif
22
#endif
23
        /* When setting up the jump buffer return 0. */
24
        mov             a1, #0
25
 
26
        /* Return to caller, see comment in longjmp below */
27
#ifdef __APCS_26__
28
        movs            pc, lr
29
#else
30
        tst             lr, #1
31
        moveq           pc, lr
32
.word   0xe12fff1e      /*  bx lr */
33
#endif
34
 
35
 
36
/* volatile void longjmp (jmp_buf, int);  */
37
        .globl  _longjmp
38
_longjmp:
39
 
40
        /* If we have stack extension code it ought to be handled here. */
41
 
42
        /* Restore the registers, retrieving the state when setjmp() was called. */
43
        ldmfd           a1!, { v1-v7, fp, ip, sp, lr }
44
 
45
#if 0   /* Simulator does not cope with FP instructions yet.... */
46
#ifndef __SOFTFP__
47
        /* Restore floating point registers as well */
48
        lfmfd           f4, 4, [a1]
49
#endif
50
#endif
51
        /* Put the return value into the integer result register.
52
           But if it is zero then return 1 instead.  */
53
        movs            a1, a2
54
        moveq           a1, #1
55
 
56
        /* Arm/Thumb interworking support:
57
 
58
           The interworking scheme expects functions to use a BX instruction
59
           to return control to their parent.  Since we need this code to work
60
           in both interworked and non-interworked environments as well as with
61
           older processors which do not have the BX instruction we do the
62
           following:
63
                Test the return address.
64
                If the bottom bit is clear perform an "old style" function exit.
65
                (We know that we are in ARM mode and returning to an ARM mode caller).
66
                Otherwise use the BX instruction to perform the function exit.
67
 
68
           We know that we will never attempt to perform the BX instruction on
69
           an older processor, because that kind of processor will never be
70
           interworked, and a return address with the bottom bit set will never
71
           be generated.
72
 
73
           In addition, we do not actually assemble the BX instruction as this would
74
           require us to tell the assembler that the processor is an ARM7TDMI and
75
           it would store this information in the binary.  We want this binary to be
76
           able to be linked with binaries compiled for older processors however, so
77
           we do not want such information stored there.
78
 
79
           If we are running using the APCS-26 convention however, then we never
80
           test the bottom bit, because this is part of the processor status.
81
           Instead we just do a normal return, since we know that we cannot be
82
           returning to a Thumb caller - the Thumb doe snot support APCS-26
83
        */
84
 
85
#ifdef __APCS_26__
86
        movs            pc, lr
87
#else
88
        tst             lr, #1
89
        moveq           pc, lr
90
.word   0xe12fff1e      /* bx lr */
91
#endif
92
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.