$filename "t.exe"
'uses rtl64

'CPUID PROFILE

'INTEL CPUID GUIDE
'http://www.intel.com/assets/pdf/appnote/241618.pdf
'https://en.wikipedia.org/wiki/CPUID


  '---------------------------
  Function CPUdata() as string
  '===========================
   
  dim as int vendor(4),
      features(4),
      cache(4),
      serial(4),
      extFun(1),
      extInfo(2),
      brand(12),
      extL2cache(2),
      addrSizes(1)

  sys mrbx    
  mov mrbx,rbx
  
  mov eax,&h0 : cpuid : lea rdi,vendor
  mov [rdi+00],eax
  mov [rdi+04],ebx
  mov [rdi+08],edx
  mov [rdi+12],ecx

  mov eax,&h1 : cpuid : lea rdi,features
  mov [rdi+00],eax
  mov [rdi+04],ebx
  mov [rdi+08],ecx
  mov [rdi+12],edx

  mov eax,&h2 : cpuid : lea rdi,cache
  mov [rdi+00],eax
  mov [rdi+04],ebx
  mov [rdi+08],ecx
  mov [rdi+12],edx

  'Pentium III only
  mov eax,&h3 
  cpuid
  lea rdi,serial
  mov [rdi+00],eax
  mov [rdi+04],ebx
  mov [rdi+08],ecx
  mov [rdi+12],edx

  mov eax,&h80000000 : cpuid : lea rdi,extFun
  mov [rdi+00],eax
  
  mov eax,&h80000001 : cpuid : lea rdi,extInfo
  mov [rdi+08],ecx
  mov [rdi+12],edx
  
  
  mov eax,&h80000002 : cpuid : lea rdi,brand
  mov [rdi+00],eax
  mov [rdi+04],ebx
  mov [rdi+08],ecx
  mov [rdi+12],edx
  mov eax,&h80000003
  cpuid
  mov [rdi+16],eax
  mov [rdi+20],ebx
  mov [rdi+24],ecx
  mov [rdi+28],edx
  mov eax,&h80000004
  cpuid
  mov [rdi+32],eax
  mov [rdi+36],ebx
  mov [rdi+40],ecx
  mov [rdi+44],edx
 
  mov eax,&h80000006 : cpuid : lea rdi,extL2cache
  mov [rdi+00],ecx
 
  mov eax,&h80000008 : cpuid : lea rdi,AddrSizes
  mov [rdi+00],eax
 

  mov rbx,mrbx
  '

  '------
  'OUTPUT
  '======

  dim as int d
  dim as string s
  dim as string cr
  cr="
  "
  '
  'FEATURES
  '--------
  '
  's+="INTEL CPU TYPE: " str(features(2) and 255 )+cr+cr
  
  d=features(4) 'EDX

  if d and  1          then s=s+"FPU   "+cr
  if d and  2          then s=s+"VME   "+cr
  if d and  4          then s=s+"DE    "+Cr
  if d and  8          then s=s+"PSE   "+cr
  if d and  0x10       then s=s+"TSC   "+cr
  if d and  0x20       then s=s+"MSR   "+cr
  if d and  0x40       then s=s+"PAE   "+cr
  if d and  0x80       then s=s+"MCE   "+cr
  
  if d and  0x100      then s=s+"CXB    "+cr
  if d and  0x200      then s=s+"APIC   "+cr
  '0X400
  if d and  0x800      then s=s+"SEP    "+cr
  if d and  0x1000     then s=s+"MTRR   "+cr
  if d and  0x2000     then s=s+"PGE    "+cr
  if d and  0x4000     then s=s+"MCA    "+cr
  if d and  0x8000     then s=s+"CMOV   "+cr
  if d and  0x10000    then s=s+"PAT    "+cr
  if d and  0x20000    then s=s+"PSE-36 "+cr
  if d and  0x40000    then s=s+"PSN    "+cr
  if d and  0x80000    then s=s+"CLFLUSH"+cr
  '0x100000
  if d and  0x200000   then  s=s+"DS    "+cr
  if d and  0x400000   then  s=s+"ACPI  "+cr
  if d and  0x800000   then  s=s+"MMX   "+cr
  if d and  0x1000000  then  s=s+"FXSR  "+cr
  if d and  0x2000000  then  s=s+"SSE   "+cr
  if d and  0x4000000  then  s=s+"SSE2  "+cr
  if d and  0x8000000  then  s=s+"SS    "+cr
  if d and  0x10000000 then  s=s+"HTT   "+cr
  if d and  0x20000000 then  s=s+"TM    "+cr
  if d and  0x40000000 then  s=s+"IA64  "+cr
  if d and  0x80000000 then  s=s+"PBE   "+cr
   
  s+=cr+cr
  
  d=features(3)
  
  if d and  1          then s=s+"SSE3  "+cr
  '0x2
  if d and  4          then s=s+"DTES64"+cr
  if d and  8          then s=s+"MONITOR"+cr
  if d and  0x10       then s=s+"DS-CPL"+cr
  if d and  0x20       then s=s+"VMX   "+cr
  if d and  0x40       then s=s+"SMS   "+cr
  if d and  0x80       then s=s+"EST   "+cr
  
  if d and  0x100      then s=s+"TM2    "+cr
  if d and  0x200      then s=s+"SSSE3  "+cr
  if d and  0x400      then s=s+"CNXT-ID"+cr
  '0x800 
  '0x1000
  if d and  0x2000     then s=s+"CMPXCHG16B"+cr
  if d and  0x4000     then s=s+"xTPR   "+cr
  if d and  0x8000     then s=s+"PDCM   "+cr
  '0x10000
  '0x20000
  if d and  0x40000    then s=s+"DCA    "+cr
  if d and  0x80000    then s=s+"SSE4-1 "+cr
  if d and  0x100000   then s=s+"SSE4-2"+cr
  if d and  0x200000   then s=s+"X2APIC"+cr
  if d and  0x400000   then s=s+"MOVBE "+cr
  if d and  0x800000   then s=s+"POPCNT"+cr
  '0x1000000
  '0x2000000
  if d and  0x4000000  then  s=s+"XSAVE "cr
  if d and  0x8000000  then  s=s+"OSXSAVE"+cr
  '0x10000000
  '0x20000000
  '0x40000000
  '0x80000000

  dim as sys p1,p2
  dim as zstring vendorz at p1
  p1=&vendor +4
  dim as zstring brandz  at p2
  p2=&brand

  string serials=hex(serial(1),8) hex(serial(2),8) hex(serial(3),8) hex(serial(4),8)
  function=

  "CPUID"     cr cr+
  serials     cr cr+
  vendorz     cr cr+
  brandz      cr cr+
  "Features:" cr cr+
  s
End Function


'print CPUdata()
putfile "ProcessorProfile.txt",CPUdata()
