Tuesday, December 27, 2011

CS401 3 Computer Architecture and Assembly assignment solution fall december 2011

Copy the following code in "NOTEPAD" and save as

filename.asm

submit the asm file in vulms.

Please makes changes before submitting.



 [org 0x0100]
jmp start
oldisr: dd 0
message1: db 'Hello'
message2: db 'World'
;===============================================
kbisr:
 push ax
 push es
 mov ax, 0xb800
 mov es, ax
 in al, 0x60
;=======================Hello===================
 cmp al, 0x23
 jne nextcmp


mov ah, 0x13
mov al, 0
mov bh, 0
mov bl, 7
mov dx, 0x0000
mov cx, 5
push cs
pop es
mov bp, message1
int 0x10
 
 jmp exit
;=======================World===================
nextcmp:
 cmp al, 0x11
 jne nextcmp1
mov ah, 0x13
mov al, 0
mov bh, 0
mov bl, 7
mov dx, 0x0000
mov cx, 5
push cs
pop es
mov bp, message2
int 0x10


 jmp exit


;====================clear screen===============
nextcmp1:
 cmp al, 0x2e
 jne nomatch


mov ax, 0xb800
mov es, ax
mov di, 0
nextchar:
mov word [es:di], 0x0720
add di, 2
cmp di, 4000
jne nextchar


 jmp exit


;===============================================


nomatch:
 pop es
 pop ax
 jmp far [cs:oldisr]
;===============================================
exit:
 mov al, 0x20
 out 0x20, al
 pop es
 pop ax
 iret
;===================main========================
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


 mov dx, start
 add dx, 15
 mov cl, 4
 shr dx, cl
 mov ax, 0x3100
 int 0x21

No comments:

Post a Comment