1/* This is file is a merger of SETJMP.S and LONGJMP.S */
2/*
3 *  This file was modified to use the __USER_LABEL_PREFIX__ and
4 *  __REGISTER_PREFIX__ macros defined by later versions of GNU cpp by
5 *  Joel Sherrill (joel@OARcorp.com)
6 *  Slight change: now includes i386mach.h for this (Werner Almesberger)
7 *
8 * Copyright (C) 1991 DJ Delorie
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms is permitted
12 * provided that the above copyright notice and following paragraph are
13 * duplicated in all such forms.
14 *
15 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 */
18
19 /*
20 **	jmp_buf:
21 **	 eax ebx ecx edx esi edi ebp esp eip
22 **	 0   4   8   12  16  20  24  28  32
23 */
24
25       #include "i386mach.h"
26
27        .global SYM (setjmp)
28        .global SYM (__libc_longjmp)
29        .weak SYM (longjmp)
30       SOTYPE_FUNCTION(setjmp)
31       SOTYPE_FUNCTION(longjmp)
32       SOTYPE_FUNCTION(__libc_longjmp)
33
34SYM (setjmp):
35
36	pushl	ebp
37	movl	esp,ebp
38
39	pushl	edi
40	movl	8 (ebp),edi
41
42	movl	eax,0 (edi)
43	movl	ebx,4 (edi)
44	movl	ecx,8 (edi)
45	movl	edx,12 (edi)
46	movl	esi,16 (edi)
47
48	movl	-4 (ebp),eax
49	movl	eax,20 (edi)
50
51	movl	0 (ebp),eax
52	movl	eax,24 (edi)
53
54	movl	esp,eax
55	addl	$12,eax
56	movl	eax,28 (edi)
57
58	movl	4 (ebp),eax
59	movl	eax,32 (edi)
60
61	popl	edi
62	movl	$0,eax
63	leave
64	ret
65
66SYM (__libc_longjmp):
67SYM (longjmp):
68	.weak longjmp
69	pushl	ebp
70	movl	esp,ebp
71
72	movl	8(ebp),edi	/* get jmp_buf */
73	movl	12(ebp),eax	/* store retval in j->eax */
74	movl	eax,0(edi)
75
76	movl	24(edi),ebp
77
78       __CLI
79	movl	28(edi),esp
80
81	pushl	32(edi)
82
83	movl	0(edi),eax
84	movl	4(edi),ebx
85	movl	8(edi),ecx
86	movl	12(edi),edx
87	movl	16(edi),esi
88	movl	20(edi),edi
89       __STI
90
91	ret
92