Skip to content
Advertisement

SYS_READ call only works once, seemingly skips over code when ran again

I’m trying to rewrite a little text game in assembly for fun, and I noticed that I’m only able to run the following code successfully once. If I run it again elsewhere, it will seemingly skip over the code.

I am compiling using the following command:

nasm -f elf64 -o test.o textgame.s && ld -o test test.o && ./test

Full code

mov rax, 0
mov rdi, 0
mov rsi, buffer
mov rdx, buffer_len
syscall

Advertisement

Answer

Solved! Thanks to Jester!

With a buffer_len of 1 there is no place for the linefeed so the next time around that will be read.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement