+ added an i8086-embedded target support to the compiler (RTL and makefile

support are not done yet)

git-svn-id: trunk@33999 -
This commit is contained in:
nickysn 2016-06-17 19:15:24 +00:00
parent e022ba1b53
commit c2305809dc
13 changed files with 133 additions and 28 deletions

View File

@ -41,6 +41,9 @@ implementation
{$ifndef NOTARGETWIN}
,t_win16
{$endif}
{$ifndef NOTARGETEMBEDDED}
,t_embed
{$endif}
{**************************************
Assemblers

View File

@ -2723,7 +2723,7 @@ implementation
idtxt : 'OMF';
asmbin : '';
asmcmd : '';
supported_targets : [system_i8086_msdos];
supported_targets : [system_i8086_msdos,system_i8086_embedded];
flags : [af_outputbinary,af_no_debug];
labelprefix : '..@';
comment : '; ';

View File

@ -2248,7 +2248,7 @@ begin
'm':
begin
{$if defined(i8086)}
if (target_info.system in [system_i8086_msdos,system_i8086_win16]) then
if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then
begin
case Upper(Copy(More,j+1,255)) of
'TINY': init_settings.x86memorymodel:=mm_tiny;
@ -2323,7 +2323,7 @@ begin
't':
begin
{$if defined(i8086)}
if (target_info.system in [system_i8086_msdos]) then
if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin
case Upper(Copy(More,j+1,255)) of
'EXE': SetAppType(app_cui);
@ -3085,7 +3085,7 @@ begin
{$endif i8086}
if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and
not(target_info.system in (systems_darwin+[system_i8086_msdos])) then
not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) then
begin
{ smartlink creation does not yet work with DWARF
debug info on most targets, but it works in internal assembler }

View File

@ -1165,7 +1165,7 @@ implementation
abssym.addroffset:=Tordconstnode(pt).value.svalue;
{$if defined(i386) or defined(i8086)}
tcpuabsolutevarsym(abssym).absseg:=false;
if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16]) and
if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) and
try_to_consume(_COLON) then
begin
pt.free;

View File

@ -2080,7 +2080,7 @@ implementation
begin
p2:=comp_expr([ef_accept_equal]);
{ support SEG:OFS for go32v2/msdos Mem[] }
if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16]) and
if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) and
(p1.nodetype=loadn) and
assigned(tloadnode(p1).symtableentry) and
assigned(tloadnode(p1).symtableentry.owner.name) and

View File

@ -28,7 +28,7 @@
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="239">
<Units Count="241">
<Unit0>
<Filename Value="pp.pas"/>
<IsPartOfProject Value="True"/>
@ -833,6 +833,7 @@
<Unit200>
<Filename Value="rautils.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="RAUtils"/>
</Unit200>
<Unit201>
<Filename Value="regvars.pas"/>
@ -986,6 +987,14 @@
<Filename Value="systems\t_win16.pas"/>
<IsPartOfProject Value="True"/>
</Unit238>
<Unit239>
<Filename Value="systems\i_embed.pas"/>
<IsPartOfProject Value="True"/>
</Unit239>
<Unit240>
<Filename Value="systems\t_embed.pas"/>
<IsPartOfProject Value="True"/>
</Unit240>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -282,7 +282,8 @@ unit scandir;
begin
if not (target_info.system in systems_all_windows + [system_i386_os2,
system_i386_emx, system_powerpc_macos,
system_arm_nds, system_i8086_msdos] +
system_arm_nds, system_i8086_msdos,
system_i8086_embedded] +
systems_nativent) then
begin
if m_delphi in current_settings.modeswitches then
@ -298,9 +299,9 @@ unit scandir;
begin
current_scanner.skipspace;
hs:=current_scanner.readid;
if (hs='GUI') and not (target_info.system in [system_i8086_msdos]) then
if (hs='GUI') and not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
SetApptype(app_gui)
else if (hs='CONSOLE') and not (target_info.system in [system_i8086_msdos]) then
else if (hs='CONSOLE') and not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
SetApptype(app_cui)
else if (hs='NATIVE') and (target_info.system in systems_windows + systems_nativent) then
SetApptype(app_native)
@ -313,9 +314,9 @@ unit scandir;
SetApptype(app_arm9)
else if (hs='ARM7') and (target_info.system in [system_arm_nds]) then
SetApptype(app_arm7)
else if (hs='COM') and (target_info.system in [system_i8086_msdos]) then
else if (hs='COM') and (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
SetApptype(app_com)
else if (hs='EXE') and (target_info.system in [system_i8086_msdos]) then
else if (hs='EXE') and (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
SetApptype(app_cui)
else
Message1(scan_w_unsupported_app_type,hs);
@ -438,7 +439,7 @@ unit scandir;
procedure dir_forcefarcalls;
begin
if (target_info.system<>system_i8086_msdos)
if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
{$ifdef i8086}
or (current_settings.x86memorymodel in x86_near_code_models)
{$endif i8086}
@ -1258,7 +1259,7 @@ unit scandir;
begin
do_moduleswitch(cs_create_smart);
if (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
not(target_info.system in (systems_darwin+[system_i8086_msdos])) and
not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) and
{ smart linking does not yet work with DWARF debug info on most targets }
(cs_create_smart in current_settings.moduleswitches) and
not (af_outputbinary in target_asm.flags) then
@ -1626,7 +1627,7 @@ unit scandir;
procedure dir_hugecode;
begin
if (target_info.system<>system_i8086_msdos)
if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
{$ifdef i8086}
or (current_settings.x86memorymodel in x86_near_code_models)
{$endif i8086}
@ -1642,7 +1643,7 @@ unit scandir;
var
hs : string;
begin
if target_info.system<>system_i8086_msdos then
if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin
Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERNORMALIZATION');
exit;
@ -1672,7 +1673,7 @@ unit scandir;
procedure dir_hugepointerarithmeticnormalization;
begin
if target_info.system<>system_i8086_msdos then
if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin
Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERARITHMETICNORMALIZATION');
exit;
@ -1682,7 +1683,7 @@ unit scandir;
procedure dir_hugepointercomparisonnormalization;
begin
if target_info.system<>system_i8086_msdos then
if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin
Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERCOMPARISONNORMALIZATION');
exit;

View File

@ -701,16 +701,16 @@ implementation
procedure SetAppType(NewAppType:tapptype);
begin
{$ifdef i8086}
if (target_info.system=system_i8086_msdos) and (apptype<>NewAppType) then
if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) and (apptype<>NewAppType) then
begin
if NewAppType=app_com then
begin
targetinfos[system_i8086_msdos]^.exeext:='.com';
targetinfos[target_info.system]^.exeext:='.com';
target_info.exeext:='.com';
end
else
begin
targetinfos[system_i8086_msdos]^.exeext:='.exe';
targetinfos[target_info.system]^.exeext:='.exe';
target_info.exeext:='.exe';
end;
end;

View File

@ -171,7 +171,8 @@
system_aarch64_darwin, { 86 }
system_x86_64_iphonesim, { 87 }
system_aarch64_linux, { 88 }
system_i8086_win16 { 89 }
system_i8086_win16, { 89 }
system_i8086_embedded { 90 }
);
type

View File

@ -22,6 +22,13 @@ unit i_embed;
{$i fpcdefs.inc}
{$ifdef go32v2}
{ As wlib uses a different Dos-Extender, long-command line
encoding for DJGPP does not work here.
Put all inside a script file instead }
{$define USE_SCRIPTED_WLIB}
{$endif}
interface
uses
@ -348,6 +355,75 @@ unit i_embed;
llvmdatalayout : 'e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128';
);
system_i8086_embedded_info : tsysteminfo =
(
system : system_i8086_embedded;
name : 'Embedded';
shortname : 'embedded';
flags : [tf_use_8_3,tf_smartlink_library,
tf_no_objectfiles_when_smartlinking,tf_cld,
tf_no_generic_stackcheck,tf_emit_stklen];
cpu : cpu_i8086;
unit_env : '';
extradefines : '';
exeext : '.exe';
defext : '.def';
scriptext : '.bat';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.dll';
staticlibext : '.a';
staticlibprefix : '';
sharedlibprefix : '';
sharedClibext : '.dll';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : '';
importlibprefix : '';
importlibext : '.al';
Cprefix : '_';
newline : #13#10;
dirsep : '\';
assem : as_i8086_omf;
assemextern : as_i8086_nasmobj;
link : ld_int_msdos;
linkextern : ld_msdos;
{$ifdef USE_SCRIPTED_WLIB}
ar : ar_watcom_wlib_omf_scripted;
{$else}
ar : ar_watcom_wlib_omf;
{$endif}
res : res_none;
dbg : dbg_dwarf2;
script : script_dos;
endian : endian_little;
alignment :
(
procalign : 1;
loopalign : 1;
jumpalign : 0;
constalignmin : 0;
constalignmax : 2;
varalignmin : 0;
varalignmax : 2;
localalignmin : 0;
localalignmax : 2;
recordalignmin : 0;
recordalignmax : 2;
maxCrecordalign : 2
);
first_parm_offset : 4;
stacksize : 0;
stackalign : 2;
abi : abi_default;
llvmdatalayout : 'todo';
);
implementation
initialization
@ -376,4 +452,9 @@ initialization
set_source_info(system_x86_64_embedded_info);
{$endif embedded}
{$endif CPUX86_64}
{$ifdef cpu8086}
{$ifdef embedded}
set_source_info(system_i8086_embedded_info);
{$endif embedded}
{$endif cpu8086}
end.

View File

@ -1487,6 +1487,14 @@ initialization
RegisterTarget(system_x86_64_embedded_info);
{$endif x86_64}
{$ifdef i8086}
{ no need to register linker ld_embedded, because i8086_embedded uses the
regular msdos linker. In case a flat binary, relocated for a specific
segment address is needed (e.g. for a BIOS or a real mode bootloader), it
can be produced post-compilation with exe2bin or a similar tool. }
RegisterTarget(system_i8086_embedded_info);
{$endif i8086}
{$ifdef mipsel}
RegisterLinker(ld_embedded,TLinkerEmbedded);
RegisterTarget(system_mipsel_embedded_info);

View File

@ -173,7 +173,8 @@ const
{ 86 } 'Darwin-AArch64',
{ 87 } 'iPhoneSim-x86-64',
{ 88 } 'Linux-AArch64',
{ 89 } 'Win16'
{ 89 } 'Win16',
{ 90 } 'Embedded-i8086'
);
const

View File

@ -581,7 +581,7 @@ interface
else if (atype=sec_threadvar) and
(target_info.system in (systems_windows+systems_wince)) then
writer.AsmWrite('.tls'#9'bss')
else if target_info.system in [system_i8086_msdos,system_i8086_win16] then
else if target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded] then
begin
if secnames[atype]='.text' then
secname:=CodeSectionName(aname)
@ -643,7 +643,7 @@ interface
{$endif i8086}
begin
{$ifdef i8086}
if target_info.system in [system_i8086_msdos,system_i8086_win16] then
if target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded] then
begin
if current_settings.x86memorymodel=mm_huge then
WriteSection(sec_data,'',2);
@ -1251,7 +1251,8 @@ interface
{$ifdef i8086}
case target_info.system of
system_i8086_msdos,
system_i8086_win16:
system_i8086_win16,
system_i8086_embedded:
FormatName:='obj';
else
internalerror(2014082060);
@ -1304,7 +1305,7 @@ interface
idtxt : 'NASM';
asmbin : 'nasm';
asmcmd : '-f $FORMAT -o $OBJ -w-orphan-labels $EXTRAOPT $ASM';
supported_targets : [system_i8086_msdos,system_i8086_win16];
supported_targets : [system_i8086_msdos,system_i8086_win16,system_i8086_embedded];
flags : [af_needar,af_no_debug];
labelprefix : '..@';
comment : '; ';
@ -1316,7 +1317,7 @@ interface
idtxt : 'NASMOBJ';
asmbin : 'nasm';
asmcmd : '-f obj -o $OBJ -w-orphan-labels $EXTRAOPT $ASM';
supported_targets : [system_i8086_msdos,system_i8086_win16];
supported_targets : [system_i8086_msdos,system_i8086_win16,system_i8086_embedded];
flags : [af_needar,af_no_debug];
labelprefix : '..@';
comment : '; ';