everyone! I'm sharpening my assembly low-level skills and made myself a simple bootloader. I now made some routines and the entrypoint and successfully output a message however, I want to clear the screen so in outputting my message, it comes out clean. I've tried making a routine which clears the AX
register, stores the content of address 0xb800
to BX
then copying or MOV
ing the contents of the AX
register.
like this:
vram equ 0xb800
xor ax, ax
mov bx, [vram]
mov bx, ax
int 10h
it successfully clears the screen but I have a problem, as shown on the picture, it stretches the text.
Then I searched for some answers. I didn't found some answers because search results just gives me DOS interrupts to clear the screen.
But, I did try using INT 10, AH=07h
but I don't how to use it.
please lend me a hand thank you! :D
CodePudding user response:
The text gets 'stretched' because you setup for a 40-columns screen! You've written:
xor ax, ax <<<< This is video mode 0, so 40x25 16-color text int 10h
Use
mov 0003h
int 10h
to setup the 80x25 16-color text screen.
vram equ 0xb800 xor ax, ax mov bx, [vram] mov bx, ax int 10h
In the above code you seem to have mixed 2 ways to clear the screen.
Setting the video mode
BIOS offers a number of video modes. Some are text modes, others are graphics modes. In a graphics mode you can address every single pixel whereas in a text mode you deal with colored characters. Of course, in the graphics modes you can output colored characters too.
This is a list of the more relevant modes:
01h 40x25 16-color text 25 rows, 40 columns -> wide characters!
03h 80x25 16-color text 25 rows, 80 columns
07h 80x25 monochrome text 25 rows, 80 columns
10h 640x350 16-color graphics 25 rows, 80 columns
12h 640x480 16-color graphics 30 rows, 80 columns
13h 320x200 256-color graphics 25 rows, 40 columns -> wide characters!
Clearing the video memory manually
Your equate vram equ 0xb800
represents the segment in memory where the regen buffer is located. The value 0xB800 needs to be loaded in a segment register. Next code will clear (the 1st page of) the 80x25 text screen:
mov ax, vram
mov es, ax
xor di, di
mov cx, 80 * 25
mov ax, 0720h ; WhiteOnBlack space character
cld
rep stosw
Clearing the video memory using BIOS
BIOS provides 2 functions that can scroll a window in the active page, which is most of the time DisplayPage 0. Next code uses function 07h to clear (the entire active page of) the 80x25 text screen:
mov dx, 184Fh ; (79,24) Lowerright corner
xor cx, cx ; (0,0) Upperleft corner
mov bh, 07h ; WhiteOnBlack
mov ax, 0700h ; BIOS.ScrollWindowDown, AL=0 ClearWindow
int 10h