about summary refs log tree commit diff
path: root/src/setjmp/powerpc/longjmp.s
blob: e3740901eb1cca1878588e35b1e63792589172f5 (plain) (blame)
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
        .global _longjmp
        .global longjmp
        .type   _longjmp,@function
        .type   longjmp,@function
_longjmp:
longjmp:
# void longjmp(jmp_buf env, int val);
# put val into return register and restore the env saved in setjmp
# if val(r4) is 0, put 1 there.
	# 0) move old return address into r0
	lwz 0, 0(3)
	# 1) put it into link reg
	mtlr 0
	#2 ) restore stack ptr
	lwz 1, 4(3)
	#3) restore control reg
	lwz 0, 8(3)
	mtcr 0
	#4) restore r14-r31
	lwz 14, 12(3)
	lwz 15, 16(3)
	lwz 16, 20(3)
	lwz 17, 24(3)
	lwz 18, 28(3)
	lwz 19, 32(3)
	lwz 20, 36(3)
	lwz 21, 40(3)
	lwz 22, 44(3)
	lwz 23, 48(3)
	lwz 24, 52(3)
	lwz 25, 56(3)
	lwz 26, 60(3)
	lwz 27, 64(3)
	lwz 28, 68(3)
	lwz 29, 72(3)
	lwz 30, 76(3)
	lwz 31, 80(3)
	#5) put val into return reg r3
	mr 3, 4

	#6) check if return value is 0, make it 1 in that case
	cmpwi cr7, 4, 0
	bne cr7, 1f
	li 3, 1
1:
	blr