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

For this problem, assume that an int is stored in 8 bits. What value would be di

ID: 3881369 • Letter: F

Question

For this problem, assume that an int is stored in 8 bits. What value would be displayed to the screen when the following code executes?

    int a = 36;
    int b = 8;
    int c = a * b;
    printf("%d ", c);

Question options:

An error message appears

288

32

-224

The figure above shows you the bytes stored in a small portion of memory and in some registers. The memory is simply a byte dump similar to what you would get in gdb if you asked for 64 bytes while the registers show you values as 64-bit words. Which memory location holds the long value -8? (Recall that a long is 8 bytes wide and that Intel is little endian.)

Question options:

0x1028

0x1020

0x1010

0x1018

The figure above shows you the bytes stored in a small portion of memory and in some registers. The memory is simply a byte dump similar to what you would get in gdb if you asked for 64 bytes while the registers show you values as 64-bit words.

What happens if we execute the assembly instruction

movl %edx, %ecx

Question options:

The value of the %rcx register becomes 0x CC CC CC CC FF FF FF F8.

The value of the %rcx register becomes 0x 00 00 00 00 FF FF FF F8.

The value of the %rdx register becomes 0x FF FF FF FF 00 00 00 08.

The value of the %rcx register becomes 0x FF FF FF FF FF FF FF F8.

The figure above shows you the bytes stored in a small portion of memory and in some registers. The memory is simply a byte dump similar to what you would get in gdb if you asked for 64 bytes while the registers show you values as 64-bit words.

movq (%rbx), %rax

Question options:

The %rax register gets the value 0x 18 10 00 00 00 00 00 00

The bytes in locations 0x1020 through 0x1027 get the values AA, AA, AA, AA, 00, 00, 00, and 01 respectively.

The %rax register gets the value 0x 20 10 00 00 00 00 00 00

The %rax register gets the value 0x 00 00 00 00 00 00 10 18

An error message appears

288

32

-224

Explanation / Answer

Solution:-

1. The value will display on the screen is 32.

Explanation:- For a 8 bits of an integer the range is from 0 to 255 (in case of unsigned). Hence when variable c store 8 * 36 i.e 288 then the corresponding value ie 288 - 256 = 32 will be stored by variable c. Because total number of integers for 8 bits = 256 and maximum value = 255. Hence after 255 i. e. from 256 onwards it will move in cycle.

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