MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shift operation in Assembler

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Preety
Beginner


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Mon Apr 30, 2007 3:08 pm    Post subject: Shift operation in Assembler Reply with quote

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
View user's profile Send private message
Bill Dennis
Advanced


Joined: 03 Dec 2002
Posts: 579
Topics: 1
Location: Iowa, USA

PostPosted: Mon Apr 30, 2007 3:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Tue May 01, 2007 6:08 am    Post subject: Re: Shift operation in Assembler Reply with quote

Preety wrote:
Circular shift(both right circular shift and Left circular shift ) in Assembly Language
What is a "circular shift"?
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue May 01, 2007 7:10 am    Post subject: Reply with quote

CICS Guy - use Google
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Tue May 01, 2007 8:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue May 01, 2007 9:20 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue May 01, 2007 9:42 am    Post subject: Reply with quote

CICS Guy,

may be this will help

http://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Tue May 01, 2007 10:00 am    Post subject: Reply with quote

I understood that was meant just by the "circular shift" title, I was just wondering about Preety's usage in assembler........
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue May 01, 2007 10:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Preety
Beginner


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Wed May 02, 2007 2:57 am    Post subject: Reply with quote

DaveyC,

Could you please explain the usefulness of shift operations in detail.

Thanks,
Preety
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Wed May 02, 2007 6:32 am    Post subject: Reply with quote

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
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Wed May 02, 2007 7:28 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group