Operand Descriptor | Compilation: Expression
- An operand descriptor has the following fields:
1. Attributes: Contains the subfields type, length and miscellaneous information
2. Addressability: Specifies where the operand is located, and how it can be accessed. It has two subfields
- Moreover, Addressability code: Takes the values ‘M’ (operand is in memory), and ‘R’ (operand is in register). Other addressability codes, e.g. address in register (‘AR’) and address in memory (‘AM’), are also possible,
- Address: Address of a CPU register or memory word.
- Ex: a*b
MOVER AREG, A
MULT AREG, B
Three operand descriptors used during code generation. Assuming a, b to be integers occupying 1 memory word, these are:
- A Register Descriptor has two fields
1. Status: Contains the code free or occupied to indicate register status.
2. Operand descriptor #: If status = occupied, this field contains the descriptor for the operand contained in the register.
- Register descriptors stored in an array called Register_descriptor. One register descriptor exists for each CPU register.
- Moreover, In above Example, the register descriptor for AREG after generating code for a*b would be Occupied#3
- Similarly, This indicates that register AREG contains the operand described by descriptor #3.
- The Quadruple is a structure with at the most tour fields such as op,arg1,arg2 and result.
- Moreover, The op field used to represent the internal code for an operator, the arg1 and arg2 represent the two operands used and result field is used to store the result of an expression.
- Similarly, Consider the input statement x:= -a*b + -a*b
Triples Compilation: Expression
- Similarly, The Triple Representation the use of temporary variables avoided by referring the pointers in the symbol table.
- the expression x : = – a * b + – a * b the triple representation is as given below
Indirect Triples | Compilation: Expression
- The Indirect Triple representation the listing of triples is been done. Moreover, And listing pointers are used instead of using statements.