home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / sysutl / probe102.lbr / ASCTOBIN.CZ / ASCTOBIN.C
Text File  |  1986-12-28  |  1KB  |  39 lines

  1. /******************************************************************************/
  2. /*                              asciitobin(ch,str)                            */
  3. /*                      Copyright (c) 1984 by Paul M. Sittler                 */
  4. /******************************************************************************/
  5. #define EOS     0x00
  6.  
  7. asciitobin(ch,str)      /* converts ascii character ch to a 9-character */
  8.             /*          binary encoded string in the form of */
  9.             /*          0100 1011 */
  10.  
  11. /******************************************************************************/
  12. /*                            calling parameters                              */
  13. /******************************************************************************/
  14. char ch;                /* ascii character passed with function call */
  15. char *str;              /* pointer to 9 character binary encoded ascii string */
  16.  
  17. {
  18. /******************************************************************************/
  19. /*                                 local variables                            */
  20. /******************************************************************************/
  21.     int bin_ch;
  22.  
  23.     for (bin_ch = 0; bin_ch < 9; bin_ch++)
  24.     {
  25.     if (bin_ch == 4)
  26.         str[bin_ch++] = ' ';
  27.     (ch & 0x80) ? str[bin_ch] = '1' : str[bin_ch] = '0';
  28.     ch <<= 1;
  29.     }
  30.     str[9] = EOS;
  31. }
  32. 
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. *********************