1

Using 01h interrupt (AH = 01h - READ CHARACTER FROM STANDARD INPUT, WITH ECHO), what will be output at the end of stdin for a cat program? Is ^Z (1Ah) used to mark the end of stdin by convention?

Testing this program with emu2 (emu2 doscat.com < input.txt) results in FFh being constantly printed, although that might be from emu2 being a C program and reading EOFs as -1.

section .text
start:
        mov ah, 01h ; read char from stdin with echo
        int 21h     ; call DOS services
        jmp start
qwr
  • 9,525
  • 5
  • 58
  • 102
  • With int 21h/ah=1 ^Z is not interpreted, thus not causing an EOF if input is redirected. So it will keep reading characters from STDIN until you break with control-C. – Michael Petch Feb 11 '23 at 02:00
  • 1
    If reading from a redirected source you would have to modify the code to search for 0ffh and stop reading once found. Note if there is a 0ffh in the input stream as part of the file that will also stop. You might want to consider using Int 21h/ah=3fh to read from standard input. You can check the return value for 0 bytes read which would be EOF. See: http://www.ctyme.com/intr/rb-2783.htm (note: file handle 0 is standard input in dos) – Michael Petch Feb 11 '23 at 02:21

0 Answers0