Object Code Forms in Compilation
In the final stage of compilation, the code generator produces the output known as the object code. This code
is the machine-understandable form of the original program. Depending on the target platform and use case,
the compiler can produce the object code in several different forms. Each form has its own advantages and
trade-offs in terms of execution speed, flexibility, and ease of linking.
1. Absolute Machine Code
This is a fully compiled, final form of machine code that is ready to be loaded into memory and executed
directly.
- No further processing like linking or relocation is needed.
- Typically used in simple or small standalone systems.
- Suitable for educational compilers like WATFIV or PL/C.
- Limitation: No flexibility for modularity or dynamic linking.
Absolute Code Example:
Example:
Memory Location | Instruction
0x0000 | LOAD A
0x0001 | ADD B
0x0002 | STORE C
0x0003 | HALT
2. Relocatable Object Code
This form of code can be relocated in memory during linking or loading. Each subprogram can be compiled
separately and later combined into a full program.
- Common in modern development environments.
- Object modules can be linked together using a linker.
- Compiler must provide relocation information.
- Supports large and modular programs.
Object Code Forms in Compilation
Relocatable Code Snippet:
Example:
Symbol Table Entry:
Label: START | Offset: 0x0040
Instruction: JMP START ; Adjusted during linking
3. Assembly Language Code
This is a symbolic version of the machine code. It is more readable and can be processed by an assembler to
produce final object code.
- Easier to debug and optimize manually.
- Allows use of macros, constants, and labels.
- Requires a separate assembly step.
- Useful for low-level system programming and embedded systems.
Assembly Code Example:
Example:
MOV AX, 0010h
ADD AX, BX
MOV [RESULT], AX
Comparison of Object Code Forms
| Code Form | Human Readable | Executable Directly | Requires Linking |
|----------------------|----------------|----------------------|------------------|
| Absolute Machine Code| No | Yes | No |
| Relocatable Code | No | No | Yes |
| Assembly Code | Yes | No | Yes |
Conclusion
Each object code form serves different needs in software development. For quick execution, absolute code is
effective. For modular programming and code reuse, relocatable code is ideal. Assembly code offers greater
Object Code Forms in Compilation
control and transparency for debugging, making it suitable for system-level programming.