0% found this document useful (0 votes)
58 views62 pages

R20 MP&MC Lab Manual

The document provides instructions for writing and executing assembly language programs using MASM software on a PC. It describes 22 steps to set up the environment, write and save programs, assemble and link the code, debug the executable, and view register values and memory locations during execution. The document also provides examples of assembly language programs that perform 16-bit arithmetic operations like addition, subtraction, multiplication, and division on unsigned and signed hexadecimal numbers.

Uploaded by

Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views62 pages

R20 MP&MC Lab Manual

The document provides instructions for writing and executing assembly language programs using MASM software on a PC. It describes 22 steps to set up the environment, write and save programs, assemble and link the code, debug the executable, and view register values and memory locations during execution. The document also provides examples of assembly language programs that perform 16-bit arithmetic operations like addition, subtraction, multiplication, and division on unsigned and signed hexadecimal numbers.

Uploaded by

Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 62

Dept of E.C.

E Microprocessors & Microcontrollers LAB

INTRODUCTIONTOMASM

1. Switchonthecomputer.
2. Select“start->run”button.
3. Type“cmd”&clickok.
4. Pressalt+enterto getfullscreen.
5. Typecd.. &press “enter” button.
6. Repeatstep4.
7. Type ”cdMASM(or)Term86E” &pressenterbutton.
8. Type“edit” &press“enter”button
9. Typetheprogram&select“file->save as”
10. Savethefilewithanexetenxion“.asm”,(ex1.asm)
11. Select“file->exit”
12. Typethecommand“MASM(or)Term86Eprogramname.asm” &pressenter4 times.
13. Check if any errors / warnings are there in ur program ..if any errors are there
modifytheprogram bygivingthe command”edit programname.asm”
14. Againsavetheprogram.
15. Repeatstep12untiluget0errors&0 warnings.
16. Thentypethecommand“linkprogramname.obj” (ex1.obj)&pressenter4times
17. Thentypethecommand“debugprogramname.exe”(ex1.exe)&pressenter.
18. Givethecommand”u“ tonotethe address&opcodeof program.
19. Give the command” t“to check the registers update after each & every
instructionexecution,repeat this process until theprogram ends.
20. If theRESULT isin memorylocation givethecommand “dds:0000”
21. Toquitfromdebuggingmodetypethecommand“q”
22. Repeatthesameprocessfromstep 8toexecutethenextprogram.

SITS, KADAPA Page1


Dept of E.C.E Microprocessors & Microcontrollers LAB

A. PROGRAMS FOR 16BIT ARITHMETIC OPERATIONS


ADDITION&SUBTRACTION

Aim: To Write an Assembly Language Program to perform addition & subtract two 16-BitNumbers.

Apparatus:

Software: MASM(or)TERM 86E

Hardware: PC, Key Board / 8086Trainer Kit, R.P.S

Procedure:

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

Adress Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

MOV AX,DATA ;Copy Data Segment Starting


AddressintoAXRegister
START:
MOV DS,AX ;CopytheContentofAXintoDS

MOV AX,X ;CopytheContentsofXintoAXRe


gister.

SITS, KADAPA Page2


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV BX,Y ;Copy the Contents ofY into


BXRegister.
ADD AX,BX ;AddtheContentsofAXwithBX.

MOV Z,AX ;Copy the Contents of AX into


memorylocationpointedbyZ.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input: AX=4521H, BX=1324H

Output: AX =5645H

SITS, KADAPA Page3


Dept of E.C.E Microprocessors & Microcontrollers LAB

Subtraction Program:

Address Op code Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
MOV AX,X ;CopytheContentsofXintoAXRe
gister.
MOV BX,Y ;Copy the Contents ofY into
BXRegister.
SUB AX,BX ;SubtracttheContentsofAXwithBX.

MOV Z,AX ;Copy the Contents of AX into


memorylocationpointedbyZ.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input: AX=4521H, BX=1324H

Output: AX =31FDH

RESULT: The Assembly Language Program to add &subtract two 16-bit numbers was executed successfully
by using MASM Software.

SITS, KADAPA Page4


Dept of E.C.E Microprocessors & Microcontrollers LAB

B. 16-BITUNSIGNED& SIGNEDMULTIPICATION&DIVISION

Aim: To Write an Assembly Language Program to Perform Multiplication and Division of signed
and unsigned Hexa decimal numbers.

Apparatus:

Software: MASM(or)TERM 86E

Hardware: PC, Key Board, 8086TrainerKit, R.P.S

Procedure:

Double click on DOS BOX (0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masm file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and enter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Unsigned Multiplication Program:

Address Op code Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;Copy Data Segment Starting


Address into AX Register
MOV DS,AX ;Copy the Content of AX into DS
MOV AX,X ;Copy the Contents of X into AX
Register.
MOV BX,Y ;Copy the Contents of Y into BX
Register.
MUL BX ;Multiply the Contents of AX with BX.

SITS, KADAPA Page5


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV SI,OFFSETZ ;Copy the Address pointed by Z into SI.

MOV [SI],AX ;Copy the Contents of AX into Memory


location pointed by SI.

ADD SI,02H ;Add02toSIRegister.

MOV [SI],DX ;Copy the Contents of DX into


memorylocationpointedbySI.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART
Input: AX=4521H, BX=1324H

Output: DX =052BH&AX =2BA4H (MultiplicationOf 4521H*1324H=052B2BA4H)

SITS, KADAPA Page6


Dept of E.C.E Microprocessors & Microcontrollers LAB

UN SIGNED DIVISION Program:

Address Op code Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

START: ;CopyData Segment Starting


MOV AX,DATA AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
MOV AX,X ;CopytheContentsofXintoAXRe
gister.
MOV BX,Y ;Copy the Contents ofY into
BXRegister.
DIV BX ;DividetheContentsofAXwithBX.

MOV SI,OFFSETZ ;CopytheAddresspointedbyZintoSI.

MOV [SI],AX ;Copy the Contents of AX into


MemorylocationpointedbySI.

ADD SI,02H ;Add02toSIRegister.

MOV [SI],DX ;Copy the Contents of DX into


memorylocationpointedbySI.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input:AX=4521H, BX=1324H

Output:DX =0BB5H(Remainder)&AX =0003H(Quotient)

SIGNEDMULTIPLICATIONProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
XOR AX,AX ;ClearContentsofAXRegister.

SITS, KADAPA Page7


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV AX,X ;CopytheContentsofXintoAXRe


gister.
MOV BX,Y ;Copy the Contents ofY into
BXRegister.
NEG BX ;Perform2’sComplementofBX.
CWD ;ConvertWordintoDoubleWord
IMUL BX ;MultiplytheContentsofAXwithBX
IncludingSign.
MOV SI,OFFSETZ ;CopytheAddresspointedbyZintoSI.

MOV [SI],AX ;CopytheContentsofAXintoMemory


locationpointedbySI.
ADD SI,02H ;Add02toSIRegister.
MOV [SI],DX ;Copy the Contents of DX into
memorylocationpointedbySI.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input:AX=4521H, BX=1324H

Output:DX =FAD4H&AX =D45CH(Multiplicationof4521H*-1324H=FAD4D45CH)

SIGNEDDIVISIONProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATADATASEGMENT

X DW
4521HY DW
1324HZDW?

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
XOR AX,AX ;ClearContentsofAXRegister.
MOV AX,X ;CopytheContentsofXintoAXRe
gister.
MOV BX,Y ;Copy the Contents ofY into
BXRegister.
NEG BX ;Perform2’sComplementofBX.

CWD ;ConvertWordintoDoubleWord

IDIV BX ;DividetheContentsofAXwithBX
IncludingSign.
MOV SI,OFFSETZ ;CopytheAddresspointedbyZintoSI.

MOV [SI],AX ;CopytheContentsofAXintoMemory


locationpointedbySI.
ADD SI,02H ;Add02toSIRegister.

SITS, KADAPA Page8


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV [SI],DX ;Copy the Contents of DX into


memorylocationpointedbySI.

INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input:AX=4521H, BX=1324H

Output:AX = FFFDH
(QUOTIENT)DX=0BB5H(RE
MAINDER)

RESULT: The Assembly Language Programto Perform Multiplication and Division of signed
andunsignedHexadecimalnumberswas successfullyexecuted.

SITS, KADAPA Page9


Dept of E.C.E Microprocessors & Microcontrollers LAB

C. FACTORIAL,SQUARE& CUBEOFA NUMBER

Aim:To Writean ALP tofindsquare,cubeandfactorialof agiven number.

Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

FactorialProgram:

Adress Opcode Label Mnemonics Operands Comments

ASSUME

CS:CODE,DS:DATADATASE

GMENT
NDB04H
RES DW?
DATAENDS

CODESEGMENT

MOV AX,DATA ;CopyDataSegmentStarting


START: AddressintoAXRegister
MOV DS,AX ;CopytheContent ofAXinto
DS
XOR AX,AX ;ClearContentsofAXRegister.

MOV AL, N ;CopytheContentsofXintoAXRe


gister.
XOR BX,BX ;ClearContentsofBXRegister.

MOV BL,AL ;Copy Contents of AL in


toRegisterBL

SITS, KADAPA Page10


Dept of E.C.E Microprocessors & Microcontrollers LAB

UP: DEC BL ; Decrement BLby01

CMP BX,01 ;CompareBX register contentswith


01H

JZ EXIT ; JumptoLabelEXITifZF=1

MUL BL ;MultiplycontentsofALwithBL

JMP UP ;JumptoLabelUP

EXIT: MOV RES,AX ; Copy the Factorial of N


intoMemoryLocationRES.

INT 21H ;ReturntoDOSPrompt

CODE
ENDSENDS
TART

Input:N=[0000]=04H

Output:RES=[0001]=18H

SITS, KADAPA Page11


Dept of E.C.E Microprocessors & Microcontrollers LAB

SquareofaNumberProgram:

Adress Opcode Label Mnemonics Operands Comments

ASSUME

CS:CODE,DS:DATADATASE

GMENT
XDB08H
SQRDW(?)
DATAENDS

CODESEGMENT

MOV AX,DATA ;CopyData Segment Starting


START: AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXinto
DS
XOR AX,AX ;ClearContentsofAXRegister.

MOV AL, X ;CopytheContents


ofXintoAXRegister.
MUL AL ;MultiplycontentsofALwith AL
&RESULTisstored inAX.
MOV SQR,AX ;Copy the contents of AX into
SQRMemoryLocation

INT 21H ;ReturntoDOSPrompt

CODE
ENDSENDS
TART

Input:X=[0000]=08H

Output:SQR=[0001]=40H

CubeofaNumberProgram:

Adress Opcode Label Mnemonics Operands Comments

ASSUME

CS:CODE,DS:DATADATASE

GMENT
XDB08H
CUBEDW(?)
DATAENDS

CODESEGMENT

MOV AX,DATA ;CopyData Segment Starting


START: AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXinto
DS
XOR AX,AX ;ClearContentsofAXRegister.

MOV AL, X ;CopytheContentsofXintoAXRe


gister.
MOV BL,AL ;Copy the Contents of Register
BLintoALRegister.
MUL BL ;MultiplycontentsofALwithBL
&RESULTisstored inAX.

SITS, KADAPA Page12


Dept of E.C.E Microprocessors & Microcontrollers LAB

MUL BL ;MultiplycontentsofALwithBL
&RESULTisstored inAX.
MOV CUBE,AX ;Copy the contents of AX into
SQRMemoryLocation

INT 21H ;ReturntoDOSPrompt

CODE
ENDSENDS
TART

Input:X=[0000]=08H

Output:AX=200H

RESULT: The Assembly Language Programto find square, cube and factorial of a given
numberwassuccessfullyexecuted.

SITS, KADAPA Page13


Dept of E.C.E Microprocessors & Microcontrollers LAB

3. PROGRAMS INVOLVING BIT MANIPULATION

INSTRUCTIONSA.Data isPositive orNegative

Aim:ToWriteanAssemblyLanguageProgramtofindthegivendataispositiveornegative.

Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

Adress Opcode Label Mnemonics Operands Comments


ASSUME

CS:CODE,DS:DATADATASE

GMENT

NUM DB12H

MES1DB10,13,"DATAISPOSITIVE$"

MES2DB10,13,"DATAISN
EGATIVE$"

DATAENDS
CODESEGMENT

MOV AX,DATA ;CopyDataSegment Starting


START: AddressintoAXRegister

SITS, KADAPA Page14


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV DS,AX ;CopytheContentofAXinto


DS
XOR AX,AX ;ClearContentsofAXRegister.

MOV AL,NUM ;Copy the Contents ofNUM


intoAXRegister.
ROL AL,01 ; Rotate Left the contents of AL
by1 time.
JC NEGA ;JumptoLabelNEGAifCY=1

MOV DX,OFFSETMES1 ;Copy the offset ofMES1 into


DXRegister
JMP EXIT ;JumotoLabelExit

NEGA: MOV DX,OFFSETMES2 ;Copy the offset ofMES2 into


DXRegister
EXIT: MOV AH,09H ; Display the mesaage or
stringwhoseaddressisgiveninD
INT 21H X.

MOV AH,4CH ;Terminate the Current Process


&Return toDOSPrompt

INT 21H

CODE
ENDSENDS
TART

Input:NUM=[0000]= 08H

Output:DATAISPOSITIVE

RESULT: The Assembly Language Programto find the given data is positive or
negativewassuccessfullyexecuted.

SITS, KADAPA Page15


Dept of E.C.E Microprocessors & Microcontrollers LAB

B.Data is EVEN orODD

Aim:ToWriteanAssemblyLanguageProgramtofind thegivendataisEvenorOdd
Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

Adress Opcode Label Mnemonics Operands Comments


ASSUME

CS:CODE,DS:DATADATASE

GMENT

NUM DB15H

MES1DB10,13,"NUMBERISEVEN$"

MES2 DB 10,13,"NUMBER IS

ODD$"DATAENDS
CODESEGMENT

MOV AX,DATA ;CopyData Segment Starting


START: AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXinto
DS

SITS, KADAPA Page16


Dept of E.C.E Microprocessors & Microcontrollers LAB

XOR AX,AX ;ClearContentsofAXRegister.

MOV AL,NUM ;Copy the Contents ofNUM


intoAXRegister.
TEST AL,01 ;PerformANDoperationbetweenco
ntentsofAL&01H
JNZ EXIT ;JumptoLabelEXITifZF=0

MOV DX,OFFSETMES1 ;Copy the offset of MES1 into


DXRegister & Display the
MOV AH,09H stringpointedbyMES1on Screen

INT 21H

EXIT: MOV DX,OFFSETMES2 ;Copy the offset of MES1 into


DXRegister & Display the
MOV AH,09H stringpointedbyMES1on Screen

INT 21H

LAST: MOV AH,4CH ;Terminate the Current Process


&Return toDOSPrompt

INT 21H

CODE
ENDSENDS
TART

Input:NUM=[0000]= 15H

Output:DATAISEVEN.

RESULT:The Assembly Language Programto find the given data is Even or Oddwas
successfullyexecuted.

SITS, KADAPA Page17


Dept of E.C.E Microprocessors & Microcontrollers LAB

C.COUNTINGLOGICAL0s&1s

Aim:ToWriteanAssemblyLanguageProgramtofind Logical onesandzerosinagiven data


Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

Adress Opcode Label Mnemonics Operands Comments


ASSUME

CS:CODE,DS:DATADATASE

GMENT

X DB

02AHONE

DB?

ZERODB?

DATAENDS
CODESEGMENT

MOV AX,DATA ;CopyDataSegmentStarting


START: AddressintoAXRegister
MOV DS,AX ;CopytheContent ofAXinto
DS

SITS, KADAPA Page18


Dept of E.C.E Microprocessors & Microcontrollers LAB

XOR AX,AX ;ClearContentsofAXRegister.

MOV AL,X ;Copy the Contents


ofmemorylocationXintoAXRegister.
MOV BL,08 ; copy08intoregisterBL

MOV CL,01 ;copy01 intoregisterCL

UP: ROR AL,CL ;RotateRightthecontentsofALbyCLti


mes
JNC DOWN ;JumptoLabelDown ifCY=0

INC ONE ;IncrementthememorylocationO


NEcontentsby1.
JMP DOWN1 ;JumptoLabelDown1

DOWN: INC ZERO ;IncrementthememorylocationO


NEcontentsby1.
DOWN1 DEC BL ; Decrement BL Register
: Contentsby01
JNZ UP ; JumptoLabelUPifZF= 0

MOV AH,4CH ;Terminate the Current Process


&Return toDOSPrompt

INT 21H

CODE
ENDSENDS
TART

Input:X=[0000]=2AH= (0010 1010)2

Output:ONE=[0001]=03
ZERO= [0002] =05

RESULT: The Assembly Language Programto find Logical ones and zeros in a given data wassuccessfullyexecut

SITS, KADAPA Page19


Dept of E.C.E Microprocessors & Microcontrollers LAB

3.PROGRAMSONARRAYS FOR8086

AdditionofNno‘s.
Aim:ToWritean AssemblyLanguageProgramtofind AdditionofNNumbers.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

LARGESTNUMBERProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUMECS:CODE,DS:D
ATA

DATA

SEGMENTARRA

YDB
29H,15H,32H,08H,45H,17H

COUNT EQU

06HDATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS

SITS, KADAPA Page20


Dept of E.C.E Microprocessors & Microcontrollers LAB

XOR AX,AX ;ClearContentsofAXRegister.


XOR BX,BX ;ClearContentsofBXRegister.
MOV CL,COUNT-1
;Copy05HintoCLRegister
MOV SI,OFFSET ;Copy the Address Pointed by
ARRAY ARRAYintoSIRegister.

MOV AL,[SI] ;Copy the Contents of


MemoryLocationpointedbySIRegisteri
nto
ALRegister.
INC SI ;IncrementSIContentsbyone.

L1: MOV BL,[SI] ;CopytheContentsofMemory


Location pointed by SI Register into
BLRegister.
ADC AL,BL ;AddcontentsofAL&BLwithcarry.

INC SI ;IncrementSIContentsbyone.

DEC CL ;DecrementCLContentsbyone.
JNZ L2 ;JumptoL2 ifCLis notequaltoZero.

INT 21H ;Terminate the Current Process


&Return toDOSPrompt

CODE
ENDSENDS
TART

Input:LIST
[0000]=29H
[0001]=15H
[0002]=32H
[0003]=08H
[0004]=45H
[0005]=17H

Output:AX=00D4H

RESULT: The Assembly Language Programto findAddition of N numberswas


successfullyexecuted.

SITS, KADAPA Page21


Dept of E.C.E Microprocessors & Microcontrollers LAB

SITS, KADAPA Page22


Dept of E.C.E Microprocessors & Microcontrollers LAB

A. LARGEST/SMALLESTNUMBER
Aim:ToWriteanAssemblyLanguageProgramtofindLargest/ Smallestnumber.

Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

LARGESTNUMBERProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUMECS:CODE,DS:DATAD

ATASEGMENT

LIST
DB29H,15H,32H,08H,45H,17HC
OUNTEQU06H

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
XOR AX,AX ;ClearContentsofAXRegister.
MOV CL,COUNT-1 ;Copy05HintoCLRegister

MOV SI,OFFSETLIST ;CopytheAddressPointedbyLIST


intoSIRegister.
MOV AL,[SI] ;Copy the Contents of
MemoryLocationpointedbySIRegisteri
nto
ALRegister.

SITS, KADAPA Page23


Dept of E.C.E Microprocessors & Microcontrollers LAB

CMP AL,[SI+1] ;ComparetheContentsofALwith


L2: Contents ofmemory location
pointedbySI.
JNC L1 ;JumptoL1ifCarryFlagisNotSet.

MOV AL,[SI+1] ;CopytheContentsofmemorypointed


bySI+1intoAL.
INC SI ;IncrementSIContentsbyone.
L1:
DEC CL ;DecrementCLContentsbyone.
JNZ L2 ;JumptoL2 ifCLis notequaltoZero.
INT 21H ;ReturntoDOSPrompt.
CODE
ENDSENDS
TART

Input:LIST
[0000]=29H
[0001]=15H
[0002]=32H
[0003]=08H
[0004]=45H
[0005]=17H

Output:AL=45H
SMALLESTNUMBERProgram

Adress Opcode Label Mnemonics Operands Comments


ASSUMECS:CODE,DS:DATAD

ATASEGMENT

LIST
DB29H,15H,32H,08H,45H,17HC
OUNTEQU06H

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
XOR AX,AX ;ClearContentsofAXRegister.
MOV CL,COUNT-1 ;Copy05HintoCLRegister

MOV SI,OFFSETLIST ;CopytheAddressPointedbyLIST


intoSIRegister.
MOV AL,[SI] ;Copy the Contents of
MemoryLocationpointedbySIRegisteri
nto
ALRegister.
CMP AL,[SI+1] ;Compare the Contents of AL
L2: withContentsofmemorylocationpointed
bySI.
JC L1 ;JumptoL1ifCarryFlagisSet.

MOV AL,[SI+1] ;CopytheContentsofmemorypointed


bySI+1intoAL.
INC SI ;IncrementSIContentsbyone.
L1:
DEC CL ;DecrementCLContentsbyone.
JNZ L2 ;JumptoL2 ifCLis notequaltoZero.
INT 21H ;ReturntoDOSPrompt.
CODE
ENDSENDS

SITS, KADAPA Page24


Dept of E.C.E Microprocessors & Microcontrollers LAB

TART

Input:LIST
[0000]=29H
[0001]=15H
[0002]=32H
[0003]=08H
[0004]=45H
[0005]=17H

Output:AL=08H

RESULT: The Assembly Language Programto findLargest& Smallest numberwas


successfullyexecuted.

SITS, KADAPA Page25


Dept of E.C.E Microprocessors & Microcontrollers LAB

B. ASCENDINGORDER / DESCENDINGORDER
Aim:To Write an Assembly Language Programto Sort the given numbers in Ascending
/DescendingOrder.

Apparatus:

Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

ASCENDINGORDERProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUMECS:CODE,DS:DATAD

ATASEGMENT

LIST
DB29H,15H,32H,08H,45H,17HC
OUNTEQU06H

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
XOR AX,AX ;ClearContentsofAXRegister.
MOV DL,COUNT-1 ;Copy05HintoDLRegister

MOV CL,DL ;CopytheContentsofDLintoCL.


UP2:
MOV SI,OFFSETLIST ;CopytheAddressPointedbyLIST
intoSIRegister.
UP1: MOV AL,[SI] ;Copy the Contents of
MemoryLocationpointedbySIRegisteri
SITS, KADAPA Page26
Dept of E.C.E Microprocessors & Microcontrollers LAB

nto
ALRegister.
INC SI ;IncrementSIContentsbyone.

CMP AL,[SI] ;Compare the Contents of AL


withContentsofmemorylocationpointed
bySI.
JC L1 ;JumptoL1ifCarryFlagisSet.

XCHG AL,[SI] ;ExchangetheContentsofALWith


ContentsofmemorypointedbySI.
DEC SI ;DecrementSIContentsbyone.

MOV [SI],AL ;Copy the Contents of AL into


memorylocationpointedbySI.
JMP UP1 ;JumptoLabelUP1

L1: LOOP UP1 ;Decrement CL&Jump toUP1ifCLis


notequaltozero.
DEC DL ;DecrementDLContentsbyone.
JNZ UP2 ;JumptoUP2ifDLisnotequalto
Zero.
MOV AL,[SI] ;CopytheContentsofALWith
ContentsofmemorypointedbySI.
INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input: LIST
[0000]=29H
[0001]=15H
[0002]=32H
[0003]=08H
[0004]=45H
[0005]=17H

Output:
[0000]=08H
[0001]=15H
[0002]=17H
[0003]=29H
[0004]=32H
[0005]=45H

DescendingOrderProgram:

Adress Opcode Label Mnemonics Operands Comments


ASSUMECS:CODE,DS:DATAD

ATASEGMENT

LIST DB
29H,15H,32H,08H,45H,17HCOUNTE
QU06H

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


;AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS

SITS, KADAPA Page27


Dept of E.C.E Microprocessors & Microcontrollers LAB

XOR AX,AX ;ClearContentsofAXRegister.


MOV DL,COUNT-1 ;Copy05HintoDLRegister

MOV CL,DL ;CopytheContentsofDLintoCL.


UP2:
MOV SI,OFFSETLIST ;CopytheAddressPointedbyLIST
intoSIRegister.
UP1: MOV AL,[SI] ;Copy the Contents of
MemoryLocationpointed
bySIRegisterinto
ALRegister.
INC SI ;IncrementSIContentsbyone.

CMP AL,[SI] ;Compare the Contents of AL


withContentsofmemorylocationpointed
bySI.
JNC L1 ;JumptoL1ifCarryFlagisNotSet.

XCHG AL,[SI] ;ExchangetheContentsofALWith


ContentsofmemorypointedbySI.
DEC SI ;DecrementSIContentsbyone.

MOV [SI],AL ;Copy the Contents of AL


intomemorylocationpointedbyS
I.
JMP UP1 ;JumptoLabelUP1

L1: LOOP UP1 ;Decrement CL&JumptoUP1ifCL


isnot equaltozero.
DEC DL ;DecrementDLContentsbyone.
JNZ
UP2 ;Jump to UP2 if DL is not equal
toZero.
MOV AL,[SI] CopytheContentsofALWith
;ContentsofmemorypointedbySI.
INT 21H ;ReturntoDOSPrompt.

CODE
ENDSENDS
TART

Input: LIST
[0000]=29H
[0001]=15H
[0002]=32H
[0003]=08H
[0004]=45H
[0005]=17H
Output:
[0000]=45H
[0001]=32H
[0002]=29H
[0003]=17H
[0004]=15H
[0005]=08H

RESULT: The Assembly Language Programto arrange given list of numbers in Ascending
andDescendingOrder was successfullyexecuted.

SITS, KADAPA Page28


Dept of E.C.E Microprocessors & Microcontrollers LAB

4. STRINGOPERATIONS
A. STRINGLENGTH

Aim:To Write an Assembly Language Programto Comapre two strings are equal or not
usingStringPrefix.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:
Adress Opcode Label Mnemonics Operands Comments
ASSUMECS:CODE,DS:DATA

DATA
SEGMENTSTR1DB
"HELLO$"
MSG DB 10,13,"LENGTH
OFSTRINGIS:$"
LEN DB 03
DUP("$")DATAEND
S

CODESEGMENT

START: MOV AX,DATA ;CopyData Segment Starting


;AddressintoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
MOV SI,OFFSET ;ClearadressofSTR1intoSIRegiste
STR1
MOV CL,00H ;Copy00HintoDLRegister

MOV AL,'$' ; CopytheCharacter$intoAL

SITS, KADAPA Page29


Dept of E.C.E Microprocessors & Microcontrollers LAB

L1: CMP AL,[SI] ; Compare the Contents of AL


withContentsofmemorylocationpointed
bySI.
JE L2 ;JumptoLabel L2 ifEqualorZF= 1

INC SI ;IncrementthecontentsofSIby1

INC CL ;Increment CLregisterContentsby1

JMP L1 ;JumptoLabelL1

L2: ADD CL,30H ; ADD30HtoCLRegisterContents

MOV DX,OFFSET ;Copy the offset ofMSG into


MSG DXRegister&Displaythestringpointedb
MOV AH,09H yMSGonScreen

INT 21H

MOV DI,OFFSET ;Copy the Offset of LEN in to


LEN DIRegister

MOV [DI],CL ;CopytheContentsofCLintomemory


locationpointedbyDI
MOV DX,OFFSET ;Copy the offset ofMSG into
LEN DXRegister&Displaythestringpointedb
yMSGonScreen
MOV AH,09H
INT 21H

MOV AH,4CH ;Terminate the Current Process


INT 21H &Return toDOSPrompt

CODE
ENDSENDS
TART

INPUT:STR1=HELLO

OUTPUT:LengthoftheString=5.

RESULT:AssemblyLanguageProgramtofindLengthofthestringwassuccessfullyexecuted.

SITS, KADAPA Page30


Dept of E.C.E Microprocessors & Microcontrollers LAB

B. STRINGDISPLAY

Aim:ToWrite anAssemblyLanguage Programtodisplaythe givenstring.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:
Adress Opcode Label Mnemonics Operands Comments
ASSUME

CS:CODE,DS:DATADATASE

GMENT

STRING DB 10,13,”THIS IS
ASAMPLESTRING$”

DATAENDS

CODESEGMENT

START: MOV AX,DATA ;Copy Data Segment


StartingAddressinto
AXRegister
MOV DS,AX ;CopytheContentofAXintoDS
LEA DX,STRING ;Copy the offset ofMSG into
DXRegister&Displaythestringpointedb
MOV AH,09H
yMSGonScreen
INT 21H
MOV AH,4CH ;Terminate the Current Process
&Return toDOSPrompt
INT 21H

SITS, KADAPA Page31


Dept of E.C.E Microprocessors & Microcontrollers LAB

CODE
ENDSENDS
TART

INPUT:STRING=THIS ISASAMPLESTRING

OUTPUT:THISISASAMPLESTRING
READASTRINGFROM KEYBOARD& DISPLAYON MONITOR:
ASSUME
CS:CODE,DS:DATADATASE
GMENT
MSG1DB10,13,"ENTERASTRING:$"
MSG2 DB 10,13,"YOU ENTERED THE STRING:
$"STRDB20 DUP("$")
DATA
ENDSCODESEG
MENT
START:MOV AX,DATAMOV
DS,AX
MOV DX,OFFSET
MSG1MOV AH,09H
INT21H
MOV SI,OFFSET
STRMOV AH,01H
L1:INT
21HMOV
[SI],ALINCSI
CMP
AL,0DHJNZ
L1
L2: MOV DX,OFFSET
MSG2MOV AH,09H
INT21H
MOV DX,OFFSET
STRMOV AH,09H
INT21HMOV
AH,4CHINT
21H

CODE
ENDSENDS
TART

INPUT:ENTERASTRING: HELLO

OUTPUT:YOUENTEREDTHESTRING:HELLO

SITS, KADAPA Page32


Dept of E.C.E Microprocessors & Microcontrollers LAB

RESULT:Assembly Language Programto display given string are equal or not using String
Prefixwassuccessfullyexecuted.

SITS, KADAPA Page33


Dept of E.C.E Microprocessors & Microcontrollers LAB

C. STRINGCOMPARISON

Aim:To Write an Assembly Language Programto Compare two strings are equal or not
usingStringPrefix.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:
Adress Opcode Label Mnemonics Operands Comments
ASSUMECS:CODE,DS:DATA

DATA
SEGMENTSTR1DB
"HELLO$"
MSG1DB10,13,"STRINGSAREE
QUAL$"
MSG2DB10,13,"STRINGSAREN
OTEQUAL$"
STR2 DB
"HEPLO$"DATAEN
DS
CODE
SEGMENTORG1
000H
START: MOV AX,DATA ;CopyDataSegmentStartingAddress
intoAXRegister
MOV DS,AX ;CopytheContentofAXintoDS
MOV ES,AX ;CopytheContentofAXintoES
LEA SI,STR1 ;Copytheoffset addressofSTR1into
SI
LEA DI,STR2 ;CopytheaddressofSTR1intoDI
MOV CL,05 ;CopytheCountValue05intoCL
CLD ;CleartheDirectionalFlag

SITS, KADAPA Page34


Dept of E.C.E Microprocessors & Microcontrollers LAB

REP CMPSB ;CompareSTR1with STR2


JE L1 ;JumpifEqualorZerotoAddressPoi
ntedbyLabel L1
MOV DX,OFFSET ;WritetheStringpointedbyMSG2onStanda
MSG2 rd Output.
MOV AH,09
INT 21H
L1: JMP L2 ;JumptoaddresspointedbyL1
MOV DX,OFFSET ;WritetheStringpointedbyMSG1onStanda
MSG1 rd Output.
L2: MOV AH,09H
INT 21H
MOV AH,4CH ;Terminate the Current Process
INT 21H &Return toDOS

CODE
ENDSENDS
TART
INPUT:STR1=HELLO

STR2=HEPLO

OUTPUT:StringsarenotEqual.

RESULT:Assembly language programto Compare two strings are equal or not using String
Prefixwassuccessfullyexecuted.

SITS, KADAPA Page35


Dept of E.C.E Microprocessors & Microcontrollers LAB

D. STRINGREVERSE&PALINDROME

Aim:ToWritean AssemblyLanguageProgramto Reversea givenString.

Apparatus:
Software:MASM(or)TERM 86E
Hardware: PC,KeyBoard/8086Trainer Kit,R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

Adress Opcode Label Mnemonics Operands Comments

ASSUME

CS:CODE,DS:DATADATASE

GMENT

STR1 DB

"HELLO$"STR2DB255

DUP("$")

MSG1DB10,13,"STRINGISP
ALINDROME$"

MSG2DB10,13,"STRINGISNOTP
ALINDROME$"

MSG3 DB 10,13,"STRING IN
REVERSEIS:$"

DATAENDS
CODESEGMENT
START: MOV AX,DATA ;CopyDataSegmentStartingAddressintoAX
Register

SITS, KADAPA Page36


Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV DS,AX ;CopytheContentofAXintoDS


MOV SI,OFFSETSTR1 ;Copytheoffset addressofSTR1intoSI
MOV CL, LENGTHSTR1 ;CopytheCountValue05intoCL
MOV DI,SI ;Copythecontents ofSIintoDI
ADD DI,04 ;Add04HtoDIRegister
L1: MOV AL,[SI] ;Copythecontentspointedbymemory
locationofSIintoAL.
CMP AL,[DI] ;Compare the contents pointed by
memorylocationofDIwith AL.
JNE L2 ;JumpifNotEqualorZF=0tolabelL2

INC SI ;Increment SIContentsby01.


DEC DI ; Decrement DIContentsby01.
DEC CL ;DecrementCLContentsby01.
JNZ L1 ;JumptoLabelL1ifZF=0.
MOV DX,OFFSETMSG1 ;WritetheStringpointedbyMSG1onStandar
d Output.
MOV AH,09H
INT 21H
JMP L3 ;JumptoLabelL3
L2: MOV DX,OFFSETMSG2 ;WritetheStringpointedbyMSG2onStandar
d Output.
MOV AH,09H
INT 21H

L3: MOV SI,OFFSETSTR1 ;Copy the offset address of STR1 into


SIRegister

MOV CL,05H ; Copy05intoCLRegiste


ADD SI,04 ;Add04tocontentsofSI
MOV DI,OFFSETSTR2 ;Copy the offset address of STR1 into
SIRegister

L4: MOV AL,[SI] ;Copythecontentspointedbymemorylocatio


nofSIintoAL.

MOV [DI],AL ;Copy the contents of AL in


tomemorylocationpointedbyDI.

DEC SI ; Decrement SIcontentsby01


INC DI ;Increment DIcontentsby01
DEC CL ; Decrement CLcontentsby01
JNZ L4 ;JumptoLabel L4 ifZF= 0
MOV DX,OFFSETMSG3 ;WritetheStringpointedbyMSG3onStandar
d Output.
MOV AH,09H
INT 21H
MOV DX,OFFSETSTR2 ;Write theString pointed bySTR2
onStandard Output.
MOV AH,09H
INT 21H
MOV AH,4CH ;Terminate the Current Process & Return
INT 21H toDOS
CODE
ENDSENDS
TART

SITS, KADAPA Page37


Dept of E.C.E Microprocessors & Microcontrollers LAB

INPUT:STR1=HELLO.

OUTPUT:String in Reverse is:

OLLEH.Stringisnota

Palindrome.

RESULT: The Assembly Language Programto Reverse the given string & checking wheteher it is
apalindrome or notwas successfullyexecuted.

SITS, KADAPA Page38


Dept of E.C.E Microprocessors & Microcontrollers LAB

5. DIGITAL CLOCKDESIGNUSING8086
A. DESIGNINGCLOCKUSINGINT21HINTERRUPT.

Aim:ToWritean AssemblyLanguageProgramfordesigningclockusingint21hinterrupt.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

ASSUME

CS:CODE,DS:DATADATASE

GMENT

MESSAGE DB 'CURRENT TIME IS:

$'HRDB?

MIN DB ?

SEC DB ?

MSEC DB ?

DATAENDS

CODE
SITS, KADAPA Page39
Dept of E.C.E Microprocessors & Microcontrollers LAB

SEGMENTSTAR

T:

MOV

AX,DATAMOV

DS,AXMOV

AH,2CHINT

21H

MOV

HR,CHMOV

MIN,CLMOV

SEC,DHMOV

MSEC,DLMOV

AH,09H

LEA

DX,MESSAGEINT

21H

MOV AL,HR

AND

AL,ALAAM

MOV

BX,AXCALL

DISPLAYMOV

DL,':'MOV

AH,02HINT 21H

MOV

AL,MINAAM

MOV

BX,AXCALL

DISPLAYMOV

SITS, KADAPA Page40


Dept of E.C.E Microprocessors & Microcontrollers LAB

DL,':'MOV

AH,02HINT 21H

MOV

AL,SECAAM

MOV

BX,AXCALL

DISPLAYMOV

DL,'.'MOV

AH,02HINT 21H

MOV

AL,MSECAAM

MOV

BX,AXCALL

DISPLAYMOV

AH,4CHINT

21H

DISPLAYPROCNEAR

MOV

DL,BHADD

DL,30HMOV

AH,02HINT2

1HMOV

DL,BLADD

DL,30HMOV

AH,02HINT

21H

RET

DISPLAY

ENDPCODE

SITS, KADAPA Page41


Dept of E.C.E Microprocessors & Microcontrollers LAB

ENDSENDSTA

RT

OUTPUT:

CURRENTTIMEIS:18:35:50:100

RESULT:Assembly Language Programfor designing clock using int 21h interrupt was
executedsuccessfully.

SITS, KADAPA Page42


Dept of E.C.E Microprocessors & Microcontrollers LAB

B. DESIGNINGCLOCKUSINGDOSINTERRUPT FUNCTIONS.

Aim:ToWriteanAssemblyLanguageProgramfor designingclockusingDOSinterrupt functions.

Apparatus:
Software:MASM(or)TERM 86E

Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

;UsedINTERRUPTS

;AH=2CH//Getsthesystemdate

;AH=02h

;For2CH

;Hours isin CH

; Minutesisin CL

;SecondsisinDH

.MODELSMALL

.DATA

.CODE

SITS, KADAPA Page43


Dept of E.C.E Microprocessors & Microcontrollers LAB

START: MOV

AX,@DATAMOVDS,AX

HOUR:

MOV

AH,2CHINT2

1HMOV

AL,CHAAM

MOV

BX,AXCALL

DISP

MOV

DL,':'MOVAH,0

2H

INT

21HMINUTES

:MOV

AH,2CHINT2

1HMOV

AL,CLAAM

MOV

BX,AXCALL

DISPMOV

DL,':'MOV

AH,02HINT

21H

Seconds:MOV

AH,2CHINT2

1HMOV

SITS, KADAPA Page44


Dept of E.C.E Microprocessors & Microcontrollers LAB

AL,DHAAM

MOV

BX,AXCALL

DISPMOV

AH,4CHINT

21H

DISP

PROCMOV

DL,BHADD

DL,30HMOV

AH,02HINT2

1HMOV

DL,BLADD

DL,30HMOV

AH,02H

INT

21HRET

DISP

ENDPENDS

TART

(OR)

.MODELSMALL

.STACK100H

.DATA

PROMPTDB'CURRENTSYSTEM TIMEIS:$'

TIMEDB '00:00:00$'

.CODE

MAINPROC
SITS, KADAPA Page45
Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV AX,

@DATAMOV

DS,AX

LEA BX,

TIMECALL

GET_TIMELEA

DX,

PROMPTMOVAH,

09HINT21H

LEA DX,

TIMEMOV

AH,

09HINT21H

MOV AH,

4CHINT21H

MAIN

ENDPGET_TIME

PROC

PUSH

AXPUSH

CXMOV AH,

2CHINT21H

MOVAL,CHCALL

CONVERTMOV

[BX],

AXMOVAL,CLCA

LL

CONVERTMOV

[BX + 3],

AXMOVAL,DHCA

LL

SITS, KADAPA Page46


Dept of E.C.E Microprocessors & Microcontrollers LAB

CONVERTMOV

[BX + 6],

AXPOPCX

POP

AXRET

GET_TIME

ENDPCONVERT

PROCPUSHDX

MOV AH,0

MOV DL,

10DIVDL

OR AX,

3030HPOPDX

RET

CONVERT

ENDPEND

MAINOUTPUT:

CURRENTSYSTEMTIME IS :18:36:10

RESULT:An Assembly Language Programfor designing clock using DOS Interrupt functions
wasexecutedsuccessfully.

SITS, KADAPA Page47


Dept of E.C.E Microprocessors & Microcontrollers LAB

C. DESIGNINGCLOCKBYREADINGSYSTEMTIME

Aim:To Writean AssemblyLanguage Programfor designingclockbyreadingsystemtime.

Apparatus:
Software:MASM(or)TERM 86E
Hardware: PC,KeyBoard, 8086TrainerKit, R.P.S

Procedure

Double click on DOS BOX(0.74.3)


Window is opened like this [z:\>]
In that type
z:\> mount c c:\masm then enter and type
z:\>c: then enter and type edit
c:\> edit and enter
window opened is blue colour
type the program
In file,save the program
In file exist
Again black window opened
In that type masam file name.asm & 4 enters
Type link file name.obj & 4enters
Type debug file name.exe and lenter
Type t
t
t
t until the int 03
After that type q for quiting the program
Again type edit to go to blue window for program To terminate from Dosbox type exist

Program:

SITS, KADAPA Page48


Dept of E.C.E Microprocessors & Microcontrollers LAB

.MODEL SMALL

.DATA

MSG DB 10,13,"THE CURRENT TIME

IS:"HOURDB2 DUP(0),':'

MINDB2 DUP(0),':'

SECDB2 DUP(0),'$'

.CODE

MOV

AX,@DATAMOV

DS,AXMOVAH,2

CHINT 21H

MOV

AL,CHAAM

ADD

AX,3030HMOV

HOUR,AHMOV

HOUR+1,ALMOV

AL,CL

AAM

ADD

AX,3030HMOV

MIN,AHMOV

MIN+1,ALMOV

AL,DHAAM

ADD

AX,3030HMOV

SEC,AHMOV

SEC+1,ALMOV

AH,09HLEA

SITS, KADAPA Page49


Dept of E.C.E Microprocessors & Microcontrollers LAB

DX,MSGINT

21H

MOV

AH,4CHINT

21H

END

(OR)

.MODEL SMALL

.DATA

MSG DB "THE TIME IS:

"HRSDB?,?,':'

MINSDB?,?,':'

SEC DB ?,?,' (HH:MM:SS)

',10,13DB"THE DATE IS:"

DADB?,?, '/'

MONDB?,?, '/'

YEADB?,?,'(DD/MM/YY)',10,13,'$'

.CODE

MOV

AX,@DATAMOV

DS,

AXMOVAH,2CHI

NT 21H

MOV

AL,CHAAM

ADD AX,

3030HMOV HRS,

AHMOV HRS+1,

SITS, KADAPA Page50


Dept of E.C.E Microprocessors & Microcontrollers LAB

ALMOV

AL,CLAAM

ADD AX,

3030HMOV

MINS, AHMOV

MINS+1,ALMOV

AL,DHAAM

ADD AX,

3030HMOV

SEC, AHMOV

SEC+1,ALMOV

AH, 2AHINT

21H

MOV AL,

DLAAM

ADD

AX,3030HMOV

DA,AHMOV DA

+1, ALMOV AL,

DHAAM

ADD AX,

3030HMOV

MON,AHMOV

MON+1,ALADD

CX, 0F830HMOV

AL, CLAAM

ADD AX,

3030HMOV

YEA,AHMOV

SITS, KADAPA Page51


Dept of E.C.E Microprocessors & Microcontrollers LAB

YEA+1,ALLEA

DX,MSGMOV

AH,09HINT 21H

MOV

AH,4CHINT

21H

END

OUTPUT:
THE TIME IS :

18:37:20THEDATEIS:21

/12/22

RESULT:An Assembly Language Programfor designing clock by reading system time


wasexecutedsuccessfully.

SITS, KADAPA Page52


Dept of E.C.E Microprocessors & Microcontrollers LAB

6.ASCII ARITHMETIC OPERATIONS


AIM : To Write an assembly language program to find
a. ASCII addition
b. ASCII subtraction
c. ASCII multiplication
d. ASCII division
Software required: MASM SOFTWARE
PROCEDURE:
Double click on DOS Box(0.74-3)
window is opened like this(z:\>)
In that type
z:\> mount c c:\masm then enter and type
z:\>c:
c:\>edit and enter
Window is opened in blue colour
Type the program
In file save the program
In file exit
Again black window is opened
In that type MASM filename.asm & four enters
type -->link filename.obj & four enters
type--> debug filename.exe &one enter
type t
t
t
until int 21
After that type Q for quit the program
Again type edit to go to blue window for new program
PROGRAM:
A. ASCII ADDITION
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
CODE SEGMENT
START:
XOR AX,AX
XOR BX,BX
MOV AX,35H
MOV BX,39H
ADD AX,BX
AAA
OR AX,3030H
INT 21H
CODE ENDS
END START
B.ASCII SUBTRACTION:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
CODE SEGMENT
START:
XOR AX,AX
XOR BX,BX
MOV AX,39H
MOV BX,35H
SUB AX,BX
AAS
SITS, KADAPA Page53
Dept of E.C.E Microprocessors & Microcontrollers LAB

OR AX,3030H
INT 21H
CODE ENDS
END START

C.ASCII MULTIPLICATION:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
CODE SEGMENT
START:
XOR AX,AX
XOR BX,BX
MOV AL,004H
MOV BL,09H
MUL BL
AAM
OR AX,3030H
INT 21H
CODE ENDS
END START
D.ASCII DIVISION:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
CODE SEGMENT
START:
XOR AX,AX
XOR BX,BX
MOV AX,0609H
MOV BL,09H
AAD
DIV BL
OR AX,3030H
INT 21H
CODE ENDS
END START
RESULT:
The assembly language program to find
a. ASCII addition
b. ASCII subtraction
c. ASCII multiplication
d. ASCII division were executed successfully by using MASM SOFTWARE.

SITS, KADAPA Page54


Dept of E.C.E Microprocessors & Microcontrollers LAB

7.LCM of two given numabers and Square Root of given number


AIM : To Write an assembly language program to find
a. LCM of two given numbers
b. Square Root of given number

Software required: MASM SOFTWARE

PROCEDURE:
Double click on DOS Box(0.74-3)
window is opened like this(z:\>)
In that type
z:\> mount c c:\masm then enter and type
z:\>c:
c:\>edit and enter
Window is opened in blue color
Type the program
In file save the program
In file exit
Again black window is opened
In that type MASM filename.asm & four enters
type -->link filename.obj & four enters
type--> debug filename.exe &one enter
type t
t
t
until int 21
After that type Q for quit the program
Again type edit to go to blue window for new program

A. LCM OF TWO NUMBERS:


ASSUME CS:CODE
CODE SEGMENT
START:
MOV AX,0009H
MOV BX,0003H
MOV DX,AX
BACK:
CMP AX,BX
JZ AHEAD1
ADD DX,0009H
MOV AX,DX
AHEAD1:
SUB AX,BX
JNZ BACK
AHEAD2:
INT 21H
CODE ENDS
END START

SITS, KADAPA Page55


Dept of E.C.E Microprocessors & Microcontrollers LAB

B.SQUARE ROOT OF NUMBER


ASSUME CS:CODE
CODE SEGMENT
START:
MOV AX,0040H
MOV BX,0001H
XOR DX,DX
L1:
SUB AX,BX
INC DX
CMP AX,0000
JZ L2
ADD BX,0002
JMP L1
L2:
INT 21H
CODE ENDS
END START

Result : The assembly language program to find


a. LCM of two given numbers
b. Square Root of given number
Were executed successfully by using MASM SOFTWARE

SITS, KADAPA Page56


Dept of E.C.E Microprocessors & Microcontrollers LAB

8.BCD AND ASCII CONVERSIONS

AIM: To write an alp program to perform


A. BCD TO ASCII
B.ASCII TO BCD

software required:
MASMM SOFTWARE

PROCEDURE:
Double click on DOS Box(0.74-3)
window is opened like this(z:\>)
In that type
z:\> mount c c:\masm then enter and type
z:\>c:
c:\>edit and enter
Window is opened in blue colour
Type the program
In file save the program
In file exit
Again black window is opened
In that type MASM filename.asm & four enters
type -->link filename.obj & four enters
type--> debug filename.exe &one enter
type t
t
t
until int 21
After that type Q for quit the program
Again type edit to go to blue window for new program

PROGRAM:

A.BCD TO ASCII

ASSUME CS:CODE
CODE SEGMENT
START:
MOV AL,98H
MOV AH,AL
MOV CL,04H
SHR AL,CL
AND AX,0F0FH
OR AX,3030H
INT 03H
CODE ENDS
END START

B.ASCII TO BCD

ASSUME CS:CODE
CODE SEGMENT
START:
MOV AX,3636H
AND AX,0F0FH
SITS, KADAPA Page57
Dept of E.C.E Microprocessors & Microcontrollers LAB

MOV CL,04H
SHL AH,CL
OR AL,AH
AND AH,00H
INT 03H
CODE ENDS
END START

RESULT : The ALP program to perform


A. BCD TO ASCII
B.ASCII TO BCD
Were executed successfully by using MASM SOFTWARE

SITS, KADAPA Page58


Dept of E.C.E Microprocessors & Microcontrollers LAB

9.DECIMAL TO HEXA DECIMAL AND ASCII TO DECIMAL CONVERSIONS

AIM: To Write an ALP Program to perform


A. DECIMAL TO HEXA DECIMAL
B. ASCII TO DECIMAL

SOFTWARE REQUIRED:
MASM SOFTWARE

PROCEDURE:
Double click on DOS Box(0.74-3)
window is opened like this(z:\>)
In that type
z:\> mount c c:\masm then enter and type
z:\>c:
c:\>edit and enter
Window is opened in blue colour
Type the program
In file save the program
In file exit
Again black window is opened
In that type MASM filename.asm & four enters
type -->link filename.obj & four enters
type--> debug filename.exe &one enter
type t
t
t
until int 21
After that type Q for quit the program
Again type edit to go to blue window for new program

PROGRAM:

A. DECIMAL TO HEXA DECIMAL

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
N1,DW 0010
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV AX,N1
MOV BX,AX
AND BX,000FH
AND AX,00F0H
MOV CL,04H
SHR AX,CL
MOV DX,16
MUL DX
ADD AX,BX
INT 21H
CODE ENDS
END START
SITS, KADAPA Page59
Dept of E.C.E Microprocessors & Microcontrollers LAB

B.ASCII TO DECIMAL

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ASCII DW " "
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV AX,ASCII
SUB AX,30H
INT 21H
CODE ENDS
END START

RESULT : The ALP Program to perform


A. DECIMAL TO HEXA DECIMAL
B. ASCII TO DECIMAL
Were executed successfully by using MASM SOFTWARE

SITS, KADAPA Page60


Dept of E.C.E Microprocessors & Microcontrollers LAB

10.PACKED BCD & UNPACKED BCD CONVERSIONS

AIM: To Write an ALP Program to perform


A. UNPACKED BCD TO PACKED BCD
B. PACKED BCD TO UNPACKED BCD

SOFTWARE REQUIRED:
MASM SOFTWARE

PROCEDURE:
Double click on DOS Box(0.74-3)
window is opened like this(z:\>)
In that type
z:\> mount c c:\masm then enter and type
z:\>c:
c:\>edit and enter
Window is opened in blue colour
Type the program
In file save the program
In file exit
Again black window is opened
In that type MASM filename.asm & four enters
type -->link filename.obj & four enters
type--> debug filename.exe &one enter
type t
t
t
until int 21
After that type Q for quit the program
Again type edit to go to blue window for new program

PROGRAM:

A. UNPACKED BCD TO PACKED BCD

ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START:
MOV AX,0809H
MOV CL,04H
SHL AH,CL
OR AL,AH
AND AH,00H
INT 03H
CODE ENDS
END START

B.PACKED BCD TO UNPACKED BCD

ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START:
MOV Al,27H
MOV AH,AL
MOV CL,04H
SHR AH,CL
SITS, KADAPA Page61
Dept of E.C.E Microprocessors & Microcontrollers LAB

AND AX,0F0FH
INT 03H
CODE ENDS
END START

RESULT : The ALP Program to perform


A. UNPACKED BCD TO PACKED BCD
B. PACKED BCD TO UNPACKED BCD
Were executed successfully by using MASM SOFTWARE

SITS, KADAPA Page62

You might also like