2011年(76)
分类:
2011-08-24 17:48:08
- First, for CodeWarrior to be able to access your function you need the following line:
.function "MyFile", PPC_Start_Asm, PPC_End_Asm - PPC_Start_Asm
Where "MyFile" is the name of your file (without the extension), PPC_Start_Asm is a label at the beginning of your code, and PPC_End_Asm is a label at the end of your code. The "PPC_End_Asm - PPC_Start_Asm" portion tells CodeWarrior the size of your function in bytes (difference between end and beginning addresses).
- Next, tell the compiler that the following section is your assembly code and not something else. Put .text at the start of your assembly function:
.text
- Finally, put a label for the beginning of your program, following the label for PPC_Start_Asm:
PPC_Start_Asm:
MyFunction:
Both PPC_Start_Asm and MyFunction will contain the same address.
Here is a complete example of a simple program:
.include "defines.h"
.function "MyFile", PPC_Start_Asm, PPC_End_Asm - PPC_Start_Asm
.text
PPC_Start_Asm:
MyFunction:
; To Do: place your assembly code here
PPC_End_Asm:
.import My_Function
; your other code
; call to My_Function subroutine
bl My_Function
; more codeIn “Other_File.asm”
.export My_Function
My_Function:
;your My_Function code
blr ; return to MainSource file