Change the value of an array in x86 assembly (built-in in C ++)

This is the first time I am talking to an assembly and cannot change the index values ​​of an array. Here is the method I'm working on

int ascending_sort( char arrayOfLetters[], int arraySize )
 {
   char temp;

__asm
    {

   //???
      }
}

And here is what I tried

mov temp, 'X'
mov al, temp
mov arrayOfLetters[0], al

And that gave me error C2415: wrong type of operand

so i tried

mov temp, 'X'
mov al, temp
mov BYTE PTR arrayOfLetters[0], al

This is done, but it did not change the array ...

+3
source share
3 answers

The value is arrayOfLettersequivalent to a pointer. So your build code could be as follows:

mov temp, 'X' 
mov al, temp 
mov edx, arrayOfLetters
mov [edx], al 

The code above edxloads the address arrayOfLetters. Then the last command stores the byte alin the address it points to edx.

+2
source

varaible, , . , , . :

__asm
{
mov eax, arrayOfLetter
mov [eax], 0x58
}

, :

__asm
{
mov eax, arrayOfLetter
mov [eax+index], 0x58
}
+3

This SO question relates to reading array elements instead of modifying them, but I suspect that the main explanation will be much the same (namely, that arrayOfLetters should be considered as a pointer):

0
source

Source: https://habr.com/ru/post/1741367/