Added more tests
This commit is contained in:
@ -6,26 +6,6 @@ func Jump(offset int) uint32 {
|
||||
return 0b000101<<26 | uint32(offset)
|
||||
}
|
||||
|
||||
// JumpIfLess jumps if the result was less.
|
||||
func JumpIfLess(offset int) uint32 {
|
||||
return branchCond(0b1001, offset)
|
||||
}
|
||||
|
||||
// JumpIfLessOrEqual jumps if the result was less or equal.
|
||||
func JumpIfLessOrEqual(offset int) uint32 {
|
||||
return branchCond(0b1101, offset)
|
||||
}
|
||||
|
||||
// JumpIfGreater jumps if the result was greater.
|
||||
func JumpIfGreater(offset int) uint32 {
|
||||
return branchCond(0b1100, offset)
|
||||
}
|
||||
|
||||
// JumpIfGreaterOrEqual jumps if the result was greater or equal.
|
||||
func JumpIfGreaterOrEqual(offset int) uint32 {
|
||||
return branchCond(0b1010, offset)
|
||||
}
|
||||
|
||||
// JumpIfEqual jumps if the result was equal.
|
||||
func JumpIfEqual(offset int) uint32 {
|
||||
return branchCond(0b0000, offset)
|
||||
@ -36,6 +16,26 @@ func JumpIfNotEqual(offset int) uint32 {
|
||||
return branchCond(0b0001, offset)
|
||||
}
|
||||
|
||||
// JumpIfGreater jumps if the result was greater.
|
||||
func JumpIfGreater(offset int) uint32 {
|
||||
return branchCond(0b1100, offset)
|
||||
}
|
||||
|
||||
// JumpIfGreaterOrEqual jumps if the result was greater or equal.
|
||||
func JumpIfGreaterOrEqual(offset int) uint32 {
|
||||
return branchCond(0b1010, offset)
|
||||
}
|
||||
|
||||
// JumpIfLess jumps if the result was less.
|
||||
func JumpIfLess(offset int) uint32 {
|
||||
return branchCond(0b1001, offset)
|
||||
}
|
||||
|
||||
// JumpIfLessOrEqual jumps if the result was less or equal.
|
||||
func JumpIfLessOrEqual(offset int) uint32 {
|
||||
return branchCond(0b1101, offset)
|
||||
}
|
||||
|
||||
// branchCond performs a conditional branch to a PC-relative offset.
|
||||
func branchCond(cond uint32, offset int) uint32 {
|
||||
offset &= 0b111_1111_1111_1111_1111
|
||||
|
Reference in New Issue
Block a user