Login
Register
@
Dark Mode
Profile
Edit my Profile
Messages
My favorites
Register
Activity
Q&A
Questions
Unanswered
Tags
Subjects
Users
Ask
Previous Years
Blogs
New Blog
Exams
Dark Mode
ISA architrecture
shima abdullah
asked
in
CO and Architecture
Jul 4, 2022
retagged
Jul 4, 2022
by
Shubham Sharma 2
103
views
0
votes
0
votes
Write a stack-based program that computes the following function : 5+(3x7) – 8, assuming that the stack starts out empty
co-and-architecture
stack
shima abdullah
asked
in
CO and Architecture
Jul 4, 2022
retagged
Jul 4, 2022
by
Shubham Sharma 2
by
shima abdullah
103
views
answer
comment
Follow
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
0
votes
0
votes
@
shima+abdullah
In forth you could do it this way….
1. 5 3 7 * + 8 –
What is happening on the line ::
5 is pushed onto the stack....
3 is pushed onto the stack….
7 is pushed onto the stack….
* multiplies the top two stack elements which removes them both from the stack and then pushes the result onto the stack……
+ adds the top two stack elements which removes them both from the stack and then pushes the result onto the stack…..
8 is pushed onto the stack….
- the top element is subtracted from second element which removes them both from the stack and then pushes the result onto the stack….
So the stack looks like this at each stage.
Top of the stack is the rightmost element ::
# 5 ...
## 5 3 ...
### 5 3 7 ...
#### 5 21 ...
##### 26 ...
###### 26 8 ….
####### 18 …..
The . on the second line is a command that prints the top of the stack and then removes it ….
## assuming that the stack starts out empty?
Also, in the above code it does not matter if there is something in the stack before these operations as we only play with what we put there….
Bikram 1
answered
Jul 13, 2022
by
Bikram 1
comment
Follow
share this
0 Comments
Please
log in
or
register
to add a comment.
← Previous
Next →
← Previous in category
Next in category →
Related questions
0
votes
0
votes
0
answers
1
shima abdullah
asked
in
CO and Architecture
Jul 2, 2022
119
views
in a stack ISA, the postfix expression z = X Y x W U x +
In a stack ISA, the postfix expression z = X Y x W U x +
shima abdullah
asked
in
CO and Architecture
Jul 2, 2022
by
shima abdullah
119
views
co-and-architecture
stack
0
votes
0
votes
1
answer
2
Overflow04
asked
in
CO and Architecture
Sep 5, 2022
127
views
COA
Please Explain : “ sp content is incremented for stack going downward method and decrement for stack going upward method”
Overflow04
asked
in
CO and Architecture
Sep 5, 2022
by
Overflow04
127
views
co-and-architecture
stack
ace-test-series
0
votes
0
votes
1
answer
3
pream sagar
asked
in
CO and Architecture
Jan 21, 2019
184
views
made easy test series
Consider the following expression used to execute on a stack CPU X = (A × B)+C, where all the variables are in the memory. What is the number of zero and one address instructions are required respectively to evaluate the expression? A)5 and 2 B)0 and 7 C)7 and 0 D)2 and 4
pream sagar
asked
in
CO and Architecture
Jan 21, 2019
by
pream sagar
184
views
co-and-architecture
stack
0
votes
0
votes
0
answers
4
BHOJARAM
asked
in
CO and Architecture
Jan 11, 2019
232
views
#madeeasy
A stack based CPU executes the instruction. Memory location 500 contain 0×88 and memory location 700 contain 0×37. Stack pointer is at 0×003F. I1: push 500 I2: push 700 I3: add I4: pop 600 I5: push 300 Then after execution of above instruction the memory location 600 contains _
BHOJARAM
asked
in
CO and Architecture
Jan 11, 2019
by
BHOJARAM
232
views
co-and-architecture
stack
Subscribe to GATE CSE 2023 Test Series
Subscribe to GO Classes for GATE CSE 2023
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
-tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
DRDO Previous Year Papers
From Rank 4200 to 64: My Journey to Success in GATE CSE Exam
What are the key things to focus on during the final 10-15 days before the GATE exam to improve performance?
All India GO Classes Mock test
NTA UGC NET JRF December 2022 Apply Online Form 2023
Subjects
All categories
General Aptitude
(2.5k)
Engineering Mathematics
(9.3k)
Digital Logic
(3.3k)
Programming and DS
(5.9k)
Algorithms
(4.6k)
Theory of Computation
(6.7k)
Compiler Design
(2.3k)
Operating System
(5.0k)
Databases
(4.6k)
CO and Architecture
(3.8k)
Computer Networks
(4.6k)
Non GATE
(1.3k)
Others
(2.4k)
Admissions
(649)
Exam Queries
(842)
Tier 1 Placement Questions
(17)
Job Queries
(74)
Projects
(9)
Unknown Category
(853)
Recent Blog Comments
When this exam will happen ?
Can Someone guide me how to prepare for interview...
It's not a standard resource, don't follow them.
https://byjus.com/maths/diagonalization/
@amit166 can you share the reference of the...
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy