Autor Beitrag
suga2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Di 06.05.08 20:41 
hallo...und zwar bastel ich mal wieder an einer aufgabe herum,die irgendwie ,warum auch immer nicht wirklich funktionieren will. :oops:
ich habe zwei buttons,über den einen lese ich die frequenz aus der registry aus und mit dem anderen soll ich via zeitmessung und asm routine die frequnz bestimmten. leichter gesagt als getan. auslesen funktioniert, messen aber nicht.... bitte um ratschlag :) :idea:


ausblenden volle Höhe Delphi-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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
      private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  M_Reg:TRegistry;Frequenz:extended;

implementation

{$R *.dfm}

function  Messung:single;
CONST Zeitdauer=500// 1/2 sekunde
Var StampHi,StampLo:Cardinal;
begin
ASM
dw 310Fh //rdtsc
mov StampLo,eax
mov StampHi,edx
END;
sleep(Zeitdauer);
ASM
dw 310Fh //rdtsc
sub eax,StampLO
sbb edx,StampHi
mov StampLo,eax
mov StampHi,edx
END;
Frequenz:=StampLO/(1000.0*Zeitdauer)
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
Messung;
end;


procedure TForm1.Button1Click(Sender: TObject);
var M_Reg:TRegistry;Frequenz:integer;
begin

M_Reg:=TRegistry.Create;

M_Reg.RootKey:=HKEY_LOCAL_MACHINE;
if M_Reg.OpenKeyReadOnly
('\HARDWARE\DESCRIPTION\System\CentralProcessor\0\')
then Frequenz:=M_Reg.READINTEGER('~MHZ')
else Frequenz:=0;
M_Reg.Free;

Label1.Caption:=inttostr(Frequenz);

end;
end;


ASM ist vorgegeben un nur der hinweis, dass es sich bei der vorgabe um 32 bit handelt, wir aber mit 64 arbeiten. :?: ist damit der typ gemeint, wie single,double oder extended??? :?:


danke schon mal im voraus :D
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 07.05.08 08:49 
hmmm, sollte es nicht sbc statt sbb heißen ???

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mi 07.05.08 14:28 
Titel: sbc
nein,eben nicht.weil ich 2mal sub müsste, darf aber nicht,deswegen wird das zweite mal nicht sub sondern sbb geschrieben...
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mi 07.05.08 14:41 
hab den entscheidenen fehler geunden, ; statt. :oops: aaaaber nun habe ich das nächste problem. das label, wo die frequenz ausgegeben werden soll, kann ich doch nicht in eine function schreiben, da eine function doch keinen rückgabewert habe, bzw diese nur abgewarbeitet wird, oder hab ich da etwas falsch verstanden`. ich möchte mit meinem button2click zur marke messung springen, macht er auch, aber ich will,dass er die frequenz im label2 ausgibt. in die function passt das nicht,also in den button2click, oder? denn bekomm ich aber die fehlermeldung "es gibt keine überladene version von 'inttostr', die man mit diesen argumenten aufrufen kann....
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 07.05.08 17:02 
Ist auch richtig so: function  Messung:single;
Die Funktion gibt einen Single zurück, also brauchst du FloatToString.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mi 07.05.08 19:43 
:D danke, nun passts.....