-- linux爱好者,业余时间热衷于分析linux内核源码 -- 目前主要研究云计算和虚拟化相关的技术,主要包括libvirt/qemu,openstack,opennebula架构和源码分析。 -- 第五届云计算大会演讲嘉宾 微博:@Marshal-Liu
分类: LINUX
2009-09-04 13:56:19
- 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