Bit shift operators
This commit is contained in:
@@ -18,6 +18,9 @@ var opHandlers = map[OpCodeType]opHandler{
|
||||
OpOr: (*State).handleOr,
|
||||
OpXor: (*State).handleXor,
|
||||
|
||||
OpShiftRight: (*State).handleShiftRight,
|
||||
OpShiftLeft: (*State).handleShiftLeft,
|
||||
|
||||
OpIsEqual: (*State).handleIsEqual,
|
||||
OpIsLessThanUnsigned: (*State).handleIsLessThanUnsigned,
|
||||
OpIsLessThanSigned: (*State).handleIsLessThanSigned,
|
||||
@@ -102,6 +105,18 @@ func (state *State) handleXor(instr *Instruction) {
|
||||
state.writeUnsigned(&instr.Operand1, in1^in2)
|
||||
}
|
||||
|
||||
func (state *State) handleShiftRight(instr *Instruction) {
|
||||
in1 := state.readUnsigned(&instr.Operand1)
|
||||
in2 := state.readUnsigned(&instr.Operand2)
|
||||
state.writeUnsigned(&instr.Operand1, in1>>in2)
|
||||
}
|
||||
|
||||
func (state *State) handleShiftLeft(instr *Instruction) {
|
||||
in1 := state.readUnsigned(&instr.Operand1)
|
||||
in2 := state.readUnsigned(&instr.Operand2)
|
||||
state.writeUnsigned(&instr.Operand1, in1<<in2)
|
||||
}
|
||||
|
||||
func (state *State) handleIsEqual(instr *Instruction) {
|
||||
in1 := state.readUnsigned(&instr.Operand1)
|
||||
in2 := state.readUnsigned(&instr.Operand2)
|
||||
|
||||
Reference in New Issue
Block a user