Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64-bit linux, Assembly Language, Issues?

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.)
like image 653
bplus Avatar asked Feb 22 '09 14:02

bplus


People also ask

What assembly language is used for Linux?

The GNU Assembler, commonly known as gas or as, is the assembler developed by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software.

Is x86 64 an assembly language?

x86-64 assembly language is a human-readable version of this machine code. x86-64 has hundreds of instructions, and compiling programs to the most efficient machine code requires a good understanding of all of them–indeed, the fastest C compiler for x86-64 processors is developed by Intel!

Is Linux written in assembly?

Linux is also written mostly in C, with some parts in assembly. About 97 percent of the world's 500 most powerful supercomputers run the Linux kernel. It is also used in many personal computers.

What assembly language does Ubuntu use?

x86 Assembly Language Programming with Ubuntu.


2 Answers

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

like image 151
SoapBox Avatar answered Sep 24 '22 13:09

SoapBox


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.

like image 29
ypnos Avatar answered Sep 22 '22 13:09

ypnos