Last active
October 8, 2018 04:46
-
-
Save mkakh/cab48e36592fe94a4406326cdd67bb62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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