Autor Beitrag
Bryce
Hält's aus hier
Beiträge: 6



BeitragVerfasst: So 16.02.03 15:20 
Ich bin gerade dabei ein bisschen mit der CPUID-Instruction herumzuspielen. Leider erhalte ich ständig irgendeinen Fehler, der total sinnlos ist, z.B. wir mir bei einer simplen String-Zuweisung (z.B. s:='Hallo';) auf einmal etwas von "Access Violation" erzählt. Und das scheint alles daran zu liegen, dass ich nun den CPUID-Befehl benutze.

Kann mir vielleicht jemand sagen woran das liegt? Muss ich beim CPUID-Befehl etwas beachten?

Hier nochmal der code
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure OnCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
Const
  HexChars : Array[0..15] of Char =
  ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');


Function Hex8(x:Byte) : String;
  Begin
    Hex8 := HexChars[x DIV 16] + HexChars[x MOD 16];
  End;

Function Hex32(x:DWord) : String;
  Begin
    Hex32 := Hex8(x SHR 24) + Hex8(x SHR 16 AND $FF) +
             Hex8(x SHR 8 AND $FF) + Hex8(x AND $FF);
  End;

Procedure CPUID(s:DWord;Var a,b,c,d : DWord);
  Var
    e,f,g,h : DWord;
  Begin
    asm
      mov eax,s
      cpuid
      mov e,eax
      mov f,ebx
      mov g,ecx
      mov h,edx
      ret
    end;
    a := e;
    b := f;
    c := g;
    d := h;
  End;  


Procedure ProcessorDetection;
  Var
    a,b,c,d : DWord;
    s : String;
  Begin
    Form1.Memo1.Clear;
    CPUID($00000000,a,b,c,d);
    s:='ASSA';
    Form1.Memo1.Lines.Add(s);
  End;


procedure TForm1.OnCreate(Sender: TObject);
begin
  ProcessorDetection;
end;

end.