-
February 10th, 2005, 08:50 PM
#1
64 bit processors and some newb question
Ok, I'm not sure if this should go in newbies or here but I'll go ahead. Just starting to learn C and I got a couple questions.
1) I have an AMD Athlon 64 bit processor. I only have a 32 bit version of windows. From what I understand I will not be able to utilize my 64-bit architecture until windows releases x64, is this true ? (on a side note, will linux be able to utilized my 64 bit processor ?)
2) Any good references on programming with a 64 bit architecture ?
3) From my understanding, x86 processors use little endian byte ordering. Does the AMD, and will this effect writing effeciant 64 bit programs ?
One more question: On a linux command Line, how do I get a programm to accept command line parameters ? like:
#myprog param1 param2
Anyways, I will probably become a regular subscriber to this specific forum, since I am sure I will have more questions
The fool doth think he is wise, but the wiseman knows himself to be a fool - Good Ole Bill Shakespeare
-
February 10th, 2005, 10:04 PM
#2
This might answer question number two...
http://www.experts-exchange.com/Prog...ing_Platforms/ Intel_Programming/Intel_64Bit_Architecture/ - 47k - 9 Feb 2005
and here's the link to the page I found it on...
http://www.google.ca/search?client=f...=Google+Search
Google Search: programming with a 64 bit architecture
it might provide more resources.
Eg
-
February 10th, 2005, 10:15 PM
#3
For easy reference to a variety of programs...
http://directory.google.com/Top/Comp...ing/Languages/
I think this has a strong list.
-
February 10th, 2005, 10:20 PM
#4
Windows need Windows XP x64 to use the 64 bits architecture. For Linux, there is 64 bits distructions out there.
I'm not a programmer so I cannot answer the other question!
-
February 11th, 2005, 09:44 AM
#5
Hi
You need an OS supporting 64bit, if you develop code, you also need a
compiler suitable for 64bit.
64bit processors and OS
Although I mainly work on AMDs Opteron, I made good experience with
the Red Hat Enterprise Linux, which supports most 64bit architectures.
We have it installed on AMD Opteron(tm) Processor 244, AMD Athlon(tm) 64,
Intel(R) Itanium 2 and Intel(R) Xeon(TM) MP(64bit)
There is also a free version of Windows XP Professional x64 Edition[1] available.
64bit processors and compilers
gcc[2] by default creates 64bit code on AMD64-machines. You could generate 32bit
by an -m32 flag. The intel compiler icc[3] usually generates more performant
code on an intel-based machine. You might have to pay for it, but check the licensing
conditions for details.
64bit processor programming
Usually, the correct compiler already produces 64bit code - quite nicely optimised.
You do not have to think about little/big-endian ordering in general.
You can go further in optimisation, but for this you need quite an in-depth
understanding. Check the intel.com[4] and amd.com[5] - pages - an example for
optimisation[6], an example for SSE3[7].
And as per you last question about command line parameter:
Code:
...
int main(int argc, char *argv[]){
int i;
for (i=0;i<argc;i++) printf("%s\n",argv[i]);
}
...
does the job
Cheers
[1] https://microsoft.order-9.com/winxp6...winxp64&id=dl#
[2] http://gcc.gnu.org
[3] http://www.intel.com/software/products/compilers/
[4] http://www.intel.com/cd/ids/develope.../eng/index.htm
[5] https://devcenter.amd.com/
http://devforums.amd.com/index.php?act=idx
[6] http://www.amd.com/us-en/assets/cont...docs/25112.PDF
[7] http://www.intel.com/cd/ids/develope.../eng/66717.htm
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
-
February 11th, 2005, 09:26 PM
#6
whoa! Hey guys, thanks.
Extra thanks to sec. Thanks a ton man. If I had enought antipoints to assign...
The fool doth think he is wise, but the wiseman knows himself to be a fool - Good Ole Bill Shakespeare
-
February 13th, 2005, 09:42 AM
#7
Ok, I know it is bad form to post twice in a row, but I couldn't edit my previous post, so here goes...
After my code has accepted the command line parameters, how do I parse the different parameters into seperate char variables ? What I mean is this;
./myprogram param1 param2
now after I accept from argc and argv how do I assign like this;
char param1, param2
char param1()
...code this or that...
char param2()
...code this or that...
...or....
int main(int argc, char *argv[]){
int i;
for (i=0;i<argc;i++) printf("%s\n",argv[i]);
}
after this, to take the integer i and assign the different parameters into different variables
Also, A couple more questions, what are argv and argc ? Why do you assign them into different types of variables ? (char, int)
What does the line:
for (i=0;i<argc;i++) printf("%s\n",argv[i]);
do ?
what does the %s do ?
Sorry for all the questions, it is kinda hard to turn up a (helpful) google.
The fool doth think he is wise, but the wiseman knows himself to be a fool - Good Ole Bill Shakespeare
-
February 13th, 2005, 11:51 AM
#8
Hi
Maybe you should start reading some basic c tutorials. Two decent ones have been
written by white_scorpion[1]. In the beginner tutorial, you learn about printf,
in the intermediate one %s is explained.
The line
Code:
for (i=0;i<argc;i++) printf("%s\n",argv[i]);
simply prints the program arguments on the console.
I would not try to achieve too much at once. First, learn to understand
how that little program is doing what it is doing.
char *argv[] are somewhat "advanced" data types (pointers and arrays).
But if you want to convert the first parameter to an integer, try an
If you want to check the second parameter char by char, try an
Code:
for (i=0;i<strlen(argv[2]);i++)
printf("%c",argv[2][i]);
Cheers
[1] http://www.antionline.com/search.php...orumchoice=678
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
-
February 13th, 2005, 11:38 PM
#9
hey thanks
I am starting to get this, but I am having some problems (with the different syntaxes I think)
this is what I have:
Code:
#include <stdio.h>
int main(void)
{
char name[15];
printf("Please enter your name:\n");
scanf("%s",name);
if(name == "myname")
{
printf("\n%s rocks",name);
}
else
{
printf("\nHello %s how are you?",name);
}
return 0;
}
but if I enter myname it still says "hello myname how are you" not "myname rocks" I think it has something to do with the if statement. coulda anyone tell me where I am going wrong ?
The fool doth think he is wise, but the wiseman knows himself to be a fool - Good Ole Bill Shakespeare
-
February 14th, 2005, 12:43 AM
#10
Hi dmorgan
The string comparison usually does not work in this way (with exceptions, eg fortran).
I would use
Code:
#include<string.h>
(...)
if(strcmp(name,"myname")==0)
(...)
Cheers.
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|