From d1664cbba8a03e2ad32e9b33e499b777233656ad Mon Sep 17 00:00:00 2001 From: marc Date: Thu, 4 May 2006 00:53:16 +0000 Subject: [PATCH] + added testproject for disassembler git-svn-id: trunk@9239 - --- .gitattributes | 5 ++ debugger/windebug/test/asmtest.lpi | 77 +++++++++++++++++++++++++ debugger/windebug/test/asmtest.lpr | 18 ++++++ debugger/windebug/test/asmtestunit.lfm | 73 +++++++++++++++++++++++ debugger/windebug/test/asmtestunit.lrs | 22 +++++++ debugger/windebug/test/asmtestunit.pas | 80 ++++++++++++++++++++++++++ 6 files changed, 275 insertions(+) create mode 100644 debugger/windebug/test/asmtest.lpi create mode 100644 debugger/windebug/test/asmtest.lpr create mode 100644 debugger/windebug/test/asmtestunit.lfm create mode 100644 debugger/windebug/test/asmtestunit.lrs create mode 100644 debugger/windebug/test/asmtestunit.pas diff --git a/.gitattributes b/.gitattributes index 78e49dd471..e8454ace95 100644 --- a/.gitattributes +++ b/.gitattributes @@ -573,6 +573,11 @@ debugger/windebug/fpwd/fpwdglobal.pas svneol=native#text/pascal debugger/windebug/fpwd/fpwdloop.pas svneol=native#text/pascal debugger/windebug/fpwd/fpwdpeimage.pas svneol=native#text/pascal debugger/windebug/fpwd/fpwdtype.pas svneol=native#text/pascal +debugger/windebug/test/asmtest.lpi svneol=native#text/plain +debugger/windebug/test/asmtest.lpr svneol=native#text/pascal +debugger/windebug/test/asmtestunit.lfm svneol=native#text/plain +debugger/windebug/test/asmtestunit.lrs svneol=native#text/plain +debugger/windebug/test/asmtestunit.pas svneol=native#text/pascal debugger/windebug/windebugger.pp svneol=native#text/pascal debugger/windebug/windextra.pp svneol=native#text/pascal debugger/windebug/windisas.pp svneol=native#text/plain diff --git a/debugger/windebug/test/asmtest.lpi b/debugger/windebug/test/asmtest.lpi new file mode 100644 index 0000000000..13317a5152 --- /dev/null +++ b/debugger/windebug/test/asmtest.lpi @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debugger/windebug/test/asmtest.lpr b/debugger/windebug/test/asmtest.lpr new file mode 100644 index 0000000000..7befab4888 --- /dev/null +++ b/debugger/windebug/test/asmtest.lpr @@ -0,0 +1,18 @@ +program asmtest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms + { add your units here }, AsmTestUnit; + +begin + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/debugger/windebug/test/asmtestunit.lfm b/debugger/windebug/test/asmtestunit.lfm new file mode 100644 index 0000000000..e405410eba --- /dev/null +++ b/debugger/windebug/test/asmtestunit.lfm @@ -0,0 +1,73 @@ +object Form1: TForm1 + Caption = 'AsmTest' + ClientHeight = 224 + ClientWidth = 400 + PixelsPerInch = 120 + HorzScrollBar.Page = 399 + VertScrollBar.Page = 223 + Left = 435 + Height = 224 + Top = 232 + Width = 400 + object Label1: TLabel + Caption = 'Enter hex values separated by spaces here' + Color = clNone + ParentColor = False + Left = 8 + Height = 18 + Top = 8 + Width = 263 + end + object Label2: TLabel + Anchors = [akLeft, akBottom] + Caption = 'Output' + Color = clNone + ParentColor = False + Left = 8 + Height = 17 + Top = 171 + Width = 45 + end + object txtCode: TMemo + Anchors = [akTop, akLeft, akRight, akBottom] + Lines.Strings = ( + '90' + '41' + 'E8 12345678' + 'C3' + 'AA' + '0F0F A4 B6 12345678 A6' + '65 0F 01 92 12345678' + '43 DB 9C B1 55667788' + '' + ) + ScrollBars = ssVertical + TabOrder = 0 + Left = 8 + Height = 135 + Top = 32 + Width = 384 + end + object txtOutput: TEdit + Anchors = [akLeft, akRight, akBottom] + ReadOnly = True + TabOrder = 1 + Left = 8 + Height = 23 + Top = 191 + Width = 384 + end + object chk64Bit: TCheckBox + Caption = '64 bit' + TabOrder = 2 + Left = 304 + Height = 17 + Top = 9 + Width = 55 + end + object Timer1: TTimer + Interval = 250 + OnTimer = Timer1Timer + top = 184 + end +end diff --git a/debugger/windebug/test/asmtestunit.lrs b/debugger/windebug/test/asmtestunit.lrs new file mode 100644 index 0000000000..00ef11025d --- /dev/null +++ b/debugger/windebug/test/asmtestunit.lrs @@ -0,0 +1,22 @@ +{ This is an automatically generated lazarus resource file } + +LazarusResources.Add('TForm1','FORMDATA',[ + 'TPF0'#6'TForm1'#5'Form1'#7'Caption'#6#7'AsmTest'#12'ClientHeight'#3#224#0#11 + +'ClientWidth'#3#144#1#13'PixelsPerInch'#2'x'#18'HorzScrollBar.Page'#3#143#1 + +#18'VertScrollBar.Page'#3#223#0#4'Left'#3#179#1#6'Height'#3#224#0#3'Top'#3 + +#232#0#5'Width'#3#144#1#0#6'TLabel'#6'Label1'#7'Caption'#6')Enter hex values' + +' separated by spaces here'#5'Color'#7#6'clNone'#11'ParentColor'#8#4'Left'#2 + +#8#6'Height'#2#18#3'Top'#2#8#5'Width'#3#7#1#0#0#6'TLabel'#6'Label2'#7'Anchor' + +'s'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#6'Output'#5'Color'#7#6'clNone'#11 + +'ParentColor'#8#4'Left'#2#8#6'Height'#2#17#3'Top'#3#171#0#5'Width'#2'-'#0#0#5 + +'TMemo'#7'txtCode'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0 + +#13'Lines.Strings'#1#6#2'90'#6#2'41'#6#11'E8 12345678'#6#2'C3'#6#2'AA'#6#22 + +'0F0F A4 B6 12345678 A6'#6#20'65 0F 01 92 12345678'#6#20'43 DB 9C B1 5566778' + +'8'#6#0#0#10'ScrollBars'#7#10'ssVertical'#8'TabOrder'#2#0#4'Left'#2#8#6'Heig' + +'ht'#3#135#0#3'Top'#2' '#5'Width'#3#128#1#0#0#5'TEdit'#9'txtOutput'#7'Anchor' + +'s'#11#6'akLeft'#7'akRight'#8'akBottom'#0#8'ReadOnly'#9#8'TabOrder'#2#1#4'Le' + +'ft'#2#8#6'Height'#2#23#3'Top'#3#191#0#5'Width'#3#128#1#0#0#9'TCheckBox'#8'c' + +'hk64Bit'#7'Caption'#6#6'64 bit'#8'TabOrder'#2#2#4'Left'#3'0'#1#6'Height'#2 + +#17#3'Top'#2#9#5'Width'#2'7'#0#0#6'TTimer'#6'Timer1'#8'Interval'#3#250#0#7'O' + +'nTimer'#7#11'Timer1Timer'#3'top'#3#184#0#0#0#0 +]); diff --git a/debugger/windebug/test/asmtestunit.pas b/debugger/windebug/test/asmtestunit.pas new file mode 100644 index 0000000000..3acf590e39 --- /dev/null +++ b/debugger/windebug/test/asmtestunit.pas @@ -0,0 +1,80 @@ +unit AsmTestUnit; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, windisas, + ExtCtrls, LCLProc, Math; + +type + + { TForm1 } + + TForm1 = class(TForm) + chk64Bit: TCheckBox; + Timer1: TTimer; + txtOutput: TEdit; + Label1: TLabel; + Label2: TLabel; + txtCode: TMemo; + procedure Timer1Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{ TForm1 } + +procedure TForm1.Timer1Timer(Sender: TObject); +var + idx, n: Integer; + Line, S: String; + Code: array[0..28] of Byte; + CodeIdx, B: Byte; + Value: Int64; + e: Integer; + p: Pointer; +begin + n := txtCode.SelStart; + if n < 0 then Exit; + S := Copy(txtCode.Text, 1, n); + idx := 0; + for n := 1 to Length(S) do + begin + if S[n] = #10 then Inc(idx); + end; + Line := txtCode.Lines[idx]; + CodeIdx := 0; + while (Line <> '') and (CodeIdx < 20) do + begin + S := GetPart([], [' ', #9], Line); + Delete(Line, 1, 1); // strip end ' ' or #9 + if S = '' then Continue; + B := Min(16, Length(S)); + Val('$' + S, Value, e); + if e <> 0 then Continue; + Move(Value, Code[CodeIdx], B div 2); + Inc(CodeIdx, B div 2); + end; + if CodeIdx > 0 + then begin + p := @Code; + Disassemble(p, chk64Bit.Checked, S, Line); + txtOutput.Text := S + ' '+ Line; + end +// else txtOutput.Text :=''; +end; + +initialization + {$I asmtestunit.lrs} + +end. +