x86 asm: move cmp from x86-assembly-cheat

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-06-12 00:00:01 +00:00
parent 0028ff0ebd
commit cefb1a823d
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-assembly
*
* Compare two numbers and set the flags register.
*
* `cmp X, Y` does `X - Y` and ignores the exact result, but sets
* all flags that would be set on the subtraction, just like SUB does.
*/
#include <lkmc.h>
LKMC_PROLOGUE
/* 2 == 2 */
mov $2, %rax
cmp $2, %rax
LKMC_ASSERT(je)
/* 2 > 1 */
mov $2, %rax
cmp $1, %rax
LKMC_ASSERT(ja)
LKMC_EPILOGUE