Keywords: EDK, inline, assembly, source, code, MicroBlaze
I am often interested in placing inline assembly commands within my C source files. Does the MicroBlaze GNU compiler recognize this? What is the format for inserting this source?
The GNU compiler (mb-gcc) was built specifically for MicroBlaze and supports many of the GNU features. Refer to the GNU source manual for applicable source support features.
Below are several examples of placing simple inline assembly commands with the main source code:
j++; //below is the equivalent inline assembly commands
asm("lwi r3, r0, 292"); // load word immediate
asm("addik r3, r3, 1"); // immediate add w/ keep carry
asm("swi r3, r0, 292"); // store word immediate
Other examples include:
int a,b,c = 0;
asm ("add %0,%1,%2": "=r" (a): "r" (b), "r" (c)) ;
This example passes the variable values "b" and "c" to the "add" instruction and returns the result into "a."