将 [symbol + constant] Intel 语法寻址模式转换为 AT&T 语法? [英] Converting [symbol + constant] Intel syntax addressing mode to AT&T syntax?
问题描述
我只是不知道如何在移动值时向目的地添加偏移量,特别是在我拥有的英特尔语法中:
I just cant figure out how to add an offset to my destination when moving a value, specifically in Intel syntax I have:
MOV [gdtr + 2], EAX
对于 AT&T 语法,我尝试将其转换为:
and for AT&T syntax I have tried converting it to:
movl %eax, gdtr(2,1)
在表达式之后编译 junk '(2,1)' 时出错
但仅使用 gdtr(,1)
工作正常.
which gives an error when compiling junk '(2,1)' after expression
but using just gdtr(,1)
works fine.
我不明白为什么我不能使用基本偏移量,而只能使用比例因子.
I don't understand why I cant use base offset, and only the scale factor.
推荐答案
简单写
movl %eax, gdtr+2
基址偏移寻址仅在偏移为寄存器时才有效.使用寻址模式将两个常量相加是没有意义的;其工作方式(无论语法如何)是汇编器/链接器将 symbol+constant
解析为指令编码的位移字段的单个数字.
Base-offset addressing only works when the offset is a register. There's no point in having an addressing mode to add two constants together; the way this works (regardless of syntax) is that the assembler / linker resolve symbol+constant
into a a single number for the displacement field of the instruction encoding.
这篇关于将 [symbol + constant] Intel 语法寻址模式转换为 AT&T 语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!