home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c329 / 2.img / EXAMPLES / MOUSEASM.S < prev    next >
Encoding:
Text File  |  1989-10-23  |  5.7 KB  |  213 lines

  1. ;  MOUSEASM.S
  2. ;  copyright 1989, MicroWay, Inc.
  3. ; ------------------------------------- ; 
  4.     name    t2            ;
  5.     .387                ;
  6.     assume    cs:codeseg        ;
  7.     assume    ds:dataseg        ;
  8. codeseg    segment dword er use32 public     ;
  9.                     ;
  10. extrn    _init_mouse:near        ;
  11. extrn   _show_mouse_cursor:near         ;
  12. extrn   _hide_mouse_cursor:near         ;
  13. extrn    _get_mouse:near            ;
  14. extrn    _set_mouse:near            ;
  15. extrn    _get_press:near            ;
  16. extrn    _get_release:near        ;
  17. extrn    _mouse_viewport:near        ;
  18. extrn    _read_motion:near        ;
  19. extrn    _set_mp_ratio:near        ;
  20. extrn   _set_mouse_cursor:near          ;
  21. extrn    _set_subroutine:near        ;
  22.                     ;
  23. dataseg    segment dword rw use32 public     ;
  24.                     ;
  25. intno    dw    33h            ; This is a data area to 
  26. rds    dw    (?)            ; hold the values of registers
  27. res    dw    (?)            ; for the Phar Lap service,
  28. rfs    dw    (?)            ; int 21, number 2511, issue
  29. rgs    dw    (?)            ; real mode interrupt with 
  30. reax    dd    (?)            ; specified register values
  31. redx    dd    (?)            ;
  32.                     ;
  33. dataseg    ends                ;
  34.     align    4            ;
  35.                     ;
  36. _mouse    proc near            ;
  37.     public    _mouse            ; C & Pascal entry
  38. _mouse_:                ;
  39.     public    _mouse_            ; FORTRAN entry
  40.     push    ebp            ;
  41.     mov    ebp,esp            ; save all registers - 
  42.     push    eax            ;   we don't know what kind
  43.     push    ebx            ;   of trouble the mouse 
  44.     push    ecx            ;   interrupt may produce
  45.     push    edx            ;
  46.     push    edi            ;
  47.     push    esi            ;
  48.     pushf                ;
  49. ; int 21 service function 2511 requires that an area in memory be
  50. ; used to specify the contents of the eax, ds, es, fs, gs, and edx
  51. ; registers, as these cannot be loaded at the time the function is
  52. ; invoked.  edx points at the location.
  53. ;
  54. ; For most functions, we only need to save the contents of eax and
  55. ; edx in this place, but for functions 9, 12, 18, and 'R', es will
  56. ; also have to be specified.  ds is loaded with a copy of es in these
  57. ; cases as a matter of safety.
  58. ; In the case of graphics cursor, we assume it is at an offset of 0
  59. ; into its segment (each such cursor will require, for that reason,
  60. ; its own segment).  We cannot do this in the case of a routine, so
  61. ; the programmer will have to pass the entry point as an argument.
  62. ;
  63.     mov    esi,[ebp+08h]        ; 
  64.     mov    eax,[esi]        ; first parameter
  65.     mov    reax,eax        ; into memory
  66.     mov    esi,[ebp+0ch]        ; 
  67.     mov    ebx,[esi]        ; second parameter
  68.     mov    esi,[ebp+10h]        ;
  69.     mov    ecx,[esi]        ; third parameter
  70.     mov    esi,[ebp+14h]        ;
  71.     mov    eax,[esi]        ; fourth paramter
  72.     cmp    reax,9            ; if the first parameter is 
  73.     je    short m1        ;   9, 12, 18 or 'R', then 
  74.     cmp    reax,12            ;   load es
  75.     je    short m2        ;
  76.     cmp    reax,18            ;
  77.     je    short m1        ;
  78.     cmp    reax,'R'        ;
  79.     je    short m1        ;
  80.     mov    redx,eax        ; 
  81.     jmp    short m4        ;
  82. m1:                    ;
  83.     mov    redx,0            ; array of data - offset 0
  84.     jmp    short m3        ;
  85. m2:                    ;
  86.     mov    redx,ebx        ; entry into routine
  87. m3:                    ;
  88.     mov    rds,ax            ;
  89.     mov    res,ax            ;
  90. m4:                    ;
  91.     mov    edx,offset intno    ; offset of memory area
  92.     mov    ax,2511h        ;
  93.     int    21h            ; do the interrupt
  94.     mov    eax,redx        ; now, replace parameters with
  95.     mov    edi,[ebp+14h]        ;   return values
  96.     mov    [edi],eax        ; last parameter
  97.     mov    edi,[ebp+10h]        ;
  98.     mov    [edi],ecx        ; third
  99.     mov    edi,[ebp+0ch]        ;
  100.     mov    [edi],ebx        ; second
  101.     mov    eax,reax        ;
  102.     mov    edi,[ebp+08h]        ;
  103.     mov    [edi],eax        ; first
  104.     popf                ; restore registers
  105.     pop    esi            ;
  106.     pop    edi            ;
  107.     pop    edx            ;
  108.     pop    ecx            ;
  109.     pop    ebx            ;
  110.     pop    eax            ;
  111.     pop    ebp            ;
  112.     ret                ; return
  113. _mouse    endp                ;
  114.                     ;
  115.                     ;
  116. _realbuf_    proc    near        ;
  117.     public    _realbuf_        ; FORTRAN entry
  118. _realbuf:                ;
  119.     public    _realbuf        ; C & Pascal entry
  120.     push    ebx             ;
  121.     push    edi            ;
  122.     push    esi            ;
  123.     mov    edx,[esp+10h]        ; address of parameter
  124.     mov    ebx,[edx]        ; parameter
  125.     shr    ebx,4            ; we want to request paragraphs
  126.     inc    ebx            ; round up
  127.     mov    ax,25c0h         ; request rm memory function
  128.     int    21h            ;
  129.     jnc    short rb1        ; carry indicates failure
  130.     mov    eax,-1            ; for failure, return -1
  131.     jmp    short rb2        ;
  132. rb1:                    ;
  133.     movzx    eax,ax            ;
  134. rb2:                    ;
  135.     mov    [edx],ax        ; the parameter value has been
  136.     pop    esi            ; replaced with the segment value
  137.     pop    edi            ;
  138.     pop    ebx            ;
  139.     ret                ; return
  140. _realbuf_    endp            ;
  141.     align    4            ;
  142. ; The following are FORTRAN entry points - it would have been 
  143. ; a tiny bit faster to doctor the output of the Pascal compilation
  144. ; (the Assembly file) to insert labels, but it would also be more
  145. ; likely that errors would result in the release product.
  146. ;
  147.                     ;
  148. _init_mouse_    proc near        ;
  149.     public    _init_mouse_        ;
  150.     jmp    _init_mouse        ;
  151. _init_mouse_    endp            ;
  152.                     ;
  153. _show_mouse_cursor_   proc near         ;
  154.         public  _show_mouse_cursor_     ;
  155.         jmp     _show_mouse_cursor      ;
  156. _show_mouse_cursor_   endp              ;
  157.                     ;
  158. _hide_mouse_cursor_   proc near         ;
  159.         public  _hide_mouse_cursor_     ;
  160.         jmp     _hide_mouse_cursor      ;
  161. _hide_mouse_cursor_   endp              ;
  162.                     ;
  163. _get_mouse_    proc near        ;
  164.     public    _get_mouse_        ;
  165.     jmp    _get_mouse        ;
  166. _get_mouse_    endp            ;
  167.                     ;
  168. _set_mouse_    proc near        ;
  169.     public    _set_mouse_        ;
  170.     jmp    _set_mouse        ;
  171. _set_mouse_    endp            ;
  172.                     ;
  173. _get_press_    proc near        ;
  174.     public    _get_press_        ;
  175.     jmp    _get_press        ;
  176. _get_press_    endp            ;
  177.                     ;
  178. _get_release_    proc near        ;
  179.     public    _get_release_        ;
  180.     jmp    _get_release        ;
  181. _get_release_    endp            ;
  182.                     ;
  183. _mouse_viewport_    proc near    ;
  184.     public    _mouse_viewport_    ;
  185.     jmp    _mouse_viewport        ;
  186. _mouse_viewport_    endp        ;
  187.                     ;
  188. _read_motion_    proc near        ;
  189.     public    _read_motion_        ;
  190.     jmp    _read_motion        ;
  191. _read_motion_    endp            ;
  192.                     ;
  193. _set_mp_ratio_    proc near        ;
  194.     public    _set_mp_ratio_        ;
  195.     jmp    _set_mp_ratio        ;
  196. _set_mp_ratio_    endp            ;
  197.                     ;
  198. _set_mouse_cursor_   proc near          ;
  199.         public  _set_mouse_cursor_      ;
  200.         jmp     _set_mouse_cursor       ;
  201. _set_mouse_cursor_   endp               ;
  202.                     ;
  203. _set_subroutine_    proc near    ;
  204.     public    _set_subroutine_    ;
  205.     jmp    _set_subroutine        ;
  206. _set_subroutine_    endp        ;
  207.                     ;
  208. codeseg    ends                ;
  209.     end                ;
  210.