Question: Consider the following code fragment in a high-level language: Assume that Q is an array of 32-byte records and the VAL field is in the

Consider the following code fragment in a high-level language:
Consider the following code fragment in a high-level language:
Assume that

Assume that Q is an array of 32-byte records and the VAL field is in the first 4 bytes of each record. Using x86 code, we can compile this program fragment as follows:

Consider the following code fragment in a high-level language:
Assume that

This program makes use of the IMUL instruction, which multiplies the second operand by the immediate value in the third operand and places the result in the first operand (see Problem 10.13). A RISC advocate would like to demonstrate that a clever compiler can eliminate unnecessarily complex instructions such as IMUL. Provide the demonstration by rewriting the above x86 program without using the IMUL instruction.

for I ..100 loop S S0(1).VAL end loop; MOV ECX.1 use register ECX to hold I LP IMUL EAX, ECX, 32 g offset in EAX MoV EBX, QIEAX d VAL field ADD S.EBX INC CMP JNE ECX ECX, 101 LP add to S increment I compare to 101 loop until I 100

Step by Step Solution

3.36 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

If we replace I by 32 I we can generate the followin... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

896-C-S-S-A-D (2587).docx

120 KBs Word File

Students Have Also Explored These Related Systems Analysis And Design Questions!