0% found this document useful (0 votes)
8 views

FAQs

The document outlines key differences between ARM7 and ARM9 architectures, highlighting improvements in pipeline stages and performance. It also covers various programming concepts in C, including storage classes, structures, unions, and the volatile keyword. Additionally, it discusses embedded systems code execution, including reset vectors, startup code, application code, and libraries.

Uploaded by

Vodela Kavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

FAQs

The document outlines key differences between ARM7 and ARM9 architectures, highlighting improvements in pipeline stages and performance. It also covers various programming concepts in C, including storage classes, structures, unions, and the volatile keyword. Additionally, it discusses embedded systems code execution, including reset vectors, startup code, application code, and libraries.

Uploaded by

Vodela Kavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

1) Difference between ARM7 and ARM9

2) ARM means???

ARM9 is an ARM architecture 32-bit RISC CPU family. With this design generation, ARM moved
from a von Neumann architecture (Princeton architecture) to a Harvard architecture with
separate instruction and data buses (and caches), significantly increasing its potential speed.

while ARM9 is 5-stage pipeline IF-ID-RF-EX-WB.

ARM7 is 3-stage pipeline: IF-ID-EX

RF: register fetch, WB: write-back, EX: execute, IF: instruction fetch,
ID: instruction decode.

Key improvements over ARM7 cores, enabled by spending more transistors, include

 Decreased heat production and lower overheating risk.


 Clock frequency improvements. Shifting from a three stage pipeline to a five stage one lets the
clock speed be approximately doubled, on the same silicon fabrication process.
 Cycle count improvements. Many unmodified ARM7 binaries were measured as taking about
30% fewer cycles to execute on ARM9 cores. Key improvements include
o Faster loads and stores; many instructions now cost just one cycle. This is helped by
both the modified Harvard architecture (reducing bus and cache contention) and the
new pipeline stages.
o Exposing pipeline interlocks, enabling compiler optimizations to reduce blockage
between stages.

3) JTAG

Joint Test Action Group (JTAG) is widely used for IC debug ports. In the embedded processor
market, essentially all modern processors support JTAG when they have enough pins. Embedded
systems development relies on debuggers talking to chips with JTAG to perform operations like
single stepping and breakpointing. Digital electronics products such as cell phones or a wireless
access point generally have no other debug or test interfaces

A JTAG interface is a special four/five-pin interface added to a chip

1. TDI (Test Data In)


2. TDO (Test Data Out)
3. TCK (Test Clock)
4. TMS (Test Mode Select)
5. TRST (Test Reset) optional.
4) Volatile keyword

A variable is declared as a Volatile variable when the Programmer knows that the value is
supposed to be changed by hardware. So that Compiler will not optimize the code by assuming
that the variable is constant and is not being modified in the program. To avoid this kind of
optimization Programmer uses the keyword/modifier “Volatile”.

5) Can we declare a variable as constant volatile?

Yes. Usually this is done to make sure that the variable is not getting modified in the program by
mistake. Hence this variable can only be changed by hardware not through the program.

6) Storage Classes

In C, storage class provides information about their location and visibility.


C provides four storage classes as:

1. auto storage class


2. register storage
3. extern storage class
4. static storage class

Storage class determines its storage duration, scope and linkage.


 Storage duration is the period during which that identifier exists in the memory.
 Scope is where the identifier can be referenced in a program.
 Linkage determines for a multiple-source file.

Let's summarize all storage classes in C as following as:


Automatic Storage Register Storage External Storage
Features Static Storage Class
Class Class Class
Keyword auto register static extern
Initial
Garbage Garbage Zero Zero
Value
Storage Memory CPU register Memory Memory
scope limited,local scope limited,local
Scope scope limited,local to block Global
to block to block
limited life of value of variable persist
limited life of Global,till the
Life block,where between different function
block,where defined program execution
defined calls
Memory
Stack Register memory Segment Segment
location

void main() void add(); void main()


{ void main() {
auto int i; { extern int i;
printf("%d",i); void main() add(); printf("%d",i);
} { add(); int i=5
OUTPUT register int i; } }
Example 124 for(i=1; i<=5 ; i+ void add() OUTPUT
+); { 5
printf("%d ",i); static int i=1;
} printf("\n%d",i);
OUTPUT i=i+1;
12345 }
OUTPUT
1
2

FIGURE: Table of Storage classes in C

7) Structures and Union

Structures in C are used to encapsulate, or group together different data into one object. You can define
a Structure as shown below:

Sample Code

1. struct object {
2. char id[20];
3. int xpos;
4. int ypos;
5. };

Structures can group data of different types as you can see in the example of a game object for a video
game. The variables you declare inside the structure are called data members.

Unions and Structures are identical in all ways, except for one very important aspect. Only one element
in the union may have a value set at any given time. Everything we have shown you for structures will
work for unions, except for setting more than one of its members at a time. Unions are mainly used to
conserve memory. While each member within a structure is assigned its own unique storage area, the
members that compose a union share the common storage area within the memory. Unions are useful
for application involving multiple members where values are not assigned to all the members at any one
time.

Let us modify our structure object from above so that it has a union for indicating dead or alive in it:

Sample Code

1. struct object {
2. char id[20];
3. struct coordinates loc;
4. union deadoralive {
5. int alive;
6. int dead;
7. }
8. };

Only dead or alive can be set to anything at any one time. You can get to it the same as with a structure
inside a structure as we learned in the last section.

8) Difference between Global and Static variable

a) Global variables can be used in multiple files whereas Static variable can be used in the
same file.
b) Global variables scope is throughout the program whereas Static variable scope is within
the block in which it is declared. But if the variable is declared Static globally then the
scope of that variable can be throughout the program but within the same file. i.e.

 Static global variables: variables declared as static at the top level of a source file
(outside any function definitions) are only visible throughout that file ("file scope",
also known as "internal linkage").
 Static local variables: variables declared as static inside a function are statically
allocated while having the same scope as automatic local variables. Hence
whatever values the function puts into its static local variables during one call will
still be present when the function is called again.
9) Write a program to find factorial of the given number
Recursion: A function is called 'recursive' if a statement within the body of a function calls the
same function. It
is also called 'circular definition'. Recursion is thus a process of defining something in terms of
itself.
Program: To calculate the factorial value using recursion.

Code:
#include <stdio.h>
int fact(int n);
int main()
{
int x, i;
printf("Enter a value for x: \n");
scanf("%d", &x);
i = fact(x);
printf("\nFactorial of %d is %d", x, i);
return 0;
}

int fact(int n)
{
/* n=0 indicates a terminating condition */
if (n <= 0)
{
return (1);
}

else
{
/* function calling itself */
return (n * fact(n - 1));
/*n*fact(n-1) is a recursive expression */
}
}

Output:
Enter a value for x:
4
Factorial of 4 is 24

10) Write a program to swap two numbers using bitwise operators.

Code:
#include <stdio.h>
int main()
{
int i = 65;
int k = 120;
printf("\n value of i=%d k=%d before swapping", i, k);
i = i ^ k;
k = i ^ k;
i = i ^ k;
printf("\n value of i=%d k=%d after swapping", i, k);
return 0;
}

Explanation:
i = 65; binary equivalent of 65 is 0100 0001
k = 120; binary equivalent of 120 is 0111 1000
i = i^k;
i...0100 0001
k...0111 1000
---------
val of i = 0011 1001
---------
k = i^k
i...0011 1001
k...0111 1000
---------
val of k = 0100 0001 binary equivalent of this is 65
---------(that is the initial value of i)
i = i^k
i...0011 1001
k...0100 0001
---------
val of i = 0111 1000 binary equivalent of this is 120
--------- (that is the initial value of k)

Similar examples of programs:


http://techforum4u.com/entry.php/1321-Important-C-Programs-Asked-in-Interviews

10) Pointers:

a) char *p → pointer pointing to a char variable


Both pointer and value of the variable can be changed.

b) const char *p; → constant pointer pointing to a char variable


Pointer cannot be changed but the value of the variable can be changed.

c) const *char p; → pointer pointing to a constant char variable


Pointer can be changed but the value of the variable cannot be changed.

d) const char const *p; → constant pointer pointing to a constant char variable
Here both are constant
11) Function Pointers
The pointer pointing to the address of the function.
Example:
int sum(int a, int b);
int (*p) (int , int);

void main(void)
{
p = &sum;
…..
…..
printf(“sum of the variables = %d“, p(10,20));
}

int sum(int a , int b)


{
return (a+b);
}

Code execution in embedded systems:


Low-level embedded software can be broken down into the following:

1. Reset vector - this is usually written in assembly. It is the very first thing that runs at start-up and
can be considered hardware-specific code. It will usually perform simple functions like setting up
the processor into a pre-defined steady state by configuring registers and such. Then it will jump
to the startup code. The most basic reset vector merely jumps directly to the start-up code.
2. Startup code - this is the first software-specific code that runs. Its job is basically to set up the
software environment so that C code can run on top. For example, C code assumes that there is
a region of memory defined as stack and heap. These are usually software constructs instead of
hardware. Therefore, this piece of start-up code will define the stack pointers and heap pointers
and such. This is usually grouped under the 'c-runtime'. For C++ code, constructors are also
called. At the end of the routine, it will execute main(). edit: Variables that need to be ini-
tialised and also certain parts of memory that need clearing are done here. Basically, everything
that is needed to move things into a 'known state'.
3. Application code - this is your actual C application starting from the main() function. As you
can see, a lot of things are actually under the hood and happen even before your first main func-
tion is called. This code can usually be written as hardware-agnostic if there is a good hardware
abstraction layer available. The application code will definitely make use of a lot of library func-
tions. These libraries are usually statically linked in embedded systems.
4. Libraries - these are your standard C libraries that provide primitive C functions. There are also
processor specific libraries that implement things like software floating-point support. There can
also be hardware-specific libraries to access the I/O devices and such for stdin/stdout. A couple
of common C libraries are Newlib and uClibc.
5. Interrupt/Exception handler - these are routines that run at random times during normal code
execution as a result of changes in hardware or processor states. These routines are also typi-
cally written in assembly as they should run with minimal software overhead in order to service
the actual hardware called.

You might also like