比较跳转指令为一条指令 [英] Compare and jump instruction as one instruction

查看:206
本文介绍了比较跳转指令为一条指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,我可以比较和跳跃在一个指令:

Is there a way I can compare and jump in one instruction:

C code:结果
 1. 而(I< 10)结果
 2. {我++}

C code:
1. while(i<10)
2. {i++}

大会code:(EAX = 0)(ECX = 10)


  1. 。而

  2. CMP EAX,ECX

  3. JGE .endofwhile

  4. 添加EAX,1

  5. JMP。而

  6. .endofwhile:

  1. .while:
  2. cmp eax, ecx
  3. jge .endofwhile
  4. add eax, 1
  5. jmp .while
  6. .endofwhile:

有没有一种方法,我可以在一个指令做线2和3?

Is there a way i can do line 2 and 3 in one instruction?

推荐答案

是的,你可以测试并作为一个单一的指令处理分支,做的方式,这是写他们两个指令像你这样,要用现代的Intel处理器,并遵循一些简单的规则(分支指令必须包含在code,测试指令结束的相同的16个字节线,两条指令,不要通过其他任何指令分离,... )。

Yes, you can have the test and branch treated as a single instruction, and the way to do this is to write them as two instructions like you did, to use a modern Intel processor and to follow a few simple rules (the branch instruction must be contained in the same 16-bytes line of code that the test instruction ends, the two instructions must not be separated by any other instruction, …).

的机制被称为<一href=\"https://web.archive.org/web/20120922053925/http://www.behardware.com/articles/623-7/intel-core-2-duo-test.html\"相对=nofollow>宏观融合。更详细的信息,包括在宏观融合应用可从瓦格纳雾的手册中的precise条件,第82页。

The mechanism is called macro-fusion. More detailed information including the precise conditions in which macro-fusion apply is available from Agner Fog's manual, page 82.

这篇关于比较跳转指令为一条指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆