hugeptr.inc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by the Free Pascal development team.
  4. Processor dependent implementation for the system unit for
  5. intel i8086+
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. function fpc_hugeptr_add_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
  13. var
  14. o: LongInt;
  15. begin
  16. o:=LongInt(Ofs(p^))+n;
  17. fpc_hugeptr_add_longint:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  18. end;
  19. function fpc_hugeptr_add_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
  20. var
  21. linear: LongInt;
  22. begin
  23. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)+n;
  24. fpc_hugeptr_add_longint_normalized:=HugePointer(Ptr(linear shr 4,linear and $F));
  25. end;
  26. function fpc_hugeptr_sub_longint(p: HugePointer; n: LongInt): HugePointer; compilerproc;
  27. var
  28. o: LongInt;
  29. begin
  30. o:=LongInt(Ofs(p^))-n;
  31. fpc_hugeptr_sub_longint:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  32. end;
  33. function fpc_hugeptr_sub_longint_normalized(p: HugePointer; n: LongInt): HugePointer; compilerproc;
  34. var
  35. linear: LongInt;
  36. begin
  37. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)-n;
  38. fpc_hugeptr_sub_longint_normalized:=HugePointer(Ptr(linear shr 4,linear and $F));
  39. end;
  40. procedure fpc_hugeptr_inc_longint(var p: HugePointer; n: LongInt); compilerproc;
  41. var
  42. o: LongInt;
  43. begin
  44. o:=LongInt(Ofs(p^))+n;
  45. p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  46. end;
  47. procedure fpc_hugeptr_inc_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
  48. var
  49. linear: LongInt;
  50. begin
  51. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)+n;
  52. p:=HugePointer(Ptr(linear shr 4,linear and $F));
  53. end;
  54. procedure fpc_hugeptr_dec_longint(var p: HugePointer; n: LongInt); compilerproc;
  55. var
  56. o: LongInt;
  57. begin
  58. o:=LongInt(Ofs(p^))-n;
  59. p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  60. end;
  61. procedure fpc_hugeptr_dec_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
  62. var
  63. linear: LongInt;
  64. begin
  65. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)-n;
  66. p:=HugePointer(Ptr(linear shr 4,linear and $F));
  67. end;
  68. function fpc_hugeptr_cmp_normalized_e(p1, p2: HugePointer): Boolean; compilerproc;
  69. begin
  70. fpc_hugeptr_cmp_normalized_e:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  71. end;
  72. function fpc_hugeptr_cmp_normalized_ne(p1, p2: HugePointer): Boolean; compilerproc;
  73. begin
  74. fpc_hugeptr_cmp_normalized_ne:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<>((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  75. end;
  76. function fpc_hugeptr_cmp_normalized_b(p1, p2: HugePointer): Boolean; compilerproc;
  77. begin
  78. fpc_hugeptr_cmp_normalized_b:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  79. end;
  80. function fpc_hugeptr_cmp_normalized_be(p1, p2: HugePointer): Boolean; compilerproc;
  81. begin
  82. fpc_hugeptr_cmp_normalized_be:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  83. end;
  84. function fpc_hugeptr_cmp_normalized_a(p1, p2: HugePointer): Boolean; compilerproc;
  85. begin
  86. fpc_hugeptr_cmp_normalized_a:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))>((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  87. end;
  88. function fpc_hugeptr_cmp_normalized_ae(p1, p2: HugePointer): Boolean; compilerproc;
  89. begin
  90. fpc_hugeptr_cmp_normalized_ae:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))>=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  91. end;