Good night, I need some help.
I won't lie, this is an assignment for my university, but I haven't found anything related to.
What I need it's to print messages to the terminal (in a loop style) until the user "halts" the execution pressing ESC key.
This is what I have so far, I'm not asking for anyone to solve my issues, but it would be nice to point me into the right direction.
section .data
ICANON: equ 1<<1
TCGETS: equ 0x5401
TCSETS equ 0x5402
sys_exit: equ 60
sys_read: equ 0
sys_write: equ 1
sys_open: equ 2
sys_close: equ 3
sys_ioctl: equ 16
stdin: equ 0
stdout: equ 1
s1: db "Cadena: 1", 10
s1l: equ $-s1
s2: db "Cadena: 2", 10
s2l: equ $-s2
section .bss
buffer: resb 2
termios: resb 36
section .text
write_stdout:
mov rax, sys_write
mov rdi, stdout
syscall
ret
get_keycode:
mov rax, sys_read
mov rdi, stdin
mov rsi, buffer
mov rdx, 1
syscall
ret
write_stdin_termios:
mov rax, sys_ioctl
mov rdi, stdin
mov rsi, TCSETS
mov rdx, termios
syscall
ret
read_stdin_termios:
mov rax, sys_ioctl
mov rdi, stdin
mov rsi, TCGETS
mov rdx, termios
syscall
ret
canonical_off:
call read_stdin_termios
mov rax, ICANON
not rax
and [termios+12], rax
call write_stdin_termios
ret
canonical_on:
call read_stdin_termios
or dword [termios+12], ICANON
call write_stdin_termios
ret
GLOBAL _start
_start:
nop
nop
call canonical_off
xor rsi, rsi
read_code:
mov rsi, s1
mov rdx, s1l
call write_stdout
cmp rsi, 24
je end
call get_keycode
mov al, byte[buffer]
cmp al, "e"
je end
jmp read_code
end:
mov rax, sys_exit
mov rdi, 0
syscall
Thanks in advance.