📄 unit1.pas
字号:
writeln(OuI,';'); {write to inline assembler source file}
HasAssembler := True;
end;
writeln(OuP,s); {write to Pascal51 source file}
i := Pos('PROCEDURE',wS);
i := i + 10;
j := Pos(';',wS);
procname := copy(ws,i,j-i);
procname := trim(procname);
HitList.Add(procname);
procname := procname + ':';
writeln(OuI,procname); {write to inline assembler source file}
Listbox1.items.add('Assembler procedure ' + procname + ' processed.');
readln(InF,wS);
wS1 := UpperCase(wS);
while Pos('END;',wS1) = 0 do
begin
if Pos('BEGIN',wS1) <> 0 then
writeln(OuP,wS) {write to Pascal51 source file}
else
begin
writeln(OuP,'{ ',wS, ' }'); {write to Pascal51 source file}
writeln(OuI,wS); {write to inline assembler source file}
end;
readln(InF,wS);
wS1 := UpperCase(wS);
end;
writeln(OuI,';'); {write to inline assembler source file}
s := wS;
end
else convert_char(s); {deal with changing all 'n' to ascii values}
writeln(OuP,s); {write to Pascal51 source file}
end;
procedure TForm1.btnPreProcessClick(Sender: TObject);
var
s : string;
outname, fPath, fName : string;
begin
ListBox1.clear;
if FileExists(ProjPath) then
begin
Hitlist := TStringList.Create; {list of 'External' procedures}
AssignFile(InF, ProjPath); { Current project }
Reset(InF);
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3);
OutName := fPath + fName + 'p51';
AssignFile(OuP, OutName); { File selected in dialog box }
Rewrite(OuP);
OutName := fPath + fName + 'asi';
AssignFile(OuA, OutName); { File selected in dialog box }
Rewrite(OuA);
StrProcessed := False; {haven't done any strings}
HasAssembler := False; {inline assembler not found yet}
While not eof(InF) do
begin
Readln(InF, S); { Read the first line out of the file }
if (Pos('Strings',S) > 0) and not StrProcessed then
ProcessStrings
else
WriteItOut(S);
end;
CloseFile(InF);
CloseFile(OuP);
CloseFile(OuA);
if HasAssembler then CloseFile(OuI); {if any InLine Assembler found}
end
else
showmessage('Project (.p80) file not found! - Double click on Project label to select a project.');
end;
procedure TForm1.btnPostProcessClick(Sender: TObject);
var
s : string;
outname, fPath, fName : string;
begin
{read in a a51 file and merge in .asi (strings include) file.}
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
OutName := fPath + fName + 'a51';
AssignFile(InA, OutName); { Pascal51 generated asm file }
Reset(InA);
OutName := fPath + fName + 'asi';
AssignFile(InS, OutName); { Generated strings include file }
Reset(InS);
OutName := fPath + fName + 'ila';
AssignFile(Oui, OutName); { Generated inline assembler include file }
Reset(Oui);
OutName := fPath + fName + 'a80';
AssignFile(OuA, OutName); { Generated final asm file }
Rewrite(OuA);
While not eof(InA) do {while not end of .a51 file}
begin
Readln(InA, S);
if not (S[1] in [' ',';']) and (Pos(':',S) <> 0) then
ProcessLabel(S)
else if Pos('----- End Of Pascal51 Relocate Segment -----',S) <> 0 then {insert .ila}
ProcessIla {insert the .ila file}
else if Pos(chr(9) + 'END' + chr(9),S) <> 0 then {end of .a51 file}
ProcessInclude {append the .asi file to the .a80 file}
else
writeln(OuA,S);
end;
Listbox1.items.add('Finished processing assembler file');
CloseFile(InA);
CloseFile(InS);
CloseFile(OuA);
CloseFile(Oui);
Hitlist.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
appIni := TInifile.Create('pascal80.ini');
CompilerPath := appIni.ReadString('compiler','path','Double click here to select Pascal51 Compiler path');
lblCpath.Caption := 'Compiler : ' + CompilerPath;
Asm51Path := appIni.ReadString('assembler','path','Double click here to select ASM51 path');
lblApath.Caption := 'Assembler : ' + Asm51Path;
ProjPath := appIni.ReadString('project','path','Double click here to select a project (.p80) file');
lblProject.Caption := 'Project : ' + ProjPath;
end;
procedure TForm1.lblProjectDblClick(Sender: TObject);
begin
OpenDialog1.Filter := 'Pascal80 Project file|*.p80';
if OpenDialog1.Execute then { Display Open dialog box }
begin
Appini.WriteString('project','path',OpenDialog1.FileName); { File selected in dialog box }
ProjPath := OpenDialog1.FileName;
lblProject.Caption := 'Project : ' + ProjPath;
end;
end;
procedure TForm1.btnEditClick(Sender: TObject);
begin
ExecuteFile(ProjPath, '','', SW_SHOW);
end;
procedure TForm1.btnCompileClick(Sender: TObject);
var
fPath, fName, aName, lName, sOptions : string;
begin
if FileExists(CompilerPath) then
begin
sOptions := '';
if form2.ckbDebug.State = cbChecked then sOptions := sOptions + '-d ';
if form2.ckbStop.State = cbChecked then sOptions := sOptions + '-e ';
sOptions := sOptions + '-x' + form2.edtStart.text;
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
aName := fName + 'a51';
lName := fName + 'l51';
fName := fName + 'p51';
ExecuteFile(CompilerPath , sOptions + ' ' + fName + ' ' + aName + ' ' + lName, fPath, SW_SHOW);
end
else
ShowMessage('Pascal Compiler .exe file not found! - Double click on the compiler label to locate it.');
end;
procedure TForm1.btnViewl51Click(Sender: TObject);
var
fPath, fName : string;
begin
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
fName := fName + 'l51';
ExecuteFile(fPath + fName, '','', SW_SHOW);
end;
procedure TForm1.btnViewa51Click(Sender: TObject);
var
fPath, fName : string;
begin
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
fName := fName + 'lst';
ExecuteFile(fPath + fName, '','', SW_SHOW);
end;
procedure TForm1.btnAssembleClick(Sender: TObject);
var
fPath, fName : string;
begin
if FileExists(Asm51Path) then
begin
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
fName := fName + 'a80';
ExecuteFile(Asm51Path , fName, fPath, SW_SHOW);
end
else
ShowMessage('8051 Assembler .exe file not found! - double click assembler label to locate.');
end;
procedure TForm1.lblCpathDblClick(Sender: TObject);
begin
Form2.Show;
end;
procedure TForm1.lblApathDblClick(Sender: TObject);
begin
OpenDialog1.Filter := 'ASM51 assembler .exe file|*.exe';
if OpenDialog1.Execute then { Display Open dialog box }
begin
Appini.WriteString('assembler','path',OpenDialog1.FileName); { File selected in dialog box }
Asm51Path := OpenDialog1.FileName;
lblApath.Caption := 'Assembler : ' + Asm51Path;
end;
end;
procedure TForm1.btnLinkClick(Sender: TObject);
var
fPath, fName, Bat51Path : string;
begin
fPath := ExtractFilePath(ProjPath);
fName := ExtractFileName(ProjPath);
fName := Copy(fName,1,length(fName)-3); {remove file extension - 3 chars only}
fName := fName + 'bat';
Bat51Path := fPath + fName;
if FileExists(Bat51Path) then
ExecuteFile(Bat51Path , fName, fPath, SW_SHOW)
else
showmessage('Batch file ' + Bat51Path + ' not found! - You have to create this file yourself.');
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
application.terminate;
end;
procedure TForm1.About1Click(Sender: TObject);
begin
AboutBox.Show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -