Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Q5: Quiz#5: Postfix code
1. Q5: postfix code
38: Quiz#5: Postfix code , Name: ___________________________
CS 340, Fall 2019, York College of Pennsylvania
41, 20 points, 2019-10-09 (at start of class)
2. Background
3. Postfix code execution
Use the provided postfix code and values for the variables in the postfix code.
The first line should be "init the stack".
Write the variable or operator, left justified on a separate line.
On the following line(s) for each variable or operator, write the actions(s), for that variable or operator.
pushes should have the form "push expression as value".
pops should have the form "pop value as variable".
Use reg1 and reg2 as temporary registers.
The last line should indicate the result.
The variable values to be used will be provided. (Note: This was done in class when the exam was given and this text added after the exam).
Postfix code list:
omitted
Variable values:
(omitted)
Example: (using the running example)
Postfix code:
x y & x ! y ! & |
Let
x be
1 and
y be
0
Sequence: (you should write something like the following, depending on the expression provided).
init stack to empty
x
push x as 1
y
push y as 0
&
pop 0 as reg2
pop 1 as reg1
push reg1*reg2 as 0
x
push x as 1
&
pop 1 as reg2
push 1-reg2 as 0
y
push y as 0
&
pop 0 as reg2
push 1-reg2 as 1
&
pop 1 as reg2
pop 0 as reg1
push reg1*reg2 as 0
|
pop 0 as reg2
pop 0 as reg1
push reg1+reg2-reg1*reg2 as 0
pop 0 as result
4. Scoring rubric
CS 340 - Q5 : Quiz#5: Postfix code
Your grade: _ / 20
[LATE] Late or redo penalty: _ / -20
Pre-rubric summary score: _ / 20
Note: The rubric system was created after this work was graded.
[CREDIT] Extra credit: _ / +4
Comments: