The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: gwapo on August 11, 2008, 12:40:21 AM

Title: Quick question with DUP(xx, xx, xx)
Post by: gwapo on August 11, 2008, 12:40:21 AM
I used to declare an array like this:

  TheData db 128 dup(?) ; array of 128 bytes

But while reading some old drawing software, I've seen a declaration like this:

  CMYKProfile db 1024 dup(0ffh, 0feh, 078h)

I don't know what that declaration means, and MSDN doesn't seem to have
answer either. Probably some of the gurus here can shead a light about
what that data declaration means?

  1. Is it a 3x1024 array initialized with sequence 0ffh, 0feh, 078h?
  2. Or just 1024 bytes array filled with 0ffh, 0feh, 078h?

Thanks,

-chris
Title: Re: Quick question with DUP(xx, xx, xx)
Post by: hutch-- on August 11, 2008, 12:46:45 AM
Chris,

MASM never builds complex arrays, you get the byte count with the specified content. Its much the same technique as an array of structures.
Title: Re: Quick question with DUP(xx, xx, xx)
Post by: MichaelW on August 11, 2008, 03:19:45 AM
To expand the answer to a picture, if I place the statement:

CMYKProfile db 1024 dup(0ffh, 0feh, 078h)

In the initialized data section, then assemble, link, and dump the contents of the EXE, this is what the data looks like:

00000800  FF FE 78 FF FE 78 FF FE - 78 FF FE 78 FF FE 78 FF  ..x..x..x..x..x.
00000810  FE 78 FF FE 78 FF FE 78 - FF FE 78 FF FE 78 FF FE  .x..x..x..x..x..
. . .
000013E0  FE 78 FF FE 78 FF FE 78 - FF FE 78 FF FE 78 FF FE  .x..x..x..x..x..
000013F0  78 FF FE 78 FF FE 78 FF - FE 78 FF FE 78 FF FE 78  x..x..x..x..x..x

Title: Re: Quick question with DUP(xx, xx, xx)
Post by: dsouza123 on August 11, 2008, 03:22:17 AM

aa db 9 dup ('A','B','C')

ABCABCABC

Title: Re: Quick question with DUP(xx, xx, xx)
Post by: gwapo on August 11, 2008, 06:54:58 AM
Thanks for the very helpful responses.

:bg

Cheers,

-chris
Title: Re: Quick question with DUP(xx, xx, xx)
Post by: jj2007 on August 11, 2008, 08:22:29 AM
Quote from: dsouza123 on August 11, 2008, 03:22:17 AM
aa db 9 dup ('A','B','C')
ABCABCABC

ABCABCABC is nine chars long, but this is not the output you will get: db 9 means "get the full sequence 9 times", i.e. ABCABCABCABCABCABCABCABCABC
Title: Re: Quick question with DUP(xx, xx, xx)
Post by: gwapo on August 12, 2008, 05:00:43 AM
Quote from: jj2007 on August 11, 2008, 08:22:29 AM

... aa db 9 dup ('A', 'B', 'C')

db 9 means "get the full sequence 9 times", i.e. ABCABCABCABCABCABCABCABCABC


Thanks, this made it clear.

From the original example:

   CMYKProfile db 1024 dup (0ffh, 0feh, 078h)

I did got a 1024x3 block of initialized memory :U

-chris