Question

6. Write an assembly program to find the largest of twenty 32-bit values stored in ascending memory starting at data1. Stor

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question:

Write an assembly program to find the largest of twenty 32-bit values stored in ascending memory starting at "data1". Store the largest data element found at "largest", and store the address of the largest data found at "largest address" .text .global main .equ data1, 0x40000000 .equ largest, Ox40001000 .equ largestaddress, 0x40001000 LDR RO, -data1 LDR R1,=largest LDR R2, largestaddress

Answer:

Step 1: Write a Assembly Code to store twenty (20) 32 bit values from Address 4050

Step 2: First main thing is that 20 32-bit values are stored in ascending memory starting at "data1"

Step 3: Store the first element of the array to 'A'

Step 4: Comparing A with other elements of array, If A is smaller then stored the element in A, otherwise compare with next element.

Below is the data-segment

text

.global main

.equ data1, 0x40000000

.equ largest, Ox40001000

.equ largestaddress, 0x40001000 LDR RO, -data1 LDR R1,=largest LDR R2, largestaddress

Step 5: Value of A is the Answer

As per above steps below is the assembly code

==============================================================================.

Memory Address Instructions Comments

4000 LXI H,4050 H <-40,L <-50

4003 MOV C,M C <-M

4004 DCR C C <- C-1

4005 INX H HL <- HL+0001

4006 MOV A,M A<- M

4007 INX H HL <- HL+0001  

4008 CMP M A-M

4009 JNC 400D If Carry Flag=0, goto 400D

400C MOV A,M A <-- M

400D DCR C C<-- C-1

400E JNZ 4007 If Zero Flag=0, goto 4007

4011 STA 3050 Store A Value to Address 3050

4014 HLT Stop the Program

==============================================================================

Write Compile and execute the program in x85/x86 compatible operating systems.

Give different input variables for 20 32bit numbers are verify the output of largest number within those 20 numbers.

For Example 20 Input numbers are

1 3 4 5 6 8 7 9 11 14 15 17 19 21 23 27 30 34 67 70

Above Input is stored from 4050 onwards

Now Ran the above Assembly code and the largest number is 70 Stored in Address 3050     

Add a comment
Know the answer?
Add Answer to:
6. Write an assembly program to find the largest of twenty 32-bit values stored in ascending memory starting at "data1". Store the largest data element found at "largest", and store t...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT