Hi,
smeezekitty wrote:Why dont you compile it for i386 32 bit and then it will work on both.
there is little advantage of using 64 bit unless your OS takes more ram then the average computer user has!
Regardless of how much RAM the computer has, a 32-bit OS can use PAE to access all of it.
Note: PAE used to be limited to 36-bit physical addressing, but on 64-bit CPUs PAE has been extended to works with "however many physical address bits the CPU supports" (the same limit as long mode).
Despite this, there's a few massive advantages for 64-bit OSs. The first advantage is the linear/virtual address space size (e.g. 262144 GiB per address space rather than 4 GiB per address space), which allows a single process to use a lot more than 4 GiB of "RAM + swap + memory mapped files + whatever".
The second major advantage is that you end up with twice as many registers. This means that you (or your compiler) can keep frequently used variables in registers instead of "spilling" them into local variables on the stack; and you (or your compiler) can unroll some types of loops much more efficiently.
For example, imagine code that blits an 8 * 8 "256 colour" texture (e.g. font data) into display memory. With 64-bit registers you can load all the source data into general registers then write all of the data (and end up with no instruction dependencies, etc). With 32-bit registers you end up doing 2 rows at a time (much less instruction parallelism). It's even more important if you need to do something with the data.
Of course the general registers are also twice as wide, which can be a huge improvement in specific cases too. For an example, here's some code to multiply 64-bit unsigned integers:
Code: Select all
;ebx:eax = first integer
;esi:ecx = second integer
;ebp:edi = result
push eax
mul ecx
mov ebp,edx
mov edi,eax
pop eax
mul esi
test edx,edx
jne .overflow
add ebp,eax
jc .overflow
mov eax,ebx
mul ecx
test edx,edx
jne .overflow
add ebp,eax
jc .overflow
clc
ret
.overflow:
stc
ret
Notice that I ran out of registers and had to store EAX on the stack, and that there's 3 multiplication instructions, 2 additions, etc. For 64-bit code, the multiplication above is a single instruction (e.g. "mul rbx"), and would probably be about 3 or 4 times faster.
Unfortunately there's a lot of wrong information about "64-bit 80x86". Other common myths include "64-bit code is larger and this makes code perform worse" (wrong: 64-bit code is almost always the same size or smaller than the
equivalent 32-bit code), and "64-bit OSs can't run 32-bit or 16-bit code" (wrong: they can).
As far as I can tell, there has only ever been 4 real disadvantages for 64-bit (on 80x86):
- some CPUs don't support 64-bit (but that's becoming less of a problem)
- some compilers and tools don't support 64-bit (but this problem mostly stopped existing years ago)
- Microsoft suck, and there can be compatibility problems and device driver problems for 64-bit versions of Windows (but that's becoming much less of a problem, and doesn't effect any alternative OS anyway)
- it doesn't support virtual8086 mode (but that's only really useful for running crappy legacy BIOS functions that are better avoided anyway).
Cheers,
Brendan