Detectar o tamanho de linha da cache L1 do processador
programCache_CPUID;{$APPTYPE CONSOLE}usesSysUtils;typeRegisters=record_eax_:cardinal;_ebx_:cardinal;_ecx_:cardinal;_edx_:cardinal;end;procedureCPUID(varregs:Registers);beginasmpushesipushebxpushecxpushedxmovesi,regsmoveax,Registers(esi).&_eax_movebx,Registers(esi).&_ebx_movecx,Registers(esi).&_ecx_movedx,Registers(esi).&_edx_db$0F,$A2{ CPUID }movRegisters(esi).&_edx_,edxmovRegisters(esi).&_ecx_,ecxmovRegisters(esi).&_ebx_,ebxmovRegisters(esi).&_eax_,eaxpopedxpopecxpopebxpopesiend;end;constAMDProcessor=1143;IntelProcessor=1223;varsize:cardinal;regs:Registers;maker:cardinal;begin{ Default }size:=64;{ Get the manufacturer code (1223 for Intel, 1143 for AMD) }regs._eax_:=0;CPUID(regs);maker:=regs._ebx_and$000000FF+regs._ecx_and$000000FF+regs._edx_and$000000FF;regs._ebx_:=regs._ebx_shr8;regs._ecx_:=regs._ecx_shr8;regs._edx_:=regs._edx_shr8;maker:=maker+regs._ebx_and$000000FF+regs._ecx_and$000000FF+regs._edx_and$000000FF;regs._ebx_:=regs._ebx_shr8;regs._ecx_:=regs._ecx_shr8;regs._edx_:=regs._edx_shr8;maker:=maker+regs._ebx_and$000000FF+regs._ecx_and$000000FF+regs._edx_and$000000FF;regs._ebx_:=regs._ebx_shr8;regs._ecx_:=regs._ecx_shr8;regs._edx_:=regs._edx_shr8;maker:=maker+regs._ebx_and$000000FF+regs._ecx_and$000000FF+regs._edx_and$000000FF;regs._ebx_:=regs._ebx_shr8;regs._ecx_:=regs._ecx_shr8;regs._edx_:=regs._edx_shr8;{ For AMD }casemakerofAMDProcessor:beginwriteln('Processador AMD');{ Check for support of the extended function $5 }regs._eax_:=$80000000;CPUID(regs);ifregs._eax_>=$80000005thenbeginwriteln('Usando a funcao 8000 0005');{ Call the function }regs._eax_:=$80000005;CPUID(regs);size:=regs._ecx_and$000000FF;end;end;IntelProcessor:beginwriteln('Processador Intel');{ Check for support of the extended function $1D }regs._eax_:=$80000000;CPUID(regs);ifregs._eax_>=$8000001Dthenbeginwriteln('Usando a funcao 8000 001D');{ Parse through all caches }regs._eax_:=$8000001D;regs._ecx_:=0;repeatCPUID(regs);{ Is this a Level 1 Data/Unified Cache ? }if((regs._eax_and$000000FF)=$21)or((regs._eax_and$000000FF)=$23)thenbeginif(regs._ebx_and$00000FFF)>sizethensize:=(regs._ebx_and$00000FFF);end;until(regs._eax_and$0000000F)=0;endelsebeginwriteln('Usando a funcao 0000 0001');{ Use the standard function 1 }regs._eax_:=1;CPUID(regs);size:=(regs._ebx_and$0000FF00)shr5;end;end;end;writeln('Linha de Cache L1: ',size);end.