mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 20:14:27 +01:00
userland: add assembly support
Move arm assembly cheat here, and start some work on x86 cheat as well.
This commit is contained in:
20
userland/arch/x86_64/c/scratch_hardcode.c
Normal file
20
userland/arch/x86_64/c/scratch_hardcode.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* This is a worse version of scratch.c with hardcoded scratch. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int main(void) {
|
||||
uint64_t in1 = 0xFFFFFFFF;
|
||||
uint64_t in2 = 1;
|
||||
uint64_t out;
|
||||
__asm__ (
|
||||
"mov %[in2], %%rax;" /* scratch = in2 */
|
||||
"add %[in1], %%rax;" /* scratch += in1 */
|
||||
"mov %%rax, %[out];" /* out = scratch */
|
||||
: [out] "=r" (out)
|
||||
: [in1] "r" (in1),
|
||||
[in2] "r" (in2)
|
||||
: "rax"
|
||||
);
|
||||
assert(out == 0x100000000);
|
||||
}
|
||||
Reference in New Issue
Block a user