home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / babys203.zip / FORPGMRS.EXE / TDSP.CPP < prev    next >
C/C++ Source or Header  |  1992-11-28  |  3KB  |  84 lines

  1. //====================================================================//
  2. // TDSP.CPP - demonstrates the usage of PRTDRV.OBJ                    //
  3. //                                                                    //
  4. // (c) Budget Software Company  1992                                  //
  5. //                                                                    //
  6. //====================================================================//
  7.  
  8. #include <dos.h>
  9. #include <string.h>
  10.  
  11. #define LPT1 4
  12. #define COM1 0
  13.  
  14. // declare routines
  15. extern "C"
  16.   {
  17.   void far dspler_init_me();
  18.   void far dspler_despool();
  19.   }
  20. char *printme = "This is a string to print. \n";
  21. //
  22. void printstuff(unsigned char port)
  23. {
  24. //
  25. // The following code shows how to send multiple bytes.  This method
  26. // should be used when coming off of the Timer interrupt.  Normally,
  27. // you exit the Timer interrupt after this call, and continue on at
  28. // the next Timer interrupt (adjusting your print stream pointer
  29. // according to how many bytes were actually sent).  This demonstration
  30. // continues to call the print function until the stream is all printed.
  31. //
  32.   unsigned int segm = FP_SEG(printme);
  33.   unsigned int off = FP_OFF(printme);
  34.   int workint;
  35.   int anint = strlen(printme);     // number of bytes to print
  36.   unsigned char returnAL;
  37.   unsigned char aushort = (unsigned char)anint; // convert to 8 bits
  38.   do
  39.      {
  40.      asm mov cl,aushort         // number of bytes to print
  41.      asm mov bl,port
  42.      asm mov bh,2               // indicate source as Timer interrupt
  43.      asm push bx
  44.      asm push cx
  45.      asm mov ax,off             // DX:AX point to stream
  46.      asm mov dx,segm
  47.      asm pop cx
  48.      asm pop bx
  49.      dspler_despool();
  50.      asm mov returnAL,al        // AL has the number of bytes printed
  51.      workint = (int)returnAL;
  52.      aushort = aushort - returnAL;  // adjust number of bytes left to print
  53.      off += workint;            // adjust pointer to stream
  54.      }
  55.   while(aushort != 0);
  56. }
  57.  
  58. int main()
  59. {
  60.   asm mov ah,0         // All 8 ports: don't send direct to port.
  61.   asm mov al,0ffh      // All 8 ports: use BIOS.
  62.   dspler_init_me();    // Initialize PRTDRV.
  63. //
  64. // The following code shows how to send a single byte to print.
  65. // This method should be used when coming off of an IRQ, or off of
  66. // idle time.
  67. //
  68.   asm mov cl,1    // send 1 byte
  69.   asm mov ch,'a'  // character to send
  70.   asm mov bl,4    // port LPT1
  71.   asm mov bh,0    // indicate source was IRQ
  72.   dspler_despool();
  73. //
  74. // print to LPT1
  75. //
  76. printstuff(LPT1);
  77. //
  78. // print to COM1
  79. //
  80. printstuff(COM1);
  81. //
  82.   return 0;
  83. }
  84.