mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
x86 asm: move POPCNT in from x86-assembly-cheat
This commit is contained in:
37
userland/arch/x86_64/popcnt.S
Normal file
37
userland/arch/x86_64/popcnt.S
Normal file
@@ -0,0 +1,37 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-bit-and-byte-instructions */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov $0, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $0)
|
||||
|
||||
mov $1, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $1)
|
||||
|
||||
mov $2, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $1)
|
||||
|
||||
mov $3, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $2)
|
||||
|
||||
mov $4, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $1)
|
||||
|
||||
mov $5, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $2)
|
||||
|
||||
mov $6, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $2)
|
||||
|
||||
mov $7, %rbx
|
||||
popcnt %rbx, %rax
|
||||
LKMC_ASSERT_EQ(%rax, $3)
|
||||
LKMC_EPILOGUE
|
||||
Reference in New Issue
Block a user