50 lines
719 B
Plaintext
50 lines
719 B
Plaintext
; fasm example_flat_assembly.fasm example_flat_assembly && chmod +x example_flat_assembly
|
|
|
|
format ELF64 executable 3
|
|
|
|
entry main
|
|
|
|
TERMINAL_INPUT = 0
|
|
TERMINAL_OUTPUT = 1
|
|
|
|
EXIT_SUCCESS = 0
|
|
EXIT_FAILURE = 1
|
|
|
|
macro write file, data, size {
|
|
mov rax, 1
|
|
mov rdi, file
|
|
mov rsi, data
|
|
mov rdx, size
|
|
syscall
|
|
}
|
|
|
|
macro exit code {
|
|
mov rax, 60
|
|
mov rdi, code
|
|
syscall
|
|
}
|
|
|
|
segment readable executable
|
|
|
|
colour:
|
|
write TERMINAL_OUTPUT, colour_red, 7
|
|
ret
|
|
|
|
cancel:
|
|
write TERMINAL_OUTPUT, colour_end, 4
|
|
ret
|
|
|
|
main:
|
|
call colour
|
|
write TERMINAL_OUTPUT, string, length
|
|
call cancel
|
|
exit EXIT_SUCCESS
|
|
|
|
segment readable writable
|
|
|
|
colour_red db 27, "[1;31m"
|
|
colour_end db 27, "[0m"
|
|
|
|
string db "Heyo world!", 10, 0
|
|
length dq $ - string
|