I'm working in Visual Studio 2012 Professional, i have this code:
char* array = (char*) malloc(100);
array[0] = 'H'; array[1] = 'e'; array[2] = 'l'; array[3] = 'l';array[4] = 'o';
__asm {
// Missing code here
}
How can i access, for example, the chars in the array using inline assembly? I tried this but it works only for the first character in the array:
mov eax, array[0]
mov al, [eax] // Now al contains the 'H'
Buf if i change the code to "mov eax, array[1]" it doesn't work anymore (access violation). How can i loop trough the array?
EDIT, SOLVED (i can't answer my own question for 8 hours) : I found what was wrong with the code:
mov eax, array[0]
mov al, [eax]
actually works, but the eax value gets changed because i modify the al register that's part of the eax register, so when i put it in a loop the eax value is no longer valid. Changing eax to ebx, for example, makes it work without any problem.