1234567891011121314151617181920212223242526272829303132333435 |
- section .bss
- buf resq 1
- section .text
- getchar:
- mov rax,0x00
- mov rdi,0 ;stdin fd
- lea rsi,[buf]
- mov rdx,1 ;count
- syscall
-
- cmp rax,1
- jne .getchar_fail
- mov rax,0
- mov al,[buf]
- ret
- .getchar_fail:
- mov rax,-1
- ret
- putchar:
- mov [buf],al
- mov rax,0x01
- mov rdi,1 ;stdout fd
- lea rsi,[buf]
- mov rdx,1
- syscall
- ret
|