[1]; This is our first assembly language program
; Author Name: Mr. Sandip S. Hire (Asst.Professor, MIT, Aurangabad, Maharashtra, India)
; Roll No.:101318
.model small
.stack 100h
.data
msg db 10,13,"Hello World!!!","$"
.code
start:
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov al,0h
mov ah,4ch
int 21h
end start
--------------------------------------------------------
How to execute:-
; c:>masm hello.asm;
; c:>link hello.obj;
; c:>hello
[2]
;Program to print "Hello World" using MACRO
;Author Name: Mr. Sandip S. Hire
;Roll No: 101318
PRINTSTR MACRO MSG
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 256
.data
msg db 10,"Hello World","$",10,10
msg1 db 10,"Welcome Sandip","$",10
msg2 db 10,"This is MIT College","$",10
.code
start: mov ax,@data
mov ds,ax
PRINTSTR msg
PRINTSTR msg1
PRINTSTR msg2
mov ax,4c00h
int 21h
end start
[13]
;Program to find even and odd number(0-9)
;Author Name: Mr. Sandip S. Hire
;Roll No : 101318
PRINT MACRO msg
lea dx,msg
mov ah,09h
int 21h
Endm
.model small
.stack 100h
.data
Inputmsg db 10,13,"Enter your number:-$"
Evenmsg db 10,13,"Your number is Even...$"
Oddmsg db 10,13,"Your number is Odd...$"
.code
start: mov ax,@data
mov ds,ax
PRINT Inputmsg
mov ah,01 ;Enter (0-9)
int 21h
and al,0Fh
rcr al,1
jc Oddno
PRINT Evenmsg
jmp skip
Oddno:PRINT Oddmsg
skip:mov ah,4ch
int 21h
end start
[14]
[15]
[17]
;Program to add digits of a 3-digit number
;Author Name: Mr.Sandip S. Hire
;Id:101318 Date: 10/3/2017
PRINT MACRO msg
mov ah,09h
mov dx,OFFSET msg
int 21h
Endm
.model small
.stack 100
.data
msg db 10,13,"Enter any 3-digit number(0-9):","$"
msg1 db 10,13,"Sum of digits is: ","$"
count db 3
sum db 1 DUP(0)
.code
start: mov ax,@data
mov ds,ax
PRINT msg
back:mov ah,01h
int 21h
sub al,30h
add al,[sum]
daa
mov [sum],al
dec byte ptr [count]
jnz back
PRINT msg1
call DISPLAY
mov ah,4ch
int 21h
DISPLAY PROC NEAR
mov al,sum
mov cl,04
rol al,cl
and al,0Fh
cmp al,9
jbe next
add al,07h
next:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,sum
and al,0FH
cmp al,9
jbe next1
add al,07h
next1:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
DISPLAY Endp
end start
[18]
;PROGRAM TO PERFORM CONVERSION FROM TWO ASCII NUMBERS TO PACKED ;BCD
;AUTHOR NAME: MR.SANDIP S. HIRE
;DATE: 10/3/2017
.model small
.stack 100
.data
msg1 db 10,13,"The Packed BCD Number is: ","$"
Num1 db 35H
Num2 db 39H
PackBcd db 0
.code
start:
mov ax,@data
mov ds,ax
mov al,Num1
mov bl,Num2
and al,0Fh ;05
and bl,0Fh ;09
mov cl,04
rol al,cl ;50
or al,bl ;59
mov ah,4ch
int 21h
end start
; Author Name: Mr. Sandip S. Hire (Asst.Professor, MIT, Aurangabad, Maharashtra, India)
; Roll No.:101318
.model small
.stack 100h
.data
msg db 10,13,"Hello World!!!","$"
.code
start:
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov al,0h
mov ah,4ch
int 21h
end start
--------------------------------------------------------
How to execute:-
; c:>masm hello.asm;
; c:>link hello.obj;
; c:>hello
[2]
;Program to print "Hello World" using MACRO
;Author Name: Mr. Sandip S. Hire
;Roll No: 101318
PRINTSTR MACRO MSG
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 256
.data
msg db 10,"Hello World","$",10,10
msg1 db 10,"Welcome Sandip","$",10
msg2 db 10,"This is MIT College","$",10
.code
start: mov ax,@data
mov ds,ax
PRINTSTR msg
PRINTSTR msg1
PRINTSTR msg2
mov ax,4c00h
int 21h
end start
[3]
;Program to print "Hello World" using PROC
;Author Name: Mr. Sandip S. Hire
;Roll No: 101318
.model small
.stack 256
.data
msg db 10,"Hello World","$",10,10
msg1 db 10,"Welcome Sandip","$",10
msg2 db 10,"This is MIT College","$",10
.code
start: mov ax,@data
mov ds,ax
lea si,msg
call DISPLAY
lea si,msg1
call DISPLAY
lea si,msg2
call DISPLAY
mov ax,4c00h
int 21h
DISPLAY PROC
mov ah,09h
mov dx,si
int 21h
ret
DISPLAY ENDP
end start
[4]
; Program to perform single digit addition
; Author Name: Mr. Sandip S. Hire
; Roll No.:101318
.model small
.stack 100h
.data
msg db 10,13,"Addition is:-$"
a db 02h
b db 02h
.code
start:
mov ax,@data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov al,a
mov bl,b
add al,bl
add al,30H
mov dl,al
mov ah,02
int 21h
mov ah,4ch
int 21h
end start
[5]
; Program to perform single digit addition
; Author Name: Mr. Sandip S. Hire
; Roll No.:101318
.model small
.stack 100h
.data
msg db 10,13,"Addition is:-$"
a db 02h
b db 02h
.code
start:
mov ax,@data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov al,a
mov bl,b
add al,bl
add al,30H
mov dl,al
mov ah,02
int 21h
mov ah,4ch
int 21h
end start
[5]
;Program to add two 8 bit numbers
;Author Name: Mr.Sandip S. Hire
;Roll no:101318
MESSAGE MACRO msg ;Printing message
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 100h
.data
msg db 10,13,"The Addition is: $"
num db 0FFh
num2 db 0FFh
temp db 0
.code
start:mov ax,@data ;Initializing DS
mov ds,ax
MESSAGE msg
mov al,num ;adding 8 bit operands
add al,num2
mov temp,al
jnc forw
mov dl,31h ;Print 1 if CF=1
mov ah,02h
int 21h
forw:
call DISPLAY
mov ah,4ch ; return back to DOS
int 21h
DISPLAY PROC
mov al,temp ;FE
mov cl,04
rol al,cl ;EF
and al,0Fh ;0F
cmp al,9
jbe next
add al,07h
next:add al,30h
mov dl,al ;Print F
mov ah,02h
int 21h
mov al,temp ;FE
and al,0FH ;0E
cmp al,9
jbe next1
add al,07h
next1:add al,30h
mov dl,al ;Print E
mov ah,02h
int 21h
ret
DISPLAY ENDP
end start
[6]
Program to add two 16 bit numbers
;Author Name: Mr.Sandip S. Hire
;Roll no:101318
.model small
.stack 100h
.data
msg db 10,13,"Addition Is:","$"
count db 4
num1 dw 0FFFFh
num2 dw 0FFFFh
result dw 0
.code
start:
mov ax,@data ; Initialize DS
mov ds,ax
mov ah,09h ; Printing msg
lea dx,msg
int 21h
mov ax,[num1] ; ax=num1
add ax,[num2] ; ax=ax+num2
mov result,ax
jnc next
mov dl,31h ;out 1 if CF=1
mov ah,02h
int 21h
next:
call DISPLAY
mov ah,4ch ;return back DOS
int 21h
DISPLAY PROC
loop1: mov cl,4
rol result,cl
mov dx,result
and dl,0fh ;Mask upper nibble to dl register
cmp dl,09h
jbe loop2
add dl,07h
loop2:
add dl,30h
mov ah,02h
int 21h
dec byte ptr [count]
jnz loop1
ret
DISPLAY endp
end start
[7]
;Program to subtract two 8 bit numbers
;Author Name: Mr. Sandip S. Hire
;Roll no:101318
MESSAGE MACRO msg ;Printing message
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 100h
.data
msg db 10,13,"The subtraction is: $"
num db 0FFh
num2 db 0AAh
temp db 0
.code
start:mov ax,@data ;Initializing DS
mov ds,ax
MESSAGE msg
mov al,num ;subtracting 8 bit operands
sub al,num2
mov temp,al
jnc forw
mov dl,31h ;Print 1 if CF=1
mov ah,02h
int 21h
forw:
call DISPLAY
mov ah,4ch ; return back to DOS
int 21h
DISPLAY PROC
mov al,temp ;FE
mov cl,04
rol al,cl ;EF
and al,0Fh ;0F
cmp al,9
jbe next
add al,07h
next:add al,30h
mov dl,al ;Print F
mov ah,02h
int 21h
mov al,temp ;FE
and al,0FH ;0E
cmp al,9
jbe next1
add al,07h
next1:add al,30h
mov dl,al ;Print E
mov ah,02h
int 21h
ret
DISPLAY ENDP
end start
[8]
;Program for 16 bit subtraction
;Author:Mr.Sandip S. Hire
;Roll_no 101318
.model small
.stack 100h
.data
msg db 10,13,"Substraction Is:","$"
count db 4
num1 dw 0FFFFh
num2 dw 0AAAAh
result dw 0
.code
start:
mov ax,@data ; Initialize DS
mov ds,ax
mov ah,09h ; Printing msg
lea dx,msg
int 21h
mov ax,[num1] ; ax=num1
sub ax,[num2] ; ax=ax+num2
mov result,ax
jnc next
mov dl,31h ;out 1 if CF=1
mov ah,02h
int 21h
next:
call DISPLAY
mov ah,4ch ;return back DOS
int 21h
DISPLAY PROC
loop1: mov cl,4
rol result,cl
mov dx,result
and dl,0fh ;Mask upper nibble to dl register
cmp dl,09h
jbe loop2
add dl,07h
loop2:
add dl,30h
mov ah,02h
int 21h
dec byte ptr [count]
jnz loop1
ret
DISPLAY endp
end start
[9]
;Program to perform 8bit Multiplication
;Author name:Mr. Sandip S. Hire
;Roll_no:101318
PRINT MACRO msg
mov ah,09h ;Printing message
lea dx,msg
int 21h
ENDM
.model small
.stack 256
.data
msg db 10,13,"The result of multiplication: $"
data1 db 0FFh
data2 db 0FFh
result dw 0
count db 4
.code
start:mov ax,@data ;Initializing data segment
mov ds,ax
PRINT msg
mov al,data1 ;adding operands
mul data2
mov result,ax
call DISPLAY
mov ah,4ch ;return to DOS
int 21h
DISPLAY PROC
loop1: mov cl,4
rol result,cl
mov dx,result
and dl,0fh ;Mask upper nibble to dl register
cmp dl,09h
jbe loop2
add dl,07h
loop2:
add dl,30h
mov ah,02h
int 21h
dec byte ptr [count]
jnz loop1
ret
DISPLAY endp
end start ;end of Program
[10]
;Program for 16 bit multiplication
;Author:Mr. Sandip S. Hire
;Roll_no 101318
.model small
.stack 100h
.data
msg db 10,13,"Multiplication Is:","$"
count db 4
num1 dw 0FFFFh
num2 dw 0AAAAh
result dw 0
result1 dw 0
.code
start:
mov ax,@data ; Initialize DS
mov ds,ax
mov ah,09h ; Printing msg
lea dx,msg
int 21h
mov ax,[num1] ; ax=num1
mul [num2] ; ax=ax*num2
mov result,dx
mov result1,ax
call DISPLAY
mov ax,result1
mov result,ax
mov [count],4
call DISPLAY
mov ah,4ch ;return back DOS
int 21h
DISPLAY PROC
loop1: mov cl,4
rol result,cl
mov dx,result
and dl,0fh ;Mask upper nibble to dl register
cmp dl,09h
jbe loop2
add dl,07h
loop2:
add dl,30h
mov ah,02h
int 21h
dec byte ptr [count]
jnz loop1
ret
DISPLAY endp
end start
[11]
;Program to perform 8 bit division
;Author name:Mr.Sandip S. Hire
;Roll_no:101318
PRINT MACRO msg
mov ah,09h ;Printing message
lea dx,msg
int 21h
ENDM
.model small
.stack 256
.data
msg db 10,13,"The quotient of division is: $"
msg1 db 10,13,"Remainder is: $"
data1 db 15h
data2 db 05h
result db 0
rem db 0
.code
start:mov ax,@data ;Initializing data segment
mov ds,ax
PRINT msg
mov al,data1 ;adding operands
mov ah,00h
div data2
mov result,al
mov rem,ah
call DISPLAY
PRINT msg1
mov al,rem
mov result,al
call DISPLAY
mov ah,4ch ;return to DOS
int 21h
DISPLAY PROC
mov al,result
and al,0F0h ; Displaying the first
mov cl,04 ; digit of result
rol al,cl
cmp al,09
jbe next ;jump below equal next
add al,07h
next:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,result ;Displaying the second
and al,0FH ;digit of result
cmp al,09
jbe next1
add al,07h
next1:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
DISPLAY ENDP
end start ;end of Program
[12]
;program for 16 bit division
;Author:Mr.Sandip S. Hire
;Roll_no 101318
.model small
.stack 100h
MESSAGE MACRO msg
mov ah,09h ; Printing msg
lea dx,msg
int 21h
endm
.data
msg db 10,13,"Division Is:","$"
msg1 db 10,13,"Reminder is:","$"
count db 4
num1 dw 0FFFFh
num2 dw 05555h
quo dw 0
rem dw 0
result dw 0
.code
start:
mov ax,@data ; Initialize DS
mov ds,ax
MESSAGE msg
mov dx,00h
mov ax,[num1] ; ax=num1
div [num2] ; ax=ax*num2
mov rem,dx
mov quo,ax
mov ax,quo
mov result,ax
call DISPLAY
MESSAGE msg1
mov ax,rem
mov result,ax
mov [count],4
call DISPLAY
mov ah,4ch ;return back DOS
int 21h
DISPLAY PROC
loop1: mov cl,4
rol result,cl
mov dx,result
and dl,0fh ;Mask upper nibble to dl register
cmp dl,09h
jbe loop2
add dl,07h
loop2:
add dl,30h
mov ah,02h
int 21h
dec byte ptr [count]
jnz loop1
ret
DISPLAY endp
end start
[13]
;Program to find even and odd number(0-9)
;Author Name: Mr. Sandip S. Hire
;Roll No : 101318
PRINT MACRO msg
lea dx,msg
mov ah,09h
int 21h
Endm
.model small
.stack 100h
.data
Inputmsg db 10,13,"Enter your number:-$"
Evenmsg db 10,13,"Your number is Even...$"
Oddmsg db 10,13,"Your number is Odd...$"
.code
start: mov ax,@data
mov ds,ax
PRINT Inputmsg
mov ah,01 ;Enter (0-9)
int 21h
and al,0Fh
rcr al,1
jc Oddno
PRINT Evenmsg
jmp skip
Oddno:PRINT Oddmsg
skip:mov ah,4ch
int 21h
end start
[14]
;Problem definition: -Program to check whether number is EVEN or ODD (00-FF)
;Author Name: - Mr. Sandip S. Hire
;Roll No:- 101318
MESSEGE MACRO msg
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 100h
.data
msg db 10,13,"Enter your Number: $"
evenno db 10,13,"Number is Even....$"
oddno db 10,13,"Number is Odd......$"
temp db ?
.code
start:
mov ax,@data
mov ds,ax
MESSEGE msg
call INPUT
mov al,temp
mov ah,00
mov bl,02
div bl
cmp ah,00
je even1
MESSEGE oddno
jmp skip
even1:MESSEGE evenno
skip:mov ah,4ch
int 21h
INPUT PROC NEAR
mov ah,01h
int 21h
cmp al,39h
jbe next2
sub al,07h
next2:sub al,30h
mov temp,al
mov cl,04h
rol temp,cl
mov ah,01h
int 21h
cmp al,39h
jbe next3
sub al,07h
next3:sub al,30h
add temp,al
ret
INPUT ENDP
end start
[15]
;Program to find average of n numbers
;Author Name: Mr. Sandip S. Hire
;Roll No : 101318
.model small
.stack 100
.data
msg db 10,13,"Average of Numbers is:-$"
array db 10H,11H,12H,13H,14H
array_len db 5
result db 0
.code
start: org 100H
mov ax,@data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov cl,array_len
lea si,array
xor ax,ax
back: adc al,[si]
inc si
dec cl
jnz back
mov bl,array_len
mov ah,00h
div bl
mov result,al
call DISPLAY
mov ah,4ch
int 21h
DISPLAY PROC
mov al,result
and al,0F0h ; Displaying the first
mov cl,04 ; digit of result
rol al,cl
cmp al,09
jbe next ;jump below equal next
add al,07h
next:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,result ;Displaying the second
and al,0FH ;digit of result
cmp al,09
jbe next1
add al,07h
next1:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
DISPLAY ENDP
end start
;Author Name: Mr. Sandip S. Hire
;Roll No : 101318
.model small
.stack 100
.data
msg db 10,13,"Average of Numbers is:-$"
array db 10H,11H,12H,13H,14H
array_len db 5
result db 0
.code
start: org 100H
mov ax,@data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov cl,array_len
lea si,array
xor ax,ax
back: adc al,[si]
inc si
dec cl
jnz back
mov bl,array_len
mov ah,00h
div bl
mov result,al
call DISPLAY
mov ah,4ch
int 21h
DISPLAY PROC
mov al,result
and al,0F0h ; Displaying the first
mov cl,04 ; digit of result
rol al,cl
cmp al,09
jbe next ;jump below equal next
add al,07h
next:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,result ;Displaying the second
and al,0FH ;digit of result
cmp al,09
jbe next1
add al,07h
next1:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
DISPLAY ENDP
end start
[16]
;Program to count number of positive and negative numbers
;Author Name:Mr.Sandip S.Hire
;Roll No:101318
PRINTMSG MACRO msg
mov ah,09h
lea dx,msg
int 21h
ENDM
.model small
.stack 100h
.data
msg1 db 10,13,"Number of positive numbers are: $"
msg2 db 10,13,"Number of negative numbers are: $"
array db 80h,20h,90h,40h,0FFh
count db 05
negcount db 0
poscount db 0
.code
start:
mov ax,@data
mov ds,ax
mov si,OFFSET array
mov bh,00 ; positive count
mov bl,00 ; negative count
back:
mov al,[si]
add al,00
js neg1 ;if SF=1 number is negative
inc bh ;increment count of positive no.
jmp skip
neg1: inc bl ;increment count of negative no.
skip: inc si
dec byte ptr [count]
jnz back
add bx,3030h
mov poscount,bh
mov negcount,bl
PRINTMSG msg1
mov dl,poscount
mov ah,02
int 21h
PRINTMSG msg2
mov dl,negcount
mov ah,02
int 21h
mov ah,4ch
int 21h
end start
[17]
;Program to add digits of a 3-digit number
;Author Name: Mr.Sandip S. Hire
;Id:101318 Date: 10/3/2017
PRINT MACRO msg
mov ah,09h
mov dx,OFFSET msg
int 21h
Endm
.model small
.stack 100
.data
msg db 10,13,"Enter any 3-digit number(0-9):","$"
msg1 db 10,13,"Sum of digits is: ","$"
count db 3
sum db 1 DUP(0)
.code
start: mov ax,@data
mov ds,ax
PRINT msg
back:mov ah,01h
int 21h
sub al,30h
add al,[sum]
daa
mov [sum],al
dec byte ptr [count]
jnz back
PRINT msg1
call DISPLAY
mov ah,4ch
int 21h
DISPLAY PROC NEAR
mov al,sum
mov cl,04
rol al,cl
and al,0Fh
cmp al,9
jbe next
add al,07h
next:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,sum
and al,0FH
cmp al,9
jbe next1
add al,07h
next1:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
DISPLAY Endp
end start
[18]
;PROGRAM TO PERFORM CONVERSION FROM TWO ASCII NUMBERS TO PACKED ;BCD
;AUTHOR NAME: MR.SANDIP S. HIRE
;DATE: 10/3/2017
.model small
.stack 100
.data
msg1 db 10,13,"The Packed BCD Number is: ","$"
Num1 db 35H
Num2 db 39H
PackBcd db 0
.code
start:
mov ax,@data
mov ds,ax
mov al,Num1
mov bl,Num2
and al,0Fh ;05
and bl,0Fh ;09
mov cl,04
rol al,cl ;50
or al,bl ;59
mov ah,4ch
int 21h
end start
[19]
comment !
Program to find largest number from the array containing 15 elements
Author Name: Mr. Sandip S. Hire
Id: 101318
!
.model small
.stack 100h
.data
ArraySet db 09h,04h,15h,18h,16h,11h,05h,20h,02h,01h
ArrayLen dw 0AH
largest db ?
.code
start: org 100h
mov ax,@data
mov ds,ax
mov cx,ArrayLen
mov bl,00h
mov si,OFFSET ArraySet
back:mov al,[si]
cmp al,bl
jc next
mov bl,al
next:inc si
loop back
mov largest,bl
mov ah,4ch
int 21h
end start
[20]
COMMENT %
PROGRAM TO EXCHANGE BLOCK OF DATA CONTAINING 10 ELEMENTS
FROM ONE MEMORY LOCATION TO ANOTHER
Author Name: Mr. Sandip S. Hire
Roll : 101318
%
.model small
.stack 100h
.data
src_array db 10h,11h,12h,13h,14h,15h
dest_array db 5 DUP(0)
.code
start: org 100h
mov ax,@data
mov ds,ax
mov cx,05
mov si,OFFSET src_array
mov di,OFFSET dest_array
back:mov al,[si]
mov [di],al
inc si
inc di
loop back
mov ah,4ch
int 21h
end start
[21]
; Program to demonstrate AAM instruction
; Author Name: Mr. Sandip S. Hire
; Roll : 101318
.model small
.stack 100h
.data
res dw 0
.code
start:
mov ax,@data
mov ds,ax
xor ah,ah
mov al,9
mov bl,5
mul bl
aam
or ax,3030h
mov [res],ax
mov dl,ah
mov ah,02h
int 21h
mov dx,res
mov ah,02h
int 21h
mov ah,4ch
int 21h
end start
Nice work
ReplyDelete