I am trying to increase a numerical value using the built-in assembly in C ++. The reason I do this is to practice my "built-in assembly" skills.
Good thing I have done so far:
void main() { int x; cout << "Please enter a number "; cin >> x; cout << "The number you entered is: " << x << "\n"; foo(&x); cout << "The new number is: " << x; cin >> x; } void foo(int *x) { __asm { inc [x] }; }
And the meaning has never changed.
x. x - , x ( foo). , , main x. , inc [x] . , [x], inc [[x]]. , , : , . :
x
foo
main
inc [x]
[x]
inc [[x]]
push eax mov eax, [x] inc dword ptr [eax] pop eax
, , Visual ++ int-pointer:
void foo(*x) { (*x)++; }
(*x)++; mov eax,dword ptr [x] mov ecx,dword ptr [eax] add ecx,1 mov edx,dword ptr [x] mov dword ptr [edx],ecx
, Aneri.
x86 , , . :
__asm { mov eax, x mov ebx, [eax] inc ebx mov [eax], ebx };