回覆列表
  • 1 # 使用者774056550451

    演算法實現: unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) { unsigned int sum; __asm__ __volatile__( "movl (%1), %0 ;\n" "subl , %2 ;\n" "jbe 2f ;\n" "addl 4(%1), %0 ;\n" "adcl 8(%1), %0 ;\n" "adcl 12(%1), %0 ;\n" "1: adcl 16(%1), %0 ;\n" "lea 4(%1), %1 ;\n" "decl %2 ;\n" "jne 1b ;\n" "adcl , %0 ;\n" "movl %0, %2 ;\n" "shrl , %0 ;\n" "addw %w2, %w0 ;\n" "adcl , %0 ;\n" "notl %0 ;\n" "2: ;\n" : "=r" (sum), "=r" (iph), "=r" (ihl) : "1" (iph), "2" (ihl) : "memory"); return(sum); } 擴充套件資料二進位制反碼求和工作原理 :0和0相加是0,但要產生一個進位1,0和1相加是1,1和1相加是0.若最高位相加後產生進位,則最後得到的結果要加1。(0)反 + (0)反 = 1 + 1 = 10(1)反 +(0)反=0+ 1 =1(1)反 + (1)反 = 0 + 0 = 0

  • 中秋節和大豐收的關聯?
  • 俠盜飛車在遊戲裡怎樣輸入命令?