Professional Documents
Culture Documents
FALLSEM2018-19 CSE2001 TH SJT502 VL2018191005001 Reference Material I Unit-3lecture3
FALLSEM2018-19 CSE2001 TH SJT502 VL2018191005001 Reference Material I Unit-3lecture3
Lecture 6
Instruction format
• Compute Memory traffic, total memory for
encoding and storing code that implements
the expression evaluation a=(b+c)*d-e.
Assume that the opcode occupy one byte,
addresses occupy three bytes, data values also
occupy three bytes and 3 byte world length
3-Address
Evaluate a = (b+c)*d - e
add a, b, c ab+c 0-Address
add c AccAcc+c
mpy d AccAcc*d
sub e AccAcc-e
store a aAcc
Memory Memory M/As to M/As to Memory
to Store to Fetch Execute Traffic
encode
add a, b, c ab+c
4*3=12 1+(3*3)=1 4 3 4+3=7
mpy a, a, d aa*d 0
sub a, a, e aa-e 4*3=12 1+(3*3)=1 4 3 4+3=7
0
4*3=12 1+(3*3)=1 4 3 4+3=7
0
36 30 12 9 21
Memory Memory M/As to M/As to Memory
to Store to Fetch Execute Traffic
encode
Mov a,b ab
3*3=9 1+(2*3)= 3 2 5
Add a,c aa+c
7
mpy a, d aa*d 3*3=9 1+(2*3)= 3 3 6
Sub a,e a a- e 7
3*3=9 1+(2*3)= 3 3 6
7
3*3=9 1+(2*3)= 3 3 6
7
Memory Memory M/As to M/As to Memory
to Store to Fetch Execute Traffic
load b Accb encode
2*3=6 1+(1*3)=4 2 1 2+1=3
add c AccAcc+c
2*3=6 1+(1*3)=4 2 1 2+1=3
mpy d AccAcc*d
2*3=6 1+(1*3)=4 2 1 2+1=3
sub e AccAcc-e
2*3=6 1+(1*3)=4 2 1 2+1=3
store a aAcc
2*3=6 1+(1*3)=4 2 1 2+1=3
30 20 10 5 15
push b 2*3=6 1+(1*3)=4 2 1 3
push c 2*3=6 1+(1*3)=4 2 1 3
add 3 1 1 0 1
push d 2*3=6 1+(1*3)=4 2 1 3
mpy 3 1 1 0 1
push e 2*3=6 1+(1*3)=4 2 1 3
sub 3 1 1 0 1
pop a 2*3=6 1+(1*3)=4 2 1 3
39 23 13 5 15
Summary of 3-,2-,1-, and 0-Addresss instruction programming
4-Address 45 39 24 9 33
3-Address 36 30 12 9 21
2-Address 36 28 12 11 23
1-Address 30 20 10 5 15
0-Address 39 23 13 5 15
Instruction format
• Compute Memory traffic, total memory for
encoding and storing code that implements
the expression evaluation A= (B-C)*D.
Assume that the opcode occupy one byte,
addresses occupy two bytes, data values also
occupy two bytes and 1 byte world length