MIM3122 Computer Exercise #3

1. Using DEBUG, display the memory locations listed below, which describe the computer's configuration and help execute commands.

        0:417h-418h            These two locations describe the status of special keys, such as shift, and control
                                        Note the effect of the various key presses (see fig. 6-6, and 6-7 in the class
                                        packet, the section titled: "More about Keyboards and Scan Codes").
        0:41Ah                    points to the keyboard buffer head location
        0:41Ch                    points to the keyboard buffer tail location
        0:41Eh-43Ch           keyboard buffer: space for 15 key strokes beginning with 41Eh. Note the
                                        ASCII and scan codes in the buffer and relate them to commands entered.
        0:449h                     video mode
        0:44Ch-44Dh           amount of display memory in bytes (remember "backwords" convention)

To see the operation of the keyboard buffer, in DEBUG issue the command: "d 0:41a" several times to fill the buffer with copies of this command. Using the ASCII display portion of DEBUG, identify the ASCII and scan codes for "d 0:41a" in the keyboard buffer. Remember key codes are stored in the buffer from low to high memory locations.

2. To observe the effect of changing character attributes, use the DEBUG "Enter" command (E) to enter values directly into video RAM. You must first determine the appropriate addresses to use in video RAM. The starting address of video RAM depends on the video mode (check location 0:449 for video mode, which will be a text mode). Consult Fig. 4-10 in the class packet, the section titled: "More about Video Modes" for the starting segment address for the indicated mode. The offset address depends upon where you wish to place the characters on the screen.

In text mode, the complete screen contents are contained in memory between offset 0000h and 0F9Fh (0000d to 3999d). Pick a RAM location that maps to a row that you can easily see. A good screen location is in the last row, third column. Calculate the character memory offset value from the formula: CO = ROW*A0 + COL*2. Remember rows are numbered (in hex) 0,1,...,18, and columns 0,1,2,...,4F. Using DEBUG, enter the desired ASCII and attribute bytes (See the ASCII Character Set in the Keyboard section of the class packet). Some easily seen attributes are 87h for blinking and 70h for reverse video, but you can select from a wide variety of foreground and background colors (see Fig. 4-4 and 4-7 in the Video section of the class packet). You might find a hex calculator or the Windows calculator from the accessories group helpful in doing hex calculations.

3. For this illustration you will need to invoke GWBASIC (download from the course web page) from the floppy or Zip drive. Type GWBASIC at the prompt and follow the screen directions to "load" (F3) and "run" (F2) programs. Issue Ctrl-Brk to terminate a program and "SYSTEM" to return to DOS. Use KEY-BITS (download from the course web page) to "see" the bits which hold the status of the shift and toggle keys on the PC keyboard. "Load" and then "run" KEY-BITS. Press keys such as shift, control, and caps-lock and observe the results.

4. From the floppy or Zip drive, run KEYSCOPE (download from the course web page). This program will display the scan and ASCII codes for a key as it is pressed and released. The press and release codes for each key differ by 128d in value. Scan and ASCII codes appear in the Keyboard section of the class packet.