!************************************************************************** !* !* Boot-ROM-Code to load an operating system across a TCP/IP network. !* !* Module: setjmp.S !* Purpose: Routines for long jumps !* Entries: _setjmp, _longjmp !* !************************************************************************** !* !* Copyright (C) 1998-2003 Gero Kuhlmann !* !* This program is free software; you can redistribute it and/or modify !* it under the terms of the GNU General Public License as published by !* the Free Software Foundation; either version 2 of the License, or !* any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. !* !* $Id: setjmp.S,v 1.4 2003/01/25 23:29:41 gkminix Exp $ !* ! !************************************************************************** ! ! Include assembler macros: ! #include #include "libpriv.inc" ! !************************************************************************** ! ! Start code segment. ! .text public _setjmp ! define entry points public _longjmp ! !************************************************************************** ! ! Set a long jump environment structure. Returns zero on set, or the ! parameter value of longjmp. ! Input: 1. arg - pointer to setjmp buffer ! Output: zero on initial call or the parameter value of longjmp ! _setjmp: penter (0) ! setup standard stack frame getcarg (bx,0) ! get pointer to setjmp buffer mov [bx + JMPBUF_SI],si mov [bx + JMPBUF_DI],di mov [bx + JMPBUF_ES],es mov [bx + JMPBUF_BP],bp mov [bx + JMPBUF_SP],sp mov ax,#setj9 mov [bx + JMPBUF_PC],ax xor ax,ax setj9: pleave ret ! !************************************************************************** ! ! Return to a prevously defined setjmp. ! Input: 1. arg - pointer to setjmp buffer ! 2. arg - value to be returned by setjmp ! Output: routine doesnt return ! _longjmp: penter (0) ! setup standard stack frame getcarg (bx,0) ! get pointer to setjmp buffer getcarg (ax,1) ! get return argument or ax,ax jnz longj1 ! never return zero mov ax,#1 longj1: mov si,[bx + JMPBUF_SI] mov di,[bx + JMPBUF_DI] mov bp,[bx + JMPBUF_BP] mov es,[bx + JMPBUF_ES] mov sp,[bx + JMPBUF_SP] jmp near ptr [bx + JMPBUF_PC] ! !************************************************************************** ! end