wow it now reads one char!!!

This commit is contained in:
pablusha
2026-05-09 21:19:41 +03:00
parent c96bd06861
commit d4cbc9082a
3 changed files with 98 additions and 4 deletions
+87
View File
@@ -0,0 +1,87 @@
%define STDIN 0
%define STDOUT 1
%define STDERR 2
%define SYS_READ 0
%define SYS_WRITE 1
%define SYS_IOCTL 16
%define SYS_EXIT 60
%define TCGETS 0x5401
%define TCSETS 0x5402
section .data
ioctl_err_m db "ioctl error", 10, 0
section .bss
orig_termios resb 60
raw_termios resb 60
cbuf resb 4
section .text
global _start
_start:
mov rax, SYS_IOCTL
mov rdi, STDIN
mov rsi, TCGETS
mov rdx, orig_termios
syscall
test rax, rax
js ioctl_err
mov rcx, 15
mov rsi, orig_termios
mov rdi, raw_termios
rep movsd
mov eax, [raw_termios + 12]
and eax, ~(2 | 8 | 1)
mov [raw_termios + 12], eax
mov rax, SYS_IOCTL
mov rdi, STDIN
mov rsi, TCSETS
mov rdx, raw_termios
syscall
mov rax, SYS_READ
mov rdi, STDIN
mov rsi, cbuf
mov rdx, 4
syscall
mov rdx, rax
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, cbuf
syscall
mov rax, SYS_IOCTL
mov rdi, STDIN
mov rsi, TCSETS
mov rdx, orig_termios
syscall
jmp exit
ioctl_err:
args_err:
mov rax, SYS_WRITE
mov rdi, STDERR
mov rsi, ioctl_err_m
mov edx, 12
syscall
jmp exit_err
exit_err:
mov rax, SYS_EXIT
mov rdi, 1
syscall
exit:
mov rax, SYS_EXIT
mov rdi, 0
syscall