cmpl和cmp之间的区别 [英] The difference between cmpl and cmp

查看:3194
本文介绍了cmpl和cmp之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解程序集以解决难题.但是我遇到了以下指示:

I am trying to understand assembly to be able to solve a puzzle. However I encountered the following instructions:

0x0000000000401136 <+44>:    cmpl   $0x7,0x14(%rsp)
0x000000000040113b <+49>:    ja     0x401230 <phase_3+294>

我认为它的作用是: 0x14(%rsp)的值为-7380.根据我的理解,cmpl比较无符号.同时执行跳转. (unsigned)-7380> 7 (未签名)7380> 7->跳转

What I think its doing is: The value of 0x14(%rsp) is -7380. According to my understanding cmpl compares unsigned. Also the jump is performed. So can it be that (unsigned)-7380 > 7 (unsigned)7380 > 7--> jump

我实际上不希望它跳下去.但这是正确的解释吗?我是在吵架吗?

I actually don't want it to jump. But is this the correct explanation or not? Am I flipping arguments?

如果您对如何操作此跳跃有任何建议!

Also if you have any advice about how to manipulate this jump!

推荐答案

根据我的理解,cmpl比较未签名.

在某种程度上,两者都可以.

It does both, in a way.

有符号与无符号的区别在于跳转指令的用法.

The difference in signed vs. unsigned is here the usage of the jump instructions.

对于>,无符号的为ja,有符号的为jg(如果大于则跳转,如果大于则跳转).

For >, there is ja for unsigned and jg for signed (jump if above and jump if greater).

对于<,无符号的为jb,有符号的为jl(如果低于则跳转,如果不足则跳转).

For <, there is jb for unsigned and jl for signed (jump if below and jump if less).

确切地说,这是几个跳转命令的含义:

To be exact, here is the meaning of several jump commands:

对于未签名的比较:

For unsigned comparisons:

JB/JNAE (CF = 1)           : Jump if below/not above or equal
JAE/JNB (CF = 0)           : Jump if above or equal/not below
JBE/JNA (CF = 1 or ZF = 1) : Jump if below or equal/not above
JA/JNBE (CF = 0 and ZF = 0): Jump if above/not below or equal

对于已签名的比较:

JL/JNGE (SF <> OF)          : Jump if less/not greater or equal
JGE/JNL (SF = OF)           : Jump if greater or equal/not less
JLE/JNG (ZF = 1 or SF <> OF): Jump if less or equal/not greater
JG/JNLE (ZF = 0 and SF = OF): Jump if greater/not less or equal

这篇关于cmpl和cmp之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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