Sunteți pe pagina 1din 36

;----------------------------------------------------------------------------

; PROGRAM TO ADD N NUMBERS OF GIVEN ARRAY


; SE-I ROLL NO:-2123 Assignment no 1
;----------------------------------------------------------------------------

.model small

.stack 50

.data
arr db 0f0h,0f0h,0f0h,0f0h,0f0h
cnt db 04
msg db 0ah,0dh,'Addition of result is $'

.code
mov ax,@data
mov ds,ax

mov cl,5
mov dx,0000h
lea si,arr

l1:
add dl,[si]
jnc l2
inc dh

l2:
inc si
dec cl
jnz l1

mov bx,dx

mov cx,0404h

lea dx,msg
mov ah,09
int 21h

l3:
rol bx,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe l4
add dl,07

l4:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz l3

mov ah,4ch
int 21h

end
;----------------------------------------------------
OUTPUT
Addition of result is 04B4
;----------------------------------------------------
;Program for Non-Overlapping and Overlapping data Transfer
;Roll No.:-2123 Assignment No.:-2
;-------------------------------------------------------------------------------

.model small
display1 macro msg ;Macro for Display string
lea dx,msg
mov ah,09
int 21h
endm

.stack 100
.data

org 100h ;Offset


arr db 10h,20h,30h,40h,50h,60h,70h,80h,90h,95h
cnt db 04
cnt2 db 10
cnt1 db 02
msg1 db 10,13,'1. X+5$'
msg2 db 10,13,'2. x-5$'
msg3 db 10,13,'3. Non Overlapping$'
msg4 db 10,13,'Enter Your Choice :$'
msg5 db 10,13,'Address Value before transfer of data',10,13,'$'
msg6 db 10,13,'Address Value after transfer of data',10,13,'$'
msg7 db 10,13,'$'
msg8 db ' $'

.code
mov ax,@data
mov ds,ax
mov es,ax

display1 msg1
display1 msg2
display1 msg3

display1 msg5
lea si,arr
label3:
call display2
inc si
display1 msg7
dec cnt2
jnz label3

display1 msg4
mov ah,01
int 21h

cmp al,31h
jne l2
call addfive

mov cnt2,10
add si,06
display1 msg6
label32:
call display2
inc si
display1 msg7
dec cnt2
jnz label32

jmp l5

l2:
cmp al,32h
jne l4
call subfive

mov cnt2,10
sub di,10
mov si,di
display1 msg6
label33:
call display2
inc si
display1 msg7
dec cnt2
jnz label33

jmp l5

l4:
lea si,arr
mov di,si
add di,100h
mov cx,0010
l6:
mov dl,[si]
mov [di],dl
inc si
inc di
loop l6

mov cnt2,10
sub di,10
mov si,di
display1 msg6
label34:
call display2
inc si
display1 msg7
dec cnt2
jnz label34

l5:
mov ah,4ch
int 21h

addfive proc near ;Procedure For Overlapp +5 data transfer


mov cx,0010
lea si,arr
mov di,si
add si,09
add di,14

l1:
mov dl,[si]
mov [di],dl
dec si
dec di
loop l1
retn
addfive endp

subfive proc near ;Procedure For Overlapp -5 data transfer


lea si,arr
mov di,si
sub di,04
mov cx,0010
l3:
mov dl,[si]
mov [di],dl
inc si
inc di
loop l3
retn
subfive endp
jmp l5

display2 proc near ;Procedure to display addresses and Values at that address
mov ch,[si]
mov bx,si
mov cl,04
mov cnt,cl
mov cnt1,02

label1:
rol bx,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe label2
add dl,07

label2:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz label1

display1 msg8
label31:
rol ch,cl
mov dl,ch
and dl,0fh
cmp dl,09
jbe label41
add dl,07

label41:
add dl,30h
mov ah,02
int 21h
dec cnt1
jnz label31
retn

endp

end
;-------------------------------------------------------------------------------
OUTPUT
E:\Sachin>cd tasm

E:\Sachin\tasm>edit assign2.asm

E:\Sachin\tasm>tasm assign2.asm
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International

Assembling file: assign2.asm


Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 439k
E:\Sachin\tasm>tlink assign2.obj
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International

E:\Sachin\tasm>assign2.exe

1. X+5
2. x-5
3. Non Overlapping
Address Value before transfer of data
0100 10
0101 20
0102 30
0103 40
0104 50
0105 60
0106 70
0107 80
0108 90
0109 95

Enter Your Choice :1


Address Value after transfer of data
0105 10
0106 20
0107 30
0108 40
0109 50
010A 00
010B 04
010C 00
010D 90
010E 95

Enter Your Choice :2


Address Value after transfer of data
00FC 10
00FD 20
00FE 30
00FF 40
0100 50
0101 60
0102 70
0103 80
0104 90
0105 95

E:\Sachin\tasm>assign2.exe

Enter Your Choice :3


Address Value after transfer of data
0200 10
0201 20
0202 30
0203 40
0204 50
0205 60
0206 70
0207 80
0208 90
0209 95
;------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; Program to find Total number of positive, Negative & zeroes
; in given Array
;Roll No:-2123 Assignment no.:-3
;-------------------------------------------------------------------------------

.model small

.stack 100

disp macro msg5


lea dx,msg5
mov ah,09
int 21h
endm

.data
org 100h
arr db 00,08,00,-4,-7,-1,-2,03 ;Given Array
cnt db 04
cntp db 00 ;Conter to Positive Numbers
cntn db 00 ;Conter to Negative Numbers
cntz db 00 ;Counter to Zero number

msg1 db 10,13,'Number of Zeroes :$'


msg2 db 10,13,'Number of Positive integers :$'
msg3 db 10,13,'Number of Negative integers :$'

.code
mov ax,@data
mov ds,ax

mov cx,0008
mov bx,0000h
lea si,arr

l1:
mov ah,[si]
shl ah,01 ;Check for Carry
jc l2
cmp ah,00 ;If result of compare not equal then No. is +ve
je l3
jne l5

l2:
inc cntn ;Increment Counter

l4:
inc si
loop l1
jmp l7

l6: ;To teminata from DOS


mov ah,4ch
int 21h

l3:
inc cntz

jmp l4
l5:
inc cntp
jmp l4

l7:
disp msg1
mov bl,cntz
call disp1

disp msg2
mov bl,cntp
call disp1

disp msg3
mov bl,cntn
call disp1
jmp l6

disp1 proc near ;Procedure To display Counter


mov cnt,04
mov cl,04
mov dx,0000
label1:
rol bx,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe label2
add dl ,07
label2:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz label1
retn
endp

end
-------------------------------------------------------------------------------
OUTPUT

Microsoft Windows XP [Version 5.1.2600]


(C) Copyright 1985-2001 Microsoft Corp.

D:\Documents and Settings\ABC>e:

E:\>cd sachin

E:\Sachin>cd tasm

E:\Sachin\tasm>tasm assign3.asm
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International

Assembling file: assign3.asm


Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 441k

E:\Sachin\tasm>tlink assign3.obj
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International

E:\Sachin\tasm>assign3.exe

Number of Zeroes :0002


Number of Positive integers :0002
Number of Negative integers :0004
-------------------------------------------------------------------------------
;Program to conver given HEX number into BCD form
; and BCD number into HEX Number
;assignment no:-4 ROLL NO.-2123
;-----------------------------------------------------

.model small

disp_str macro msg ;macro to display string


lea dx,msg
mov ah,09
int 21h
endm

disp macro ;Macro to accept HEX no.


l3:
mov ah,01
int 21h
rol bx,cl
sub al,30h
cmp al ,09
jbe l2
sub al,07
and al,0fh
l2:
add bl,al
dec cnt
jnz l3

endm

.stack 100

.data
msg1 db 10,13,'Enter HEX Number $'
msg2 db 10,13,'BCD number is $'
msg3 db 10,13,'1-HEX to BCD',10,13,'2-BCD to HEX $'
msg4 db 10,13,'Enter your choice :$'
msg5 db 10,13,'Enter BCD Number $'
msg6 db 10,13,'HEX number is $'

cnt db 04
cnt1 db 00
pow dw 2710h
fact dw 000Ah
result dw 0000

.code

mov ax,@data
mov ds,ax
disp_str msg3
disp_str msg4

mov ah,01
int 21h
sub al,30h
cmp al,1
jne choice2

disp_str msg1
mov bx,0000h
mov cx,0404

disp

mov ax,bx ;procedure to convert HEX into BCD


mov cx,000ah
mov cnt1,0
label1:
mov dx,0000
div cx
push dx
inc cnt1
cmp ax,0000 ;Continue untill AX containts becomes 0
jne label1

mov cx,0000
mov cl,cnt1
disp_str msg2

label2: ;procedure to Display BCD


mov dx,0000
pop dx
cmp dx,09
jbe label3
add dx,07
label3:
add dx,30h
mov ah,02h
int 21h
loop label2
jmp l4

choice2: ;procedure to convert BCD into HEX


disp_str msg5
mov cx,0005
label4:
mov ax,0000
mov ah,01
int 21h
sub al,30h
mov ah,00
mul pow
add result,ax
mov ax,pow
div fact
mov pow,ax
loop label4

disp_str msg6
mov bx,result

mov cl,04
mov cnt,04
label5: ;procedure to Display HEX
rol bx,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe label6
add dl,07

label6:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz label5

l4:
mov ah,4ch
int 21h
end
-----------------------OUTPUT------------------------
E:\Sachin\tasm>sassign4

1-HEX to BCD
2-BCD to HEX
Enter your choice :1
Enter HEX Number ffff
BCD number is 65535

1-HEX to BCD
2-BCD to HEX
Enter your choice :1
Enter HEX Number 1234
BCD number is 4660

1-HEX to BCD
2-BCD to HEX
Enter your choice :2
Enter BCD Number 65535
HEX number is FFFF

1-HEX to BCD
2-BCD to HEX
Enter your choice :2
Enter BCD Number 04660
HEX number is 1234
E:\Sachin\tasm>
-------------------------END--------------------------------
;------------------------------------------------------------
;Program to perform various operations on string
;Roll No:-2123 Assignment no.:-5
;------------------------------------------------------------

.model small

disp_str macro msg ;Macro to display string


lea dx,msg
mov ah,09
int 21h
endm

disp_int macro ;Macro to display Length


mov cnt,02
mov cl,04
l1:
rol bl,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe l2
add dl,07
l2:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz l1
endm

.stack 100

.data

msg db 10,13,'********MENU*********$'
msg1 db 10,13,'1-Enter string $'
msg2 db 10,13,'2-Lenth :$'
msg3 db 10,13,'3-Reverse $'
msg4 db 10,13,'4-Palindrome$'
msg5 db 10,13,'Given string is Palindrome$'
msg6 db 10,13,'Given string is not Palindrome$'
msg7 db 10,13,'Enter your choice:$'
msg8 db 10,13,'5-Exit$'
msg9 db 10,13,'$'
msg12 db 10,13,'Enter string :$'
msg22 db 10,13,'Lenth of string is :$'
msg32 db 10,13,'Reverse of string is :$'
msg41 db 10,13,'Given String is not Palindrome$'
msg42 db 10,13,'Given String is Palindrome$'
str1 db 20 dup('$')
str2 db 20 dup('$')
cnt db 04

.code
mov ax,@data
mov ds,ax
mov es,ax

begin: ;Program starts


disp_str msg9
disp_str msg
disp_str msg1
disp_str msg2
disp_str msg3
disp_str msg4
disp_str msg8
disp_str msg7

mov ah,01 ;Wait until key enter from keyboard


int 21h

sub al,30h
cmp al,1
jne next1
call accept
jmp begin

next1:
cmp al,2
jne next2
call len
jmp begin

next2:
cmp al,3
jne next3
call rev
jmp begin

next3:
cmp al,4
jne next4
call palindrome
jmp begin

next4:
cmp al,5
je EXIT

EXIT:
mov ah,4ch
int 21h

accept proc near ;Procedure to accept String


disp_str msg9
disp_str msg12
mov ah,0ah ;interrupt 0ah to accept String
lea dx,str1
int 21h
retn
endp

len proc near ;Procedure to find length


disp_str msg9
disp_str msg22
lea si,str1+1
mov bx,[si]
and bx,00ffh
disp_int
retn
endp

rev proc near ;Procedure to find Reverse of string


disp_str msg32
lea si,str1+1
mov cx,[si]
and cx,00ffh
lea si,str1
lea di,str2
add si,cx
add si,01
STD ;Set Direction Flag
label1:
movsb ;To move string si to di
add di,02
loop label1
disp_str str2
retn
endp

palindrome proc near ;Procedure to check Palindrome

condition
lea si,str1+1
mov ax,[si]
and ax,00ffh
add si,01 ;si points to 1st character
mov di,si
add di,ax
sub di,01 ;di points to last char
mov bl,02
div bl ;CX contains loop bound value
mov cl,al
mov ch,00
CLD ;Reset Direction Flag
label2:
cmpsb ;Compare 1st & last char
jne label3
sub di,02
loop label2
disp_str msg42
retn
label3:
disp_str msg41

retn
endp

end
-------------------------------------------------------------------------------
OUTPUT
********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:1

Enter string :PICT

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:2

Lenth of string is :04

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:3
Reverse of string is :TCIP

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:4
Given String is not Palindrome

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:1

Enter string :MADAM

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:4
Given String is Palindrome

********MENU*********
1-Enter string
2-Lenth :
3-Reverse
4-Palindrome
5-Exit
Enter your choice:5
E:\Sachin\tasm>
-------------------------------END----------------------------
;---------------------------------------------------------------------
;Program to perform various operations on string.
;Roll No:-2123 Assignment no.:-6
;---------------------------------------------------------------------

.model small

.stack 100

disp_str macro msg ;Macro to display string


lea dx,msg
mov ah,09
int 21h
endm

.data
msg db 10,13,'********MENU*********$'
msg1 db 10,13,'1-Concatenation $'
msg2 db 10,13,'2-Compare $'
msg3 db 10,13,'3-Occurance of substring $'
msg4 db 10,13,'4-Exit $'
msg5 db 10,13,'Enter your choice :$'
newline db 10,13,'$'
str1 db 20 dup('$')
str2 db 20 dup('$')

.code
mov ax,@data
mov ds,ax
mov es,ax

public str1,str2

begin:
disp_str newline
disp_str msg
disp_str msg1
disp_str msg2
disp_str msg3
disp_str msg4
disp_str msg5

mov ah,01
int 21h
sub al,30h
cmp al,01
jne next1
extrn concat:far ;Declaration of far Procedure
call concat
jmp begin
next1:
cmp al,2
jne next2
extrn compare:far
call compare
jmp begin

next2:
cmp al,3
jne Exit
extrn substring:far
call substring
jmp begin

EXIT:
mov ah,4ch
int 21h

public accept ;Declaration of Public procedure


accept proc far
mov ah,0ah
mov dx,si
int 21h
retf
endp

end
-------------------------------------------------------------------------------
OUTPUT
********MENU*********
1-Concatenation
2-Compare
3-Occurance of substring
4-Exit

Enter your choice: 1


Enter 1st string PICT
Enter 2nd string _SCTR
Result of Concatenation is: PICT_SCTR

Enter your choice: 2


Enter 1st string PICT
Enter 2nd string SCTR
Strings are not equal

Enter your choice: 2


Enter 1st string PICT
Enter 2nd string PICT
Strings are equal

Enter your choice: 3


Enter 1st string pictsctrpict
Enter substring: pict
Occurrence of substring is : 02
-------------------------------END----------------------------

/***************PART II OF ASSIGN6 ***************/


.model small

.stack 100

disp_str macro msg ;Macro to display string


lea dx,msg
mov ah,09
int 21h
endm

disp_concat macro msg ;Macro to display string


lea dx,msg+2
mov ah,09
int 21h
endm

accept_str macro msg ;Macro to accept String


disp_str msg1
lea si,str1
extrn accept:far
call accept
disp_str msg
lea si,str2
call accept
endm

.data
msg1 db 10,13,'Enter 1st string $'
msg2 db 10,13,'Enter 2nd string $'
msg3 db 10,13,'Result of Concatenation is :$'
msg4 db 10,13,'Strings are not equal $'
msg5 db 10,13,'Strings are equal $'
msg6 db 10,13,'Enter substring :$'
msg7 db 10,13,'Ocuranse of substring is : $'
msg8 db 10,13,'String not Found$'
newline db 10,13,'$'
cnt db 00
cnt1 db 00
extrn str1:byte
extrn str2:byte

.code

mov ax,@data
mov ds,ax
mov es,ax

public concat
proc concat far ;Far procedure for Concatenation
accept_str msg2
lea di,str1+1
mov cx,[di]
and cx,00ffh
add di,cx
lea si,str2+1
inc di
mov cx,[si]
inc si
and cx,00ffh
CLD
l1:
movsb
loop l1
disp_str msg3
disp_concat str1
retf
endp

public compare
proc compare far ;Far procedure for Compare of strings
accept_str msg2
lea si,str1+1
lea di,str2+1
mov ch,[si]
mov cl,[di]
cmp ch,cl
jne l2
inc si
inc di
CLD
mov ch,00h
repe cmpsb
jne l2
disp_str msg5
je l3
l2:
disp_str msg4
l3:
retf
endp

public substring
proc substring far ;Far procedure to find occurrences of Substring
accept_str msg6
lea si,str1+1
mov al,[si]
inc si
jmp l4

l5:
mov ah,00h
lea si,str1+1
mov al,[si]
sub al,cnt1
lea si,str1+2
add si,ax
mov al,cnt1

l4:
lea di,str2+1
mov bl,[di]
lea di,str2+2

l6:
mov cl,[si]
cmp cl,0Dh
je l10

mov dl,[di]
cmp cl,dl

je l7
inc si
dec al
jnz l6

l7:
dec al
mov cnt1,al
dec bl

l8:
inc di
inc si
mov cl,[si]
cmp cl,0Dh
je l10
mov dl,[di]
cmp cl,dl
jne l5
dec al
dec bl
jnz l8
inc cnt

inc si
cmp al,00h
jne l4

l10:
disp_str msg7
mov cx,0204h
mov bl,cnt
l9:
rol bl,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe ll
add dl,07
ll:
add dl,30h
mov ah,02h
int 21h
dec ch
jnz l9
retf
endp

end
;---------------------------------------------------------------------
;Program Sort Array in Ascending and Descending order
;Roll No:-2123 Assignment no.:-7
;---------------------------------------------------------------------
.model small

disp_str macro msg ;macro to display string


lea dx,msg
mov ah,09
int 21h
endm

.stack 100

.data

msg1 db 10,13,10,13,'Which operation do want to do $'


msg2 db 10,13,'1-To sort Array in Ascending order $'
msg3 db 10,13,'2-To sort Array in Descending order $'
msg4 db 10,13,'3-EXIT $'
msg5 db 10,13,'Enter your choice :$'
msg6 db 10,13,'Original Array is',10,13,'$'
msg7 db 10,13,'Array in ascending order is',10,13,'$'
tab db ' $'

arr db 5,50h,40h,20h,10h,60h ;Array to be sort


cnt db 05 ;Counter
cnt1 db 06
temp db ? ;For Swap

.code
mov ax,@data
mov ds,ax
mov es,ax
disp_str msg6
call disp_arr ;To display original Array

begin:
disp_str msg1
disp_str msg2
disp_str msg3
disp_str msg4
disp_str msg5

mov ah,01 ;Accept Choice


int 21h
sub al,30h
cmp al,01
jne next1
mov cnt,05 ;Reinitialize count
mov cnt1,06
call ascending
disp_str msg7
call disp_arr ;Display Sorted Array
jmp begin

next1:
cmp al,02
jne next2
mov cnt,05 ;Reinitialise count
mov cnt1,06
call descending
disp_str msg7
call disp_arr ;Display Sorted Array
jmp begin

next2:
jmp EXIT

ascending proc near


l:
mov di,0001
l1:
mov dl,[arr+di]
cmp dl,[arr+di+1] ;Compare
jbe l2 ;if 1st no is less then skip swap
call swap
l2:
inc di
mov ah,0
mov al,cnt1
dec al
cmp ax,di ;cheks n value
jnz l1
dec cnt
jnz l
retn
endp

descending proc near


l4:
mov di,0001
l5:
mov dl,[arr+di]
cmp dl,[arr+di+1]
jg l6
call swap
l6:
inc di
mov ah,0
mov al,cnt1
dec al
cmp ax,di
jnz l5
dec cnt
jnz l4

retn
endp

EXIT:
mov ah,4ch
int 21h

swap proc near ;Procedure to swap


mov ah,[arr+di+1]
mov [arr+di],ah
mov [arr+di+1],dl
retn
endp

disp_arr proc near ;Procedure to display Array


lea si,arr
mov cl,04
mov cnt1,05
label1:
disp_str tab
inc si
mov bx,[si]
and bx,00ffh
mov cnt,02
label2:
rol bl,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe label3
add dl,07
label3:
add dl,30h
mov ah,02
int 21h
dec cnt
jnz label2
dec cnt1
jnz label1
retn
endp
end
------------------------------ OUTPUT -------------------------------------
E:\Sachin\tasm>assign7

Original Array is
50 40 20 10 60

Which operations do want to do?


1-To sort Array in ascending order
2-To sort Array in Descending order
3-EXIT
Enter your choice: 1
Array in ascending order is
10 20 40 50 60

Which operations do want to do?


1-To sort Array in ascending order
2-To sort Array in Descending order
3-EXIT
Enter your choice: 2
Array in ascending order is
60 50 40 20 10

Which operations do want to do?


1-To sort Array in ascending order
2-To sort Array in Descending order
3-EXIT
Enter your choice: 3

-------------------------------END-----------------------
;---------------------------------------------------------------------
;Program for Multiplication of two 8 bit positive Numbers
;Roll No:-2123 Assignment no.:-8
;---------------------------------------------------------------------
.model small

disp_str macro msg ;Macro to display String


lea dx,msg
mov ah,09h
int 21h
endm

.stack 100

.data

msg1 db 10,13,'Enter Multiplicant :$'


msg2 db 10,13,'Enter Multiplier :$'
msg3 db 10,13,'Result of Multipliction is :$'
multr db ?
mult db ?
ans dw 00

.code

mov ax, @data


mov ds,ax

disp_str msg1
call accept ;Call to Multiplicand Accept proc
mov mult,dl
disp_str msg2
call accept ; Call to Multiplier Accept proc
mov multr,dl
call multi ;Call to Multiplication Proc
mov ans,bx
disp_str msg3
call disp_res
jmp EXIT

accept proc near


mov cx,0204h
mov dl,00h
l1:
mov ah,01
int 21h
sub al,30h
rol dl,cl
add dl,al
dec ch
jnz l1
retn
endp

multi proc near


mov bh,00h
mov bl,multr
mov dl,mult
mov ch,08
l2:
test bl,01 ;testing last digit 1 or 0
jz shiftr ;If 1 then jump on shift right
add bh,dl ;Add result
shiftr:
rcr bx,01 ;Rotate right
dec ch
jnz l2
retn
endp

disp_res proc near


mov cx,0404h
mov dl,00h
mov bx,ans
l3:
rol bx,cl
mov dl,bl
and dl,0fh
cmp dl,09
jbe l4
add dl,07
l4:
add dl,30h
mov ah,02
int 21h
dec ch
jnz l3
retn
endp

EXIT:
mov ah,4ch
int 21h

end
------------------------ OUTPUT ---------------------------
Enter Multiplicand: 16
Enter Multiplier: 11
Result of Multiplication is: 0176
-------------------------------END---------------------------
;-----------------------------------------------------------------------
; Title:-Program to handle Divide by Zero Interrupt
; Class : SE-I ROLL No : 2123 Assignment No: 16
;------------------------------------------------------------------------

.MODEL SMALL
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,0FFFH
MOV BX,0000H
DIV BX
MOV AH,4CH
INT 21H
END

----------------------- OUTPUT --------------------------------

E:\SACHIN\TASM>assgn16.exe
SORRY DIVIDE BY ZERO ERROR..!!!!
Divide overflow
------------------------- END ------------------------------------

******************* TSR POGRAM *******************

.MODEL TINY
.CODE
ORG 0100
START:
JMP INIT
SAVEINTO DD ?
MSG DB "SORRY DIVIDE BY ZERO ERROR..!!!! $"

RESI:
PUSH AX
PUSH BX
PUSH CX
PUSH DX

PUSH CS
POP DS

LEA DX,MSG
MOV AH,09H
INT 21H

POP DX
POP CX
POP BX
POP AX
JMP CS:SAVEINTO

INIT:
CLI
PUSH CS
POP DS
MOV AH,35H
MOV AL,00H
INT 21H

MOV WORD PTR CS:SAVEINTO,BX


MOV WORD PTR CS:SAVEINTO+2,ES

MOV AH,25H
MOV AL,00H
MOV DX,OFFSET RESI
INT 21H

STI
MOV AH,31H
MOV DX,OFFSET INIT
INT 21H
END START
;-----------------------------------------------------------------------
; Title:-Program to Display Clock
; Class : SE-I ROLL No : 2123 Assignment No: 15
;------------------------------------------------------------------------
.MODEL TINY

.stack 100

.CODE
ORG 0100
START:
JMP INIT
SAVE DD ?
HR DB 0
MIN DB 0
SEC DB 0
MSG DB ':$'

RESI:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH CS
POP DS

MOV AH,02H
INT 1AH

MOV HR,CH
MOV MIN,CL
MOV SEC,DH

MOV AH,09H
LEA DX,MSG
INT 21H

POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
JMP CS:SAVE

INIT:
CLI
PUSH CS
POP DS
MOV AH,35H
MOV AL,08H
INT 21H

MOV WORD PTR CS:SAVE,BX


MOV WORD PTR CS:SAVE+2,ES
;STORE ADDDR IN IVT TO SAVE
MOV AH,25H
MOV AL,08H
MOV DX,OFFSET RESI ;LOAD NEW ADDR IN IVT
INT 21H

STI
MOV AH,31H
MOV DX,OFFSET INIT ;STAY RESIDENT
INT 21H
END START

S-ar putea să vă placă și