Skip to content

Commit

Permalink
support for NASM assembly synthax
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrogen602 committed Aug 12, 2019
1 parent b194ea5 commit 4c55099
Show file tree
Hide file tree
Showing 6 changed files with 910 additions and 8 deletions.
432 changes: 430 additions & 2 deletions femto

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions hello.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; ----------------------------------------------------------------------------------------
; Writes "Hello, World" to the console using only system calls. Runs on 64-bit macOS only.
; To assemble and run:
;
; nasm -fmacho64 hello.asm && ld hello.o && ./a.out
; ----------------------------------------------------------------------------------------

global start

section .text
start: mov rax, 0x02000004 ; system call for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 13 ; number of bytes
syscall ; invoke operating system to do the write
mov rax, 0x02000001 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit

section .data
message: db "Hello, World", 10 ; note the newline at the end
Loading

0 comments on commit 4c55099

Please sign in to comment.