Skip to content

Commit

Permalink
xbox: Add setjmp
Browse files Browse the repository at this point in the history
  • Loading branch information
thrimbor committed Oct 1, 2019
1 parent c06b9d2 commit ae5c0a3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
27 changes: 27 additions & 0 deletions platform/xbox/functions/setjmp/longjmp.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.text

/*
Buffer layout:
0: unsigned long ebp
4: unsigned long ebx
8: unsigned long edi
12: unsigned long esi
16: unsigned long esp
20: unsigned long eip
*/

.globl _longjmp
_longjmp:
movl 4(%esp), %ecx
movl 8(%esp), %eax

movl (%ecx), %ebp
movl 4(%ecx), %ebx
movl 8(%ecx), %edi
movl 12(%ecx), %esi
movl 16(%ecx), %esp
movl 20(%ecx), %edx
testl %eax, %eax
jnz .r
incl %eax
.r: jmp *%edx
27 changes: 27 additions & 0 deletions platform/xbox/functions/setjmp/setjmp.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.text

/*
Buffer layout:
0: unsigned long ebp
4: unsigned long ebx
8: unsigned long edi
12: unsigned long esi
16: unsigned long esp
20: unsigned long eip
*/

.globl _setjmp
_setjmp:
movl 4(%esp), %eax

movl %ebp, (%eax)
movl %ebx, 4(%eax)
movl %edi, 8(%eax)
movl %esi, 12(%eax)
leal 4(%esp), %ecx
movl %ecx, 16(%eax)
movl (%esp), %ecx
movl %ecx, 20(%eax)

xorl %eax, %eax
ret
26 changes: 26 additions & 0 deletions platform/xbox/include/setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _PDCLIB_SETJMP_H
#define _PDCLIB_SETJMP_H _PDCLIB_SETJMP_H

#ifdef __cplusplus
extern "C" {
#endif

/*
Buffer layout:
0: unsigned long ebp
4: unsigned long ebx
8: unsigned long edi
12: unsigned long esi
16: unsigned long esp
20: unsigned long eip
*/
typedef unsigned long jmp_buf[6];

int setjmp( jmp_buf env );
_Noreturn void longjmp( jmp_buf env, int val );

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit ae5c0a3

Please sign in to comment.