I have a problem. I have following x86 delphi code which is written in ASM. I need to port this to AMD64?
type
TCPUID = array[1..4] of Longint;
function GetCID : TCPUID; assembler; register;
asm
push ebx
push edi
mov edi, eax
mov eax, 1
dw $A20F
stosd
mov eax, ebx
stosd
mov eax, ecx
stosd
mov eax, edx
stosd
pop edi
pop ebx
end;
I have never programmed in assembly, does anyone know what the port would be or how I would go about changing it.
I am not Win64 assembler guru, but the next translation worked for me (tested on 64-bit free pascal):
program project1;
{$mode delphi}
{$asmmode intel}
type
TCPUID = array[1..4] of Longint;
function GetCID: TCPUID;
asm
push rbx
push rdi
mov rdi, rcx
mov eax, 1
cpuid
mov [rdi],eax
add rdi,4
mov [rdi],ebx
add rdi,4
mov [rdi],ecx
add rdi,4
mov [rdi],edx
pop rdi
pop rbx
end;
var ID: TCPUID;
begin
ID:= GetCID;
Writeln(ID[1], '-', ID[2], '-', ID[3], '-', ID[4]);
Readln;
end.