Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. You are given the following information. A function with prototype void decod

ID: 3589624 • Letter: 2

Question

2. You are given the following information. A function with prototype void decodel (int *xp, int *yp, int *zp) is compiled into assembly code shown below (Note that function setup and finish codes are not shown). Write C code for decode1 that will have an effect equivalent to the assembly code below Note that parameters xp, yp, and zp are stored at memory locations with offset 8, 12, and 16, respectively, relative to the address in register ebp ebp+8, yp at ebp+ 12, %ebp+16 // assume that xp at movl 8(%ebp), %edi movl 12(%ebp), %edx movl 16(%ebp ) , %ecx movl (%edx), %ebx movl (%ecx), %esi movl (%edi), %eax movl %eax , (%edx ) movi %ebx, (%ecx ) movl %esi, (%edi ) zp at

Explanation / Answer

#include<stdio.h>
int main() {
void decode(int *xp, int *yp, int *zp)
{
int tx = *xp;
int ty = *yp;
int tz = *zp;
*yp = tx;
*zp = ty;
*xp = tz;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote