Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing x86 assembly on an x64 bit processor

For example, I'm running Windows 7 64 bit, but it seems like all of the best resources out there for learning assembly languages speak about x86. If writing x86 on x64 is possible, what's the best way to go about this? Are there converters in existence? Also, what are some good resources for 64 bit assembly programming?

like image 894
zeboidlund Avatar asked Dec 23 '11 23:12

zeboidlund


People also ask

Does x86 assembly work on x64?

Yes, of course. Most programs are still 32 bit and run fine on 64-bit Windows systems. Those programs are machine language, which has a one-to-one mapping with assembly (and can be easily disassembled into x86 assembly code).

What is x64 x86 assembly?

x64 is a generic name for the 64-bit extensions to Intel‟s and AMD‟s 32-bit x86 instruction set architecture (ISA). AMD introduced the first version of x64, initially called x86-64 and later renamed AMD64. Intel named their implementation IA-32e and then EMT64.

What is the difference between x86 and x64 assembly?

What is the difference between x86 and x64? As you guys can already tell, the obvious difference will be the amount of bit of each operating system. x86 refers to a 32-bit CPU and operating system while x64 refers to a 64-bit CPU and operating system.

What language does x86 use?

Many x86 assemblers use Intel syntax, including FASM, MASM, NASM, TASM, and YASM. GAS, which originally used AT&T syntax, has supported both syntaxes since version 2.10 via the .


2 Answers

Most 64-bit operating systems can run 32-bit binaries without trouble. Since your question is tagged [windows], you should be fine. If you follow the instructions for building a 32-bit binary from your tutorials, the resulting binaries should work without modification. If you are using a different toolchain, you might need to find the flag that tells your assembler to produce 32-bit rather than 64-bit code.

The differences between 32- and 64-bit assembly programming are pretty minor. There are some new and improved instructions to handle the 64-bit types, plus some new register names. There's a new ABI to contend with, too. Intel has Software Developer Manuals that describe all of the possible instructions and how they work.

like image 56
Carl Norum Avatar answered Oct 08 '22 02:10

Carl Norum


x86 is definitely not the best, first, assembly to learn. if at all it is the last one you want to learn. checkout https://github.com/dwelch67 lsasim is an instruction set designed for learning assembly. pcemu_samples is a modified pcemu (8086/88 emulator capable of running dos), with the bios/dos calls removed, specifically for learning 8088/86 assembler. I recommend when you approach x86 assembly you start with 8088/86, something like the pcemu_samples (where you are forced to focus on assembly language and not system calls). dosbox and bochs can run 8088/86 programs with dos/bios when you want to move into system calls. THEN move up into the 32 and 64 bit enhancements, multi-core and all that.

You will do yourself a great benefit by learning x86 last. msp430, the lsasim thing above, arm, thumb (not thumb2) are all good starting points. Learning a few different instruction sets at least, if not many, will also benefit you greatly. I have simulators for some of these which give you good visibility into what is going on, I recommend learning on simulators first, simulators you can get visibility into.

if you start with 8088/86 then move to 386/486 then forward into x64 the other answers you are getting about the instructions (sorta) working everywhere will make a whole lot of sense.

like image 21
old_timer Avatar answered Oct 08 '22 00:10

old_timer