Software Development Process Compiler Linker C File Asm. File Binary File Exec. File Assemble r Library Implementation Phase Debugger Profiler Verification Phase Compilers –Cross compiler Runs on one processor, but generates code for another Assemblers Linkers Debuggers Profilers
Assembly and linking Last steps in compilation: HLL compile assembly assemble HLL assembly link executable load
Multiple-module programs Programs may be composed from several files. Addresses become more specific during processing: –relative addresses are measured relative to the start of a module; –absolute addresses are measured relative to the start of the CPU address space.
Assemblers Major tasks: –generate binary for symbolic instructions; –translate labels into addresses; –handle pseudo-ops (data, etc.). Generally one-to-one translation. Assembly labels: ORG 100 label1ADR r4,c
Symbol table ADD r0,r1,r2 xxADD r3,r4,r5 CMP r0,r3 yySUB r5,r6,r7 assembly code xx0x8 yy0x10 symbol table
Symbol table generation Use program location counter (PLC) to determine address of each location. Scan program, keeping count of PLC. Addresses are generated at assembly time, not execution time.
Symbol table example ADD r0,r1,r2 xxADD r3,r4,r5 CMP r0,r3 yySUB r5,r6,r7 xx0x8 yy0x10 PLC=0x7
Two-pass assembly Pass 1: –generate symbol table Pass 2: –generate binary instructions
Relative address generation Some label values may not be known at assembly time. Labels within the module may be kept in relative form. Must keep track of external labels---can’t generate full binary for instructions that use external labels.
Pseudo-operations Pseudo-ops do not generate instructions: –ORG sets program location. –EQU generates symbol table entry without advancing PLC. –Data statements define data blocks.
Linking Combines several object modules into a single executable module. Jobs: –put modules in order; –resolve labels across modules.
external reference entry point Externals and entry points xxxADD r1,r2,r3 B a yyy%1 aADR r4,yyy ADD r3,r4,r5
Module ordering Code modules must be placed in absolute positions in the memory space. Load map or linker flags control the order of modules. module1 module2 module3
Dynamic linking Some operating systems link modules dynamically at run time: –shares one copy of library among all executing programs; –allows programs to be updated with new versions of libraries.
Formato S S00F C6C6F C S11F00007C0802A FFF07C6C1B787C8C23783C S11F001C4BFFFFE D C0803A64E800020E9 S C6C6F20776F726C642E0A0042 S F9 S FC Record Description Address Bytes Data Sequence –S0 Block header 2 Yes –S1 Data sequence 2 Yes –S2 Data sequence 3 Yes –S3 Data sequence 4 Yes –S5 Record count 2 No –S7 End of block 4 No –S8 End of block 3 No –S9 End of block 2 No
Intel HEX file : EFE09D : EB7C20001FF5F : E EDA3F01B2CAA7 : F B5E712B722B C7 : FF The first data record is explained as follows: : Start code. 10 Hex 10 (decimal 16), indicating 16 data character pairs, 16 bytes of binary data, in this record. 01 Four-character 2-byte address field: hex address 0100, 00 indicates location where the following data is to be loaded. 00 Record type indicating a data record. The next 16 character pairs are the ASCII bytes of the actual program data. 40 Checksum of the first Hex-record. The termination record is explained as follows: : Start code. 00 Byte count is zero, no data in termination record. 00 Four-character 2-byte address field, zeros Record type 01 is termination. FF Checksum of termination record. HEX-RECORD TYPES There are three possible types of Hex-records. –00 :A record containing data and the 2-byte address at which the data is to reside. –01 : A termination record for a file of Hex-records. Only one termination record is allowed per file and it must be the last line of the file. There is no data field. –02 : A segment base address record. This type of record is ignored by Lucid programmers.