tags:

views:

417

answers:

8

I need to mess around with the stacks on these architecture and am really a n00b here. Any pointers to reading topics/google searches that i can do. I am looking for how these architectures are fundamentally different from each other. something more than the wikipedia article on this topic http://en.wikipedia.org/wiki/X64

A: 

All the registers in CPU of x86 are 32-bit where as for 64-Bit its 64-Bit :)

If you using pointer arithematic then sizeof() will yeild different results and so would an incrment operation.

I feel you can get detailed information on intel site about the two architecutures and also even the instruction set highlighting new instructions add with 64-Bit processors.

Kavitesh Singh
Actually, in x86 you have 32-bit, 16-bit and 8-bit general purpose registers. Besides that, you have 8 64-bit MMX registers and 8 128-bit SSE registers. In x64 you have all that plus: all 32-bit registers can be extended to 64 bits, you have 8 more GPRs and 8 more SSE registers.
Nathan Fellman
+1  A: 

For starters the size of a pointer is 8 bytes instead of 4.

Registers can hold 64-bit values as well.

Also there are often many differences at the OS level. For example on Windows you have things like filesystem redirection and registry redirection (WOW64) when running 32-bit apps on a 64-bit Windows OS.

Brian R. Bondy
Basically the word size is 8 bytes instead of 4 bytes. This alone results in many differences. x64 assembly is somewhat different than x86 assembly (different register names, etc.)
Charles Salvia
There are also more GPRs.
Joey
+3  A: 

I believe the Wikipedia article you linked to provides a reasonable amount of introductory information. If you are interested in the specific details of differences in Long Mode, you can consult one of the official references: Intel® 64 and IA-32 Architectures Software Developer's Manuals.

Mehrdad Afshari
+8  A: 

In x86 there are 8 32 bit registers, in x64 the registers are 64 bits each and there are 8 more of them. The 128 bit SSE registers are 128 bits in both, but on x86 there are 8 of them while in x64 there are 16 of them. Also some instructions were cut in x64.

In x64 mode you can still use the registers as 32 bits by using their 32 bit name(starting with an 'e') instead of their 64 bit name(starting with an 'r'), and the assembly would be mostly the same.

http://en.wikipedia.org/wiki/X86#x86%5Fregisters

Or if you want some really heavy reading(like 1000s of pages...)

http://www.intel.com/products/processor/manuals/index.htm I read through a few hundred pages of those manuals and learned a lot, really good stuff.

Ramónster
A: 

In addition to the fact that the general purpose registers are now 64-bits instead of 32, there are also new registers: r8, r9, r10, r11, r12, r13, r14, and r15. The fact that there are more registers also leads to the fact that most compilers use pass-by-register calling conventions for function calls (except those with varargs), whereas in x86 most compilers push all arguments to the stack.

The x87 FPU is also deprecated, preferring SSE.

asveikau
The x87 FPU is just as available in x86-64 as in x86. You can use it the same as you used to able to.
Nathan Fellman
It's available, sure, but marked as deprecated. From AMD: "Despite its long service in x86 architecture, x87 arithmetic is deprecated in 64-bit mode." http://developer.amd.com/documentation/articles/pages/62720069.aspx
asveikau
hmm... Then I must be misunderstanding what deprecated means :-). What *does* it mean?
Nathan Fellman
It probably means that AMD will not make much effort in optimizing them (so they might get very slow), and is probably going to drop it from hardware and emulate it only in software. That's my guess.
liori
A: 

While I don't think this is specifically an x86 vs. x64 answer it may be relevant.

On Linux, under x86 the stack is either 4k or 8k, while under x64 it's 16k.

Robert S. Barnes
+2  A: 

Um, stack? Do you mean the physical(E/RSP stack)? If so then my answer is relevant:

On x86, almost every C compiler uses the cdecl calling standard. I can't remember the details on it, but it was consistent among compilers and operating systems. Basically, arguments is pushed to the stack(right to left) and then the return value is put in eax and the caller is responsible for cleanup.

On x86-64 though, its all pretty screwed up. The windows calling convention is different from linux(most non-linux unix-like OSs have kept with the original C calling standard though which leads to more screwyness). I can't remember how they differ, but they do. Look up "different calling conventions x86-64" in google and you'll find the details of it.

see: http://en.wikipedia.org/wiki/X86%5Fcalling%5Fconventions#Microsoft%5Fx64%5Fcalling%5Fconvention

Earlz
+4  A: 

All the answers here mention the changes in the register set, which I'll list here for completeness:

  • All existing 32-bit general purpose registers are extended to 64 bits (EAX is extended to RAX and so on)
  • 8 new 64-bit general purpose registers (R8 through R15)
  • 8 new 128-bit SSE registers (XMM8 through XMM15)

There are also changes in addressing modes:

  • CS, DS, ES and SS are flat. That is, their base is 0x0 and their limit is 0xffffffffffffffff. FS and GS can have a base over 32 bits.
  • Descriptors in the GDT, LDT and IDT have changed. They 8 bytes in 64-bit mode
  • A non-contiguous address space. In 32-bit mode the linear address space is from 0x0 to 0xfffffff. In 64-bit mode the linear address space is split from 0x0 to 0x00007ffffffff and from 0xffff800000000000 to 0xffffffffffffffff. Basically, there are only 48 bits of address, and the address is sign-extended to 64 bits.
  • A new paging mode.

Various instructions were removed:

  • One byte INC instructions with encoding 40+rw and 40+rd. The 4x byte became the REX prefix.
  • instructions for loading the segment registers that are now flat: LDS, LDS, LSS.

There are more differences that I simply can remember off the top of my head. I'll add them if I can think of some more.

Nathan Fellman
+1: Most complete answer
greyfade