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 (longjmp)
29       SOTYPE_FUNCTION(setjmp)
30       SOTYPE_FUNCTION(longjmp)
31
32SYM (setjmp):
33
34	pushl	ebp
35	movl	esp,ebp
36
37	pushl	edi
38	movl	8 (ebp),edi
39
40	movl	eax,0 (edi)
41	movl	ebx,4 (edi)
42	movl	ecx,8 (edi)
43	movl	edx,12 (edi)
44	movl	esi,16 (edi)
45
46	movl	-4 (ebp),eax
47	movl	eax,20 (edi)
48
49	movl	0 (ebp),eax
50	movl	eax,24 (edi)
51
52	movl	esp,eax
53	addl	$12,eax
54	movl	eax,28 (edi)
55
56	movl	4 (ebp),eax
57	movl	eax,32 (edi)
58
59	popl	edi
60	movl	$0,eax
61	leave
62	ret
63
64SYM (longjmp):
65	pushl	ebp
66	movl	esp,ebp
67
68	movl	8(ebp),edi	/* get jmp_buf */
69	movl	12(ebp),eax	/* store retval in j->eax */
70	movl	eax,0(edi)
71
72	movl	24(edi),ebp
73
74       __CLI
75	movl	28(edi),esp
76
77	pushl	32(edi)
78
79	movl	0(edi),eax
80	movl	4(edi),ebx
81	movl	8(edi),ecx
82	movl	12(edi),edx
83	movl	16(edi),esi
84	movl	20(edi),edi
85       __STI
86
87	ret
88