Browse Source

+ added rtl helpers for huge pointer arithmetic

git-svn-id: trunk@28099 -
nickysn 11 years ago
parent
commit
f0346c096f
4 changed files with 93 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 79 0
      rtl/i8086/hugeptr.inc
  3. 1 0
      rtl/i8086/i8086.inc
  4. 12 0
      rtl/inc/compproc.inc

+ 1 - 0
.gitattributes

@@ -8176,6 +8176,7 @@ rtl/i386/setjump.inc svneol=native#text/plain
 rtl/i386/setjumph.inc svneol=native#text/plain
 rtl/i386/setjumph.inc svneol=native#text/plain
 rtl/i386/strings.inc svneol=native#text/plain
 rtl/i386/strings.inc svneol=native#text/plain
 rtl/i386/stringss.inc svneol=native#text/plain
 rtl/i386/stringss.inc svneol=native#text/plain
+rtl/i8086/hugeptr.inc svneol=native#text/plain
 rtl/i8086/i8086.inc svneol=native#text/plain
 rtl/i8086/i8086.inc svneol=native#text/plain
 rtl/i8086/int32p.inc svneol=native#text/plain
 rtl/i8086/int32p.inc svneol=native#text/plain
 rtl/i8086/int64p.inc svneol=native#text/plain
 rtl/i8086/int64p.inc svneol=native#text/plain

+ 79 - 0
rtl/i8086/hugeptr.inc

@@ -0,0 +1,79 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2014 by the Free Pascal development team.
+
+    Processor dependent implementation for the system unit for
+    intel i8086+
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+function fpc_hugeptr_add_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+var
+  o: LongInt;
+begin
+  o:=LongInt(Ofs(p^))+n;
+  fpc_hugeptr_add_longint:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
+end;
+
+function fpc_hugeptr_add_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+var
+  linear: LongInt;
+begin
+  linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)+n;
+  fpc_hugeptr_add_longint_normalized:=HugePointer(Ptr(linear shr 4,linear and $F));
+end;
+
+function fpc_hugeptr_sub_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+var
+  o: LongInt;
+begin
+  o:=LongInt(Ofs(p^))-n;
+  fpc_hugeptr_sub_longint:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
+end;
+
+function fpc_hugeptr_sub_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+var
+  linear: LongInt;
+begin
+  linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)-n;
+  fpc_hugeptr_sub_longint_normalized:=HugePointer(Ptr(linear shr 4,linear and $F));
+end;
+
+procedure fpc_hugeptr_inc_longint(var p: HugePointer; n: LongInt); compilerproc;
+var
+  o: LongInt;
+begin
+  o:=LongInt(Ofs(p^))+n;
+  p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
+end;
+
+procedure fpc_hugeptr_inc_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
+var
+  linear: LongInt;
+begin
+  linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)+n;
+  p:=HugePointer(Ptr(linear shr 4,linear and $F));
+end;
+
+procedure fpc_hugeptr_dec_longint(var p: HugePointer; n: LongInt); compilerproc;
+var
+  o: LongInt;
+begin
+  o:=LongInt(Ofs(p^))-n;
+  p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
+end;
+
+procedure fpc_hugeptr_dec_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
+var
+  linear: LongInt;
+begin
+  linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)-n;
+  p:=HugePointer(Ptr(linear shr 4,linear and $F));
+end;

+ 1 - 0
rtl/i8086/i8086.inc

@@ -667,4 +667,5 @@ Procedure SysResetFPU;
   end;
   end;
 
 
 {$I int32p.inc}
 {$I int32p.inc}
+{$I hugeptr.inc}
 
 

+ 12 - 0
rtl/inc/compproc.inc

@@ -746,3 +746,15 @@ function fpc_longword_to_double(i: longword): double; compilerproc;
 
 
 function fpc_setjmp(var s : jmp_buf) : {$ifdef CPU16}smallint{$else}longint{$endif}; compilerproc;
 function fpc_setjmp(var s : jmp_buf) : {$ifdef CPU16}smallint{$else}longint{$endif}; compilerproc;
 procedure fpc_longjmp(var s : jmp_buf; value : {$ifdef CPU16}smallint{$else}longint{$endif}); compilerproc;
 procedure fpc_longjmp(var s : jmp_buf; value : {$ifdef CPU16}smallint{$else}longint{$endif}); compilerproc;
+
+{$ifdef i8086}
+{ i8086 huge pointer helpers }
+function fpc_hugeptr_add_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+function fpc_hugeptr_add_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+function fpc_hugeptr_sub_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+function fpc_hugeptr_sub_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
+procedure fpc_hugeptr_inc_longint(var p: HugePointer; n: LongInt); compilerproc;
+procedure fpc_hugeptr_inc_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
+procedure fpc_hugeptr_dec_longint(var p: HugePointer; n: LongInt); compilerproc;
+procedure fpc_hugeptr_dec_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
+{$endif i8086}