首页 > 代码库 > 汇编三个数选最大

汇编三个数选最大

  1 #include <stdio.h>  2   3 int main()  4 {  5         int i = 9;  6         int j = 67;  7         int k = 34;  8         int max = 0;  9 #if 0 10  11         if(i >= j) 12                 max = i; 13         else  14                 max = j; 15         if(k > max)      16                 max = k; 17 exit: 18 #else 19         __asm__ __volatile__( 20                 "mov r0, %1\n" 21                 "mov r1, %2\n" 22                 "mov r2, %3\n" 23                 "cmp r0, r1\n" 24                 "movge %0, r0\n" 25                 "movle %0, r1\n" 26                 "cmp %0, r2\n" 27                 "movle %0, r2\n" 28                 :"=r" (max) 29                 :"r" (i), "r" (j), "r" (k) 30                 :"r0", "r1", "r2",  "memory" 31         ); 32 #endif 33  34         printf("%d\n", max); 35 }

 

汇编三个数选最大