Lab1 ECE
Lab1 ECE
Note : Draw the flowchart for the solution of each problem and write efficient assembly language
programs for 8085 Microprocessor.
1. Write a program to multiply two 8-bit numbers stored in the memory location 3001H and
3002H using Shift and Add method. Store the answer in register pair H-L. (Higher byte of
the result in the H register and lower byte of the result in the L register).
2. Eight 16-bit unsigned numbers are stored in the memory 1000H-1000Fh (lower byte of the
16-bit number stored at lower address). Add all the numbers and store the sum in the memory
locations 2002H (Most significant byte), 2001H and 2000H.
3. Suppose a 16-bit number is present in register pair D-E. Find the 2’s complement of the
number and store the result in H-L register pair. Use the first register of the register pair as
the most significant byte.
4. Write a program to add two multi-byte numbers stored in the external memory. The first
number is stored at the external memory location 6000H, 6001H, 6002H and the second
number is stored at the external memory location 7000H, 7001H, 7002H (lower byte of data
stored at lower address). Write the result at the external memory location starting from
8000H.
5. Write a program to convert 8-bit binary number to BCD. Binary number is available at
external memory location at 2000H. Store result at the memory location 2001H (BCD2,BCD1)
and 2002H (BCD0).
6. Write a program to convert a 8-bit packed BCD number stored in the Accumulator to two
ASCII numbers corresponding to the two BCD digits and store the ASCII numbers in the
register pair D-E.
7. Write a program to add two packed BCD numbers stored at external memory location 6000H
and 6001H. Store the answer in memory location 6002H (for carry) and 6003H.
8. Perform operations on 16 bit packed BCD data stored in register pair B-C and D-E according
to contents of Accumulator as shown below. Use separate subroutine for each operation. Store
the answer in external memory locations 2001H, 2002H and 2003H(for carry/borrow).
10. Treat the register pair D-E (MSB in D) as 16-bit register and rotate them 2 places to the left
without involving the carry bit.
11. Write a program to sort an array of ten 8 bit numbers available in the external memory
location starting at 2000h onwards in ascending order. (After ordering, lowest value must
appear at 2000h).
12. Write a program to sort an array starting from external memory location 4000H in descending
order. Number of data elements is stored on external memory location 1FFFH.
13. Write a program to check whether the nth bit of a 16-bit number stored in external memory
location 4000H and 4001H (lower byte at lower address) is 1, Write FFH in A register if it is
1, else store 00H in A register. The value of n is stored in the B register.
14. Write a program to search a number in a given array of 10, 8-bit numbers. The array is stored
in the external memory at address starting at 4000H. The number to be searched is given in
B register. Write FFH in A register if it is found, else write 00H in A register. Write the
memory address of the number in H-L pair if it is found. Use the binary search algorithm.
15. Write a program to transfer a block of data from external memory location 4000H to 6000H.
The number of data bytes to be transferred is given in the register A.
16. Write a program to find the LCM and HCF of two 8-bit numbers stored in the external
memory location 3001h and 3002h. Write two subroutines to compute HCF and LCM. Store
the result in the register pair D-E for LCM and B for HCF.
17. Write a program to generate first 10 numbers of Fibonacci series and store in the external
memory locations starting 3000h.
18. Write a program to divide the 8-bit number in the B register by the data stored in C register.
Restore the number in B register using multiplication of the result and the answer of division
operation.
19. Write a program to count the number of data bytes stored in external memory locations 0100H
to 0200H that are greater than the random unsigned number in B register and less than the
random unsigned number stored in C register. Write the result in D-E register pair.
20. Suppose you need to create a wrapper (software module) to extend the arithmetic and logic
unit of 8085 microprocessor for 16 bit operations. Write the subroutines for each of the
following pseudo-instruction (corresponding to 8-bit instruction in 8085). Assume that the
operands are in the B-C and D-E register pair. In case only one operand is required, assume
it is in the B-C register pair. Result should be read from the H-L register pair. Carry flag
should be set/reset according to the result of addition and subtraction instruction. You need
not consider any other flag.
MYADD16
MYSUB16
MYAND16
MYOR16
MYXOR16
MYRLC16
MYRRC16
MYRAL16
MYRLR16
MYINC16
MYDEC16
You should preserve any register that you are going to use in your subroutines. Write a main
program to test some of these pseudo-instructions.