您的位置:首页 > 其它

PPC中如何实现C以及汇编的远程调用

2010-11-03 14:55 447 查看
汇编的远程调用可用counter 寄存器实现:

li32    r0, timer_init
mtspr   9, r0
bctrl


C的远程调用可用函数指针实现:

typedef int (*func_ptr)(int a,int b)

int max(int a, int b) {
return a>b?a:b;
}

main() {
func_ptr xxx;
xxx=max;  or  max=(func_ptr)0xffff0000;
(*xxx)(9,8);
}


再举个例子:
==========================================
//declare before main()
// Function point that is used at the end of the program
// to jump to the address location stated by PROG_START_ADDR
#define PROG_START_ADDR 0x80180000
int (*func_ptr) ();
// declare after main()
// function point that is set to point to the address of
// PROG_START_ADDR
func_ptr = PROG_START_ADDR;
// jump to start execution code at the address
// PROG_START_ADDR
func_ptr();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐