Question

In: Electrical Engineering

Write an Intel 8085 assembly program to find the largest of N numbers stored in memory...

Write an Intel 8085 assembly program to find the largest of N numbers stored in memory using the algorithm below. Hand trace (execute) the program showing the changes made to all affected registers and memory locations.

Max = a(1)

For i = n to N

If max < a(i) then max = a(i)

Next i

Solutions

Expert Solution

                ALGORITHM:

1) Load the address of the first element of the array in HL pair

2) Move the count to B – reg.

3) Increment the pointer

4) Get the first data in A – reg.

5) Decrement the count.

6) Increment the pointer

7) Compare the content of memory addressed by HL pair with that of A - reg.

8) If Carry = 0, go to step 10 or if Carry = 1 go to step 9

9) Move the content of memory addressed by HL to A – reg.

10) Decrement the count

11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.

12) Store the largest data in memory.

13) Terminate the program.

PROGRAM

PROGRAM

                                        Description

                LXI H,4200

Set pointer for array

                MOV B,M

Load the Count

                INX H

Set 1st element as largest data

                MOV A,M

Copy data from register M to accumulator

                DCR B

Decrements the count

LOOP:     INX H

Increment of HL pair by 1

                CMP M

f A- reg > M go to AHEAD

                JNC AHEAD

Jump to AHEAD if carry is not = 1

                MOVA,M

the new Set value as largest

AHEAD: DCR B

Decrement B

                JNZ LOOP

Repeat comparisons till count = 0

                STA 4300

Repeat comparisons till count = 0

                HLT

Stop program


Related Solutions

Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to 2FFF & transfer to 4000 to 4FFF
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location...
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000
Write an assembly program In MASM assembler to calculate the sum of odd numbers only stored...
Write an assembly program In MASM assembler to calculate the sum of odd numbers only stored in a 16-bit integers array. The size of the array is provided in a separate variable. Use the following design: Sum = 0 FOR i = 0 TO SizeOfArray - 1     IF Arr[i] % 2 = 1           Sum = Sum + Arr[i]     END IF END FOR
Assembly Language HW For this program you will find the largest common factor for 2 numbers,...
Assembly Language HW For this program you will find the largest common factor for 2 numbers, a and b. The largest common factor is the largest positive number that divides the two numbers. The C++ code for doing this is: int LCF (int a, int b) { if (a == 0 && b == 0)      b = 1; else      if (b == 0)           b = a;      else           if (a != 0)               ...
Write two algorithms to find both the smallest and largest numbers in a list of n...
Write two algorithms to find both the smallest and largest numbers in a list of n numbers. In first algorithm, you simply write one loop to find the minimum and maximum. So there will be 2(n - 1) comparisons. In second algorithm, you try to find a method that does at most 1.5n comparisons of array items. Determine the largest list size (i.e., n) that Algorithm 1 can process and still compute the answer within 60 seconds. Report how long...
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
Write a program in Easy68K: a) Define an array of numbers in the memory.
Write a program in Easy68K: a) Define an array of numbers in the memory. b) Read two numbers from keyboard. The first number is the size of the array and the second number is what index of the array you want to access. The index you entered can be larger than the array. c) Display the element indexed by (index % size) in the array. 
MIPS Assembly program: Accept N numbers from the user and sort the N numbers using any...
MIPS Assembly program: Accept N numbers from the user and sort the N numbers using any sorting algorithm. Print both the sorted array and unsorted array. N should be greater than or equal to 10.
Assignment Description: Develop and test an Intel 8086 assembly program that reads two decimal numbers x...
Assignment Description: Develop and test an Intel 8086 assembly program that reads two decimal numbers x and y. Your program should display the result of their: 1) Addition: x+y 2) Subtraction: x-y 3) Multiplication: x*y 4) Division: x / y Notes:  x and y are two-digit decimal numbers (i.e. 0-99).  The program should display an error message if the value of y is zero, in the case of division.  You can assume only positive numbers but you...
Write a MIPS assembly program to calculate the Fibonacci numbers from 1..n using the recursive method....
Write a MIPS assembly program to calculate the Fibonacci numbers from 1..n using the recursive method. The definition of a Fibonacci number is F(n) = F(n-1) + F(n-2). The implementation must follow the following guidelines: Prompt the user for a number n Allocate heap memory to hold the exact number of elements in the Fibonacci sequence for n Implement recursive Fibonacci method as a subprogram Print the Fibonacci sequence array
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT