linux-mips
[Top] [All Lists]

Re: [PATCH -v1] MIPS: a few of fixups and cleanups for the compressed ke

To: Chih-hung Lu <winfred.lu@gmail.com>
Subject: Re: [PATCH -v1] MIPS: a few of fixups and cleanups for the compressed kernel support
From: Ralf Baechle <ralf@linux-mips.org>
Date: Sun, 1 Nov 2009 08:43:17 +0100
Cc: Wu Zhangjin <wuzhangjin@gmail.com>, Linux-MIPS <linux-mips@linux-mips.org>
In-reply-to: <a2dc26810910291916x1556eb21uecaa8bdeeb98baae@mail.gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1256797212-7794-1-git-send-email-wuzhangjin@gmail.com> <a2dc26810910291916x1556eb21uecaa8bdeeb98baae@mail.gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.19 (2009-01-05)
On Fri, Oct 30, 2009 at 10:16:14AM +0800, Chih-hung Lu wrote:

> May I ask a question,
> what is the difference between "addu a0, 4" and "addiu a0, a0, 4"?

That's because you are human - you're smart enough to notice the difference
without even thinking about it :)

The machine instructions addu and addiu differ.  Addiu takes an immediate
constant as it's last op.  Addu takes a register instead.  Now the assembler
is trying to make things a little easier to us.  Depending on the type of
the last argument it will assemble an "addu" assembler instruction either
into an addiu or addu.

The other difference between the two instructions used in your example is
that the first has two operands, the other three operands.  If there is
only two operands, the assembler will implicitly assume, that the 2nd
register is the same as the first register.

Or in other words, the code generated from both will be entirely identical.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [PATCH -v1] MIPS: a few of fixups and cleanups for the compressed kernel support, Ralf Baechle <=