One*_*ree 3 arrays x86 assembly redhat
我有以下一段 x86 汇编代码:
1
2 .text
3
4 .data
5
6 # define an array of 3 dwords
7 array_word DW 1, 2, 3
8
9
10 .globl main
11
12main:
13 # nothing interesting ..
14
Run Code Online (Sandbox Code Playgroud)
但是当我编译这个时,我不断收到以下错误:
$ gcc my_asm.s
my_asm.s: Assembler messages:
my_asm.s:7: Error: no such instruction: `array_word DW 1,2,3'
Run Code Online (Sandbox Code Playgroud)
这是我使用的海湾合作委员会:
$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)
您的语法错误 - (由汇编文件gas调用)使用与其他汇编器(如.gccNASM
使用
array_word: .word 1, 2, 3
Run Code Online (Sandbox Code Playgroud)
另请参阅https://sourceware.org/binutils/docs/as/Word.html#Word
请注意,结果.word是特定于目标 CPU 的 - 另一种选择是.hword:
7.60 .hword表达式
这需要零个或多个表达式,并为每个表达式发出一个16 位数字。
该指令是 ; 的同义词
.short;根据目标架构,它也可能是 的同义词.word。
顺便说一句:你# define an array of 3 dwords在评论中说 - 但请注意DWisDefine Word定义了一个 16 位字。在 中NASM,您将用于DD32 位字。