Instruction Word Format

Thread Starter

CSharpque

Joined Sep 23, 2011
40
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.
 

Papabravo

Joined Feb 24, 2006
21,225
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.
 

Thread Starter

CSharpque

Joined Sep 23, 2011
40
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
 

Papabravo

Joined Feb 24, 2006
21,225
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.
 

Thread Starter

CSharpque

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

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

One address instruction
LDA A
ADD B
STA T1
LDA C
MUL D
SUB E
ADD T2
LDA A
ADD B
DIV T2
STR X

iS IT RIGHT?
 
Top