LinuxQuestions.org
Help answer threads with 0 replies.
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-28-2010, 01:08 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Rep: Reputation: 52
asm 64bit registers


I have tried to learn how 64bit asm (nasm in my case) works and found, among the many disparate pieces of info on the net, a few vague inferences that floating point registers can be used for other purposes than what they are intended for, example:
"64-bit Linux allows up to fourteen parameters to be transferred in registers (6 integer and 8 floating point)."
This would be fantastic for string operations/manipulation (I have never used asm for floating-point operations), can anyone shed a bit of light?
Thank you for your help.
 
Old 03-28-2010, 02:59 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by rblampain View Post
I have tried to learn how 64bit asm (nasm in my case) works and found, among the many disparate pieces of info on the net, a few vague inferences that floating point registers can be used for other purposes than what they are intended for, example:
"64-bit Linux allows up to fourteen parameters to be transferred in registers (6 integer and 8 floating point)."
This would be fantastic for string operations/manipulation (I have never used asm for floating-point operations), can anyone shed a bit of light?
Thank you for your help.

What is the exact question ?
 
Old 03-28-2010, 08:46 AM   #3
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Can those floating-point registers be used for string manipulation?
 
Old 03-28-2010, 05:13 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by rblampain View Post
Can those floating-point registers be used for string manipulation?
What exactly is string manipulations ? I.e. I (think I) know how to manipulate strings, but I do not know what you (think you) know.
 
Old 03-29-2010, 02:00 AM   #5
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
I thought string manipulation was clear but it seems it is not.
For example can 2 strings (alphanumeric text) be placed in 2 floating-point registers (128/256bit?) for comparison? Is it faster (as implied in the info I found) than doing it in 64bit registers?

A simple asm code would look like this in 64bit asm:
first_string db "number of bytes of alphanumeric text here"
second_string db "number of bytes of alphanumeric text here"
mov resi,first_string
mov redi,second_string
cmp resi,redi

Last edited by rblampain; 03-29-2010 at 02:10 AM.
 
Old 03-29-2010, 02:41 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by rblampain View Post
I thought string manipulation was clear but it seems it is not.
For example can 2 strings (alphanumeric text) be placed in 2 floating-point registers (128/256bit?) for comparison? Is it faster (as implied in the info I found) than doing it in 64bit registers?

A simple asm code would look like this in 64bit asm:
first_string db "number of bytes of alphanumeric text here"
second_string db "number of bytes of alphanumeric text here"
mov resi,first_string
mov redi,second_string
cmp resi,redi

So, you think it's clear ?

For example, in the "C" world strings are null terminated and as such their length can be whatever.

OTOH, FP registers (AFAIK) can be loaded from memory only as a whole.

So, for strings whose length is not a multiple of 8, FP registers can possibly be used for the initial part of the strings whose length is a multiple of 8, and the rest should be dealt with by other means.

Now, the world "possibly". You have to verify that any data can be loaded into them not causing an FP exception. In the FP numbers world both NaNs and Infs exist. Probably loading not causing an exception can be done.

Likewise, you have to verify that any data can be compared for equality, including the above mentioned NaNs and Infs.

Among string operations there is also kind of '>' and '<' (see 'man 3 strcmp'). This operation can not be performed using FP registers for comparison - unless there is a possibility to access data in them as separate bytes. So, another thing for you to verify.

The last but not least - do you need registers for comparison at all ? Maybe there is an instruction which compares, say, 'long long int' (8 bytes) with another 'long long int' - both of them being in memory. Obviously, if such an instruction exists, the comparison occurs inside the CPU, but using implicit registers. If so, why do you need registers for comparison at all - loading data into them is extra instructions, so fetching the instruction even from cache may take more time than the comparison under consideration.

Last edited by Sergei Steshenko; 03-29-2010 at 02:38 PM.
 
1 members found this post helpful.
Old 03-29-2010, 06:30 AM   #7
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Very good point, thank you very much.
 
Old 03-29-2010, 02:39 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by rblampain View Post
Very good point, thank you very much.
And I forgot to mention alignment - AFAIR, SIMD registers allow only aligned transfers, don't know about the "classical" FP ones.
 
1 members found this post helpful.
Old 03-29-2010, 10:54 PM   #9
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
So, the conclusion is those registers are not suitable for general purposes.
 
  


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
64bit RPM installation is failing on SLES-10/11 but working fine on RHEL4/5 64bit os raghuhb Linux - Software 2 11-06-2009 07:31 AM
How do I resolve install DB2v9.5 64bit/RHEL 5 64bit (libstdc++.so.5 is not found)? okonita Linux - Newbie 2 11-13-2008 02:15 AM
ASM x32 vs ASM x64 Tegramon Programming 3 02-27-2008 02:26 PM
Can't install amarok 64bit du eto missing provider of libpq.so.4()(64bit) Ossah Linux - Software 1 04-21-2007 09:23 PM
64bit Eval Issues...switched to 64bit OSS and WOW RedShirt SUSE / openSUSE 6 01-23-2006 09:07 PM

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

All times are GMT -5. The time now is 11:43 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