Search code examples
assemblyx86dos

DOS interrupt 10 with AX 700


Im trying to figure out what this code does:

mov AX,$700
  mov BH,0
  mov CX,0
  mov DH,25
  mov DL,40
  int $10

But i cant find a good source for DOS interrupts anywhere. Best I could do is http://www.techhelpmanual.com/27-dos__bios___extensions_service_index.html but it does not seem to list this operation?

I believe this clears the screen but I want to know what the values in DH, DL mean.


Solution

  • Im trying to figure out what this code does:

    A major source for this kind of interrupts is the Ralf Brown Interrupt List.

    mov AX,$700
    mov BH,0
    mov CX,0
    mov DH,25
    mov DL,40
    int $10
    
    • int $10 is a BIOS interrupt that expects its function number 07h in the AH register. What could be confusing is the mention mov AX,$700 that would better have been written as mov ax, $0700 with an accompanying comment that details what AH and AL signify.
    • furthermore I find it a bit strange that whomever wrote this code snippet, did combine AH and AL, and also CH and CL, but forgot to treat DH and DL the same way.

    I believe this clears the screen but I want to know what the values in DH, DL mean.

    The numbers in DH and DL are meant to specify the lower right corner of the window to clear/scroll but in this case they are very probably wrong. They show a mis-understanding about how the BIOS uses zero-based coordinates for the character cells.
    If your screen has 40 columns and 25 rows, then the lower right corner is at column 39 and row 24. (If the screen would have had 80 columns and 25 rows, then the mention of DH=25 would still be wrong. The only video mode where these values would have been fine is the 640x480 graphics mode that has 30 rows.)

    Better write it like this

    mov dx, 1827h   ; DH=24 (lower right row), DL=39 (lower right column)
    xor cx, cx      ; CH=0 (upper left row), CL=0 (upper left column)
    mov bh, 0       ; BH=0 (attribute)
    mov ax, 0700h   ; AH=07h (function number), AL=0 (use clear instead)
    int 10h         ; BIOS.ScrollWindowDown
    

    The attribute in BH is set to BlackOnBlack. This is sometimes a first step towards an error. Later text that gets outputted by BIOS.Teletype or DOS.Print will remain invisible. Since this BIOS function writes space characters to actually clear the window, it's fine to specify an attribute with a non-black foreground like eg. 07h (WhiteOnBlack).