2025-02-05 23:16:18 +01:00
|
|
|
package x86
|
2024-06-24 11:00:32 +02:00
|
|
|
|
2025-03-13 13:17:58 +01:00
|
|
|
// Jump continues program flow at the new offset.
|
|
|
|
// The offset is relative to the next instruction.
|
|
|
|
func Jump8(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0xEB, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfLess jumps if the result was less.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfLess(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x7C, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfLessOrEqual jumps if the result was less or equal.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfLessOrEqual(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x7E, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfGreater jumps if the result was greater.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfGreater(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x7F, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfGreaterOrEqual jumps if the result was greater or equal.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfGreaterOrEqual(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x7D, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfEqual jumps if the result was equal.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfEqual(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x74, byte(offset))
|
2024-07-07 12:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// JumpIfNotEqual jumps if the result was not equal.
|
2025-03-13 13:17:58 +01:00
|
|
|
func Jump8IfNotEqual(code []byte, offset int8) []byte {
|
|
|
|
return append(code, 0x75, byte(offset))
|
2024-06-24 11:00:32 +02:00
|
|
|
}
|