Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Clear Screen

NANOSAURUSNANOSAURUS Member Posts: 12
How do I clear the screen with out using MSDOS interupts?

«1

Comments

  • billywm664billywm664 Member Posts: 176
    : How do I clear the screen with out using MSDOS interupts?
    :
    Well, if it were screen mode 13h, i'd do this:

    mov ax, 0a000h
    mov es, ax
    xor di, di
    mov ax, 0
    mov cx, 64000
    rep stosb

    I think that'd clear the screen. You can adapt that to any screen mode, but the basic idea's the same. Here, it starts with the beginning of segment a000h and fills 64000 bytes (320x200 pixels, 1 byte each) with 0 (with the default palette, the color black)

  • NANOSAURUSNANOSAURUS Member Posts: 12
    : : How do I clear the screen with out using MSDOS interupts?
    : :
    : Well, if it were screen mode 13h, i'd do this:
    :
    : mov ax, 0a000h
    : mov es, ax
    : xor di, di
    : mov ax, 0
    : mov cx, 64000
    : rep stosb
    :
    : I think that'd clear the screen. You can adapt that to any screen mode, but the basic idea's the same. Here, it starts with the beginning of segment a000h and fills 64000 bytes (320x200 pixels, 1 byte each) with 0 (with the default palette, the color black)
    : The code did not work


  • macrotechmacrotech Member Posts: 16
    : How do I clear the screen with out using MSDOS interupts?
    :

    Hi;
    Use these macros
    Before calling them use

    mov ax,3
    int 10h
    mov ax,0b800h
    mov es,ax
    ClrScr1 Macro
    mov ah, 6
    mov al, 0
    mov bh, 7
    mov cx, 0
    mov dh, 24
    mov dl, 79
    int 10h
    mov ah, 2
    mov bh, 0
    mov dh, 0
    mov dl, 0
    int 10h
    xor ax, ax
    endm

    ClrScr2 Macro
    ;assume we are in the text mode screen
    mov cx,2000 ;Word count of whole screen
    mov ax,0 ;Zero pattern for the screen
    mov di,ax ;Set starting address
    cld ;Go in forward direction
    ;Clear the screen with a single string operation
    rep stosw
    endm

    for graphic mode use this code

    mov ax,0013h ;graphic mode
    int 10h

    mov ax,0A000h ;vga segment address
    mov es,ax
    cld ;Go in forward direction
    mov al,55 ;55 blue color in graphic mode
    mov di,0
    FillPage:
    stosb ;mov es:[di] color in al
    cmp di,64000
    je await
    jmp FillPage

    Await:
    mov ah,0
    int 16h
    cmp ah,1
    je Exit
    jmp await

    Exit: mov ax,4c00h ; Returns control to DOS
    int 21h ;MUST be here! Program will crash without it!



    regards
    cevahir
    http://www.macrotech.bigstep.com



  • congminh1709congminh1709 Member Posts: 3
    Hello everyone, i have the same problem. How to clear screen without using any interrupts?

    In this code, you used some interrupts? I wrote " //////////////// " on these lines.

    [code]

    Hi;
    Use these macros
    Before calling them use

    mov ax,3
    int 10h ////////////////
    mov ax,0b800h
    mov es,ax
    ClrScr1 Macro
    mov ah, 6
    mov al, 0
    mov bh, 7
    mov cx, 0
    mov dh, 24
    mov dl, 79
    int 10h ////////////////
    mov ah, 2
    mov bh, 0
    mov dh, 0
    mov dl, 0
    int 10h ////////////////
    xor ax, ax
    endm

    ClrScr2 Macro
    ;assume we are in the text mode screen
    mov cx,2000 ;Word count of whole screen
    mov ax,0 ;Zero pattern for the screen
    mov di,ax ;Set starting address
    cld ;Go in forward direction
    ;Clear the screen with a single string operation
    rep stosw
    endm

    for graphic mode use this code

    mov ax,0013h ;graphic mode
    int 10h ////////////////

    mov ax,0A000h ;vga segment address
    mov es,ax
    cld ;Go in forward direction
    mov al,55 ;55 blue color in graphic mode
    mov di,0
    FillPage:
    stosb ;mov es:[di] color in al
    cmp di,64000
    je await
    jmp FillPage

    Await:
    mov ah,0
    int 16h ////////////////
    cmp ah,1
    je Exit
    jmp await

    Exit: mov ax,4c00h ; Returns control to DOS
    int 21h ;MUST be here! Program will crash without it! ////////////////


    regards
    cevahir
    http://www.macrotech.bigstep.com
    [/code]

    Thanks for reading my post.
  • YRQYRQ Member Posts: 8
    Anyway, it depends on screen mode. So what billywm664 said is right. It did not work because your screen mode was not 13h. Assume it were screen mode 03h, you can have it a try:
    [code]
    mov ax , 0b800h
    mov es , ax
    xor di , di
    mov ah , 07h ; Black background, white font set
    mov al , ' ' ; filled with space
    mov cx , 2000
    rep stosw
    [/code]

    As you can see, I fill the screen with spaces and set the color of background black and font white.
  • YRQYRQ Member Posts: 8
    This post has been deleted.
  • congminh1709congminh1709 Member Posts: 3
    Thanks. And how to exit the program without using any interrupts (21h and 20h), can I do that?
  • YRQYRQ Member Posts: 8
    Yes, of course you can exit a program without using any interrupts. You can use [b]ret[/b] to exit a program as follow:
    [code]
    code segment
    main proc far
    assume cs:code
    start:
    push ds
    xor ax , ax
    push ax ; initialize the stack in order to exit the program using ret
    ; Your program body here
    ret
    main endp
    code ends
    end start
    [/code]

    But be careful if you use stack in your program.
  • congminh1709congminh1709 Member Posts: 3
    Thanks so much ^_^. I did it!
  • BretBret Member Posts: 114
    As far as I know, there is no way to legitimately exit a DOS program without issuing an INT 20h or INT 21h.

    The first two bytes of the PSP are always CDh 20h (the CPU Op Code for INT 20h), and your sample code simply jumps to it (albeit indirectly). So, you are actually issuing an INT 20h, even though it doesn't look like that's what you're doing. Even simpler is to do a JMP 0 (as long as CS = PSP, which it is by default in a .COM executable).
«1
Sign In or Register to comment.