无法理解 Kip Irvine 的汇编语言书中的存储分配
Trouble understanding storage allocation in Kip Irvine's assembly language book
我读了这本书Assembly Language for x86 by Kip Irvine。在第 85 页,他写了以下关于为什么使用符号的内容:
Using the DUP
Operator: Section 3.4.4
showed how to use the DUP
operator to create storage for arrays and strings. The counter used by DUP
should be a symbolic constant, to simplify program maintenance. In the next example, if COUNT has been defined, it can be used in the following data definition:
array dword COUNT DUP(0)
我不明白这个命令在做什么。谁能给我解释一下这是什么意思?
很简单:
.const
COUNT equ 10 ; sets COUNT to a value of 10 or whatever
.data
array dword COUNT DUP(0) ; creates an array of DWORDs/4-byte values
因此 array
由 COUNT(=10) 个 DWORD
个等于“0”的值组成(4*10 = 40 字节)。
DUP
命令只是说前面的数据类型是'duplicated' COUNT次。因此 DWORD
s DUP
的 array
由 COUNT
编辑会导致一个名为 array
的地址,后跟初始化为 [ 的 (sizeof(DWORD)*COUNT) 个字节=12=]s 值为 0.
我读了这本书Assembly Language for x86 by Kip Irvine。在第 85 页,他写了以下关于为什么使用符号的内容:
Using the
DUP
Operator:Section 3.4.4
showed how to use theDUP
operator to create storage for arrays and strings. The counter used byDUP
should be a symbolic constant, to simplify program maintenance. In the next example, if COUNT has been defined, it can be used in the following data definition:array dword COUNT DUP(0)
我不明白这个命令在做什么。谁能给我解释一下这是什么意思?
很简单:
.const
COUNT equ 10 ; sets COUNT to a value of 10 or whatever
.data
array dword COUNT DUP(0) ; creates an array of DWORDs/4-byte values
因此 array
由 COUNT(=10) 个 DWORD
个等于“0”的值组成(4*10 = 40 字节)。
DUP
命令只是说前面的数据类型是'duplicated' COUNT次。因此 DWORD
s DUP
的 array
由 COUNT
编辑会导致一个名为 array
的地址,后跟初始化为 [ 的 (sizeof(DWORD)*COUNT) 个字节=12=]s 值为 0.