Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 将yasm代码(英特尔风格)移植到gas(AT&T风格)_Assembly_X86 64_Gnu Assembler_Yasm - Fatal编程技术网

Assembly 将yasm代码(英特尔风格)移植到gas(AT&T风格)

Assembly 将yasm代码(英特尔风格)移植到gas(AT&T风格),assembly,x86-64,gnu-assembler,yasm,Assembly,X86 64,Gnu Assembler,Yasm,我试图学习汇编x86 32位中的字符串,但最近从yasm切换到gas,并尝试翻译源文件,顺便说一句,我使用了xorpd代码,您可以看到 我看到了一些AT&T语法,我试着翻译,但是翻译失败了,我不知道问题出在哪里,如果有人能告诉我代码中的问题出在哪里 字符串 fn.s 编译器失败 $ gcc-9 -m32 strings.s -o strings strings.s: Assembler messages: strings.s:1: Error: missing string 问题是第一行。GA

我试图学习汇编x86 32位中的字符串,但最近从yasm切换到gas,并尝试翻译源文件,顺便说一句,我使用了xorpd代码,您可以看到 我看到了一些AT&T语法,我试着翻译,但是翻译失败了,我不知道问题出在哪里,如果有人能告诉我代码中的问题出在哪里

字符串

fn.s

编译器失败

$ gcc-9 -m32 strings.s -o strings
strings.s: Assembler messages:
strings.s:1: Error: missing string

问题是第一行。GAS要求所有字符串(包括文件名)都使用双引号

.包括fn.s而非“fn.s”单引号

GAS也不接受像“abc”这样的多字符文字作为数字文字,就像YASM和NASM那样。事实上,它完全破坏了解析,并打印出无意义的错误消息

.string 'abcd'

.include 'fn.s'


mov $'a', %eax
mov $'ab', %ax
.long 'abc'
请注意,第5行为空,文件以换行结束,但它位于包含单引号的行的末尾

单字符文字用作整数,如add$'0'、%eax或.long'b

或在.intel_语法noprefix中,作为add eax,“0”

您可能应该使用.intel\u语法noprefix


大多数情况下,只需将OFFSET放入mov-reg,symbol使其成为mov-reg,OFFSET-symbol获得mov立即编码,并移植指令。与手动将所有内容更改为AT&T语法相比,更容易出错。

能否直接将string.s的相关部分添加到问题中,而不是添加链接。有关堆栈溢出的问题必须是自包含的。请出示一份表格,并把它放在你的问题中。不要在问题中添加代码链接。当您链接到的所有站点都停止运行时,您的问题必须仍然有意义。movl ARRLEN,%ecx需要为$ARRLEN,因为您需要的是一个立即常数,而不是负载。不能仍然工作相同的错误PeterNote gas可以执行英特尔语法。也许和yasm不一样,但解决这个问题可能比改用at&t更容易。
$ gcc-9 -m32 strings.s -o strings
strings.s: Assembler messages:
strings.s:1: Error: missing string
.string 'abcd'

.include 'fn.s'


mov $'a', %eax
mov $'ab', %ax
.long 'abc'
strings.s: Assembler messages:
strings.s: Warning: end of file not at end of a line; newline inserted
strings.s:1: Error: junk at end of line, first unrecognized character is `9'
strings.s:2: Error: missing string
strings.s:5: Error: backward ref to unknown label "97:"
strings.s:5: Error: junk `44%ax' after expression
strings.s:5: Error: number of operands mismatch for `mov'
strings.s:6: Error: backward ref to unknown label "97:"
strings.s:6: Error: junk at end of line, first unrecognized character is `c'