Video memory problem

Hello everyone, I need to print a carrier return directly in video memory (without using DOS interruptions), I tried to found out how to do it in Google, but nothing useful have been found. For example, I have to print a row of one's, then print a carrier return, and then another row of numbers, as in the following description:

1111111111111
2222222222222

Somebody know how to do this?
I'm working under Windows.

Best regards

Comments

  • : Hello everyone, I need to print a carrier return directly in video
    : memory (without using DOS interruptions), I tried to found out how
    : to do it in Google, but nothing useful have been found. For example,
    : I have to print a row of one's, then print a carrier return, and
    : then another row of numbers, as in the following description:
    :
    : 1111111111111
    : 2222222222222
    :
    : Somebody know how to do this?
    : I'm working under Windows.
    :
    : Best regards


    [color=Blue]I assume you working in DOS Prompt under Windows, because Windows will not allow directly operate on video memory outside of DOS Prompt.

    The screen buffer begins at B800:0000 and it has some rows and columns. # of columns is usually 80. # of rows can be 25 or 40 in most cases.

    Now, to print Carriage Return symbol means to stop writing on the current line and jump to the next line. If cursor is at the last line of the screen buffer - then all lines will be scrolled up revealing a new line, where the rest of symbols are written.

    To make it happen you need to move data starting from beginning of line #2 to overwrite data from line #1. Each line on screen takes 160 bytes (80 x 2 byte for CHARACTER + ATTRIBUTE).

    So, to sum up (assuming you have 25 rows on screen) you need to move 24 rows (24 x 160 bytes) from address B800:160 bytes to address B800:0000. Then you need to clear the line #25 with blank characters. The data can be copied with MOVSW instruction - it is slightly faster than MOVSB. You can use also MOVSD, but then you need to calculate the count. With MOVSW you just move characters.
    [/color]
    [code]
    ;
    ; Preserve segment registers
    ;
    push ds
    push es
    ;
    ; Making pointers:
    ; ES:DI points to row #1
    ; DS:SI points to row #2
    ;
    mov ax, 0B800h
    mov ds, ax
    mov es, ax
    xor di, di
    mov si, 160
    ;
    ; Move characters!
    ;
    mov cx, 24*80
    rep movsw
    ;
    ; Point ES:DI to row 25
    ;
    mov di, 24*160
    ;
    ; Prepare a blank character with color 7 (default DOS color)
    ;
    mov ax, 0720h
    ;
    ; Fill the last row with blanks
    ;
    mov cx, 80
    rep stosw
    ;
    ; Restore segments
    ;
    pop es
    pop ds
    [/code]
  • hello! Thanks, I made the trick. I used what you said about the rows and columns in the video buffer, so at the end of every row of characters I printed white spaces in the diferrence between 80 and the number of characters.

    Thanks for your help

    Best regards.

  • Hi, I found another problem, how can I clear the screen? I want that after writing charactecrs on the screen, a new screen without characters appear, someting like the cls command in DOS.

    Best regards

  • : Hi, I found another problem, how can I clear the screen? I want that
    : after writing charactecrs on the screen, a new screen without
    : characters appear, someting like the cls command in DOS.
    :
    : Best regards
    :
    :
    [color=Blue]
    1. Point ES:DI at B800:0000
    2. AX = 0720h (Blank character with color=7)
    3. CX = 25*80 (number of characters on screen of 25 rows by 80 symbols per row)
    4. REP STOSW (this will repeat STOSW instruction CX times)
    [/color]
  • Thanks for the reply. I got other problem.

    I have this code:

    [code]
    mov ax,0B800h
    mov es,ax

    xor di,di
    lea si,message ;message is a byte defined on data segment, offset 0
    mov cx,1
    mov ah,07h
    cld
    write:
    lodsb
    stosw
    loop write
    [/code]

    I run this code on the emu8086 emulator, and it works good, but if I create a .exe file, I always receive this output:

    t
Sign In or Register to comment.

Howdy, Stranger!

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

Categories