Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!stat!vsserv!loligo!schrader
From: schrader@loligo (Dave Schrader)
Newsgroups: comp.lang.pascal
Subject: Re: Need BCD routines for TP4.0/TP5.0/TP5.5
Summary: Need BCD routines for TP4.0/TP5.0/TP5.5
Keywords: TP4 TP5 TP55 BCD
Message-ID: <234@vsserv.scri.fsu.edu>
Date: 2 Oct 89 15:27:01 GMT
References: <89273.161831TRM900@PSUVM.BITNET> <89273.185750TBC101@PSUVM.BITNET> <19038@ut-emx.UUCP> <413@s5.Morgan.COM>
Sender: news@vsserv.scri.fsu.edu
Reply-To: schrader@loligo.UUCP (David Schrader)
Organization: Florida State University Computing Center
Lines: 49

This is my first post to the *net*. I have read, with interest, but had no
need to post until now. Please forgive the length of this posting.
  
A project (personal) I am working on (which grew out of an earlier posting)
requires that I read/write the system real clock. I have written all of the
appropriate routines (see below for basic structure), but the problem is on
a READ it returns the values in BCD and on a WRITE is requires that they be
passed BCD values.
  
I have looked, in vain, for that information in the TurboPascal 4.0, 5.0,
and 5.5 manuals and examples. They indicate that BCD support was phased out
after TP 3.0. The documentation and the examples are some what confusing and
seem, to me, contradictory. Does anyone have the source to some routines that
will take a number (0..23,0..59,1..100) and convert it to BCD and one that
will take the BCD representation of a number (same ranges) and convert it to
a number (type integer in both cases...). I DO need source code.
  
Any help will be appreciated.
  
   PROGRAM xyz ;
   CONST   Read_Real_Time_Clock  = hex_value;   {memory fails, notes at home}
           Rite_Real_Time_Clock  = hex_value;   {memory fails, notes at home}
           Timer_Interupt_Value  = hex_value;   {memory fails, notes at home}
   USES    dos,crt;
   VAR     dos_regs : Registers;
           HH       : INTEGER; {In the range of 0..23}
           MM       : INTEGER; {In the range of 0..59}
           SS       : INTEGER; {In the range of 0..59}

   { FUNCTION BCD_to_Int and FUNCTION Int_to_BCD} will go here eventually }

   PROCEDURE Read_RT_Clock(VAR HH , MM , SS : INTEGER) ;
   BEGIN
      dos_regs.AH := Read_Real_Time_Clock;
      INTR(dos_regs,Timer_Interupt_Value);
      HH := BCD_to_Int(dos_regs.CH)      ; {This is what I need }
      : 
   END;
   PROCEDURE Rite_RT_Clock(    HH , MM , SS : INTEGER) ;
   BEGIN
      dos_regs.CH := Int_to_BCD(HH)      ; {This is what I need }
      : 
      dos_regs.AH := Rite_Real_Time_Clock;
      INTR(dos_regs,Timer_Interupt_Value);
   END;
  
Thanks (again),
  
David Schrader