Consider the following code fragment in a high-level language: for I in 1…100 lo
ID: 3680964 • Letter: C
Question
Consider the following code fragment in a high-level language:
for I in 1…100 loop
Sd S + Q(I). VAL
end loop;
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:
MOV ECX,1 ; use register ECX to hold I
LP: IMUL EAX, ECX, 32 ; get offset in EAX
MOV EBX, Q[EAX] ; load VAL field
ADD S, EBX ; add to S
INC ECX ; increment I
CMP ECX, 101 : compare to 101
JNE LP ; loop until I = 100
I need to rewrite the code using shift instead of IMUL
Explanation / Answer
You can use the command circshift
by passing the values as parameters.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.