1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- global _start
- section .data
- _start:
- call getchar
- cmp rax,-1
- je .done
- call putchar
- jmp _start
-
- .done:
- mov rdi,rax
- mov rax,60
- syscall
- getchar:
- mov rax,0x00
- mov rdi,0 ;stdin fd
- lea rsi,[rel buf]
- mov rdx,1 ;count
- syscall
-
- cmp rax,1
- jne .getchar_fail
- mov rax,0
- mov al,[rel buf]
- ret
- .getchar_fail:
- mov rax,-1
- ret
- putchar:
- mov [rel buf],al
- mov rax,0x01
- mov rdi,1 ;stdout fd
- lea rsi,[rel buf]
- mov rdx,1
- syscall
- ret
- buf:
- db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|