I'm currently trying to understand ARM assembly for Cortex-M cores.
I know that functions that are in Thumb mode (which is the only mode the core supports) are called by their address and the LSB of the address is high to indicate that the destination is Thumb code.
In assembly I write following in front of the function "Reset_Handler" to tell the assembler that the data at the label is executable/a function:
.type Reset_Handler, %function
Reset_Handler:
MOV R0, R0 # just do something
If I now load the address of the label
LDR R0, =Reset_Handler
the LSB of R0 is set.
Do I have to put this .type directive in front of every label I want to use as a function with indirect calls?
Or is there a way to let the assembler automatically decide the correct address?
If I want to copy the code of the function to RAM and load the address of this function, I have to clear the LSB myself to get the "real" address where the data is located, am I right?
Is the .type directive necessary in this case? I know that it is necessary as soon as I want to put the address in the vector table as this requires the LSB to be set.