Skip to content

Instantly share code, notes, and snippets.

@mkakh
Last active October 8, 2018 04:46
Show Gist options
  • Save mkakh/cab48e36592fe94a4406326cdd67bb62 to your computer and use it in GitHub Desktop.
Save mkakh/cab48e36592fe94a4406326cdd67bb62 to your computer and use it in GitHub Desktop.
section .data
text db "number> "
nl db 10
section .bss
inputChar resb 1
tmp resb 1
section .text
global _start
_start:
call _printText
call _getChar
call _printChar
call _printNewLine
mov rax, 60
mov rdi, 0
syscall
_printNewLine:
mov rax, 1
mov rdi, 1
mov rsi, nl
mov rdx, 1
syscall
ret
_printChar:
mov rax, 1
mov rdi, 1
mov rsi, inputChar
mov rdx, 1
syscall
ret
_getChar:
; 1桁入力
mov rax, 0
mov rdi, 0
mov rsi, inputChar
mov rdx, 1
syscall
; 改行を捨てる
mov rax, 0
mov rdi, 0
mov rsi, tmp
mov rdx, 1
syscall
ret
_printText:
mov rax, 1
mov rdi, 1
mov rsi, text
mov rdx, 8
syscall
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment