How is it conceivable to have a machine without express operands guidelines? This is conceivable on the off chance that we know where the operands are, and where is the outcome to be put away. As such all operands are understood.
A stack is a memory (now and again called LIFO = Last In First Out) characterized by two activities PUSH and POP: PUSH moves another thing from the memory into the stack (you don't need to mind where), while POP gets the last thing that was driven into the stack. The arrangements of procedure on a stack machine are.
Activity
PUSH Operation POP Operation Where
• Operation shows the name of the activity to be performedoperation consistently follows up on the value(s) at head of the stack.
• Op is the location in the principle memory where the incentive to bepushed/popped is found.
A stack machine has two recollections: an unstructured one, we consider it the principle memory, where directions and information are put away, and an organized one, the stack where access is permitted distinctly through predefined activities (PUSH/POP). It merits referencing here that a stack has typically a quick part where the head of the stack is found, and which is normally inside CPU, while the enormous body of the stack is outside the CPU (perhaps extensible to plate) and, subsequently, more slow. One may imagine the quick piece of the stack (inside CPU) as the registers of the machine; in actuality, a stack machine doesn't have unequivocal registers.
Model: STATEMENT IMLPEMENTATION: Show how to execute the announcement
utilizing a stack machine.
Answer:
PUSH a # Push the estimation of a;
PUSH c # Push the estimation of c
MUL # Duplicate the two qualities on head of the stack
PUSH b
Include
PUSH a
Include
POP a # Store the outcome back in memory at the location where an is found.
At whatever point an activity is played out, the source operands are flown from the stack, the activity is performed, and the outcome is driven into the stack.
No comments:
Post a Comment