Embedded C Exam
Embedded C Exam
The following affect the stack consumption of a function (you can choose more than one)
a.The number of function arguments..
b.The number of times the function called in the program.
c. The number of static local variables defined in the function.
d.The number of local variables defined in the code. e. The size of
b.it is target dependent, but if it is possible, this segment of code should be copied to RAM after
each reset
c. it is target dependent, but if it is possible, this segment should be un- erasable in RAM.
c. Increase Portability.
6. Which of the following is the best way to declare a C preprocessor Macro that takes two
arguments and return the smaller of their two values?
a. #define MIN(A,B) ((A) < (B) ? (A): (B))
b. #define MIN(A,B) { if (A<B) A; else B; } x
c. #define MIN(A,B) ((A <B) ? A: B)
d. #define MIN(A,B) A<B? A: B;
7. Which of the following will define a function that can not be called from
another source file.
a. void function(){ ... } c. const void function (){ ... }
b. extern void function (){ ... } d.static void function (){ ... }
8. Which of the following items should be generally be declared using C volatile keyword (you
can choose more than one)
a.A memory mapped peripheral status register.
b. A global variable used within an interrupt service routine.
c. A global variable used by multiple tasks in a multi-thread application.
9. The static keyword can be used for
a. scope limitation. c. both answers.
b.persistent storage.
10.Static variables are:
a.Initialized once and retains its value through the program execution.
b. Can be accessed outside the scope of the function.
c. Disappear from the memory at end of the function.
11.A static variable is allocated in the ...
a.Data Segment. b. Stack. c. Heap.
12.Making the variable static affects:
a. its scope. b. its life-time.
c. Its scope and lifetime d. it depends.
18.To ensure the compiler will not perform any optimizations concerning the access of a
variable use the .... Keyword
a.extern b. register
c.volatile d. static
19. Using the... keyword informs the compiler of the variable type but does not allocate memory
for it.
a.extern b.register.
c. volatile d. static
{printf("%d",y);}
22.Inline function result in faster code execution and less code size:
a.TRUE. b. FALSE.
void main(){
28. The tool that combines object files or libraries and produces a single
a. Compiler. b. Assembler.
c. Pre-Processor. d. Linker.
a. A function that is called, performs the requests functionality and returns the result of the
request.
c. A function that is called, performs the requests functionality and returns without the result of
the request.
a. Calls itself.
b. Can be interrupted during its processing and then called again with another task.
34.The difference between little- and big-endian bit orders is that ...
a. Little endian designates the MSB of a byte by bit7 while big endian designates it by bit 0
b. Little endian designates the MSB of a byte by bito while big endian designates it by bit 7
c. Little endian arranges the MSB of a byte on the right while big endian sets it on the left.
a. The macro will not calculate the number of elements in the array.
b.The macro will work only with arrays statically defined in the code.
c. The macro will work only with arrays dynamically defined in the code.
a. OxFF000000 12 34 65 78
b. 0xFF000000 00 00 00 00
c. OXFF000000 78 56 34 12
38.All is true about the keyword register except
a.it minimizes the load/store overhead. b.the compiler will never ignore it.
and the input to the macro are of integral values only. This macro may
40. To protect the global u8Data variable in the following code, the code
should...
u8 u8Data;
interrupt void vid FctInterrupt(void){
u8Data++;
u8 u8Function(void){
u8 u8FinalValue;
u8Data = 0;
while(u8Data == 0);
u8Data <<=4;
u8Data++;
u8FinalValue=u8Data;
return u8FinalValue;
a.TRUE. b. False.
42.If x is an integer its size is not known at the moment, then the best way to initialize it to all 1's
is x = ...
a.~0 b. !0 c.0xFFFF
43. "Initialized variables" values are copied from ROM to RAM during:
a. Compilation. b. Linking.
sum += i;
return sum;}
c. static function.
int main(){
int a,b=3;
a = SQR(b+2); .
printf("%d\n",a);
return 0;
a. 25 b.11
53.If we want to define a variable within the body of a function such that it maintains its value
defined as:
a. auto. b. register.
c. volatile. d. static.
struct x{
char y;
int z; }
a.interrupts. b. tight.
c. occasional. d. periodic.
Linker Script:
MEMORY{
In C File: App.c
a. 0.40000000 b.0x40000200
c. 0x40000004 d. 0x40000204
1 A,b 21 B 41 A
2 B 22 A 42 A
3 C 23 C 43 C
4 D 24 G 44 D
5 B 25 A 45 A
6 A 26 C 46 D
7 D 27 A 47 A
8 A,b,c 28 D 48 B
9 C 29 A 49 C
10 A 30 A 50 D
11 A 31 B 51 D
12 D 32 C 52 C
13 D 33 B 53 D
14 D 34 A 54 C
15 A 35 B 55 A
16 D 36 B 56 A
17 A 37 C 57 B
18 C 38 B 58 C
19 A 39 C 59 A
20 A 40 C 60 B
61 c 62 c 63 b
64 c