Due Date: Thursday, August 6, 2020: Spring 2020 CS:401 Assembly Language Total Marks: 20
Due Date: Thursday, August 6, 2020: Spring 2020 CS:401 Assembly Language Total Marks: 20
Total Marks: 20
[org 0x0100]
jmp start
oldisr: dd 0 ; space for saving old isrkeyboardinterrupt service routine
kbisr:
push ax
push es
mov ax, 0xb800
mov es, ax ;point es to video memory
in al, 0x60 ;read a char from keyboard port
cmp al, 0x31 ;is to hold the key in N
jnenextcmp ;no, try next comparison
mov byte [es:0],'S' ;yes, print ABCD at top left
mov byte [es:2],'A'
mov byte [es:4],'M'
mov byte [es:6],'A'
mov byte [es:8],'D'
jmp nomatch ;leave interrupt routine
nextcmp:
cmp al, 0xB1 ; is the key n is release
jnenomatch ; no, leave interrupt routine
mov byte [es:0],'' ; yes, print space at top left
mov byte [es:2],''
mov byte [es:4],''
mov byte [es:6],''
mov byte [es:8],''
nomatch:
pop es
pop ax
jmp far [cs:oldisr] ;call the original ISR
start:
xor ax, ax
mov es, ax ;point es to IVT base
mov ax, [es:9*4]
mov [oldisr], ax ;save offset of old routine
mov ax, [es:9*4+2]
mov [oldisr+2], ax ;save segment of old routine
cli ; disable interrupts
mov word [es:9*4], kbisr ;store offset at n*4
mov [es:9*4+2],cs ;store segment at n*4+2
sti ;enable interrupts
exit:
mov ah, 0 ;service 0 - get keystroke
int 0x16 ;call BIOS keyboard service
Screen Shot:1
Screen Shot:2
Screen Shot:3
Screen Shot:4