LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2005, 09:25 AM   #1
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
Assembly language: Purpose of shift register?


Could someone explain what the purpose of this is? It's for SPARC processor assembly language.
 
Old 03-17-2005, 10:56 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Do you mean some insttruction to shift all bits of byte to left or right?
Like "a << 4" in C?

This can be handy for:
  • Serialization of bits.
  • Binary representation, like printing the zeroes and ones.
  • Multiplication: shifting bits one position to the left is a very fast way to multiply by 2.
    Likewise, shifting to the right is dividing by 2, 4, 8, 16, 32... (resp 1,2,3,4,5,... positions).
 
Old 03-17-2005, 10:59 AM   #3
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Original Poster
Rep: Reputation: 45
No, not the shift instruction but the shift register, although it might be used for shifting bits.. hmm.

Thanks
 
Old 03-21-2005, 05:06 PM   #4
gaffel
LQ Newbie
 
Registered: Mar 2004
Distribution: debian sarge, 2.6.6, and ALSA finally works!!
Posts: 18

Rep: Reputation: 0
?
I think this is a bit like asking what is the purpose of the AND function.
A shift register is an easily implemented hardware block in electronics and has multiple uses when used with supplementary hardware (e.g. shift registers are often used in pseudo-random number generators to generate long sequences.)
When looking at the shift register from a higher level language viewpoint it may seem a bit pointless, but at a low level it allows you to move bits around very effectively, and in assembler that is literally what you are doing, manipulating bits directly
This looked to be a useful site on assembly language
http://www.osdata.com/topic/language...o.htm#websites
Look-up the section on 'Shift and rotate'. It gives examples of different variations of shift register instructions that generate different end results, for manipulating bits using a shift register.
I don't know a lot about assembly, but if all these instructions are available that use shift registers in different ways, I am sure that they weren't created just for fun!
Perhaps you would have better insight if you tried to create a simple programme for a less complicated processor (such as a microcontroller.) You may find that as you try to reliase the programme that the shift register becomes very useful!!
Good luck!
 
Old 03-21-2005, 08:24 PM   #5
rjcrews
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 193

Rep: Reputation: 30
as the above poster stated, these are for low level programming.

They make math functions extremely fast and simple. (adders and such contain these)

like hko stated, it is almost imposslbe to do low level multiplying and dividing without these while being efficient.

If you are writing math functions in assembly you will use these.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert Assembly langugae to Executable in c language ssg14j Programming 15 11-04-2008 07:49 AM
How to do type casting in Sparc Assembly Language foxele Programming 1 10-09-2004 04:40 PM
Assembly Language on 64 Bit systems Sleevy Programming 1 09-06-2004 01:58 AM
Assembly Language, and networks grizzly Programming 5 12-11-2003 09:50 PM
SPARC assembly language jclark00001 Programming 3 02-26-2003 08:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration