在GNU汇编器中处理或记住cmp的向后参数的好方法是什么? [英] What's a good way to deal with or remember backwards arguments to cmp in the GNU assembler?

查看:100
本文介绍了在GNU汇编器中处理或记住cmp的向后参数的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一些使用Intel语法的汇编代码:

Here is some assembly code in Intel syntax:

// Jump to done if rsi >= rax.
cmp rsi, rax
jae done

这对我的大脑是有道理的:如果rsi高于或等于" rax,您会跳, 匹配cmp指令中的参数顺序.将此与 GNU语法:

This makes sense to my brain: you jump if rsi is "above or equal to" rax, matching the order of arguments in the cmp instruction. Compare this to the GNU syntax:

// Jump to done if rsi >= rax.
cmp %rax, %rsi
jae done

这每次都会伤害我的大脑.当我来到这个新鲜的地方并没有帮助 过一会儿不写汇编代码后,我去查找cmp的语义 和jae在Intel手册中,并发现所有内容均以第一"表示 和第二"操作数,与我在屏幕上看到的不匹配 我的面前.

This hurts my brain every time. It doesn't help that when I come to this fresh after awhile not writing assembly code I go to look up the semantics of cmp and jae in the Intel manual and find that it's all stated in terms of "first" and "second" operand, which doesn't match what I'm seeing on the screen in front of me.

结束抱怨.我的问题:

  1. 是否还有其他方法可以将cmpjae表示给GNU汇编程序,所以 cmp的操作数顺序与引用的逻辑比较匹配 通过jae?

  1. Is there some other way to express cmp or jae to the GNU assembler so that the order of operands to cmp matches the logical comparison referred to by jae?

假设(1)的答案是否定的,有人对我有好办法吗 看看这个,这样我就可以记住下一次的工作原理了吗?有什么更好的 比"GNU会倒退"?

Assuming the answer to (1) is no, does anybody have a good way for me to look at this so that I can remember how it works next time? Anything better than "GNU does it backwards"?

请注意,我不是在询问如何在GNU汇编器中使用Intel语法.我知道这是可能的.我正在使用现有的GNU语法代码库,并且正在寻求某种助记符或其他方式来帮助我保持头脑清醒.

Note that I'm not asking how to use Intel syntax with the GNU assembler; I'm aware that's possible. I'm working in an existing GNU syntax codebase, and am asking for some mnemonic or other way to help me keep this straight in my head.

推荐答案

在GAS中,您可以使用.intel_syntax noprefix来获取您更熟悉的语法,但是您不能只是在AT& T语法中交换它们

In GAS you can use .intel_syntax noprefix to get the syntax you're more familiar with, but you can't just swap them around in AT&T syntax.

我要记住,在英特尔语法中,mov x,y的意思是使x等于y",而在AT& T语法中,则是将x复制到y",一旦将该约定向下扩展到其他指令你碰到了.

I'd say keep in mind that in Intel syntax mov x,y means 'make x equal to y' whereas in AT&T syntax it's 'copy x into y', once you have that convention down expand it to other instructions you come across.

这篇关于在GNU汇编器中处理或记住cmp的向后参数的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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