Category : Printer Utilities
Archive   : PRNTST11.ZIP
Filename : PRNTST.ASM

 
Output of file : PRNTST.ASM contained in archive : PRNTST11.ZIP
_CODE segment para public 'CODE'

assume cs:_CODE,ds:_CODE,es:_CODE,ss:_CODE

org 100h

begin: jmp topcode

strlen equ 26

author db '° Printer Port Test Program.'
db 0Ah,0Dh
db '° By Julio Monroy.'
db 0Ah,0Dh
db '$'

crlf db 0Ah,0Dh,24h
bit_msg db 'Bit '
db '$'
bits db ' (printer timed out) : $'
db ' (unused) : $'
db ' (unused) : $'
db ' (I/O error) : $'
db ' (printer selected) : $'
db ' (out of paper) : $'
db ' (printer acknowledge) : $'
db ' (printer not busy) : $'

m_busy db 'The printer appears to be busy printing.$'
m_offline db 'The printer appears to be offline.$'
m_nopaper db 'The printer appears to be out of paper.$'
m_online db 'The printer appears to be on-line and ready.$'
m_notready db 'The printer is not responding or not ready.$'
m_notsure db 'Unknown status. Do you have a printer port attached?$'

help_msg db '(c) 1991 Incipits Software. by Julio Monroy',0Ah,0Dh
db 'Direct Parallel Port Interrogator'
db 0Ah,0Dh,'Usage is:'
db 0Ah,0Dh,' PRNTST [/n] [/R]'
db 0Ah,0Dh
db 0Ah,0Dh,'Where /R means perform test repeatedly. This is optional.'
db 0Ah,0Dh,'Where n is either 1, 2, or 3 (1=LPT1,etc.).'
db 0Ah,0Dh
db 0Ah,0Dh,'Example: PRNTST /3 /R = performs test repeatedly on LPT3.'
db 0Ah,0Dh,'Example: PRNTST /2 = performs single test on LPT2.'
db 0Ah,0Dh,'Example: PRNTST = performs single test on LPT1.'
db 0Ah,0Dh
db 0Ah,0Dh,'If no command line parameters are used, the default is LPT1 with single test.'
db 0Ah,0Dh,'$'

bitoff db 'is OFF$' ;ASCII message
biton db 'is ON $' ;ASCII message
bitstat db 26 dup(0),24h ;Dummy string message

bitnum db 00h ;tracks bit we are testing
bitfld db 01h
testbyte db 00h ;Holds port status after INT 17h call
testrep db 00h ;Repeat test variable
port dw 00h ;Holds which port we are testing

topcode:
; Check for help request
mov si,81h ;start of command line
cld

begin1: lodsb ;load byte from command line
cmp al,'a' ;check for lower case alpha
jb ok
cmp al,'z'
ja ok
sub al,20h ;yes? Convert to upper case.
ok:
cmp al,0Dh
je begin6 ;EOL
cmp al,31h ;check for ASCII "1" (port to test)
je begin2 ;save port number
cmp al,32h ;check for ASCII "2" (port to test)
je begin3 ; " "
cmp al,33h ;check for ASCII "3" (port to test)
je begin4 ; " "
cmp al,52h ;check for repetitive test
je begin5 ;
cmp al,2Fh ;
jbe begin1 ;white space

mov dx,offset help_msg ;show help

errout: ;abort program with error
call display
mov ax,4C01h
int 21h

begin5: mov testrep,1 ;Save repeat test variable
jmp begin1 ;go back

begin2: mov port,00h
jmp begin1
begin3: mov port,01h
jmp begin1
begin4: mov port,02h
jmp begin1

begin6: call cls
begin7:
xor dx,dx
call gotoXY ;Position cursor at top of screen
call linefeed
mov dx,offset author ;show program & author name
call display ;
call linefeed ;
push cx

push bx ;Portions of code section taken from
push es ;"The IBM PC Technical Refererence"
mov ax,0040H ;manual system-bios reference section
assume es:nothing ;
mov es,ax ;
mov bx,port ;establish proper port address
mov dx,es:[bx+08H] ;locate address offset in BIOS data area
inc dx ;
in al,dx ;Perform a direct port interrogation.
in al,dx ;
mov ah,al ;
and ah,0F8H ;check for our bits
xor ah,48H ;
pop es ;
pop bx ;

mov cs:testbyte,ah ;Save it
mov cx,8 ;Set for 8 iterations (for 8 bits!)

l1: push cx ;Show "Bit " string
mov dx,offset bit_msg ;
call display ;

mov ah,02h ;Setup for character output to video
mov dl,bitnum ;and show which bit we are on.
add dl,30h ;Add 30h to convert to ASCII char
int 21h ;call DOS

lea si,bits ;Point to our string array
lea di,bitstat ;and to our dummy storage string.
mov al,bitnum ;Which bit are we on?
cbw ;
mov cl,strlen ;Setup multiplicand.
mul cl ;Multiply to get offset of array.
add si,ax ;Move pointer to array offset.
mov cx,strlen ;Set for 26 character iterations..

l2: cld
lodsb ;Move our data into dummy string.
stosb ;
loop l2 ;

mov dx,offset bitstat ;Show our bit significance message.
call display ;
mov al,testbyte ;Fetch our stored byte.
test al,bitfld ;Test if bit is high
jnz l3 ;Yes? Show it as being on...
mov dx,offset bitoff ;otherwise show it is off.
jmp l4 ;
l3: mov dx,offset biton ;

l4: call display ;Show it is ON or OFF.
call linefeed ;
shl bitfld,1 ;Move to next bit.
inc bitnum ;Increment our bit tracker.
pop cx ;Restore our original loop counter.
loop l1 ;

endit:
call show_stat ;Show string telling port status.

mov ah,0Bh ;test for keypressed
int 21h
cmp al,0 ;Yes? Exit program.
jne out1 ;No? setup for next sample
cmp testrep,0 ;
je out2 ;
mov cx,8 ;
mov bitnum,0 ;
mov bitfld,1 ;
jmp begin7 ;restart sample

out1: mov ah,8 ;clear keyboard buffer
int 21h ;
out2: mov ax,4C00h ;Else, exit gracefully.
int 21h


show_stat proc near

cmp testbyte,10h ;This part tests the overall port status.
jne l5 ;It determines what bits are set and
mov dx,offset m_busy ;displays a message showing the state.
jmp l9 ;Busy printing?
l5: cmp testbyte,18h ;
jne l6 ;
mov dx,offset m_offline ;Printer offline?
jmp l9 ;
l6: cmp testbyte,38h ;
jne l7 ;
mov dx,offset m_nopaper ;No paper in printer?
jmp l9 ;
l7: cmp testbyte,90h ;
jne l8 ;
mov dx,offset m_online ;Printer off-line?
jmp l9 ;
l8: cmp testbyte,68h ;
jne l10 ;
mov dx,offset m_notready ;Printer off or not responding
jmp l9 ;
l10: mov dx,offset m_notsure ;Unknown port configuration.

l9: call linefeed ;
call display ;Show our overall status.
mov ax,0A20h ;Clear to end of line
mov bh,0 ;
mov bl,07h ;
mov cx,10h ;
int 10h ;
call linefeed ;
ret ;

show_stat endp


linefeed proc near ;Generic linefeed procedure.
;
push dx ;
mov dx,offset crlf ;
call display ;Call our display function
pop dx ;
ret ;

linefeed endp

display proc near
;Generic DOS string display function.
mov ah,9 ;
int 21h ;
ret ;

display endp

cls proc near ;Clears the screen

push ax
push bx
push cx
push dx

mov ax,0600h
mov bh,07h
mov cx,0
mov dh,18h
mov dl,4Fh
int 10h


pop dx
pop cx
pop bx
pop ax

ret

cls endp


gotoXY proc near ; Positions cursor at X,Y position.
; DH = Y coordinate
push ax ; DL = X coordinate
push bx
push dx
push cx

mov ah,02h
mov bh,0
int 10h

pop cx
pop dx
pop bx
pop ax

ret

gotoXY endp

_CODE ends

end begin


  3 Responses to “Category : Printer Utilities
Archive   : PRNTST11.ZIP
Filename : PRNTST.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/