12-28-2011, 05:30 PM
ssignment No. 03
Semester: Fall 2011
CS401: Computer Architecture and Assembly Language Programming
Total Marks: 20
Due Date:29th December, 2011
Assignment
You are required to write an Assembly program that shall be executed as Terminate and Stay Resident (TSR) program and performs the following operations.
When the key h is pressed, string Hello will be displayed on screen.
When the key w is pressed, string World will be displayed on screen.
When the key c is pressed, whole screen will be cleared.
HINT:
You can check which key is pressed with the help of keyboard interrupt.
SOLUTION:
Programme code following
[org 0x100]
jmp start
msg1: db ‘Hellow’,0
msg2: db ‘World’,0
clrscr: push es
push ax
push cx
push di
mov ax,0xb800
mov es,ax
xor di,di
mov ax,0×0720
mov cx,2000
cld
rep stosw
pop di
pop cx
pop ax
pop es
ret
strlen: push bp
mov bp,sp
push es
push cx
push di
les di,[bp+4]
mov cx,0xffff
xor al,al
repne scasb
mov ax,0xffff
sub ax,cx
dec ax
pop di
pop cx
pop es
pop bp
ret 4
printstr: push bp
mov bp,sp
push es
push ax
push cx
push si
push di
push ds
mov ax,[bp+4]
push ax
call strlen
cmp ax,0
jz exit
mov cx,ax
mov ax,0xb800
mov es,ax
mov al,80
mul byte [bp+8]
add ax,[bp+10]
shl ax,1
mov di,ax
mov si,[bp+4]
mov ah,[bp+6]
cld
nextchar: lodsb
stosw
loop nextchar
exit: pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
start:
mov ah,0
int 0×16
mov ax,0
push ax
mov ax,0
push ax
mov ax,0×71
push ax
mov ax,msg1
push ax
call printstr
mov ah,0
int 0×16
mov ax,2
push ax
mov ax,2
push ax
mov ax,0×71
push ax
mov ax,msg2
push ax
call printstr
mov ah,0
int 0×16
call clrscr
mov ah,0
int 0×16
mov ax,0x4c00
int 0×21
Semester: Fall 2011
CS401: Computer Architecture and Assembly Language Programming
Total Marks: 20
Due Date:29th December, 2011
Assignment
You are required to write an Assembly program that shall be executed as Terminate and Stay Resident (TSR) program and performs the following operations.
When the key h is pressed, string Hello will be displayed on screen.
When the key w is pressed, string World will be displayed on screen.
When the key c is pressed, whole screen will be cleared.
HINT:
You can check which key is pressed with the help of keyboard interrupt.
SOLUTION:
Programme code following
[org 0x100]
jmp start
msg1: db ‘Hellow’,0
msg2: db ‘World’,0
clrscr: push es
push ax
push cx
push di
mov ax,0xb800
mov es,ax
xor di,di
mov ax,0×0720
mov cx,2000
cld
rep stosw
pop di
pop cx
pop ax
pop es
ret
strlen: push bp
mov bp,sp
push es
push cx
push di
les di,[bp+4]
mov cx,0xffff
xor al,al
repne scasb
mov ax,0xffff
sub ax,cx
dec ax
pop di
pop cx
pop es
pop bp
ret 4
printstr: push bp
mov bp,sp
push es
push ax
push cx
push si
push di
push ds
mov ax,[bp+4]
push ax
call strlen
cmp ax,0
jz exit
mov cx,ax
mov ax,0xb800
mov es,ax
mov al,80
mul byte [bp+8]
add ax,[bp+10]
shl ax,1
mov di,ax
mov si,[bp+4]
mov ah,[bp+6]
cld
nextchar: lodsb
stosw
loop nextchar
exit: pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
start:
mov ah,0
int 0×16
mov ax,0
push ax
mov ax,0
push ax
mov ax,0×71
push ax
mov ax,msg1
push ax
call printstr
mov ah,0
int 0×16
mov ax,2
push ax
mov ax,2
push ax
mov ax,0×71
push ax
mov ax,msg2
push ax
call printstr
mov ah,0
int 0×16
call clrscr
mov ah,0
int 0×16
mov ax,0x4c00
int 0×21
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
