home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / ports / prtscr.asm < prev    next >
Assembly Source File  |  1995-07-28  |  3KB  |  126 lines

  1. .286
  2. code segment
  3. assume cs:code,ds:code
  4. org 100h
  5.  
  6. start:
  7.   jmp main                      ;jump to main program
  8.  
  9. ;resident procedures:
  10.  
  11. print proc near                 ;outputs ASCIIZ string to Pos ds:si on LPT1
  12. print_loop:
  13.   xor ah,ah                     ;function 0
  14.   lodsb                         ;get characters
  15.   or al,al                      ;finished, if 0 as conclusion
  16.   je finished
  17.   xor dx,dx                     ;output on LPT1
  18.   int 17h
  19.   jmp print_loop                ;next character
  20. finished:
  21.   ret
  22. print endp
  23.  
  24. handler5 proc far               ;handler for interrupt 5
  25.   push es                       ;store all used registers
  26.   push ds
  27.   pusha
  28.  
  29.   mov ax,cs                     ;load es with PSP segment
  30.   mov es,ax
  31.   mov ds,ax                     ;data segment in code segment also
  32.  
  33.   mov di,80h                    ;parameter block as buffer
  34.   mov ah,1bh                    ;function 1bh
  35.   xor bx,bx
  36.   int 10h                       ;get video status
  37.  
  38.   cli
  39.  
  40.   mov al,byte ptr cs:[80h+22h]  ;get number screen lines
  41.   cmp al,25d
  42.   jbe normal                    ;if 25 screen lines, normal routine
  43.  
  44.   lea si,small_font          ;switch to 6 point font
  45.   call print                    ;code to printer
  46.   jmp output
  47.  
  48. normal:
  49.   lea si,big_font           ;switch to 12 point font
  50.   call print                    ;code to printer
  51.  
  52. output:
  53.   sti
  54.   pushf
  55.   call dword ptr [oldint5]      ;enable normal output
  56.  
  57.   popa
  58.   pop ds
  59.   pop es
  60.   iret
  61. handler5 endp
  62.  
  63. oldint5: dd 0                   ;original vector
  64. small_font:  db 1bh,'(s6V'   ;6 point height
  65.                 db 1bh,'&l12D'  ;12 lines per inch
  66.                 db 1bh,'(s12H'  ;12 characters per inch
  67.                 db 0
  68. big_font:    db 1bh,'(s12V' ;12 point height
  69.                 db 1bh,'&l6D'   ;6 lines per inch
  70.                 db 1bh,'(s10H'  ;10 characters per inch
  71.                 db 0
  72.  
  73. last:
  74.  
  75. main proc near
  76.   mov ax,3505h                  ;read out interrupt 5
  77.   int 21h
  78.   mov di,bx                     ;es:di points to installed handler
  79.   mov si,bx                     ;ds:si points to handler of this program
  80.   mov cx,4                      ;compare 8 bytes
  81.   repe cmpsw
  82.   jcxz uninstall           ;same ?, then uninstall
  83.  
  84. install:
  85.   mov word ptr oldint5,bx       ;store old vector
  86.   mov word ptr oldint5 + 2,es
  87.  
  88.   mov ax,2505h                  ;redirect interrupt 5
  89.   lea dx,handler5               ;load offset, segment already in ds
  90.   int 21h
  91.  
  92.   mov ax,ds:[2ch]               ;load environment segment
  93.   mov es,ax                     ;to es
  94.   mov ah,49h                    ;and release
  95.   int 21h
  96.  
  97.   mov ah,9                      ;output installation message
  98.   lea dx,installed
  99.   int 21h
  100.   lea dx,last                 ;remain resident until label last
  101.   inc dx
  102.   int 27h
  103.  
  104. uninstall:
  105.   mov ah,9                      ;output uninstall message
  106.   lea dx,uninstalled
  107.   int 21h
  108.  
  109.   push ds
  110.   lds dx,dword ptr es:[oldint5] ;load ds:dx with old vector
  111.   mov ax,2505h                  ;set this
  112.   int 21h
  113.   pop ds
  114.  
  115.   mov ah,49h                    ;release resident memory
  116.   int 21h
  117.   int 20h                       ;and exit
  118. main endp
  119.  
  120.  
  121. installed:    db 'New Print Screen function installed',0dh,0ah,'$'
  122. uninstalled:  db 'Print Screen uninstalled',0dh,0ah,'$'
  123.  
  124. code ends
  125. end start
  126.