There are two different syntaxes for assembly language, AT&T and Intel. The difference is really only aesthetic, both compile to the same underlying code. For no particular reason I have been using AT&T syntax. All my code has been built and run on 64 bit Ubuntu linux, with the GNU assembly, gas, and the GNU linker ld. My code is available on github.
My first assembly program was a little something like this:
.section .data
.section .text
.globl _start
_start:
movq $60, %rax
movq $0, %rdi
syscall
Put this in a file named return.s and run
as return.s -o return.o
This calls the gnu assembler, which assembles the text you have written into object code in a file named return.o.
Then run
ld return.o -o return
This calls the GNU linker and links the object code, creating an executable file named return. Now if, in the same directory, you run
./return
your code (should) run successfully.
All this code does is tell the CPU to exit with exit code 0, so when it runs successfully, you shouldn’t really see anything. You can inspect the exit code of the last program you ran with
echo $?
which, in this case should be 0.