Thursday, July 30, 2009

What does 64 bit technology mean as a computer programmer?

I know in the past, computer hard ware was unable to deal with numbers bigger than 2^32, so if you are writing a program in a language such as C++ in 64 bit architecture does this mean it is now legal to do things like





int x = 6000000000; ?? I know in 32 bit architecture doing something like that would bomb your program. If you were using 64 bit architecture would it be legal to assign variables to any number %26lt;= 2^64??? If so and you wrote a program to do something like that and it compiled on a 64 bit computer what would happen if you tried to run it on a 32 bit computer?? Would the compiler handle such situations? Or would you have to write two separate versions?? Are there compilers designed to specifically deal with 64 bit architecture, and ones to deal with 32 bit??





As a programmer what do you have to consider if you are writing a program for a 64 bit machine as compared to a 32 bit???? Thanks.

What does 64 bit technology mean as a computer programmer?
You can get (some are free) assemblers and compilers which support 64 bit. A 64 bit CPU has registers which can hold a 64 bit (8 byte) number. The Instruction Pointer register (the register which points to a code address) can be 64 bit or higher. In the old 8 bit 6502 CPU, the registers were 8 bit, but the Program Counter (Instruction Pointer) register was 16 bits in size. That means that the CPU can directly access addresses from 0-65535. Current 64 bit CPUs have 64 bit addressing, although you would never need to address memory that high. Current 32 bit programs allow for up to 4 gigabytes for code, 4 gigabytes for data, and a 4 gigabyte stack. Obviously, that is more than enough.





A 64 bit program would not run on a 32 bit computer because the 64 bit mode on the AMD/Intel CPUs use different registers and machine code.





I really cannot see any real justification for 64 bit programs these days. 32 bit programs are bad enough. Just about every Windows program that I come across features bloated, slow code. People don't even properly debug or bother to optimize their code anymore. (The problem isn't confined to Windows programs either.) Most device drivers and code libraries suffer from the same problem. Sheesh, just finding someone who knows Assembly language is a special event in itself these days.


Imagine how things would be with 64 bit programs. The programs would take more file space and more memory. Sure, 64 bit memory copying and number handling would be nice, but you need to add more memory to handle the larger programs.


Since programs are larger, that means longer accesses with the page file. (Accessing the page file slows down your computer.)





Let's put it this way: If you were going to upgrade your computer, would you rather run 32 bit programs faster, or use 64 bit programs and run at the same speed (if not slower) than what you had before.





I challange any low level programmer to truly justify 64 bit operating systems and programs for home users today. If they don't agree with me, then they obviously haven't inspected 32 bit programs %26amp; drivers and sneered in disgust at the bloated, slow code. 64 bit programs aren't the key to faster computing - it's all up to the programmers.
Reply:It depends on what you mean when you say 'programmer'. if you are a programmer that writes computer programs in assembly language, then it means alot. if you are a higher-level programmer (java,c++,c), it probably wont change how you write your programs.
Reply:It's going to have little effect on your code. About the only thing it does to existing code is change the optimal alignment. Well-written code won't care about this, poorly-written stuff will sometimes blow up about it.





What 64-bit gives you is a few new things.





The ability to use bigger integers as native types is nice for doing math on larger numbers.





The real reason, though, is to increase the maximum address space. XP normally gives any one program only 2gb available. 3gb can be had with some compromises, but that's it. The machine itself will also max out around 3gb.





A 64-bit chip means these limits are gone. There are plenty of boards out there that can support 8gb of RAM--utterly useless if you don't have a 64-bit chip and a 64-bit OS.

surveys

No comments:

Post a Comment