home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / prnwrite.asm < prev    next >
Encoding:
Assembly Source File  |  1994-03-13  |  1.2 KB  |  42 lines

  1. ;-----------------------------------------------------------------------;
  2. ; PRNWRITE.ASM                                ;
  3. ;                                    ;
  4. ; Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits.        ;
  5. ; Redistributed by permission.                        ;
  6. ;-----------------------------------------------------------------------;
  7. %    .MODEL    memmodel,c
  8.  
  9.     .CODE
  10.     PUBLIC    prnwrite
  11. ;-----------------------------------------------------------------------;
  12. ; Writes the specified number of characters to the standard list    ;
  13. ; device.                                ;
  14. ;                                    ;
  15. ; Usage:    int prnwrite(char *buffer,int count);            ;
  16. ; Returns:    0 if successful or a non-zero value if an error        ;
  17. ;        occurred.                        ;
  18. ;-----------------------------------------------------------------------;
  19. prnwrite    PROC buffer:PTR BYTE,count:WORD
  20.     mov    ah,40h            ;Write characters to the standard
  21.     mov    bx,4            ; list device
  22.     mov    cx,count        ;Number of characters to write
  23.     IF    @DataSize
  24.     push    ds
  25.     lds    dx,buffer
  26.     ELSE
  27.     mov    dx,buffer
  28.     ENDIF
  29.     int    21h            ;Call MS-DOS
  30.     IF    @DataSize
  31.     pop    ds
  32.     ENDIF
  33.     mov    dx,ax            ;dx = number of characters written
  34.     mov    ax,0            ;Clear ax
  35.     adc    ax,0            ;Increment ax if carry set
  36.     cmp    dx,count        ;Increment ax if not all
  37.     adc    ax,0            ; characters were written
  38.     ret
  39. prnwrite    ENDP
  40.  
  41.     END
  42.