Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include int dummy_function(int i, long j){ return i&(~j); } int main(){ char* str = Failure is simply the opportunity to begin again,

#include  #include  #include  #include  int dummy_function(int i, long j){ return i&(~j); } int main(){ char* str = "Failure is simply the opportunity to begin again, this time more intelligently."; int myint = INT_MAX - 26; long mylong = LONG_MIN + 2570; struct S7 { int i; int j; char c; }; struct S7 s; struct S7 r[12]; int *ptr_int = (int *)str+9; long *ptr_long = (long *)str+3; printf("%d", dummy_function(*ptr_int,*ptr_long)); return 0; }

1. What is the address of the character string pointed to by str?

2. What is the word that starts at address str+0x24 ?

3. What is the address where variable myint is stored?

4. What is the address of the leftmost (or highest order) byte of myint? (Hint: the leftmost byte is 0x7f)

5. What is the address of the leftmost (or highest order) byte of mylong?

6.

The source code declares the following struct:

struct S7 { int i; int j; char c; };

We also have an array of structures, declared as struct S7 r[12].

What is the size of the array r in bytes?

How many bytes is one instance of the struct S7?

Given the declaration of the struct above, we might expect the size of each element of the array (which is a struct with 2 int and 1 char) to be 4bytes * 2 + 1byte = 9 bytes. Is the size reported in Q6.2 different? If yes, what causes this difference in size?

What is the address where r[4].j is located?

what is the address where r[7].c is located?

The code also contains a function with signature dummy_function(int i, long j). Line 21 of the source code contains a call to this function. Identify the parameters and the registers used as arguments for this call by looking at the assembly code

Which register contains the first argument?

What is the value passed in this register (as hex) for the first argument?

Which register contains the second argument?

What is the value passed in this register (as hex) for the second argument?

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

=+j Describe how EU directives impact IHRM.

Answered: 1 week ago

Question

=+and reduction in force, and intellectual property.

Answered: 1 week ago