Newer
Older
Microsoft / ljtoibm / LJTOIBM.ASM
@tundra tundra on 24 May 2012 5 KB Initial revision

		PAGE	40,132
		TITLE	LJTOIBM.ASM
;
;
; **********
; * LJTOIBM.ASM - Laser Jet -> IBM Graphics XLATE - VERSION 1.2.3
; * LAST MODIFIED: 11/24/85
; * COPYRIGHT (C) 1985 BY T.A. DANELIUK
; **********
;
;
; **********
; * SYSTEM EQUATES
; **********
;
;
SPACE		EQU	20H				; ASCII SPACE
DOS		EQU	21H				; DOS INTERRUPT
EOL		EQU	0A0DH				; END-OF-LINE STRING
EXIT		EQU	4CH				; NORMAL EXIT TO DOS
GET_IR_VECT	EQU	35H				; GET VECTOR FROM IR TABLE
PRINTER_IR	EQU	17H				; PRINTER IR VECTOR
PRINT_STRING	EQU	09H				; IR TO PRINT STRING ON DISPLAY
SET_IR_VECT	EQU	25H				; SET AN IR VECTOR IN TABLE
TAB		EQU	09H				; ASCII TAB
TAIL_BEGIN	EQU	81H				; OFFSET OF COMMAND TAIL IN PSP
TAIL_LENGTH	EQU	80H				; LOC OF LENGTH BYTE IN CMD TAIL
TERMINATE	EQU	31H				; TERMINATE/STAY RESIDENT
;
;
;
; **********
; * CODE SEGMENT
; **********
;
;
LJ_XL		SEGMENT WORD 'CODE'
		ASSUME	CS:LJ_XL,DS:LJ_XL,ES:LJ_XL
;
;

		ORG	100H
;
START_RUN	EQU	THIS BYTE
;
;
START:		JMP	INIT				; GO TO INITIALIZATION CODE
;
;
; TRANSLATION TABLE FROM IBM TO LASER JET CHARACTER SET
;
;
;
TABLE		DB	000H,001H,002H,003H,004H,005H,006H,007H
		DB	008H,009H,00AH,00BH,00CH,00DH,00EH,00FH
		DB	0FDH,0FBH,012H,013H,014H,015H,016H,017H
		DB	018H,019H,01AH,01BH,01CH,01DH,01EH,01FH
		DB	020H,021H,022H,023H,024H,025H,026H,027H
		DB	028H,029H,02AH,02BH,02CH,02DH,02EH,02FH
		DB	030H,031H,032H,033H,034H,035H,036H,037H
		DB	038H,039H,03AH,03BH,03CH,03DH,03EH,03FH
		DB	040H,041H,042H,043H,044H,045H,046H,047H
		DB	048H,049H,04AH,04BH,04CH,04DH,04EH,04FH
		DB	050H,051H,052H,053H,054H,055H,056H,057H
		DB	058H,059H,05AH,05BH,05CH,05DH,05EH,05FH
		DB	060H,061H,062H,063H,064H,065H,066H,067H
		DB	068H,069H,06AH,06BH,06CH,06DH,06EH,06FH
		DB	070H,071H,072H,073H,074H,075H,076H,077H
		DB	078H,079H,07AH,07BH,07CH,07DH,07EH,07FH
		DB	0B4H,0CFH,0C5H,0C0H,0CCH,0C8H,0D4H,0B5H
		DB	0C1H,0CDH,0C9H,0DDH,0D1H,0D9H,0D8H,0D0H
		DB	0DCH,0D7H,0D3H,0C2H,0CEH,0CAH,0C3H,0CBH
		DB	0EEH,0DAH,0DBH,0BFH,0BBH,0BCH,020H,0BEH
		DB	0C4H,0D5H,0C6H,0C7H,0B7H,0B6H,0F9H,0FAH
		DB	0B9H,02DH,02DH,0F8H,0F7H,0B8H,0FBH,0FDH
		DB	07FH,07FH,07FH,07CH,07CH,07CH,02DH,02DH
		DB	02DH,07CH,07CH,02DH,02DH,02DH,02DH,02DH
		DB	02DH,02DH,02DH,07CH,02DH,02BH,07CH,07CH
		DB	02DH,02DH,02DH,02DH,07CH,02DH,02BH,02DH
		DB	02DH,02DH,02DH,02DH,02DH,02DH,02DH,02BH
		DB	02BH,02DH,02DH,0FCH,0FCH,0FCH,0FCH,0FCH
		DB	020H,0DEH,020H,020H,020H,020H,020H,020H
		DB	020H,020H,020H,020H,020H,0D2H,020H,020H
		DB	020H,0FEH,020H,020H,020H,020H,020H,020H
		DB	0B3H,020H,020H,020H,020H,020H,020H,020H
;
;
LJ_IBM	EQU	THIS BYTE
;
; FIRST COMES THE HEADER
;
		JMP SHORT ENTRY
		DW OFFSET END_RUN-1			; LAST ADDR. OF RESIDENT CODE
MOD_NAME	DB	'LJTOIBM '			; NAME OF MODULE IN ASCII
;
; THE FOLLOWING 4 HEADER BYTES ARE APPLICATION DEFINED.
;
		DB	0
		DB	0
		DB	0
		DB	0
;
; NOW THE ACTUAL RESIDENT INTERRUPT CODE
;
ENTRY:		PUSH	AX				; SAVE CHARACTER
		OR	AH,AH				; WE ONLY DEAL WITH 0
		JNZ	RUN_DONE
		PUSH	BX
		MOV	BX, OFFSET TABLE		; GET TABLE LOCATION
		PUSH	DS
		PUSH	CS
		POP	DS
		XLAT					; GET SUBSTITUTE CHARACTER
		POP	DS
		POP	BX
RUN_DONE:	PUSHF					; FAKE AN INTERRUPT
		CALL DWORD PTR	CS:OLD_VECTOR		; CALL ORIGINAL ROUTINE
;
GO_BACK		EQU	THIS BYTE
;
		CLI					; INTERRUPTS OFF FOR NOW
		MOV	CS:TEMP,AH			; SAVE RETURN STATUS
		POP	AX				; GET ORIGINAL CHARACTER BACK
		MOV	AH,CS:TEMP
		IRET					; BACK TO THE OUTSIDE WORLD
;
OLD_VECTOR	DD	?
TEMP		DB	?
;
END_RUN		EQU	THIS BYTE
;
;
		PAGE
; **********
; * LOADER/INSTALL CODE
; **********
;
;
INIT: 		PUSHF					; SAVE IR STATUS
		CLI					; TURN 'EM OFF FOR NOW
;
;
; DISPLAY BANNER
;
;
		MOV	DX,OFFSET MSG1
		MOV	AH,PRINT_STRING
		INT	DOS
;
;
; GET EXISTING PRINTER VECTOR AND SAVE FOR CHAINING
;
;
CHAIN_IR:	MOV	AH,GET_IR_VECT			; FUNCTION NUMBER
		MOV	AL,PRINTER_IR			; INTERRUPT NUMBER
		INT	DOS
		MOV	BP,OFFSET OLD_VECTOR
		MOV	CS:[BP],BX			; WE GOT THE OLD VECTOR IN ES:BX
		MOV	BX,ES				; GET SEGMENT
		MOV	CS:[BP+2],BX
;
;
; STUFF NEW VECTOR INTO TABLE SO WE GET CONTROL FIRST
;
;
		MOV	DX,OFFSET LJ_IBM		; VECTOR IN DS:DX - DS ALREADY OK
		MOV	AH,SET_IR_VECT
		MOV	AL,PRINTER_IR
		INT	DOS
;
;
; TERMINATE, BUT STAY RESIDENT EXIT CODE
;
;
RESIDE_EXIT:	MOV	AX,OFFSET END_RUN		; CALCULATE MODULE LENGTH IN PARAS
		MOV	CL,10H				; DIVISOR
		DIV	CL
		AND	AH,AH				; ANY REMAINDER?
		JZ	NO_REMAINDER			; NO
		INC	AL				; YES, BUMP A FULL PARAGRAPH
NO_REMAINDER:	XOR	DX,DX				; CLEAR DX
		MOV	DL,AL				; TERMINATE FN. NEEDS LENGTH IN DX
		XOR	AL,AL				; SET RETURN ERROR CODE TO 0
		MOV	AH,TERMINATE			; TERMINATE & STAY RESIDENT FN
		POPF					; RESET ORIGINAL IR STATUS
		INT	DOS				; DO THE DOS CALL
		PAGE
; BANNER MESSAGE STRINGS
;
;
MSG1		DW	EOL
		DB	'LJTOIBM - LASER JET TO IBM CHARACTER XLATE - Version 1.2.3'
		DW	EOL
		DB	'Copyright (c) 1985, T.A. Daneliuk, Chicago, IL 60625'
		DW	EOL
		DB	'Permission Granted To Reproduce This Program'
		DW	EOL
		DB	'For PERSONAL, *** NON-COMMERCIAL *** Use Only!'
		DW	EOL,EOL
		DB	'$'
;
;
;
LJ_XL		ENDS
		END	START