I have a coldfire sequence from IDAPro that looks like this:
sub_29be8: var_8 = -8 var_2 = -2 arg_0 = 8 arg_6 = $E link a6, #-4; move.l a2, -(sp) movea.l arg_0(a6),a2 tst.w arg_6(a6) bne.s loc_29c00 bset #5, $1e(a2) bra.s loc_29c14 ....
In the documentation here, I'm having some issues with understanding what exactly the documentation is saying.
LINK Ay,#<displacement> W
SP – 4→SP; //subtract SP by 4 and set into SP
Ay → (SP); //set address pointed to in Ay and set into value of SP
SP→Ay, SP + dn → SP //set SP into Ay, add the offset specified by <displacement> and set into SP
Are ALL of these steps executed for the
LINK instruction, or are these the possibilities based on some processor states that I haven't found out about yet? (This appears to be setting up the stack for a function call.)
The next question I have about the sequence is the second instruction,
move.l a2, -(sp)
This appears to be moving a
longword from a2 into the stack pointer, HOWEVER the negation looks odd to me. It appears to be "move address in a2 into SP and then multiply its value by -1" but I could also see the parenthesis being used as specifying an order of operations to be applied to the address.