::: µ¨ÆÄÀÌ Tip&Trick :::

µ¨ÆÄÀÌ Tip&Trick ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-07 10:19:05, Hit : 5395, Vote : 1388
 CPU Á¾·ù ±¸Çϱâ

unit CpuId;

interface

type
  TCpuType = (cpu8086, cpu80286, cpu386, cpu486, cpuPentium);

{ Return the type of the current CPU }
function CpuType: TCpuType;

{ Return the type as a short string }
function CpuTypeString: String;

implementation

uses SysUtils;

function CpuType: TCpuType; assembler;
asm
  push DS

  { First check for an 8086 CPU }
  { Bits 12-15 of the FLAGS register are always set on the }
  { 8086 processor. }
  pushf            { save EFLAGS }
  pop bx           { store EFLAGS in BX }
  mov ax,0fffh     { clear bits 12-15 }
  and ax,bx        { in EFLAGS }
  push ax          { store new EFLAGS value on stack }
  popf             { replace current EFLAGS value }
  pushf            { set new EFLAGS }
  pop ax           { store new EFLAGS in AX }
  and ax,0f000h    { if bits 12-15 are set, then CPU }
  cmp ax,0f000h    { is an 8086/8088 }
  mov ax, cpu8086  { turn on 8086/8088 flag }
  je @@End_CpuType

  { 80286 CPU check }
  { Bits 12-15 of the FLAGS register are always clear on the }
  { 80286 processor. }
  or bx,0f000h     { try to set bits 12-15 }
  push bx
  popf
  pushf
  pop ax
  and ax,0f000h    { if bits 12-15 are cleared, CPU=80286 }
  mov ax, cpu80286 { turn on 80286 flag }
  jz @@End_CpuType

  { To test for 386 or better, we need to use 32 bit instructions,
    but the 16-bit Delphi assembler does not recognize the 32 bit opcodes
    or operands.  Instead, use the 66H operand size prefix to change
    each instruction to its 32-bit equivalent. For 32-bit immediate
    operands, we also need to store the high word of the operand immediately
    following the instruction.  The 32-bit instruction is shown in a comment
    after the 66H instruction.
  }

  { i386 CPU check }
  { The AC bit, bit #18, is a new bit introduced in the EFLAGS }
  { register on the i486 DX CPU to generate alignment faults. }
  { This bit can not be set on the i386 CPU. }

  db 66h           { pushfd }
  pushf
  db 66h           { pop eax }
  pop ax           { get original EFLAGS }
  db 66h           { mov ecx, eax }
  mov cx,ax        { save original EFLAGS }
  db 66h           { xor eax,40000h }
  xor ax,0h        { flip AC bit in EFLAGS }
  dw 0004h
  db 66h           { push eax }
  push ax          { save for EFLAGS }
  db 66h           { popfd }
  popf             { copy to EFLAGS }
  db 66h           { pushfd }
  pushf            { push EFLAGS }
  db 66h           { pop eax }
  pop ax           { get new EFLAGS value }
  db 66h           { xor eax,ecx }
  xor ax,cx        { can't toggle AC bit, CPU=Intel386 }
  mov ax, cpu386   { turn on 386 flag }
  je @@End_CpuType

  { i486 DX CPU / i487 SX MCP and i486 SX CPU checking }
  { Checking for ability to set/clear ID flag (Bit 21) in EFLAGS }
  { which indicates the presence of a processor }
  { with the ability to use the CPUID instruction. }
  db 66h           { pushfd }
  pushf            { push original EFLAGS }
  db 66h           { pop eax }
  pop ax           { get original EFLAGS in eax }
  db 66h           { mov ecx, eax }
  mov cx,ax        { save original EFLAGS in ecx }
  db 66h           { xor eax,200000h }
  xor ax,0h        { flip ID bit in EFLAGS }
  dw 0020h
  db 66h           { push eax }
  push ax          { save for EFLAGS }
  db 66h           { popfd }
  popf             { copy to EFLAGS }
  db 66h           { pushfd }
  pushf            { push EFLAGS }
  db 66h           { pop eax }
  pop ax           { get new EFLAGS value }
  db 66h           { xor eax, ecx }
  xor ax, cx
  mov ax, cpu486   { turn on i486 flag }
  je @@End_CpuType { if ID bit cannot be changed, CPU=486}
                   { without CPUID instruction functionality }

  { Execute CPUID instruction to determine vendor, family, }
  { model and stepping.  The use of the CPUID instruction used }
  { in this program can be used for B0 and later steppings }
  { of the P5 processor. }
   db 66h          { mov eax, 1 }
   mov ax, 1       { set up for CPUID instruction }
   dw 0
   db 66h          { cpuid }
   db 0Fh          { Hardcoded opcode for CPUID instruction }
   db 0a2h
   db 66h          { and eax, 0F00H }
   and ax, 0F00H   { mask everything but family }
   dw 0
   db 66h          { shr eax, 8 }
   shr ax, 8       { shift the cpu type down to the low byte }
   sub ax, 1       { subtract 1 to map to TCpuType }

@@End_CpuType:
   pop ds
end;

function CpuTypeString: String;
var
  kind: TCpuType;
begin
  kind := CpuType;
  case kind of
  cpu8086:
    Result := '8086';
  cpu80286:
    Result := '80286';
  cpu386:
    Result := '386';
  cpu486:
    Result := '486';
  cpuPentium:
    Result := 'Pentium';
  else
    { Try to be flexible for future cpu types, e.g., P6. }
    Result := Format('P%d', [Ord(kind)]);
  end;
end;

end.





491   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TRichEdit ÀÇ ¼±ÅÃµÈ ¿µ¿ª¸¸ ÀμâÇÏ±â  ±è¿µ´ë 2003/03/07 5043 937
  [½Ã½ºÅÛ] CPU Á¾·ù ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 5395 1388
489   [½Ã½ºÅÛ] »ç¿îµåÆÄÀÏ ¾øÀÌ PC ½ºÇÇÄ¿·Î À½¾Ç¿¬ÁÖ  ±è¿µ´ë 2003/03/07 7605 1138
488   [³×Æ®¿÷/ÀÎÅͳÝ] ÇÁ·Î±×·¥À¸·Î ³×Æ®¿öÅ© µå¶óÀÌºê ¿¬°á/ÇØÁ¦  ±è¿µ´ë 2003/03/07 7429 1428
487   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÁî Á¾·á¿Í °°Àº ±×´ÃÁø È­¸é ¸¸µé±â  ±è¿µ´ë 2003/03/07 3552 946
486   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¾ÆÀÌÄÜ »çÀÌÆ®  ±è¿µ´ë 2003/03/07 4071 1209
485   [½Ã½ºÅÛ] À©µµ¿ìÁî ½Ã½ºÅÛ Ç¥ÁØ ÆùÆ® ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 3486 967
484   [³×Æ®¿÷/ÀÎÅͳÝ] RS232 Åë½Å  ±è¿µ´ë 2003/03/07 7593 2020
483   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ÁÖ¾îÁø ¿µ¿ªÀÇ È­¸é ĸó  ±è¿µ´ë 2003/03/07 3926 1119
482   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¼ýÀÚ¸¦ ¿µ¹® Ç¥±â·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4693 1044
481   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¼ýÀÚ¸¦ ÇÑ±Û Ç¥±â·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4029 1056
480   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ÀÇ ³»¿ëÀ» Bitmap À¸·Î ¸¸µé±â 2  ±è¿µ´ë 2003/03/07 4347 1610
479   [COM/OLE] MS-WORD Á¾·á½ÃÅ°±â  ±è¿µ´ë 2003/03/07 3044 853
478   [À©µµ¿ìÁî API] ½Ã½ºÅÛ »ç¿îµå ¿¬ÁÖÇÏ±â  ±è¿µ´ë 2003/03/07 5353 1455
477   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Algorithm to sort a TStringGrid #2  ±è¿µ´ë 2003/03/07 5291 1375
476   [À©µµ¿ìÁî API] ¿ÜºÎ ÇÁ·Î±×·¥ÀÇ ÁÂÇ¥,»óÅ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 3672 1155
475   [À©µµ¿ìÁî API] À©µµ¿ìÁî Telnet À¸·Î È£½ºÆ® Á¢¼ÓÇÏ±â  ±è¿µ´ë 2003/03/07 4564 1247
474   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ƯÁ¤ÇÑ Æú´õ·Î À̵¿ÇÑ DOS â ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 4649 1256
473   [½Ã½ºÅÛ] DOS ¸í·É¾î ½ÇÇàÇÏ°í °á°ú ¹Þ¾Æ¿À±â  ±è¿µ´ë 2003/03/07 7162 1680
472   [À©µµ¿ìÁî API] NTÀÇ ÇöÀç user°¡ administrative privilege ¸¦ °¡Áö°í ÀÖ´ÂÁö?  ±è¿µ´ë 2003/03/07 3541 966
471   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] µÎ°³ÀÇ StringGrid sync ¸¶Ãß±â  ±è¿µ´ë 2003/03/07 4125 1132
470   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÀÇ title bar ÆùÆ® ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 3649 960
469   [³×Æ®¿÷/ÀÎÅͳÝ] ³×Æ®¿öÅ© °øÀ¯ ¼³Á¤/ÇØÁ¦ Çϱâ (Windows 9x)  ±è¿µ´ë 2003/03/07 4878 1229
468   [³×Æ®¿÷/ÀÎÅͳÝ] ³×Æ®¿öÅ© °øÀ¯ Á¤º¸ Àоî¿À±â (WIndows 9x)  ±è¿µ´ë 2003/03/07 4130 1154
467   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ´­·ÁÁø Å°º¸µå Å°ÀÇ ¸íĪ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 7879 1583
466   [À©µµ¿ìÁî API] Windows98 ¿¡¼­ÀÇ SetForegroundWindow  ±è¿µ´ë 2003/03/07 6390 1664
465   [À©µµ¿ìÁî API] Task bar ¿¡ ³ªÅ¸³ªÁö ¾Ê´Â ÇÁ·Î±×·¥ ¸¸µé±â  ±è¿µ´ë 2003/03/07 5663 1660
464   [COM/OLE] Outlook »ç¿ëÇÏ±â  ±è¿µ´ë 2003/03/07 4047 1335
463   [½Ã½ºÅÛ] ÁöÁ¤ÇÑ drive°¡ CD-ROM ÀÎÁö °Ë»çÇÏ±â  ±è¿µ´ë 2003/03/07 6905 1820
462   [½Ã½ºÅÛ] ¾î¶² ¾îÇø®ÄÉÀ̼ÇÀÌ ½ÃÀÛ µÇ´ÂÁö hookÀ¸·Î ¾Ë¾Æ³»±â  ±è¿µ´ë 2003/03/07 5788 1729
461   [À©µµ¿ìÁî API] À©µµ¿ìÁî Ž»ö±âÀÇ ¾ÆÀÌÄÜ »Ì¾Æ³»¼­ »ç¿ëÇÏ±â  ±è¿µ´ë 2003/03/07 8602 2063
460   [À©µµ¿ìÁî API] System Images  ±è¿µ´ë 2003/03/07 8530 1986
459   [À©µµ¿ìÁî API] ÄÄÇ»ÅÍ/ÆÄÀÏ/Æú´õ ã±â È­¸é ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 8554 1696
458   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Unix-format time À» TDateTime ·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4506 1240
457   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ½ÇÇà½Ã component ¸¦ Move/Resize ½ÃÅ°±â  ±è¿µ´ë 2003/03/07 3692 1067
456   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TMemo ¸¦ È­¸éÅ©±â·Î ÀμâÇÏ±â  ±è¿µ´ë 2003/03/07 3198 809
455   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] SpeedButton ¿¡ OnMouseEnter/OnMouseExit À̺¥Æ® ³Ö±â  ±è¿µ´ë 2003/03/07 4374 1183
454   [À©µµ¿ìÁî API] Å°º¸µåÀÇ Scroll Lock Äѱâ/²ô±â  ±è¿µ´ë 2003/03/07 4755 1276
453   [µ¥ÀÌÅͺ£À̽º] table packing ÇÏ±â  ±è¿µ´ë 2003/03/07 4040 1119
452   [À©µµ¿ìÁî API] reboot Windows  ±è¿µ´ë 2003/03/07 5108 1343

[ÀÌÀü 10°³] [1]..[11][12] 13 [14][15][16][17][18][19][20]..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2025 Zeroboard / skin by zero