00001 00006 /* 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.0 (the "License"); you may not use this file except in 00009 * compliance with the License. You may obtain a copy of the License at 00010 * http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" 00013 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 00014 * License for the specific language governing rights and limitations 00015 * under the License. 00016 * 00017 * Contributor(s): Torsten Landschoff <tla@informatik.uni-kiel.de> 00018 */ 00019 00020 #include <setjmp.h> 00021 00022 #ifdef CONF_SETJMP 00023 00024 int setjmp(jmp_buf env); 00025 00026 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00027 __asm__("\n\ 00028 .text\n\ 00029 .align 2\n\ 00030 .globl _setjmp\n\ 00031 _setjmp:\n\ 00032 stc ccr,r1h ; remember flags\n\ 00033 mov.w #12,r2 ; move r0 'behind' jump buffer\n\ 00034 add r2,r0 ; for storing with pre-decrement\n\ 00035 \n\ 00036 pop r2 ; get return address\n\ 00037 mov.w r2,@-r0 ; store return address\n\ 00038 mov.w r1,@-r0 ; store flags\n\ 00039 mov.w r7,@-r0 ; store registers r4-r7\n\ 00040 mov.w r6,@-r0\n\ 00041 mov.w r5,@-r0\n\ 00042 mov.w r4,@-r0\n\ 00043 sub.w r0,r0 ; return value: 0\n\ 00044 jmp @r2 ; jump to caller\n\ 00045 "); 00046 #endif // DOXYGEN_SHOULD_SKIP_THIS 00047 00048 00049 void longjmp(jmp_buf env, int val); 00050 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00051 __asm__("\n\ 00052 .text\n\ 00053 .align 2\n\ 00054 .globl _longjmp\n\ 00055 _longjmp:\n\ 00056 mov.w @r0+,r4 ; restore registers r4-r7\n\ 00057 mov.w @r0+,r5\n\ 00058 mov.w @r0+,r6\n\ 00059 mov.w @r0+,r7\n\ 00060 mov.w @r0+,r2 ; get flags\n\ 00061 mov.w @r0+,r0 ; get return address\n\ 00062 push r0 ; set up for rts\n\ 00063 mov.w r1,r0 ; return specified value\n\ 00064 ldc r2h,ccr ; restore flags\n\ 00065 rts ; return to caller\n\ 00066 "); 00067 #endif // DOXYGEN_SHOULD_SKIP_THIS 00068 00069 #endif // CONF_SETJMP
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |