hugeptr.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. function fpc_hugeptr_sub_hugeptr(p1, p2: HugePointer): LongInt; compilerproc;
  41. begin
  42. fpc_hugeptr_sub_hugeptr:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))-((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  43. end;
  44. procedure fpc_hugeptr_inc_longint(var p: HugePointer; n: LongInt); compilerproc;
  45. var
  46. o: LongInt;
  47. begin
  48. o:=LongInt(Ofs(p^))+n;
  49. p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  50. end;
  51. procedure fpc_hugeptr_inc_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
  52. var
  53. linear: LongInt;
  54. begin
  55. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)+n;
  56. p:=HugePointer(Ptr(linear shr 4,linear and $F));
  57. end;
  58. procedure fpc_hugeptr_dec_longint(var p: HugePointer; n: LongInt); compilerproc;
  59. var
  60. o: LongInt;
  61. begin
  62. o:=LongInt(Ofs(p^))-n;
  63. p:=HugePointer(Ptr(Seg(p^)+SelectorInc*SmallInt(o shr 16),o and $FFFF));
  64. end;
  65. procedure fpc_hugeptr_dec_longint_normalized(var p: HugePointer; n: LongInt); compilerproc;
  66. var
  67. linear: LongInt;
  68. begin
  69. linear:=(LongInt(Seg(p^)) shl 4)+Ofs(p^)-n;
  70. p:=HugePointer(Ptr(linear shr 4,linear and $F));
  71. end;
  72. function fpc_hugeptr_cmp_normalized_e(p1, p2: HugePointer): Boolean; compilerproc;
  73. begin
  74. fpc_hugeptr_cmp_normalized_e:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  75. end;
  76. function fpc_hugeptr_cmp_normalized_ne(p1, p2: HugePointer): Boolean; compilerproc;
  77. begin
  78. fpc_hugeptr_cmp_normalized_ne:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<>((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  79. end;
  80. function fpc_hugeptr_cmp_normalized_b(p1, p2: HugePointer): Boolean; compilerproc;
  81. begin
  82. fpc_hugeptr_cmp_normalized_b:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  83. end;
  84. function fpc_hugeptr_cmp_normalized_be(p1, p2: HugePointer): Boolean; compilerproc;
  85. begin
  86. fpc_hugeptr_cmp_normalized_be:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))<=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  87. end;
  88. function fpc_hugeptr_cmp_normalized_a(p1, p2: HugePointer): Boolean; compilerproc;
  89. begin
  90. fpc_hugeptr_cmp_normalized_a:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))>((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  91. end;
  92. function fpc_hugeptr_cmp_normalized_ae(p1, p2: HugePointer): Boolean; compilerproc;
  93. begin
  94. fpc_hugeptr_cmp_normalized_ae:=((LongInt(Seg(p1^)) shl 4)+Ofs(p1^))>=((LongInt(Seg(p2^)) shl 4)+Ofs(p2^));
  95. end;