home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / BCDASM.ZIP / BCDASM / EXAMPLES / EXC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-03  |  777 b   |  23 lines

  1.     /* Sample C app using BCDASM routines */
  2.  
  3. #include <stdio.h>
  4. #include "bcd.h"
  5. #define  BCDSZ  10
  6. #define  BUFSZ  256
  7.  
  8. int main(void)
  9. {
  10.     byte bnum[BCDSZ];                   /* BCD variable goes here */
  11.     chrA buf[BUFSZ];                    /* String output buffer   */
  12.     chrA nstr[] = "61728394506172839";
  13.  
  14.     bcdA2p(bnum, BCDSZ, nstr);          /* Convert nstr to BCD   */
  15.     bcdAdd(bnum, bnum, BCDSZ);          /* Add to self           */
  16.     bcdNeg(bnum, BCDSZ);                /* Reverse sign          */
  17.  
  18.     bcdFmt(buf, BUFSZ, bnum, BCDSZ,     /* Convert BCD to Asciiz */
  19.            32,-1,-1,-1, -1,-1,-1,-1);
  20.                                         /* Display Asciiz string */
  21.     printf("Hello from BCDASM: %s\n", buf);
  22.     return 0;
  23. }