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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [mmixware/] [setjmp.S] - Blame information for rev 258

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

Line No. Rev Author Line
1 207 jeremybenn
/* Setjmp and longjmp for mmix.
2
 
3
   Copyright (C) 2001 Hans-Peter Nilsson
4
 
5
   Permission to use, copy, modify, and distribute this software is
6
   freely granted, provided that the above copyright notice, this notice
7
   and the following disclaimer are preserved with no changes.
8
 
9
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
10
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12
   PURPOSE.
13
 
14
   jmp_buf[5]:
15
   0:   fp
16
   1:   rJ (return-address)
17
   2:   sp
18
   3:   rO *before* the setjmp call.
19
   4:   temporary storage.  Reserved between setjmp and longjmp.  */
20
 
21
#ifdef __MMIX_ABI_GNU__
22
#define arg1 $231
23
#define arg2 $232
24
#define outret $231
25
#define popval 0
26
#else
27
#define arg1 $0
28
#define arg2 $1
29
#define outret $0
30
#define popval 1
31
#endif
32
 
33
        .section .text.setjmp,"ax",@progbits
34
        .global setjmp
35
setjmp:
36
% Store fp, sp and return address.  Recycle the static-chain and
37
% structure-return registers as temporary register, since we need to keep
38
% the jmp_buf (parameter 1) and the return address across a "POP".
39
        SET  $251,arg1
40
        STOU $253,$251,0
41
        GET  $252,rJ
42
        STOU $252,$251,8
43
        STOU $254,$251,16
44
        SETL outret,0
45
 
46
% Jump through hoops to get the value of rO *before* the setjmp call.
47
        GETA $255,0f
48
        PUT  rJ,$255
49
        POP  popval,0
50
0:
51
        GET  $255,rO
52
        STOU $255,$251,24
53
        GO   $255,$252,0
54
        .size setjmp,.-setjmp
55
 
56
        .section .text.longjmp,"ax",@progbits
57
        .global longjmp
58
longjmp:
59
% Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf.
60
% Save arg1 in a global register, since it will be destroyed by the POPs
61
% (in the mmixware ABI).
62
        CSZ  arg2,arg2,1
63
        STOU arg2,arg1,32
64
        SET  $251,arg1
65
 
66
% Loop and "POP 0,0" until rO is the expected value, like
67
% the expansion of nonlocal_goto_receiver, except that we put the return
68
% value in the right register and make sure that the POP causes it to
69
% enter the right return-value register as seen by the caller.  For the
70
% GNU ABI, it is unnecessary to do this in the loop and perhaps the memory
71
% access can be hoisted outside the loop, but this is safe and simple and
72
% I see no need to optimize longjmps.
73
        GETA $255,0f
74
        PUT  rJ,$255
75
        LDOU $255,$251,24
76
0:
77
        GET  $252,rO
78
        CMPU $252,$252,$255
79
        BNP  $252,1f
80
        LDOU outret,$251,32
81
        POP  popval,0
82
1:
83
        LDOU $253,$251,0
84
        LDOU $255,$251,8
85
        LDOU $254,$251,16
86
        GO   $255,$255,0
87
        .size longjmp,.-longjmp

powered by: WebSVN 2.1.0

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