File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -12427,6 +12427,9 @@ Do a BT and then swap the value of the tested bit.
12427
12427
* link:userland/arch/x86_64/setcc.S[SETcc]
12428
12428
+
12429
12429
Set a a byte of a register to 0 or 1 depending on the cc condition.
12430
+ * link:userland/arch/x86_64/popcnt.S[POPCNT]
12431
+ +
12432
+ Count the number of 1 bits.
12430
12433
* link:userland/arch/x86_64/test.S[TEST]
12431
12434
+
12432
12435
Like <<x86-binary-arithmetic-instructions,CMP>> but does AND instead of SUB:
Original file line number Diff line number Diff line change
1
+ /* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-bit-and-byte-instructions */
2
+
3
+ #include <lkmc.h>
4
+
5
+ LKMC_PROLOGUE
6
+ mov $0 , %rbx
7
+ popcnt %rbx , %rax
8
+ LKMC_ASSERT_EQ(%rax , $0 )
9
+
10
+ mov $1 , %rbx
11
+ popcnt %rbx , %rax
12
+ LKMC_ASSERT_EQ(%rax , $1 )
13
+
14
+ mov $2 , %rbx
15
+ popcnt %rbx , %rax
16
+ LKMC_ASSERT_EQ(%rax , $1 )
17
+
18
+ mov $3 , %rbx
19
+ popcnt %rbx , %rax
20
+ LKMC_ASSERT_EQ(%rax , $2 )
21
+
22
+ mov $4 , %rbx
23
+ popcnt %rbx , %rax
24
+ LKMC_ASSERT_EQ(%rax , $1 )
25
+
26
+ mov $5 , %rbx
27
+ popcnt %rbx , %rax
28
+ LKMC_ASSERT_EQ(%rax , $2 )
29
+
30
+ mov $6 , %rbx
31
+ popcnt %rbx , %rax
32
+ LKMC_ASSERT_EQ(%rax , $2 )
33
+
34
+ mov $7 , %rbx
35
+ popcnt %rbx , %rax
36
+ LKMC_ASSERT_EQ(%rax , $3 )
37
+ LKMC_EPILOGUE
You can’t perform that action at this time.
0 commit comments