Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my assembly code. I need help with this part of the assignment. I need to estimate the median value of a

I need help with my assembly code. I need help with this part of the assignment. I need to estimate the median value of a list. Since the list length is even off the list, the estimated median will be computed by summing the first, last, and two middle values and then dividing by 4. Be sure to divide the length by 2 (and not hard-code the indexes). These are the list values.

lst dd 1246, 1116, 1542, 1240, 1677, 1635, 2426, 1820

dd 1246, -2333, 2317, -1115, 2726, 2140, 2565, 2871

dd 1614, 2418, 2513, 1422, -2119, 1215, -1525, -1712

dd 1441, -3622, -731, -1729, 1615, 1724, 1217, -1224

dd 1580, 1147, 2324, 1425, 1816, 1262, -2718, 2192

dd -1432, 1235, 2764, -1615, 1310, 1765, 1954, -967

dd 1515, 3556, 1342, 7321, 1556, 2727, 1227, -1927

dd 1382, 1465, 3955, 1435, -1225, -2419, -2534, -1345

dd 2467, 1315, 1961, 1335, 2856, 2553, -1032, 1835

dd 1464, 1915, -1810, 1465, 1554, -1267, 1615, 1656

dd 2192, -1825, 1925, 2312, 1725, -2517, 1498, -1677

dd 1475, 2034, 1223, 1883, -1173, 1350, 1415, 335

dd 1125, 1118, 1713, 3025

Here is my assembly code, but I am not sure what is wrong.

mov eax, dword [length]

cdq

shr eax, 1

mov ebx, dword [lst + eax*4]

add ebx, dword [lst + (eax-1)*4]

add ebx, dword [lst + (eax+1)*4]

add ebx, dword [lst + (eax+2)*4]

mov eax, ebx

mov ebx, 4

cdq

idiv ebx

mov dword [estMed], eax

The value I am getting is 3443, when I should be getting 2292. Please help.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

Stages of a Relationship?

Answered: 1 week ago