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

前端 未结 2 1660
盖世英雄少女心
盖世英雄少女心 2020-12-16 16:23

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

STACK16_SIZE    =       100h
stack16         db      STACK16_SIZE dup (?)

I thi

相关标签:
2条回答
  • 2020-12-16 16:36

    ? means no particular value, uninitialized. DUP means duplicate.

    So you get 100h bytes that are uninitialized.

    0 讨论(0)
  • 2020-12-16 16:55

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

    0 讨论(0)
提交回复
热议问题