home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / bluebook.zip / BCD.DOC < prev    next >
Text File  |  1986-05-08  |  4KB  |  99 lines

  1.  
  2. BCD.DOC -- Description of BCD.ASM
  3. =================================
  4.  
  5.   From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
  6.         by Christopher L. Morgan
  7.         Copyright (C) 1984 by The Waite Group, Inc.
  8.  
  9.   Purpose:  BCD.ASM contains routines to convert between internal binary
  10.     coded decimal (BCD) and other formats, both internal and external.
  11. _______________________________________________________________________________
  12.  
  13.    Contents:
  14.    ---------
  15.    BCDIN    --  Convert from ASCII Decimal to BCD
  16.    BCDOUT    --  Convert from BCD to ASCII Decimal
  17.    BCD2I16    --  Convert from BCD to 16-bit Binary
  18.    I162BCD    --  Convert from 16-bit Binary to BCD
  19. _______________________________________________________________________________
  20.  
  21.   Overview:
  22.     These routines can convert external decimal representation and 
  23.   internal BCD representation, and between internal binary and internal BCD.
  24.     The internal BCD format packs two decimal digits per byte, one per
  25.   nibble.  By using a large number of bytes, you can precisely represent
  26.   high precision decimal numbers.  These routines use 18 bytes of storage to 
  27.   handle 36-digit BCD numbers, but are easily modified to handle other sizes.
  28.     Fixed point numbers can be handled by assigning a fixed position for
  29.   a decimal point.  For example, dollars & cents can be handled by assigning
  30.   the decimal point so there are exactly two BCD digits to its right, which
  31.   form the fractional part of the number.
  32. _______________________________________________________________________________
  33.  
  34. BCDIN
  35.  
  36.   Function: This routine accepts a decimal number from the standard input
  37.     device and converts it to internal BCD format.
  38.  
  39.   Input: The individual digits of the decimal number are received in ASCII
  40.     through a call to a standard I/O routine. The valid digits are 0 
  41.     through 9. An ASCII code other than a digit will terminate the routine.
  42.  
  43.   Output: On return a 36-digit number is stored in BCD form in an
  44.     18-byte buffer called BCDBUFF.
  45.  
  46.   Registers used: No registers are modified.
  47.  
  48.   Segments referenced: DATAS is data segment which contains BCDBUFF.
  49.  
  50.   Routines called: STDIN
  51. _______________________________________________________________________________
  52.  
  53. BCDOUT
  54.  
  55.   Function: This routine converts a 36-digit number stored in BCD form to
  56.     ASCII decimal form which is sent to the standard output device.
  57.  
  58.   Input: Upon entry a 36-digit number is stored in an 18-byte BCD buffer
  59.     called BCDBUFF.
  60.  
  61.   Output: A string of ASCII digits representing a decimal number is stored
  62.     in a buffer called TBUFF and then sent out through a standard I/O routine.
  63.  
  64.   Registers used: No registers are modified.
  65.  
  66.   Segments referenced: DATAS is a data segment containing BCDFUFF and TBUFF.
  67.  
  68.   Routines called: STDOUT
  69. _______________________________________________________________________________
  70.  
  71. BCD2IB16
  72.  
  73.   Function: This routine converts from internal BCD to intermal binary format.
  74.  
  75.   Input: Upon entry a 36-digit number is contained in am 18-byte BCD buffer
  76.     called BCDBUFF.
  77.  
  78.   Output: A 16-bit binary number is returned in the DX register.
  79.  
  80.   Registers used: Only DX is modified. DX is used for output.
  81.  
  82.   Segments referenced: DATAS is a data segment containing the buffer, BCDBUFF.
  83. _______________________________________________________________________________
  84.  
  85. IB162BCD
  86.  
  87.   Function: This routine converts internal 16-bit binary numbers to numbers
  88.     stored in internal BCD format.
  89.  
  90.   Input: Upon entry a 16-bit binary number is in the DX register.
  91.  
  92.   Output: On return a 36-digit number is stored in BCD form in an 18-byte
  93.     buffer called BCDBUFF.
  94.  
  95.   Registers used: No registers are modified. DX is used for input.
  96.  
  97.   Segments referenced: DATAS is a data segment containing BCDBUFF.
  98. _______________________________________________________________________________
  99. >>>> Physical EOF BCD.DOC <<<<<