home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / lowlevel / amisl / nolpt.asm < prev    next >
Assembly Source File  |  1992-09-12  |  4KB  |  166 lines

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