100% found this document useful (4 votes)
8K views

Intermediate Code Forms (Variant I and Variant II)

The document describes two variants of intermediate code used in compilers. Variant I represents operands as symbols, literals, or constants paired with an ordinal number, such as (S,17) for a symbol. Variant II selectively replaces operands with their processed forms, representing literals as pairs like (L,m) but leaving symbols as references. Both variants store intermediate code as sequences of IC units with an address, mnemonic, and operands field for each instruction.

Uploaded by

Sagar Mane
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
8K views

Intermediate Code Forms (Variant I and Variant II)

The document describes two variants of intermediate code used in compilers. Variant I represents operands as symbols, literals, or constants paired with an ordinal number, such as (S,17) for a symbol. Variant II selectively replaces operands with their processed forms, representing literals as pairs like (L,m) but leaving symbols as references. Both variants store intermediate code as sequences of IC units with an address, mnemonic, and operands field for each instruction.

Uploaded by

Sagar Mane
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Intermediate Code Forms

• The intermediate code consist of sequence of


IC units, each IC unit consisting of the
following three fields.
• 1. Address
• 2.Representation of the mnemonic opcode.
• 3.Representation of operands.
Mnemonic Field
• The mnemonic field contains a pair of the form:
• (statement class, code)

• Statement class can be one of IS,DL, and AD standing for


imperative statement, declaration statement and assembler
directive respectively.
• Imperative statement: code is the instruction opcode in the
machine language
• Declaration statement and assembler directive: code is an
ordinal number within class
• E.g (AD,01) ---Assembler directive START
Intermediate code for Imperative Statement

• Two variants of Intermediate Code


• Variant-I
• Variant-II

• Variant-I
• The first operand is represented by a single digit number which is
a code for a register (1-4 for AREG-DREG) or the condition code
itself(1-6 for LT-ANY)
• The second operand which is a memory operand, is represented
by a pair of the form
• (operand class, code)
• Where operand class is one of C, S, L standing for constant,
symbol and literal
• e.g The operand descriptor for the statement
START 200 is (C,200)
For a symbol or literal the code field contains the
ordinal number of the operands entry in SYMTAB
or LITTTAB.

Entries for a symbol xyz and a literal =‘25’ would be


of the form
(S,17) and (L,35) respectively.
• It is necessary to enter A in SYMTAB say in entry
number n, so that it can be represented by (S,n)
IC.
• This implies that two kinds of entries may exist in
SYMTAB at any time –for defined symbols and for
forward references.
• Variant II:
• This variant differs from variant I of the
intermediate code in that the operand field of
the source statement are selectively replaced
by their processed forms.
• For Imperative statements, the operand field
is processed only to identify literal references.
• Literals are entered in LITTTAB and are
represented as (L,m) in IC.
• Symbolic references in the source statement
are not processed at all during pass I.
Comparison of Variants
Variant II

You might also like