I'm trying to port some code from old Delphi7 to Lazarus but following code just won't compile. Lazarus always complains about unknown identifiers.
function GetCPUID(Leaf, Subleaf: Integer): TCPUID;
begin
asm
{$IF Defined(CPUX86)}
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(CPUX64)}
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;
ERROR MESSAGES
Compile Project, Target: C:\Users\Dave\AppData\Local\Temp\project1.exe: Exit code 1, Errors: 40, Warnings: 4
unit1.pas(65,9) Error: Unknown identifier "R9"
unit1.pas(65,12) Error: Unknown identifier "RCX"
unit1.pas(66,9) Error: Unknown identifier "ECX"
unit1.pas(66,13) Error: Unknown identifier "R8D"
unit1.pas(67,9) Error: Unknown identifier "R8"
unit1.pas(67,12) Error: Unknown identifier "RBX"
unit1.pas(68,9) Error: Unknown identifier "EAX"
unit1.pas(68,13) Error: Unknown identifier "EDX"
unit1.pas(70,9) Error: Assembler syntax error in operand
unit1.pas(70,10) Error: Unknown identifier "R9"
unit1.pas(70,14) Error: Dollar token is used without an identifier
unit1.pas(70,15) Error: Invalid constant expression
unit1.pas(70,16) Error: Invalid reference syntax
unit1.pas(70,18) Error: Unknown identifier "EAX"
unit1.pas(70,18) Error: No size specified and unable to determine the size of the operands
unit1.pas(70,18) Warning: Size suffix and destination or source size do not match
unit1.pas(71,9) Error: Assembler syntax error in operand
unit1.pas(71,10) Error: Unknown identifier "R9"
unit1.pas(71,14) Error: Dollar token is used without an identifier
unit1.pas(71,15) Error: Invalid constant expression
unit1.pas(71,16) Error: Invalid reference syntax
unit1.pas(71,18) Error: Unknown identifier "EBX"
unit1.pas(71,18) Error: No size specified and unable to determine the size of the operands
unit1.pas(71,18) Warning: Size suffix and destination or source size do not match
unit1.pas(72,9) Error: Assembler syntax error in operand
unit1.pas(72,10) Error: Unknown identifier "R9"
unit1.pas(72,14) Error: Dollar token is used without an identifier
unit1.pas(72,15) Error: Invalid constant expression
unit1.pas(72,16) Error: Invalid reference syntax
unit1.pas(72,18) Error: Unknown identifier "ECX"
unit1.pas(72,18) Error: No size specified and unable to determine the size of the operands
unit1.pas(72,18) Warning: Size suffix and destination or source size do not match
unit1.pas(73,9) Error: Assembler syntax error in operand
unit1.pas(73,10) Error: Unknown identifier "R9"
unit1.pas(73,15) Error: Unknown identifier "C"
unit1.pas(73,15) Error: Invalid constant expression
unit1.pas(73,16) Error: Invalid reference syntax
unit1.pas(73,18) Error: Unknown identifier "EDX"
unit1.pas(73,18) Error: No size specified and unable to determine the size of the operands
unit1.pas(73,18) Warning: Size suffix and destination or source size do not match
unit1.pas(74,9) Error: Unknown identifier "RBX"
unit1.pas(74,14) Error: Unknown identifier "R8"
unit1.pas(83,1) Error: Illegal expression
unit1.pas(83,11) Fatal: Syntax error, ";" expected but "identifier TFORM1" found