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
-1.png)
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:
-2.png)
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
If we replace I by 32 I we can generate the followin... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
896-C-S-S-A-D (2587).docx
120 KBs Word File
