mips calling conventions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a question regarding the mips32 calling conventions in gcc. I
implement in C++ and use assembly when neccessary. As far as I know the
first four arguments are passed in a0 to a3 but space on the stack still
needs to be "allocated" for those four arguments. Here is what I've got so
far:


Part I wrote in assembly:

[...]
a000b210:       40044000        mfc0    a0,c0_badvaddr
a000b214:       0c002a3a        jal     a000a8e8 <foo>
a000b218:       03a02821        move    a1,sp
[...]

Code in .cpp file ( Function: extern "C" void foo( unsigned p0, unsigned p1
) )

a000a8e8 <foo>:
a000a8e8:       27bdff98        addiu   sp,sp,-104
a000a8ec:       afbf0064        sw      ra,100(sp)
a000a8f0:       afb00060        sw      s0,96(sp)
a000a8f4:       afa40068        sw      a0,104(sp) [ ??? ]
a000a8f8:       afa5006c        sw      a1,108(sp) [ ??? ]
a000a8fc:       3c02a002        lui     v0,0xa002

...So the assembly part calles foo() and passes two arguments. Do I have to
manually decrease the stack pointer by 4*4 bytes now and increment it again 
when I return ?? It's just - the code produced by gcc seems to smash the
stack... On the other hand it seems really weird to me if I had to write
somthing like

[...]
mfc0    a0,c0_badvaddr
subi    sp, sp, 16
jal     a000a8e8 <foo>
move    a1,sp
addi    sp, sp, 32
[...]

every time a call a C routine in assembly.

Would be smashing if anybody could help me out.

Thomas

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux