+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
IDEA SOLUTION:
A= (B+C)*(D+E)
3 address instructions involve three operands i.e. two source and one destination. Op-code specifies the operation to be carried out.
add x, b, c
add y, d, e
mul a, x, y
In case of 2 address instructions, there are two operands. One of them is used as source whereas the other one is used both as source and destination.
load y, b
add y, c
load r, d
add r, e
mul y, r
store a, y
In case of 0 address instruction only op code field has to be specified. Stack is used to hold both the operands and result.
push d
push e
add
push b
push c
add
mul
pop a
** Values of all operands remained unchanged. **
Tags:
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)One more idea solution of CS501 Assignment#1 Fall 2011
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 |
r,c,24
Mul s,r,17
Add z,y,s
Two Address Instruction
Load y,a
Sub y,b
Mul y,3
Load s,c
Add s,24
Mul s,17
Add y,s
Store z,y
One Address Instruction
Lda c
Adda 24
Mula 17
Sta s
Lda a
Suba b
Mul 3
Adda s
Sta z
0 Address Instruction
push c
push 24
add
push 17
mul
push a
push b
sub
push 3
mul
add
popz
QUESTION 1:
Write the code to implement the expression A = (B+C) * (D + E) for
3-address instructions
2-address instructions
1-address instructions
0-address instructions
In accordance with programming language practice, computing the expression should not change the values of its operands.
SOLUTION:
bhai ye solution thek ha ??????
Fit hay.........
CS501 SOLUTION
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.
SOLUTION:
The given expression is A = (B+C) * (D + E)
3-ADDRESS INSTRUCTIONS
|
2-ADDRESS INSTRUCTIONS
|
1-ADDRESS INSTRUCTIONS |
0-ADDRESS INSTRUCTIONS
|
|
add x,b,c |
load y,b |
lda 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 |
lda b |
push b |
|
|
mul y,r |
adda c |
push c |
|
|
store a,y |
mula s |
add |
|
|
|
sta z |
mul |
|
|
|
|
pop a |
|
See the attached file for one more idea solution of CS501 Assignment#01 Fall 2011
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post