Question: Fill in the blanks 1. 2. /*function le2be converts a little endian int and return it as a big endian int. The code does this

Fill in the blanks

1.

Fill in the blanks 1. 2. /*function le2be converts a little endian

2.

/*function le2be converts a little endian int and return it as a big endian int. The code does this using shift and logical operations only. No built-in or library conversion functions are used.*/ int le2be(int x){

int d;

/* ((x >>24) & 0x000000FF) =0x ______________________

((x >> 8) & 0x0000FF00) = 0x_______________________

((x

((x

*/ d= ( ((x >>24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | \

((x

//d = 0x_____________________________________

return d;

}

3.

int and return it as a big endian int. The code does

/*function le2bep converts a little endian int and return it as a big endian int. The code does this using pointers. No built-in or library conversion functions are used. Assume that the address of int d is 0x10000, and the address of int bed is 0x11000 for the purpose of filling in the blanks*/ int le2bep(int x){

int d = x;

char *dptr = &d;

int bed;

char *bedptr = &bed;

*(bedptr + 3) = *dptr;

*(bedptr + 2) = *(dptr + 1);

*(bedptr + 1) = *(dptr + 2);

*bedptr = *(dptr + 3);

return bed;

}

PLEASE SHOW ALL STEPS AND WORK

The table, below, represents the binary contents of four consecutive locations in memory in a little-endian architecture. Memory Address Memory Data 0000 1100 0011 0001 1010 1100 0002 0101 1100 0003 0110 1011 Treat the data stored at these addresses as: (a) A single 32-bit (int) hexadecimal value: (b) Two unsigned 16-bit values. Express these values in hexadecimal. 0000,0001 0002,0003 (c) Four signed (two's complement) byte values. Express these values in decimal. 0000 0001 0002 0003 /*function le2bep converts a little endian int and return it as a big endian int. The code does this using pointers. No built-in or library conversion functions are used. Assume that the address of int d is 0x10000, and the address of int bed is 0x11000 for the purpose of filling in the blanks*/ int le bep(int x) int d = x; //d = Ox char *dptr=&d; //dptr = Ox int bed; char *bedptr = &bed; //bedptr = 0x *(bedptr + 3) = *dptr; 1/*(bedptr + 3) = 0x *(bedptr + 2) = *(dptr + 1); 1/*(bedptr + 2) = 0x *(bedptr + 1) = *(dptr + 2); //*(bedptr + 1) = 0x *bedptr = *(dptr + 3); // *bedptr = Ox_ return bed; 1/bed = 0x }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!