0

What are the technical advantages of me compiling in 64 bit mode, as opposed to 32 bit? Are we talking the about of RAM my application will be able to use? The size of CPU registers I will be able to use?

I ask because I was reading this question:

ICC inline assembler doesn`t like push/pop

A guy couldn't get inline assembly instruction POP to compile because he was compiling in 64 bit mode and POP only works on 32 bit registers (at least, that is how I read the answer).

I cannot believe you cannot use the POP assembly command if you compile in 64 bit mode?

My main question is- if you choose 64 bit compilation- does this mean you cannot use "regular" inline assembly instructions?

Community
  • 1
  • 1
user997112
  • 29,025
  • 43
  • 182
  • 361
  • The most relevant advantages are more general purpose registers, bigger address space, guaranteed presence of SSE. – Matteo Italia Mar 17 '13 at 15:25
  • You CAN use the `POP` assembly instruction in 64-bits mode, but in particular `POP ebp` can't be encoded in 64-bits mode. On the other hand `POP rbp` (the 64-bits version of ebp) should work just fine. – Jorge Núñez Mar 17 '13 at 15:41
  • @JorgeNúñez thanks, that makes more sense! So he was popping the wrong register! – user997112 Mar 17 '13 at 15:51
  • @user997112 yes, harold gives a more detailed reasoning behind it in his answer – Jorge Núñez Mar 17 '13 at 16:14
  • So we have now seen one reason for **not** using inline assembly. It's not portable at all. – Bo Persson Mar 17 '13 at 18:21
  • There is no such thing as "regular inline assembly". x86 and x86-64 are different instructions sets, and you have to port your code from 32-bit to 64-bit code accordingly. There are **a lot** of differences, of which only a few can be seen in my question http://stackoverflow.com/questions/11897116/how-to-convert-linux-32-bit-gcc-inline-assembly-to-64-bit-code. The best source of information is Intel http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-manual-325462.html or AMD http://support.amd.com/us/Processor_TechDocs/24592_APM_v1.pdf – nrz Mar 17 '13 at 18:55

1 Answers1

2

push and pop in 64bit mode can not have 32bit operands, only 16bit or 64bit, it is not the case that pop only works on 32bit registers. In general a lot of code will work the same in 32bit and 64bit modes, but some little-used instructions (decimal math, instructions that have to do with segmentation) have been removed completely from 64bit mode.

harold
  • 61,398
  • 6
  • 86
  • 164