Professional Documents
Culture Documents
8086 All Basic Programs
8086 All Basic Programs
8086 All Basic Programs
NO: 1
DATE:
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
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 :
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
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:
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:
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
INPUT OUTPUT
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:
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 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
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:
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:
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:
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.
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:
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
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:
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.
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.
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
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.
0000:2020 DW 1000
0000:2022 DW 2000
0000:2024 DW 3000
0000:2026 DW 4000
0000:2028 DW 5000
INPUT OUTPUT
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
INPUT OUTPUT
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
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.