例如demo-int裡的檔案ag101_16mb.h,
有幾個example。您可以用asm這個key word來搜尋。
如
Code:
#define NDS32_SET_BITS(addr, mask) \
__asm__ __volatile__(\
" sethi $r1, hi20(%1) \n\t" \
" ori $r1, $r1, lo12(%1) \n\t" \
" sethi $r2, hi20(%0) \n\t" \
" ori $r2, $r2, lo12(%0) \n\t" \
" lwi $r0, [$r2] \n\t" \
" or $r0, $r0, $r1 \n\t" \
" sw $r0, [$r2] \n\t" \
::"i"(addr),"i"(mask):"$r0", "$r1", "$r2")
Code:
#define NDS32_REG_WAIT4_BIT_ON(addr, mask) \
__asm__ __volatile__(\
" sethi $r1, hi20(%1) \n\t" \
" ori $r1, $r1, lo12(%1) \n\t" \
" sethi $r2, hi20(%0) \n\t" \
" ori $r2, $r2, lo12(%0) \n\t" \
"1: lwi $r0, [$r2] \n\t" \
" and $r0, $r0, $r1 \n\t" \
" beqz $r0, 1b \n\t" \
::"i"(addr),"i"(mask):"$r0", "$r1", "$r2")
Inline assembly的用法,
請參考文件programming guide的19.9. Inline Assembly Programming的說明。