Ubuntu Forums Archive Viewer

How to programing in 64bit.

Archived thread 1003289 from Programming Talk. Markdown source: Programming_Talk/thread_1003289_How_to_programing_in_64bit..md

Original URL About this archive
#1

I've been getting back into programming. When I started, there weren't any 64bit processors.

From what I read, if you have source code for 32bit, and compile it into a 64bit application. It makes some use of the 64bit benefits, but is still essentially a 32bit program running in an 64bit environment.

Now all the books I have on programing basically say, here's how the language works, and then let the compile do the magic. From what I understand, there's more to 64bit than compiler magic.

So Does anyone know any books, links or tutorials? Everything, I read is just generalizations that don't help.

-Thanks

#2

Assuming a high level language, there should be no trouble. One of the differences, however, I think will be in the sizes of some of the integer types.

#3

Unless you are planning on writing hand optimized assembly, just let the compiler worry about it and write code like you always have.

#4

same, except that pointer size isn't 4bytes.

#5

Like stated above, it's mainly for lower level languages like ASM and SPARC. It will be language dependent though, what language are ou programming in?

#6

Arukas said: From what I read, if you have source code for 32bit, and compile it into a 64bit application. It makes some use of the 64bit benefits, but is still essentially a 32bit program running in an 64bit environment.

If you compile it with a 64-bit compiler, then the result will be a 64-bit native program. The compiler will optimize it for 64-bit automatically to a great extent (for example, it will automatically use the more and larger processor registers, and use the x86_64 calling convention, which is to pass parameters in registers instead of on the stack).

There's really not that much that you have to do yourself if you're programming in a higher level programming language. There are some things that you have to take into account, for example that pointers are not 32-bit anymore (as already said above).

#7

I figured writing in ASM would be different. I've also read that pointers will not be the same size. However, I have read nothing that suggest that the data types will be different.

Pointers being a difference size makes since. But the other variable data types being different sizes sounds like something you should know if you playing in 64bit land.

#8

In gcc, pointers and longs become 64 bits. ints remain 32 bits. This is a problem mainly for programs that erroneously expect ints and longs to be interchangeable.

#9

wmcbrine said: In gcc, pointers and longs become 64 bits. ints remain 32 bits. This is a problem mainly for programs that erroneously expect ints and longs to be interchangeable.

Yup. One should never assume any exact size for short int, int, or long int. stdint.h has exact-width integers for that.