Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site desint.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcrdcf!trwrb!desint!geoff
From: geoff@desint.UUCP (Geoff Kuenning)
Newsgroups: net.lang.c
Subject: Re: Re: setjmp: read the manual
Message-ID: <159@desint.UUCP>
Date: Fri, 19-Oct-84 03:17:47 EDT
Article-I.D.: desint.159
Posted: Fri Oct 19 03:17:47 1984
Date-Received: Sun, 21-Oct-84 12:16:32 EDT
References: <401@ism780.UUCP>
Reply-To: geoff@desint.UUCP (Geoff Kuenning)
Organization: his home computer, Thousand Oaks, CA
Lines: 40
Summary: 

In article <401@ism780.UUCP> Darryl Richman (darryl@ism780.UUCP) writes:

>>To fix a program that this breaks, you remove "register" declarations from
>>routines that call setjmp.  Not so bad.
>
>Don't you also have to start removing the register declarations in the
>functions that call functions that call setjmp?  Seems like you could
>lose their (parents to funcs that call setjmp) register values further
>down in the call chain also...
>

Nope.  "setjmp" itself takes care of this by saving 100% of the registers at
the time it is called.  So the *parents'* registers are completely
protected.

>>On the VAX there is a call instruction that dumps all this
>>stuff on the stack for you (slowly; I understand a Modula compiler that
>>avoided the instruction sped itself up by 20%).  On the 68000 there is
>>no such whizzo instruction so we were forced to do it efficiently or
>>tell ourselves why not.
>
>BTW the 68000 has a whizzo instruction for saving registers --
>`movem' (move multiple).

The register saving is not the problem.  The problem is recording *on the
stack* which registers have been saved, so that someone other than the routine
that saved the registers (e.g., longjmp) can restore them.  On the 68k, you
would have to explicitly push a movem mask, and unwinding that mask would
involve either slow bit shifting or (yuck) instruction modification (although
you don't have to unwind it in software very often).  But pushing that mask
(you can manage to pop it for free as part of your 'unlk') is a pretty heavy
penalty to pay in a 5-instruction entry/exit sequence (link/movem/movem/unlk
and rts), just so setjmp works a bit simpler.  And what about the pdp11, the
8086, and many other machines?  Bell supports UNIX on an ever-growing variety
of computers.

-- 
	Geoff Kuenning
	First Systems Corporation
	...!ihnp4!trwrb!desint!geoff