prevent buffer overflow, LoadString accepts the size of the buffer in TCHARs, not...
[reactos.git] / reactos / ntoskrnl / kdbg / i386 / setjmp.S
1 .file "setjmp.S"
2 /*
3 * Copyright (C) 1998, 1999, Jonathan S. Shapiro.
4 *
5 * This file is part of the EROS Operating System.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 /* #include <eros/i486/asm.h> */
23
24
25 /*
26 * typedef struct {
27 * unsigned long ebx, esi, edi;
28 * unsigned long ebp;
29 * unsigned long sp;
30 * unsigned long pc;
31 * } jmp_buf[1];
32 */
33
34 /*
35 * On entry, the stack to setjmp looks like:
36 *
37 * ptr to jmp_buf
38 * return PC
39 */
40 .globl _setjmp
41 _setjmp:
42 pushl %ebp
43 movl %esp,%ebp
44
45 movl 0x8(%ebp),%eax /* address of jmp_buf to eax */
46 movl %ebx,(%eax) /* save %ebx */
47 movl %esi,4(%eax) /* save %esi */
48 movl %edi,8(%eax) /* save %edi */
49 leal 8(%ebp),%edx /* calling proc's esp, not ours! */
50 movl %edx,16(%eax)
51 movl 4(%ebp), %edx /* save return PC */
52 movl %edx,20(%eax)
53 movl 0(%ebp),%edx /* calling proc's ebp, not ours! */
54 movl %edx,12(%eax)
55
56 xorl %eax,%eax /* return 0 the first time */
57 leave
58 ret $4
59