home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / gvb-int.zip / GVB-INT.ASM next >
Assembly Source File  |  1988-06-15  |  5KB  |  88 lines

  1. ; GVB-INT.SHR - 1988 by Simon Kane
  2. ;
  3. ; This DESQview 'Shared Program' provides a means to allow a program
  4. ; that writes directly to the screen to use the DV-supplied alternate
  5. ; video buffer without making major changes or requiring a loader.
  6. ;
  7. ; Refer to GVB-INT.DOC for more information.
  8. ;
  9. code          segment para public 'code'
  10.               assume cs:code
  11.               org   00h
  12. begin:        cmp   cx,0                    ; initialization call ?
  13.               je    initialize              ; yes - continue
  14.               retf                          ; no - ignore it
  15. ;
  16. copyright     db    'Copyright 1988 Simon Kane'
  17. ;
  18. initialize    proc  far
  19. USER_INT:     mov   al,67h                  ; Interrupt # to be trapped
  20.               push  cs                      ; Point DS to ourselves
  21.               pop   ds                      ; * (but don't ASSUME it)
  22.               mov   dx,offset interrupt     ; Point DX to intrpt routine
  23.               mov   ah,25h                  ; Function is Set I-vector
  24.               int   21h                     ; Call DOS
  25.               clc                           ; Tell DESQview we're OK
  26.               ret   12                      ; Return to DESQview
  27. initialize    endp
  28. ;
  29. interrupt     proc
  30. ;             pushf                         ; Left on stack by INT
  31. ;             push  cs                      ; * BP+20 after pushes
  32. ;             push  ip                      ; * BP+18 * and BP setup
  33.               push  es                      ; Save registers
  34.               push  ds                      ; * BP+14
  35.               push  di                      ; *    12
  36.               push  si                      ; *    10
  37.               push  bp                      ; *    08
  38.               push  bx                      ; *    06
  39.               push  dx                      ; *    04
  40.               push  cx                      ; *    02
  41.               push  ax                      ; * BP+00
  42.               mov   bp,sp                   ; set stack base for mugging
  43. ; get segment:offset of operand byte, fix return address
  44.               mov   ds,[BP+20]              ; get segment of operand
  45.               mov   si,[BP+18]              ; get offset of operand
  46. get_DV_buf:   mov   ah,0FEh                 ; Func is get_video_buffer
  47.               int   10h                     ; Returned by DV in ES:DI
  48.               mov   al,[SI]                 ; get operand byte in AL
  49. ; fix return address
  50.               inc   si                      ; bump past it
  51.               mov   [BP+18],si              ; and save for IRET
  52. ; put video address where caller wants it
  53.               cmp   al,0C0h                 ; Output to Register?
  54.               jb    try_mem_op              ; * no
  55.               cmp   al,0C8h                 ; * yes - is it ES?
  56.               je    save_g_reg              ; * *     yes - go save it
  57.               jb    out_g_reg               ; * *     no - it's a g_reg
  58.               cmp   al,0CBh                 ; * *     no - is it DS?
  59.               jne   bad_op_code             ; * *     * no - error!
  60.               mov   al,7                    ; * *     * yes - set index
  61.               jmp   save_g_reg              ; * *     * * and go save it
  62. out_g_reg:    cmp   al,0C4h                 ; * is it SP?
  63.               je    bad_op_code             ; * * yes - error!
  64.               jb    save_g_reg              ; * it's 0-3 - offset OK
  65.               dec   al                      ; * 5-7 is now 4-6
  66. save_g_reg:   and   ax,000Fh                ; * clean up register
  67.               shl   al,1                    ; * times 2 for stack offset
  68.               mov   di,ax                   ; * set stack frame offset
  69.               mov   [BP+DI],es              ; * put it into stack frame
  70.               jmp   done                    ; * and return it to caller
  71. try_mem_op:   jmp   bad_op_code             ; memory ops not implemented
  72. done:         pop   ax                      ; Restore registers
  73.               pop   cx                      ; * (one of which might've
  74.               pop   dx                      ; *  been mugged to be the
  75.               pop   bx                      ; *  DV v-buffer seg addr)
  76.               pop   bp                      ; *
  77.               pop   si                      ; *
  78.               pop   di                      ; *
  79.               pop   ds                      ; *
  80.               pop   es                      ; *
  81.               iret                          ; Return to caller
  82. ; Invalid destination operand (operand code byte is bad)
  83. bad_op_code:  mov   ax,4CF0h                ; terminate w/ RC=240
  84.               int   21h
  85. interrupt     endp
  86. code          ends
  87.               end begin
  88.