Cse Lab Update
Cse Lab Update
List of Experiments:
EXPERIMENT NO : 1
AIM: To write an ALP (8086) to find out the sum of given ‘n’ 8-bit numbers.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment.
4. Clear the AX and BX registers.
5. Take the count value into CL register.
6. Copy the offset address of numlist and move the first value into BL.
7. Perform repeated addition till the count value becomes zero.
8. Store the sum in the offset address defined for RESULT in data segment.
9. Terminate the program.
10. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
COUNT EQU 6d
NUMLIST DB 19h,29h,39h,49h,59h,99h
RESULT DW 01h DUP (?)
. CODE
MOV AX, @DATA
MOV DS, AX
OUTPUT: 01B6H
RESULT: Thus the sum of given ‘n’ 8-bit numbers has been executed successfully and the result
is verified.
AIM: To write an ALP (8086) to perform the addition of two 32-bit numbers.
ALGORITHM:
1. Start
2. LSW of 1st operand is moved to AX register.
3. LSW of 2nd operand is moved to BX register.
4. Add the contents of AX and BX registers and the result is stored in AX register.
5. Copy the LSW of result present in AX register into CX register.
6. MSW of 1st operand is moved to AX register.
7. MSW of 2nd operand is moved to BX register.
8. Add the contents of AX and BX registers along with carry (obtained from previous addition)
and the result is stored in AX register.
9. Copy the MSW of the result present in AX register into DX register.
10. Terminate the program.
11. Stop
INPUT 1: 5678F000h
INPUT 2: 12341000h
RESULT: Thus the program for addition of two double words has been executed successfully by
using TRAINER KIT and result is verified.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment.
4. Clear the AX and BX registers.
5. Take the count value into CL register.
6. Copy the offset address of numlist and move the first value into BL.
7. Perform repeated subtraction till the count value becomes zero.
8. Store the result in the offset address defined for RESULT in data segment.
9. Terminate the program.
10. Stop
PROGRAM:
DATA SEGMENT
VAR1 DB 53H
VAR2 DB 2AH
RES DB?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,VAR1
MOV BL,VAR2
SUB AL,BL
OUTPUT:
RESULT: Thus the subtraction of given ‘n’ 8-bit numbers has been executed successfully and the
result is verified.
EXPERIMENT NO :4
ALP for Subtraction of two 16-bit numbers
AIM: To write an ALP (8086) to perform the subtraction of two 16-bit numbers.
ALGORITHM:
1. Start
2. LSW of 1st operand is moved to AX register.
3. LSW of 2nd operand is moved to BX register.
4. Subtract the contents of BX from AX register and the result is stored in AX register.
5. Copy the LSW of result present in AX register into CX register.
6. MSW of 1st operand is moved to AX register.
7. MSW of 2nd operand is moved to BX register.
8. Subtract the contents of BX from AX registers along with borrow (obtained from previous
subtraction) and the result is stored in AX register.
9. Copy the MSW of the result present in AX register into DX register.
10. Terminate the program.
11. Stop
PROGRAM :
DATA SEGMENT
VAR1 DW 8560H
VAR2 DW 3297H
RES DW?
DATA ENDS
ASSUME CS: CODE,DS:DATA
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
RSR RCET, BHILAI Assistant Prof. Nanda R Mude Page 8
MICROPROCESSOR LAB MANUAL
B.Tech CSE 5th Sem
MOV AX, VAR1
CLC
SUB AX, VAR2
MOV RES, AX
INPUT 1: 8560 h
INPUT 2:3297h
OUTPUT: AX=
RESULT: Thus the program for subtraction of two words has been executed successfully by using
TRAINER & result is verified.
AIM: To write an ALP (8086) to perform the subtraction of two 32-bit numbers.
ALGORITHM:
1. Start
2. LSW of 1st operand is moved to AX register.
3. LSW of 2nd operand is moved to BX register.
4. Subtract the contents of BX from AX register and the result is stored in AX register.
5. Copy the LSW of result present in AX register into CX register.
6. MSW of 1st operand is moved to AX register.
7. MSW of 2nd operand is moved to BX register.
8. Subtract the contents of BX from AX registers along with borrow (obtained from previous
subtraction) and the result is stored in AX register.
9. Copy the MSW of the result present in AX register into DX register.
10. Terminate the program.
11. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
. CODE
MOV AX, 0111h
MOV BX, 1000h
SUB AX, BX MOV
CX, AX MOV AX,
5678h MOV BX,
1234h SBB AX, BX
MOV DX, AX INT
21h
END
INPUT 1: 56780111h
DX: CX=4443F111h
RESULT: Thus the program for subtraction of two double words has been executed successfully by
using TRAINER & result is verified.
EXPERIMENT NO : 6(B)
AIM: To write an ALP (8086) to perform the multiplication of two unsigned 16-bit numbers.
RESULT: Thus the program for multiplication of two 16-bit program executed successfully by
using TRAINER & result is verified.
AIM: To write an ALP (8086) to perform the multiplication of two 8-bit numbers.
ALGORITHM:
1. Start
2. Copy the first 8 bit operand into AL register.
3. Copy the second 8 bit operand into BL register.
4. Perform multiplication between the values stored in AL and BL , observe the MSW of the result
present in DX and LSW in AX.
5. Terminate the program.
6. Stop
PROGRAM:
DATA SEGMENT
VAR1 DB 0EDH
VAR2 DB 99H
RES DW?
DATA ENDS
ASSUME CS: CODE, DS:DATA
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, VAR1
MOV BL, VAR2
MUL BL
INPUT 1: 80h
INPUT 2: 20h
OUTPUT: AX=
RESULT: Thus the program for multiplication of two 8 bit numbers has been executed
successfully by using TRAINER and result is verified.
AIM: To write an ALP (8086) to perform the multiword division of 16-bit by 08 bit number.
APPARATUS: 8086 trainer kit, keyboard.
ALGORITHM:
1. Start
2. Copy the 16 bit dividend into AX register.
3. Copy the 8 bit divisor into BL register.
4. Perform division between the values stored in AX and BL, observe the quotient in AL and
remainder in AH.
5. Terminate the program.
6. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
. CODE
MOV AX, 1234h
MOV BL, 58h DIV
BL
INT 21h
END
INPUT 1: 1234h
INPUT 2: 58h
OUTPUT: AL (Q) = 34H AL
(R) =54H
RESULT: Thus the division of 16-bit by 8-bit number program executed successfully by using
TRAINER and result is verified.
EXPERIMENT NO : 8
To evaluate arithmetic expressions
AIM: To write an ALP (8086) to evaluate given arithmetic expression is f = (a+b) (b+c) (c+d)
(a+b+c+d)
APPARATUS: 8086 Tainer kit,keyboard.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment through AX register.
4. Copy the variable data a & b into AL & BL and perform the addition between AL & BL.
5. Initialize the starting address of result temporarily with SI register and store the result 1200h
location from the AL register.
6. Copy the variable data b & c into AL & BL and perform the addition between AL & BL.
7. Increment the SI register and store the result 1201h location from the AL register.
8. Copy the variable data c & d into AL & BL and perform the addition between AL & BL.
9. Increment the SI register and store the result 1202h location from the AL register.
10. Copy the variable data a into AL register and perform the addition between AL registers & b.
11. Add the content of AL and c then d to the AL register.
12. Copy the result into BL register from AL register & move the content in 1200h location to AL.
13. Multiply the content in AL with content available in 1201h location then multiply with content
in 1202h location perform the division.
14. Terminate the program.
15. Stop.
OUTPUT: AX = 050Ah
RESULT: Thus the program for given arithmetic expression was successfully executed.
AIM: To write an ALP (8086) to perform the string operation for sorting a string in an ascending
order.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment.
4. Specify the count value for external loop in DX and copy into CX register.
5. Take the offset address of list into SI register.
6. Copy the first number in list into the AL register.
7. Compare the number in AL register with subsequent number and exchange the position of the
numbers depending on result of the comparison.
8. Repeat step7 until the value present in CX register is Zero.
9. Repeat the steps 6,7and 8 until the DX becomes Zero and observe the results in ascending order.
10. Terminate the program.
11. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 53h, 10h, 24h, 12h
. CODE
MOV AX, @DATA
MOV DS, AX
MOV DX, 03h
AGAIN2: MOV CX, DX
MOV SI, OFFSET LIST
RSR RCET, BHILAI Assistant Prof. Nanda R Mude Page 19
MICROPROCESSOR LAB MANUAL
B.Tech CSE 5th Sem
AGAIN1: MOV AL, [SI]
CMP AL, [SI+1]
JL PR1
XCHG [SI+1], AL
XCHG [SI], AL PR1:
ADD SI, 01h LOOP
AGAIN1
DEC DX
JNZ AGAIN2
MOV AH, 4Ch
INT 21h
END
RESULT: Thus the program for sorting a string in an ascending order is executed successfully by
using TRAINER and result is verified.
EXPERIMENT NO : 9(B)
AIM: To write an ALP (8086) to perform the string operation for sorting a string in an descending
order.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment.
4. Specify the count value for external loop in DX and copy into CX register.
5. Take the offset address of list into SI register.
6. Copy the first number in list into the AL register.
7. Compare the number in AL register with subsequent number and exchange the position of the
numbers depending on result of the comparison.
8. Repeat step7 until the value present in CX register is Zero.
9. Repeat the steps 6,7& 8 until the DX becomes Zero and observe the results in descending order.
10. Terminate the program.
11. Stop.
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 53h, 10h, 24h, 12h
. CODE
MOV AX, @DATA
MOV DS, AX
MOV DX, 03h
AGAIN2: MOV CX, DX
MOV SI, OFFSET LIST
AGAIN1: MOV AL, [SI]
CMP AL, [SI+1]
JG PR1
XCHG [SI+1], AL
XCHG [SI], AL PR1:
ADD SI, 01h LOOP
AGAIN1
DEC DX
JNZ AGAIN2
MOV AH, 4C INT
21h
END
RESULT: Thus the program for sorting a string in descending order is executed successfully by
Trainer Kit and result is verified.
RSR RCET, BHILAI Assistant Prof. Nanda R Mude Page 22
MICROPROCESSOR LAB MANUAL
B.Tech CSE 5th Sem
EXPERIMENT NO : 10(A)
AIM: To write an ALP (8086) to determine the smallest number of a given array.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of data segment.
4. Take the offset address of array into SI register.
5. Copy the count value into CL register and clear the AX register.
6. Take the first number in list into AL regiser.
7. Compare the number in AL register with subsequent number and copy the smallest number into
AL register depending on result of the comparison.
8. Repeat step7 until the value present in CL register is Zero.
9. Terminate the program.
10. Stop.
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 02h, 09h, 03h, 06h, 08h, 07
. CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, OFFSET LIST
MOV CL, 05h
XOR AX, AX
MOV AL, [SI]
UP: INC SI
CMP AL, [SI] JB
GO
MOV AL, [SI] GO:
LOOP UP
INT 21h
END
OUTPUT: AL = 02H
RESULT: Thus the smallest number of a given ‘n’ number program was executed successfully
using TRAINER and result is verified.
AIM: To write an ALP (8086) to determine the smallest number of a given array.
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 02h, 09h, 03h, 06h, 08h, 07h
. CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, OFFSET LIST
MOV CL, 05h
XOR AX, AX
MOV AL, [SI]
UP: INC SI
CMP AL, [SI]
JNB GO
MOV AL, [SI] GO:
LOOP UP
INT 21h
END
OUTPUT: AL = 09H
RESULT: Thus the largest number of a given ‘n’ number program was executed successfully
using TRAINER and result is verified.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS and ES register with the starting address of data segment.
4. Copy the count value into CL register.
5. Get the offset address of array into SI register and clear the direction flag.
6. Copy the number to be search in AL register and scan repeatedly.
7. If not found display the message BYTE NOT FOUND.
8. If found display the message BYTE FOUND.
9. Terminate the program
10. Stop
EXPERIMENT NO : 12
ALGORITHM:
1. Start
2. Move the packed data into BL register and count value into BH register temporarily.
3. Copy the packed BCD data from BL to AL register and count value from BH to CL registers.
4. Perform shift left & rotate right operations by the AL with the count number of times specified.
5. Perform XOR and copy the lower byte of unpacked BCD data to DL register.
6. Copy the packed BCD data from BL to AL register and count value from BH to CL registers.
7. Perform shift right operations by the AL with the count number of times specified.
8. Perform XOR and copy the higher byte of unpacked BCD data to DH register.
9. Terminate the program.
10. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
. CODE
MOV BL, 57H MOV
BH, 04H MOV AL,
BL MOV CL, BH
SHL AL, CL ROR
AL, CL MOV DL,
AL MOV AL, BL
MOV CL, BH SHR
AL, CL MOV DH,
AL XOR DX, 3030h
INT 21H
END
RESULT: Thus the program for converting from BCD to ASCII has been executed successfully by
using TRAINER KIT and result is verified.
EXPERIMENT NO : 13
AIM: To write an ALP (8086) to move the block of data from one segment to another segment.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of source segment.
4. Initialize ES register with the starting address of destination segment.
5. Copy the number of bytes in the string to CL register.
6. Store the offset address in source and destination segments in SI and DI registers respectively.
7. Select the auto increment/decrement of offset address using direction flag.
8. Move the string bytes from source segment to destination segment until all the bytes are moved.
9. Terminate the program.
10. Stop
PROGRAM:
. MODEL SMALL
. STACK
. DATA
STRING DB ’COMPUTER’
STRING1 DB 8 DUP (?)
. CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CL, 08H
MOV SI, OFFSET STRING MOV
DI, OFFSET STRING1
CLD
REP MOVSB INT
21H
END
INPUT: COMPUTER
RESULT: Thus the program to move a block of string from one memory location to another
memory location is executed successfully.
EXPERIMENT NO : 14
Reverse String
AIM: To write an ALP (8086) to reverse the string using TRAINER software.
ALGORITHM:
1. Start
2. Define the data segment with required variables.
3. Initialize DS register with the starting address of source segment.
4. Initialize ES register with the starting address of destination segment.
5. Copy the number of bytes in the string to CL register.
6. Copy the offset address of STG into SI register and offset address of ATG1 into DI register.
7. Clear direction flag for copying from lowest address to highest address.
8. Copy the string characters in reverse order from source segment to destination segment.
9. Repeat step8 until the count becomes zero in CL register.
10. Terminate the program
11. Stop
PROGRAM:
RSR RCET, BHILAI Assistant Prof. Nanda R Mude Page 32
MICROPROCESSOR LAB MANUAL
B.Tech CSE 5th Sem
.MODEL SMALL
.STACK
.DATA
STG DB ‘SVCET’,’$’ STG1
DB 05H DUP (?), ‘$, COUNT
EQU 05H
.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX MOV CL,
COUNT MOV SI, OFFSET
STG
MOV DI, OFFSET STG1
CLD
ADD SI, 04h A1:
MOVSB DEC SI
DEC SI DEC
CL JNZ A1
MOV AH, 09H LEA
DX, STG1
INT 21H INT
03H END
INPUT: SVCET
OUTPUT: TECVS
RESULT: Thus the ALP for performing the reverse string operation has been successfully
executed.