Add FPC Compabulity
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
<PackageName Value="FCL"/>
|
<PackageName Value="FCL"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="3">
|
<Units Count="4">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="fpcunitproject1.lpr"/>
|
<Filename Value="fpcunitproject1.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@@ -50,9 +50,13 @@
|
|||||||
<UnitName Value="TestCase1"/>
|
<UnitName Value="TestCase1"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="..\Source\Fasm4Delphi.pas"/>
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="..\Fasm4Delphi\Source\Fasm4Delphi.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit3>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
@@ -60,11 +64,11 @@
|
|||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<OtherUnitFiles Value="..\Source"/>
|
<OtherUnitFiles Value="..\Source;..\Fasm4Delphi\Source"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<Exceptions Count="3">
|
<Exceptions Count="4">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Name Value="EAbort"/>
|
<Name Value="EAbort"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
@@ -74,6 +78,9 @@
|
|||||||
<Item3>
|
<Item3>
|
||||||
<Name Value="EFOpenError"/>
|
<Name Value="EFOpenError"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
|
<Item4>
|
||||||
|
<Name Value="EOSError"/>
|
||||||
|
</Item4>
|
||||||
</Exceptions>
|
</Exceptions>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
|||||||
@@ -4,37 +4,217 @@
|
|||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<Version Value="10"/>
|
<Version Value="10"/>
|
||||||
<BuildModes Active="Default"/>
|
<BuildModes Active="Default"/>
|
||||||
<Units Count="3">
|
<Units Count="11">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="fpcunitproject1.lpr"/>
|
<Filename Value="fpcunitproject1.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<EditorIndex Value="-1"/>
|
|
||||||
<CursorPos X="66" Y="6"/>
|
<CursorPos X="66" Y="6"/>
|
||||||
<UsageCount Value="20"/>
|
<UsageCount Value="22"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="testcase1.pas"/>
|
<Filename Value="testcase1.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="TestCase1"/>
|
<UnitName Value="TestCase1"/>
|
||||||
<IsVisibleTab Value="True"/>
|
<EditorIndex Value="1"/>
|
||||||
<EditorIndex Value="-1"/>
|
<TopLine Value="17"/>
|
||||||
<TopLine Value="21"/>
|
<CursorPos X="67" Y="29"/>
|
||||||
<CursorPos X="62" Y="41"/>
|
<UsageCount Value="22"/>
|
||||||
<UsageCount Value="20"/>
|
<Loaded Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="..\Source\Fasm4Delphi.pas"/>
|
<Filename Value="..\Source\Fasm4Delphi.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<EditorIndex Value="-1"/>
|
<EditorIndex Value="-1"/>
|
||||||
<WindowIndex Value="-1"/>
|
<WindowIndex Value="-1"/>
|
||||||
<TopLine Value="-1"/>
|
<TopLine Value="-1"/>
|
||||||
<CursorPos X="-1" Y="-1"/>
|
<CursorPos X="-1" Y="-1"/>
|
||||||
<UsageCount Value="20"/>
|
<UsageCount Value="20"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="..\..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<WindowIndex Value="-1"/>
|
||||||
|
<TopLine Value="-1"/>
|
||||||
|
<CursorPos X="-1" Y="-1"/>
|
||||||
|
<UsageCount Value="20"/>
|
||||||
|
</Unit3>
|
||||||
|
<Unit4>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<EditorIndex Value="2"/>
|
||||||
|
<TopLine Value="217"/>
|
||||||
|
<CursorPos Y="234"/>
|
||||||
|
<UsageCount Value="22"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit4>
|
||||||
|
<Unit5>
|
||||||
|
<Filename Value="..\Fasm4Delphi\Source\Fasm4Delphi.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<EditorIndex Value="4"/>
|
||||||
|
<TopLine Value="16"/>
|
||||||
|
<CursorPos X="3" Y="31"/>
|
||||||
|
<UsageCount Value="22"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit5>
|
||||||
|
<Unit6>
|
||||||
|
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\varianth.inc"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="484"/>
|
||||||
|
<CursorPos X="12" Y="496"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit6>
|
||||||
|
<Unit7>
|
||||||
|
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\wstringh.inc"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="2"/>
|
||||||
|
<CursorPos X="11" Y="19"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit7>
|
||||||
|
<Unit8>
|
||||||
|
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\ustringh.inc"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="2"/>
|
||||||
|
<CursorPos X="11" Y="19"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit8>
|
||||||
|
<Unit9>
|
||||||
|
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\systemh.inc"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="1068"/>
|
||||||
|
<CursorPos X="17" Y="1086"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit9>
|
||||||
|
<Unit10>
|
||||||
|
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\win\wininc\base.inc"/>
|
||||||
|
<EditorIndex Value="3"/>
|
||||||
|
<TopLine Value="140"/>
|
||||||
|
<CursorPos X="6" Y="169"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit10>
|
||||||
</Units>
|
</Units>
|
||||||
<General>
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<ActiveWindowIndexAtStart Value="-1"/>
|
<Position1>
|
||||||
</General>
|
<Filename Value="testcase1.pas"/>
|
||||||
<JumpHistory HistoryIndex="-1"/>
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="429" Column="56" TopLine="427"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="185" Column="44" TopLine="170"/>
|
||||||
|
</Position4>
|
||||||
|
<Position5>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position5>
|
||||||
|
<Position6>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="185" Column="35" TopLine="174"/>
|
||||||
|
</Position6>
|
||||||
|
<Position7>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="188" Column="24" TopLine="171"/>
|
||||||
|
</Position7>
|
||||||
|
<Position8>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="198" Column="20" TopLine="180"/>
|
||||||
|
</Position8>
|
||||||
|
<Position9>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position9>
|
||||||
|
<Position10>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="549" TopLine="533"/>
|
||||||
|
</Position10>
|
||||||
|
<Position11>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="539" TopLine="533"/>
|
||||||
|
</Position11>
|
||||||
|
<Position12>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position12>
|
||||||
|
<Position13>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="537" Column="8" TopLine="533"/>
|
||||||
|
</Position13>
|
||||||
|
<Position14>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="185" Column="56" TopLine="169"/>
|
||||||
|
</Position14>
|
||||||
|
<Position15>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="33" TopLine="17"/>
|
||||||
|
</Position15>
|
||||||
|
<Position16>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="23" Column="11" TopLine="17"/>
|
||||||
|
</Position16>
|
||||||
|
<Position17>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="174" Column="17" TopLine="157"/>
|
||||||
|
</Position17>
|
||||||
|
<Position18>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="217" Column="6" TopLine="201"/>
|
||||||
|
</Position18>
|
||||||
|
<Position19>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="621" Column="58" TopLine="599"/>
|
||||||
|
</Position19>
|
||||||
|
<Position20>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="355" Column="29" TopLine="336"/>
|
||||||
|
</Position20>
|
||||||
|
<Position21>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="217" Column="5" TopLine="194"/>
|
||||||
|
</Position21>
|
||||||
|
<Position22>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="226" Column="32" TopLine="205"/>
|
||||||
|
</Position22>
|
||||||
|
<Position23>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="27" TopLine="17"/>
|
||||||
|
</Position23>
|
||||||
|
<Position24>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="23" Column="60" TopLine="17"/>
|
||||||
|
</Position24>
|
||||||
|
<Position25>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="27" TopLine="17"/>
|
||||||
|
</Position25>
|
||||||
|
<Position26>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="234" TopLine="217"/>
|
||||||
|
</Position26>
|
||||||
|
<Position27>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="23" Column="59" TopLine="17"/>
|
||||||
|
</Position27>
|
||||||
|
<Position28>
|
||||||
|
<Filename Value="testcase1.pas"/>
|
||||||
|
<Caret Line="29" Column="67" TopLine="17"/>
|
||||||
|
</Position28>
|
||||||
|
<Position29>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="234" TopLine="217"/>
|
||||||
|
</Position29>
|
||||||
|
<Position30>
|
||||||
|
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||||
|
<Caret Line="539" TopLine="523"/>
|
||||||
|
</Position30>
|
||||||
|
</JumpHistory>
|
||||||
</ProjectSession>
|
</ProjectSession>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
|||||||
BIN
FPCTests/test
Normal file
BIN
FPCTests/test
Normal file
Binary file not shown.
@@ -5,7 +5,7 @@ unit TestCase1;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, fpcunit, testutils, testregistry,Fasm4Delphi;
|
Classes, SysUtils, fpcunit, testutils, testregistry,FasmOnDelphi;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@@ -16,36 +16,35 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
|
||||||
CompliterMemSize=$10000;
|
|
||||||
|
|
||||||
var
|
|
||||||
CompliterMem:PFASM_STATE;
|
|
||||||
|
|
||||||
procedure TTestCase1.TestHookUp;
|
procedure TTestCase1.TestHookUp;
|
||||||
|
var
|
||||||
|
Res:TFasmResult;
|
||||||
begin
|
begin
|
||||||
if fasm_AssembleFile('..\Tests\Test1.asm',CompliterMem,CompliterMemSize)<>FASM_OK then
|
Res:=FasmAssembleFileToFile('..\Tests\Test1.ASM','..\Tests\Test1.bin');
|
||||||
Fail('Error in test1:'+sLineBreak+
|
if Res.Error<>FASM_OK then
|
||||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
Fail('Error in test1:'+sLineBreak+
|
||||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
'Condition: '+Res.OutStr+sLineBreak+
|
||||||
if fasm_Assemble('add eax,0',CompliterMem,CompliterMemSize)<>FASM_OK then
|
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||||
writeln('Error in test2:'+sLineBreak+
|
Res:=FasmAssemble('add eax,0');
|
||||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
if Res.Error<>FASM_OK then
|
||||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
Fail('Error in test2:'+sLineBreak+
|
||||||
if fasm_AssembleFile('..\FasmDll\FASM.ASH',CompliterMem,CompliterMemSize)=FASM_OK then
|
'Condition: '+Res.OutStr+sLineBreak+
|
||||||
Fail('Error in test3:'+sLineBreak+
|
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||||
'FASM is compiling something that it is can not compile at all.');
|
Res:=FasmAssembleFile('..\Fasm4Delphi\FasmDll\FASM.ASH');
|
||||||
if fasm_Assemble('call -100',CompliterMem,CompliterMemSize)<>FASM_OK then
|
if Res.Error=FASM_OK then
|
||||||
Fail('Error in test4:'+sLineBreak+
|
Fail('Error in test3:'+sLineBreak+
|
||||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
'FASM is compiling something that it is can not compile at all.');
|
||||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
Res:=FasmAssembleToFile('add eax,0','test');
|
||||||
|
if Res.Error<>FASM_OK then
|
||||||
|
Fail('Error in test4:'+sLineBreak+
|
||||||
|
'Condition: '+Res.OutStr+sLineBreak+
|
||||||
|
'Error Code:'+IntToStr(Res.Error)+sLineBreak);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
LoadFASM('..\FasmDll\FASM.DLL');
|
OpenFASM('..\fasmw172\FASM.EXE');
|
||||||
GetMem(CompliterMem,CompliterMemSize);
|
|
||||||
RegisterTest(TTestCase1);
|
RegisterTest(TTestCase1);
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
unit FasmOnDelphi platform;
|
unit FasmOnDelphi;
|
||||||
|
|
||||||
{Delphi Translation&Tests:Artyom Gavrilov,Vlad Untkin.
|
{Delphi Translation&Tests:Artyom Gavrilov,Vlad Untkin.
|
||||||
Donate:https://money.yandex.ru/to/410014959153552}
|
Donate:https://money.yandex.ru/to/410014959153552}
|
||||||
@@ -20,9 +20,9 @@ interface
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
System.SysUtils,
|
SysUtils,
|
||||||
{$IFDEF USEFasm4Delphi}Fasm4Delphi,{$ENDIF}
|
{$IFDEF USEFasm4Delphi}Fasm4Delphi,{$ENDIF}
|
||||||
{$IFDEF USEIOUtils}System.IOUtils{$ENDIF},Windows,Math;
|
{$IFDEF USEIOUtils}System.IOUtils,{$ENDIF}Windows,Math;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFasmVersion={$IFDEF USEFasm4Delphi}Fasm4Delphi.TFasmVersion;
|
TFasmVersion={$IFDEF USEFasm4Delphi}Fasm4Delphi.TFasmVersion;
|
||||||
@@ -178,12 +178,51 @@ procedure SetFasmTemp(Path:string);
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
function GetLongPathNameA(lpszShortPath: LPSTR; lpszLongPath: LPSTR;
|
||||||
|
cchBuffer: DWORD): DWORD; stdcall;external 'Kernel32.dll';
|
||||||
|
|
||||||
|
function Pos(const SubStr,Str:AnsiString;Offset:Integer): Integer; overload;
|
||||||
|
var
|
||||||
|
I, LIterCnt, L, J: Integer;
|
||||||
|
PSubStr, PS: PAnsiChar;
|
||||||
|
begin
|
||||||
|
L := Length(SubStr);
|
||||||
|
{ Calculate the number of possible iterations. Not valid if Offset < 1. }
|
||||||
|
LIterCnt := Length(Str) - Offset - L + 1;
|
||||||
|
|
||||||
|
{ Only continue if the number of iterations is positive or zero (there is space to check) }
|
||||||
|
if (Offset > 0) and (LIterCnt >= 0) and (L > 0) then
|
||||||
|
begin
|
||||||
|
PSubStr := PAnsiChar(SubStr);
|
||||||
|
PS := PAnsiChar(Str);
|
||||||
|
Inc(PS, Offset - 1);
|
||||||
|
|
||||||
|
for I := 0 to LIterCnt do
|
||||||
|
begin
|
||||||
|
J := 0;
|
||||||
|
while (J >= 0) and (J < L) do
|
||||||
|
begin
|
||||||
|
if PS[I + J] = PSubStr[J] then
|
||||||
|
Inc(J)
|
||||||
|
else
|
||||||
|
J := -1;
|
||||||
|
end;
|
||||||
|
if J >= L then
|
||||||
|
Exit(I + Offset);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
var
|
var
|
||||||
FasmLocation:string='FASM';
|
FasmLocation:string='FASM';
|
||||||
FasmTemp:string;
|
FasmTemp:string;
|
||||||
IsDll:boolean=false;
|
IsDll:boolean=false;
|
||||||
|
|
||||||
function RunFasm(Command:string):string;
|
function RunFasm(Command:AnsiString):string;
|
||||||
var
|
var
|
||||||
StartupInfo:TStartupInfo;
|
StartupInfo:TStartupInfo;
|
||||||
ProcessInformation:TProcessInformation;
|
ProcessInformation:TProcessInformation;
|
||||||
@@ -227,7 +266,7 @@ var
|
|||||||
begin
|
begin
|
||||||
{$IFDEF USEFasm4Delphi}
|
{$IFDEF USEFasm4Delphi}
|
||||||
if IsDll then
|
if IsDll then
|
||||||
Result:=fasm_GetVersion
|
Result:=fasm_GetVersion()
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@@ -273,26 +312,26 @@ begin
|
|||||||
Result.Error:=fasm_Assemble(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
Result.Error:=fasm_Assemble(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
GetMem(Result.OutData,Mem.output_length);
|
GetMem(Result.OutData,Mem^.output_length);
|
||||||
CopyMemory(Result.OutData,Mem.output_data,Mem.output_length);
|
CopyMemory(Result.OutData,Mem^.output_data,Mem^.output_length);
|
||||||
Result.sb:=Mem.output_length;
|
Result.sb:=Mem^.output_length;
|
||||||
Result.OutStr:='Success.';
|
Result.OutStr:='Success.';
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result.OutData:=nil;
|
Result.OutData:=nil;
|
||||||
Result.sb:=0;
|
Result.sb:=0;
|
||||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||||
p:=Mem.error_line;
|
p:=Mem^.error_line;
|
||||||
nr:=0;
|
nr:=0;
|
||||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||||
begin
|
begin
|
||||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||||
inc(nr);
|
inc(nr);
|
||||||
SetLength(Result.Lines,nr);
|
SetLength(Result.Lines,nr);
|
||||||
Result.Lines[nr-1].Line:=p.line_number;
|
Result.Lines[nr-1].Line:=p^.line_number;
|
||||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||||
p:=p^.macro_calling_line;
|
p:=p^.macro_calling_line;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -318,7 +357,7 @@ begin
|
|||||||
Result.Error:=i0;
|
Result.Error:=i0;
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
FileHandle:=CreateFile(PWideChar(s),GENERIC_READ,0,nil,3,128,0);
|
FileHandle:=CreateFile(PChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||||
Result.sb:=GetFileSize(FileHandle,nil);
|
Result.sb:=GetFileSize(FileHandle,nil);
|
||||||
getmem(Result.OutData,Result.sb);
|
getmem(Result.OutData,Result.sb);
|
||||||
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
||||||
@@ -375,24 +414,24 @@ begin
|
|||||||
Result.sb:=0;
|
Result.sb:=0;
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
FileHandle:=CreateFile(PWideChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
FileHandle:=CreateFile(PChar(OutFile),GENERIC_WRITE,0,nil,3,128,0);
|
||||||
WriteFile(FileHandle,Mem.output_data^,Mem.output_length,nr,nil);
|
WriteFile(FileHandle,Mem^.output_data^,Mem^.output_length,nr,nil);
|
||||||
CloseHandle(FileHandle);
|
CloseHandle(FileHandle);
|
||||||
Result.OutStr:='Success.';
|
Result.OutStr:='Success.';
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||||
p:=Mem.error_line;
|
p:=Mem^.error_line;
|
||||||
nr:=0;
|
nr:=0;
|
||||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||||
begin
|
begin
|
||||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||||
inc(nr);
|
inc(nr);
|
||||||
SetLength(Result.Lines,nr);
|
SetLength(Result.Lines,nr);
|
||||||
Result.Lines[nr-1].Line:=p.line_number;
|
Result.Lines[nr-1].Line:=p^.line_number;
|
||||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||||
p:=p^.macro_calling_line;
|
p:=p^.macro_calling_line;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -464,26 +503,26 @@ begin
|
|||||||
Result.Error:=fasm_AssembleFile(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
Result.Error:=fasm_AssembleFile(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
GetMem(Result.OutData,Mem.output_length);
|
GetMem(Result.OutData,Mem^.output_length);
|
||||||
CopyMemory(Result.OutData,Mem.output_data,Mem.output_length);
|
CopyMemory(Result.OutData,Mem^.output_data,Mem^.output_length);
|
||||||
Result.sb:=Mem.output_length;
|
Result.sb:=Mem^.output_length;
|
||||||
Result.OutStr:='Success.';
|
Result.OutStr:='Success.';
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result.OutData:=nil;
|
Result.OutData:=nil;
|
||||||
Result.sb:=0;
|
Result.sb:=0;
|
||||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||||
p:=Mem.error_line;
|
p:=Mem^.error_line;
|
||||||
nr:=0;
|
nr:=0;
|
||||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||||
begin
|
begin
|
||||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||||
inc(nr);
|
inc(nr);
|
||||||
SetLength(Result.Lines,nr);
|
SetLength(Result.Lines,nr);
|
||||||
Result.Lines[nr-1].Line:=p.line_number;
|
Result.Lines[nr-1].Line:=p^.line_number;
|
||||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||||
p:=p^.macro_calling_line;
|
p:=p^.macro_calling_line;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -505,7 +544,7 @@ begin
|
|||||||
Result.Error:=i0;
|
Result.Error:=i0;
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
FileHandle:=CreateFile(PWideChar(s),GENERIC_READ,0,nil,3,128,0);
|
FileHandle:=CreateFile(PChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||||
Result.sb:=GetFileSize(FileHandle,nil);
|
Result.sb:=GetFileSize(FileHandle,nil);
|
||||||
getmem(Result.OutData,Result.sb);
|
getmem(Result.OutData,Result.sb);
|
||||||
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
||||||
@@ -562,8 +601,8 @@ begin
|
|||||||
Result.sb:=0;
|
Result.sb:=0;
|
||||||
if Result.Error=FASM_OK then
|
if Result.Error=FASM_OK then
|
||||||
begin
|
begin
|
||||||
FileHandle:=CreateFile(PWideChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
FileHandle:=CreateFile(PChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
||||||
WriteFile(FileHandle,Mem.output_data^,Mem.output_length,nr,nil);
|
WriteFile(FileHandle,Mem^.output_data^,Mem^.output_length,nr,nil);
|
||||||
CloseHandle(FileHandle);
|
CloseHandle(FileHandle);
|
||||||
Result.OutStr:='Success.';
|
Result.OutStr:='Success.';
|
||||||
end
|
end
|
||||||
@@ -571,17 +610,17 @@ begin
|
|||||||
begin
|
begin
|
||||||
Result.OutData:=nil;
|
Result.OutData:=nil;
|
||||||
Result.sb:=0;
|
Result.sb:=0;
|
||||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||||
p:=Mem.error_line;
|
p:=Mem^.error_line;
|
||||||
nr:=0;
|
nr:=0;
|
||||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||||
begin
|
begin
|
||||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||||
inc(nr);
|
inc(nr);
|
||||||
SetLength(Result.Lines,nr);
|
SetLength(Result.Lines,nr);
|
||||||
Result.Lines[nr-1].Line:=p.line_number;
|
Result.Lines[nr-1].Line:=p^.line_number;
|
||||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||||
p:=p^.macro_calling_line;
|
p:=p^.macro_calling_line;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -658,12 +697,12 @@ initialization
|
|||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
begin
|
begin
|
||||||
SetLength(Result,MAX_PATH);
|
SetLength(FasmTemp,MAX_PATH);
|
||||||
Len:=GetTempPath(MAX_PATH,PChar(FasmTemp));
|
Len:=GetTempPath(MAX_PATH,PChar(FasmTemp));
|
||||||
if Len<>0 then
|
if Len<>0 then
|
||||||
begin
|
begin
|
||||||
Len:=GetLongPathName(PChar(FasmTemp),nil,0);
|
Len:=GetLongPathNameA(PChar(FasmTemp),nil,0);
|
||||||
GetLongPathName(PChar(FasmTemp),PChar(FasmTemp),Len);
|
GetLongPathNameA(PChar(FasmTemp),PChar(FasmTemp),Len);
|
||||||
SetLength(FasmTemp,Len-1);
|
SetLength(FasmTemp,Len-1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,12 +22,6 @@ type
|
|||||||
[Test]
|
[Test]
|
||||||
procedure Test4;
|
procedure Test4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
CompliterMemSize=$10000;
|
|
||||||
|
|
||||||
var
|
|
||||||
CompliterMem:PFASM_STATE;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -45,8 +39,8 @@ var
|
|||||||
begin
|
begin
|
||||||
Res:=FasmAssembleFileToFile('..\..\Test1.ASM','..\..\Test1..bin');
|
Res:=FasmAssembleFileToFile('..\..\Test1.ASM','..\..\Test1..bin');
|
||||||
if Res.Error<>FASM_OK then
|
if Res.Error<>FASM_OK then
|
||||||
raise Exception.Create('Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
||||||
'Error Code: '+CompliterMem^.error_code.ToString+sLineBreak);
|
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMyTestObject.Test2;
|
procedure TMyTestObject.Test2;
|
||||||
@@ -74,12 +68,11 @@ var
|
|||||||
begin
|
begin
|
||||||
Res:=FasmAssembleToFile('add eax,0','test');
|
Res:=FasmAssembleToFile('add eax,0','test');
|
||||||
if Res.Error<>FASM_OK then
|
if Res.Error<>FASM_OK then
|
||||||
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
||||||
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
'Error Code:'+IntToStr(Res.Error)+sLineBreak);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||||
OpenFASM('..\..\..\fasmw172\FASM.EXE');
|
OpenFASM('..\..\..\fasmw172\FASM.EXE');
|
||||||
GetMem(CompliterMem,CompliterMemSize);
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
Reference in New Issue
Block a user