Subversion Repositories Kolibri OS

Rev

Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 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
 
32
.def  _setjmp; .scl  2;  .type 32; .endef
33
 
34
SYM (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
 
66
.def  _longjmp; .scl  2;  .type 32; .endef
67
 
68
SYM (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
	movl	28(edi),esp
79
 
80
	pushl	32(edi)
81
 
82
	movl	0(edi),eax
83
	movl	4(edi),ebx
84
	movl	8(edi),ecx
85
	movl	12(edi),edx
86
	movl	16(edi),esi
87
	movl	20(edi),edi
88
 
89
	ret