mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
x86 asm: logical instructions move from x86-assembly-cheat
This commit is contained in:
@@ -12366,6 +12366,15 @@ Bibliography:
|
||||
** link:userland/arch/x86_64/idiv.S[IDIV]
|
||||
* link:userland/arch/x86_64/cmp.S[CMP]
|
||||
|
||||
=== x86 logical instructions
|
||||
|
||||
<<intel-manual-1>> 5.1.4 "Logical Instructions"
|
||||
|
||||
* link:userland/arch/x86_64/and.S[AND]
|
||||
* link:userland/arch/x86_64/not.S[NOT]
|
||||
* link:userland/arch/x86_64/or.S[OR]
|
||||
* link:userland/arch/x86_64/xor.S[XOR]
|
||||
|
||||
=== x86 SIMD
|
||||
|
||||
History:
|
||||
|
||||
9
userland/arch/x86_64/and.S
Normal file
9
userland/arch/x86_64/and.S
Normal file
@@ -0,0 +1,9 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-logical-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov $0x00FF, %rax
|
||||
and $0x0F0F, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $0x000F)
|
||||
LKMC_EPILOGUE
|
||||
9
userland/arch/x86_64/not.S
Normal file
9
userland/arch/x86_64/not.S
Normal file
@@ -0,0 +1,9 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-logical-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov $0x0FF0, %rax
|
||||
not %ax
|
||||
LKMC_ASSERT_EQ(%rax, $0xF00F)
|
||||
LKMC_EPILOGUE
|
||||
9
userland/arch/x86_64/or.S
Normal file
9
userland/arch/x86_64/or.S
Normal file
@@ -0,0 +1,9 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-logical-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov $0x00FF, %rax
|
||||
or $0x0F0F, %ax
|
||||
LKMC_ASSERT_EQ(%rax, $0x0FFF)
|
||||
LKMC_EPILOGUE
|
||||
22
userland/arch/x86_64/xor.S
Normal file
22
userland/arch/x86_64/xor.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-logical-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov $0x00FF, %rax
|
||||
xor $0x0F0F, %ax
|
||||
LKMC_ASSERT_EQ(%rax, $0x0FF0)
|
||||
|
||||
/* xor to set to zero idiom
|
||||
*
|
||||
* http://stackoverflow.com/questions/1135679/does-using-xor-reg-reg-give-advantage-over-mov-reg-0
|
||||
*
|
||||
* xor can be used to set a register to 0 instad of mov:
|
||||
*
|
||||
* Compileres often do this to generate shorter instrucitons,
|
||||
* but there are also cases where `mov` is better.
|
||||
*/
|
||||
mov $0x1020, %rax
|
||||
xor %ax, %ax
|
||||
mov $0x0000, %ax
|
||||
LKMC_EPILOGUE
|
||||
Reference in New Issue
Block a user