Contents    Page-10    Prev    Next    Page+10    Index   

Location Counter

As code is generated, it will be put into the next available location in a static data area. A location counter keeps track of the next available location in the data area.

  1. Initially, the LC is set to 0 .

  2. After each instruction is generated, the LC is incremented by the length of the instruction.

  3. When a label is encountered, the relative address of the label is set to the value of the LC.

  4. At the end, the length of the code segment is the value of the LC.

There may be multiple location counters, e.g., one for code and one for static data.