mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-29 04:54:27 +01:00
x86 asm: move rotation and bit instructoins in from x86-assembly-cheat
This commit is contained in:
24
userland/arch/x86_64/test.S
Normal file
24
userland/arch/x86_64/test.S
Normal file
@@ -0,0 +1,24 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-bit-and-byte-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
/* 0xF0 & 0x00 == 0x00 */
|
||||
mov $0xF0, %r12
|
||||
test $0, %r12b
|
||||
/* The comparison was equal 0. */
|
||||
LKMC_ASSERT(jz)
|
||||
/* r12 is unchanged. */
|
||||
LKMC_ASSERT_EQ(%r12, $0x0F0)
|
||||
|
||||
/* 0xF0 & 0x18 == 0x10 != 0x00 */
|
||||
mov $0xF0, %r12
|
||||
test $0x18, %r12b
|
||||
LKMC_ASSERT(jnz)
|
||||
LKMC_ASSERT_EQ(%r12, $0x0F0)
|
||||
|
||||
/* test %rax, %rax vs cmp $0, %rax: test produces a shorter
|
||||
* encoding to decide if a register equals zero or not.
|
||||
* http://stackoverflow.com/questions/147173/x86-assembly-testl-eax-against-eax
|
||||
*/
|
||||
LKMC_EPILOGUE
|
||||
Reference in New Issue
Block a user