x86 asm: move gnu gas char literals from x86-assembly-cheat

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-06-23 00:00:03 +00:00
parent d62070d934
commit 23d8f703fd
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#gnu-gas-assembler-char-literals */
#include <lkmc.h>
LKMC_PROLOGUE
mov $0, %r12
/* Memory. */
mov mychar, %r12b
LKMC_ASSERT_EQ(%r12, $0x61)
/* Immediate. Without the `$`, does a memory access, and segfaults! */
mov $'b, %r12b
LKMC_ASSERT_EQ(%r12, $0x62)
/* Space character works. */
mov $' , %r12b
LKMC_ASSERT_EQ(%r12, $0x20)
/* Backslash escapes work. */
mov $'\n , %r12b
LKMC_ASSERT_EQ(%r12, $0x0A)
LKMC_EPILOGUE
mychar:
.byte 'a