一、问题:
lazarus编译以下代码时出错:
lazarus编译以下代码时出错:
function GetCPUID(Leaf, Subleaf: Integer): TCPUID; begin asm {$IF Defined(cpu386)} push ebx push edi mov edi, ecx mov ecx, edx cpuid mov [edi+$0], eax mov [edi+$4], ebx mov [edi+$8], ecx mov [edi+$c], edx pop edi pop ebx {$ELSEIF Defined(cpux86_64)} mov r9,rcx mov ecx,r8d mov r8,rbx mov eax,edx cpuid mov [r9+$0], eax mov [r9+$4], ebx mov [r9+$8], ecx mov [r9+$c], edx mov rbx, r8 {$ELSE} {$Message Fatal 'GetCPUID has not been implemented for this architecture.'}; {$IFEND} end;
二、解决方法:
有2个解决方法:
1、使用delphi兼容模式
{$mode delphi}
2、使用Lazarus默认的 {$mode objfpc}模式,请添加:
{$asmmode intel}