[futurebasic] Re: [FB] Okay, so I have dyslexia (was: AIFF)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1999 : Group Archive : Group : All Groups

From: Derek Smith <dereksmi@...>
Date: Wed, 13 Oct 1999 12:07:53 -1000
On Wed, 13 Oct 1999, Joe Lewis Wilkins wrote:

> > It decremented that stack pointer and then moved the contents it was
> > currently pointing at into the variable.  There *are* occasions when this
> > would be done, but its rare.
> But, wouldn't this "contents" be pretty much an "unknown"? If it were "known", we'd
> probably be dealing with some kind of "indexing" to it instead - no? I forgot about
> reading -(?) as a decrement though.

Not really.  You can stick values of any kind on to the stack in reverse
order if you wish.  The problem is that the way the stack is setup, this
would destroy the previous values it was holding.  If you popped stuff off
the stack in reverse order after that, you'd get the values you put in
there, but the stack pointer would be ruined.

You would only do this when you wanted to get values on the stack in
reverse order and you remembered to repair the stack pointer afterward.
For the record, I don't reccomend it, but there is nothing wrong with it.
The CPU will execute it same as anything else.  

Of course, now I better explain that.  The reason that it executes is
this:  sp is really A7, an address register. The 68000 has a number of
special instruction features that let you stuff a pointer into an address
register and then predecrement/postdecrement or
pre-increment/post-increment a pointer that you place there.  It is
extremely useful and efficient to do this when copying and moving pointer
data.  With the pre-decrement mixed with a post-increment, you can copy a
block in reverse byte order into another block.  And there are many times
when this would be needed. I used it on several occasions to flip a sprite
upside down and mirrored left to right.

The 68000 doesn't really know what you are using the registers for.  The
system stack is held in a register that happens to be an address register,
so all of these instructions are percectly valid when using the sp.  For
all the CPU cares, you could make more stacks with A0 to A6 as well.
They all get treated the same way.  Its just Mac convention to use A7.