Machine-Level Representation of Programs I
1 Machine-Level Representation of Programs I
Outline Compiler drivers History of the intel IA-32 architecture Assembly code and object code Memory and Registers Addressing Mode Data Formats Suggested reading -chap1.2,1.4.1.1.7.3.3.1,3.2,3.3,3.4.1
2 Outline • Compiler drivers • History of the Intel IA-32 architecture • Assembly code and object code • Memory and Registers • Addressing Mode • Data Formats • Suggested reading – Chap 1.2, 1.4.1, 1.7.3, 3.1, 3.2, 3.3, 3.4.1
The hello program It begins life as a high-level C program Can be read and understand by human beings The individual c statements must be translated by compiler drivers So that the hello program can run on a computer system Compiler:编译器
3 The Hello Program • It begins life as a high-level C program – Can be read and understand by human beings • The individual C statements must be translated by compiler drivers – So that the hello program can run on a computer system – Compiler:编译器
The hello program The C programs are translated into A sequence of low-level machine-language instructions These instructions are then packaged in a form called an object program Object program are stored as a binary disk file Also referred to as executable object files
4 The Hello Program • The C programs are translated into – A sequence of low-level machine-language instructions • These instructions are then packaged in a form – called an object program • Object program are stored as a binary disk file – Also referred to as executable object files
The Context of a Compiler (gcc)Figure 1.3P5 hello.c Source program(text) Preprocessor(cpp hello. i Modified source program(text) Compiler(cc1) hello.s Assembly program(text) Assembler(as) hello. o Relocatable object program(binary Linker(Id) Compiler:编译器 hello Executable object program(binary) Assembler:汇编器 Linker:连接器
5 The Context of a Compiler (gcc) hello.c Source program (text) Preprocessor (cpp) hello.i Modified source program (text) Assembly program (text) Compiler (cc1) hello.s Assembler (as) hello.o Relocatable object program (binary) Linker (ld) hello Executable object program (binary) Figure 1.3 P5 Compiler:编译器 Assembler:汇编器 Linker:连接器
Characteristics of the high level programming languages Abstraction Productive reliable Type checking As efficient as hand written code Can be compiled and executed on a number of different machines, whereas assembly code is highly machine specific Productive:多产的 Reliab|e:可靠的
6 Characteristics of the high level programming languages • Abstraction – Productive – reliable • Type checking • As efficient as hand written code • Can be compiled and executed on a number of different machines, whereas assembly code is highly machine specific Productive:多产的 Reliable: 可靠的
Characteristics of the assembly programming languages Managing memory Low level instructions to carry out the computation Highly machine specif ic
7 Characteristics of the assembly programming languages • Managing memory • Low level instructions to carry out the computation • Highly machine specific
Why should we understand the assembly code Understand the optimization capabilities of the compiler Analyze the underlying inefficiencies in the code Sometimes the run-time behavior of a program is needed
8 Why should we understand the assembly code • Understand the optimization capabilities of the compiler • Analyze the underlying inefficiencies in the code • Sometimes the run-time behavior of a program is needed
From writing assembly code to understand assembly code Different set of skills Transformations Relation between source code and assembly code Reverse engineering Trying to understand the process by which a system was created By studying the system and By working backward Backward:回溯
9 From writing assembly code to understand assembly code • Different set of skills – Transformations – Relation between source code and assembly code • Reverse engineering – Trying to understand the process by which a system was created • By studying the system and • By working backward Backward:回溯
A Historical Perspective Long evolutionary development Started from rather primitive 16-bit processors Added more features Take the advantage of the technology improvements Satisfy the demands for higher performance and for supporting more advanced operating systems Laden with features providing backward compatibility that are obsolete | aden with:承载 compatibility;:兼容性 大 obsolete:陈旧的
10 A Historical Perspective • Long evolutionary development – Started from rather primitive 16-bit processors – Added more features • Take the advantage of the technology improvements • Satisfy the demands for higher performance and for supporting more advanced operating systems – Laden with features providing backward compatibility that are obsolete * laden with:承载 * compatibility: 兼容性 * obsolete:陈旧的