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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-