I am messing around with assembly for the first time, and can't seem to change the index values of an array. Here's the method I am working on
int ascending_sort( char arrayOfLetters[], int arraySize )
{
char temp;
__asm
{
//???
}
}
And these are what I tried
mov temp, 'X'
mov al, temp
mov arrayOfLetters[0], al
And this gave me an error C2415: improper operand type
so I tried
mov temp, 'X'
mov al, temp
mov BYTE PTR arrayOfLetters[0], al
This complied, but it didn't change the array...
When you have a parameter or varaible that is an array, it is actually a pointer to the first element of the array. You have to deference that pointer in order to change the data that it points to. For example:
__asm
{
mov eax, arrayOfLetter
mov [eax], 0x58
}
Or, more generically:
__asm
{
mov eax, arrayOfLetter
mov [eax+index], 0x58
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With