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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [or32/] [longjmp.S] - Blame information for rev 399

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

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

powered by: WebSVN 2.1.0

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