What's the difference between a label and a function in an assembly

I followed the YouTube build instructions via AT&T syntax. I just found out about declaring (if that's the right term here) a function with a .type directive like:

.type MyFunction, @function

      

Now I can define my function like this:

MyFunction:
    <code here>

      

And call it afterwards whenever:

call MyFunction

      

I know that before in the tutorials we were just creating a shortcut that was attached to some code:

MyLabel:
    <code here>

      

which could then be called like this:

call MyLabel

      

So my questions are:

What is the difference between a function declared with .type and a function declared simply with a label? When should one be used on top of the other, or does it matter?

+6


source to share


1 answer


I think whatever assembly you use is a return command. Whatever name "return" is used in your assembler. Function call differs from branching in that some context data (status register with bits N, C, V, program counter) are pushed / saved on the stack. When the return command is executed, data from the stack is restored. This is necessary to be able to continue program execution from the address immediately after the function call.



0


source







All Articles