Search code examples
assemblydos

MS-DOS standard output interrupt and function


I need to write a resident program which grabs console output to the file. To do this I have to know what interrupt and function DOS uses to print its output to console, to rewrite this interrupt. But I can't find it anywhere.


Solution

  • In the last step DOS uses the TELETYPE OUTPUT for to print its output to console: RBIL->inter61a.zip->INTERRUP.A

    --------V-100E-------------------------------
    INT 10 - VIDEO - TELETYPE OUTPUT
    AH = 0Eh
    AL = character to write
    BH = page number
    BL = foreground color (graphics modes only)
    Return: nothing
    Desc:   display a character on the screen, advancing the cursor and scrolling
      the screen as necessary
    Notes:  characters 07h (BEL), 08h (BS), 0Ah (LF), and 0Dh (CR) are interpreted
      and do the expected things
    IBM PC ROMs dated 1981/4/24 and 1981/10/19 require that BH be the same
      as the current active page
    BUG:    if the write causes the screen to scroll, BP is destroyed by BIOSes
      for which AH=06h destroys BP
    SeeAlso: AH=02h,AH=06h,AH=0Ah
    

    And here is an other way for to set and get an interrupt vector: RBIL->inter61b.zip->INTERRUP.F

    --------D-2125-------------------------------
    INT 21 - DOS 1+ - SET INTERRUPT VECTOR
    AH = 25h
    AL = interrupt number
    DS:DX -> new interrupt handler
    Notes:  this function is preferred over direct modification of the interrupt
      vector table
    some DOS extenders place an API on this function, as it is not
      directly meaningful in protected mode
    under DR DOS 5.0-6.0, this function does not use any of the
      DOS-internal stacks and may thus be called at any time; however,
      under Novell DOS 7.0 - DR-DOS 7.02, this function was not reentrant.
      Since 1998/05/29, DR-DOS 7.03 no longer uses any internal stacks and
      tests for this function much earlier, to allow a minimal stack usage
      of just two words in addition to the IRET frame, allowing it to be
      called from INT 21h functions, specificially device drivers.  This
      fixes the MCS SMB client
    Novell NetWare (except the new DOS Requester) monitors the offset of
      any INT 24 set, and if equal to the value at startup, substitutes
      its own handler to allow handling of network errors; this introduces
      the potential bug that any program whose INT 24 handler offset
      happens to be the same as COMMAND.COM's will not have its INT 24
      handler installed
    SeeAlso: AX=2501h,AH=35h
    
    --------D-2135-------------------------------
    INT 21 - DOS 2+ - GET INTERRUPT VECTOR
    AH = 35h
    AL = interrupt number
    Return: ES:BX -> current interrupt handler
    Note:   under DR DOS 5.0+, this function does not use any of the DOS-internal
      stacks and may thus be called at any time
    SeeAlso: AH=25h,AX=2503h
    

    A little variation of the end of our ISR:

    myisr:
    ....etc....
    
               DB 0EAh ; jmp far
    old_dosint DW ?, ?
    

    Edit: RBIL->inter61b.zip->INTERRUP.F

    --------D-2109-------------------------------
    INT 21 - DOS 1+ - WRITE STRING TO STANDARD OUTPUT
    AH = 09h
    DS:DX -> '$'-terminated string
    Return: AL = 24h (the '$' terminating the string, despite official docs which
        state that nothing is returned) (at least DOS 2.1-7.0 and
        NWDOS)
    Notes:  ^C/^Break are checked, and INT 23 is called if either pressed
    standard output is always the screen under DOS 1.x, but may be
      redirected under DOS 2+
    under the FlashTek X-32 DOS extender, the pointer is in DS:EDX
    SeeAlso: AH=02h,AH=06h"OUTPUT"
    

    Example:

    STRING DB "Hello","$"
    
    mov ah,9
    lea dx,STRING
    int 21h