aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/setjmp.s
blob: 465a712a097ceb82229a877fa48bd4bfa9ff9d92 (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
48
# PSn00bSDK setjmp/longjmp
# (C) 2023 spicyjpeg - MPL licensed
#
# This is not a "proper" implementation of setjmp/longjmp as it does not save
# COP0 and GTE registers, but it is fully compatible with the version found in
# the BIOS.

.set noreorder

.section .text.setjmp
.global setjmp
.type setjmp, @function
setjmp:
	sw   $ra, 0x00($a0)
	sw   $sp, 0x04($a0)
	sw   $fp, 0x08($a0)
	sw   $s0, 0x0c($a0)
	sw   $s1, 0x10($a0)
	sw   $s2, 0x14($a0)
	sw   $s3, 0x18($a0)
	sw   $s4, 0x1c($a0)
	sw   $s5, 0x20($a0)
	sw   $s6, 0x24($a0)
	sw   $s7, 0x28($a0)
	sw   $gp, 0x2c($a0)

	jr   $ra
	li   $v0, 0

.section .text.longjmp
.global longjmp
.type longjmp, @function
longjmp:
	lw   $ra, 0x00($a0)
	lw   $sp, 0x04($a0)
	lw   $fp, 0x08($a0)
	lw   $s0, 0x0c($a0)
	lw   $s1, 0x10($a0)
	lw   $s2, 0x14($a0)
	lw   $s3, 0x18($a0)
	lw   $s4, 0x1c($a0)
	lw   $s5, 0x20($a0)
	lw   $s6, 0x24($a0)
	lw   $s7, 0x28($a0)
	lw   $gp, 0x2c($a0)

	jr   $ra
	move $v0, $a1