<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404354&amp;view=findpost&amp;p=3613739</guid>
        <pubDate>Sun, 19 Jul 2015 04:02:31 +0000</pubDate>
        <title>Помогите с переносом кода с TP7 на FreePascal</title>
        <link>https://forum.sources.ru/index.php?showtopic=404354&amp;view=findpost&amp;p=3613739</link>
        <description><![CDATA[MBo: Зачем это переводить? Разве во FreePascal нет процедур для работы со временем?]]></description>
        <author>MBo</author>
        <category>32-битные компиляторы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404354&amp;view=findpost&amp;p=3613736</guid>
        <pubDate>Sat, 18 Jul 2015 23:04:54 +0000</pubDate>
        <title>Помогите с переносом кода с TP7 на FreePascal</title>
        <link>https://forum.sources.ru/index.php?showtopic=404354&amp;view=findpost&amp;p=3613736</link>
        <description><![CDATA[vohman: Привет всем гуру ))<br>
Вот задачка:<br>
Не совсем понимаю, как перевести данную процедуру (ТурбоПас) на &quot;нормальный&quot; язык для ФриПаскаль. :(<br>
Кто-нибудь может помочь переписать этот код (ниже) на ФрииПаскаль?<br>
Полный модуль (исходник) пристёгиваю.<br>
Возможно есть у кого версия 1.4 данной библиотеки? В нем есть эти процедуры без inline, был бы благодарен<br>
за исходники версии 1.4  (Turbo BTree)<br>
<br>
<br>
type<br>
    TimeArr = record<br>
        lsLongInt : LongInt;               (* least significant long integer *)<br>
        msLongInt : LongInt;                (* most significant long integer *)<br>
        end;<br>
<br>
var<br>
    clock : TimeArr;<br>
<br>
(* This routine does two things that are important to understand when<br>
   using it.  It first increments the internal clock.  It then sets x to this<br>
   new &quot;time&quot;.                                                               *)<br>
<br>
procedure GetTime(var x : TimeArr);<br>
    begin<br>
    Inline(<br>
        (* This was created from the original source code using the INLINE4<br>
           utility from CompuServe.  It has difficulty dealing with the lea<br>
           si, &gt;CLOCK instruction.  This was hand coded using a listing of the<br>
           original assembled file.  Thus, if any future modifications require<br>
           changing this file and reassembling with INLINE, be sure to check<br>
           the output to make sure this instruction is OK.  INLINE does flag<br>
           an error here to remind you - I have not included the original<br>
           source code for simplicities sake.  If anyone wants it, I have it<br>
           - Dean                                                            *)<br>
<br>
      &#036;C4/&#036;BE/&gt;X/         (*  les di, &gt;x[bp]           ; set es:di to point<br>
                                                         to the users time<br>
                                                         var                 *)<br>
      &#036;8D/&#036;36/&gt;CLOCK/     (*  lea si, &gt;CLOCK           ; set ds:si to point<br>
                                                         to the local<br>
                                                         database time var   *)<br>
      &#036;83/&#036;04/&#036;01/        (*  add word ptr [si],1      ; inc the database<br>
                                                         time                *)<br>
      &#036;83/&#036;54/&#036;02/&#036;00/    (*  adc word ptr 2[si], 0    ;                     *)<br>
      &#036;83/&#036;54/&#036;04/&#036;00/    (*  adc word ptr 4[si], 0    ;                     *)<br>
      &#036;83/&#036;54/&#036;06/&#036;00/    (*  adc word ptr 6[si], 0    ;                     *)<br>
      &#036;FC/                (*  cld                      ; copy new time to<br>
                                                         UserTime            *)<br>
      &#036;B9/&#036;04/&#036;00/        (*  mov cx, 4                ;                     *)<br>
      &#036;F2/&#036;A5);           (*  rep   movsw              ; use movsw to save<br>
                                                         one memory access   *)<br>
<br>
    end;                                           (* end of GetTime routine *)<br>
<br>
<br>
Модуль не большой, пару процедур-функций. Вообще интересно еще то же самое и для функции CompareTime из этого модуля.<br>
<br>
Заранее Спасибо всем откликнувшимся. <br>
П.С.<br>
Сделал предпросмотр и почему-то файл не возможно прикрепить. Поэтому приведу весь код модуля ниже (не большой он, извиняюсь что слегка нарушаю правила форума)<br>
<br>
(* TBTree16             Copyright &copy;  1988,1989       Dean H. Farwell II    *)<br>
<br>
unit Time;<br>
<br>
(*****************************************************************************)<br>
(*                                                                           *)<br>
(*                       T I M E    R O U T I N E S                          *)<br>
(*                                                                           *)<br>
(*****************************************************************************)<br>
<br>
<br>
(* This unit is completely redesigned as of version 1.4 and can be used to<br>
   track the sequence of events.  As opposed to previous versions, it does not<br>
   use actual time, but uses a counter to simulate time.  This counter is just<br>
   like an internal clock with each &quot;tick&quot; being noted by incrementing the<br>
   counter.  The clock is an internal variable of type TimeArr (defined in<br>
   this unit) which is nothing more than a record of two long integers.  This<br>
   gives the clock a range of over 2 billion squared which is larger than<br>
   anyone will ever need.  The use of this unit is straightforward.  The user<br>
   has variables of type TimeArr.  To assign a time call GetTime.  To compare<br>
   two times call CompareTime.  A routine to set the max time and to print<br>
   times is also provided.<br>
<br>
   note - The idea to use the simulated clock rather than using my previous<br>
          method came from Chris Cardozo.  It was an extremely slick way to<br>
          get around compatibility problems which I would not have thought<br>
          of.                                                                *)<br>
<br>
(* Version Information<br>
<br>
   Version 1.1 - No Changes<br>
<br>
   Version 1.2 - No Changes<br>
<br>
   Version 1.3 - No Changes<br>
<br>
   Version 1.4 - Redesigned complete unit.  The reason for the redesign was to<br>
                 alleviate any dependancies on specific memory locations which<br>
                 the previous version had.<br>
<br>
   Version 1.5 - GetTime and CompareTime were redone using INLINE statements<br>
                 by Chris Cardozo.  They function the same way as in version<br>
                 1.4, but are faster and smaller (400 bytes verses 560).  His<br>
                 extensive efforts on all facets of TBTREE are appreciated.<br>
<br>
               - The order of the fields in TimeArr are switched<br>
<br>
   Version 1.6 - No Changes                                                  *)<br>
<br>
(*&#33;*)<br>
(*&#092;*)<br>
(*////////////////////////// I N T E R F A C E //////////////////////////////*)<br>
<br>
interface<br>
<br>
uses<br>
    Compare,<br>
    Numbers;<br>
<br>
<br>
type<br>
    TimeArr = record<br>
        lsLongInt : LongInt;               (* least significant long integer *)<br>
        msLongInt : LongInt;                (* most significant long integer *)<br>
        end;<br>
<br>
<br>
(* This routine does two things that are important to understand when<br>
   using it.  It first increments the internal clock.  It then sets x to this<br>
   new &quot;time&quot;.                                                               *)<br>
<br>
procedure GetTime(var x : TimeArr);<br>
<br>
<br>
(* This function compares two time arrays.  LESSTHAN is returned if X is less<br>
   than Y (earlier).  GREATERTHAN is returned if X is greater than Y (later).<br>
   If they are equal then EQUALTO is returned                                *)<br>
<br>
function CompareTime(var x : TimeArr;<br>
                     var y : TimeArr) : Comparison;<br>
<br>
<br>
(* This routine will print the two long integers that make up x (of type<br>
   TimeArr)                                                                  *)<br>
<br>
procedure PrintTime(x : TimeArr);<br>
<br>
<br>
(* This routine sets both long integer fields of a timeArr variable to the<br>
   maximum possible value (MAXLONGINT)                                       *)<br>
<br>
procedure SetMaxTime(var x : TimeArr);<br>
<br>
<br>
(*&#092;*)<br>
(*///////////////////// I M P L E M E N T A T I O N /////////////////////////*)<br>
<br>
implementation<br>
<br>
var<br>
    clock : TimeArr;<br>
<br>
(* This routine does two things that are important to understand when<br>
   using it.  It first increments the internal clock.  It then sets x to this<br>
   new &quot;time&quot;.                                                               *)<br>
<br>
procedure GetTime(var x : TimeArr);<br>
<br>
    begin<br>
    Inline(<br>
        (* This was created from the original source code using the INLINE4<br>
           utility from CompuServe.  It has difficulty dealing with the lea<br>
           si, &gt;CLOCK instruction.  This was hand coded using a listing of the<br>
           original assembled file.  Thus, if any future modifications require<br>
           changing this file and reassembling with INLINE, be sure to check<br>
           the output to make sure this instruction is OK.  INLINE does flag<br>
           an error here to remind you - I have not included the original<br>
           source code for simplicities sake.  If anyone wants it, I have it<br>
           - Dean                                                            *)<br>
<br>
      &#036;C4/&#036;BE/&gt;X/         (*  les di, &gt;x[bp]           ; set es:di to point<br>
                                                         to the users time<br>
                                                         var                 *)<br>
      &#036;8D/&#036;36/&gt;CLOCK/     (*  lea si, &gt;CLOCK           ; set ds:si to point<br>
                                                         to the local<br>
                                                         database time var   *)<br>
      &#036;83/&#036;04/&#036;01/        (*  add word ptr [si],1      ; inc the database<br>
                                                         time                *)<br>
      &#036;83/&#036;54/&#036;02/&#036;00/    (*  adc word ptr 2[si], 0    ;                     *)<br>
      &#036;83/&#036;54/&#036;04/&#036;00/    (*  adc word ptr 4[si], 0    ;                     *)<br>
      &#036;83/&#036;54/&#036;06/&#036;00/    (*  adc word ptr 6[si], 0    ;                     *)<br>
      &#036;FC/                (*  cld                      ; copy new time to<br>
                                                         UserTime            *)<br>
      &#036;B9/&#036;04/&#036;00/        (*  mov cx, 4                ;                     *)<br>
      &#036;F2/&#036;A5);           (*  rep   movsw              ; use movsw to save<br>
                                                         one memory access   *)<br>
<br>
    end;                                           (* end of GetTime routine *)<br>
<br>
(*&#092;*)<br>
(* This function compares two time arrays.  LESSTHAN is returned if X is less<br>
   than Y (earlier).  GREATERTHAN is returned if X is greater than Y (later).<br>
   If they are equal then EQUALTO is returned                                *)<br>
<br>
function CompareTime(var x : TimeArr;<br>
                     var y : TimeArr) : Comparison;<br>
<br>
    begin<br>
    Inline(<br>
                          (*                           ; LI1 = StackOffs + 4 *)<br>
                          (*                           ; LI2 = StackOffs     *)<br>
      &#036;8C/&#036;DA/            (* mov dx, ds                ; save Turbo&#39;s ds     *)<br>
      &#036;C5/&#036;B6/&gt;X/         (* lds si, &gt;x[bp]            ; point ds:si to high<br>
                                                         word of first memory<br>
                                                         region              *)<br>
      &#036;83/&#036;C6/&#036;03/        (* add si, 3                 ; region is 4 words<br>
                                                         long                *)<br>
      &#036;C4/&#036;BE/&gt;Y/         (* les di, &gt;y[bp]            ; point es:di to high<br>
                                                         word of second<br>
                                                         memory region       *)<br>
      &#036;83/&#036;C7/&#036;03/        (* add di, 3                 ; region is 4 words<br>
                                                         long                *)<br>
      &#036;FD/                (* std                       ; compare from high<br>
                                                         word to low word    *)<br>
      &#036;B9/&#036;04/&#036;00/        (* mov cx, 4                 ; 4 words to compare  *)<br>
      &#036;F3/&#036;A7/            (* repe  cmpsw               ; do compare          *)<br>
      &#036;B8/&#036;01/&#036;00/        (* mov ax, 1                 ; assume result was<br>
                                                         EQUAL               *)<br>
      &#036;74/&#036;0B/            (* je Done                   ; if so, then we are<br>
                                                         all done            *)<br>
      &#036;77/&#036;06/            (* ja GrThan                 ; was first parameter<br>
                                                         greater ?           *)<br>
      &#036;B8/&#036;00/&#036;00/        (* mov ax, 0                 ; no, then it must<br>
                                                         have been less than<br>
                                                         second              *)<br>
      &#036;E9/&#036;03/&#036;00/        (* jmp Done                  ;                     *)<br>
      &#036;B8/&#036;02/&#036;00/        (* GrThan: mov ax, 2         ;                     *)<br>
      &#036;8E/&#036;DA/            (* Done:   mov ds, dx        ; all done so can<br>
                                                         restore Turbo&#39;s ds  *)<br>
      &#036;88/&#036;46/&#036;FF);       (* mov [bp-1], al            ; store function<br>
                                                         result for Turbo    *)<br>
<br>
    end;                                       (* end of CompareTime routine *)<br>
<br>
<br>
(* This routine will print the two long integers that make up x (of type<br>
   TimeArr)                                                                  *)<br>
<br>
procedure PrintTime(x : TimeArr);<br>
<br>
    begin<br>
    Writeln(&#39;Most Significant Long Integer = &#39;,x.msLongInt);<br>
    Writeln(&#39;Least Significant Long Integer = &#39;,x.lsLongInt);<br>
    end;                                         (* end of PrintTime routine *)<br>
<br>
(*&#092;*)<br>
(* This routine sets both long integer fields of a timeArr variable to the<br>
   maximum possible value (MAXLONGINT)                                       *)<br>
<br>
procedure SetMaxTime(var x : TimeArr);<br>
<br>
    begin<br>
    x.lsLongInt := MAXLONGINT;<br>
    x.msLongInt := MAXLONGINT;<br>
    end;                                        (* end of SetMaxTime routine *)<br>
<br>
begin<br>
clock.msLongInt := 0;<br>
clock.lsLongInt := 0;<br>
end.                                                     (* end of Time unit *)]]></description>
        <author>vohman</author>
        <category>32-битные компиляторы</category>
      </item>
	
      </channel>
      </rss>
	