Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4. Comparing ISAs (20 points) In this question we will compare two different architectures The first is x86: an extended accumulator, CISC architecture with
Question 4. Comparing ISAs (20 points) In this question we will compare two different architectures The first is x86: an extended accumulator, CISC architecture with variable-length . The second is MIPS, a register-register RISC architecture with 32-bit fixed-length in- Consider the following C code which takes two integers (a and b) as inputs, computes the instructions and 32-bit data values structions and 32-bit data values Greatest Common Divisor (GCD) between them, and stores the result in memory 1 void gcd( int a, int b, int* result ) while ( b != 0 ) { int temp = b; b=a%b; a = temp ; 4 6 *result = a; If we were to take this code and compile it on an x86 machine (like your laptop), we would get the following assembly code. You can try this at home. I loop : test %esi, %esi 2 je End mov %eax, mov %edi, div %esi mov %esi, jmp loop mov (%rcx), %edi %esi 4 %edx 6 7 8 End : %edi If you were to try compiling this yourself, you would get the above output. In this assembly, %edi contains a. %esi contains b, and %rcx contains result. All other similar terms are names referring to registers in the processor The table at the top of the next page describes the operation of the x86 instructions as well as the size of the encoding and the latency of the instruction execution Question 4. Comparing ISAs (20 points) In this question we will compare two different architectures The first is x86: an extended accumulator, CISC architecture with variable-length . The second is MIPS, a register-register RISC architecture with 32-bit fixed-length in- Consider the following C code which takes two integers (a and b) as inputs, computes the instructions and 32-bit data values structions and 32-bit data values Greatest Common Divisor (GCD) between them, and stores the result in memory 1 void gcd( int a, int b, int* result ) while ( b != 0 ) { int temp = b; b=a%b; a = temp ; 4 6 *result = a; If we were to take this code and compile it on an x86 machine (like your laptop), we would get the following assembly code. You can try this at home. I loop : test %esi, %esi 2 je End mov %eax, mov %edi, div %esi mov %esi, jmp loop mov (%rcx), %edi %esi 4 %edx 6 7 8 End : %edi If you were to try compiling this yourself, you would get the above output. In this assembly, %edi contains a. %esi contains b, and %rcx contains result. All other similar terms are names referring to registers in the processor The table at the top of the next page describes the operation of the x86 instructions as well as the size of the encoding and the latency of the instruction execution
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started