This unit processes intermediate code and generates executable code and reference records for Linker.
|
Most compilers use some kind of intermediate code which is a program representation somewhere betwen the high-level source code and executable code for target processor. This means that the compiler does not generate the target code directly but it generates some intermediate pseudo instructions which are converted into target code after the program is compiled.
|
Turbo Pascal uses few procedures to generate any x86 instruction needed. In general two intermediate code records are used: one for actual inctruction opcodes and imemdiate data and one for references.
|
Programs created with Turbo Pascal use stack frame. This is part of the processor's stack space which can be accessed using a dedicated base pointer (BP) register.
|
Each module (program or unit) needs some initialization and finalization: entry and exit code.
|
Interrupt procedures also need some initialization and finalization.
|
Procedures and functions (including methods) also need initialization and finalization code.
|
Turbo Pascal generates jumps in an interesting way. Since most jumps will jump to the same place, Turbo Pascal keeps them in a linked list.
|
Whenever Turbo Pascal needs to reference anything that doesn't have fixed location, i.e. its address is not known yet like variables, typed constants or procedures, the compiler generates intermediate code reference record which contains all information to later resolve the reference.
|
Turbo Pascal tries to optimize loading of addresses to ES:DI register pair. For this purpose it uses few intermediate code instructions that track addresses that need to be loaded.
|
Turbo Pascal tries to convert all near jumps to short. This is only possible if jump displacement can be stored in a byte.
|
|
|
<< Start < Prev 1 2 Next > End >>
|