Question: Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed
Using Microsoft Visual Studio.
1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array.
2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table.
3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table.
C++ Program
#include
#include
int main()
{
unsigned char uc8_arr[3] = { 0x80, 0x40, 0xFF };
unsigned char uc0, uc1, uc2;
unsigned char *ucPtr0, *ucPtr1, *ucPtr2;
signed char sc8_arr[3];
signed char *scPtr0, *scPtr1, *scPtr2;
short sh16_arr[3];
short *svPtr0, *svPtr1, *svPtr2;
int i32_arr[3] = {0x80, -660, 6600000};
int *ivPtr0, *ivPtr1, *ivPtr2;
ucPtr0 = &uc8_arr[0];
ucPtr1 = &uc8_arr[1];
ucPtr2 = &uc8_arr[2];
_asm
{
mov EAX, ucPtr0;
mov BL, [EAX];
mov uc0, BL;
mov EAX, ucPtr1;
mov CL, [EAX];
mov uc1, CL;
mov EAX, ucPtr2;
mov CL, [EAX];
mov uc2, CL;
}
printf("------------------------8-bit unsigned array-------------------------- ");
printf("The first element in the array in hex is 0x%x, in decimal is %u, %u ", uc8_arr[0], uc8_arr[0], uc0);
printf("The address for memory at the first element in the array is %x H ", ucPtr0);
printf("--- ");
printf("The second element in the array in hex is 0x%x, in decimal is %u, %u ", uc8_arr[1], uc8_arr[1], uc1);
printf("The address for memory at the second element in the array is %x H ", ucPtr1);
printf("--- ");
printf("The third element in the array in hex is 0x%x, in decimal is %u, %u ", uc8_arr[2], uc8_arr[2], uc2);
printf("The address for memory at the third element in the array is %x H ", ucPtr2);
printf("---- ");
}
Table 1.
| DATA TYPE | VARIABLE NAME | HEX | DECIMAL | ADDRESS |
| signed char (array with 3 elements) | sc8_arr[0] | 0x80 |
|
|
| signed char (array with 3 elements) | sc8_arr[1] |
|
|
|
| signed char (array with 3 elements) | sc8_arr[2] | 0xFF | -1 |
|
| unsigned char (array with 3 elements) | uc8_arr[0] | 0x80 |
|
|
| unsigned char (array with 3 elements) | uc8_arr[1] | 0x40 |
|
|
| unsigned char (array with 3 elements) | uc8_arr[2] | 0xFF | 255 |
|
| short (signed array with 3 elements) | sh16_arr[0] | 0x8000 |
|
|
| short (signed array with 3 elements) | sh16_arr[1] |
| 400 |
|
| short (signed array with 3 elements) | sh16_arr[2] |
| -400 |
|
| short (unsigned array with 3 elements) |
|
|
|
|
| short (unsigned array with 3 elements) |
|
|
|
|
| short (unsigned array with 3 elements) |
|
|
|
|
| int (signed array with 3 elements) | i32_arr[0] | 0x80000000 |
|
|
| int (signed array with 3 elements) | i32_arr[1] |
| -330 |
|
| int (signed array with 3 elements) | i32_arr[2] |
| 3300000 |
|
| int (unsigned array with 3 elements) |
|
|
|
|
| int (unsigned array with 3 elements) |
|
|
|
|
| int (unsigned array with 3 elements) |
|
|
|
|
TABLE 2
| Content in memory (the number of bits, the value in hex, the value in decimal | ADDRESS FOR MEMORY IN HEX | Identify the number of bytes used for each type of variable |
| (8 bits unsigned) (0x80) (128) | 18fc00 H |
|
| (8 bits unsigned) (0x80) (64) | 18fc01 H |
|
| (8 bits unsigned) (0x80) (256) | 18fc02 H |
|
|
|
|
|
|
|
|
|
|
|
|
|
| (32 bits signed) (0x8000 0000) (? decimal) | 18fbdc (real address) | 4 bytes, need 4 addresses |
|
| (18fbdd H) | |
|
| (18fbde H) | |
|
| (18fbdf H) | |
| (32 bits signed) (? hexadecimal) (-6600000) | (18fbe0 H) |
|
|
|
|
|
|
|
|
|
|
|
|
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
