# Instruction Word Format

Discussion in 'Homework Help' started by CSharpque, Dec 11, 2011.

1. ### CSharpque Thread Starter Member

Sep 23, 2011
40
0
Hello
I have two question in my paper

Write down zero address and one address instruction for X=(A+b)*(C+d)/(E-F)

I know format of both instruction For one address instruction format id
op code and address part
and for two address instruction format
op code
so how can write this can anyone explain this?

Second question
Write a program to evaluate arithmatic statement x=((A*B)+(C*D-E))/(A+B) - using general register computer with three address instruction format and accumulator type computer with one address instruction format.

2. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
In a zero address machine there is a pushdown stack. All unary operations e.g. negate or comliment, operate on the TOS (Top of Stack). All binary operations e.g. add, subtract, or multiply, use the top two elements of the stack and put the result back on the stack.

Checkout Polish Postfix notation as an unambiguous way to write any expression. The code for such a machine fit nicely into the zero address format.

3. ### CSharpque Thread Starter Member

Sep 23, 2011
40
0
i got answer for question one and concept is same as u said thank for answer
and anyone help me how to solve question 2 i can't understand what question 2 said

4. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
A three address format has a operand#1, operand#2, and a result. No intermediate registers are required to do any computation.

In a one address machine there is a general purpose register called an "Accumulator" that is an implied operand along with the single memory address contained in the instruction.

5. ### CSharpque Thread Starter Member

Sep 23, 2011
40
0
i have preapre answer of second question

For three address instruction
MUL t1,A,B
MUL t2,C,D
SUB T3,T2,E
DIV X,T4,T5

LDA A
STA T1
LDA C
MUL D
SUB E
LDA A