linux-mips
[Top] [All Lists]

Re: function call on MIPS (newbie question)

To: Harald Krapfenbauer <krapfenbauer@ict.tuwien.ac.at>
Subject: Re: function call on MIPS (newbie question)
From: David VomLehn <dvomlehn@cisco.com>
Date: Tue, 24 Jun 2008 10:45:07 -0700
Authentication-results: rtp-dkim-1; header.From=dvomlehn@cisco.com; dkim=pass ( sig from cisco.com/rtpdkim1001 verified; );
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; l=2061; t=1214329521; x=1215193521; c=relaxed/simple; s=rtpdkim1001; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=dvomlehn@cisco.com; z=From:=20David=20VomLehn=20<dvomlehn@cisco.com> |Subject:=20Re=3A=20function=20call=20on=20MIPS=20(newbie=2 0question) |Sender:=20 |To:=20Harald=20Krapfenbauer=20<krapfenbauer@ict.tuwien.ac. at>; bh=qSISNRgjPFqKC3pDpDMS4LjADo/VtG9cDEvaK6q6OUU=; b=peqNlZkBVcTiUtA9lA1Jf+z6pAvsS4jweYL+w7pRCywI5ioSuCe1JlupWp K2rKbpDE4jcmeRbyAabXSJC2UtU0PJz2j1jf/JP4XdmsymMopvznw/5agoMi EX1zFY3ANw;
In-reply-to: <4860C9FD.60103@ict.tuwien.ac.at>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <4860C9FD.60103@ict.tuwien.ac.at>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)
Harald Krapfenbauer wrote:
Hi!

I'm a newbie to the MIPS architecture and I want to port some program to
MIPS.
I must call a function within the .text segment with 2 simple
parameters. So I figured out the following code
...

The code is written to the stack, the SP and the PC are then set to the
beginning of the code on the stack.

Unlike x86 architectures, the MIPS architecture generally does not have hardware to synchronize data and instructions caches. When writing code for execution on the MIPS processor, you need to be sure that you flush the data cache and invalidate the instruction cache before trying to execute the code. On most MIPS processors, you can use the SYNCI instruction to do this. Take a look at the documentation for this instruction in "MIPS32® Architecture for Programmers Volume II: The MIPS32® Instruction Set". It has sample code on how to properly do this in an unprivileged application. You can get to this manual, as well as other MIPS manuals, at:

     http://www.mips.com/products/product-materials/processor/mips-architecture/

You will need to register for a free account to download this.

You can also use the cacheflush system call to synchronize the data and instruction caches.
--
David VomLehn, dvomlehn@cisco.com
The opinions expressed herein are likely mine, but might not be my employer's...




- - - - - Cisco - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.


<Prev in Thread] Current Thread [Next in Thread>