소스 검색

* changed the asizeint and asizeuint to 32-bit on CPUs with 16-bit address
space, in order to allow data structures larger than 32k (and less than 64k)

git-svn-id: trunk@32529 -

nickysn 9 년 전
부모
커밋
bfa96171e0
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      compiler/globtype.pas
  2. 7 0
      compiler/symdef.pas

+ 8 - 0
compiler/globtype.pas

@@ -92,8 +92,16 @@ interface
        PAInt = ^AInt;
 
        { target cpu specific type used to store data sizes }
+{$ifdef cpu16bitaddr}
+       { on small CPUs such as i8086, we use LongInt to support data structures
+         larger than 32767 bytes and up to 65535 bytes in size. Since asizeint
+         must be signed, we use LongInt/LongWord. }
+       ASizeInt = LongInt;
+       ASizeUInt = LongWord;
+{$else cpu16bitaddr}
        ASizeInt = PInt;
        ASizeUInt = PUInt;
+{$endif cpu16bitaddr}
 
        { type used for handling constants etc. in the code generator }
        TCGInt = Int64;

+ 7 - 0
compiler/symdef.pas

@@ -3781,6 +3781,13 @@ implementation
         if (ado_IsBitPacked in arrayoptions) then
           { can't just add 7 and divide by 8, because that may overflow }
           result:=result div 8 + ord((result mod 8)<>0);
+{$ifdef cpu16bitaddr}
+        if result>65535 then
+          begin
+            result:=-1;
+            exit;
+          end;
+{$endif cpu16bitaddr}
       end;