Question: 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!





Swap:

Negate:

cmp:

Logic:

Shift:

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
Get step-by-step solutions from verified subject matter experts
