1

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.

  • 1
    Your second question is explained in (uh) about any 68K documentation: it's just a pre-decrement. If you are familiar with x86 code: it's a push, but to any A-register, and 'you' need to decrement the address yourself, or it'll just store the new value. – usr2564301 Feb 17 '15 at 21:07
  • @Jongware, I'm using the ColdFire User Manual, and the only reference to "predecrement" in the entire 700+ pages was a description of the algorithm used by the MASK instruction. I had to dig up a different "programmer's reference" to get more detail. – avgvstvs Feb 17 '15 at 21:20
  • Gave me the answer to LINK as well. – avgvstvs Feb 17 '15 at 21:21
1

Answer to the LINK question was provided on page 119 here.

Pre/Post decrement operations are described on page 44.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.