Please carefully read the following instructions before attempting assignment.
It should be clear that your assignment would not get any credit if:
  • The assignment is submitted after the due date.
  • The submitted assignment does not open or file is corrupt.
  • Strict action will be taken if submitted solution is copied from any other student or from the internet.

You should concern the recommended books to clarify your concepts as handouts are not sufficient.
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc. will not be accepted. 
Topic Covered:
  • Instruction set features
  • Addressing modes
  • Comparison of the instruction sets

Question No.1
Write the code/instructions to implement the expression A = (B – C) + 15(D - 45) on 3, 2, 1, and 0-address machines.
Question No.2:
Compute the total memory traffic in bytes for both instructions fetch and instruction execution for the code that implements the expression evaluation for the four machines in question # 1. 
Assume opcodes occupy one byte, addresses occupy three bytes, and data values also occupy three bytes. Don’t mix it with code size of instruction.

Views: 585

Replies to This Discussion

3-address machine

2-address machine

1-address machine

0-address machine

Sub    x,b,c

Sub   Y,d,45

Mul    r,y,15

Add   A,x,r

Load     x,b

Sub       x,c

Load     r,b

Sub       r,45

Mul       r,15

Add      x,r

Store     x.A

Ida             d

Sub a         45

Mul a         15

St a             r

Id a            b

Sub a         c

St a            a

Push            d

Push            45


Push            15


Push             b

Push             c


Pop               A


total memory traffic is
3-address machine ( ) byte
2-address machine ( ) byte
1-address machine ( ) byte
0-address machine ( ) byte

Hello shakila,

you can calculate traffic through below mentioned scenario

3 – Address: There is 1 op code of 1 byte and 3 addresses of 3 bytes so code size will be 10. Also 3 addresses have 3 data fetching instructions so number of bytes accessed through memory will be 9+10=19. Since there are total 4 instructions so total traffic will be 19*4=76

hello nida,

hope you doing well, your last store statement for 2-address code is wrong. it should be "store a,x"




© 2019   Created by Irfan Khan MSCS.   Powered by

Badges  |  Report an Issue  |  Terms of Service