Hello!
When rax/eax is initialized to 0, the processor vendor's name is stored in the rbx/ebx, rdx/edx and rcx/ecx registers. I want to store them in a global variable so that I can build the string together and return it. For further vendor identification in other functions, I additionally store ecx in another global variable, so I can quickly check the manufacturer without executing the CPUID instruction another time.
My problem is: When I return the full vendor name string (12 bytes) it reads into the second, shorter string (4 bytes), so instead of "AuthenticAMD" I get "AuthenticAMDcAMD", but why?
Code:
%define INTEL 6C65746Eh ; "letn" - last part (ecx) of GenuineIntel
%define AMD 444D4163h ; "DMAc" - last part (ecx) of AuthenticAMD
%define OTHER 0h
[...]
global _GetVendor
export _GetVendor
_GetVendor:
XOR eax, eax
CPUID
MOV [g_vendor], ebx
MOV [g_vendor+4], edx
MOV [g_vendor+8], ecx
PUSH g_vendor
POP eax
CMP ecx, INTEL
JE .setintel
CMP ecx, AMD
JE .setamd
MOV dword [g_vendorId], OTHER
JMP .exit
.setamd:
MOV dword [g_vendorId], AMD
JMP .exit
.setintel:
MOV dword [g_vendorId], INTEL
.exit:
RET 0
[...]
[section .bss]
g_model resb 48
g_vendor resb 12
g_vendorId resb 4
; Note: No unicode!
Does this have something to do with the NTS?
Thanks in advance, aVoX.