So, if your code looks like this:
Code: Select all
void B(void);
void A(void);
void A(void)
{
}
void B(void)
{
}
Code: Select all
; ---------------------------------------------------------------
; void __near__ B (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _B: near
.segment "CODE"
rts
.endproc
; ---------------------------------------------------------------
; void __near__ A (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _A: near
.segment "CODE"
rts
For example, if I have various functions in memory, then the ones that belong together should go after each other:
MovePlayer
MovePlayerHelperFunction
MoveOpponent
But in this case, since MovePlayer and MoveOpponent would be declared in the header file since they need to be called from another code file while MovePlayerHelperFunction is just a local function and is therefore only declared in the .c source file, the order in assembly would be this:
MovePlayer
MoveOpponent
MovePlayerHelperFunction
So, why is this even the case?
Declarations of function headers are just there to let other translation units know what the function looks like. I can write the same declaration as often as I want. It's just a reference point.
Why is the code not ordered according to the way I actually define the functions? Or is there any way to do this?