home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / LPTMON10.ZIP / LPTMON.ASM < prev    next >
Assembly Source File  |  1994-01-16  |  6KB  |  284 lines

  1. ; LPTMON.ASM by Celso Minnitti, Jr
  2. ;
  3. ; Date: 01-16-1994
  4. ;
  5. ; Compile:  TASM /m2 LPTMON
  6. ;        TLINK /t LPTMON
  7.  
  8. ATTR            EQU     70h
  9. REFRESH         EQU     9                        ;55ms*9 = 0.495 seconds
  10.  
  11. _TEXT   segment byte public 'CODE'
  12.     assume cs:_TEXT, ds:_TEXT
  13.         org    100h
  14.  
  15. start:          jmp     install
  16. pause           db      0
  17.  
  18. old08           dd      0
  19. old0f        dd    0
  20. old2f        dd    0
  21.  
  22. column          dw      70 * 2
  23. lptIO        dw    378h
  24. vidseg        dw    0b800h
  25.  
  26. count_08        db      0
  27. count_0f    db    0             ;counter of int fh (irq 7)
  28.  
  29.  
  30. int_08:     pushf
  31.         call    cs:old08
  32.         pushf
  33.         cmp    byte ptr cs:[pause],1
  34.         je    int08_ret
  35.         inc    byte ptr cs:[count_08]
  36.         cmp    byte ptr cs:[count_08],REFRESH
  37.         jb    int08_ret
  38.  
  39.         push    ax
  40.         push    cx
  41.                 push    dx
  42.         push    di
  43.         push    si
  44.         push    ds
  45.         push    es
  46.  
  47.         push    cs
  48.         pop    ds
  49.         mov    byte ptr [count_08],0
  50.  
  51.         call    print_lptmon
  52.  
  53.         pop    es
  54.         pop    ds
  55.         pop    si
  56.         pop    di
  57.         pop    dx
  58.         pop    cx
  59.         pop    ax
  60. int08_ret:    popf
  61.         iret
  62.  
  63. int_0f:     inc    byte ptr cs:[count_0f]
  64.         jmp    cs:old0f
  65.  
  66. int_2f:     cmp    ah,90h
  67.         je    int2f_00
  68.         jmp    cs:old2f
  69.  
  70. int2f_00:    cmp    al,0             ;is function 0?
  71.         jne    int2f_01
  72.         mov    ax,0ffffh         ;return 0ffffh to show that
  73.         iret                 ;lptmon is resident
  74.  
  75. int2f_01:    cmp    al,1             ;is function 1?
  76.         jne    int2f_02
  77.         xor    byte ptr cs:[pause],1     ;turn on/off lptmon
  78.         iret
  79.  
  80.  
  81. int2f_02:    push    ds             ;function 2, uninstall
  82.         mov    ax,2508h         ;restore int 8
  83.         lds    dx,cs:[old08]
  84.         int    21h
  85.  
  86.         mov    al,0fh             ;restore int 0fh
  87.         lds    dx,cs:[old0f]
  88.         int    21h
  89.  
  90.         mov    al,2fh             ;restore int 2fh
  91.         lds    dx,cs:[old2f]
  92.         int    21h
  93.  
  94.         mov    es,word ptr cs:[2ch]     ;release enviroment
  95.         mov    ah,49h
  96.         int    21h
  97.  
  98.         push    cs
  99.         pop    es             ;release psp
  100.         mov    ah,49h
  101.         int    21h
  102.         pop    ds
  103.         iret
  104.  
  105. ;--------------------------------------------------------------------------
  106. print_lptmon:    cld
  107.         push    cs
  108.         pop    es
  109.         call    read_port
  110.  
  111.                 mov     es,[vidseg]
  112.                 mov     di,word ptr [column]
  113.         mov    ax,6             ;print 6 lines
  114.         mov    si,offset LPTMON
  115.  
  116. print_lptmon1:    mov    cx,10             ;each line has 10 chars
  117.         rep    movsw
  118.         add    di,140             ;go to next line
  119.         dec    ax
  120.         jnz    print_lptmon1
  121.         ret
  122.  
  123. ;--------------------------------------------------------------------------
  124. read_port:    mov    dx,[lptIO]         ;get port address
  125.         xor    si,si
  126.         mov    cx,3
  127.  
  128. read_port1:    in    al,dx
  129.         mov    di,word ptr [si+XY]
  130.         call    print8h
  131.         inc    si
  132.         inc    si
  133.         inc    dx
  134.         loop    read_port1
  135.  
  136.         mov    al,[count_0f]
  137.         mov    di,word ptr [si+XY]
  138.         call    print8h
  139.         ret
  140.  
  141. ;**************************************************************************
  142. ;                PRINT8H
  143. ;
  144. ;enter:     AL = # to print in hexadecimal at ES:DI
  145. ;**************************************************************************
  146. print8h     proc    near
  147.         push    ax
  148.         push    cx
  149.         push    dx
  150.         push    di
  151.  
  152. pri81:        mov    cx,2
  153.         mov    dl,al
  154.         mov    ah,ATTR
  155. pri82:        rol    dl,4
  156.         mov    al,dl
  157.         and    al,0fh
  158.         daa
  159.         add    al,0f0h
  160.         adc    al,40h
  161.         stosw
  162.         loop    pri82
  163.  
  164.         pop    di
  165.         pop    dx
  166.         pop    cx
  167.         pop    ax
  168.         ret
  169. print8h     endp
  170.  
  171. XY        dw    offset LPTMON+1*20+6*2
  172.         dw    offset LPTMON+2*20+6*2
  173.         dw    offset LPTMON+3*20+6*2
  174.         dw    offset LPTMON+4*20+6*2
  175.  
  176. ; This data was created using Thedraw
  177. LPTMON LABEL BYTE
  178.         DB      '┌',122,'─',122,'L',126,'P',126,'T',126,'M',126,'O',126
  179.         DB      'N',126,'─',122,'┐',122,'│',122,'3',123,'7',123,'8',123
  180.         DB      '=',123,' ',123,' ',122,' ',122,' ',122,'│',122,'│',122
  181.         DB      '3',123,'7',123,'9',123,'=',123,' ',123,' ',122,' ',122
  182.         DB      ' ',122,'│',122,'│',122,'3',123,'7',123,'A',123,'=',123
  183.         DB      ' ',123,' ',122,' ',122,' ',122,'│',122,'│',122,'I',123
  184.         DB      'R',123,'Q',123,'7',123,'=',123,' ',123,' ',122,' ',122
  185.         DB      '│',122,'└',122,'─',122,'─',122,'─',122,'─',122,'─',122
  186.         DB      '─',122,'─',122,'─',122,'┘',122
  187.  
  188. ;--------------------------------------------------------------------------
  189. install:    mov    al,byte ptr ds:[80h]     ;get # of chars in cmd line
  190.         cmp    al,2             ;space + 1st argument
  191.         jne    install0
  192.  
  193.         mov    al,byte ptr ds:[82h]     ;get 1st argument
  194.                 cmp     al,'u'
  195.         je    uninstall
  196.         cmp    al,'U'
  197.         je    uninstall
  198.         cmp    al,'-'                   ;turn pause on/off
  199.         jne    install0
  200.         mov    ax,9001h
  201.         int    2fh
  202.         jmp    exit
  203.  
  204. install0:    mov    ax,9000h         ;is lptmon already installed?
  205.         int    2fh
  206.         cmp    ax,0ffffh
  207.         jne    install1
  208.         mov    dx,offset msg00      ;already installed
  209.         jmp    print
  210.  
  211. install1:    mov    ah,9             ;ok to install
  212.         mov    dx,offset copyright
  213.         int    21h
  214.  
  215.         call    init             ;setup vidseg variable
  216.  
  217.         mov    ax,3508h         ;save int 08
  218.         int    21h
  219.         mov    word ptr [old08],bx
  220.         mov    word ptr [old08+2],es
  221.         mov    dx,offset int_08
  222.         mov    ah,25h             ;set int 08
  223.         int    21h
  224.  
  225.         mov    ax,350fh         ;save int 0f
  226.         int    21h
  227.         mov    word ptr [old0f],bx
  228.         mov    word ptr [old0f+2],es
  229.         mov    dx,offset int_0f
  230.         mov    ah,25h             ;set int 0fh
  231.         int    21h
  232.  
  233.         mov    ax,352fh         ;save int 2fh
  234.         int    21h
  235.         mov    word ptr [old2f],bx
  236.         mov    word ptr [old2f+2],es
  237.         mov    dx,offset int_2f
  238.         mov    ah,25h             ;set int 2fh
  239.         int    21h
  240.  
  241.         mov    dx,offset install     ;tsr
  242.         int    27h
  243.  
  244. print:        mov    ah,9
  245.         int    21h
  246. exit:        int    20h             ;return to DOS
  247.  
  248. uninstall:    mov    ax,9002h
  249.         int    2fh
  250.         mov    dx,offset msg01
  251.         jmp    print
  252.  
  253. ;**************************************************************************
  254. ;                   INIT
  255. ; Initialize:
  256. ; vidseg = B800 (color) or B000 (mono)
  257. ;**************************************************************************
  258. init        proc    near
  259.         push    ds
  260.         xor    ax,ax
  261.         mov    ds,ax
  262.                 mov     al,byte ptr ds:[410h]
  263.         pop    ds
  264.  
  265.         and    al,30h
  266.         cmp    al,30h
  267.         mov    ax,0B800h
  268.         jnz    init1
  269.         mov    ax,0B000h
  270. init1:        mov    word ptr [vidseg],ax
  271.         ret
  272. init        endp
  273.  
  274.  
  275. copyright    db    'LPTMON 1.0  Public Domain by Celso Minnitti Jr  '
  276.         db    '01-16-94',10,13,24h
  277. msg00        db    'Usage:   LPTMON [option]',10,13
  278.         db    '         U   Uninstall LPTMON',10,13
  279.         db    '         -   Turn on/off the display of LPTMON',10,13,24h
  280. msg01        db    'LPTMON successfully uninstalled',10,13,24h
  281.  
  282. _TEXT    ends
  283. end    start
  284.