Question

In: Computer Science

Suppose you have the following set of hexadecimal values: $20, $25, $40, $50, $12. Write a...

Suppose you have the following set of hexadecimal values: $20, $25, $40, $50, $12. Write a segment of program to find the minimum and maximum values of the set. Answer must be written in assembly.

Solutions

Expert Solution

For implementation of given problem we use CMP instruction which compare two operand by subtracting them
                        If Accumulator > Register then carry and zero flags are reset
                        If Accumulator = Register then zero flag is set
                        If Accumulator < Register then carry flag is set

Here List of numbers store from 2000H to 2004H and maximum number is at 2010H and minimum number is at 2011H.

It follow the following step for finding the minimum and maximum number from given number.

1. In B register maximum number is stored and in C register minimum number is stored.

2. Load counter =number of element in D register

3. Load starting element in Accumulator which is 2000h, B and C register

4. Compare Accumulator and B register

5. Transfer contents of Accumulator to B If carry flag is not set else, compare Accumulator with C register, if carry flag is set transfer contents of Accumulator to C

6. Decrement counter in D register

7. If D>0 take next element in Accumulator and go to point 4

8. If D=0, store B to 2010h and C register in memory 2011h

9. End of program

Program:

ADDRESS

LABEL

INSTRUCTION

COMMENT

2000H

LXI H, 2000H

Load starting address of list which is 2000h

2003H

MOV B, M

Store maximum in register B

2004H

MOV C, M

Store minimum in register C

2005H

MVI D, 05H

Counter for 5 elements set register D=5

2007H

LOOP:

MOV A, M

Retrieve list element in Accumulator

2008H

CMP B

Compare element with maximum number

2009H

JC MIN

Jump to MIN if not maximum

200CH

MOV B, A

Transfer contents of A to B as A > B

200DH

MIN:

CMP C

Compare element with minimum number

200EH

JNC SKIP

Jump to SKIP if not minimum

2011H

MOV C, A

Transfer contents of A to C if A < minimum

2012H

SKIP:

INX H

Increment memory to next address which is 2001h

2013H

DCR D

Decrement counter

2014H

JNZ LOOP

Jump to LOOP if D > 0

2017H

LXI H, 2010H

Load address 2010h to store maximum

201AH

MOV M, B

Move maximum to 2010H

201BH

INX H

Increment memory so next address is 2011h

201CH

MOV M, C

Move minimum to 2011H

201DH

HLT

Halt

Output:

If at any point you find any difficulty feel free ask me.


Related Solutions

Make a Frequency Distribution Chart for the following set of Data 50, 10, 25, 20, 20,...
Make a Frequency Distribution Chart for the following set of Data 50, 10, 25, 20, 20, 20, 50,100, 30, 15
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70...
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70 5 Draw a Histogram Draw a polygon After listening to YouTube “histogram and polygon,” explain how histogram is different and similar to polygon.
1) If you computed the 20% Trimmed mean on a data set with 50 values, how...
1) If you computed the 20% Trimmed mean on a data set with 50 values, how many values would you exclude, or throw away in total? 2) Why do people calculate a trimmed mean, anyway? 3) Calculate the Harmonic Mean for the values: 1, 2, 50, 200.
Write an assembly program that rearrange the values in the following array as 40, 30, 20,...
Write an assembly program that rearrange the values in the following array as 40, 30, 20, 10: .data byte1 BYTE 10, 20, 30, 40 Save the original four byte data into eax, and the rearranged data into ebx, from the least significant bit to the most significant bit. Insert a call DumpRegs statement to display the register values.
Calculate F Test for given 10, 20, 30, 40, 50 and 5,10,15, 20, 25. For 10,...
Calculate F Test for given 10, 20, 30, 40, 50 and 5,10,15, 20, 25. For 10, 20, 30, 40, 50:
Suppose that you have programmed your computer to do the following: (i) Draw 50 X values...
Suppose that you have programmed your computer to do the following: (i) Draw 50 X values from a uniform distribution between 10 and 20. (i.e. uniform on [10,20]) (ii) Count the number of X values greater than 18 and call this number G (iii) Divide G by 50 and call this number H (iv) Repeat steps i to iii to obtain 10,000 H values (v) Calculate the average H value and the variance of H Values Answer the following questions:...
Problem 1. A set of 25 measurements consists of the values 3 6 7 15 12...
Problem 1. A set of 25 measurements consists of the values 3 6 7 15 12 6 8 4 5 6 5 12 1 3 3 7 5 10 8 3 9 2 6 1 5 (a) Construct a relative frequency histogram to describe the data. (10 pts) (b) Find: the median m (5 pts), the sample mean ¯x (5 pts), the sample standard deviation s (5 pts), the upper and lower quartiles (10 pts), the 37-th percentile (5 pts)....
First, obtain a set of real-world numeric data. You should have 25 to 50 entries in...
First, obtain a set of real-world numeric data. You should have 25 to 50 entries in your data set. You can collect your own data or use data from an online source. In your initial post, list your data and calculate the five-number summary. Then, pose a problem that involves an analysis of the data. Do not provide a solution. Instead, be sure that you include enough relevant information so that your classmates can propose their solutions in their responses....
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini...
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini coefficient using the quintile distribution. 2. Draw the Lorenz curve with proper labels.
Question 1 For the dataset: 20, 20, 10, 10, 40, 50, 20, 30, 10, 20, 50,...
Question 1 For the dataset: 20, 20, 10, 10, 40, 50, 20, 30, 10, 20, 50, 60, 20, 30, 50, 20, 30, 40, 30, 30, 30, 50, 40 calculate the max, min, mode, median and mean.(20%) Draw a boxplot with inner and outer fence For the data in part (i), if the value 60 was replaced by 2000, what would you call this value in the dataset? What could be the explanation for such a value? How can you through...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT