[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: %hi vs %lm for 64-bit constants
On Mon, 17 Aug 2009, raymond.meyer%rambler.ru@localhost wrote:
> Hi, I'm confused about sparc assembly language %hi and %lm operators
> when used on sparcv9. Both of the operators extract 22 bits, which are
> bits 10 to 31.
> %hi(addr) which does (addr) >> 10
> %lm(addr) which does ((addr) >> 10) & 0x3fffff
> Assuming that 'addr' is a 64-bit memory address, from which I need to
> extract bits 10 to 31, then it looks like %hi and %lm are duplicates of
> each other.
> I think %hi treats addr as a 32-bit constant and extracts bits 10 to 31
> by shifting right 10 places.
> And %lm treats addr as a 64-bit constant and extracts bits 10 to 31 by
> shifting right 10 places and masking least significant 22 bits.
> Why have both then?
%lm zeros out bits beyond 31 before the left shift. %hi does not. You
can get strange effects if you use any bits above 22 from a negative
Main Index |
Thread Index |