Experiment - 1 Addition of Two 8 Bit Numbers
Experiment - 1 Addition of Two 8 Bit Numbers
AIM:
ALGORITHM:
THEORY:
To perform this task, we are using the ADD operation of 8085 Microprocessor. When
the result of the addition is the 1-byte result, then the carry flag will not be enabled.
When the result is exceeding the 1-byte range, then the carry flag will be 1
PROGRAM:
Input: 80 (4150)
80 (4251)
Output: 00 (4152)
01 (4153)
CONCLUSION:
AIM:
ALGORITHM:
THEORY:
In 8085, the SUB instruction is used 2’s complemented method for subtraction. When
the first operand is larger, the result will be positive. It will not enable the carry flag after
completing the subtraction. When the result is negative, then the result will be in 2’s
complemented form and carry flag will be enabled.
PROGRAM:
MVI C, 00 Initialize C to 00
LDA 4150 Load the value to Acc.
MOV B, A Move the content of Acc to B register.
LDA 4151 Load the value to Acc.
SUB B
JNC LOOP Jump on no carry.
CMA Complement Accumulator contents.
INR A Increment value in Accumulator.
INR C Increment value in register C
LOOP: STA 4152 Store the value of A-reg to memory address.
MOV A, C Move contents of register C to Accumulator.
STA 4153 Store the value of Accumulator memory address.
HLT Terminate the program.
OBSERVATION/RESULTS:
Input: 06 (4150)
02 (4251)
Output: 04 (4152)
01 (4153)
CONCLUSION:
AIM:
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Increment the value of carry.
7) Check whether repeated addition is over and store the value of product and carry
in memory location.
8) Terminate the program.
THEORY:
The 8085 has no multiplication operation. To get the result of multiplication, we should
use the repetitive addition method.
After multiplying two 8-bit numbers it may generate 1-byte or 2-byte numbers, so we
are using two registers to hold the result.
PROGRAM:
OBSERVATION/RESULTS:
Input: FF (4150)
FF (4151)
Output: 01 (4152)
FE (4153)
CONCLUSION:
AIM:
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register(B register).
3) Get the second data and load into Accumulator.
4) Compare the two numbers to check for carry.
5) Subtract the two numbers.
6) Increment the value of carry .
7) Check whether repeated subtraction is over and store the value of product and
carry in memory location.
8) Terminate the program.
THEORY:
The 8085 has no division operation. To get the result of the division, we should use the
repetitive subtraction method.
By using this program, we will get the quotient and the remainder. 4153H will hold the
quotient, and 4152H will hold the remainder.
PROGRAM:
LXI H, 4150
MOV B, M Get the dividend in B – reg.
MVI C, 00 Clear C – reg for qoutient
INX H
MOV A, M Get the divisor in A – reg.
NEXT: CMP B Compare A - reg with register B.
JC LOOP Jump on carry to LOOP
SUB B Subtract A – reg from B- reg.
INR C Increment content of register C.
JMP NEXT Jump to NEXT
LOOP: STA 4152 Store the remainder in Memory
MOV A, C
STA 4153 Store the quotient in memory
HLT Terminate the program.
OBSERVATION/RESULTS:
Input: FF (4150)
FF (4251)
CONCLUSION:
AIM:
To find the smallest number in an array of data using 8085 instruction set.
ALGORITHM:
THEORY:
In this program the data are stored at location 4201H onwards. The 4200H is containing
the size of the block. After executing this program, it will return the smallest number and
store it at location 4300H.
Logic is simple, we are taking the first number at register B to start the job. In each
iteration we are getting the number from memory and storing it into register A. Then if
B > A, then we simply update the value of B with A, otherwise go for the next iteration.
Thus we can find the smallest number in a block of bytes.
PROGRAM:
OBSERVATION/RESULTS:
Output: 0A (4300)
CONCLUSION:
Thus the program to find the smallest number in an array of data was executed
EXPERIMENT-6
LARGEST NUMBER IN AN ARRAY OF DATA
AIM:
To find the largest number in an array of data using 8085 instruction set.
ALGORITHM:
THEORY:
In this program the data are stored at location 4201H onwards. The 4200H is
containing the size of the block. After executing this program, it will return the largest
number and store it at location 4300H.
Logic is simple, we are taking the first number at register B to start the job. In each
iteration we are getting the number from memory and storing it into register A. Then
if B < A, then we simply update the value of B with A, otherwise go for the next
iteration. Thus we can find the largest number in a block of bytes.
PROGRAM:
OBSERVATION/RESULTS:
Output: FE (4300)
CONCLUSION:
Thus the program to find the largest number in an array of data was executed
EXPERIMENT-7
BCD TO HEX CONVERSION
AIM:
To convert two BCD numbers in memory to the equivalent HEX number using
8085 instruction set
ALGORITHM:
THEORY:
In this problem we are taking a BCD number from the memory and converting
it to its binary equivalent. At first we are cutting each nibble of the input. So if
the input is 52 (0101 0010) then we can simply cut it by masking the number by
0FH and F0H. When the Higher order nibble is cut, then rotate it to the left
four times to transfer it to lower nibble.
Now simply multiply the numbers by using decimal adjust method to get final
decimal result.
PROGRAM:
LXI H,4150
MOV A,M Initialize memory pointer
ADD A MSD X 2
MOV B,A Store MSD X 2
ADD A MSD X 4
ADD A MSD X 8
ADD B MSD X 10
INX H Point to LSD
ADD M Add to form HEX
INX H
MOV M,A Store the result
OBSERVATION/RESULTS:
Output: 4152 : 1D H
CONCLUSION:
Thus the program to convert BCD data to HEX data was executed.
EXPERIMENT- 8
HEX TO BCD CONVERSION
AIM:
To convert given Hexa decimal number into its equivalent BCD number using
8085 instruction set
ALGORITHM:
THEORY:
Here we are taking a number from the memory, and initializing it as a counter.
Now in each step of this counter we are incrementing the number by 1, and adjust
the decimal value. By this process we are finding the BCD value of binary number
or hexadecimal number.
We can use INR instruction to increment the counter in this case but this
instruction will not affect carry flag, so for that reason we have used ADI 10H
PROGRAM:
Input: 4150 : FF
CONCLUSION:
Thus the program to convert HEX data to BCD data was executed.
EXPERIMENT-9
HEX TO ASCII CONVERSION
AIM:
To convert given Hexa decimal number into its equivalent ASCII number
using 8085 instruction set.
ALGORITHM:
THEORY:
The logic behind HEX to ASCII conversion is very simple. We are just checking
whether the number is in range 0 – 9 or not. When the number is in that range,
then the hexadecimal digit is numeric, and we are just simply adding 30H with it to
get the ASCII value. When the number is not in range 0 – 9, then the number is
range A – F, so for that case, we are converting the number to 41H onwards.
PROGRAM:
OBSERVATION/RESULTS:
CONCLUSION:
Thus the given Hexadecimal number was converted into its equivalent ASCII Code.
EXPERIMENT-10
AIM:
ALGORITHM:
THEORY:
In this program we will arrange the numbers in bubble sorting technique. In this sorting
technique, it will be executed in different pass. In each pass the largest number is stored at
the end of the list. Here we are taking the numbers from location 4201H . The array size is
stored at 4200H.
PROGRAM:
LXI H,4200
MOV C,M
DCR C
REPEAT: MOV D,C
LXI H,4201
LOOP: MOV A,M
INX H
CMP M
JC SKIP
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
SKIP: DCR D
JNZ LOOP
DCR C
JNZ REPEAT
HLT
OBSERVATION/RESULTS:
CONCLUSION: