Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java EVM stack operations. Any help is appreciated! Swap: Negate: cmp: Logic: Shift: 1 import EVM. 2 import Utilities.*; 3 import Utilities.Error; import Value.* import

Java EVM stack operations. Any help is appreciated!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Swap:

image text in transcribed

Negate:

image text in transcribed

cmp:

image text in transcribed

Logic:

image text in transcribed

Shift:

image text in transcribed

1 import EVM. 2 import Utilities.*; 3 import Utilities.Error; import Value.* import OperandStack. 6 import Instruction.*; 7 import java.util.* 8 import java.io. 10 public class EVM static private void bin0p(int opcode, int type, OperandStack operandStack) Value o1, o2; 12 13 14 15 16 17 18 19 20 21 o1 operandStack.pop) 02 operandStack.pop) 7 Check that the operands have the right type if (!(o1.getType()type && o2.getType)type)) Error.error("Error: Type mismatch -operands do not match operator.") switch (opcode) case RuntimeConstants.opc_dadd: operandStack.push(new DoubleValue(((DoubleValue)o2).getValue()+((DoubleValue)o1).getValue())); break; 7Finish this method 23 24 25 26 /1 code here 27 28 29 30 /1 code here static private void swap (OperandStack operandStack) static private void negate(int type, OperandStack operandStack) 32 static private void cmp (int type, OperandStack opera ndStack) { 34 / code here 35 36 37 38 39 40 static private void two(int from, int to, OperandStack operandStack) Value e-operandStack.pop) if (e.getType()-from) Error.error("OperandStack.two: Type mismatch.") switch (from) 1 import EVM. 2 import Utilities.*; 3 import Utilities.Error; import Value.* import OperandStack. 6 import Instruction.*; 7 import java.util.* 8 import java.io. 10 public class EVM static private void bin0p(int opcode, int type, OperandStack operandStack) Value o1, o2; 12 13 14 15 16 17 18 19 20 21 o1 operandStack.pop) 02 operandStack.pop) 7 Check that the operands have the right type if (!(o1.getType()type && o2.getType)type)) Error.error("Error: Type mismatch -operands do not match operator.") switch (opcode) case RuntimeConstants.opc_dadd: operandStack.push(new DoubleValue(((DoubleValue)o2).getValue()+((DoubleValue)o1).getValue())); break; 7Finish this method 23 24 25 26 /1 code here 27 28 29 30 /1 code here static private void swap (OperandStack operandStack) static private void negate(int type, OperandStack operandStack) 32 static private void cmp (int type, OperandStack opera ndStack) { 34 / code here 35 36 37 38 39 40 static private void two(int from, int to, OperandStack operandStack) Value e-operandStack.pop) if (e.getType()-from) Error.error("OperandStack.two: Type mismatch.") switch (from)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago