`dup (?)` 在 TASM 中是什么意思? [英] What does `dup (?)` mean in TASM?

查看:37
本文介绍了`dup (?)` 在 TASM 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有这段代码,但我不熟悉语法.

I have this code here, but I'm unfamiliar with the syntax.

STACK16_SIZE    =       100h
stack16         db      STACK16_SIZE dup (?)

我认为 dup 意味着我们声明了一个数组类型的变量,因为这是一个堆栈,但我不确定.那么 dup 在 TASM 中究竟是什么意思?

I think dup means we declare a variable of type array, as this is a stack, but I'm not sure. So what does dup mean in TASM, exactly?

推荐答案

STACK16_SIZE dup (?) 表示将括号内的数据复制STACK16_SIZE次.相当于写?, ?, ?, ?, ... (100h 次)

STACK16_SIZE dup (?) means to duplicate the data in parenthesis by STACK16_SIZE times. It is equivalent to writing ?, ?, ?, ?, ... (100h times)

括号中的数据是未初始化的数据".也就是说,内存已分配,但在加载时未设置为任何特定值.

The data in parens is "uninitialized data". That is, memory is allocated, but not set to any particular value on load.

Assembly 不提供数组类型".如果是,则仅用于调试器在检查数据时使用.但是,在此代码片段中,stack16 是一个符号,其地址以字节内存块开头——这是违反直觉的,并且可能是一个微妙错误的来源.对于 CPU 堆栈,它确实应该定义为 16 位字 (dw) 或 32 位字 (dd).

Assembly does not provide an array "type". If it does, it is only for debuggers for use when inspecting the data. However, in this code snippet, stack16 is a symbol with an address beginning a memory block of bytes—which is counter-intuitive and potentially a source of a subtle bug. For a CPU stack, it really ought to be defined as 16 bit words (dw) or 32 bit words (dd).

这篇关于`dup (?)` 在 TASM 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆