File: setjmp.S

package info (click to toggle)
picolibc 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 31,616 kB
  • sloc: ansic: 312,308; asm: 22,739; perl: 2,414; sh: 1,619; python: 1,019; pascal: 329; exp: 287; makefile: 164; xml: 40; cpp: 10
file content (122 lines) | stat: -rw-r--r-- 2,958 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
and/or other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley.  The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */
; setjmp/longjmp for D30V.

	.text
	.globl	setjmp
	.type	setjmp,@function
	.stabs	"setjmp.S",100,0,0,setjmp
	.stabs	"int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0
	.stabs	"setjmp:F(0,1)",36,0,1,setjmp

setjmp:
; Address of jmpbuf is passed in R2.  Save the appropriate registers.
	st2w	r26, @(r2+,r0)
	st2w	r28, @(r2+,r0)
	st2w	r30, @(r2+,r0)
	st2w	r32, @(r2+,r0)
	st2w	r34, @(r2+,r0)
	st2w	r36, @(r2+,r0)
	st2w	r38, @(r2+,r0)
	st2w	r40, @(r2+,r0)
	st2w	r42, @(r2+,r0)
	st2w	r44, @(r2+,r0)
	st2w	r46, @(r2+,r0)
	st2w	r48, @(r2+,r0)
	st2w	r50, @(r2+,r0)
	st2w	r52, @(r2+,r0)
	st2w	r54, @(r2+,r0)
	st2w	r56, @(r2+,r0)
	st2w	r58, @(r2+,r0)
	st2w	r60, @(r2+,r0)
	st2w	r62, @(r2+,r0)

	mvfacc	r4, a1, 16
	mvfacc	r5, a1, 0
	st2w	r4, @(r2+,r0)

	mvfsys	r4, psw
	mvfsys	r5, rpt_c
	st2w	r4, @(r2+,r0)

	mvfsys	r4, rpt_s
	mvfsys	r5, rpt_e
	st2w	r4, @(r2+,r0)

	mvfsys	r4, mod_s
	mvfsys	r5, mod_e
	st2w	r4, @(r2+,r0)

; Return 0 to caller
	add	r2, r0, r0
	jmp	link
.Lsetjmp:
	.size	setjmp,.Lsetjmp-setjmp
	.stabs	"",36,0,0,.Lsetjmp-setjmp

	.globl	longjmp
	.type	longjmp,@function
	.stabs	"longjmp:F(0,1)",36,0,1,longjmp
longjmp:
; Address of jmpbuf is in R2.  Restore the registers.
	ld2w	r26, @(r2+,r0)
	ld2w	r28, @(r2+,r0)
	ld2w	r30, @(r2+,r0)
	ld2w	r32, @(r2+,r0)
	ld2w	r34, @(r2+,r0)
	ld2w	r36, @(r2+,r0)
	ld2w	r38, @(r2+,r0)
	ld2w	r40, @(r2+,r0)
	ld2w	r42, @(r2+,r0)
	ld2w	r44, @(r2+,r0)
	ld2w	r46, @(r2+,r0)
	ld2w	r48, @(r2+,r0)
	ld2w	r50, @(r2+,r0)
	ld2w	r52, @(r2+,r0)
	ld2w	r54, @(r2+,r0)
	ld2w	r56, @(r2+,r0)
	ld2w	r58, @(r2+,r0)
	ld2w	r60, @(r2+,r0)
	ld2w	r62, @(r2+,r0)

	ld2w	r4, @(r2+,r0)
	mvtacc	a1, r4, r5

	mvfsys	r6, psw
	ld2w	r4, @(r2+,r0)		/* psw, rpt_c */
	and	r6, r6, 0xfcff		/* set rp, md bits from setjmp, leave */
	and	r4, r4, 0x0300		/* all other psw bits the same */
	or	r4, r4, r6
	mvtsys	psw, r4
	mvtsys	rpt_c, r5

	ld2w	r4, @(r2+,r0)
	mvtsys	rpt_s, r4
	mvtsys	rpt_e, r5

	ld2w	r4, @(r2+,r0)
	mvtsys	mod_s, r4
	mvtsys	mod_e, r5

; Value to return to caller is in R3.  If caller attemped to return 0,
; return 1 instead.

	cmpeq	f0, r3, 0	|| 	add	r2, r3, r0
	jmp	link		||	add/tx	r2, r2, 1
.Llongjmp:
	.size	longjmp,.Llongjmp-longjmp
	.stabs	"",36,0,0,.Llongjmp-longjmp