News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Basic array help

Started by Xenomorph05, April 01, 2010, 01:43:15 PM

Previous topic - Next topic

Xenomorph05

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!

dedndave

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

Xenomorph05

#2
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?