Bitwise operators
This commit is contained in:
@@ -13,6 +13,11 @@ var opHandlers = map[OpCodeType]opHandler{
|
||||
OpDivideUnsigned: (*State).handleDivideUnsigned,
|
||||
OpDivideSigned: (*State).handleDivideSigned,
|
||||
|
||||
OpNot: (*State).handleNot,
|
||||
OpAnd: (*State).handleAnd,
|
||||
OpOr: (*State).handleOr,
|
||||
OpXor: (*State).handleXor,
|
||||
|
||||
OpIsEqual: (*State).handleIsEqual,
|
||||
OpIsLessThanUnsigned: (*State).handleIsLessThanUnsigned,
|
||||
OpIsLessThanSigned: (*State).handleIsLessThanSigned,
|
||||
@@ -74,6 +79,29 @@ func (state *State) handleDivideSigned(instr *Instruction) {
|
||||
state.writeSigned(&instr.Operand1, in1/in2)
|
||||
}
|
||||
|
||||
func (state *State) handleNot(instr *Instruction) {
|
||||
in := state.readUnsigned(&instr.Operand1)
|
||||
state.writeUnsigned(&instr.Operand1, in^uint64(0xffffffffffffffff))
|
||||
}
|
||||
|
||||
func (state *State) handleAnd(instr *Instruction) {
|
||||
in1 := state.readUnsigned(&instr.Operand1)
|
||||
in2 := state.readUnsigned(&instr.Operand2)
|
||||
state.writeUnsigned(&instr.Operand1, in1&in2)
|
||||
}
|
||||
|
||||
func (state *State) handleOr(instr *Instruction) {
|
||||
in1 := state.readUnsigned(&instr.Operand1)
|
||||
in2 := state.readUnsigned(&instr.Operand2)
|
||||
state.writeUnsigned(&instr.Operand1, in1|in2)
|
||||
}
|
||||
|
||||
func (state *State) handleXor(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