- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Has anyone called assemby functions from C with NIOS II IDE.
I have an Assemby file that looks similar to the following; .global read_com1
read_com1:
movia %g7,com1
movia %g1,com1_cpw
st ,%g7 ;Store start of buffer in com1 cpw
movia %g7,com1
movia %g1,com1_cpr
st ,%g7 ;Store start of buffer in com1 cpr
movia %g7,com1_wrpf;zero com1_wrpf
movia %g0,0x00
st ,%g0
movia %g7,com1_rdfl;zero com1_rdfl
movia %g0,0x00
st ,%g0
jmp %o7 ;Return
nop
then I have a C file with a prototype and trying to call this assembly function. as follows //Prototypes
int read_com1(void);
value = read_com1();
The compiler and the Assembler complete with no errors but the linker gives me that following error; undefined reference to `read_com1' I have used this in NIOS V3.0 projects in the past with no trouble. Does anyone have any idea why this is not working in NIOSII IDE. Any thoughts or Ideas would be greatly appreciated!! Brandon
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brandon,
Your code should link just fine. You might want to check your Makefile(s) to make sure your asm object module is actually being included in the link. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,friends above
I have a question. I think NiosII 's compiler won't recognize assembly instruction written in Nios first generation. How did you managed to call assembly written in firstion generation from C in NiosII IDE? I'm curious about that because I have a lot of instructions written in first generation.If I can call them in NiosII IDE,then I won't have to re-write them . thx ---yancharles- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yc,
Assembly is assembly. It's very processor-specific. Looks like you'd better start writing (re-writing) :-) Cheers, - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yancharles,
You can call assembly functions in NIOSII. I resolved the problem that I was having originally when I started this thread. All you have to do is make sure that your function call has a .global reference to the name (As shown in the code snippet) create a prototype for the function and you can call the routine. If you look in the programers reference manual you can see how to pass information to your function. registers r4, r5, and so on are used to pass information to your function and returning data is through registers r2,r3. Also remember that NIOSII and first gen. NIOS has some changes in the instruction set. so you may need to modify your assembly function. Good Luck, Btaylor And thanks to scott for giving me some clues on the trouble I was having!!! It was a linking problem!!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yancharles,
After somemore work you are correct. You would have to re-write your code for the NIOSII. The instruction set is quite different and NIOSII will not compile first generations NIOS. I hope that I did not miss lead you too bad, in my last comment. I had to re-write all of my legacy assmebly code to work with NIOSII (What a pain) Good Luck, Btaylor
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page