[net.lang.c] Args in Regs

rbj@icst-cmr (root) (04/28/86)

> Why do so many of the micro operating systems
> insist on putting arguments in registers!!!.  Even MS-DOS expects
> arguments in registers rather than on the stack.

Surprise! Even UNIX (V6) does this! The reason is that the machine
generally uses the same regs in supervisor mode. This is easier than
trying to did the args out of the user's space, which entails accessing
another map entry. BSD seems to use the stack however.

	(Root Boy) Jim Cottrell		<rbj@cmr>
	"One man gathers what another man spills"

rbj@icst-cmr (Root Boy Jim) (05/20/86)

>I don't want to quote too much of the original article -- it was rather long.
>The thrust of it was that passing parameters in registers doesn't make things
>run faster.  This does not fit with my experience.  When we implemented
>parameter passing in registers at Zilog, it was a big win.

*WAS* a big win - meaning maybe it looked good on benchmarks...

[...]
>I will admit that this parameter passing caused difficulties.  In particular,
>varargs code was messy, and debuggers more difficult to implement.  Was it
>worth it?  I believe so.  Our emphasis was on speed, and that we had.

1) pdp-11 style varargs was broken - no way from C to get a those arguments
   that got crammed into registers.

	The key phrase here is `pdp-11 style'. No way from C? Just use
	the variable names! The compiler knows about them.

2) Because of the register assignment scheme used, you couldn't even blindly
   pass a list of variable arguments to a routine like printf that did know
   how to deal with them.

	Why not? And who says varargs has to be written in C? It just may
   	have to be written in assembly some day.

3) setjmp/longjmp got broken with respect to restoring register variable
   parameters somewhere along the way.

	Probably difficult, but not impossible. Pyramids seem to work.

In the long run, portability seems to have become the more important issue:

Just try porting some of the code in mod.sources and net.sources to the
machine and see how far you can get without having to go into the editor 
and start whacking at source code.  Assume that software developers will
have the same problems porting their wares...

	Agreed. No one said it would be easy. But then, if it wasn't 
	just a little bit hard, they'd hire your kid sister instead of you.

Also, note that Zilog has never delivered its ATT SVID blessed System V port,
and that their next series of machines will contain ATT chips running vanilla
3Bx software...

	Zilog of course has other problems as well.
	 
George Robbins - now working with,	uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

	(Root Boy) Jim Cottrell		<rbj@cmr>
	"One man gathers what another man spills"