Navi

Number of Addresses (a)

Zero- Addresses (0-operand)

so called stack machines: All arithmetic operations take place using the top one or two positions on the stack: push a, push b, add, pop c. For stack machines, the terms "0-operand" and "zero-address" apply to arithmetic instructions, but not to all instructions, as 1-operand push and pop instructions are used to access memory.

All addresses implicit
Uses a stack that is in a known location and often at least the top 2 elements are in processor registers.
e.g. push a
      push b
      add
      pop c

c = a + b

Example :-

Program to execute Y = (A-B) / (C+D*E)


0-Address

One-Address (1-operand)

so called accumulator machines, include early computers and many small microcontrollers: most instructions specify a single right operand (that is, constant, a register, or a memory location), with the implicit accumulator as the left operand (and the destination if there is one): load a, add b, store c. A related class is practical stack machines which often allow a single explicit operand in arithmetic instructions: push a, add b, pop c.

Implicit second address
Usually a register (accumulator)
Contains one of the operands and is used to store the result
Common on early machines

Example:-
Program to execute Y = (A-B) / (C+D*E)

1-Address

Two addresses (1-operand)

CISC — often load a,reg1; add reg1,b; store reg1,c on machines that are limited to one memory operand per instruction; this may be load and store at the same location
CISC — move a->c; add c+=b.
RISC — Requiring explicit memory loads, the instructions would be: load a,reg1; load b,reg2; add reg1,reg2; store reg2,c

One address doubles as operand and result
a = a + b
Reduces length of instruction
Requires some extra work
Temporary storage to hold some results


Example:-
Program to execute Y = (A-B) / (C+D*E)


2-Address

Three addresses (1-operand)


CISC — It becomes either a single instruction: add a,b,c, or more typically: move a,reg1; add reg1,b,c as most machines are limited to two memory operands.
RISC — arithmetic instructions use registers only, so explicit 2-operand load/store instructions are needed: load a,reg1; load b,reg2; add reg1+reg2->reg3; store reg3,c; unlike 2-operand or 1-operand, this leaves all three values a, b, and c in registers available for further reuse.
Operand 1, Operand 2, Result
a = b + c;
May be a forth - next instruction (usually implicit)
Not common
Needs very long words to hold everything

Example:-

Program to execute Y = (A-B) / (C+D*E)

3-Address


0 comments: