We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

# CS401 Assignment 2 SolutiON..!

Hello...

AsSalam U Alaikum...

I hope U al r fi9 & ShinE like Star......

Ya lygia solutiOn.... iB iss main Apna Apna VU ID  lgaa la ar SS ly lygiaAa....

[org 0x0100]

jmp start

message: db'BC000000000' ; string to be printed

length: dw 20 ; length of string

clrscr: push es

push ax

push cx

push di

mov ax, 0xb800

moves, ax ; point es to video base

xor di, di ; point di to top left column

mov ax, 0x0720 ; space char in normal attribute

mov cx, 2000 ; number of screen locations

cld ; auto increment mode

repstosw ; clear the whole screen

pop di

pop cx

pop ax

popes

ret

; subroutine to print a string

; takes the x position, y position, attribute, address of string and

; its length as parameters

printstr: push bp

movbp, sp

pushes

push ax

push cx

pushsi

push di

mov ax, 0xb800

moves, ax ; point es to video base

mov al, 80 ; load al with columns per row

mul byte [bp+10] ; multiply with y position

add ax, [bp+12] ; add x position

shl ax, 1 ; turn into byte offset

movdi,ax ; point di to required location

movsi, [bp+6] ; point si to string

mov cx, [bp+4] ; load length of string in cx

mov ah, [bp+8] ; load attribute in ah

cld ; auto increment mode

nextchar: lodsb ; load next char in al

stosw ; print char/attribute pair

loopnextchar ; repeat for the whole string

pop di

popsi

pop cx

pop ax

popes

popbp

ret 10

start: call clrscr ; call the clrscr subroutine

mov ax, 10

push ax ; push x position

mov ax, 15;

push ax ; push y position

mov ax, 0x12 ; blue on black attribute

push ax ; push attribute

mov ax, message

push ax ; push address of message

push word [length] ; push message length

callprintstr ; call the printstr subroutine

mov ax, 0x4c00 ; terminate program

int 0x21

NXt 2 SS ap apnI VU ID ka mutabk lain gy :/

.....................

kSi Ko agr is Code main Mistake Lag rhE hy ar Corect SolutIon unka Pass hy to plz wo add kr ka Sb ke Hlp kr Dygia ....

ThNkiewz!!

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

Views: 990

### Replies to This Discussion

bhai ya mny ne bnai :P CS619 bhai na bna ka de

CS401 Assignment no.2 Solution step to step

https://youtu.be/aLoXQAIGvz0

[org 0x0100]

jmp start

oldisr: dd 0                                          ; space for saving old isr

next:     dw 0

clrscr: push es                                    ; subroutine to clear the screen

push ax

push cx

push di

mov ax, 0xb800

mov es, ax                          ; point es to video base

xor di, di                               ; point di to top left column

mov ax, 0x0720                                 ; space char in normal attribute

mov cx, 2000                      ; number of screen locations

cld                                          ; auto increment mode

rep stosw                            ; clear the whole screen

pop di

pop cx

pop ax

pop es

ret

; keyboard interrupt service routine

kbisr:     push ax

push es

push di

mov di, [next]

mov ax, 0xb800

mov es, ax                          ; point es to video memory

in al, 0x60                            ; read a char from keyboard port

nextcmp1:cmp al, 0x32                  ; has the m key pressed

jne nextcmp2                    ; no, try next comparison

mov byte [es:di], 'm'      ; yes, print m

jmp exit                               ; leave interrupt routine

nextcmp2: cmp al, 0x2E                                 ; has the C key pressed

jne nextcmp3                    ; no, try next comparison

mov byte [es:di], 'c'        ; yes, print c

jmp exit                               ; leave interrupt routine

nextcmp3: cmp al, 0x1F                                 ; has the s pressed

jne nextcmp4                    ; no, try next comparison

mov byte [es:di], 's'        ; print s

jmp exit                               ; leave interrupt routine

nextcmp4: cmp al, 0x2C                                ; has the z pressed

jne nextcmp5                    ; no, try next comparison

mov byte [es:di], 'z'        ; print z

jmp exit                               ; leave interrupt routine

nextcmp5: cmp al, 0x0B                                ; has the 0 pressed

jne nextcmp6                    ; no, try next comparison

mov byte [es:di], '0'        ; print 0

jmp exit                               ; leave interrupt routine

nextcmp6: cmp al, 0x02                                 ; has the 1 pressed

jne nextcmp7                    ; no, try next comparison

mov byte [es:di], '1'        ; print 1

jmp exit                               ; leave interrupt routine

nextcmp7: cmp al, 0x03                                 ; has the 2 pressed

jne nextcmp8                    ; no, try next comparison

mov byte [es:di], '2'        ; print 2

jmp exit                               ; leave interrupt routine

nextcmp8: cmp al, 0x04                                 ; has the 3 pressed

jne nextcmp9                    ; no, try next comparison

mov byte [es:di], '3'        ; print 3

jmp exit                               ; leave interrupt routine

nextcmp9: cmp al, 0x05                                 ; has the 4 pressed

jne nextcmpA                   ; no, try next comparison

mov byte [es:di], '4'        ; print 4

jmp exit                               ; leave interrupt routine

nextcmpA: cmp al, 0x06                                ; has the 5 pressed

jne nextcmpB                    ; no, try next comparison

mov byte [es:di], '5'        ; print 5

jmp exit                               ; leave interrupt routine

nextcmpB: cmp al, 0x07                                ; has the 6 pressed

jne nextcmpC                    ; no, try next comparison

mov byte [es:di], '6'        ; print 6

jmp exit                               ; leave interrupt routine

nextcmpC: cmp al, 0x08                                ; has the 7 pressed

jne nextcmpD                   ; no, try next comparison

mov byte [es:di], '7'        ; print 7

jmp exit                               ; leave interrupt routine

nextcmpD: cmp al, 0x09                                ; has the 8 pressed

jne nextcmpE                    ; no, try next comparison

mov byte [es:di], '8'        ; print 8

jmp exit                               ; leave interrupt routine

nextcmpE: cmp al, 0x0A                                ; has the 9 pressed

jne nomatch                      ; no, try next comparison

mov byte [es:di], '9'        ; print 9

jmp exit                               ; leave interrupt routine

nomatch:mov [next], di

pop di

pop es

pop ax

jmp far [cs:oldisr]             ; call the original ISR

exit:       mov al, 0x20

out 0x20, al                         ; send EOI to PIC

mov [next], di

pop di

pop es

pop ax

iret                                         ; return from interrupt

start:     call clrscr                              ; call clrscr subroutine

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

l1:           mov ah, 0                            ; service 0 ? get keystroke

int 0x16                                ; call BIOS keyboard service

cmp al, 13                            ; is the Ent key pressed

jne l1                                     ; if no, check for next key

mov ax, [oldisr]                 ; read old offset in ax

mov bx, [oldisr+2]           ; read old segment in bx

cli                                            ; disable interrupts

mov [es:9*4], ax              ; restore old offset from ax

mov [es:9*4+2], bx         ; restore old segment from bx

sti

mov ax, 0x4c00                                 ; terminate program

int 0x21

hi....any one here?

CS401 Assignment no.2 Solution step to step

https://youtu.be/aLoXQAIGvz0

## Latest Activity

5 minutes ago
8 minutes ago
16 minutes ago
20 minutes ago
Nouman Butt liked + " J i y a " ♥'s discussion Agr............
24 minutes ago
24 minutes ago
Minhaas, Zee Meer, Ubaid ullah and 21 more joined Virtual University of Pakistan
37 minutes ago
37 minutes ago
38 minutes ago
43 minutes ago
52 minutes ago
52 minutes ago

1

2

3