The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hilnius on May 15, 2012, 12:23:46 PM

Title: problem allocating an array
Post by: hilnius on May 15, 2012, 12:23:46 PM
Hi all,
I'm new to the asm language, and i've some problems allocating an empty array :
i examinated the code of the console "adress.asm" tutorial, which allocates an array and displays it.
Now i try to let the user fill an array, but i don't have the adress of the array i allocated (in the .data? section)
here's the code :

.data?
    myArray dd 20 dup(?)

.code
start:
    push esi
    mov esi, myArray
    print str$(esi)
    pop esi
    exit

and it prints out 0
so i don't understand why it prints 0 whereas when the array is allocated in the .data section like :

.data                         
      itm0  dd 0
      itm1  dd 1
      itm2  dd 2
      itm3  dd 3
      itm4  dd 4
      itm5  dd 5
      itm6  dd 6
      itm7  dd 7
      itm8  dd 8
      itm9  dd 9

      array1 dd itm0,itm1,itm2,itm3,itm4
             dd itm5,itm6,itm7,itm8,itm9

the same output there is 4202509 (or a number like that), which is the adress of the array !

thanks
hilnius
Title: Re: problem allocating an array
Post by: BogdanOntanu on May 15, 2012, 12:38:53 PM
Nope, it is the address of item0 ...

Try mov esi, offset myArray
Title: Re: problem allocating an array
Post by: hilnius on May 15, 2012, 12:47:48 PM
well, it works...
i'll watch the doc of offset
thanks a lot
(and sorry to have chosen the wrong forum to post)