diff --git a/compiler/i8086/cputarg.pas b/compiler/i8086/cputarg.pas
index 03bdd4c933..6c4ca06610 100644
--- a/compiler/i8086/cputarg.pas
+++ b/compiler/i8086/cputarg.pas
@@ -41,6 +41,9 @@ implementation
{$ifndef NOTARGETWIN}
,t_win16
{$endif}
+ {$ifndef NOTARGETEMBEDDED}
+ ,t_embed
+ {$endif}
{**************************************
Assemblers
diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas
index 92166687ee..555844b6e0 100644
--- a/compiler/ogomf.pas
+++ b/compiler/ogomf.pas
@@ -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 : '; ';
diff --git a/compiler/options.pas b/compiler/options.pas
index 554264c1e7..8396bb9da8 100644
--- a/compiler/options.pas
+++ b/compiler/options.pas
@@ -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 }
diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas
index c8c56234f1..501ea5dc00 100644
--- a/compiler/pdecvar.pas
+++ b/compiler/pdecvar.pas
@@ -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;
diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas
index 6f5bb788f9..113a66c8e2 100644
--- a/compiler/pexpr.pas
+++ b/compiler/pexpr.pas
@@ -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
diff --git a/compiler/ppc8086.lpi b/compiler/ppc8086.lpi
index 1fad98a607..462074c9f2 100644
--- a/compiler/ppc8086.lpi
+++ b/compiler/ppc8086.lpi
@@ -28,7 +28,7 @@
-
+
@@ -833,6 +833,7 @@
+
@@ -986,6 +987,14 @@
+
+
+
+
+
+
+
+
diff --git a/compiler/scandir.pas b/compiler/scandir.pas
index 32f193f74d..a9db1ddd19 100644
--- a/compiler/scandir.pas
+++ b/compiler/scandir.pas
@@ -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;
diff --git a/compiler/scanner.pas b/compiler/scanner.pas
index f23db71695..86c956d830 100644
--- a/compiler/scanner.pas
+++ b/compiler/scanner.pas
@@ -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;
diff --git a/compiler/systems.inc b/compiler/systems.inc
index 75ccd91bbc..744afcd685 100644
--- a/compiler/systems.inc
+++ b/compiler/systems.inc
@@ -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
diff --git a/compiler/systems/i_embed.pas b/compiler/systems/i_embed.pas
index 0ed2dc0cf2..dfa920151f 100644
--- a/compiler/systems/i_embed.pas
+++ b/compiler/systems/i_embed.pas
@@ -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.
diff --git a/compiler/systems/t_embed.pas b/compiler/systems/t_embed.pas
index 3db127f869..8276df8c90 100644
--- a/compiler/systems/t_embed.pas
+++ b/compiler/systems/t_embed.pas
@@ -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);
diff --git a/compiler/utils/ppuutils/ppudump.pp b/compiler/utils/ppuutils/ppudump.pp
index 864a6ad143..56f64c4d34 100644
--- a/compiler/utils/ppuutils/ppudump.pp
+++ b/compiler/utils/ppuutils/ppudump.pp
@@ -173,7 +173,8 @@ const
{ 86 } 'Darwin-AArch64',
{ 87 } 'iPhoneSim-x86-64',
{ 88 } 'Linux-AArch64',
- { 89 } 'Win16'
+ { 89 } 'Win16',
+ { 90 } 'Embedded-i8086'
);
const
diff --git a/compiler/x86/agx86nsm.pas b/compiler/x86/agx86nsm.pas
index e7258a14c3..587147a11e 100644
--- a/compiler/x86/agx86nsm.pas
+++ b/compiler/x86/agx86nsm.pas
@@ -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 : '; ';