簡體   English   中英

組裝數組聲明時“無此類指令錯誤”:

[英]“no such instruction error” when assembling an array declaration:

我有以下一段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

但是當我編譯它時,我不斷收到以下錯誤:

$ gcc my_asm.s 
my_asm.s: Assembler messages:
my_asm.s:7: Error: no such instruction: `array_word DW 1,2,3'

這是我使用的gcc:

$ 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.

您的語法是錯誤的gas (由gcc調用的匯編文件)使用的語法與NASM等其他匯編器的語法不同。

采用

array_word: .word 1, 2, 3

另請參閱https://sourceware.org/binutils/docs/as/Word.html#Word

請注意, .word的結果是特定於目標CPU的-另一種選擇是.hword

7.60 .hword 表達式

這期望零個或多個表達式,並為每個表達式發出16位數字

該偽指令是.short的同義詞; 根據目標體系結構,它也可能是.word的同義詞。

順便說一句:您說# define an array of 3 dwords在您的注釋中# define an array of 3 dwords -但請注意DWDefine Word一個16位字的定義字。 NASM ,您將DD用於32位字。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM