<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=OurMajorLangIsCAndCPlusPlus%2Fsetjmp.c</id>
	<title>OurMajorLangIsCAndCPlusPlus/setjmp.c - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=OurMajorLangIsCAndCPlusPlus%2Fsetjmp.c"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=OurMajorLangIsCAndCPlusPlus/setjmp.c&amp;action=history"/>
	<updated>2026-05-15T04:57:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://mediawiki.zeropage.org/index.php?title=OurMajorLangIsCAndCPlusPlus/setjmp.c&amp;diff=37375&amp;oldid=prev</id>
		<title>imported&gt;Unknown at 05:23, 7 February 2021</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=OurMajorLangIsCAndCPlusPlus/setjmp.c&amp;diff=37375&amp;oldid=prev"/>
		<updated>2021-02-07T05:23:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; //&lt;br /&gt;
 // setjmp.c&lt;br /&gt;
 //&lt;br /&gt;
 // Non-local goto&lt;br /&gt;
 //&lt;br /&gt;
 // Copyright (C) 2002 Michael Ringgaard. All rights reserved.&lt;br /&gt;
 //&lt;br /&gt;
 // Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 // modification, are permitted provided that the following conditions&lt;br /&gt;
 // are met:&lt;br /&gt;
 // &lt;br /&gt;
 // 1. Redistributions of source code must retain the above copyright &lt;br /&gt;
 //    notice, this list of conditions and the following disclaimer.  &lt;br /&gt;
 // 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 //    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 //    documentation and/or other materials provided with the distribution.  &lt;br /&gt;
 // 3. Neither the name of the project nor the names of its contributors&lt;br /&gt;
 //    may be used to endorse or promote products derived from this software&lt;br /&gt;
 //    without specific prior written permission. &lt;br /&gt;
 // &lt;br /&gt;
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND&lt;br /&gt;
 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;br /&gt;
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 // ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE&lt;br /&gt;
 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL&lt;br /&gt;
 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS&lt;br /&gt;
 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)&lt;br /&gt;
 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT&lt;br /&gt;
 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY&lt;br /&gt;
 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF &lt;br /&gt;
 // SUCH DAMAGE.&lt;br /&gt;
 // &lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;setjmp.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #define OFS_EBP   0&lt;br /&gt;
 #define OFS_EBX   4&lt;br /&gt;
 #define OFS_EDI   8&lt;br /&gt;
 #define OFS_ESI   12&lt;br /&gt;
 #define OFS_ESP   16&lt;br /&gt;
 #define OFS_EIP   20&lt;br /&gt;
 &lt;br /&gt;
 __declspec(naked) int setjmp(jmp_buf env)&lt;br /&gt;
 {&lt;br /&gt;
   __asm&lt;br /&gt;
   {&lt;br /&gt;
     mov edx, 4[esp]          // Get jmp_buf pointer&lt;br /&gt;
     mov eax, [esp]           // Save EIP&lt;br /&gt;
     mov OFS_EIP[edx], eax&lt;br /&gt;
     mov OFS_EBP[edx], ebp    // Save EBP, EBX, EDI, ESI, and ESP&lt;br /&gt;
     mov OFS_EBX[edx], ebx&lt;br /&gt;
     mov OFS_EDI[edx], edi&lt;br /&gt;
     mov OFS_ESI[edx], esi&lt;br /&gt;
     mov OFS_ESP[edx], esp&lt;br /&gt;
     xor eax, eax             // Return 0&lt;br /&gt;
     ret&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 __declspec(naked) void longjmp(jmp_buf env, int value)&lt;br /&gt;
 {&lt;br /&gt;
   __asm&lt;br /&gt;
   {&lt;br /&gt;
     mov edx, 4[esp]          // Get jmp_buf pointer&lt;br /&gt;
     mov eax, 8[esp]          // Get return value (eax)&lt;br /&gt;
 &lt;br /&gt;
     mov esp, OFS_ESP[edx]    // Switch to new stack position&lt;br /&gt;
     mov ebx, OFS_EIP[edx]    // Get new EIP value and set as return address&lt;br /&gt;
     mov [esp], ebx&lt;br /&gt;
     &lt;br /&gt;
     mov ebp, OFS_EBP[edx]    // Restore EBP, EBX, EDI, and ESI&lt;br /&gt;
     mov ebx, OFS_EBX[edx]&lt;br /&gt;
     mov edi, OFS_EDI[edx]&lt;br /&gt;
     mov esi, OFS_ESI[edx]&lt;br /&gt;
 &lt;br /&gt;
     ret&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
----&lt;br /&gt;
[[OurMajorLangIsCAndCPlusPlus]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>