This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: HI and LO qualifiers in MIPS assembly


On Fri, Mar 10, 2006 at 06:07:37PM +0200, Nikolaos Kavvadias wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>  
> Hi there
> 
> i have a question on some alternative syntaxes of the MIPS
> instructions regarding the %hi and
> %lo qualifiers. The %hi is necessary when specifying addition of a
> carry from the lower part
> highest bit.
> 
> Sometimes gas emits what i believe is a macro-instruction, e.g. this
> one is for the LUI:

I assume you mean "gcc emits ..."

> lui   $reg, %hi(symbol)
> e.g.
> lui $10,%hi(sym)
> 
> another one is:
> lw $2, %lo(v)($10)

Those aren't macros (or, pedantically speaking, macros which just
expand to single instructions with the same mnemnonic). The %hi
and %lo tell gas/ld to encode the appropriate part of the symbol
value in the associated relocation.

> How can I expand these expressions into "normal" instructions, as
> these are defined in the MIPS32 architecture manual for programmers
> (vol. 2)?

lui and lw are MIPS32 instructions. There is also a lw macro in gas
which may expand into multiple instruction for e.g.

lw $1, sym($4)

With a percent op, you get a direct mapping to a relocation.


Thiemo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]