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

Problem 4) Suppose that the following bytes were in RAM at the addresses shown a

ID: 3586531 • Letter: P

Question

Problem 4)

Suppose that the following bytes were in RAM at the addresses shown and that the integers in “array” start at 0x00001800.

Recall that Microblaze is a “little-endian” device.

0x00001800

0x12

0x00001801

0x4F

0x00001802

0xEF

0x00001803

0xC6

0x00001804

0xA4

0x00001805

0xFE

0x00001806

0x03

0x00001807

0x9D

0x00001808

0x99

0x00001809

0x08

0x0000180a

0x1E

0x0000180b

0x23

0x0000180c

0xF2

0x0000180d

0xAC

0x0000180e

0x7F

0x0000180f

0x57

array[0]                        unsigned int array[4];

     .                                           int *intptr;

    .                       

    .                                                   

                                    

If intptr = &array[0x01], what is the value of *intptr?   

If intptr = &array[0x02], what is the value of *intptr?

If intptr = &array[0x01], what is the value of intptr++?

If intptr = &array[0x02], what is the value of intptr++?        

0x00001800

0x12

0x00001801

0x4F

0x00001802

0xEF

0x00001803

0xC6

0x00001804

0xA4

0x00001805

0xFE

0x00001806

0x03

0x00001807

0x9D

0x00001808

0x99

0x00001809

0x08

0x0000180a

0x1E

0x0000180b

0x23

0x0000180c

0xF2

0x0000180d

0xAC

0x0000180e

0x7F

0x0000180f

0x57

Explanation / Answer

Size of integer is 4 bytes

First we have to know big/little endian systems

Big-endian is an order in which the most significant value in the sequence is stored first (at the lowest storage address). Little-endian is an order in which the least significant value in the sequence is stored first. For example, in a big-endian computer, the two bytes required for the hexadecimal number 4F42 would be stored as 4F42 in storage (if 4F is stored at storage address 1000, for example, 42 will be at address 1001). In a little-endian system, it would be stored as 424F (42 at address 1000, 4F at 1001)

1) intptr = &array[0x01]

intptr=&array[0x01]=&array[1] //address of second integer since array indexing starts at 0

= 0x00001804

Now the value at above address is an integer comprising 4 bytes.

Since it is little endian storage mechanism,

value will be 0x9D03FEA4

2) If intptr = &array[0x02], what is the value of *intptr?

Similar to Q1, but here the integer pointed is next address

intptr = &array[0x02]=&array[2]=0x00001808

value = 0x231E0899

3) If intptr = &array[0x01], what is the value of intptr++?

from Q1 we know, intptr = 0x00001804;

pointer increment operation is done on a pointer of type Integer, so it will increment the address by 4 bytes since size of integer is 4 bytes.

thus resulting address of intptr=0x00001808;

4) If intptr = &array[0x02], what is the value of intptr++?

Similar analogy as Q3, intptr = 0x00001808, after incrementing intptr = 0x0000180c

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