Sunday, April 29, 2012

x86-64

Intel create IA64 RISC and AMD create AMD64.  AMD64 is backward compatible and allows running of 32-bit programs.  Intel subsequently create its own compatible version called EM64T/IA-32e.  The difference between the two is minimal.

AMD64 has 2 modes.  Legacy mode makes the CPU behaves like a 32-bit CPU and all 64-bit enhancements are turned off.  Long Mode is the native 64-bit mode.  32-bit programs can still run in compatible mode which can easily and quickly switch to 64-bit mode.  MAC OS X uses this mechanism to run a 32-bit kernel and 64-bit applications.

AMD64 enhancements include:
(1) 32-bit regiesters extended to 64-bit (e.g. EAX -> RAX)
(2) 8 new 64-bit registers called R8 to R15
(3) A nonexecute (NX) bit is by default to mark pages as nonexecutable. (NX bit was already available in some x86 processors wjere PAE was enabled.)
(4) Since a full 64-bit virtual address space requires lots of memory to store page tables, a subset is used, namely 48-bit.  The remaining 16 bit is a copy of the 47th bit in an address.
(5) Pages can be 4K, 2M or 1G in size.
(6) Segmentation has been crippled.  GDT exists but most entries are ignored.
(7) Calling convention procedure has changed.  IA32 pass paramenters on stack.  x86-64 passess majority of parameters via registers.

No comments: