Download Slide 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Survey of Program
Compilation and Execution
Bangor High School
Ali Shareef
2/28/06
Main Components of a
Computer
External Devices
Processor
Memory
Memory



Temporary holding area where instructions
are stored while they are waiting to be
executed.
Data and intermediate values are also
stored in memory.
Memory is Volatile

When the power is shut off, everything in
memory is lost
Processor


Executes Instruction
Pentium 4 is a 32 bit processor



Processors can process a 32 digit “bit”
number at a time.
Processor executes instructions one at a
time, (technically).
Instructions are represented as binary
numbers.
Processor

Registers

Fast memory within the processor where
data is stored while an instruction is being
executed.
Processor

Pentium 4 processor uses a 2.3 MHz
clock.




Clock oscillates at 2,300,000 cycles/sec
Most instructions take about 5 cycles
2,300,000/5 ~ 460,000 instructions are
executed per second
Even though a processor is executing one
instruction at a time, user interaction is
very smooth.
Execution Process
1)
2)
Program is loaded into memory from
external storage (hard drive, floppy
disk.)
Processor executes instructions from
memory
Execution


Can the processor understand C code?
Can it execute C code?
Compilation




The processor cannot understand most high
level languages such as C.
Need to translate C code to assembly code.
Assembly code corresponds to actual numeric
values for the instructions that the processor
can understand.
A compiler is used to translate code written in
C to assembly code, so that the processor
can understand it.
Demo

Compile program in Visual Studio and
see the assembly code.
Comparison


Is it better to program in a high level
language like C?
Or assembly code?
Comparison

Pros : High Level language




Easy to use,
Easy to debug,
Quickly develop programs
Cons :


Depend on compiler to produce code
May not be efficient
Comparison

Pros : Assembly Code



Can write very efficient, optimal code
Can utilize the full functionalities of the
processor
Cons :


Hard to write code, hard to debug
Requires knowledge of the architecture of
the processor that you are using
Conclusion

Main Components of a Computer


Memory


Processor, Memory, External devices
Temporary holding area for instructions
Processor

Executes instructions
Conclusion

Program Execution



Load instructions to memory
Processor executes instructions
Compilation

Compiler translates high level language to
assembly
Conclusion

High level language or Assembly use
depends upon application