Lec7_RunAProgram
Lec7_RunAProgram
Running a Program
CSE 3105 (Computer Interfacing & Embedded Systems)
Assembly Language
Machine Instruction
Translate a C Program into a Machine Program
❏ Executable files created by compilers are usually platform dependent.
❏ An executable file compiled for one type of microprocessors, such as ARM
Cortex-M3, cannot directly run on a platform with a different kind of
microprocessors that support a different set of machine instructions, such as
PIC or Atmel AVR microcontrollers.
❏ When we migrate a program written in a high-level language to a processor
of a different instruction set, we usually have to modify and recompile the
source programs for the new target platform.
Translate a C Program into a Machine Program
Extracting
symbols and Intermediate Optimization
checking Representation
syntax
Machine Program
Translate a C Program into a Machine Program
A processor of Harvard architecture loads a program into the instruction memory and the data memory.
Reusing Registers to Improve Performance
Question: Why some variable is not stored in memory rather stored in register?
Answer: Variables stored in registers rather than memory are typically those that are
heavily used and require fast access. Registers are much faster to access than memory
because they are part of the CPU itself, whereas accessing memory involves traversing
buses and interacting with potentially slower components. When a variable is stored in
a register, it means that the CPU can directly manipulate the variable's value without
having to fetch it from memory. This can significantly speed up the execution of code
that heavily uses these variables, particularly in tight loops or performance-critical
sections of code. In languages like C or C++, the register keyword can be used as a
hint to the compiler that a particular variable should be stored in a register if possible.
However, modern compilers are often able to make these decisions automatically
based on their optimization algorithms and the characteristics of the target hardware.
Reusing Registers to Improve Performance
Self Study: Temporal, Spatial Locality, Register Allocation, Processor Registers
(Article 1.3.1 & 1.3.2)