You are on page 1of 7

UNIT II PROGRAMMING FOR EMBEDDED SYSTEMS TWO MARK QUESTIONS AND ANSWERS 1.

What are integer data types available in the C programming Language? Data type Char Short int Unsigned Int Long int Char Short int Int Signed Long int Size 8bits 16bits 16or 32bits 32bits 8bits 16bits 16or 32bits 32bits Range 0to255 0to65,535 16bits:same unsigned short int; 32bits:same

as as

unsigned long int. 0to4,294,967,295 -128to+127 -32,768to+32,767 16bits:same as signed short int; 32bits:same as signed long int. -2,147,483, 648to+2,147,483,647

2. What are the useful typedefs for embedded software? typedef signed char typedef signed short int typedef signed long int typedef unsigned char typedef unsigned short int typedef unsigned long int typedef UNSIGNED8 typedef UNSIGNED16 typedef UNSIGNED32 #ifdef _ GNUC_ typedef signed long long int 1 SIGNED64; SIGNED8; SIGNED16; SIGNED32; UNSIGNED8; UNSIGNED16; UNSIGNED32; BYTE; WORD16; DWORD32;

typedef unsigned long long int typedef UNSIGNED64 #endif


3. Create a Boolean data type and constants.

UNSIGNED64; QWORD64;

Typedef char #define FALSE #define TRUE (0);

BOOL; (!FALSE).

4. What are the symbol for Boolean versus Bitwise Operators?

Operation AND OR XOR NOT

Boolean Operator && || Unsupported !

Bitwise Operator & | ^ ~

5. Calculate (5 || !3) && 6 using Boolean operator. (5 || !3) && 6 = (true OR (NOT true)) AND true = (true OR false) AND true = (true) AND true = true =1
6. Calculate (5 | ~3) & 6 using Bitwise operator.

(5 | ~3) & 6 = (00..0101 OR ~00..0011) AND 00..0110 =(00..0101 OR 11..1100) AND 00..0110 =(11..1101) AND 00..0110 = 00..0100 ; = 4. 7. How will you set, clear and invert bits? Set OR Operator Bits = bits | (1 << 7) 2

Clear AND Operator Bits & = ~ (1 << 7) Invert XOR Operator (Toggling) Bits ^= (1 <<6) 8. List the four fields of a line of code in assembly language. 10.

Label field Operation field Operand field Comment field Absolute speed is critical To access a particular feature of the hardware.

9. What are the situations in which programming are assembly language?

What are two situations exist to access data in memory? The address of the data is a constant that may be specified by using the identifier that appears in the label field where the data is defined in the program. IN C, such data is said to be statically allocated and is either declared globally, outside of all functions, or is declared inside a functions , using static keyword.

The address of the data is a variable that may only be determined at execution time and loaded into a register. In C, any data that is accessed through a pointer, all function parameters, and any non static variables declared inside a function must be accessed in this manner.

11.

What are the basic types of memory allocation in C? Static Dynamic Automatic

12.

What is meant by Automatic memory allocation? Automatic memory allocation is the default allocation method inside functions. The Key word auto may be added as a declaration prefix to make the allocation method explicit.

13.

What are the disadvantages of automatic memory allocation? The lack of persistence, 3

14.

An automatic object declared within the body of a function will not retain its value from one invocation of the function another.

What are the advantages of automatic memory allocation? Conservation of memory through reuse, The program manages the reuse of these memory resources automatically.

15.

What are the advantages of Static Allocation? Persistence values. The objects that are use automatic allocation, a value stored in a static object will remain from one execution of function another.

16.

What are the disadvantages of Static Allocation? The inability to reclaim the memory for other purposes once the object is no longer needed.

17.

What is meant by dynamic allocation? Dynamic objects are allocated from a region of memory known as the heap using the library function malloc. The size of operator is normally used to determine the amount of memory required to hold an object of the desired type.

18.

What is meant by shared function? A shared function is one that is called by more than one thread; any function called by a shared function is also a shared function. Any static object referenced within a shared function is thus a form of shared memory.

19.

What is meant by fragmentation? The scattering of parts of a computer file across different regions of a disk. Fragmentation occurs when the operating system breaks up the file and stores it in locations left vacant by previously deleted files. The more fragmented the file, the slower it is to retrieve, since each piece of the file must be identified and located on the disk.

20.

What are the advantages of Dynamic Allocation? The advantages of dynamic allocation are that it offers both the persistence of static allocation and memory conservation through reuse.

21.

What are the disadvantages of Dynamic Allocation?

The disadvantage is the burden it places on the programmer to balance each call to malloc with a corresponding call to free.
22.

Define reentrant function. A function is reentrant if, while it is being executed, it can be reinvoked by itself, or by any other routine, by interrupting the present execution for a while.

23.

What are the two locations of declarations are usually placed?

Outside of all functions to create global variables, Immediately following a function header to create temporary variable local to the function.

24.

What the three distinct phases that constitute the sequencing of an

instruction are determining? Register(s) EAX EDX and EAX EBP Usage in C functions Function return all pointer and integer values up to 32 bits in this register. Functions return 64-bit values (long long ints) in this register pair Used to access (i) The arguments that were passed to a function when it was called EBX,ESI,EDI<EBP,DS,ES, and SS (ii).Any automatic variables allocated by the function These registers must be preserved by functions written in assembly language any of these registers that the function modifies should be pushed on entry EAX,ECX,EDX,FS and GS to the function and popped on exit Scratch registers .These registers may be used without preserving their current content 25. What are C Register Usage Conventions for the DJGPP Complier? The memory address that contains the instruction, Fetching the instruction from memory, Executing the instruction.

26.

What are the different software coding styles available in the case Machine codes, Assembly language High level language 12 Marks Questions
1. Briefly explain the data types in C?

of embedded systems?

2. Discuss in detail about how to manipulate bits in memory and I/O ports. 3. Explain in detail about accessing memory mapped I/O devices. 4. Define structures? Explain about declaration of structures. 5. Write notes on
a. Variant access,

b. Mixing C to assembly, c. Register usage 6. Explain about use of addressing options in embedded programming. 7. Briefly discuss about instruction sequencing. 8. Write notes on a. Procedure call and return, b. Parameter passing, c. Retrieving parameters
9. Briefly explain about Memory management and types memory allocation

scheme. 10. Explain about


a. Shared memory b. Recognizing shared objects c. Shared memory device drivers

11.

What are the productivity tools available in embedded systems?

Explain any one tool. Assignment Questions 1. Write in detail about integer data types. 2. Explain briefly about variant access. 6

3. Why do we choose programming in assembly language?

You might also like