From bfa96171e0f503762b92df9c613f80cfcdcd5edd Mon Sep 17 00:00:00 2001 From: nickysn <nickysn@gmail.com> Date: Wed, 25 Nov 2015 15:35:38 +0000 Subject: [PATCH] * 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 - --- compiler/globtype.pas | 8 ++++++++ compiler/symdef.pas | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index 18796213fa..fc65ed5112 100644 --- a/compiler/globtype.pas +++ b/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; diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 1a78ea43a6..d9bcf2c120 100644 --- a/compiler/symdef.pas +++ b/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;