加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[转]cmov条件传送指令

(2013-11-02 11:39:55)
分类: 汇编
(原创博主如果有任何异议,请告知。)
操作系统:ubuntu11.10

    条件传送指令集包含了许多指令,所有指令都具有如下格式:
        cmovx source, destination
        其中 x 是一个或者连个字母的代码,表示将触发传送操作的条件。
        条件取决于 EFLAGS 寄存器的当前值。

        条件传送指令使用的特定位如下:
http://blog.chinaunix.net/attachment/201304/1/28458801_1364786275ISrv.png
http://blog.chinaunix.net/attachment/201304/1/28458801_1364786337WR8s.png
http://blog.chinaunix.net/attachment/201304/1/28458801_13647864093s8u.png
http://blog.chinaunix.net/attachment/201304/1/28458801_1364786500oooV.png

实例:

点击(此处)折叠或打开

  1. .section .data
  2.     output:
  3.         .asciz "The largest value is %d\n"

  4.     values:
  5.         .int    105,234,61,315,134,221,53,145,117,5

  6. .section .text
  7. .global    _start
  8.     _start:
  9.         nop
  10.         movl    values,    %ebx
  11.         movl    $1,        %edi

  12.     loop:
  13.         movl    values( ,%edi,4),    %eax
  14.         cmp        %ebx,    %eax
  15.         cmova    %eax,    %ebx    
  16.         inc        %edi
  17.         cmp        $10,    %edi
  18.         jne        loop

  19.         pushl    %ebx
  20.         pushl    $output
  21.         call    printf
  22.         addl    $8,        %esp
  23.         pushl    $0
  24.         call    exit

结果:
http://blog.chinaunix.net/attachment/201304/1/28458801_1364787423rkkn.png

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有