Character Display Using DOS or BIOS

View a list of interrupt Brown is by Ralph , I have found that there are many different ways to output text characters on the screen.

The BIOS ROM API offers the following features:

  • AH = 09h - Writing a character and attribute at the cursor position
  • AH = 0Ah - write a character only at the cursor position
  • AH = 0Eh - Teletype output
  • AH = 13h - Write string

The DOS API offers the following features:

  • AH = 02h - Writing a character to standard output
  • AH = 06h - direct console output
  • AH = 09h - Writing a string to standard output

What do these functions do? What should I call them? And how do I choose between them?

+4
source share
1 answer

, ,   .

  • Int 21h AH = 02h
    7 (Beep), 8 (Backspace), 9 (Tab), 10 (Linefeed) 13 ( ). .
    Backspace , , , . .
    . Tab - ASCII 9 (ASCII 32), , 8.
    Linefeed , .
    .

  • Int 21h AH = 06h
    02h, , 255. FYI - FAT.
    , , ctrl C/ ctrl Break.

  • Int 21h AH = 09h
    02h, 36, . 36 ($) , FAT.

  • Int 21h AH = 40h
    1 STDOUT, . . , , . , . , , , , Int 24h handler.

  • Int 10h AH = 09h
    , . , , . . ! 1

  • Int 10h AH = 0Ah
    09h , . 09h.

  • Int 10h AH = 0Eh Teletype
    7 (Beep), 8 (Backspace), 10 (Linefeed) 13 ( ). . , !

  • Int 10h AH = 13h
    0Eh. , , .
    ? 2


, , . . , CHKDSK.EXE TREE.COM, . , QBASIC.EXE NE.COM, .

:

:

  • , , .
  • ,
  • ()
  • , .

DOS / redirection . 02h .  , ( ) ", , ?"   . ( , .)

; IN (ds:si) OUT ()
WriteStringDOS:
      pusha
      jmps    .b
.a:   mov     dl,al
      mov     ah,02h
      int     21h             ;DOS.DisplayCharacter -> AL
.b:   lodsb
      test    al,al
      jnz     .a
      popa
      ret

, , , :

  • - ( "- -", " ..." ..)
  • /

, DOS . WriteStringBIOS .

, DOS. , . Teletype BIOS.

; IN (ds:si) OUT ()
WriteStringBIOS:
      pusha
      mov     bx,0007h        ;Display page 0, Color if graphics mode
      jmps    .b
.a:   cmp     al,9
      je      .Tab
      mov     ah,0Eh
      int     10h             ;BIOS.Teletype
.b:   lodsb
      test    al,al
      jnz     .a
      popa
      ret
.Tab: mov     ax,0E20h        ;Start displaying space(s)
      int     10h             ;BIOS.Teletype
      mov     ah,03h
      int     10h             ;BIOS.GetCursor -> CX DX
      test    dl,7
      jnz     .Tab            ;Column not yet multiple of 8
      jmps    .b

. BIOS 09h BIOS 0Eh . , .

:

; IN (bl,ds:si) OUT ()
WriteStringWithAttributeTVM:
      pusha
      mov     bh,0            ;Display page 0
      jmps    .d
.a:   cmp     al,9
      je      .Tab
      cmp     al,13
      ja      .b
      mov     cx,1101_1010_0111_1111b
      bt      cx,ax
      jnc     .c              ;7,8,10,13 don't need the color
.b:   mov     cx,1
      mov     ah,09h
      int     10h             ;BIOS.WriteCharacterAndAttribute
.c:   mov     ah,0Eh
      int     10h             ;BIOS.Teletype
.d:   lodsb
      test    al,al
      jnz     .a
      popa
      ret
.Tab: mov     cx,1            ;Start displaying colored space(s)
      mov     ax,0920h        ;ASCII 20h is space character
      int     10h             ;BIOS.WriteCharacterAndAttribute
      mov     ah,0Eh
      int     10h             ;BIOS.Teletype
      mov     ah,03h
      int     10h             ;BIOS.GetCursor -> CX DX
      test    dl,7
      jnz     .Tab            ;Column not yet multiple of 8
      jmps    .d

16 . BIOS .

; IN (bl,ds:si) OUT ()
WriteStringWithAttributeGVM:
      pusha
      mov     bh,0            ;Display page 0
      mov     bp,bx
      jmps    .d
.a:   cmp     al,9
      je      .Tab
      cmp     al,13
      ja      .b
      mov     cx,1101_1010_0111_1111b
      bt      cx,ax
      jnc     .c              ;7,8,10,13 don't need the color
.b:   push    ax
      mov     cx,1
      mov     bx,bp
      shr     bl,4            ;Get background color (high nibble)
      mov     ax,09DBh        ;ASCII DBh is full block character
      int     10h             ;BIOS.WriteCharacterAndAttribute
      xor     bx,bp           ;Anticipate upcoming 'xor'
      and     bl,15           ;Get foreground color (low nibble)
      or      bl,128          ;Have BIOS 'xor' it
      pop     ax
.c:   mov     ah,0Eh
      int     10h             ;BIOS.Teletype
.d:   lodsb
      test    al,al
      jnz     .a
      popa
      ret
.Tab: mov     cx,1            ;Start displaying colored space(s)
      mov     bx,bp
      shr     bl,4            ;Get background color
      mov     ax,0EDBh        ;ASCII DBh is full block character
      int     10h             ;BIOS.Teletype
      mov     ah,03h
      int     10h             ;BIOS.GetCursor -> CX DX
      test    dl,7
      jnz     .Tab            ;Column not yet multiple of 8
      jmps    .d

  • WriteStringDOS WriteStringBIOS 3.
  • WriteStringWithAttributeTVM WriteStringWithAttributeGVM 3 4.
  • DOS, BIOS . ( !), .

1 :   .
2 , .
3 , BIOS TTY . . VESA BIOS . BIOS, 09h 12h! 4 , .

+11

Source: https://habr.com/ru/post/1680064/


All Articles