You don't want to use normal functions to do that, because some registers could be overwritten in the very process of calling the function and/or returning from it. Moreover, the usage of the asm construct that way is not very reliable, as gcc uses it only as an "hint". What you want to do is using proper inline assembly, better if wrapped up in a macro like this one (Oh, I so wish the [code] tag worked here...):
#define GET_REG(reg) \
({ \
register unsigned long ret; \
\
__asm__ __volatile__ \
( \
"movl %%" #reg ",%0\n": \
"=r"(ret)::"cc" \
); \
\
ret; \
})
To use it, simply call it like this:
GET_REG(), where can be one of any of the registers, like d0, d1, and so on.