0% found this document useful (0 votes)
960 views34 pages

8086 All Basic Programs

The document describes a program to convert ASCII to binary code using an 8086 microprocessor. The program loads the ASCII value from memory location 5000H into the AL register, subtracts 30 from it, and compares the result to 0A. If there is a carry, the value in AL is moved to the destination. If no carry, 7 is subtracted from AL and the result is moved to the destination. The program then ends. The document provides the aim, apparatus, algorithm, procedure and program listing to perform this conversion.

Uploaded by

Sudhagar
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)
960 views34 pages

8086 All Basic Programs

The document describes a program to convert ASCII to binary code using an 8086 microprocessor. The program loads the ASCII value from memory location 5000H into the AL register, subtracts 30 from it, and compares the result to 0A. If there is a carry, the value in AL is moved to the destination. If no carry, 7 is subtracted from AL and the result is moved to the destination. The program then ends. The document provides the aim, apparatus, algorithm, procedure and program listing to perform this conversion.

Uploaded by

Sudhagar
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/ 34

EX.

NO: 1

DATE:

ADDITION OF TWO 16 BIT NUMBERS


AIM:
To write an assembly language program to add 2 16 bit numbers and to verify the result using
8086 microprocessor

APPARATUS REQUIRED:
8086 microprocessor kit, +5v power supply

ALGORITHM:
Step 1: Start the program.
Step 2: Load SI with memory location 5000H.
Step 3: Move data of SI to AX.
Step 4: Increment SI..
Step 5: Increment SI.
Step 6: Move data of SI to BX .
Step 7: ADD AX with BX.
Step 8: Increment SI.
Step 9: Increment SI.
Step 10: Move data from AX to SI.
Step 11: Stop.

PROCEDURE:
 Initially source index made to point to specific address location where first operand is stored.
 The value is stored in accumulator.
 The value in source index is incremented twice to point to the second operand.
 Store the second operand register B.
 Add the second operand to first.
 Increment the SI value twice and store the result in address location.
PROGRAM: ADDITION OF TWO 16 BIT NUMBERS

ADDRESS MNEMONICS OPERAND OPCODE REMARKS


0000:2000 MOV SI,5000H BE 00 50 Move content of 5000H to SI.
0000:2003 MOV AX,[SI] 8B 04 Move offset value of SI to AX.
0000:2005 INC SI 46 Increment SI.
0000:2006 INC SI 46 Increment SI.
0000:2007 MOV BX,[SI] 8B IC Move offset value from SI to BX.
0000:2009 ADD AX,BX O3 CB Add BX with AX.
0000:200B INC SI 46 Increment SI.
0000:200C INC SI 46 Increment SI.
0000:200D MOV [SI],AX 89 04 Move content of AX to SI.
0000:200F HLT F4 Halt.

TABULATION : ADDITION OF TWO 16 BIT NUMBERS

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to add two 16 bit numbers are written and executed using 8086
microprocessor and result were tabulated.

EX NO : 02
DATE :

SUBTRACTION OF TWO 16-BIT NUMBERS

AIM :
To write an assembly language program to subtract two 16-bit numbers and to verify the result using
8086 microprocessor.

APPARATUS REQUIRED :
1. 8086 Micro processor kit
2. +5V power supply

ALGORITHM :

Step 1 : Start.
Step 2 : Load SI with memory location 5000H.
Step 3 : Move data in SI to AX.
Step 4 : Increment SI.
Step 5 : Increment SI.
Step 6 : Move data in SI to BX.
Step 7 : Subtract AX from BX.
Step 8 : Increment SI.
Step 9 : Increment SI.
Step 10 : Move data from AX to SI.
Step 11 : Stop.

PROCEDURE :
 Initially the source index is made to point to a specific address location where the first operand
 is stored.
 The value is moved to accumulator.
 The contents of source index is incremented twice to point to second operand.
 Store the second operand in register B.
 Subtract the second operand from the first.
 Increment the contents of source index twice and the result is stored in new address location.
PROGRAM : SUBTRACTION OF TWO 16 BIT NUMBERS

ADDRESS MNEMONICS OP CODE OPERAND COMMENTS


0000:2000 MOV BE 00 50 SI, 5000H Move contents of 5000H to SI
0000:2003 MOV 8B 04 AX,[SI] Move offset value of SI to AX
0000:2005 INC 46 SI Increment SI
0000:2006 INC 46 SI Increment SI
0000:2007 MOV 8B 1C BX,[SI] Move offset value of SI to BX
0000:200A SUB 2B C3 AX,BX Subtract AX from BX
0000:200B INC 46 SI Increment SI
0000:200C INC 46 SI Increment SI
0000:200D MOV 89 04 [SI],AX Move contents of AX to SI
0000:200F HLT F4 Halt

TABULATION : SUBTRACTION OF TWO 16 BIT NUMBERS

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT :

Thus an assembly language program to subtract two 16-bit numbers was written and executed using
8086 microprocessor and the results were tabulated.
EX.NO:03

DATE:

MULTIPLICATION OF TWO 16-BIT NUMBERS

AIM:
To write an assembly language program to multiply two 16 bit numbers using 8086 microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit,+ 5V power supply.

ALGORITHM:

Step 1: Start the program.


Step 2: Load SI with memory location 5000H.
Step 3: Move offset value of SI to register AX.
Step 4: Increment SI twice.
Step 5: Move offset value of SI to register BX.
Step 6: Multiply BX.
Step 7: Increment SI twice.
Step 8: Move register AX to SI.
Step 9: Stop.

PROCEDURE:

 Initially, the source index is made to point to a specific address location where the first operand is stored.
 The value is moved to accumulator.
 The value in source index is incremented twice to point to the second operand.
 Store the second operand in register B.
 Multiply second operand to the first one.
 Increment contents of source index twice and result is stored in contents of source index.
PROGRAM:MULTIPLICATION OF TWO 16 BIT NUMBERS

ADDRESS MNEMONIC OPERAND OPCODE REMARKS


0000:2000 MOV SI,5000H BE 00 50 Move contents of 5000H to SI.

0000:2003 MOV AX,[SI] 8B 04 Move offset value of SI to AX.

0000:2005 INC SI 46 Increment SI.

0000:2006 INC SI 46 Increment SI.

0000:2007 MOV BX,[SI] 8B 1C Move offset value of SI to BX.

0000:2009 MUL BX F7 E3 Multiply BX.

0000:200B INC SI 46 Increment SI.

0000:200C INC SI 46 Increment SI.

0000:200D MOV [SI],AX 89 04 Move contents of AX to SI.

0000:200F HLT F4 Halt.

TABULATION : MULTIPLICATION OF TWO 16 BIT NUMBERS

INPUT OUTPUT

ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to multiply two 16 bit numbers was executed using 8086 microprocessor and
the results were tabulated.
EX NO: 04

DATE:

DIVISION OF TWO 16-BIT NUMBERS

AIM :
To write an assembly language program to divide two 16-bit numbers and to verify the results
using 8086 microprocessor.

APPARATUS REQUIRED:
 8086 microprocessor Kit
 +5V Power Supply

ALGORITHM:
Step 1: Start.

Step 2: Load SI with data to memory location 5000H.

Step 3: Move data to SI to register AX.

Step 4: Increment SI twice.

Step 5: Move data SI to register BX.

Step 6: Divide BX register.

Step 7: Increment SI twice.

Step 8: Move data from AX to SI.

Step 9: Stop.

PROCEDURE:
 Initially, the source index is made to point to the address of first operand.
 The value is moved to accumulator.
 The contents of source index is incremented twice to point to second operand.
 Store the second operand in register B.
 Divide the contents of accumulator by contents of register B.
 Increment contents of source index twice and result is stored in contents of source index

PROGRAM: DIVISION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONIC OPERAND OPCODE REMARKS


0000:2000 MOV SI,5000H BE 00 50 Move contents of 5000H to SI.
0000:2003 MOV AX,[SI] 8B 04 Move offset value of SI to BX.
0000:2005 INC SI 46 Increment SI.
0000:2006 INC SI 46 Increment SI.
0000:2007 MOV BX,[SI] 8B 1C Move SI value to BX.
0000:2009 DIV BX F7 F3 Divide BX.
0000:200B INC SI 46 Increment SI.
0000:200C INC SI 46 Increment SI.
0000:200D MOV [SI],AX 89 04 Move AX value to SI.
0000:200F HLT F4 Halt.

TABULATION: DIVISION OF TWO 16-BIT NUMBERS

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to divide two 16-bit numbers was written and executed using 8086
microprocessor and the results were tabulated.
EX.NO:05

DATE:

CONVERSION OF ASCII TO BINARY CODE


AIM:
To write an assembly language program to convert ASCII code to binary value using 8086
microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit, +5V power supply.

ALGORITHM:
Step 1: Start the program.
Step 2: Move the contents of 5000H to SI.
Step 3: Move ASCII value to AL register.
Step 4: Subtract content of AL by 30.
Step 5: Compare OA with AL register.
Step 6: If carry, move contents of AL register to SI.
If no carry, subtract content of AL register by 07.
Step 7: Stop.

PROCEDURE:

 The value 5000H is moved to source index.


 The input ASCII is moved to register AL and value 30 is subtracted from the same.
 The result is compared with OA.
 If there is borrow, contents of AL is moved to source index.
 If there is no borrow, 07 is subtracted from contents of AL and the result is moved to source index.
PROGRAM:ASCII TO BINARY
ADDRESS MNEMONIC OPERAND OPCODE REMARKS
0000:8000 MOV SI,5000H BE,00,30 Move contents of 5000H to SI.
0000:8003 MOV AL,38 BO,08 Move ASCII to AL.
0000:8005 SUB AL,30 3C,58 Subtract contents of AL with 30.
0000:8007 CMP AL,0A 72,02 Compare 0A with data in AL.
0000:8009 JB 800D 04,07 Jump if borrow to 800DH.
0000:800B SUB AL,07 04,30 Subtract AL with 07.
0000:800D MOV [SI],AL 88,04 Move AL to offset value of SI.
0000:800F HLT F4 Halt.

TABULATION : ASCII TO BINARY

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus, an assembly language program to convert ASCII to binary value was written and executed using
8086 microprocessor and the results were tabulated.
EXP NO:06

DATE:

CONVERSION OF BINARY TO ASCII CODE

AIM:
To write an assembly language program to convert binary number to ASCII code and verify them using
8086 microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit,+5v power supply.

ALGORITHM:
Step 1: Start
Step 2: Move contents of 5000H to SI.
Step 3: Move 08 to register AL.
Step 4: Compare 0A with AL.
Step 5: If carry, add AL with 30.
If no, add AL with 07 and 30.
Step 6: Move result to SI.
Step 7: Stop.

PROCEDURE:
 The source index is pointed to the operand's memory location.
 Registers AL is assigned value 08 and compared with OAH.
 If there is carry,30 is added with AL.
 If no carry ,7 is added with AL and then 30 is added with AL.
 Value in register AL is moved to source index.
PROGRAM: BINARY TO ASCII
ADDRESS MNEMONIC OPERAND OPCODE REMARKS
0000:8000 MOV SI,5000H BE,00,50 Move contents of 5000H to SI.
0000:8003 MOV AL,08 BO,08 Move 08 to AL.
0000:8005 CMP AL,0A 3C,0A Compare 0A with data in AL.
0000:8007 JC 800B 72,02 Jump if carry to 800BH.
0000:8009 ADD AL,07 04,07 Add AL with 07.
0000:800B ADD AL,30 04,30 Add AL with 30.
0000:800D MOV [SI],AL 88,04 Move AL to offset value of SI.
0000:800F HLT F4 Halt.

TABULATION : BINARY TO ASCII

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to execute binary to ASCII code is executed and the results were
verified using 8086 microprocessor.
EX NO:07

DATE:

SORTING OF NUMBERS IN ASCENDING ORDER


AIM:
To write an assembly language program to execute the sorting of numbers in ascending order using 8086
microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit, +5V power supply

ALGORITHM:
Step 1: Start.
Step 2: Move contents of 5000H to SI.
Step 3: Move [SI] to BX register.
Step 4: Decrement BX.
Step 5: Move contents of 5000H to SI.
Step 6: Move [SI] to CX register.
Step 7: Decrement CX.
Step 8: Increment SI twice.
Step 9: Move [SI] to AX register.
Step 10: Increment SI twice.
Step 11: Compare AX with [SI].
Step 12: If borrow, jump to step 16.
Step 13: Move SI to DX.
Step 14: Move AX to [SI].
Step 15: Decrement SI twice.
Step 16: Move DX to SI.
Step 17: Increment SI twice.
Step 18: Decrement CX.
Step 19: If not equal to zero, go to step 9, if not decrement BX.
Step 20: If not equal to zero, jump to step 5, if equal go to next step.
Step 21: Stop

PROCEDURE:
 Start the program.
 Move the contents of 5000H to source index and offset value to register BX.
 Contents of register BX is decremented by 1.
 The contents of 5000H is moved to SI and offset value to register CX.
 Contents of register CX is decremented by 1.
 Contents of SI are incremented by 1 twice.
 The offset value of SI is moved to register AX.
 Contents of SI are incremented by 1 twice.
 Compare value in SI with that in accumulator.
 If there is borrow, contents of CX register is decremented by 1.
 If there is no borrow, move value in SI to DX register and contents of SI is decremented by 1.
 Move contents of DX register to SI.
 Increment contents of SI by 1 twice and decrement contents of CX register.
 Jump to step 7 if not equal. Decrement contents in register BX.
 Jump to step 4 if not equal to the same.
 Stop the program.
PROGRAM: SORTING OF NUMBERS IN ASCENDING ORDER

ADDRESS MNEMONICS OPERAND OPCODE COMMENTS


0000:2000 MOV SI,5000H BE 00 50 Move data from 5000H to SI
0000:2003 MOV BX,[SI] 8B 1C Move SI offset value to BX.
0000:2005 DEC BX 4B Decrement data of BX
register by 1.
0000:2006 MOV SI,5000H BE 00 50 Move data from 5000H to SI
0000:2009 MOV CX,[SI] 8B OC Move offset value to CX.
0000:200B DEC CX 49 Decrement contents of CX
register by 1.
0000:200C INC SI 46 Increment SI.
0000:200D INC SI 46 Increment SI.
0000:200E MOV AX,[SI] 8B 04 Move offset value in SI to
AX register.
0000:2010 INC SI 46 Increment SI.
0000:2011 INC SI 46 Increment SI.
0000:2012 CMP AX,[SI] 3B 04 Compare data of SI with AX
0000:2014 JB 2020H 72 0A Jump if borrow to 2020H.
0000:2016 MOV DX,[SI] 8B 14 Move offset of SI to DX.
0000:2018 MOV [SI],AX 89 04 Move AX to offset of SI.
0000:201A DEC SI 4E Decrement SI.
0000:201B DEC SI 4E Decrement SI.
0000:201C MOV [SI],DX 89 14 Move DX to SI.
0000:201E INC SI 46 Increment SI.
0000:201F INC SI 46 Increment SI.
0000:2020 DEC CX 49 Decrement CX register.
0000:2021 JNE 200EH 75 EB Jump if not equal to 200EH.
0000:2023 DEC BX 4B Decrement BX register.
0000:2024 JNE 2006H 75 E0 Jump if not equal to 200BH.
0000:2026 HLT F4 Halt.
TABULATION : SORTING OF NUMBERS IN ASCENDING ORDER

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus, an assembly language program to sort the given numbers in ascending order was written and
executed using 8086 microprocessor and results were tabulated.
EX. NO:08

DATE:

SORTING OF NUMBERS IN DESCENDING ORDER

AIM:
To write an assembly language program to execute writing of numbers in descending order using 8086
microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit,+5V power supply.

ALGORITHM:
Step1:Start.
Step 2: Move contents of 5000H to SI.
Step 3: Move offset value to BX.
Step 4: Decrement BX.
Step 5: Move contents of 5000H to SI.
Step 6: Move offset value in SI to CX.
Step 7: Decrement CX.
Step 8: Increment SI twice.
Step 9: Move offset value in SI to AX.
Step 10: Increment SI twice.
Step 11: Compare SI value with AX register.
Step 12: Jump if no borrow to 2020H.
Step 13: Move contents of SI to DX.
Step 14: Move contents of AX to SI.
Step 15: Decrement SI twice.
Step 16: Move contents of DX to SI.
Step 17: Increment SI twice.
Step 18: Decrement CX register.
Step 19: Jump if not equal to 200EH.
Step 20: Decrement BX register.
Step 21: Jump if not equal to 2006H.
Step 22: End the program.
PROCEDURE:
 Initially contents of 5000H is moved to SI and offset value is moved to register BX.
 Contents of register BX is decremented by 1.
 The content of 5000H is moved to SI and offset value is moved to register CX.
 The contents of register CX is decremented by 1.
 The value in SI is pointed to consecutive values and is compared with that in accumulator.
 If there is borrow,value in SI is moved to register DX and value in accumulator is decremented by 1.
 The loop is repeated until same value is obtained.
 Stop the program.

PROGRAM: SORTING OF NUMBERS IN DESCENDING ORDER

ADDRESS MNEMONIC OPCODE OPERAND REMARKS


0000:2000 MOV BE 00 50 SI,5000H Move contents of 5000H to SI.
0000:2003 MOV 8B 1C BX,[SI] Move offset of SI to BX.
0000:2005 DEC 4B BX Decrement BX.
0000:2006 MOV BE 00 50 SI,5000H Move data from 5000H to SI.
0000:2009 MOV 8B 0C CX,[SI] Move offset value of SI to CX.
0000:200B DEC 49 CX Decrement CX.
0000:200C INC 46 SI Increment SI.
0000:200D INC 46 SI Increment SI.
0000:200E MOV 8B 04 AX,[SI] Move offset value of SI to AX.
0000:2010 INC 46 SI Increment SI.
0000:2011 INC 46 SI Increment SI.
0000:2012 CMP 3B 04 AX,[SI] Compare data in offset of SI to AX
0000:2014 JNB 73 0A 2020H Jump if no borrow to 2020H.
0000:2016 MOV 8B 14 DX,[SI] Move offset to DX.
0000:2018 MOV 89 04 [SI],AX Move AX data to offset of SI.
0000:201A DEC 4E SI Decrement SI.
0000:201B DEC 4E SI Decrement SI.
0000:201C MOV 89 14 [SI],DX Move DX offset of SI.
0000:201E INC 46 SI Decrement SI.
0000:201F INC 46 SI Decrement SI.
0000:2020 DEC 49 CX Decrement CX.
0000:2021 JNE 75 EB 200EH Jump if not equal to 200EH.
0000:2023 DEC 4B BX Decrement BX.
0000:2024 JNE 75 E0 2006H Jump if not equal to 2006H.
0000:2026 HLT F4 F4 Halt.
TABULATION : SORTING OF NUMBERS IN DESCENDING ORDER

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to sort the given numbers in descending order was written and
executed using 8086 microprocessor and the results were tabulated.
EX. NO:09

DATE:

STRING PALINDROME

AIM:
To write an assembly language program to compute the string palindrome using 8086 microprocessor.

APPARUTUS REQUIRED:
8086 microprocessor kit , +5V power supply

ALGORITHM:
Step 1: Start.
Step 2: Move data into SI and DI.
Step 3: Move 03H to CL.
Step 4: Move data from SI to AH and DI to AI.
Step 5: Compare AL with AH.
Step 6: Jump if not equal to STEP 10.
Step 7: Decrement DI and CI & increment SI.
Step 8: Jump if not equal to STEP 4.
Step 9: Jump to STEP 13.
Step 10: Move data from 3006H to SI.
Step 11: Move data 01 to CH and move CH data to offset of SI.
Step 12: Jump to stop.

PROCEDURE:
 Move the 3004H to DI and 3000H to SI and 03H to the register CL.
 Move the data in offset [SI] to register AH and data in offset address [DI] to register AL.
 Compare data in AL with AH.
 If not equal, store 01H in 3006H and register 0H.
 If equal ,increment contents of SI and decrements contents of DI and repeat step 2. Decrements register CL by
1.
 Proceed until register CL goes to 00H.

PROGRAM: STRING PALINDROME

ADDRESS LABEL MNEMONIC OPERAND OPCODE REMARKS

0000:2000 MOV SI,3000H BE 10 30 Move contents from


3000H to SI.

0000:2003 MOV DI,3004H BF 04 30 Move 3004H to DI.

0000:2006 MOV CL,03H B1 03 Move immediate 03H to


CL.

0000:2008 LOOP MOV AH,[SI] 8A 24 Move offset SI to AH.

0000:200A MOV AL,[DI] 8A 05 Move [DI] contents to AL.

0000:200C CMP AL,AH 3A C4 Compare AL with AH.

0000:200E JNZ LAST 75 0B Jump on non-zero to


LAST.

0000:2010 DEC DI 4F Decrement DI contents by


1.
0000:2011 INC SI 46 Increment SI by 1.

0000:2012 DEC CL FE C9 Decrement CL by 1.

0000:2014 JNZ LOOP 75 F2 Jump on non-zero to


LOOP.

0000:2016 JMP LOOP1 EB 09 Jump to LOOP1.

0000:2018 LAST MOV SI,3006H BE 06 30 Move 3006H to SI.

0000:201B MOV CH,01H B5 01 Move data 01H to CH.

0000:201D MOV [SI],CH 88 2C Move CH to SI.

0000:201F JMP END EB 07 Jump to END.

0000:2021 LOOP1 MOV SI,3006H BE 06 30 Move 3006H to [SI].

0000:2024 MOV CH,00H B5 00 Move 00H to CH.

0000:2026 MOV [SI],CH 88 2C Move CH to SI.

0000:2028 END HLT F4 Stop.

TABULATION : STRING PALINDROME


INPUT OUTPUT

ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to check if the given string is palindrome was executed using 8086
microprocessor and the results were tabulated.
EX NO:10
DATE:

STRING REVERSAL

AIM:
To write an assembly language program to perform string reversal operation using 8086
microprocessors.

APPARATUS REQUIRED:
8086 microprocessor kit,+5V power supply.

ALGORITHM:
Step 1 : Start.
Step 2 : Move data in 3000H to SI.
Step 3 : Move data in 3004H to DI.
Step 4 : Move 03H to CL.
Step 5 : Move contents from SI offset address to AH.
Step 6 : Move contents from DI offset address to AL.
Step 7 : Interchange the contents of AL to AH .
Step 8 : Move data from AH to offset address of SI.
Step 9 : Move data from AL to offset address of DI.
Step10: Decrement DI.
Step11: Increment SI.
Step12: Decrement SI.
Step13: Jump on no zero to 2008H.
Step14: Stop.

PROCEDURE:
 This program reverses the string.
 Load SI with contents of 3000H and DI with 3004H.
 Move contents from SI offset address to AH and DI to AL, and interchange contents of AH with AL.
 Move contents of AH to SI,AL to DI.
 Decrement DI and increment SI and decrement SI.
 Jump on no zero to loop.
PROGRAM: STRING REVERSAL

ADDRESS LABEL MNEMONICS OPERAND OPCODE COMMENTS


0000:2000H MOV SI,3000H BF 00 30 Move 3000H to SI.
0000:2003H MOV DI,3004H BF 04 30 Move 3004H contents
to DI.
0000:2006H MOV CL,03H BI 03 Move 03H to CL.
0000:2008H LOOP MOV AH,[SI] BA 24 Move contents from SI
to AH
0000:200AH MOV AL,[DI] 8A 05 Move contents from DI
to AL.
0000:200CH XCHG AL,AH 86 64 Exchange contents of
AH to AL.
0000:200DH MOV [SI],AH 88 05 Move all contents to SI.
0000:200FH MOV [DI],AL 4F AL to DI.
0000:2011H DEC DI 46 Decrement DI.
0000:2012H INC SI 46 Increment SI.
0000:2013H DEC CL FE C9 Decrement CL by 1.
0000:2014H JNZ LOOP 75 F0 Jump on no zero to
loop1.

0000:2016H HLT F4 Halt.

TABULATION: STRING REVERSAL

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to compute string reversal using 8086 microprocessor was
executed.
EX. NO:11

DATE:

AVERAGE OF DATA

AIM:
To write an assembly language program to compute the average of given data using 8086 microprocessor.

APPARUTUS REQUIRED:
8086 microprocessor kit , +5V power supply

ALGORITHM:
Step 1: Start.

Step 2: Move data 0000H to AX.

Step 3: Move data from 3000H to SI.

Step 4: Move data from AX to code segment.

Step 5: Move 05H to CX.

Step 6: Add contents of offset address of SI and AX.

Step 7: Increment SI twice.

Step 8: Move 05H to CX and divide CX data.

Step 9: Move data from 300AH to SI & AX to offset of SI.

Step 10: Interrupt 03.

Step 11: Give inputs in the form of Data Word.

Step 12: stop.


PROCEDURE:
 This program computes the average of data.
 Move the value 0 to AX and contents of 3000 to SI.
 Move contents of AX to CS and 05H to CX.
 Add contents of SI with AX.
 Increment SI twice.
 Move onto CX and divide CX.
 Move the value at 300AH to SI and AX to SI.
 Give the inputs in form of data word (DW).

PROGRAM: AVERAGE OF DATA

ADDRESS MNEMONIC OPERAND OPCODE REMARKS

0000:2000 MOV AX,0000H BE 00 00 Move 0000H to AX.

0000:2003 MOV SI,3000H BF 30 00 Move 3000H to SI.

0000:2006 MOV CS,AX BE C8 Move contents of AX to CS.

0000:2008 MOV CX,05 B9 00 05 Move 05H data to CX.

0000:200B ADD AX,[SI] 03 04 Add data of SI to AX.

0000:200D INC SI 46 Increment SI.

0000:200E INC SI 46 Increment SI.

0000:200F LOOP 200B E2 FA Loop 200B.

0000:2011 MOV CX,05 B9 05 00 Move 05H data to CX.

0000:2014 DIV CX F7 F1 Divide CX.

0000:2016 MOV SI,300A BE 0A 30 Move 300A data to SI.

0000:2019 MOV [SI],AX 89 04 Move AX data to SI.

0000:201B INT 03 CC Interrupt 03


0000:201C ORG 3000

0000:2020 DW 1000

0000:2022 DW 2000

0000:2024 DW 3000

0000:2026 DW 4000

0000:2028 DW 5000

TABULATION : AVERAGE OF DATA

INPUT OUTPUT

ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus an assembly language program to compute the average of data was executed using 8086 microprocessor
and the results were tabulated.
EX NO: 12
DATE:

FACTORIAL OF A NUMBER

AIM:
To write an assembly language program to find the factorial of a given number using 8086
microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit, +5V Power supply

ALGORITHM:
Step 1: Start.
Step 2: Move 0000H to AX and AX data to code segment.
Step 3: Move AX data to data segment.
Step 4: Move data from 3000H to SI.
Step 5: Move data from offset address SI to AL and BL.
Step 6: Decrement BL.
Step 7: Jump over zero.
Step 8: Move data from BL to offset address SI and multiply.
Step 9: Jump to step 5.
Step 10: Move data of AX to offset address of DI.
Step 11: Interrupt 03.
Step 12: Stop.

PROCEDURE:
 This program computes the factorial of a number.
 Move the value 0000H to AX and AX to CS.
 Move the contents of AX to DS and 3000H to M.
 Move contents of SI to AL and BL.
 Decrement BL. Jump on zero to 2018H.
 Move contents of BL to SI.
 Move contents of 3100H to DI.
 Move the value of AX to DI.
PROGRAM: FACTORIAL OF A NUMBER

ADDRESS MNEMONICS OPERAND OPCODE REMARKS


0000:2000 MOV AX,0000 B5 00 00 Move 0000H to AX.
0000:2003 MOV CS,AX SE CS Move AX contents to CS.
0000:2005 MOV DS,AX SE DS Move AX contents to DS.
0000:2007 MOV SI,3000 BE 0030 Move 3000H contents to SI.
0000:200A MOV AL,[SI] SE 04 Move SI data to AL.
0000:200C MOV BL,[SI] EA 1C Move SI contents to BL.
0000:200E DEC BL FE CB Decrement BL.
0000:2010 JZ 2018 74 06 Jump over zero to 2018.
0000:2012 MOV [SI],BL E8 14 Move BL to SI.
0000:2014 MUL [SI] F7 24 Multiply SI.
0000:2016 JMP 200C EB F4 Jump to 200CH.
0000:2018 MOV DI,3100 BF 00 31 Move 3100H data to DI.
0000:201B MOV [DI],AX F9 05 Move AX contents to DI.
0000:201D INT 03 CC Halt interrupt 03.

TABULATION : FACTORIAL OF A NUMBER

INPUT OUTPUT

ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus, the assembly language program to compute the factorial of a number was executed
using 8086 microproceesor.
EX NO:13

DATE:
LARGEST VALUE IN A STRING
AIM:
To write an assembly language program to find the largest value in a string of data bytes using
8086 microprocessor.

APPARATUS REQUIRED:
8086 microprocessor kit , +5 power supply.

ALGORITHM:
Step 1: Start the program.
Step 2: Move contents of 5000 to SI.
Step 3: Move contents of SI to CX.
Step 4: Decrement value of CX and increment SI.
Step 5: Move contents of SI to AX.
Step 6: Increment SI and compare values in SI to AX.
Step 7: If it has no borrow jump to step 9 .
Step 8: Move the contents of SI to DX then to AX.
Step 9: Decrement value in CX.
Step 10: Jump to step 4 if not equal .
Step 11: Move the contents of 5100 to SI .
Step 12:Move contents of AX to SI.
Step 13:Stop the program.

PROCEDURE:
 This program finds the largest value from a string bytes stored from 5000 offset address onwards.
 Move contents of SI to segment CX.
 Decrement CX and increment SI.
 Move contents of SI to AX.
 Increment SI and compare its values with AX.
 If there is no borrow jump to address 2014.
 Otherwise move contents of DX to SI and then DX to AX.
 Decrement value in CX and if not equal jump to 200A.
 Move contents of 5100 to SI.
 Move the contents of AX to SI.
PROGRAM: LARGEST VALUE IN A STRING

ADDRESS MNEMONICS OPERAND REMARKS

0000:2000 MOV SI,5000 Move the contents of 5000 to SI.

0000:2003 MOV CX,[SI] Move contents of SI to CX.


0000:2005 DEC CX Decrease value of counter.
0000:2006 INC SI Increment SI.

0000:2007 INC SI Increment SI.


0000:2008 MOV AX,[SI] Move contents of SI to AX.
0000:200A INC SI Increment SI.
0000:200B INC SI Increment SI.
0000:200C CMP AX,[SI] Compare values in AX and SI.
0000:200E JNB 2014 Jump on no borrow to 2014.
0000:2010 MOV DX,[SI] Move contents of SI to DX.
0000:2012 MOV AX,DX Move value in DX to AX.
0000:2014 DEC CX Decrement value in CX.
0000:2015 JNE 200A Jump if not equal o 200A.
0000:2017 MOV SI,5100 Move contents of 5100 to SI.
0000:201A MOV [SI],AX Move contents of AX to SI.
0000:201C HLT Halt.
TABULATION: LARGEST VALUE IN A STRING

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

RESULT:
Thus, an assembly language program to find the largest value in a string was executed and the
results were tabulated.

You might also like