Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site uiucuxc Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!uiucuxc!hamilton From: hamilton@uiucuxc.CSO.UIUC.EDU Newsgroups: net.micro.amiga Subject: Re: Lattice setjmp/longjmp Message-ID: <148600031@uiucuxc> Date: Sun, 12-Jan-86 18:31:00 EST Article-I.D.: uiucuxc.148600031 Posted: Sun Jan 12 18:31:00 1986 Date-Received: Fri, 17-Jan-86 01:31:59 EST References: <431@well.UUCP> Lines: 50 Nf-ID: #R:well.UUCP:431:uiucuxc:148600031:000:1574 Nf-From: uiucuxc.CSO.UIUC.EDU!hamilton Jan 12 17:31:00 1986 >Does anyone know if setjmp/longjmp works on the AMIGA under Lattice C? >I tried a kluge of defining: > typedef int jmp_buf[16]; >which solved the problem of making the identifier "jmp_buf" known. >What should look like? >-Fred i'm in the process of re-organizing my amiga.lib and lc.lib, so i took a look at setjmp/longjmp. here's my disassembly: _setjmp: ;setjmp (buf) movl 4(sp),a0 ;a0=buf movl sp,8(a0) ;buf[2]=sp movl (sp),(a0) ;buf[0]=ret rts _longjmp: ;longjmp (buf, val) movl a1,-(sp) ;save a1 movl a0,-(sp) ;save a0 movl 16(sp),d0 ;d0=val bne 1$ addql #1,d0 ;++d0 1$: movl 12(sp),a0 ;a0=buf movl 8(a0),a1 ;a1=setjmp's sp movl (a0),(a1) ;*(setjmp's sp)=setjmp's ret movl 4(a0),a6 ;a6=buf[1] movl (sp),a0 ;restore a0 movl 4(sp),-(a1) ;push saved a1 onto setjmp's sp movl a1,sp ;sp=setjmp's sp-4 movl (sp)+,a1 ;restore a1 and sp rts so the short anwer is that jmpbuf appears to be: typedef long jmp_buf[3]; however, if you look close, you see that setjmp doesn't save a6 in buf[1], but longjmp does copy buf[1] (garbage) to a6. also notice that setjmp doesn't clear d0 before return. i think setjmp ought to look more like: movl 4(sp),a0 ;a0=buf movl sp,8(a0) ;buf[2]=sp movl a6,4(a0) ;buf[1]=fp movl (sp),(a0) ;buf[0]=ret subl d0,d0 ;return(0) rts wayne hamilton U of Il and US Army Corps of Engineers CERL UUCP: {ihnp4,pur-ee,convex}!uiucdcs!uiucuxc!hamilton ARPA: hamilton@uiucuxc.cso.uiuc.edu CSNET: hamilton%uiucuxc@uiuc.csnet USMail: Box 476, Urbana, IL 61801 Phone: (217)333-8703