home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / AMISL092.ZIP / NOLPT.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-09-24  |  4.2 KB  |  168 lines

  1. ;-----------------------------------------------------------------------
  2. ; NOLPT.ASM    Public Domain 1992, 1995 Ralf Brown
  3. ;        You may do with this software whatever you want, but
  4. ;        common courtesy dictates that you not remove my name
  5. ;        from it.
  6. ;
  7. ; Trap output to a particular printer port and always return 'ready'
  8. ; or success, even if no printer is attached.
  9. ;
  10. ; Version 0.92
  11. ; LastEdit: 9/24/95
  12. ;-----------------------------------------------------------------------
  13.  
  14.     INCLUDE AMIS.MAC
  15.  
  16.     @Startup 2,00               ; need DOS 2.00                  
  17.                     ; this macro also takes care of declaring
  18.                     ; all the segments in the required order
  19.  
  20. ;-----------------------------------------------------------------------
  21. ;
  22. VERSION_NUM equ 005Ch    ; v0.92
  23. VERSION_STR equ "0.92"
  24.  
  25. ;-----------------------------------------------------------------------
  26. ;
  27. ; useful macros
  28. ;
  29. LODSB_ES MACRO
  30.     DB 26h,0ACh    ; LODSB ES:
  31.     ENDM
  32.  
  33. ;-----------------------------------------------------------------------
  34. ; Put the resident code into its own segment so that all the offsets are
  35. ; proper for the new location after copying it into a UMB or down into
  36. ; the PSP.
  37. ;
  38. TSRcode@
  39.  
  40. ;-----------------------------------------------------------------------
  41. ; Declare the interrupt vectors hooked by the program, then set up the
  42. ; Alternate Multiplex Interrupt Spec handler
  43. ;
  44.     HOOKED_INTS 17h            ; hooking INT 17h in add. to INT 2Dh
  45.     ALTMPX    'Ralf B','NOLPT',VERSION_NUM,'Turn printer port into bit bucket',,,,,Y
  46.  
  47. ;-----------------------------------------------------------------------
  48. ; Now the meat of the resident portion, the printer interrupt handler.
  49. ; We can save one byte by specifying the hardware reset handler set up by
  50. ; the ALTMPX macro above
  51. ;
  52.     ISP_HEADER 17h,hw_reset_2Dh
  53. printer_port equ byte ptr ($+2)
  54.     cmp    dx,0            ; will be patched to printer port
  55.     jne    use_old_int17
  56.         cmp     ah,0
  57.         je      int17_func00
  58.     cmp    ah,2
  59.     je    int17_func02
  60. use_old_int17:
  61.     jmp    ORIG_INT17h
  62.  
  63. int17_func00:
  64.     ; don't output character, simply return 'ready'
  65.     ; (fall through to func02)
  66. int17_func02:
  67.     mov    ah,90h            ; yes, printer is ready
  68.     iret
  69.  
  70. TSRcodeEnd@
  71.  
  72. ;-----------------------------------------------------------------------
  73.  
  74. _TEXT SEGMENT 'CODE'
  75.     ASSUME cs:_TEXT,ds:NOTHING,es:NOTHING,ss:NOTHING
  76.  
  77. banner    db 'NOLPT v',VERSION_STR,'  Public Domain 1992 Ralf Brown',13,10,'$'
  78. usage    db 'Usage:',9,'NOLPT 1',9,9,'disable LPT1',13,10
  79.     db 9,'...',13,10
  80.     db 9,'NOLPT 4',9,9,'disable LPT4',13,10
  81.     db 9,'NOLPT 1U',9,'uninstall from LPT1',13,10
  82.     db 9,'etc.',13,10
  83.     db '$'
  84. installed_msg     db "Installed on LPT"
  85. lpt_number     db " "
  86.          db ".",13,10,"$"
  87. cant_install_msg db "Unable to install.",13,10,"$"
  88. already_inst_msg db "Already installed.",13,10,"$"
  89. cant_remove_msg  db "Can't remove from memory.",13,10,"$"
  90. removed_msg     db "Removed.",13,10,"$"
  91.  
  92.  
  93.     @Startup2    Y
  94.     push    ds
  95.     pop    es
  96.     ASSUME    ES:_INIT
  97.     push    cs
  98.     pop    ds
  99.     ASSUME    DS:_TEXT
  100.     ;
  101.     ; say hello 
  102.     ;
  103.     DISPLAY_STRING banner
  104.     mov    bx,1000h        ; set memory block to 64K
  105.     mov    ah,4Ah
  106.     int    21h
  107.     mov    si,81h
  108. cmdline_loop:
  109.     lodsb_es
  110.     cmp    al,' '            ; skip blanks and tabs on commandline
  111.     je    cmdline_loop
  112.     cmp    al,9
  113.     je    cmdline_loop
  114.     mov    dx,offset _TEXT:usage
  115.         cmp     al,'1'
  116.     jb    exit_with_message
  117.     cmp    al,'4'
  118.     ja    exit_with_message
  119.     push    es            ; save for later use
  120.     mov    es,TGROUP@
  121.     ASSUME    ES:TGROUP
  122.         mov     byte ptr ALTMPX_SIGNATURE+14,al
  123.     mov    byte ptr lpt_number,al
  124.     sub    al,'1'
  125.     mov    printer_port,al
  126.     pop    es            ; restore addressing to PSP
  127.     ASSUME    ES:_INIT
  128.         lodsb_es                        ; get next character
  129.     and    al,0DFh            ; force to uppercase
  130.     cmp    al,'U'
  131.     jne    installing
  132. removing:
  133.     UNINSTALL cant_uninstall
  134.     DISPLAY_STRING removed_msg
  135.         mov     ax,4C00h
  136.     int    21h
  137.  
  138. cant_uninstall:
  139.         mov     dx,offset _TEXT:cant_remove_msg
  140.     jmp short exit_with_message
  141. already_installed:
  142.     mov    dx,offset _TEXT:already_inst_msg
  143. exit_with_message:
  144.     mov    ah,9
  145.     int    21h
  146.     mov    ax,4C01h
  147.     int    21h
  148.  
  149. installing:
  150.     ;
  151.     ; place any necessary pre-initialization here
  152.     ;
  153.     INSTALL_TSR ,BEST,,inst_notify,already_installed,cant_install
  154.  
  155. cant_install:
  156.     mov    dx,offset _TEXT:cant_install_msg
  157.     jmp    exit_with_message
  158.  
  159. inst_notify:
  160.     DISPLAY_STRING installed_msg
  161.     ret
  162.  
  163. _TEXT ENDS
  164.  
  165.      end INIT
  166.  
  167.  
  168.