On Monday 03 April 2006 12:57 am, Don Y wrote:
Chuck Guzis wrote:
On 4/2/2006 at 7:12 PM Roy J. Tellason wrote:
And why it was necessary to stuff parameters into
registers, when it's
easy enough to put 'em on the stack, among other things.
Well, memory fetches are slower than register references for one. It
requires stack space, for another. And the 8080 code to access the
arguments, while not awful, is somewhat clumsy:
lxi h, 2
dad sp
mov c,m
inx h
mov b,m
....or something like that to grab a word off the stack into BC.
I think the real reason (?) goes to a difference in cultures between
register rich and register poor machines IN THAT TIMEFRAME.
I think you're probably right...
E.g., if you are writing code for a 68xx, you have
little choice
but to do everything in memory addressing. Whereas if you are
using 8080/8085/Z80 et al., you just get used to *keeping* things
in registers (I can recall spending lots of time evaluating
which arguments I would put in which registers so I could
*keep* them there -- or somewhere else in the register set -- for
the duration of the algorithm... XCHG being a favorite tool
in those cases!)
Yeah. Though XTHL was another one...
Moving to something like a 99000 can be terribly
distressing
for the register rich crowd to become accustomed to! ;)
I found, though, when I was doing some z80 stuff a while back that most of
the time I'd use one pair for an address pointer and maybe one other besides
the accumulator and that was it, over 90% of the time.
Oh, and the little monitor program that I was playing with didn't push a
parameter on to the stack, it put it inline, right after the call to some
subroutine -- the called code would pick it up and use it and adjust the
stack pointer to just past it for the return. :-)
I have to dig out that code, anyhow, there were a few little tricks in there
that I think I want to use again. Like funneling everything through a
dispatch table, so that un-programmed EPROM showing up as "FFFF" in some
entries would be handled automatically ("CRASH!" :-), ferinstance.
--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James
M Dakin