问题:Delphi内联汇编取随机数
描述:function GetNumber(Min, Max: Integer): Integer;
begin
asm
push ecx
push edx
rdtsc
mov ecx, $17
mul ecx
add eax, $7
mov ecx, dword ptr ss:[ebp+$C]
sub ecx, dword ptr ss:[ebp+$8]
inc ecx
xor edx, edx
div ecx
add edx, dword ptr ss:[ebp+$8]
mov eax, edx
pop edx
pop ecx
leave
retn $8
end;
Result := 0;
end;
编译报错:[dcc32 Error] utMain.pas(133): E2116 Invalid combination of opcode and operands
在VC2012里编译通过
解决方案1:function GetNumber(Min, Max: Integer): Integer; stdcall;
asm
push ecx
push edx
rdtsc
mov ecx, $17
mul ecx
add eax, $7
mov ecx, dword ptr ss:[ebp+$C]
sub ecx, dword ptr ss:[ebp+$8]
inc ecx
xor edx, edx
div ecx
add edx, dword ptr ss:[ebp+$8]
mov eax, edx
pop edx
pop ecx
leave
ret $8
end;
- 明星图片
- 相关文章
-
联系邮箱:mxgf168#qq.com(#改为@)