linux-mips
[Top] [All Lists]

Re: Delayed jumps and branches

To: Gareth <g.c.bransby-99@student.lboro.ac.uk>
Subject: Re: Delayed jumps and branches
From: justinca@cs.cmu.edu
Date: 17 Sep 2002 14:26:18 -0400
Cc: linux-mips@linux-mips.org
In-reply-to: <20020917161959.33787757.g.c.bransby-99@student.lboro.ac.uk>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20020917161959.33787757.g.c.bransby-99@student.lboro.ac.uk>
Sender: linux-mips-bounce@linux-mips.org
Source-info: Sender is really justinca+@gs256.sp.cs.cmu.edu
On Tue, 2002-09-17 at 11:19, Gareth wrote:
> Hi,
>     jal <my_function>
>     li  $s2, 3
>     li  $v0, 2
> 
> If the jump is not taken, it requires 3 cycles to execute these 3 
> instructions.
> If the jump is taken, it requires 3 cycles to execute the first instruction of
> my_function, and li $s2, 3 is executed.
> 
> Is my reasoning correct?
> 

Aside from the corrections Thiemo sent, you should probably also
disabuse yourself of the notion that one instruction == one cycle. 

For most processors, there's no simple answer to the question "how many
cycles will this code segment take to run".   Even in the embedded
world, most newer processors are superscalar.  In addition, if you want
to be precise, you have to take into account cache behaviour, branch
prediction, issue restrictions, etc.

-Justin

Attachment: signature.asc
Description: This is a digitally signed message part

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