• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1	.global __setjmp
2	.global _setjmp
3	.global setjmp
4	.type   __setjmp,@function
5	.type   _setjmp,@function
6	.type   setjmp,@function
7__setjmp:
8_setjmp:
9setjmp:
10	ld 5, 24(1)   # load from the TOC slot in the caller's stack frame
11	b __setjmp_toc
12
13	.localentry __setjmp,.-__setjmp
14	.localentry _setjmp,.-_setjmp
15	.localentry setjmp,.-setjmp
16	mr 5, 2
17
18	.global __setjmp_toc
19	.hidden __setjmp_toc
20	# same as normal setjmp, except TOC pointer to save is provided in r5.
21	# r4 would normally be the 2nd parameter, but we're using r5 to simplify calling from sigsetjmp.
22	# solves the problem of knowing whether to save the TOC pointer from r2 or the caller's stack frame.
23__setjmp_toc:
24	# 0) store IP into 0, then into the jmpbuf pointed to by r3 (first arg)
25	mflr  0
26	std   0,  0*8(3)
27	# 1) store cr
28	mfcr  0
29	std   0,  1*8(3)
30	# 2) store SP and TOC
31	std   1,  2*8(3)
32	std   5,  3*8(3)
33	# 3) store r14-31
34	std  14,  4*8(3)
35	std  15,  5*8(3)
36	std  16,  6*8(3)
37	std  17,  7*8(3)
38	std  18,  8*8(3)
39	std  19,  9*8(3)
40	std  20, 10*8(3)
41	std  21, 11*8(3)
42	std  22, 12*8(3)
43	std  23, 13*8(3)
44	std  24, 14*8(3)
45	std  25, 15*8(3)
46	std  26, 16*8(3)
47	std  27, 17*8(3)
48	std  28, 18*8(3)
49	std  29, 19*8(3)
50	std  30, 20*8(3)
51	std  31, 21*8(3)
52	# 4) store floating point registers f14-f31
53	stfd 14, 22*8(3)
54	stfd 15, 23*8(3)
55	stfd 16, 24*8(3)
56	stfd 17, 25*8(3)
57	stfd 18, 26*8(3)
58	stfd 19, 27*8(3)
59	stfd 20, 28*8(3)
60	stfd 21, 29*8(3)
61	stfd 22, 30*8(3)
62	stfd 23, 31*8(3)
63	stfd 24, 32*8(3)
64	stfd 25, 33*8(3)
65	stfd 26, 34*8(3)
66	stfd 27, 35*8(3)
67	stfd 28, 36*8(3)
68	stfd 29, 37*8(3)
69	stfd 30, 38*8(3)
70	stfd 31, 39*8(3)
71
72	# 5) store vector registers v20-v31
73	addi  3, 3, 40*8
74	stvx 20, 0, 3 ; addi 3, 3, 16
75	stvx 21, 0, 3 ; addi 3, 3, 16
76	stvx 22, 0, 3 ; addi 3, 3, 16
77	stvx 23, 0, 3 ; addi 3, 3, 16
78	stvx 24, 0, 3 ; addi 3, 3, 16
79	stvx 25, 0, 3 ; addi 3, 3, 16
80	stvx 26, 0, 3 ; addi 3, 3, 16
81	stvx 27, 0, 3 ; addi 3, 3, 16
82	stvx 28, 0, 3 ; addi 3, 3, 16
83	stvx 29, 0, 3 ; addi 3, 3, 16
84	stvx 30, 0, 3 ; addi 3, 3, 16
85	stvx 31, 0, 3
86
87	# 6) return 0
88	li 3, 0
89	blr
90