CS501 Assignment No. 1 Fall 2011 Solution

No Comments
Assignment No. 01
Semester Fall 2011
Advance Computer Architecture - CS501
Total Marks: 20

Due Date: 31/10/2011

Question No 1 Marks: 5+5+5+5 = 20  

Write the code to implement the expression A = (B+C) * (D + E) for 

1) 3-address instructions
2) 2-address instructions
3) 1-address instructions
4) 0-address instructions

In accordance with programming language practice, computing the expression should not change the values of its operands.




Question # 3
Evaluate the expression a=(c+4)*15-b for the 3, 2, 1, and 0-address machines

Solution
3-address
2-address
1-address
0-address
Add a,c,4
mpy a,a,15
sub a,a,b

Load a,c
Add a,4
Mpy a,15
Sub a,b
Lda c
Add 4
Mpy 15
Sub b
Sta a
Push c
Push 4
Add
Push 15
Mpy
Push b
Sub
Pop a 

3-ADDRESS
INSTRUCTIONS

2-ADDRESS
INSTRUCTIONS

1-ADDRESS
INSTRUCTIONS

0-ADDRESS
INSTRUCTIONS

add x,b,c
load y,b

ida d
push d
add y,d,e

add y,c

adda e
push e
mul a,x,y
load r,d

sta s
add

add r, e
ida b
push b

mul y,r
adda c
push c

store a,y
mula s
add


sta z
mul



pop a
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment