The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Xenomorph05 on April 01, 2010, 01:43:15 PM

Title: Basic array help
Post by: Xenomorph05 on April 01, 2010, 01:43:15 PM
Hello!
I'm new to learning MASM32 and I am trying to use an array. I have searched the forum and managed to find how to make and get values from each spot of an array but I haven't seen how to replace/insert a number into the array.

making array:
.data
array1 dd 12 dup(0)                  ;Array of 12 0's


Reading from it:
mov eax, [array1+0]         ;first place in array

But How do you go and put a different number in any of the 12 places of the array? Any other tips on Arrays would be cool too. Thanks!
Title: Re: Basic array help
Post by: dedndave on April 01, 2010, 02:03:53 PM
use a register index
you can change the value in the register to address different elements in the array
        mov     edi,4*IndexNumber  ;IndexNumber = 0,1,2,etc
        mov     eax,array1[edi]    ;load the Nth element into EAX
        mov     array1[edi],eax    ;store the Nth element from EAX
Title: Re: Basic array help
Post by: Xenomorph05 on April 01, 2010, 04:13:30 PM
thanks that works like a charm.  :bg

EDIT:
What would I need to do to add a char to the array so it could be a mix of # and letters?