Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: question on ARM instruction

2004-12-14 by Kerem Or

Logical shift always shifts "0" in from left to right. Arithmetic 
shift shifts the sign bit of the register from left to right. That 
means when the register is initially a negative value, every shift 
whifts in "1"s and if it is a positive value then "0"s will be 
shifted in.

Example:

A byte initially contains 11001010 (0xca)

After one ASR this byte will look like 11100101 (0xe5) as 0xca is a 
negative value (sign bit - b7 is set)

But after one LSR this byte becomes 01100101 (0x65).

So the LSR shifts zeros in regardless of the sign bit.

Hope this clarifies everything...

Kerem



--- In lpc2000@yahoogroups.com, ©@°Ø¦â¤p¿ß <sevenstar_uk@h...> wrote:
> 
> whats the difference in between ASR(arithematic shift right) and 
LSR
> (logical shift right) as they are basically doing the same thing? 
> can someone tell me when to use ASR and when to use LSR? thank u!

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.