Forum Discussion
Altera_Forum
Honored Contributor
19 years agoAssemble in C
hi i am i am new to NIOS. I want to insert an asm code in C prog... In microcontroller prog..... i use# pragma... this command is not working in NIOS IDE. plz tell me in what way i can insert...
Altera_Forum
Honored Contributor
19 years ago --- Quote Start --- originally posted by arrive+mar 20 2007, 04:13 pm--><div class='quotetop'>quote (arrive @ mar 20 2007, 04:13 pm)</div>
--- quote start ---
<!--quotebegin-sriram_k@Mar 20 2007, 08:24 AM hi
i am i am new to nios. i want to insert an asm code in c prog...
in microcontroller prog..... i use# pragma...
this command is not working in nios ide. plz tell me in what way i can insert my
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22362)
--- quote end ---
--- Quote End --- Have a try on the inline asm, which basically enable users to write assembly instructions directly. For example:
asm ("stw r0, 16(sp)"); <div align='right'><{post_snapback}> (index.php?act=findpost&pid=22365)</div> [/b] --- Quote End --- Just a small example: __asm__ __volatile__("mov r2, %0 \n\t" "mov r3, %1 \n\t" "ldw r4, 0(r2) \n\t" "stw r4, 312(r3) \n\t" : // No output needed ! :"r"(var_a),"r"(var_b) // Input :"r2","r3","r4" // used registers ); Have a look at http://homepage.fudan.edu.cn/%7eeuler/gcc_asm/inline-1.html (http://homepage.fudan.edu.cn/%7eeuler/gcc_asm/inline-1.html) Christian