7.1.2 Preparing program for Execution(5/9) The program loaded at location 4000 Relative Address Generated Code 0000 (other process's programs) 4000 (Other modules) 5008 entry proc a 5036 Space for gvar variable 5220 load =7,R1 5224 store R1,7136 5228 push 5036 5232 call 6334 5399 (End of proc a) (Other modules 6334 entry put record 6670 (optional symbol table) 6999 (last location in the code segment) 7000 (first location in the data segment) 7136 Space for gVar variable] 8000 (other processs programs)
7.1.2 Preparing Program for Execution(5/9) • The Program Loaded at Location 4000 17
7.1.2 Preparing program for Execution(6/ 9) Address Binding Assign physical addresses relocation Static binding Programming time Compilation time Linking time · Loading time Dynamic binding Execution time
7.1.2 Preparing Program for Execution(6/9) • Address Binding • Assign Physical Addresses = Relocation • Static binding • Programming time • Compilation time • Linking time • Loading time • Dynamic binding • Execution time 18
7.1.2 Preparing program for Execution(779) Static Address Binding Static Binding At Programming, Compilation, Linking, and/or Loading time 1000 function function f 1O0 1100 Int i 120 1120 Compiler Linker Loader store 20 tore 120 store 1120 JO branch branch o branch 1000 source object load module load module module module (in seconda (in main memory memory)
7.1.2 Preparing Program for Execution(7/9) • Static Address Binding • Static Binding = At Programming, Compilation, Linking, and/or Loading Time 19
7.1.2 Preparing program for Execution (8/9) Dynamic Address Binding Dynamic Binding At Execution Time 1000 function function f 0 100 l100 Int i 120 1120 Ex xecution Compiler Link store 20 store 120 Loader store 120 address ma fo branch f branch 0 branch 0
7.1.2 Preparing Program for Execution(8/9) • Dynamic Address Binding • Dynamic Binding = At Execution Time 20
7.1.2 Preparing program for Execution( 9 / 9) Address Binding How to implement dynamic binding Perform for each address at run time pa=address_map(la) Simplest form of address_map pa =la+rr( Relocation register 重定位寄存器 1100LOAD1,500 1000 100 LOAD1,5o0有效地址 500 1500 12345 500 12345 存储空间 地址空间 ()动态重定位
7.1.2 Preparing Program for Execution(9/9) • Address Binding • How to implement dynamic binding • Perform for each address at run time: • pa = address_map(la) • Simplest form of address_map: • pa = la + RR(Relocation Register) 21