Search notes:

x64 assembler dialects

Here are a few example that demonstrate different assembler dialects for x64.
All sources use the syscall instruction to call the (Linux) syscall exit.

GNU assembler

AT&T syntax

.globl   _start
.text

_start:
  
  #
  # Load RAX register with syscall number
  #
    mov  $60, %rax   #  60 is syscall number for exit()
  # mov $231, %rax   # 231 is syscall number for exit_group()
  
  #
  # Load RDI (first argument), for exit(),
  # this is the status code.
  #
    mov  $42, %rdi   # exit status code

    syscall
Compile this source with
gcc -nostdlib -o prog prog.s

Intel syntax

In order to write an assembler source for the GNU assembler in intel syntax, the .intel_syntax noprefix directive is required:
.intel_syntax noprefix

.globl   _start
.text

_start:
  
    mov  rax, 60
    mov  rdi, 42
    syscall
This source is compiled with the exactly same command as the AT&T source.

nasm

section .text
global  _start

_start:

   mov  rax, 60
   mov  rdi, 42
   syscall
Compile and link with the following two commands:
nasm -felf64 prog.nasm -o prog.o
ld prog.o -o prog
The same source can also be compiled with yasm -felf64 ….

See also

gcc -masm
Assembler code to invoke a syscall on Linux.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1737197957, '18.218.123.194', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/assembler/x86/dialects(107): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78