diff --git a/.gitignore b/.gitignore index d41c37b..5b1ff05 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,8 @@ Temp/ *.tmp +*.res + # Delphi autogenerated files (duplicated info) *.cfg *.hpp @@ -68,4 +70,15 @@ __recovery/ # Castalia statistics file (since XE7 Castalia is distributed with Delphi) *.stat -!FasmDll/ \ No newline at end of file +#FPC +backup/ +*.compiled +*.ppu +*.o +*.or +FPCTests/*.ico +*.ini + +Tests/Win32 +!FasmDll/* +!FasmDll/DEMO/* \ No newline at end of file diff --git a/FPCTests/fpcunitproject1.lpi b/FPCTests/fpcunitproject1.lpi new file mode 100644 index 0000000..752ce22 --- /dev/null +++ b/FPCTests/fpcunitproject1.lpi @@ -0,0 +1,79 @@ + + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="3"> + <Item1> + <PackageName Value="fpcunittestrunner"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + <Item3> + <PackageName Value="FCL"/> + </Item3> + </RequiredPackages> + <Units Count="3"> + <Unit0> + <Filename Value="fpcunitproject1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="testcase1.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="TestCase1"/> + </Unit1> + <Unit2> + <Filename Value="..\Source\Fasm4Delphi.pas"/> + <IsPartOfProject Value="True"/> + </Unit2> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <OtherUnitFiles Value="..\Source"/> + </SearchPaths> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/FPCTests/fpcunitproject1.lpr b/FPCTests/fpcunitproject1.lpr new file mode 100644 index 0000000..5322b19 --- /dev/null +++ b/FPCTests/fpcunitproject1.lpr @@ -0,0 +1,13 @@ +program fpcunitproject1; + +{$mode objfpc}{$H+} + +uses + Interfaces, Forms, GuiTestRunner, fpcunittestrunner, TestCase1; + +begin + Application.Initialize; + Application.CreateForm(TGuiTestRunner, TestRunner); + Application.Run; +end. + diff --git a/FPCTests/fpcunitproject1.lps b/FPCTests/fpcunitproject1.lps new file mode 100644 index 0000000..9c90b9b --- /dev/null +++ b/FPCTests/fpcunitproject1.lps @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectSession> + <PathDelim Value="\"/> + <Version Value="10"/> + <BuildModes Active="Default"/> + <Units Count="3"> + <Unit0> + <Filename Value="fpcunitproject1.lpr"/> + <IsPartOfProject Value="True"/> + <EditorIndex Value="1"/> + <CursorPos X="66" Y="6"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + </Unit0> + <Unit1> + <Filename Value="testcase1.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="TestCase1"/> + <IsVisibleTab Value="True"/> + <TopLine Value="21"/> + <CursorPos X="62" Y="41"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + </Unit1> + <Unit2> + <Filename Value="..\Source\Fasm4Delphi.pas"/> + <IsPartOfProject Value="True"/> + <EditorIndex Value="-1"/> + <WindowIndex Value="-1"/> + <TopLine Value="-1"/> + <CursorPos X="-1" Y="-1"/> + <UsageCount Value="20"/> + </Unit2> + </Units> + <JumpHistory Count="2" HistoryIndex="1"> + <Position1> + <Filename Value="fpcunitproject1.lpr"/> + </Position1> + <Position2> + <Filename Value="testcase1.pas"/> + <Caret Line="8" Column="66"/> + </Position2> + </JumpHistory> + </ProjectSession> +</CONFIG> diff --git a/FPCTests/testcase1.pas b/FPCTests/testcase1.pas new file mode 100644 index 0000000..fddc963 --- /dev/null +++ b/FPCTests/testcase1.pas @@ -0,0 +1,51 @@ +unit TestCase1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, fpcunit, testutils, testregistry,Fasm4Delphi; + +type + + TTestCase1= class(TTestCase) + published + procedure TestHookUp; + end; + +implementation + +const + CompliterMemSize=$10000; + +var + CompliterMem:PFASM_STATE; + +procedure TTestCase1.TestHookUp; +begin + if fasm_AssembleFile('..\Tests\Test1.asm',CompliterMem,CompliterMemSize)<>FASM_OK then + Fail('Error in test1:'+sLineBreak+ + 'Condition: '+CompliterMem^.condition.ToString+sLineBreak+ + 'Error Code: '+CompliterMem^.error_code.ToString); + if fasm_Assemble('add eax,0',CompliterMem,CompliterMemSize)<>FASM_OK then + writeln('Error in test2:'+sLineBreak+ + 'Condition: '+CompliterMem^.condition.ToString+sLineBreak+ + 'Error Code: '+CompliterMem^.error_code.ToString); + if fasm_AssembleFile('..\FasmDll\FASM.ASH',CompliterMem,CompliterMemSize)=FASM_OK then + Fail('Error in test3:'+sLineBreak+ + 'FASM is compiling something that it is can not compile at all.'); + if fasm_Assemble('call -100',CompliterMem,CompliterMemSize)<>FASM_OK then + Fail('Error in test4:'+sLineBreak+ + 'Condition: '+CompliterMem^.condition.ToString+sLineBreak+ + 'Error Code: '+CompliterMem^.error_code.ToString); +end; + + + +initialization + LoadFASM('..\FasmDll\FASM.DLL'); + GetMem(CompliterMem,CompliterMemSize); + RegisterTest(TTestCase1); +end. + diff --git a/FasmDll/DEMO/ASMDEMO.EXE b/FasmDll/DEMO/ASMDEMO.EXE new file mode 100644 index 0000000..adcadb1 Binary files /dev/null and b/FasmDll/DEMO/ASMDEMO.EXE differ diff --git a/FasmDll/DEMO/FASM.DLL b/FasmDll/DEMO/FASM.DLL new file mode 100644 index 0000000..0fa23a1 Binary files /dev/null and b/FasmDll/DEMO/FASM.DLL differ diff --git a/FasmDll/DEMO/FEDIT.DLL b/FasmDll/DEMO/FEDIT.DLL new file mode 100644 index 0000000..579e439 Binary files /dev/null and b/FasmDll/DEMO/FEDIT.DLL differ diff --git a/FasmDll/FASM.DLL b/FasmDll/FASM.DLL new file mode 100644 index 0000000..0fa23a1 Binary files /dev/null and b/FasmDll/FASM.DLL differ diff --git a/Source/Fasm4Delphi.pas b/Source/Fasm4Delphi.pas index b9bef81..6704693 100644 --- a/Source/Fasm4Delphi.pas +++ b/Source/Fasm4Delphi.pas @@ -69,21 +69,24 @@ type TLINE_HEADER=record file_path:PAnsiChar; line_number:cardinal; - file_offset:cardinal; - macro_calling_line:^TLINE_HEADER; - //macro_line:^TLINE_HEADER; + case byte of + 0:(file_offset:cardinal); + 1:(macro_calling_line:^TLINE_HEADER; + macro_line:^TLINE_HEADER;); end; PLINE_HEADER=^TLINE_HEADER; - +{$EXTERNALSYM TLINE_HEADER} + TFASM_STATE=record - condition:Int32; - error_code:Int32; - error_line:PLINE_HEADER; - //output_data:pointer; - //output_length:cardinal; + condition:Int32; + case byte of + 0:(error_code:Int32; + error_line:PLINE_HEADER;); + 1:(output_length:cardinal; + output_data:pointer; ); end; PFASM_STATE=^TFASM_STATE; -//{$EXTERNALSYM TFASM_STATE} +{$EXTERNALSYM TFASM_STATE} const FASMDLLName='FASM.DLL'; @@ -158,7 +161,7 @@ var {$ENDIF} {$IFNDEF FasmStaticLink} -procedure LoadFASM(Name:string); +procedure LoadFASM(Name:string=FASMDLLName); procedure FreeFASM; {$ENDIF} @@ -168,14 +171,21 @@ implementation var &Library:THandle=0; -procedure LoadFASM(Name:string); +procedure LoadFASM(Name:string=FASMDLLName); begin if &Library<>0 then FreeFasm; -&Library:=LoadLibrary(PWideChar(Name)); +{$IFDEF FPC} +&Library:=LoadLibrary(PChar(Name)); +Pointer(fasm_GetVersion):=GetProcAddress(&Library,'fasm_GetVersion'); +Pointer(fasm_Assemble):=GetProcAddress(&Library,'fasm_Assemble'); +Pointer(fasm_AssembleFile):=GetProcAddress(&Library,'fasm_AssembleFile'); +{$ELSE} +&Library:=LoadLibrary(PChar(Name)); fasm_GetVersion:=GetProcAddress(&Library,'fasm_GetVersion'); fasm_Assemble:=GetProcAddress(&Library,'fasm_Assemble'); -fasm_AssembleFile:=GetProcAddress(&Library,'fasm_AssembleFile'); +fasm_AssembleFile:=GetProcAddress(&Library,'fasm_AssembleFile'); +{$ENDIF} end; procedure FreeFASM; diff --git a/Tests/Tester.res b/Tests/Tester.res deleted file mode 100644 index 6876088..0000000 Binary files a/Tests/Tester.res and /dev/null differ diff --git a/Tests/Win32/Debug/dunitx-results.xml b/Tests/Win32/Debug/dunitx-results.xml deleted file mode 100644 index 97e9d13..0000000 --- a/Tests/Win32/Debug/dunitx-results.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> -<test-results name="W:\Fasm4Delphi\Tests\Win32\Debug\Tester.exe" total="4" errors="0" failures="0" ignored="0" inconclusive="0" not-run="0" skipped="0" invalid="0" date="2018-02-11" time="0.001"> - <culture-info current-culture="en" current-uiculture="en" /> - <test-suite type="Assembly" name="Tester.exe" executed="true" result="Success" success="True" time="0.001" asserts="0"> - <results> - <test-suite type="Namespace" name="TesterMain" executed="true" result="Success" success="True" time="0.001" asserts="0" > - <results> - <test-suite type="Fixture" name="TMyTestObject" executed="True" result="Success" success="True" time="0.001" > - <results> - <test-case name="Test1" executed="True" result="Success" success="True" time="0.000" asserts="0" /> - <test-case name="Test2" executed="True" result="Success" success="True" time="0.000" asserts="0" /> - <test-case name="Test3" executed="True" result="Success" success="True" time="0.000" asserts="0" /> - <test-case name="Test4" executed="True" result="Success" success="True" time="0.000" asserts="0" /> - </results> - </test-suite> - </results> - </test-suite> - </results> - </test-suite> -</test-results>