Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following C program and its corresponding Assembly code, match the corresponding C statements with the appropriate Assembly instructions. Hint: You can try to

Given the following C program and its corresponding Assembly code, match the corresponding C statements with the appropriate Assembly instructions.
Hint: You can try to get on taz, make a copy of the C code, run "gcc -c filename.c" to generate the Assembly code, and then setup two vertical tmux windows to compare ...
=== C Code ===
#include
void arith (){
int x =5;
int y =124;
int *t = malloc(sizeof(int)*10);
*(t +2)=2;
*(t +4)=*(t +2)+ x;
*(t +5)= y;
}
=== End C Code ===
=== Assembly Code ===
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
movl $0x5,-0x10(%rbp)
movl $0x7c,-0xc(%rbp)
mov $0x28,%edi
callq 20
mov %rax,-0x8(%rbp)
mov -0x8(%rbp),%rax
add $0x8,%rax
movl $0x2,(%rax)
mov -0x8(%rbp),%rax
add $0x8,%rax
mov (%rax),%ecx
mov -0x8(%rbp),%rax
add $0x10,%rax
mov -0x10(%rbp),%edx
add %ecx,%edx
mov %edx,(%rax)
mov -0x8(%rbp),%rax
lea 0x14(%rax),%rdx
mov -0xc(%rbp),%eax
mov %eax,(%rdx)
nop
leaveq
retq
=== End Assembly Code ===
Question 21 options:
mov -0x8(%rbp),%rax
add $0x8,%rax
mov (%rax),%ecx
mov -0x8(%rbp),%rax
add $0x10,%rax
mov -0x10(%rbp),%edx
add %ecx,%edx
mov %edx,(%rax)
movl $0x5,-0x10(%rbp)
mov $0x28,%edi
callq 20
mov %rax,-0x8(%rbp)
movl $0x7c,-0xc(%rbp)
mov -0x8(%rbp),%rax
add $0x8,%rax
movl $0x2,(%rax)
mov -0x8(%rbp),%rax
lea 0x14(%rax),%rdx
mov -0xc(%rbp),%eax
mov %eax,(%rdx)
1.
int *t = malloc(sizeof(int)*10);
2.
int x =5;
3.
int y =124;
4.
*(t +2)=2;
5.
*(t +4)=*(t +2)+ x;
6.
*(t +5)= y;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions