lab17: init
This commit is contained in:
33
lab17/op-codes.js
Normal file
33
lab17/op-codes.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
let opcodes = {
|
||||
0x01: { mnemonic: 'ADD', evaluate: (vm) => {
|
||||
let v1 = vm.stack.pop();
|
||||
let v2 = vm.stack.pop();
|
||||
vm.stack.push(v1+v2);
|
||||
}},
|
||||
0x02: { mnemonic: 'MUL', evaluate: (vm) => {
|
||||
//
|
||||
// **YOUR CODE HERE**
|
||||
//
|
||||
// Pop the top two arguments off of the stack,
|
||||
// and then push the result on to the stack.
|
||||
}},
|
||||
0x5B: { mnemonic: 'JUMPDEST', evaluate: (vm) => {
|
||||
// Does nothing. We could check to make sure that jumps
|
||||
// always land at JUMPDEST opcodes, but it is not totally
|
||||
// clear that it is worth the bother.
|
||||
}},
|
||||
0x60: { mnemonic: 'PUSH1', evaluate: (vm) => {
|
||||
// The next byte is data, not another instruction
|
||||
vm.pc++;
|
||||
let v = vm.bytecode.readUInt8(vm.pc);
|
||||
vm.stack.push(v);
|
||||
}},
|
||||
0x0c: { mnemonic: 'PRINT', evaluate: (vm) => {
|
||||
// **NOTE**: This is not a real EVM opcode.
|
||||
console.log(vm.stack.pop());
|
||||
}},
|
||||
};
|
||||
|
||||
exports.opcodes = opcodes;
|
||||
Reference in New Issue
Block a user