Loader Concept Loader Basics Assembler Object Program Loader
Loader
Concept
Loader Basics Assembler Object Program Loader Memory (Core)
Subroutines 1. Open 2. Close – has to b loaded at specific address – Program and subroutine assembled together Subroutine Program 2 Program 1 Core allocation
Subroutines • What programmer want? • System programmers solution
Loader Functions 1. Allocate space in memory for programs (Allocation) 2. Resolve symbolic references between object decks (Linking) 3. Adjust address dependent locations to correspond to allocated space (Relocation) 4. Physically place data and instructions in memory (Loading)
Loader Schemes • Compile and Go Loader Source Program Deck • Working • Easy to implement • What is role of loader • Disadvantages Compile-and-Go Translator Program Loaded in memory Assembler
General Loader Scheme • Core wasting in previous scheme • Concept of object deck Source Program Translator Object Program 1 Loader Source Program Translator Object Program 1 • Advantages Object Programs cv for ready execution Loader
Absolute Loader • Almost like Assemble and Go loader, difference is in data passing • Disadvantages 1. Core address should b specified by programmer to assembler 2. If multiple subroutines, address of each programmer shd remember
Subroutine Linkages MAIN Main Program BAL 14, B START EXTRN ------L BALR ------END Why register 15 always? SUBROUT 15, =A(SUBROUT) 14, 15
SUBROUTINE SUBROUT START USING ------BR END *15 14
Relocating loaders • Each source program outputs text prefixed by transfer vector • Transfer vector consists of addresses contaning names of subroutines • Assembler provides length of program
Relocating Loaders • Used to 1. Avoid reassembling of all SR’s when single SR is changed 2. Perform task of allocation and linking • Binary Symbolic Subroutine(BSS) Loader • O/p of assembler has – Object program – Info @ all other prog it referenced – Relocation info
Assembly Program MAIN SAVE START EXTRN SQRT EXTRN ERR ST 14, SAVE L 1, =F’ 9’ BAL 14, SQRT C 1, =F’ 3’ BNE ERR L 14, SAVE BR 14 DS F END
Assembly Program MAIN SAVE START Machine Level Program RELATIVE ADDRESS RELOCATI OBJECT CODE ON EXTRN SQRT 0 00 ‘SQRT’ EXTRN ERR 4 00 ‘ERRb’ ST 14, SAVE 8 01 ST 14, 36 L 1, =F’ 9’ 12 01 L 1, 40 BAL 14, SQRT 16 01 BAL 14, 0 C 1, =F’ 3’ 20 01 C 1, 44 BNE ERR 24 01 BC 7, 4 L 14, SAVE 28 01 L 14, 36 BR 14 32 0 BCR 15, 14 34 0 36 00 Temp Location 40 00 9 44 00 3 DS END F
ABSOLUTE ADDRESS RELATIVE ADDRESS Memory --- 400 0 BC 15, 448 404 4 BC 15, 526 408 8 ST 14, 436 412 12 L 1, 440 416 16 BAL 14, 400 420 20 C 1, 444 424 24 BC 7, 404 428 28 L 14, 436 432 32 BCR 15, 14 436 34 Temp Location 440 40 9 444 44 3 448 SQRT 526 ERR 48 Bytes 78 Bytes
- Slides: 16