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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [or32/] [setjmp.S] - Blame information for rev 183

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

Line No. Rev Author Line
1 183 jeremybenn
/* setjmp.S. Implementation fo setjmp and longjmp.
2 148 jeremybenn
 
3 183 jeremybenn
   Copyright (C) 2000, Damjan Lampret
4
   Copyright (C) 2004, Jacob Bower
5
   Copyright (C) 2010, Embecosm Limited 
6 148 jeremybenn
 
7 183 jeremybenn
   Contributor Jeremy Bennett 
8
 
9
   This file is part of Newlib.
10
 
11
   The original work by Jacob Bower is provided as-is without any kind of
12
   warranty. Use it at your own risk!
13
 
14
   All subsequent work is bound by version 3 of the GPL as follows.
15
 
16
   This program is free software; you can redistribute it and/or modify it
17
   under the terms of the GNU General Public License as published by the Free
18
   Software Foundation; either version 3 of the License, or (at your option)
19
   any later version.
20
 
21
   This program is distributed in the hope that it will be useful, but WITHOUT
22
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
24
   more details.
25
 
26
   You should have received a copy of the GNU General Public License along
27
   with this program.  If not, see .            */
28
/* -------------------------------------------------------------------------- */
29
/* This program is commented throughout in a fashion suitable for processing
30
   with Doxygen.                                                              */
31
/* -------------------------------------------------------------------------- */
32
 
33
 
34
/* -------------------------------------------------------------------------- */
35
/*!_setjmp
36
 
37
   All processor state is saved in the buffer provided. We need not save r0
38
   (it will always be zero) and we need not save r11 (it will always be
39
   overridden here, and in _longjmp).
40
 
41
   @todo We should prefer to save and restore the status register, but this is
42
         not directly possible in user code. There is some merit in code to
43
         set the flag, since in compiled C code, that might be expected to hold
44
         a value. We leave a space for this information for future enhancement.
45
 
46
   @param[out] env(r3)  A buffer to save all the current processor state.
47
 
48
   @return  zero.
49
/* -------------------------------------------------------------------------- */
50 148 jeremybenn
        .align  4
51 183 jeremybenn
        .global _setjmp
52
        .type   _setjmp,@function
53
_setjmp:
54
        l.sw    4(r3),r1                /* Slot 0 saved for flag in future */
55
        l.sw    8(r3),r2
56
        l.sw    12(r3),r3
57
        l.sw    16(r3),r4
58
        l.sw    20(r3),r5
59
        l.sw    24(r3),r6
60
        l.sw    28(r3),r7
61
        l.sw    32(r3),r8
62
        l.sw    36(r3),r9
63
        l.sw    40(r3),r10              /* Skip r11 */
64 148 jeremybenn
        l.sw    44(r3),r12
65
        l.sw    48(r3),r13
66
        l.sw    52(r3),r14
67
        l.sw    56(r3),r15
68
        l.sw    60(r3),r16
69
        l.sw    64(r3),r17
70
        l.sw    68(r3),r18
71
        l.sw    72(r3),r19
72
        l.sw    76(r3),r20
73
        l.sw    80(r3),r21
74
        l.sw    84(r3),r22
75
        l.sw    88(r3),r23
76
        l.sw    92(r3),r24
77
        l.sw    96(r3),r25
78
        l.sw    100(r3),r26
79
        l.sw    104(r3),r27
80
        l.sw    108(r3),r28
81
        l.sw    112(r3),r29
82
        l.sw    116(r3),r30
83
        l.sw    120(r3),r31
84
 
85 183 jeremybenn
        l.jr    r9
86
        l.addi  r11,r0,0                /* Zero result */
87
 
88
        .size   _setjmp, .-_setjmp
89
 
90
/* -------------------------------------------------------------------------- */
91
/*!_longjmp
92
 
93
   All processor state is restored from the buffer provided. We need not restore
94
   r0 (it will always be zero) and we need not restore r11 (it will always be
95
   overridden here).
96
 
97
   We need to take some care, since we cannot restore r3 until all other
98
   registers are restore, and the value of r4 must first be saved in r11,
99
   modifying it if its value is zero.
100
 
101
   @todo We should prefer to save and restore the status register, but this is
102
         not directly possible in user code. There is some merit in code to
103
         set the flag, since in compiled C code, that might be expected to hold
104
         a value. We leave a space for this information for future enhancement.
105
 
106
   @param[out] env(r3)  A buffer from which to restore all the current
107
                        processor state.
108
   @param[in]  val(r4)  A value to return
109
 
110
   @return  val, unless val is zero, in which case 1 is returned.
111
/* -------------------------------------------------------------------------- */
112 148 jeremybenn
        .align  4
113 183 jeremybenn
        .global _longjmp
114
        .type   _longjmp,@function
115
_longjmp:
116
        /* Sort out the return value */
117 148 jeremybenn
        l.sfne  r4,r0
118
        l.bf    1f
119
        l.nop
120
 
121 183 jeremybenn
        l.j     2f
122
        l.addi  r11,r0,1                /* 1 as result */
123
 
124
1:      l.addi  r11,r4,0                /* val as result */
125
 
126
        /* Restore all the other registers, leaving r3 to last. */
127
2:      l.lwz   r31,120(r3)
128
        l.lwz   r30,116(r3)
129
        l.lwz   r29,112(r3)
130
        l.lwz   r28,108(r3)
131
        l.lwz   r27,104(r3)
132
        l.lwz   r26,100(r3)
133
        l.lwz   r25,96(r3)
134
        l.lwz   r24,92(r3)
135
        l.lwz   r23,88(r3)
136
        l.lwz   r22,84(r3)
137
        l.lwz   r21,80(r3)
138
        l.lwz   r20,76(r3)
139
        l.lwz   r19,72(r3)
140
        l.lwz   r18,68(r3)
141
        l.lwz   r17,64(r3)
142
        l.lwz   r16,60(r3)
143
        l.lwz   r15,56(r3)
144
        l.lwz   r14,52(r3)
145
        l.lwz   r13,48(r3)
146
        l.lwz   r12,44(r3)
147
        l.lwz   r10,40(r3)              /* Omit r11 */
148
        l.lwz   r9,36(r3)
149
        l.lwz   r8,32(r3)
150
        l.lwz   r7,28(r3)
151
        l.lwz   r6,24(r3)
152
        l.lwz   r5,20(r3)
153
        l.lwz   r4,16(r3)
154
        l.lwz   r2,8(r3)                /* Skip r3 */
155
        l.lwz   r1,4(r3)                /* Slot 0 saved for flag in future */
156
        l.lwz   r3,12(r3)               /* Now safe */
157 148 jeremybenn
 
158 183 jeremybenn
        /* Result is already in r11. Having restored r9, it will appear as
159
           though we have returned from the earlier call to _setjmp. The
160
           non-zero result gives it away though. */
161
        l.jr    r9
162 148 jeremybenn
        l.nop
163 183 jeremybenn
 
164
        .size   _longjmp, .-_longjmp

powered by: WebSVN 2.1.0

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