Re: A89: A simple? Question


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

Re: A89: A simple? Question




> nevermind, I see what's wrong.. maybe we should tell Rusty to fix
hello
> world also.. by the way, someone please answer my question about the
4 on
> the stack.. also, what is pc again?

> >	lea string(pc),a0
      ...blabla
> >_string:

Well, this is to make relocatable code:
If you suppose that program is loaded at &1000, and that string
points to &1100, then when you perform the "lea" you want
"a0=&1100", isn't it? So a "move.l #string,a0" should suffice?

NOPE! Because if your program now loads at &2000 instead of
&1000, the "move.l #string,a0" would still have the value it
was assembled for, ie &1100.

Two ways to correct this:
  * Use relocation tables (apparently Doors OS etc uses this), which
    tells the OS that he must modify certain values before the
    program is launched.
  * Tell the program to use PC+offset to the string, instead of an
    absolute adress: whatever  the program's load adress is, the
    "distance" (=offset) from the "lea" instruction to the string is
    always the same, so the adress of the string is PC+offset.
    This is exactly what "lea string(pc),a0" does!
    the program's load adress is.

==
Alain BROBECKER (baah/Arm's Tech)    |_  _  _ |_                    ___
abrobecker@yahoo.com                 |_)(_|(_|| )  of  /\  _ _  _ /  | _ _|_ 
http://www.cybercable.tm.fr/~brooby/                  /--\| ||)_)    |(-(_| )


_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com