[A89] Re: A whole lot of questions...
[Prev][Next][Index][Thread]
[A89] Re: A whole lot of questions...
>movem v.s. movem.l is there a difference? or can i assume that movem
>insinuates a long word?
No, it assumes MOVEM is MOVEM.W if no size specifier is used. This is true
for most instructions.
>also, could someone show me an example using pea and lea; I'm mostly
>wondering if it is possible to do something like pea a1...lea a1... haven't
>gotten that to compile :)
PEA and LEA can only be used with control addressing modes:
(An)
(d16,An)
(d8,An,Xn)
(xxx).W
(xxx).L
(d16,PC)
(d8,PC,Xn)
Basically, what happens is the processor calculates the effective address,
just as it would if it were going to fetch data, but instead, the
calculated address IS the data. So if A0=$1234, then: LEA (A0),A1 would put
$1234 into A1. And if you code: lea foobar(pc),a6 -- it would place place
the address of foobar in A6.
>in an assembly language program do I need to save every single register or
>just certain ones or none at all? Right now, I use movem a0-a6/d0-d7,-(a7).
>if I use a6 as a frame pointer, do i need to save it?
I don't know about the frame pointer thing, but just to be safe, I save
everything. I think the frame pointer should be the same once you exit,
anyway.
I usually just do:
_main:
movem.l d0-d7/a0-a6,-(a7)
move.l a0,save_sp
... program here ...
Exit:
move.l save_sp,a0
movem.l (a7)+,d0-d7/a0-a6
rts
save_sp: dc.l 0
The advantage of saving the stack pointer immediately after saving all the
other registers is that you can exit the program anything by simply
BSR/JSRing or branching to Exit. All the junk that has accumulated on the
stack will be skipped over and the program exits just fine.
Bart
Follow-Ups:
References: