Skip to content

ayuxsec/assembly_notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NASM

Building Executables

To build an executable binary, you need to:

  1. Write your assembly in a file (often with a .S or .s syntax.
  2. Assemble your binary into an executable object file (using the as command).
  3. Link one or more executable object files into a final executable binary (using the ld command)!

.intel_syntax noprefix tells the assembler that you will be using Intel assembly syntax, and specifically the variant of it where you don't have to add extra prefixes to every instruction.

.intel_syntax noprefix
mov rdi, 42
mov rax, 60
syscall

build

as -o asm.o asm.s

Linking: combining one or more object files into a single executable using the linker (ld).

ld -o exe asm.o # optional

The _start symbol is, essentially, a note to ld about where in your program execution should begin when the ELF is executed. you can specify the _start symbol, in your code, as so:

hacker@dojo:~$ cat asm.s

.intel_syntax noprefix
.global _start
_start:
mov rdi, 42
mov rax, 60
syscall

hacker@dojo:~$ as -o asm.o asm.s

hacker@dojo:~$ ./exe
hacker@dojo:~$ echo $?
42
hacker@dojo:~$

Loading from memory

To load the memory contents at memory address say 31337 to a register say rdi, you can do:

mov rdi, [31337]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published