Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help c# 2. Given the following code: struct { int a; int b; char *cp; foo [10];; Assume that the starting address of array

please help c#
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
2. Given the following code: struct \{ int a; int b; char *cp; foo [10];; Assume that the starting address of array foo is in register %rdx. For each of the following, either write x86-64 assembly code that will load the value of that expression into register \%rax (or \%eax, as appropriate), or write a C assignment statement that would generate the given assembly (referencing array foo and assign it to a variable t ). The first one is done as an example. a. fo0[0],bmov14(%rdx), \%eax b. foo[1] ,a c. foo [i] .b, assuming 1 is in \%rex. d. A sume % rdi contains the value of j. salq4,%rdimovb8(%rdx,%rdi),%rax Problem 3. A certain function is declared: unsigned foo (unsigned x, unsigned y ): It compiles to the following assembly code: Problem 3. A certain function is declared: unsigned foo(unsigned x, unsigned y ); It compiles to the following assembly code: movl $0,% eax .L2: testl \%esi, \%esi je .L4 addl \%edi, \%eax subl $1, \%esi jmp .L2 .L4: movl $0,% eax . L2: testl \%esi, \%esi je . L4 addl \%edi, \%eax subl $1,% esi jmp. L2 . L4: ret Recall that the first argument is passed in \%rdi, the second in \%rsi, and the return value is passed in \%ray (or in this case, since it is a four-byte integer, \%eax). The C code has the following general structure: unsigned foo(unsigned x, unsigned y ) f unsigned result = while (_... \}. return result; a. Fill in the blanks with code that will result in the given assembly code (when compiled with 0g and ignoring endbr 64 . A. Fill in the blanks with code that will result in the given assembly code (when compiled with 0g and ignoring endbr64. b. What does the function compute

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

Students also viewed these Databases questions