Browse Source

+ implemented Mem/MemW/MemL[] for i8086

git-svn-id: trunk@24665 -
nickysn 12 years ago
parent
commit
5b503f42c7
3 changed files with 41 additions and 0 deletions
  1. 29 0
      compiler/pexpr.pas
  2. 9 0
      compiler/psystem.pas
  3. 3 0
      compiler/symdef.pas

+ 29 - 0
compiler/pexpr.pas

@@ -1867,6 +1867,32 @@ implementation
                                (tloadnode(p1).symtableentry.name='MEMW') or
                                (tloadnode(p1).symtableentry.name='MEML')) then
                              begin
+{$if defined(i8086)}
+                               if try_to_consume(_COLON) then
+                                begin
+                                  p2:=ctypeconvnode.create_explicit(p2,u32inttype);
+                                  p3:=cshlshrnode.create(shln,p2,cordconstnode.create($10,s16inttype,false));
+                                  p2:=comp_expr(true,false);
+                                  p2:=caddnode.create(addn,p2,p3);
+                                  case tloadnode(p1).symtableentry.name of
+                                    'MEM': p2:=ctypeconvnode.create_explicit(p2,bytefarpointertype);
+                                    'MEMW': p2:=ctypeconvnode.create_explicit(p2,wordfarpointertype);
+                                    'MEML': p2:=ctypeconvnode.create_explicit(p2,longintfarpointertype);
+                                    else
+                                      internalerror(2013053102);
+                                  end;
+                                  p1:=cderefnode.create(p2);
+                                end
+                               else
+                                begin
+                                  { TODO: fix, this is broken for now... }
+                                  if try_to_consume(_POINTPOINT) then
+                                    { Support mem[$80000000..$80000002] which returns array [0..2] of memtype.}
+                                    p2:=crangenode.create(p2,comp_expr(true,false));
+                                  p1:=cvecnode.create(p1,p2);
+                                  include(tvecnode(p1).flags,nf_memindex);
+                                end;
+{$elseif defined(i386)}
                                if try_to_consume(_COLON) then
                                 begin
                                   p3:=caddnode.create(muln,cordconstnode.create($10,s32inttype,false),p2);
@@ -1887,6 +1913,9 @@ implementation
                                   p1:=cvecnode.create(p1,p2);
                                   include(tvecnode(p1).flags,nf_memindex);
                                 end;
+{$else}
+                               internalerror(2013053101);
+{$endif}
                              end
                            else
                              begin

+ 9 - 0
compiler/psystem.pas

@@ -282,6 +282,9 @@ implementation
   {$ifdef i8086}
         voidfarpointertype:=tpointerdef.createx86(voidtype,x86pt_far);
         voidhugepointertype:=tpointerdef.createx86(voidtype,x86pt_huge);
+        bytefarpointertype:=tpointerdef.createx86(u8inttype,x86pt_far);
+        wordfarpointertype:=tpointerdef.createx86(u16inttype,x86pt_far);
+        longintfarpointertype:=tpointerdef.createx86(s32inttype,x86pt_far);
   {$endif i8086}
 {$endif x86}
         cfiletype:=tfiledef.createuntyped;
@@ -416,6 +419,9 @@ implementation
   {$ifdef i8086}
         addtype('$void_farpointer',voidfarpointertype);
         addtype('$void_hugepointer',voidhugepointertype);
+        addtype('$byte_farpointer',bytefarpointertype);
+        addtype('$word_farpointer',wordfarpointertype);
+        addtype('$longint_farpointer',longintfarpointertype);
   {$endif i8086}
 {$endif x86}
         addtype('$openchararray',openchararraytype);
@@ -541,6 +547,9 @@ implementation
   {$ifdef i8086}
         loadtype('void_farpointer',voidfarpointertype);
         loadtype('void_hugepointer',voidhugepointertype);
+        loadtype('byte_farpointer',bytefarpointertype);
+        loadtype('word_farpointer',wordfarpointertype);
+        loadtype('longint_farpointer',longintfarpointertype);
   {$endif i8086}
 {$endif x86}
         loadtype('file',cfiletype);

+ 3 - 0
compiler/symdef.pas

@@ -848,6 +848,9 @@ interface
   {$ifdef i8086}
        voidfarpointertype,
        voidhugepointertype,
+       bytefarpointertype,        { used for Mem[] }
+       wordfarpointertype,        { used for MemW[] }
+       longintfarpointertype,     { used for MemL[] }
   {$endif i8086}
 {$endif x86}
        cundefinedtype,