P. 1
First Steps with Embedded Systems

First Steps with Embedded Systems

|Views: 739|Likes:
Published by api-3783901

More info:

Published by: api-3783901 on Nov 21, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/15/2014

pdf

text

original

When the compiler comes across a variable declaration it checks that the
variable has not previously been declared and then allocates an appropriately

Basic Data Types

73

sized block of RAM. For example, an int variable will require a single word (8
bits) of RAM or data memory7.
When the compiler allocates memory for a variable it decides where to place the
variable value based on the existing entries in its symbol table. Since the
compiler cannot know what value lies at the address allocated for a particular
variable at compile-time, you can not depend upon a specific value for a
variable the first time it is used.
Compile-time is the point at which the compiler translates a program into
machine code. Run-time indicates the point at which the machine code is
executed on the host computer. It is useful to remember that compilers have
little or no knowledge about a machine’s internal state at run-time.
Declarations that initialise variables are very useful – they ensure that you can
predict what a variable memory location will contain at run-time. When the
compiler reads a declaration which also initializes a variable it first allocates an
appropriate block of memory, then immediately loads the appropriate value into
that location.
Please note that variable declarations which contain an initialization will
automatically generate machine code to place a value at the address allocated for
the variable. Normal variable declarations do not generate any code because the
machine code contains the address allocated for such a variable. This is not the
case for either global variables or static local variables – if they are not initialized
in their declaration the compiler will initialize them by setting their initial values
to 0. The compiler will produce machine instructions to load the 0 value into
the appropriate addresses.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->