MIM3122 Computer Exercises #4

This set of exercises illustrates what can be done with some of the more straight-forward BIOS and DOS interrupts. DEBUG [see class packet: "Fundamentals of DEBUG" or App. B of the textbook] or the MASM assembler will be essential to assembling and executing the necessary code. In all of the exercises, the approach is to pre-set the necessary registers and then invoke the desired interrupt.

For example, to read the date one could use DOS interrupt 21h, service 2Ah as follows:

cs:100     mov AH,2A     ;place service number in AH
cs:102     int 21        ;invoke the interrupt
cs:104     int 20        ;normal termination of a program

To see the register contents at the end of execution, use the "Go" command (G) and break before executing instruction int 20 as: g=100 104. The day is returned in DL (1-31), the month in DH (1-12), the year in CX (1980-2099) and the day of the week in AL (0=Sun, 1=Mon, etc.). Although these data are stated here in decimal, they will of course appear in the registers as hexadecimal.

Code can be entered by issuing "a 100" in DEBUG and then keying in the statements. The program can be executed by issuing the DEBUG command G, or it may be saved as FILENAME.COM file [see Computer Exercise #1 for an example of how this is done] and then executed as an external command: FILENAME. Code could also be created using AE and then assembled and linked with MASM.

For all of the interrupts to be used in these exercises, the service number of the interrupt is placed in the AH register. See the "More about DOS Interrupts" Section of the class packet or App. G of the textbook for descriptions of BIOS and DOS interrupts.

1. Use interrupt 10h, service Eh [write character as tty] to write a small message to the screen (at least 3 or 4 characters). This interrupt writes to the screen one character at a time beginning at the current cursor position. The character to be written is placed in register AL. To write several characters, load register AL and invoke int 10h sequentially for each character to be written. The attributes of the characters cannot be altered using this interrupt.

2. An alternative way of accomplishing #1. above is to use interrupt 21h, service 2h [display output]. The character to be written is placed in register DL.

3. Use interrupt 21h, service 9h to write a string to the screen. The address of the string in memory is place in DS:DX, and this memory location must contain the string. Use -E DS:DX "string$" to enter the string.

4. Using interrupt 10h, service numbers 2h [set cursor position] and 9h [write character and attribute] move the cursor to the approximate center of the screen and write a dozen "Xs". For service 2h, BH contains the display page number [use 0], DH contains the row number [0h to 18h] and DL the column [0h to 4fh]. For service 9h, AL contains the character to be written, BH the page number [use 0], BL the attribute [try 07h for normal mode, 87h for blinking, 70h for reverse video] and CX the number of repetitions of the character to be written.

5. Taking a hint from Computer Exercise #1, write a simple routine to clear the screen using interrupt 10h, service 9. Service 2 also comes in handy.