Category : Printer Utilities
Archive   : SETPRN.ZIP
Filename : SETPRN.ASM

 
Output of file : SETPRN.ASM contained in archive : SETPRN.ZIP

COMMENT^ ** SETPRN.COM ** Last Rev. 3/11/91 ** Vincent T. Bly **
-------------------------------------------------------------------
| |
| PURPOSE: Provide a easy method of setting printer parameters |
| from the DOS command level or from a batch file. |
| |
| FUNCTION: Send a user specified text string to the printer. |
| The string may contain control characters consisting |
| of decimal numbers enclosed in brackets ("[" and "]"). |
| The normal ending carriage return/line feed may be |
| suppressed by a trailing semicolon (";") or comma (",") |
| in the same manner as the BASIC LPRINT command. |
| |
| TO USE: From DOS, type SETPRN followed by a space and the text |
| string, then press . For examples, see the file |
| SETPRN.DOC |
| |
| TO MAKE: Assemble with MASM or TASM and link with LINK or TLINK. |
| Convert the resulting .EXE file to .BIN with EXE2BIN. |
| Convert the .BIN file to .COM with RENAME. |
| |
| NOTE: For the sake of simplicity, SETPRN does not make |
| extensive checks on the current state of the system. |
| This could conceivably cause problems in a multi-user |
| environment. |
| |
-------------------------------------------------------------------^

CSEG SEGMENT
ASSUME CS:CSEG,DS:CSEG

ORG 80H ;----------- in Program Segment Prefix
NUM_CHARS LABEL BYTE ;number of characters in argument
ORG 82H
ARGTX LABEL BYTE ;start of text (after leading blank)

ORG 100H ;---------- start of actual program
;(this ORG 100H is necessary for a .COM file)

;~~ Check command line argument & set-up to read it ~~~~~~~~~~~~~~~~~~~~~~~~~~
START: MOV BX,OFFSET ARGTX ;point to start of text argument
MOV CL,[NUM_CHARS] ;set CX to number of chars in argument
MOV CH,0 ; "
CMP CX,2 ;is there at least 1 char after blank?
JAE START1 ;if so, skip ahead
JMP LST_DOC ;if not, print documenation summary
START1: SUB CX,2 ;discount char count for leading blank
;and possible trailing "," or ";"
CMP CX,0 ;is there only one character?
JE TERM ;if so, handle w/termination routine

;~~~ Parse argument & convert control codes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CHAR_2_PRN: MOV DL,[BX] ;get character
CMP DL,'[' ;is it the control prefix char?
JNE SEND_IT ;if not, go print char
MOV AL,0 ;initialize char value to 0
MOV DH,10D ;digit multiplier
CONVERT_DIGIT: INC BX ;skip to next char
DEC CX ; "
MOV DL,[BX] ;get char code into DL
JZ EXIT2 ;exit if at end of text (CX = 0)
CMP DL,']' ;is it the control code suffix?
JE PRE_SEND_IT ;if so, go prepare to print code
SUB DL,'0' ;convert digit code to value
MUL DH ;mult. char value (in AL) by 10
ADD AL,DL ;add digit value to char value
JMP CONVERT_DIGIT ;loop back to convert next digit
PRE_SEND_IT: MOV DL,AL ;put converted code into DL

;~~~ Send character to printer & loop back for next ~~~~~~~~~~~~~~~~~~~~~~~~~
SEND_IT: CALL PRNT_CHR ;go print character in DL
INC BX ;point to next character
LOOP CHAR_2_PRN ;repeat until done

;~~~ Handle termination with ";" or "," ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TERM: MOV DL,[BX] ;get last character
CMP DL,';' ;is it a semicolon?
JE COMPLETE ;if so, skip to completion routine
CMP DL,',' ;is it a comma?
JNE CR_LF ;if not, go print CR & LF
MOV DL,09 ;set DL to tab character
CALL PRNT_CHR ;go print tab
JMP COMPLETE ;skip to completion routine
CR_LF: CALL PRNT_CHR ;go print last character
CR_LF1: MOV DL,0DH ;set DL to carriage return
CALL PRNT_CHR ;go print CR
MOV DL,0AH ;set DL to line feed
CALL PRNT_CHR ;go print LF

;~~~ Display termination message & return to DOS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPLETE: MOV DX,OFFSET MESSAGE ;point to completion message
MOV AH,9 ;code for DOS display string function
INT 21H ;display message via DOS function call
EXIT1: INT 20H ;terminate via DOS function call
MESSAGE: DB '* Done *$'

;~~~ Display documentation summary if null argument ~~ (added 3/11/91 VB) ~~~~
LST_DOC: MOV CX,23 ;number of lines of summary
MOV DX,OFFSET DOC ;point to start of documentation list
MOV BX,DX ;point to DB 1 first time through
DOC_LOOP: XOR AH,AH ;get string length into AX
MOV AL,[BX]
ADD DX,AX ;point to # before string
MOV BX,DX ;save #'s address in BX
PUSH BX ;save before INT, just to be sure
PUSH DX
INC DX ;point DX to start of string
MOV AH,9 ;code for DOS display string function
INT 21H ;display string via DOS function call
POP DX ;restore regs
POP BX
LOOP DOC_LOOP ;repeat until all lines displayed
INT 20H ;terminate via DOS function call

;~~~ Send one character to printer via DOS function call ~~~~~~~~~~~~~~~~~~~~~
PRNT_CHR: MOV AH,5 ;code for DOS printer output function
INT 21H ;send to printer via DOS function call
RET ;back to calling routine

;~~~ Handle case where end of text encountered while parsing control code ~~~~
EXIT2: CMP DL,']' ;is it the control code suffix?
JNE TERM ;if not, go do normal completion
;(w/o printing control code)
MOV DL,AL ;else, put control code in DL
CALL PRNT_CHR ;go print control code
JMP CR_LF1 ;go print CR/LF & complete (3/21/86 VB)

;~~~ Documentation summary text data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DOC: DB 1 ; dummy value to jump-start loop
DB 53, 0DH,0AH,' *** SETPRN by Vince Bly Rev. 3/11/91 ***',0DH,0AH,'$'
DB 4, 0DH,0AH,'$'
DB 57, ' USAGE: (from the DOS command line or a batch file)',0DH,0AH,'$'
DB 35, ' SETPRN string_to_print',0DH,0AH,'$'
DB 4, 0DH,0AH,'$'
DB 58, ' where - string_to_print is any string of printable',0DH,0AH,'$'
DB 59, ' characters. The string should NOT be enclosed',0DH,0AH,'$'
DB 58, ' in quotes, although quotes may be included in',0DH,0AH,'$'
DB 22, ' the text.',0DH,0AH,'$'
DB 59, ' Non-printable control codes may be included',0DH,0AH,'$'
DB 61, ' by enclosing their decimal ASCII value in square',0DH,0AH,'$'
DB 45, ' brackets--see the example below.',0DH,0AH,'$'
DB 58, ' A terminating semicolon (";") may be added',0DH,0AH,'$'
DB 57, ' to suppress a CR-LF, or a comma (",") may be',0DH,0AH,'$'
DB 59, ' appended to advance to the next tab stop--like',0DH,0AH,'$'
DB 38, ' the BASIC LPRINT command.',0DH,0AH,'$'
DB 4, 0DH,0AH,'$'
DB 16, ' EXAMPLES:',0DH,0AH,'$'
DB 40, ' SETPRN This is a test 01234',0DH,0AH,'$'
DB 61, ' This prints the string "This is a test 01234"',0DH,0AH,'$'
DB 26, ' SETPRN [27]E;',0DH,0AH,'$'
DB 60, ' This sends the control string ESC "E" to the',0DH,0AH,'$'
DB 38, ' printer without a CR-LF.$'
CSEG ENDS

END START



  3 Responses to “Category : Printer Utilities
Archive   : SETPRN.ZIP
Filename : SETPRN.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/