x86 NASM Assembly - Problems with Input

前端 未结 2 1318
难免孤独
难免孤独 2021-01-20 12:51

I am working to take input from a user twice, and compare the input. If they are the same, the program exits. If not, it reprints the input from the first time, and waits fo

2条回答
  •  不要未来只要你来
    2021-01-20 13:19

    You are assuming sys.read returns the entire line. It is not required to do so. It may return after only one character, or even possibly after part of the second line.

    You know, this kind of thing kind of ticks me off. This looks like a homework problem in writing in assembly, but the problem is not with the assembly, but with the assumptions in how the system calls work.

    I really wish the instructors would provide an fgets library function for stuff like this.

    Anyway, the stupid way to fix it is to read one byte at a time, looking for LF (byte 10) to end the loop.

提交回复
热议问题