Created
February 17, 2015 15:09
-
-
Save leftis/2401ced501d517e9b4b1 to your computer and use it in GitHub Desktop.
In memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define newline 0xA | |
section .data | |
hello db "Hello", newline | |
helloLen equ $ - hello | |
section .text | |
global start | |
readFile: | |
; Read system call | |
mov rax, 0x2000003 | |
; Check if input else go to exit | |
; If input save to memory and go to print | |
start: | |
; http://stackoverflow.com/questions/234906/whats-the-purpose-of-the-nop-opcode | |
nop | |
; Call readFile instructions block | |
call readFile | |
; move our first char pointer to rsi | |
mov rsi, qword hello | |
printHello: | |
; compare byte of pointer against 0xA | |
cmp byte[rsi], 0xA | |
; if true jump to exit | |
je exit | |
; call sys_write | |
mov rax, 0x2000004 | |
; on fd 1 for out | |
mov rdi, 1 | |
; for one char length | |
mov rdx, 1 | |
; system call | |
syscall | |
; incr rsi pointer we don't need a counter | |
inc rsi | |
; jpm to function | |
jmp printHello | |
exit: | |
; call exit | |
mov rax, 0x2000001 | |
; with system status 0 | |
mov rdi, 0 | |
; call system | |
syscall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment