ASM within C code in a PPC405 of VIRTEX II Pro

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello,

I would like to know how to put ASM instructions in a C code.

With a G5 you can do that kind of functions:

asm long MyFunct(int a, int b, *pt)
{
fralloc

mr         r6, a //r6 has a
mr         r7,b //r7 has b
stbu      r6,1(pt)

frfree
blr
}

Can I can the same thing in a PPC405 ?

Tanks !


Re: ASM within C code in a PPC405 of VIRTEX II Pro
You can use inline assembly with the tools provided by Xilinx since they
are basically GCC.  You have to use the GCC inline assembly format because
inline assembly is compiler, not processor specific.  Although, the assembly
commands are processor specific.  IBM DeveloperWorks has two good articles
on assembly programming for the PowerPC family of processors.  You can find
the instruction set reference doc on both the Xilinx and IBM sites.


---Matthew Hicks


Quoted text here. Click to load it



Re: ASM within C code in a PPC405 of VIRTEX II Pro
Ok !
If i want to call an ASM function with a C code, for example:
in main.c:

int a11%;
int b12%;
int result;

result = add(a,b);

in add.asm:

*add(int a, int b)
*       r1      r2
add: addi r1,r2
mr r0,r1
blr

It works ?
Tk !!!



Re: ASM within C code in a PPC405 of VIRTEX II Pro
When i try that, I have that kind of error messages:

Error: unsupported relocation against

buh ?


Re: ASM within C code in a PPC405 of VIRTEX II Pro
Quoted text here. Click to load it

Where is the documentation that shows the details of the calling
sequence between C and assy functions - I have never been able to find
that. Stuff like how arguments are put into registers/stack, what
registers must be preserved, etc.?

thanks,
-Jeff

Re: ASM within C code in a PPC405 of VIRTEX II Pro
Quoted text here. Click to load it

I think this might be what you're looking for:

http://the.wall.riscom.net/books/proc/ppc/cwg/a_abi.html#46046

(note it's generic PowerPC; it may reference stuff the embedded 405
doesn't support).

    ken

Re: ASM within C code in a PPC405 of VIRTEX II Pro
This is a generic standard called the Application Binary Interface (ABI)
that gcc holds to.  You can read about this or find more links to other ABI
references at IBM DeveloperWorks.


---Matthew Hicks


Quoted text here. Click to load it



Re: ASM within C code in a PPC405 of VIRTEX II Pro
Thanks very much

I have another question:

I build my main in C code and I want to call a function in ASM.

In my C code, I put this: extern int Add(int a, int b);
In my ASM: Add: #code

But when I compile, I have that error message: undefined reference to
`Add'

To my mind, I miss something in the prologue of my assembly code.

That's right ?


Site Timeline