summaryrefslogtreecommitdiffstats
path: root/md/writeup/gcc_inline_assembly.md
diff options
context:
space:
mode:
Diffstat (limited to 'md/writeup/gcc_inline_assembly.md')
-rw-r--r--md/writeup/gcc_inline_assembly.md16
1 files changed, 8 insertions, 8 deletions
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");