Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 7

Unit-3

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 ab+c 0-Address

mpy a, a, d aa*d push b


sub a, a, e aa-e push c
2-Address
add
mov a, b ab
push d
add a, c aa+c
mpy
mpy a, d aa*d
push e
sub a, e aa-e
1-Address sub
load b Accb pop a

add c AccAcc+c
mpy d AccAcc*d
sub e AccAcc-e
store a aAcc
Memory Memory M/As to M/As to Memory
to Store to Fetch Execute Traffic
encode
add a, b, c ab+c
4*3=12 1+(3*3)=1 4 3 4+3=7
mpy a, a, d aa*d 0
sub a, a, e aa-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 ab
3*3=9 1+(2*3)= 3 2 5
Add a,c aa+c
7
mpy a, d aa*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 Accb encode
2*3=6 1+(1*3)=4 2 1 2+1=3
add c AccAcc+c
2*3=6 1+(1*3)=4 2 1 2+1=3
mpy d AccAcc*d
2*3=6 1+(1*3)=4 2 1 2+1=3
sub e AccAcc-e
2*3=6 1+(1*3)=4 2 1 2+1=3
store a aAcc
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

Instructio Memory to Memory M/As to M/As to Memory


n Format Store to Encode Fetch Execute Traffic

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

You might also like