Question
Question 1 Consider the following C code fragments and answer the associated questions. Assume that the code is running on a STM32F407 processor which is
Question 1 Consider the following C code fragments and answer the associated questions. Assume that the code is running on a STM32F407 processor which is little endian. The stdint.h data types have been used which indicate data size explicitly. Note that some code fragments may not give useful results.
a) Describe the result of the printf() statement in the following code fragment.
int32_t test(int32_t a, int8_t b)
{
return b >> 1 * a;
}
main()
{
printf("%x ", test);
}
b) What is the result of the printf() statement in the following code fragment?
int8_t a[] = {0x12, 0xb2, 0x37, 0xc8};
printf("%x ", a[2] | (0x08) & a[3]);
c) What is the result of the printf() statement in the following code fragment?
int8_t a[] = {0x11, 0xa2, 0x36, 0x55, 0x44, 0x33};
printf("%x ", *((alt_16 *) a + 2));
d) What is the result of the printf() statement in the following code fragment?
int8_t a[] = "ELEC3730 Is Fun!";
a[5] = a[10] = a[15] = 0;
printf("%s\t%s\t%s ", a+2, a+7, a+12);
e) What is the result of the printf() statements in the following code fragment?
int32_t process()
{
static int32_t t = 10;
t = 2*t;
return t;
}
main()
{
printf("%d, %d, %d ", process(), process(), process());
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started