Share:
Notifications
Clear all

[Solved] CS401 Assignment 3 Spring 2020  

  RSS

admin
(@admin)
Admin
Joined: 2 years ago
Posts: 4336
05/08/2020 5:30 pm  

CS401 Computer Architecture and Assembly Language Programming Assignment 3 Solution & Discussion Spring 2020


CS401 Assignment 3 Solution idea:

 

[org 0x0100]

jmp start

oldisr: dd 0

kbisr:

push ax

push es

mov ax, 0xb800

mov es,ax

in al, 0x60

cmp al, 0x31

jne nextcmp

mov byte [es:0], 'F'

mov byte [es:2], 'a'

mov byte [es:4], 'h'

mov byte [es:6], 'a'

mov byte [es:8], 'd'

jmp nomatch

nextcmp:

cmp al, 0xB1

jne nomatch

mov byte[es:0], ' '

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]

start:

xor ax, ax

mov es, ax

mov ax, [es:9*4]

mov [oldisr], ax

mov ax, [es:9*4+2]

mov [oldisr+2], ax

cli

mov word [es:9*4], kbisr

mov [es:9*4+2], cs

sti

exit:

mov ah,0

int 0x16

mov ax, 0x4c00

int 0x21

QueryVU WhatsApp Groups subject wise : Join Now


Quote
admin
(@admin)
Admin
Joined: 2 years ago
Posts: 4336
05/08/2020 5:36 pm  

CS401 Computer Architecture and Assembly Language Programming Assignment 3 Solution & Discussion Spring 2020


Another CS401 Assignment 3 Solution idea:

 

[org 0x0100]

       jmp start

       oldisr: dd 0           ; space for saving old isr keyboard interrupt 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  

jne nextcmp                   ;no, try next comparison

mov byte [es:0],'N'         ;yes, print ABCD at top left

mov byte [es:2],'A' 

mov byte [es:4],'M' 

mov byte [es:6],'E' 

mov byte [es:8],'N'

jmp nomatch                   ;leave interrupt routine

 

nextcmp:

cmp al, 0xB1                  ; is the key n is release

jne nomatch                   ; 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

 

     mov ax, 0x4c00                  ; terminate program

     int 0x21

QueryVU WhatsApp Groups subject wise : Join Now


ReplyQuote
admin
(@admin)
Admin
Joined: 2 years ago
Posts: 4336
07/08/2020 6:42 pm  

CS401 Computer Architecture and Assembly Language Programming Assignment 3 Solution & Discussion Spring 2020


Another CS401 Assignment 3 Solution idea:

 

 

Download attachment for CS401 Assignment 3 Solution file.

CS401 Assignment 3 Solution2 Spring 2020 (3 downloads)

QueryVU WhatsApp Groups subject wise : Join Now


ReplyQuote
Share: