On Wed, 2009-05-20 at 13:55 -0400, Michael Meissner wrote: > On Wed, May 20, 2009 at 10:03:08AM -0700, Bob Plantz wrote: > > On Wed, 2009-05-20 at 12:31 -0400, Michael Meissner wrote: > > > > > structures as well. 64 and 32-bit programs use a completely different ABI, and > > > the stack is set up differently. > > > > The main difference being that the first six arguments are passed in > > registers instead of on the stack. It's very "RISC-like." > > Also the alignment of the stack, whether or not the implementation can assume > the use of the SSE2 registers, size of long, how 64-bit values are returned, > what the stack unwind tables look like, etc. Lots of differences. Yes, I should have said "one difference being..." > > > > Finally, some 32-bit instruction encodings > > > are not available when the computer is in 64-bit mode, and others behave > > > differently when the 64-bit registers are enabled. > > > > > > > Isn't this true only at the individual instruction level? > > If the 32-bit library was compiled with encodings that conflict with the 64-bit > instructions, then instructions will do funky things if you somehow manage to > bolt a 32-bit library into a 64-bit program, because the library will be called > in 64-bit mode. I'm not aware of any 32-bit instructions that behave differently in 64-bit mode. Except, of course, instructions that manipulate the stack (push, pop, call, ret, etc.) do so in 32-bit or 64-bit increments, respectively. This is the machine code 0x55 is pushl %ebp in 32-bit mode and it is pushq %rbp in 64-bit mode. Do you have other examples? BTW, I'm not trying to be argumentative here. I've written an introductory computer architecture textbook based on x86-64 and am eager to avoid saying stupid things in my book. :-) The more I can learn, the better. > > > For example, you can do > > movb %ah, %al # 32-bit, no REX prefix byte > > movb %al, %r8b # 64-bit, requires REX prefix byte > > > > but you cannot do > > movb %ah, %r8b # mixed mode, conflict > > > > The first sequence of instructions will run on my machine under 64-bit > > Ubuntu. > > > > An aside: The gnu assembler, gas, gives an error message about the REX > > prefix being required for the second case. It took me a while to figure > > it out. The error message should really say something about this being > > an attempt to mix 32-bit and 64-bit modes. > > Well as they say, patches are welcome. > Mea culpa. I should learn how to do this. I thought I would have more time to contribute when I retired, but I was surprised to learn how many things there are to do in life besides "working." I don't know how I ever found enough time to work! Bob