Beruflich Dokumente
Kultur Dokumente
DEPARTMENT OF ECE
EC 8681MICROPROCESSORS AND
MICROCONTROLLERS LABORATORY
LAB MANUAL
Exp. Page
Date Name of the Experiment No. Marks Signature
No
16 Bit Addition Using Arithmetic Operation
1
of 8086 Microprocessor
16 Bit Subtraction Using Arithmetic
2
Operation of 8086 Microprocessor
16 Bit Multiplication Using Arithmetic
3
Operation of 8086 Microprocessor
16 Bit Division Using Arithmetic Operation
4
of 8086 Microprocessor
Logical Operations Using 8086
5
Microprocessor
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16-bit addition
ADDRESS DATA
INPUT 1200
1201
1202
1203
1204
OUTPUT 1205
1206
RESULT:
Thus the assembly language program to perform addition of two 16 bit
numbers using 8086 Performed and the result is stored.
Ex. NO: 02
DATE:
16 BIT SUBTRACTION
USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR
AIM:
To write an assembly language program to perform subtraction of two 16 bit
numbers using 8086.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16-bit SUBTRACTION:
SUBTRACTION:
PROGRAM FOR SUBTRACTION:
ADDRESS DATA
1300
1301
INPUT
1302
1303
1304
OUTPUT 1305
1306
RESULT:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16-bit MULTIPLICATION
Multiplication of 16-bit numbers:
MULTIPLICATION:
PROGRAM FOR MULTIPLICATION:
INPUT
OUTPUT
RESULT:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16-bit division
Division of 16-bit numbers:
Get the dividend and divisor.
Initialize the quotient to 0.
Dividend = dividend–divisor
If the divisor is greater, store the quotient
Go to step 3
If dividend is greater, quotient = quotient+ repeat from step 4.
FLOECHART:
DIVISION:
PROGRAM FOR DIVISION:
ADDRESS DATA
1200
1201
INPUT
1202
1203
1208
OUTPUT
1209
RESULT:
Thus the assembly language program to perform division of two 16 bit
numbers using 8086 Performed and the result is stored.
EX. NO: 05
DATE :
LOGICAL OPERATIONS USING 8086 MICROCONTROLLER
AIM:
To move a data block without overlap
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
Increment B register.
Increment accumulator by 1 and adjust it to decimal every time.
Compare the given decimal number with accumulator value.
OUTPUT:
AND
OR
EX-OR
RESULT:
Thus the assembly language program to perform logical operations AND, OR
& EX-OR using 8086 Performed and the result is stored.
EX. NO: 06
DATE :
MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To move a data block without overlap
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
Increment B register.
Increment accumulator by 1 and adjust it to decimal every time.
Compare the given decimal number with accumulator value.
OUTPUT:
INPUT OUTPUT
1400 1450
1401 1451
1402 1452
1403 1453
1404 1454
RESULT:
Thus the output for the Move a data block without overlap was executed
successfully.
EX. NO: 07
DATE :
CODE CONVERSION-DECIMAL TO HEXADECIMAL
AIM:
To convert a given decimal number to hexadecimal.
ALGORITHM:
Initialize the memory location to the data pointer.
Increment B register.
Increment accumulator by 1 and adjust it to decimal every time.
Compare the given decimal number with accumulator value.
When both match, the equivalent hexadecimal value is in B register.
Store the resultant in memory location.
FLOWCHART:
PROGRAM:
OUTPUT:[DECIMAL TO HEXADECIMAL]
INPUT
OUTPUT
EX. NO: 08
DATE :
CODE CONVERSION –HEXADECIMAL TO DECIMAL
AIM:
To convert a given hexadecimal number to decimal
ALGORITHM:
Initialize the memory location to the data pointer.
Increment B register.
Increment accumulator by 1 and adjust it to decimal every time.
Compare the given hexadecimal number with B register value.
When both match, the equivalent decimal value is in A register.
Store the resultant in memory location.
PROGRAM;
INPUT OUTPUT
MEMORY
DATA
RESULT:
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
PROBLEM STATEMENT:
An array of length 05 is given from the location. Sort it into descending and
ascending order and store the result.
ALGORITHM:
Number of comparisons in
9002 MOV CL,[SI]
CL
Go to next memory
9007 INC SI
location
Go to next memory
900B L3 : INC SI
location
Compare BC and AL
900F CMP AL,BC
register
DATA
INPUT
OUTPUT
DATA
INPUT
OUTPUT
RESULT:
Thus the given array of numbers are sorted in ascending & descending order.
EX. NO: 10
DATE :
LARGEST & SMALLEST
AIM:
To write an Assembly Language Program(ALP) to find the Largest and
Smallest number in a given array.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
PROBLEM STATEMENT:
An array of length 5 is given from the location. Find the largest and smallest
number and store the result.
ALGORITHM:
1018 MOV [DI],AL Else store the biggest number in 1300 location
DATA
INPUT
OUTPUT
DATA
INPUT
OUTPUT
RESULT:
Thus the largest and smallest number is found in a given array.
EX. NO: 11
DATE :
PASSWORD CHECKING
AIM:
APPARATUS REQUIRED:
PROGRAM:
; PASSWORD IS MASM1234
DATA SEGMENT
PASSWORD DB 'MASM1234'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV DS, AX
INT 21H
MOV SI, 00
UP1:
INT 21H
JE DOWN
MOV [INST+SI], AL
MOV DL,'*'
INT 21H
INC SI
JMP UP1
DOWN:
MOV BX, 00
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL, DL
JNE FAIL
EC6513- MICROPROCESSOR AND MICROCONTROLLER LABORATORY 42
INC BX
LOOP CHECK
INT 21H
JMP FINISH
FAIL:
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
RESULT:
Thus the output for the Password checking, Print RAM size and system date
was executed successfully
EC6513- MICROPROCESSOR AND MICROCONTROLLER LABORATORY 43
EXP.NO: 12
DATE :
AIM:
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROGRAM;
100B INX H
100E MOV A, M
1012 INX H
1019 INX H
101A DCR E
1026 L1 DCR C
1028 JNZ L1
1029 DCR D
1000 MOV A, D
1002 ORA E
1004 JNZ L2
1006 RET
RESULT:
Thus the assembly language program for traffic light control is verified
EX. NO: 13
DATE :
AIM:
APPARATUS REQUIRED:
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and
particular number of rotations in a specific time.
THEORY:
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a stepwise manner
from one equilibrium position to the next. Two-phase scheme: Any two adjacent
stator windings are energized. There are two magnetic fields active in quadrature
and none of the rotor pole faces can be in direct alignment with the stator poles. A
partial but symmetric alignment of the rotor poles is of course possible.
ALGORITHM:
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
FLOWCHART:
PROGRAM FOR STEPPER MOTOR CONTOL;
RESULT:
Thus the assembly language program for rotating stepper motor in both
clockwise and anticlockwise directions is written and verified.
EX. NO: 14
DATE :
INTERFACING PRGRAMMABLE KEYBOARD AND
DISPLAY CONTROLLER 8279
AIM :
APPARATUS REQUIRED:
ALGORITHM :
MEMORY
OPCODES PROGRAM COMMENDS
LOCATION
9000 MVI C,BA Initialize array
DATA BUS D7 D6 D5 D4 D3 D2 D1 D0
SEGMENTS d c B A d g f e
RESULT:
Thus the rolling message “2” is displayed using 8279 interface kit.
EX. NO: 15
DATE :
INTERFACING ANALOG TO DIGITAL CONVERTER USING 8086
AIM:
APPARATUS REQUIRED:
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the
ADC when to start the conversion and the EOC output to announce when the
conversion is complete.
ALGORITHM:
Select the channel and latch the address.
Send the start conversion pulse.
Read EOC signal.
If EOC = 1 continue else go to step (iii)
Read the digital output.
Store it in a memory location.
PROGRAM:
MEMORY
OPCODES PROGRAM COMMENTS
LOCATION
Load accumulator
1000 MOV DX,FF26 with value for ALE
high
Send through output
1000 MOV AL,90
port
Load accumulator
1003 OUT DX,AL with value for ALE
low
Send through output
1006 MOV DX,FF24
port
Store the value to
1009 MOV AL,FF make SOC high in
the accumulator
Send through output
100B OUT DX,AL
port
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were
converted into its digital equivalent.
EX. NO: 16
DATE :
INTERFACING DIGITAL – TO – ANALOG CONVERTER
USING 8086
AIM:
APPARATUS REQUIRED:
PROBLEM STATEMENT:
The program is executed for various digital values and equivalent analog
voltages are measured and also the waveforms are measured at the output ports
using CRO.
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is
between –5v and +5v. The output voltage varies in steps of 10/256 = 0.04
(approximately). The digital data input and the corresponding output voltages are
presented in the table. The basic idea behind the generation of waveforms is the
continuous generation of analog output of DAC. With 00 (Hex) as input to DAC2
the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square
wave of amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to
DAC2. Repeat this sequence again and again. As a result a saw-tooth wave will be
generated at DAC2 output. Output digital data from 00 to FF in constant steps of
01 to DAC2. Output digital data from FF to 00 in constant steps of 01 to DAC2.
Waveform generation
Square Waveform:
MEMORY
OPCODES PROGRAM COMMENTS
LOCATION
Load accumulator
1000 MOV DX,FF26 with value for ALE
high
Send through output
1000 MOV AL,80
port
Load accumulator
1003 OUT DX,AL with value for ALE
low
Send through output
1006 MOV DX,FF22
port
Store the value to
1009 MOV AL,FF make SOC high in
the accumulator
Send through output
100B OUT DX,AL
port
Decrement CX
2105 DEC CX
register
Return to main
2108 RET
address
RESULT
Thus the DAC was interfaced with 8086 and different waveforms have been
generated.
EX. NO: 17
DATE :
8 BIT ADDITION USING ARITHMETIC OPERATION 8051
MICROCONTROLLER
AIM:
To write an ALP program to add two 8-bit numbers using 8051
microcontroller.
ALGORITHM:
Clear Program Status Word.
Select Register bank by giving proper values to RS1 & RS0 of PSW.
Load accumulator A with any desired 8-bit data.
Load the register R 0 with the second 8- bit data.
Add these two 8-bit numbers.
Store the result.
Stop the program.
FLOW CHART
PROGRAM
OUTPUT:
INPUT OUTPUT
MEMORY MEMORY
DATA DATA
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
EX. NO: 18
DATE :
8 BIT SUBTRACTION USING ARITHMETIC OPERATION
8051 MICROCONTROLLER
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
Clear the carry flag.
Initialize the register for borrow.
Get the first operand into the accumulator.
Subtract the second operand from the accumulator.
If a borrow results increment the carry register.
Store the result in memory.
OUTPUT:
INPUT OUTPUT
Memory Memory
Data Data
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed.
EX. NO: 19
DATE :
8 BIT MULTIPLICATION USING ARITHMETION OPERATION 8051
MICROCONTROLLER
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
Get the multiplier in the accumulator.
Get the multiplicand in the B register.
Multiply A with B.
Store the product in memory.
FLOWCHART:
8 BIT MULTIPLICATION
INPUT OUTPUT
Memory Memory
Data Data
Location location
4500 4502
4501 4503
RESULT:
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed.
EX. NO: 20
DATE :
8 BIT DIVISION USING ARITHMETIC OPERATION 8051
MICROCONTROLLER
AIM:
To perform division of two 8 bit data and store the result in memory
ALGORITHM:
Get the Dividend in the accumulator.
Get the Divisor in the B register.
Divide A by B.
Store the Quotient and Remainder in memory.
FLOWCHART:
8 BIT DIVISION
INPUT OUTPUT
Memory Memory
Data Data
Location location
4500 4502
4501 4503
RESULT:
Thus the 8051 ALP for division of two 8 bit numbers is executed.
EX. NO: 21
DATE :
LOGICAL OPERATIONS USING
8051 MICROCONTROLLER
AIM:
To perform logical operation using 8051 microcontroller AND, OR & EX-OR.
ALGORITHM:
OUTPUT:
AND
OR
EX-OR
RESULT:
Thus the assembly language program to perform logical operations AND, OR
& EX-OR using 8051 Performed and the result is stored.
EX. NO: 22
DATE :
FIND 2’S COMPLEMENT OF A NUMBER
AIM:
To Finding 2’s complement of a number using 8051 micro controller
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
PROGRAM:
OUTPUT:
RESULT;
00 59 AAM 08 09
AH AL AH AL
ADD AX,
08 09 38 39
3030H
AH AL AH AL
NOTE; 38h and 39h are the ASCII equivalents of 8 and 9 respectively
ROUTINE: convert binary for number less than 100 passing parameter
AAM
ADD AX, 3030H
MOV BX, AX
MOV DL, BH
MOV AH, 02
INT 21H
MOV DL, BL
INT 21H
POP AX
POP BX
POP DX
RET
END P
ARITHMETIC OPERATIONS USING MASM
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 ;SERVICE NUMBER
INT 21H ; EXIT TO DOS
END BEGIN
OUTPUT
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 DB12H
N2 DB 11H
SUM DW ?
.CODE
BEGIN: MOV AX,@DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
AND AL,N2
MOV SUM,AX
MOV AH,4CH ;SERVICE NUMBER
INT 21H ;EXIT TO DOS
END BEGIN
OUTPUT
OR OPERATION
.MODEL SMALL
.STACK 100H
.DATA
N1 DB 12H
N2 DB 11H
RES DW ?
.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 AX,@DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
NOT AL
MOV RES,AL
MOV AH,4CH ;SERVICE NUMBER
INT 21H ;EXIT TO DOS
END BEGIN
OUTPUT
2s COMPLEMENT
.MODEL SMALL
.STACK 100H
.DATA
N1 DB 12H
RES DB ?
.CODE
BEGIN: MOV AX,@DATA
MOV DS, AX
MOV AH,00
MOV AL,N1
NOT AL
INC AL
MOV RES,AL
MOV AH,4CH ;SERVICE NUMBER
INT 21H ;EXIT TO DOS
END BEGIN
OUTPUT
RESULT
Thus the assembly language programs for logical operations were executed using
MASM successfully.
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 21h
END
OUTPUT
RESULT
Thus the assembly language program for transfer a block of data with overlap was
executed using MASM successfully.
TRANSFER A DATA BLOCK WITHOUT OVERLAP
AIM
To write the assembly language program for transfer a block of data using MASM
PROGRAM
.MODEL SMALL
.DATA
ARRAY1 DW 1111H,2222H,3333H,4444H,5555H
ARRAY2 DW 5 DUP (0)
COUNT DW 0005H
.STACK 100H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,ARRAY1
LEA DI,ARRAY2
MOV CX,COUNT
NEXT: MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH,4CH
INT 21H
END
OUTPUT
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
.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
PROGRAM FOR DESCENDING 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]
JNB 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
RESULT
Thus the assembly language program for program to sort the numbers in ascending
and descending order was executed using MASM successfully.
AIM
To write the assembly language program for password validation using MASM
PROGRAM
;PASSWORD-VERIFICATION PROGRAM
.MODEL SMALL
.STACK 100H
.DATA
MESSAGE DB 'ENTER PASSWORD PLZ:$'
PASSWD DB 'BHARATHI'
COUNT DW 8
CORRECT DB 'PASSWORD VERIFIED AND CORRECT$'
NOTCORRECT DB 'INVALID$'
.CODE
BEGIN: MOV AX,@DATA
MOV DS,AX
RESULT
Thus the assembly language program for verifying the password was executed
using MASM successfully.
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 BUF1
PRNSTR ANS
PRNSTR BUF2
RESULT
Thus the assembly language program for displaying the memory size was executed
using MASM successfully.
AIM
To write the assembly language program for displaying the current date and time
using MASM.
PROGRAM
RESULT
Thus the assembly language program for displaying the current date and time was
executed using MASM successfully.
AIM
To write the assembly language program for implementing a counter and a time delay
using MASM
PROGRAM
.CODE
MOV DX,@DATA
MOV DS,DX
LEA DX,MSGIN
MOV AH,09H
INT 21H
IN1:
MOV AH,01H
INT 21H
CMP AL,0DH ;
JE NXT
SUB AL,30H
MOV DL,AL
MOV AX,BX
MOV CL,0AH
MUL CL
MOV BX,AX
AND DX,00FFH
ADD BX,DX
MOV DELAYTIME,BX
LOOP IN1
NXT: MOV CX,DELAYTIME
MOV DL,10
MOV AH,02H
INT 21H
LEA SI,MSG1
LP: PUSH DX
MOV DL,[SI]
CMP DL,'$'
JE NXT2
MOV AH,02H
INT 21H
ADD SI,1
POP DX
MOV DI,DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
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
.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
.MODEL SMALL
.STACK 100H
.DATA
N1 DW 000BH
N2 DW 0008H
RES DW ?
.CODE
MOV AX,@DATA
MOV DS, AX
MOV AX, N1
SUB AX, N2
DAS
INT 3
MOV AH, 4CH
INT 21H
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
RESULT
Thus the assembly language program to display the string was executed using
MASM successfully.
AIM
To write the Assembly Language Program for displaying reverse of the string using
MASM
PROGRAM
OUTPUT
RESULT
Thus the assembly language program for displaying reverse of the string was
executed using MASM successfully.
AIM
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
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
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.
AIM
PROGRAM
.MODEL SMALL
.STACK 100H
PRNSTR MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
ENDM
DATA SEGMENT
BUF1DB "ENTER A DECIMAL NUMBER : $"
BUF2DB 0AH, "INVALID DECIMAL NUMBER...$"
BUF3DB 0AH, "EQUIVALENT HEXADECIMAL NUMBER IS : $"
BUF4DB 6
DB 0
DB 6 DUP(0)
MULTIPLIERDB 0AH
DATA ENDS
CODE SEGMENT
ASSUMECS:CODE, DS:DATA
START :
MOV AX, DATA
MOV DS, AX
MOVES, AX
PRNSTR BUF1
INCSI
LOOP SUBTRACT
RESULT