I'm reading a book on how to write assembly for x86 Linux.
I want to assemble the following assembly source code (exit.s) on my x86_x64 Linux OS:
.section .data
.section .text
.globl _start
_start:
mov1 $1, %eax
mov1 $0, %ebx
int $0x80
By calling this command: as exit.s -o exit.o
However, the assembler exits with the following error:
exit.s: Assembler messages:
exit.s: Warning: end of file not at end of a line; newline inserted
exit.s:6: Error: no such instruction: `mov1 $1,%eax'
exit.s:7: Error: no such instruction: `mov1 $0,%ebx'
From what I can gather, the instruction set for x86_x64 Linux is different from x86, hence the error. By replacing mov1
with mov
, the assembler succeeds in compiling. However, seeing as the rest of the book is written for x86, I would like to be able to assemble x86 assembly for my OS.
I read somewhere that it's possible to do so by specifying the option --32
, like so: as --32 exit.s -o exit.o
, but by doing that, I receive the same error as before.
How do I assemble x86 source code on an x86_x64 architecture?
mov1
is not valid even for correct 32-bit x86 assembly. You probably wantmovl
(last character is anL
). But that does not solve your question, to use the int 80h API you do want to compile into a 32-bit application. – ecmgcc
commands given in stackoverflow.com/questions/36861903/… – ecm-v
to have gcc show you the commands it runs to assemble and link." – ecm