16位有符号数除法
div16_t divs16_s16(int16_t val0,int16_t val1) { div16_t result; asm(
"movw r24,%A1" "
" "movw r22,%A2" "
" "mov r2,r25" "
" "sbrc r2,7" "
" "rcall 1f" "
" "mov r3,r23" "
" "sbrc r3,7" "
" "rcall 2f" "
" "call __udivmodhi4" "
" "sbrc r2,7" "
" "rcall 1f" "
" "eor r3,r2" "
" "sbrc r3,7" "
" "rcall 2f" "
" "rjmp 3f" "
"
"1:" "com r25" "
" "neg r24" "
" "sbci r25,0xff" "
" "ret" "
"
"2:" "com r23" "
" "neg r22" "
" "sbci r23,0xff" "
" "ret" "
"
"3:" "movw %A0,r22" "
" "movw %C0,r24" "
"
:"r="(result) :"r"(val0),"r"(val1) :"r2","r3","r22","r23","r24","r25" );
return result; }
总是产生警告,求高手指点。 |