Zap
Zap

Reputation: 346

An empty label in assembly occupies memory without having an instruction stored in it?

If I had the following assembly code:

      slt $t0, $t1, $t2
      bgt $t0, $t3, ELSE
      j DONE
ELSE: addi $t0, $t0, 1
DONE:

How many bytes would it take in the memory to store it? More specifically, does the empty "DONE" label use up 4 bytes as any common instruction or does it take 0 bytes since it's empty?

Upvotes: 0

Views: 1553

Answers (1)

fuz
fuz

Reputation: 93024

Labels do not occupy memory at runtime. They are just meta data to help the assembler and linker resolve references in your program. They are not needed to run the program and the CPU doesn't care abut them. Once the program is linked, they are typically stripped away from the binary as they are no longer needed.

Upvotes: 2

Related Questions