Probably one of the most famous interrupts on the x86 architecture, Interrupt 10h (h = hexadecimal) is probably best known for switching video modes:
     mov     AH, 00h     ; I want to set the video mode...
     mov     AL, 03h     ; ...to 80x25x16
     int     10h         ; Call video interrupt
int 10h can also do other nifty things like working with cursor position, setting the active video page (for modes that support it), and even reading light pen coordinates.

(By the way, the two mov statements above could have been compressed to a single mov AX, 0300h, since AX is a 16-bit register, of which AH and AL are the High and Low bytes.)

Interrupt 10h in assembly!

Here's a listing of what interrupt 10h (Video Bios) can do in assembly. I am assuming you have some basic knowledge of the assembly language. (Stuff like you know the difference between the AL, AH, and AX registers).

IF YOU HAVE NO WORKING KNOWLEDGE OF ASSEMBLY, PLEASE DO NOT VOTE ON THIS NODE.

How to use interrupt 10h:
The first number in bold on the left IS YOUR FUNCTION NUMBER. In other words, if you want to change what video mode/resolution you are using, then move into AH (A-High) the function number zero, then call interrupt 10h. You're code would look exactly as the DoctorNo code above.

Please /msg me if I am missing information, if any errors are found (factual, gramatical, or spelling), something does not make sense, or if you know a way I can better format this information.

00 Sets the video mode/resolution. Before calling int 10h, move into AL the video mode that you want. Just off the top of my head, video mode 03 in AL is 80x25x16 text mode, while video mode 13h is 320x200x256 graphics mode.

01 Sets what horizontal lines your command line cursor uses. Before calling int 10h, move into CH the cursor starting line; move into CL the cursor ending line. Usually these horizontal lines are numbered from 0 to 7. So to have the cursor become an entire block, zero goes into CH, while 7 goes into CL (the cursor takes all it's availiable horizontal lines). It is also possible to make the cursor invisible using this interrupt by putting, for example, 40h into CH and 0h into CL.

02 Sets the cordinates of the cursor. Before calling int 10h, move into BH = what video page you're working on, DH = the row you want to move the cursor to, DL = the column you want to move the cursor to (Remember, row 0 is the top row of your screen, column 0 is the left column of your screen).

03 Gets both the cursor position and what horizonal lines the cursor is using. Before calling int 10h, move into BH what video page you are working with. After calling int 10h, CH will equal the cursor starting line, CL = cursor ending line, DH = the row the cursor is currently on, and DL = the column the cursor is currently on. (If you have anything important in either the DX or CX registers, don't forget to save them before calling int 10h or else DX and CX will get overwritten.)

04 Read Light Pen. CREDIT: Thanks lj for this info! Apparently, some older computers let you use a "light pen" (like a light gun, in pen form) to point at things on the screen. The 8088 processors at the time couldn't detect the position of the pen fast enough, so old CGA cards did all the computing instead. After calling int 10h, CH = pixel row, BX = pixel column, DH = character row, and DL = character column.

05 Sets what video page is being displayed. Before calling int 10h, move into AL the video page number you want to display.

06 Scrolls a section of the screen up in text mode. Move into AL the number of lins to scroll, BH the attribute byte of the scrolled lines, CX the upper left row and column, and DX the lower right row and column. For example, if I make AL = 1, BH = 0007h, CX = 0000h, DX = 050Ah, then by calling int 10h I will create a box that is 5 rows tall, 10 columns wide, and located in the upper left of the screen. Since AL = 1, everything in this box will get shifted up one row, the top row is lost, and the new bottom row is blank. If AL = 0, it scrolls the entire box. By making AL = 0 and making the box bigger than the size of your screen, you can clear the entire screen.

07 Scrolls a section of the screen down in text mode. Exactly like function 6, except everything scrolls DOWN and not UP.

08 Reads what the character is at the current cursor position. Before calling int 10h, move into BH the video page you're working with. After calling int 10h, AH will equal the attributes of the character, while AL will equal the ASCII code of the character itself.

09 Write a character at the current cursor position. Before calling int 10h, move into AL the ASCII character code, BH the video page you want to write the character to, BL the attribute byte of the character, and CX the number of times you want to write it. If CX = 5, then you'll write 5 characters side by side starting where the cursor was located.

0A Write a character at the current cursor position. This is the same as function 09, however it does not write the attribute byte. So if you overwrite a blue 'i' with a 'I', the new 'I' will still be blue.

0B My books says, "Set Color Palette. Select a group of available colors for the color or EGA adapter. Input: AL = display mode, and BH = active display page." I've never used it. If someone can clear this up, please /msg me!

0C Write a pixel in graphics mode. Before calling int 10h move into AL the pixel value, CX the X coordinate, and DX the Y coordinate. NOTE: This is VERY slow. GOOD if you just want to display a single picture, VERY BAD if you're trying to program a game. I plan on writing a node about how to do FAST assembly graphics programming very soon.

0D Read a graphics pixel. Before calling int 10h, move into CX the X coordinate and into DX the Y coordinate of the pixel you want to read. After calling int 10h, AL will contain the value of the pixel.

0E Write a character. This is like function 0A except the cursor is advanced one spot, and you can only write one character at a time.

0F Get current video mode and video page. After calling int 10h, AL will equal the video mode you're using, and BH will equal the video page currently being displayed.

Functions 11 through 13 will not work on modern computers. If someone out there is still programming for EGA, PCjr, or similar older displays, /msg me and I'll attempt to explain these functions. (I haven't used them, so I don't know exactly how they work).

My source is Assembly Language for Intel-Based Computers: Third Edition by Kip R. Irvine, published by Prentice Hall. However, this is not verbatim. I made an attempt to explain in more detail and clear up more ambiguities of interrupt 10h than the book.

Log in or register to write something here or to contact authors.