码迷,mamicode.com
首页 > 其他好文 > 详细

汇编三个数选最大

时间:2014-10-28 21:18:57      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   sp   div   log   bs   as   

  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 }

 

汇编三个数选最大

标签:style   blog   io   color   sp   div   log   bs   as   

原文地址:http://www.cnblogs.com/luoxiang/p/4057681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!