浏览代码

* fixed nested access to parent local variables in i8086 far data memory models

git-svn-id: trunk@27388 -
nickysn 11 年之前
父节点
当前提交
f4a0c08736
共有 1 个文件被更改,包括 29 次插入2 次删除
  1. 29 2
      compiler/i8086/n8086ld.pas

+ 29 - 2
compiler/i8086/n8086ld.pas

@@ -27,11 +27,12 @@ interface
 
     uses
       globtype,
-      symsym,
+      symsym,symtype,
       node,ncgld;
 
     type
       ti8086loadnode = class(tcgloadnode)
+         procedure generate_nested_access(vs: tsym); override;
          procedure generate_absaddr_access(vs: tabsolutevarsym); override;
       end;
 
@@ -42,12 +43,38 @@ implementation
       globals,aasmdata,
       symcpu,
       nld,
-      cgbase,cgobj;
+      cgbase,cgobj,
+      cpubase,cpuinfo;
 
 {*****************************************************************************
                             TI8086LOADNODE
 *****************************************************************************}
 
+    procedure ti8086loadnode.generate_nested_access(vs: tsym);
+      begin
+        inherited;
+
+        { the parentfp pointer is always a near pointer (this is turbo pascal
+          compatible) regardless of memory model, so we need to set the segment
+          manually.
+
+          todo: once the far data memory models are fully implemented, the
+          parentfp type should be changed to a near 'ss' pointer in all memory
+          models and then this code can be removed. But this can only happen
+          after:
+          1) all calls to a_loadaddr_ref_reg go through the high level code
+             generator
+          2) a_loadaddr_ref_reg in the low level code generator stops using
+             the presence of a segment in the source reference to determine the
+             destination reg size
+          3) make_simple_ref is updated to remove unnecessary segment prefixes
+          4) hlcg.reference_reset_base is updated to set the segment on near_ss
+             pointers }
+        if (left.nodetype=loadparentfpn) and
+           (current_settings.x86memorymodel in x86_far_data_models) then
+          location.reference.segment:=NR_SS;
+      end;
+
     procedure ti8086loadnode.generate_absaddr_access(vs: tabsolutevarsym);
       begin
         if tcpuabsolutevarsym(symtableentry).absseg then