Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a "pass" mean in Assembly compiling

Tags:

assembly

Just as I asked in my question,
what is a pass in the Assembly code compiling process , thanks to explain

like image 990
Shinobi Avatar asked Jan 31 '26 02:01

Shinobi


1 Answers

In order to generate an object file, the assembler needs to do two things translate each instruction mnemonic into instruction bytes, e.g. add eax, ds:[eax] to 0x0000.

Some of these are easy to do, since all the information is contained in the instruction. However, some instructions have references to elements outside the instruction, such as:

  • jumps, which have a jump target
  • pointers to memory locations in data accesses

If the jump target or memory location have already been seen, there's no problem. However, assembly doesn't limit you to accessing locations that have been seen (such as C, which only allows you to use identifiers that were defined at an earlier point in the file), so there may be cases where an identifier isn't known yet. For instance:

  cmp eax, 0
  jz skip_this
  add eax, edx

skip_this:
  mov ecx, eax

In this example, skip_this isn't known when the jz is encountered, so the assembler doesn't know what address to put there.

In order to build the object file, the assembler processes the assembly file one line at a time. It translates what it can, and keeps track of what it still doesn't know yet. By the end of this stage, all of the identifiers have been encountered.

When the assembler finishes this stage, it processes the assembly file again and fills in the blanks.

Now, to answer your question, each of this stages of processing the entire source file from beginning to end is called a pass.

like image 80
Nathan Fellman Avatar answered Feb 02 '26 11:02

Nathan Fellman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!