diff options
Diffstat (limited to 'md')
-rw-r--r-- | md/writeup/gcc_inline_assembly.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/md/writeup/gcc_inline_assembly.md b/md/writeup/gcc_inline_assembly.md index 6e9985a..eda7764 100644 --- a/md/writeup/gcc_inline_assembly.md +++ b/md/writeup/gcc_inline_assembly.md @@ -155,6 +155,25 @@ long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigne ``` Put result of execution to __ret__, all paramters in memory +### Intel random number with RDRAND + +``` +uint64_t get_hw_rand() +{ + uint64_t ret; + int i=0; + const int timeout = 10; + while (i<timeout) + { + asm("rdrand %0\n\t" + :"=a"(ret)::); + if (ret) break; + i++; + } + return ret; +} +``` + <!-- ### Intel i386 BSD @@ -166,6 +185,14 @@ Put result of execution to __ret__, all paramters in memory ## Switching on of intel/att syntax +Inline assembler for GCC by default uses AT&T syntax. There is possible to turn on/off intel syntax. + +``` +asm(".intel_syntax noprefix"); +asm("mov eax, 1"); +asm(".att_syntax prefix"); +``` + ## Asm goto |