Altera_Forum
Honored Contributor
19 years agoassemble under nios2
Hi all,
i write a program under nios2 using assemble lanauge, following is the source code # include <linux/module.h># include <linux/kernel.h> void print(void) { printk("function print\n"); } typedef void(*pointer)(void); ulong code[3]; void jump(void) { __asm__("movia r12, print"); __asm__("jmp r12"); } int __init init_filter(void) { jump(); } void __exit exit_filter(void) { } module_init(init_filter); module_exit(exit_filter); this can work well, but if i change the function init_filter as bellow, the system will reboot, int __init init_filter(void) { pointer p; code[0]=0x03000034; code[1]=0x63000004; code[2]=0x6000683a; p = (pointer)code; p(); } code[0]~code[2] is the hex value that i get from nios2-elf-objdump according to two assemble sentences. how should i do? thanks a lot