Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

assembly - What does `dup (?)` mean in TASM?

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

STACK16_SIZE    =       100h
stack16         db      STACK16_SIZE dup (?)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...