View previous topic :: View next topic |
Author |
Message |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Mon Apr 30, 2007 3:08 pm Post subject: Shift operation in Assembler |
|
|
Hello,
As Logical left shift operation on binary numbers performs multiplication by 2 , what is the significance of performing Circular shift(both right circular shift and Left circular shift ) in Assembly Language?
Thanks.
PM |
|
Back to top |
|
 |
Bill Dennis Advanced

Joined: 03 Dec 2002 Posts: 579 Topics: 1 Location: Iowa, USA
|
Posted: Mon Apr 30, 2007 3:35 pm Post subject: |
|
|
Possibly to "round" the number to some multiple of 2 (when you shift back left zeroes are inserted)? _________________ Regards,
Bill Dennis
Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity. |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Tue May 01, 2007 6:08 am Post subject: Re: Shift operation in Assembler |
|
|
Preety wrote: | Circular shift(both right circular shift and Left circular shift ) in Assembly Language | What is a "circular shift"? |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Tue May 01, 2007 7:10 am Post subject: |
|
|
CICS Guy - use Google _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Tue May 01, 2007 8:33 am Post subject: |
|
|
Maybe I should have been a little more direct.
How does one perform a circular shift in assembly language? Is there an opcode for this?
From the way Preety put it, it sort of sounds like there is one...... |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Tue May 01, 2007 9:20 am Post subject: |
|
|
still available in Google - but whether it applies to mainframe or intel I could not tell
but there maybe another document - I've only looked at the first 3 (search on 'circular shift assembler') _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Tue May 01, 2007 10:00 am Post subject: |
|
|
I understood that was meant just by the "circular shift" title, I was just wondering about Preety's usage in assembler........ |
|
Back to top |
|
 |
DaveyC Moderator

Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Tue May 01, 2007 10:18 pm Post subject: |
|
|
CICS Guy wrote: |
How does one perform a circular shift in assembly language? Is there an opcode for this?
|
RLL (Rotate Left Single Logical)
or you can store a word with the STRV (Store Reversed).
These instructions are useful for a variety of problems. For example, changing the endianess of data received from a disparate machine. _________________ Dave Crayford |
|
Back to top |
|
 |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Wed May 02, 2007 2:57 am Post subject: |
|
|
DaveyC,
Could you please explain the usefulness of shift operations in detail.
Thanks,
Preety |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Wed May 02, 2007 6:32 am Post subject: |
|
|
DaveyC wrote: | RLL (Rotate Left Single Logical)
or you can store a word with the STRV (Store Reversed). | Neat, I just downloaded the latest PoP, over 1200 pages compared to my dog-eared 175 pager.... Boy, do I have some catching up to do..... At least I'll have some interesting bedtime reading for a while....grin..... |
|
Back to top |
|
 |
DaveyC Moderator

Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Wed May 02, 2007 7:28 am Post subject: |
|
|
Preety wrote: | DaveyC,
Could you please explain the usefulness of shift operations in detail.
Thanks,
Preety |
There are far too many uses for using shifts to list them all. Some of the most common are fast multiplication by powers of two, hashing algorithms, setting-clearing- toggling bits in bitmaps etc, etc.
Not assembler, but here is a debugging function I wrote in C to convert a flag byte to a binary string of 1s and 0s. Kudos points for anybody who can tell me how it works.
Code: |
char* c2b(
char* buffer,
unsigned char c
)
{
int i;
int numBits = CHAR_BIT;
for ( i = 0; numBits--; i++ ) {
buffer[i] = ( c & 0x80 ) ? '1' : '0';
c <<= 1;
}
buffer[i] = '\0';
return buffer;
}
|
_________________ Dave Crayford |
|
Back to top |
|
 |
|
|