Lab 13 sol
Lab 13 sol
Laboratory Manual
for
Computer Organization and Assembly Language Programming
Page 1
OBJECTIVES:
Page 2
.no_key:
; Chain to original INT 08h
jmp far [original_08h]
start:
; Save original INT 08h vector
mov ax, 0x3508
int 0x21
mov [original_08h], bx
mov [original_08h+2], es
; Display result
mov bx, ax ; Store frequency in BX
call print_number ; Print the frequency
; Exit program
mov ax, 0x4C00
Page 3
int 0x21
pop dx
pop cx
pop bx
pop ax
ret
Task 2: Change keyboard behavior to display special messages when specific keys are
pressed.
Hook INT 09h and check for specific scan codes (e.g., F1 key).
Display a custom message.
[org 0x0100]
jmp start
Page 4
int09_handler:
push ax
in al, 0x60 ; Read scan code
cmp al, 0x3B ; F1 key scan code
jne .done
lea si, f1_msg
.print_msg:
lodsb
or al, al
jz .done_msg
mov ah, 0x0E
int 0x10
jmp .print_msg
.done_msg:
; Clear keyboard buffer
in al, 0x61
mov ah, al
or al, 0x80
out 0x61, al
mov al, ah
out 0x61, al
.done:
pop ax
jmp far [original_09h]
start:
; Save original INT 09h
mov ax, 0x3509
int 0x21
mov [original_09h], bx
mov [original_09h+2], es
Page 5
mov dx, [original_09h]
int 0x21
; Exit
mov ax, 0x4C00
int 0x21
original_09h dw 0, 0
[org 0x0100]
jmp start
Page 6
; Chain to the original INT 08h handler
jmp far [original_08h]
start:
; Save the original INT 08h vector (timer interrupt)
mov ax, 0x3508 ; Function to get current vector for INT 08h
int 0x21
mov [original_08h], bx ; Store vector
mov [original_08h+2], es
; Exit to DOS
mov ax, 0x4C00
int 0x21
Page 7