views:

1355

answers:

2

I'm currently in the process of learning assembly language. I'm using Gas on Linux Mint (32-bit). Using this book: Programming from the Ground Up.

The machine I'm using has an AMD Turion 64 bit processor, but I'm limited to 2 GB of RAM. I'm thinking of upgrading my Linux installation to the 64-bit version of Linux Mint, but I'm worried that because the book is targeted at 32-bit x86 architecture that the code examples won't work.

So two questions:

  1. Is there likely to be any problems with the code samples?
  2. Has anyone here noticed any benefits in general in using 64-bit Linux over 32-bit (I've seen some threads on Stack Overflow about this but they are mostly related to Windows Vista vs. Windows XP.)
+4  A: 

Your code examples should all still work. 64-bit processors and operating systems can still run 32-bit code in a sort of "compatability mode". Your assembly examples are no different. You may have to provide an extra line of assembly or two (such as .BITS 32) but that's all.

In general, using a 64-bit OS will be faster than using a 32-bit OS. x86_64 has more registers than i386. Since you're working on assembly, you already know what registers are used for... Having more of them means less stuff has to be moved on and off the stack (and other temporary memory) thus your program spends less time managing data and more time working on that data.

Edit: To compile 32-bit code on 64-bit linux using gas, you just use the commandline argument "--32", as noted in the GAS manual

SoapBox
thank you very much, most helpful!
bplus
A: 

Even if you run Linux 64bit, it is possible to compile and run 32bit binaries on it. I don't know how good Mint's support for that is, I assume you should check.

64bit assembler however is not fully compatible to 32bit, for example you have different (more) registers. There are some specific instructions not available on either platform.

I would say the move to 64bit is not a big deal. You can still write 32bit assembly and then perhaps try to get it also running as 64bit (shouldn't be too hard), as a source of even more programming/learning fun.

ypnos
thankyou, very helpful!
bplus
I see how you like the other answer more, but if you think mine is helpful, you could give it a +1 vote as well ;) but I'm happy with your comment, too :)
ypnos