CSc 343
Computer Organization and Programming
Spring Quarter 1998
Solutions to Quiz #3 (15 May 1998, Friday)


1. What attribute byte specifies a character that is to be displayed
   in blue on white background without blinking (Give answer in hex).

   71h

2. How much video memory does the video mode 12H need to store
   one screen?

   153,600 bytes

3. When INT 21H Function 2 displays a single character on the screen,
   which register holds the character to be displayed?

   DL

4. Correct any errors in the following example:

     mov  ah,9     ; string output function
     mov  dx,message
     int  21h

   message db  'Hello World!'

   Corrected version:

     mov  ah,9     ; string output function
     lea  dx,message
     int  21h

   message db  'Hello World!','$'

5. The following example uses DOS service routine for keyboard
   input. Which variable holds the number of keys actually typed 
   and which label points to the first keystroke?

  mov  ah,0Ah
  lea  dx,label1
  int  21h              Variable holding number of keystrokes: _label2__

label0 db 20
label1 db 20            Label pointing to first keystroke:     _label3__
label2 db 20
label3 db 20 dup(' ')

6. Write an assembly program that writes the same color pixel (choose
   any color) throughout the screen in graphics mode 13H by writing 
   directly to the video display area.

   .model small
vseg segment at 0A000h
varea db 64000 dup (?)
vseg  ends
   .stack
   .code
main  proc  far
    mov  ax,vseg
    mov  es,ax

    mov  ah,0fh  ; save old video mode
    int  10h
    push ax

    mov  ah,00   ; set graphics mode 13h
    mov  al,13h
    int  10h

    mov  ah,0     ; move color 0 to all pixels in video area
    mov  cx,64000
    mov  di,0
l1: mov  [es:varea+di],ah
    inc  di
    loop l1

    pop  ax    ; restore video mode
    mov  ah,0
    int  10h

    mov  ax,4c00h
    int  21h
main endp
    end main