Re: A89: Registers


[Prev][Next][Index][Thread]

Re: A89: Registers




a0 and d0 is jut because they  are the first.. if you need the info in a0 or d0,
then you take a1 or d1...   it is just that simple..
with a7 though..  I can see that you need an explanation of how the stack works
:)
you don't put data IN a7, you put it in the stack, that a7 points to.. a7
contains the address of the stack.
if you move.l something,-(a7)
then a7 is decremented with 4 and you put the longword (4bytes) "something" into
the memory that a7 points to,
then when you want to "restore" a7 you should add 4 to a7 to be able to access
whatever is beneath the data you putted on the stack before..
if you move.w something,-(a7) then you must add 2 to a7, because move.w moves a
word and a word is 2 bytes long..

if you pushes more things, then just add together the number of bytes you have
pushed, and there you have the number you need to restore a7..

the reason you use a7 is that that is the register that by the system is
initialized to point to the stack, and it is also the register pea (push
effective address) uses..

you can create your own stack anywhere in memory (if you just allocate it first)
and have any of the An regs to point to it and use it like a7 (exept for pea)

I hope you got any of this..
//Olle

> Miles Raymond wrote:
> 
> I have had a few questions that have been bugging me since I started learning
> assembly for the 89:
> 
> 1.Why are a0, a7, and d0 used more than the other registers?
> 2.And why do we constantly have to "restore" a7, when all we are doing is
> putting more stuff in it?  Why don't we just use a different register (a1-a6,
> or d1-d7?) so we won't have to restore anything?  Or will we still have to?
> 3.How do I know how to restore a7?  I see so many different numbers being used
> to restore it.
> 
> Thanks to anyone who can answer these questions.
> 
> -Miles Raymond      EML: m_rayman@bigfoot.com
> ICQ: 13217756       IRC: Killer2        AIM: MRayMan
> http://www.bigfoot.com/~m_rayman/


References: