16
Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Embed Size (px)

Citation preview

Page 1: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Survey of Program Compilation and

Execution

Bangor High School

Ali Shareef2/28/06

Page 2: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Main Components of a Computer

External Devices Processor Memory

Page 3: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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

Page 4: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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.

Page 5: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Processor

Registers Fast memory within the processor

where data is stored while an instruction is being executed.

Page 6: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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.

Page 7: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Execution Process

1) Program is loaded into memory from external storage (hard drive, floppy disk.)

2) Processor executes instructions from memory

Page 8: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Execution

Can the processor understand C code?

Can it execute C code?

Page 9: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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.

Page 10: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Demo

Compile program in Visual Studio and see the assembly code.

Page 11: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Comparison

Is it better to program in a high level language like C?

Or assembly code?

Page 12: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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

Page 13: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

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

Page 14: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Conclusion

Main Components of a Computer Processor, Memory, External devices

Memory Temporary holding area for

instructions Processor

Executes instructions

Page 15: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Conclusion

Program Execution Load instructions to memory Processor executes instructions

Compilation Compiler translates high level

language to assembly

Page 16: Survey of Program Compilation and Execution Bangor High School Ali Shareef 2/28/06

Conclusion

High level language or Assembly use depends upon application