From ac97d20249204be787e09417404451259885032d Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 5 Nov 2015 16:18:47 +0000 Subject: [PATCH] + added support for typed word/smallint constants, initialized with Seg(symbol) on the i8086 git-svn-id: trunk@32251 - --- compiler/i8086/n8086tcon.pas | 49 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/compiler/i8086/n8086tcon.pas b/compiler/i8086/n8086tcon.pas index 5133c861ef..d890678d1b 100644 --- a/compiler/i8086/n8086tcon.pas +++ b/compiler/i8086/n8086tcon.pas @@ -35,6 +35,7 @@ interface ti8086typedconstbuilder = class(tasmlisttypedconstbuilder) protected + procedure tc_emit_orddef(def: torddef; var node: tnode);override; procedure tc_emit_pointerdef(def: tpointerdef; var node: tnode);override; end; @@ -42,10 +43,56 @@ interface implementation uses - ncon,ncnv,defcmp,defutil,aasmtai,symcpu; + verbose, + ncon,ncnv,ninl,nld, + defcmp,defutil, + aasmtai, + symconst,symtype,symsym,symcpu; { ti8086typedconstbuilder } + procedure ti8086typedconstbuilder.tc_emit_orddef(def: torddef; var node: tnode); + var + hp: tnode; + srsym: tsym; + pd: tprocdef; + resourcestrrec: trecorddef; + begin + { support word/smallint constants, initialized with Seg() } + if (def.ordtype in [u16bit,s16bit]) and (node.nodetype=inlinen) and + (tinlinenode(node).inlinenumber=in_seg_x) then + begin + hp:=tunarynode(node).left; + if hp.nodetype=loadn then + begin + srsym:=tloadnode(hp).symtableentry; + case srsym.typ of + procsym : + begin + pd:=tprocdef(tprocsym(srsym).ProcdefList[0]); + if Tprocsym(srsym).ProcdefList.Count>1 then + Message(parser_e_no_overloaded_procvars); + if po_abstractmethod in pd.procoptions then + Message(type_e_cant_take_address_of_abstract_method) + else + ftcb.emit_tai(Tai_const.Create_seg_name(pd.mangledname),u16inttype); + end; + staticvarsym : + ftcb.emit_tai(Tai_const.Create_seg_name(tstaticvarsym(srsym).mangledname),u16inttype); + labelsym : + ftcb.emit_tai(Tai_const.Create_seg_name(tlabelsym(srsym).mangledname),u16inttype); + else + Message(type_e_variable_id_expected); + end; + end + else + Message(parser_e_illegal_expression); + end + else + inherited; + end; + + procedure ti8086typedconstbuilder.tc_emit_pointerdef(def: tpointerdef; var node: tnode); var hp: tnode;