From 380f0fe40b1ab20790e75dac779e73667cc5ac72 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sat, 4 Feb 2023 14:10:26 +0000 Subject: Update all content to new pygmentize --- md/writeup/gcc_inline_assembly.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'md/writeup/gcc_inline_assembly.md') diff --git a/md/writeup/gcc_inline_assembly.md b/md/writeup/gcc_inline_assembly.md index 06db7dd..808268c 100644 --- a/md/writeup/gcc_inline_assembly.md +++ b/md/writeup/gcc_inline_assembly.md @@ -8,7 +8,7 @@ it lets do it here for wisdom of internet. ## Inline assembly syntax -``` +```c asm [volatile] ( AssemblerTemplate : OutputOperands @@ -101,7 +101,7 @@ Table of AMD64 register names ### AMD64 Add two numbers -``` +```c int32_t a=1,b=2,c=-1; asm( "movl %1, %0\n\t" @@ -114,12 +114,12 @@ __a__,__b__ - use regisers and save result __c__ to register, make to use for __c__ same register by mentioning "0" in clobber register __Output__ -``` +```text movl %edx, %edx addl %ecx, %edx ``` -``` +```c int32_t a=1,b=2,c=-1; asm( "movl %1, %0\n\t" @@ -130,14 +130,14 @@ asm( ``` __Output__ -``` +```text movl -4(%rbp), %edx addl -8(%rbp), %edx ``` ### AMD64 Call linux syscall mmap with inline asm -``` +```c long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off) { long ret; @@ -159,7 +159,7 @@ Put result of execution to __ret__, all paramters in memory ### Intel random number with RDRAND -``` +```c uint64_t get_hw_rand() { uint64_t ret; @@ -189,7 +189,7 @@ uint64_t get_hw_rand() Inline assembler for GCC by default uses AT&T syntax. There is possible to turn on/off intel syntax. -``` +```c asm(".intel_syntax noprefix"); asm("mov eax, 1"); asm(".att_syntax prefix"); -- cgit v1.2.3