Phase 3: Assembly to Object Code
What you'll learn: How the computer converts human-readable assembly instructions into a binary format called object code that hardware can almost understand.
From Words to Numbers
In the previous phase, the compiler translated your C code into Assembly. While assembly looks technical, it is still made of human-readable words like MOV, ADD, or PUSH. Your computer's processor, however, is a collection of electrical switches that only understand "on" and "off"—represented by 1s and 0s.
Phase 3 is handled by a tool called the Assembler. Its job is to take those assembly words and translate them into a specific sequence of binary numbers known as Machine Code.
The Object File (.o)
The output of this phase is an Object File (usually ending in .o or .obj). If you were to open an object file in a normal text editor, it would look like complete gibberish—a mess of strange symbols and broken characters. This is because it is no longer meant for human eyes; it is a direct map of instructions for the CPU.
Think of it like a furniture manual. The assembly code was the written instruction: "Insert Screw A into Hole B." The object code is the physical act of the screw entering the hole.
What's inside?
Even though the code is now binary, it isn't a finished program yet. The object file contains:
- Instruction Data: The binary version of your logic.
- Data: Constants or variables you defined.
- A Symbol Table: A list of "addresses" for functions and variables.
Crucially, if your code calls a function from another file (like printf), the object file leaves a "blank space" for it. It knows it needs that function, but it doesn't know where it lives yet.
// Conceptually, the Assembler turns this:
// add ebx, eax
// Into something that looks like this to the CPU:
// 00000011 11011000
By the end of this phase, your source code has been fully translated into the language of the machine, but it remains in separate pieces waiting to be joined together.
Key takeaway
The Assembler converts human-readable assembly text into binary object files (.o) containing raw machine instructions.