Scroll up and down

I decided to look at how to scroll the text on the video and I found two BIOS interrupts that should do the job: INT 10h / AH=06h and AH=07h. The description of these two interrupts within the "Ralf Brown Interrupt List" is pretty simple that one may imagine that there is no need to do any tests to learn how to use them. However I have learned not to trust descriptions and documentation when it is about software and that it is always better to have some small test to check if the Interrupt works indeed in the way the descriptions says. It was good that I did so because I learned something unexpected. I present my experience in this post and I divide the topic into two paragraphs:

The program that I developed and used for the tests

Once you download the file "Scroll.zip" from the DOWNLOAD AREA and extract the archive, you will find the familiar structure1 of this small project. The project is so small and simple that I don't even present the calling hierarchy among the procedures with a separate figure. All the main program is contained in the file "scroll.asm" (which creates "SOFTWARE.BIG") and it just calls two procedures that I have already used many times in the past: _SHOW_STR (contained in the file ".\SWBIG-LIB\show_string.asm") and _WRTASCII (contained in the file ".\SWBIG-LIB\write_ascii.asm"). The program "scroll.asm" loops several video modes. Each loop displays a predefined mask on the screen upon which two different upwards scroll and two downwards scroll are performed. In this way I imagined to check the effect of the BIOS Interrupts on many different video modes and see if the Interrupts always behave in a consistent way. Guess what? I found out that the Interrupts don't behave consistently across the different video modes and on the two different computer that I have for the testing. I will discuss the results later in the next paragraph, for the moment I just wanted to tell the intention why I structured the program "scroll.asm" as a loop across many different video modes.

I am not going to present here the source code. You download the file "Scroll.zip" from the DOWNLOAD AREA and read the comments in the code. I just want to remind you that I have used here again the same trick as I described in Fig. C of the post "RAM or not" in order to be able to run SOFTWARE.BIG on the bare metal PC and to debug it within DEBUG.EXE without any special adaptation of the code (in the past I did it differently while I was still experimenting as you can see in Fig. G of the post "Test the video modes").

Fig. A - Output of the program during test with DEBUG.EXE
Fig. A - Output of the program during test with DEBUG.EXE

Fig. A shows the output of the program in video mode 0x032 within DEBUG.EXE. In the figure, you can see the mask that I have defined and the effect of the scrolls. I prepared a mask of 39 columns by 19 rows of chars in order to make it fit also the smaller text resolution of other video modes such as 40x25 . The first line of the mask tells me which video mode is currently active. I inserted two lines of "0" at the top and the bottom boundary. I did it so because I wasn't sure about the interpretation of the Interrupt's description given in the "Ralf Brown Interrupt List". As you will see in a while, it was important to do some small experiments to understand properly what the interrupt does. I prepared six fields and I placed them on two lines, three fields by each line. I let the first field of each line to remain unchanged so that it worked as a reference for me, meanwhile I applied two different values of scroll on the second and on the third field. I scrolled the fields of the first line upwards and the fields of the second line downwards. I painted red rectangular boxes in red on Fig. A to show you which portion of the screen I was selecting for the scroll. I was wondering myself what happen to the first line. Would it scroll within the lines of "0" marked at the boundary? Now I know that the scroll happens within the scope defined with the values assigned to the registers CX and DX (the red boxes on Fig. A) and the lines scrolled just go out of scope without invading other portions of the screen. This is something that I wasn't sure of and I had to test in order to understand it right. Finally I assigned the colour 0x20 at the register BH in order to have the new blank lines as black text on green background.

Analysis of results

I decided to test all standard video modes but not the one that I knew weren't available on the IBM T41 (see Fig. K of the post "Test the video modes") plus the extended mode 0x5C that was available on both the HP Elitebook and the IBM T41 (see Fig. N of the post "Test the video modes"). I discovered that the scroll up (AH=06h) works properly on every video mode but the scroll down (AH=07h) not. I noticed that for all standard video modes, the IBM T41 was capable of performing a correct scroll down, meanwhile the HP Elitebook was not. On the extended mode, both the IBM and the HP weren't able to scroll down the selected window. I don't know the reason way scroll down is not always working and if someone of you readers knows the answer, I would appreciate it in the comment section of the post. I post here all the screenshots of the tests done, and I'd like to conclude the post with the following considerations:

  • It is always worth to test and see what really happens;
  • The exact identical program can produce different results on different computers and you just can't tell it until you test.
Fig. B - Video Mode 0x00
Fig. B - Video Mode 0x00

Fig. C - Video Mode 0x01
Fig. C - Video Mode 0x01

Fig. D - Video Mode 0x02
Fig. D - Video Mode 0x02

Fig. E - Video Mode 0x03
Fig. E - Video Mode 0x03

Fig. F - Video Mode 0x04
Fig. F - Video Mode 0x04

Fig. G - Video Mode 0x05
Fig. G - Video Mode 0x05

Fig. H - Video Mode 0x06
Fig. H - Video Mode 0x06

Fig. I - Video Mode 0x07
Fig. I - Video Mode 0x07

Fig. J - Video Mode 0x0D
Fig. J - Video Mode 0x0D

Fig. K - Video Mode 0x0E
Fig. K - Video Mode 0x0E

Fig. L - Video Mode 0x0F
Fig. L - Video Mode 0x0F

Fig. M - Video Mode 0x10
Fig. M - Video Mode 0x10

Fig. N - Video Mode 0x11
Fig. N - Video Mode 0x11

Fig. O - Video Mode 0x12
Fig. O - Video Mode 0x12

Fig. P - Video Mode 0x13
Fig. P - Video Mode 0x13

Fig. Q - Video Mode 0x5C
Fig. Q - Video Mode 0x5C

Comments