From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32506 invoked by alias); 10 Aug 2005 19:26:44 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 32436 invoked by uid 22791); 10 Aug 2005 19:26:38 -0000 Received: from amdext3.amd.com (HELO amdext3.amd.com) (139.95.251.6) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 10 Aug 2005 19:26:38 +0000 Received: from SSVLGW02.amd.com (ssvlgw02.amd.com [139.95.250.170]) by amdext3.amd.com (8.12.11/8.12.11/AMD) with ESMTP id j7AJQVEZ000655 for ; Wed, 10 Aug 2005 12:26:36 -0700 Received: from 139.95.250.1 by SSVLGW02.amd.com with ESMTP (AMD SMTP Relay (Email Firewall v6.1.0)); Wed, 10 Aug 2005 12:26:26 -0700 X-Server-Uuid: 519AC16A-9632-469E-B354-112C592D09E8 Received: from SSVLEXBH2.amd.com (SSVLEXBH2.amd.com [139.95.53.183]) by amdint.amd.com (8.12.8/8.12.8/AMD) with ESMTP id j7AJQQVq017193; Wed, 10 Aug 2005 12:26:26 -0700 (PDT) Received: from sausexmb2.amd.com ([163.181.3.157]) by SSVLEXBH2.amd.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 10 Aug 2005 12:26:23 -0700 Received: from SBOSEXMB1.amd.com ([165.204.61.40]) by sausexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 10 Aug 2005 14:26:22 -0500 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: mips calling conventions Date: Wed, 10 Aug 2005 19:26:00 -0000 Message-ID: <6096959DEF5C9447A6BF80BDC7EB9EDC682B7D@SBOSEXMB1.amd.com> From: "Meissner, Michael" To: "Mad Props" , gcc-help@gcc.gnu.org X-WSS-ID: 6EE48B681CO13597976-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2005-08/txt/msg00101.txt.bz2 There are many different MIPS calling sequences, and I've lost track of all= of the different variations. Any way in the original MIPS calling sequence, you did have to provide a ho= ming area of the top 4 words on the stack, where the compiler could store t= he arguments passed in registers. This was particularly used by variable a= rgument functions, which would store the arguments, and then va_arg would b= e a simple char *. You could optimize things by allocating this area once = in your own stack allocation, or you could allocate it just before the call= , and remove it after the call.=20 -----Original Message----- From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On Beh= alf Of Mad Props Sent: Wednesday, August 10, 2005 9:55 AM To: gcc-help@gcc.gnu.org Subject: mips calling conventions Hi, I have a question regarding the mips32 calling conventions in gcc. I implem= ent in C++ and use assembly when neccessary. As far as I know the first fou= r 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 a000b218: 03a02821 move a1,sp [...] Code in .cpp file ( Function: extern "C" void foo( unsigned p0, unsigned p1 ) ) a000a8e8 : 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 agai= n 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 so= mthing like [...] mfc0 a0,c0_badvaddr subi sp, sp, 16 jal a000a8e8 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=FCr Mail, Message, More +++