[comp.sys.ibm.pc] LPT rerouting - can it be done?

wg@alux2.ATT.COM (Bill Gieske) (03/15/89)

I have two printers attached to my Leading Edge Model D, as follows:
    LPT1: dot-matrix
    LPT2: HP Deskjet
For most printer output (e.g. screen dumps, ho-hum reports, etc) I want to
use the dot-matrix printer.  When I want fancy, I go to the HP.  Things of
this nature are produced by software smart enough to recognize printers not
on port LPT1:.

This euphoric state has been disrupted by a music score-printing program (Dr.
T's Copyist II) which only talks to the LPT1: printer.  I can easily switch
the cables, but this defeats using the dot-matrix for most other instances
where this is more than acceptable.  

Can I get LPT1: output to go to LPT2: for the purposes of running Copyist?
Mode won't do it - the rerouted port must be com1 or com2.  Print can change
the DOS print device for the purposes of the print command, but nothing more.
I have DOS 3.1, by the way.  Would a later version of DOS offer what I want?
Can I do it now without upgrading to a more recent DOS?

Any info is appreciated.

Bill Gieske
AT&T
alux2!wg

todd@stiatl.UUCP (Todd Merriman) (03/15/89)

In article <235@alux2.ATT.COM> wg@alux2.ATT.COM (Bill Gieske) writes:
>
>Can I get LPT1: output to go to LPT2: ...........


ifdef DOCUMENTATION
; ****************************************************************************
.MODULE           LPT_SWAP
.LIBRARY          CLIB
.TYPE             function
.DESCRIPTION
   Swap the mapping to LPT1 and LPT2
.ARGUMENTS
   void lpt_swap()
.NARRATIVE
   Lpt_swap swaps the LPT1 and LPT2 definitions.
.APPLICATION      system
.SYSTEM           msdos
.RETURNS
   Nothing
.LANGUAGE         Assembly
.ENDOC            END DOCUMENTATION
; ****************************************************************************
endif

	INCLUDE	\LAT\HEADER\DOS.MAC	; symbols and macros for Lattice

SFRAME	STRUC
	SAV_BX	DW	?
	SAV_ES	DW	?
	REG_BP	DW	?		; base pointer to be pushed
	RTN_ADD	DW	?		; offset of return address
SFRAME	ENDS

	M_LPT1	EQU	08H		; memory location for LPT1 mapping
	M_LPT2	EQU	0AH		; memory location for LPT2 mapping
	SEGMT	EQU	40H		; segment for locations

; ****************************************************************************
; code
; ****************************************************************************
	PSEG				; begin program section

	PUBLIC	LPT_SWAP

LPT_SWAP	PROC	NEAR
	PUSH 	BP
	PUSH	ES
	PUSH	BX
	MOV	BP,SP

	MOV	AX,SEGMT		; load segment register
	MOV	ES,AX

	MOV	AX,WORD PTR ES:[M_LPT1]
	MOV	BX,WORD PTR ES:[M_LPT2]

	MOV	WORD PTR ES:[M_LPT2],AX
	MOV	WORD PTR ES:[M_LPT1],BX

	POP	BX
	POP	ES
	POP	BP
	RET
LPT_SWAP	ENDP

	ENDPS				; end program section

	END				; end assembly

; ****************************************************************************
; Test program
; ****************************************************************************

	PAGE	59,132
	INCLUDE	\LAT\HEADER\CSUB.MAC

CODE 	SEGMENT PUBLIC

ASSUME	CS:CODE, DS:CODE, SS:CODE, ES:CODE
	EXTRN	LPT_SWAP:NEAR

	ORG	100H			; .COM origin

MAIN	PROC	FAR

START:	PUSH	DS
	SUB	AX,AX
	PUSH	AX			; leave return address
	MOV	BP,SP

	DISPLAY	MSG
	CALL	LPT_SWAP
	MOV	SP,BP

	RET				; to DOS
MAIN	ENDP

MSG:	DB	'Swapping LPT1 and LPT2',CR,LF,CPMEOS

CODE	ENDS

	END	START

; ****************************************************************************
; End LPT_SWAP.ASM
; ****************************************************************************


	...!gatech!stiatl!todd
	Todd Merriman 404-377-8638
	Atlanta, GA

jwi@lzfme.att.com (Jim Winer @ AT&T, Middletown, NJ) (03/16/89)

In article <235@alux2.ATT.COM>, wg@alux2.ATT.COM (Bill Gieske) writes:
> 
> I have two printers attached to my Leading Edge Model D, as follows:
>     LPT1: dot-matrix
>     LPT2: HP Deskjet
> ...
> Can I get LPT1: output to go to LPT2: for the purposes of running Copyist?
> Mode won't do it - the rerouted port must be com1 or com2.  Print can change
> the DOS print device for the purposes of the print command, but nothing more.
> I have DOS 3.1, by the way.  Would a later version of DOS offer what I want?
> Can I do it now without upgrading to a more recent DOS?

Use a Centronics type (parallel) X switch. (See diagram below) A
probable low-cost source is CompuAdd (mail order). A switch should
cost about $49 and the extra cable you will need (Centronics M to F)
about $11. Also look for low cost cable suppliers in the back of PC
Magazine and others. This is cheaper than the time and effort you
will spend looking for a software way to do this.

__  __      ______
  \/
__/\__      ______
A Setting  B setting

Jim Winer ..!lzfme!jwi 

I believe in absolute freedom of the press.
I believe that freedom of the press is the only protection we have
	from the abuses of power of the church, 
	from the abuses of power of the state,
	from the abuses of power of the corporate body, and 
	from the abuses of power of the press itself.
Those persons who advocate censorship offend my religion.

cgs@umd5.umd.edu (Chris G. Sylvain) (03/16/89)

In article <3783@stiatl.UUCP> todd@stiatl.UUCP (Todd Merriman) writes:
>In article <235@alux2.ATT.COM> wg@alux2.ATT.COM (Bill Gieske) writes:
>>
>>Can I get LPT1: output to go to LPT2: ...........

>ifdef DOCUMENTATION
>; ****************************************************************************
>.MODULE           LPT_SWAP
>[...]
>; End LPT_SWAP.ASM
>; ****************************************************************************

My program is shorter than your program!! To whit:
; What this program does:
; ----------------------
;
; SWAPPORT.COM swaps the I/O port numbers for LPT1 and LPT2. After running
; the first time, DOS will use LPT2 when LPT1 or PRN is specified, and LPT1
; when LPT2 is specified. Subsequent invokations reverse the situation.
;
; Program History and Attributions:
; --------------------------------
;
;	This MASM version of SWAPPORT was derived from a DEBUG script printed
;	in the Q&A article of the January 1989 issue of PC Resource. The
;	script was written by the PCResource Staff in response to a reader
;	(Mary E. Campbell, Fort Wayne, Ind.) query. The printed DEBUG script
;	includes code comments, but the instruction is to leave the comments
;	out when creating SWAPPORT.SCR. This version includes comments and
;	avoids using the "archaic" INT 20h DOS exit service.
;
;	The entire contents of the January 1989 issue of PC Resource is
;	Copyright (c) 1988 by IDG Communications/Peterborough, Inc.
;
; Motivation for using this program:
; ---------------------------------
;
;	If you have two printers connected to your machine, and would rather
;	not switch cables when you wish for the STDPRN device to be LPT2
;	instead of LPT1, then you will want to use this program. You can
;	automate the switching back in forth in a batch file, for instance.
;
; The source code for the program:
; -------------------------------
;
PRNPoffs	EQU	198h	; offset into BIOS Data Area where the LPTx
				; port numbers are stored
CSEG	SEGMENT
	ASSUME CS:CSEG, DS:NOTHING
;
	ORG	100h	; use .COM memory layout
;
START:	xor	AX, AX		; clear AX
	mov	DS, AX		; set data Segment to 0000h
	mov	SI, PRNPoffs	; DS:SI will point to BIOS printer port data
	mov	AX, [SI]	; get LPT1 port address
	mov	BX, [SI+2]	; get LPT2 port address
	xchg	AX, BX		; exchange register contents
	mov	[SI], AX	; put LPT2 address in place of LPT1
	mov	[SI+2], BX	; put LPT1 address in place of LPT2
	mov	AX, 4C01h
	int	21h		; exit with return code == 01
;
CSEG	ENDS
;
	END	START

A uuencoded (what, archive? you must be joking :-) binary will be provided
to anyone interested who is MASMless.
-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..
   ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2
   UUCP: ..!uunet!umd5.umd.edu!cgs