顯示具有 gcc assembly 標籤的文章。 顯示所有文章
顯示具有 gcc assembly 標籤的文章。 顯示所有文章

2009年12月29日 星期二

Some GCC macro examples for inline assembly (1)

Here is a very simple one:
#define FUNC(func, ret) \
     asm ("asm_func" \
     : "=a" (ret) \
     : "a" (func) \
);
a means ax/eax/rax/r0, and we can exchange a to b,c,d or r to indicate ebx,ecx,edx or any general purpose registers. And we can use %0 to indicate "=a" (ret), it means to output ax/eax/rax to memory space ret pointed, and %1 to indicate "a" (func), move the value of func to ax/eax/rax.

Ref: GCC inline assembly HOWTO.
The external link is very useful, but not latest reference. I will continue showing some example not related with my works.

2009年12月24日 星期四

GCC inline assembly

Assembly is not very friendly. But I should verify many instructions set, such as MMX, SSE, SSE2 and so on. I hate assembly, buuuuuu~

It's a good news that gcc's inline assembly is very helpful. HERE is a very useful HOWTO.