summaryrefslogtreecommitdiffhomepage
path: root/src/setjmp/nt32/longjmp.s
blob: a06ed948048ae837ca7b0a4b603b8decc51106e3 (plain)
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
############################################################################
##  mmglue: midipix architecture- and target-specific bits for musl libc  ##
##  Copyright (C) 2013--2023  SysDeer Technologies, LLC                   ##
##  Released under the Standard MIT License; see COPYING.MMGLUE.          ##
############################################################################

.text
.globl	___longjmp
.globl	__longjmp
.globl	_longjmp

.def ___longjmp; .scl 2; .type 32; .endef
.def __longjmp; .scl 2; .type 32; .endef
.def _longjmp; .scl 2; .type 32; .endef

___longjmp:
__longjmp:
_longjmp:
	movl 4(%esp), %ecx	# jump buffer
	movl 8(%esp), %eax	# val

	test %eax, %eax		# is val zero?
	jne  1f			# no:  return val
	xor  $1,   %eax		# yes: return one

1:
	movl 20(%ecx), %esi	# restore regs
	movl 16(%ecx), %edi
	movl 12(%ecx), %ebp
	movl 8(%ecx),  %ebx

	movl 4(%ecx),  %esp	# original stack pointer

	movl (%ecx),   %edx	# original return address
	jmp  *%edx

	.section .got$longjmp
	.global __imp__longjmp
__imp__longjmp:
	.long	_longjmp
	.linkonce discard