Tag archive for "code"
This procedure calculates offset of each program code block and total code size.
Once the offsets of code blocks, variables and typed constants are known, the compiler can resolve references. This procedure calculates all references (displacements, offsets, near and far pointers) to code or data.
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.
Before the target code is generated Turbo Pascal needs to know code size and offsets of instructions. This procedure processes intermediate code instructions and calculates the size of generated code, offsets of near jump instructions, offsets of labels and size of reference records.
This procedure generates target (x86) code from intermediate code instructions. This is the last phase in program block compilation. If debug info is enabled, source line code offsets will be saved into dedicated table, redundant loadings of addresses to ES:DI register pair will be removed and near jumps will be converted to short jumps where …