LABORATORY EXERCISE – FINALS
John Paul Mandap Computer Architecture and Organization
BSCPE 4A Participation - Interrupt
1.
2. Code:
mov ah, 0
mov al, 13h
int 10h ; AH=0, AL=13h, INT 10h to set graphics mode (Mode 13h, 320x200 resolution,
256 colors)
mov cx, 10 ; Set X-coordinate (horizontal position) to 10
mov dx, 10 ; Set Y-coordinate (vertical position) to 10
mov al, 0Eh ; Set color to Light Yellow (color code 0Eh) for the pixel
mov ah, 0Ch ; AH=0Ch, INT 10h to change pixel color at (x, y) = (CX, DX)
int 10h ; Execute the pixel color change at (10, 10)
mov al, 0Ch ; Set color to Light Red (color code 0Ch)
dec cx ; Decrement X-coordinate (move left to 9)
dec dx ; Decrement Y-coordinate (move up to 9)
int 10h ; Change the pixel color at (9, 9)
; LIST OF COLORS
; The following are the colors in 4-bit format (N16 N2 color codes):
; 0 - 0000 BLACK
; 1 - 0001 BLUE
; 2 - 0010 GREEN
; 3 - 0011 CYAN
; 4 - 0100 RED
; 5 - 0101 MAGENTA
; 6 - 0110 BROWN
; 7 - 0111 LIGHT GRAY
; 8 - 1000 DARK GRAY
; 9 - 1001 LIGHT BLUE
; A - 1010 LIGHT GREEN
; B - 1011 LIGHT CYAN
; C - 1100 LIGHT RED
; D - 1101 LIGHT MAGENTA
; E - 1110 YELLOW
; F - 1111 WHITE
mov al, 0Dh ; Set color to Light Magenta (0Dh)
dec cx ; Decrement X-coordinate (move left to 8)
dec dx ; Decrement Y-coordinate (move up to 8)
int 10h ; Change the pixel color at (8, 8)
mov dx, offset msg1 ; Load address of msg1 ("Enter Num: $") into DX
mov ah, 9h ; AH=9, INT 21h to print string at DS:DX
int 21h ; Output "Enter Num: "
mov ah, 1 ; AH=1, INT 21h to read a character from the keyboard
int 21h ; Wait for user input (key press) and show the character on the console
mov dh, 1 ; Set row (Y-coordinate) for cursor to 1
mov dl, 0 ; Set column (X-coordinate) for cursor to 0
mov ah, 02h ; AH=02h, INT 10h to set cursor position
int 10h ; Move cursor to (1, 0)
LEA dx, msg2 ; Load address of msg2 ("nextLine") into DX
mov ah, 9h ; AH=9, INT 21h to print string at DS:DX
int 21h ; Output the message "nextLine"
mov dh, 4 ; Set row (Y-coordinate) for cursor to 4
mov dl, 0 ; Set column (X-coordinate) for cursor to 0
mov ah, 02h ; AH=02h, INT 10h to set cursor position
int 10h ; Move cursor to (4, 0)
LEA dx, msg3 ; Load address of msg3 ("nextPhase: $") into DX
mov ah, 9h ; AH=9, INT 21h to print string at DS:DX
int 21h ; Output the message "nextPhase:"
mov dl, 'a' ; Load the character 'a' into DL
mov ah, 02h ; AH=02h, INT 21h to print a single character in DL
int 21h ; Print the character 'a' to the console
; mov ah, 39h ; AH=39h, INT 21h would be used to create a virtual drive folder (not
implemented)
; int 21h ; Execute the above command (which is currently commented out)
ret; Return from the program (end of the program)
msg1 db "Enter Num: $" ; Message 1 to prompt user to enter a number
msg2 db 0dh, 0ah, "nextLine $" ; Message 2 with line break for next phase
msg3 db "nextPhase: $", 0dh, 0ah ; Message 3 with line break for the next phase
3. Which part of the code created the pixel color Light Magenta? Refer to the code.
mov al, 0Dh ; Set color to Light Magenta (0Dh)
dec cx ; Decrement X-coordinate (move left to 8)
dec dx ; Decrement Y-coordinate (move up to 8)
int 10h ; Change the pixel color at (8, 8)
The pixel color Light Magenta is created in the code by setting the AL register to `0Dh`,
which corresponds to the color code for Light Magenta in Mode 13h (256-color graphics
mode). The coordinates for the pixel are then adjusted by decrementing the CX (X-
coordinate) and DX (Y-coordinate) registers, which move the pixel position from `(10, 10)`
to `(9, 9)`. Finally, the `int 10h` instruction is used with `AH=0Ch` to set the pixel color at
the new coordinates `(9, 9)` to Light Magenta.