How can I properly store n in functions like the following one ? Because of value in n changes for some reason after I use it once.
function Test(n: Integer): Byte;
asm
mov eax, n
add eax, eax
add eax, n
mov ecx, eax
mov ebx, eax
mov ecx, n
end;
The first argument to the function,
n, is stored ineax, so your lineis highly strange (move
nton). Also, if you changeeax, you changen.You could save the argument for future use (since you likely need to alter
eax):Also, IIRC, you must not change the value of
ebxwhen writing inline ASM. Hence, you need to surround your code bypush ebxandpop ebx.