A very readable introduction to inline asm with gcc: https://locklessinc.com/articles/gcc_asm/