Documente Academic
Documente Profesional
Documente Cultură
AIM
To write the assembly language program for arithmetic operations using MASM
.
PROGRAM
ADDITION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB 0AH
N2
DB 7H
SUM DW ?
.CODE
BEGIN:
MOV AX,@DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
ADD AL,N2
MOVSUM,AX
MOV AH,4CH
INT 21H
END BEGIN
OUTPUT
;SERVICE NUMBER
; EXIT TO DOS
SUBTRACTION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB
0AH
N2
DB
07H
RES DW ?
.CODE
BEGIN:
MOV AX, @DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
MOV BL,N2
SUB AL,BL
MOV RES,AX
MOV AH,4CH
;SERVICE NUMBER
INT 21H
;EXIT TO DOS
END BEGIN
OUTPUT
MULTIPLICATION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB 02H
N2
DB 04H
RES DW ?
.CODE
BEGIN: MOV
AX,@DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
MUL N2
MOV RES,AX
MOV AH,4CH
;SERVICE NUMBER
INT 21H
;EXIT TO DOS
END BEGIN
OUTPUT
DIVISION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB 0AH
N2
DB 02H
RES DW ?
.CODE
BEGIN: MOV
AX,@DATA
MOV DS, AX
MOV H,00
MOV AL,N1
DIV N2
MOV RES,AX
MOV AH,4CH
;SERVICE NUMBER
INT 21H
;EXIT TO DOS
END BEGIN
OUTPUT
RESULT
Thus the assembly language programs for arithmetic operations were executed
using MASM successfully.
LOGICAL OPERATIONS
AIM
To write the assembly language program for logical operations using MASM
PROGRAM
AND OPERATION
.MODEL SMALL
.STACK 100H
.DATA
N1
N2
SUM
.CODE
BEGIN: MOV
DB12H
DB 11H
DW ?
AX,@DATA
MOV
MOV
MOV
AND
MOV
MOV
INT
END
DS, AX
AH,00
AL,N1
AL,N2
SUM,AX
AH,4CH
21H
BEGIN
OUTPUT
OR OPERATION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB
N2
DB
RES DW
12H
11H
?
;SERVICE NUMBER
;EXIT TO DOS
.CODE
BEGIN: MOV
AX, @DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
OR
AL,N2
MOV RES,AX
MOV AH,4CH
;SERVICE NUMBER
INT 21H
;EXIT TO DOS
END BEGIN
OUTPUT
NOT OPERATION
.MODEL SMALL
.STACK 100H
.DATA
N1
DB 12H
RES DB
?
.CODE
BEGIN:
MOV
MOV
MOV
NOT
MOV
MOV
INT
END
OUTPUT
MOV AX,@DATA
DS, AX
AH,00
AL,N1
AL
RES,AL
AH,4CH
;SERVICE NUMBER
21H
;EXIT TO DOS
BEGIN
2s COMPLEMENT
.MODEL SMALL
.STACK 100H
.DATA
N1
RES
.CODE
BEGIN:
MOV
MOV
MOV
NOT
INC
MOV
MOV
INT
END
OUTPUT
DB 12H
DB
?
MOV AX,@DATA
DS, AX
AH,00
AL,N1
AL
AL
RES,AL
AH,4CH
;SERVICE NUMBER
21H
;EXIT TO DOS
BEGIN
RESULT
Thus the assembly language programs for logical operations were executed using
MASM successfully.
TRANSFER A DATA BLOCK WITH OVERLAP
AIM
To write the assembly language program for transfer a block with overlap of data
using MASM
.
PROGRAM
.MODEL SMALL
.DATA
Array DB 11h,22h,33h,44h,55h
Count DW 0005h
.STACK 100h
.CODE
MOV AX,@DATA
MOV ES,AX
MOV DS,AX
LEA
SI,Array
ADD SI,Count
MOV CX,Count
DEC
SI
MOV DI,SI
ADD DI,2h
STD
REP MOVSB
MOV AH,4Ch
INT
END
OUTPUT
21h
RESULT
Thus the assembly language program for transfer a block of data with overlap was
executed using MASM successfully.
RESULT
Thus the assembly language program for transfer a block of data was executed
using MASM successfully.
SORTING
AIM
To write the assembly language program to sort the numbers in ascending and
descending order using MASM
PROGRAM FOR ASCENDING ORDER
.MODEL SMALL
.STACK 100H
DATA SEGMENT
A DB 39H,78H,56H,47H
SIZ DW $-A
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV BX,SIZ
DEC BX
OUTLUP: MOV CX,BX
MOV SI,0H
INLOOP: MOV AL,A[SI]
INC SI
CMP AL,A[SI]
JB GO1
XCHG AL,A[SI]
MOV A[SI-1],AL
GO1: LOOP INLOOP
DEC BX
JNZ OUTLUP
mov ah,4ch
int 21h
CODE ENDS
END START
OUTPUT
DW $-A
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV BX,SIZ
DEC
BX
SI
CMP AL,A[SI]
JNB
GO1
XCHG
AL,A[SI]
MOV A[SI-1],AL
GO1: LOOP INLOOP
DEC
BX
JNZ
OUTLUP
MOV AH,4CH
INT
CODE
21H
ENDS
END START
OUTPUT
RESULT
Thus the assembly language program for program to sort the numbers in ascending
and descending order was executed using MASM successfully.
DB
PASSWD
DB
'BHARATHI'
COUNT
DW
CORRECT
DB
NOTCORRECT
DB
'INVALID$'
.CODE
BEGIN:
MOV AX,@DATA
MOV DS,AX
MOV CX, COUNT ;CX=8
MOV BX,OFFSETPASSWD
; BX POINTS TO PASSWD
MOV AH,08H;SERVICE NO
INT 21H
CMP AL,[BX]
JNE ERROR1
INC
BX
LOOP AGAIN
MOV DX,OFFSET CORRECT
MOV AH,09H
INT
21H
JMP OVER
ERROR1:
MOV AH,09H
INT
OVER:
21H
MOV AH,4CH
INT
21H
END BEGIN
OUTPUT
RESULT
Thus the assembly language program for verifying the password was executed
using MASM successfully.
DISPLAY THE MEMORY SIZE
AIM
To write the assembly language programs for displaying the memory size.
PROGRAM
.MODEL SMALL
.STACK 100H
PRNSTR MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
ENDM
DATA SEGMENT
ANS DB 6 DUP(' '), '$'
BUF1 DB "MEMORY AVAILABLE : $"
BUF2 DB " KILOBYTES$"
DATA ENDS
CODE SEGMENT
ASSUME
CS:CODE, DS:DATA
START :
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AX, 0000H
INT 12H
MOV CX, 000AH
MOV SI, OFFSET ANS + 5
AGAIN :
MOV DX, 0000H
DIV CX
ADD DL, 30H
MOV BYTE PTR [SI], DL
DEC SI
CMP AX, 0000H
JNZ AGAIN
PRNSTR
PRNSTR
PRNSTR
BUF1
ANS
BUF2
OUTPUT
RESULT
Thus the assembly language program for displaying the memory size was executed
using MASM successfully.
DISPLAY THE CURRENT DATE AND TIME
AIM
To write the assembly language program for displaying the current date and time
using MASM.
PROGRAM
display1
macro arg
lea
dx,arg
mov ah,09h
int
21h
endm
ndisp macro arg
local l1,l2
mov ax,arg
mov cx,00
mov bx,0ah
l1:
mov dx,0000h
div
bx
push dx
inc
cx
cmp ax,00h
jnz
l1
l2:
pop
dx
add
dx,30h
mov ah,02h
int
21h
loop l2
endm
.model small
.stack 100h
.data
msg1 db 13d,10d,'The time is $'
str1
db ":$"
msg2 db 13d,10d,'The date is $'
str2
db "-$"
hrs
db
?
min db
?
sec
db
?
yr
dw
?
mnth db
?
dat
db
?
.code
start:
mov ax,@data
mov ds,ax
mov ah,2ch
int 21h
mov hrs,ch
mov min,cl
mov sec,dh
display1 msg1
mov ah,00h
mov al,hrs
ndisp ax
display1 str1
mov ah,00h
mov al,min
ndisp ax
display1 str1
mov ah,00h
mov al,sec
ndisp ax
mov ah,2ah
int
21h
mov yr,cx
mov mnth,dh
mov dat,dl
display1 msg2
mov ah,00
mov al,dat
ndisp ax
display1 str2
mov ah,00
mov al,mnth
ndisp ax
display1 str2
mov ax,yr
ndisp ax
mov ax,4c00h
int
21h
end
start
OUTPUT
RESULT
Thus the assembly language program for displaying the current date and time was
executed using MASM successfully.
COUNTER AND TIME DELAY
AIM
To write the assembly language program for implementing a counter and a time delay
using MASM
PROGRAM
;COUNTER AND TIME DELAY
.MODEL SMALL
.STACK 100h
.DATA
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2: MOV AH,4CH
INT 21H
END
OUTPUT
RESULT
Thus the assembly language program for implementing a counter and a time delay
was executed using MASM successfully.
DECIMAL ARITHMETIC
AIM
To write the assembly language program for decimal arithmetic using MASM
PROGRAM FOR ADDITION
.MODEL SMALL
.STACK 100H
.DATA
N1DW 000BH
N2DW 0008H
RESDW ?
.CODE
MOVAX,@DATA
MOVDS,AX
MOV AX,N1
ADD AX,N2
DAA
INT 3
MOV AH,4CH
INT 21H
END
OUTPUT
END
OUTPUT
RESULT
Thus the assembly language program for decimal arithmetic was executed using
MASM successfully.
DISPLAY A STRING
AIM
To write the assembly language program to display the string using MASM
PROGRAM
; Program to display a string-8086
.model small
.stack 100h
.data
Text db 'hello world by bharathi $'
.code
begin:
mov
ax,@data
mov
ds,ax
mov
dx , offset text
mov
ah,09h
int
21h
mov
ah,4ch
;service no
int
21h
end
begin
; to exit to dos
OUTPUT
RESULT
Thus the assembly language program to display the string was executed using
MASM successfully.
DISPLAYING REVERSE OF THE STRING
AIM
To write the Assembly Language Program for displaying reverse of the string using
MASM
PROGRAM
;string reverse Program
.model small
.stack 100h
.data
text1
db
'Hello world$'
text2
db
13 dup(?)
count dw
.code
13
begin: mov
ax,@data
mov
ds,ax
mov
es,ax
mov
cx,count
;cx=13
mov
si,0
mov
di,0
add
di,count
dec
di
si
dec di
loop again
mov ah,4ch
int
21h
end begin
OUTPUT
;service number
;exit to dos
RESULT
Thus the assembly language program for displaying reverse of the string was
executed using MASM successfully.
COMPARE TWO STRING
AIM
To write the assembly language program for comparing two string.
PROGRAM
.MODEL SMALL
.STACK 100H
DATA SEGMENT
STR1 DB "ENTER FIRST STRING HERE ->$"
STR2 DB "ENTER SECOND STRING HERE ->$"
STR11 DB "FIRST STRING : ->$"
STR22 DB "SECOND STRING: ->$"
INSTR1 DB 20 DUP("$")
INSTR2 DB 20 DUP("$")
NEWLINE DB 10,13,"$"
N DB ?
S DB ?
MSG1 DB "BOTH STRING ARE SAME$"
MSG2 DB "BOTH STRING ARE DIFFERENT$"
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,INSTR1
LEA DI,INSTR2
;GET STRING
MOV AH,09H
LEA DX,STR1
INT 21H
MOV AH,0AH
MOV DX,SI
INT 21H
MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,09H
LEA DX,STR2
INT 21H
MOV AH,0AH
MOV DX,DI
INT 21H
MOV AH,09H
LEA DX,NEWLINE
INT 21H
;PRINT THE STRING
MOV AH,09H
LEA DX,STR11
INT 21H
MOV AH,09H
LEA DX,INSTR1+2
INT 21H
MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,09H
LEA DX,STR22
INT 21H
MOV AH,09H
LEA DX,INSTR2+2
INT 21H
MOV AH,09H
LEA DX,NEWLINE
INT 21H
;STRING COMPARISION
MOV BX,00
MOV BL,INSTR1+1
MOV BH,INSTR2+1
CMP BL,BH
JNE L1
ADD SI,2
ADD DI,2
L2:MOV BL,BYTE PTR[SI]
CMP BYTE PTR[DI],BL
JNE L1
INC SI
INC DI
CMP BYTE PTR[DI],"$"
JNE L2
MOV AH,09H
LEA DX,MSG1
INT 21H
JMP L5
L1:MOV AH,09H
LEA DX,MSG2
INT 21H
L5:
MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
OUTPUT
RESULT
Thus the assembly language program for comparing two strings was executed using
MASM successfully.
MOVCH, 00H
MOV AX, 0000H
CALC :
MUL MULTIPLIER
MOVBL, BYTE PTR [SI]
MOVBH, 00H
ADD AX, BX
INCSI
LOOPCALC
MOVSI, OFFSET BUF4 + 2
MOVBX, AX
MOV DX, 0000H
MOV AX, 1000H
CONVERT :
MOV CX, 0000H
CONV :
CMPBX, AX
JB CONT3
SUBBX, AX
INC CX
JMPCONV
CONT3 :
CMP CX, 0AH
JB CONT4
ADD CL, 37H
JMP CONT5
CONT4 :
ADD CL, 30H
CONT5 :
MOV BYTE PTR [SI], CL
INCSI
MOV CX, 0010H
DIV CX
CMP AX, 0000H
JNZ CONVERT
MOV BYTE PTR [SI], '$'
PRNSTR BUF3
PRNSTR BUF4+2
STOP :
MOV AX, 4C00H
INT 21H
CODE ENDS
END START
OUTPUT
RESULT
Thus the assembly language program for converting decimal number to
hexadecimal number was executed using MASM successfully.