Docsity

3. assembler 1, Lecture notes of System Programming

Partial preview of the text

Download 3. assembler 1 and more Lecture notes System Programming in PDF only on Docsity!

Assembler

UNITI

Assembler

  • (^) Assembler is a program that converts assembly language program into the machine language. Source Program Assembler Target Program Written in assembly language Machine language equivalent Databases Input Output

Assembler’s functions

  • (^) Convert mnemonic operation codes to their machine language equivalents.
  • (^) Convert symbolic operands to their equivalent machine addresses.
  • (^) Build the machine instructions in the proper format.
  • (^) Convert the data constants to internal machine representations.
  • (^) Write the object program and the assembly listing.

Format of Assembly Language

  • (^) An assembly language statement has following format: [Label] [,…] Meanings of various parts of statement:
  1. […..] Optional field
  2. Label Symbolic name
  3. Opcode Pseudoop
  4. Operand specification Types of operand(regreg, storage , Immediate)

Literal

  • (^) The difference between literal operands and

immediate operands:

  • (^) ‰ Immediate addressing, the operand value is assembled as part of the machine instruction, no memory reference. ‰
  • (^) With a literal, the assembler generates the specified value as a constant at some other memory location. The address of this generated constant is used as the TA for the machine instruction, using PCrelative or baserelative addressing with memory reference.
  • (^) Literal pools ‰ At the end of the program, Assembler directive LTORG, it creates a literal pool that contains all of the literal operands used since the previous LTORG.

Data structure used by assembler

1. Symbol Table (SYMTAB)

2. Literal Table (LITTAB)

3. Mnemonics Table or Machine Operation

Table(MOT)

4. PseudoOpcode Table (POT) or Operation

Code Table(OPTAB)

5. Location Counter

6. Pool Table(POOLTAB)

Contd…

  • (^) POT/OPTAB
  • (^) MOT

POOLTAB

Mnemonic Opcode Class Mnemonic Info. MOVER IS (04,1) DS DL R # 7 START AD R # 11 Mnemonics Opcode Length ADD 01 1 SUB 02 1 **Literal No

#**

Forward Reference in Onepass Assembler

  • Omits the operand address if the symbol has not yet been defined.
  • Enters this undefined symbol into SYMTAB and indicates that it is undefined.
  • Adds the address of this operand address to a list of forward references associated with the SYMTAB entry.
  • When the definition for the symbol is encountered, scans the reference list and inserts the address.
  • At the end of the program, reports the error if there are still SYMTAB entries indicated undefined symbols.
  • For LoadandGo assembler o Search SYMTAB for the symbol named in the END statement and jumps to this location to begin execution if there is no error.