home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / ASM / CRIT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-01-08  |  1.9 KB  |  87 lines

  1. ;                 ************
  2. ;                 * CRIT.asm *
  3. ;               *******************************************
  4. ;               * Copyright TimeSlice, Inc. 1985, 86, 87. *
  5. ;               *******************************************
  6. ;
  7. include ts.inc
  8. ;
  9. extern_code    critend
  10. ifdef MICROSOFT
  11. extern_code    critstart
  12. else
  13. extern_code    critstar
  14. critstart equ    critstar
  15. endif
  16. ;
  17. start_data
  18. end_data
  19. ;
  20. start_code
  21. ;
  22. ;***
  23. ;* CRIT( CLNUM, FP , ARGLIST , , , )
  24. ;* Crit is used when function FP is critical. You call crit and give as 1st 
  25. ;* argument, a pointer to the critical function to execute, and then, the
  26. ;* list of arguments to pass to f().
  27. ;* REMARK : CRIT() assumes that the calling function had BP pointing to the
  28. ;* base of its local frame.
  29. ;***
  30. start_struct
  31. mbr    _ax    d_int    ?
  32. mbr    _bx    d_int    ?
  33. mbr    _cx    d_int    ?
  34. mbr    _dx    d_int    ?
  35. ifdef MICROSOFT
  36. mbr    _di    d_int    ?
  37. mbr    _si    d_int    ?
  38. endif
  39. mbr    _bp    d_int    ?
  40. mbr    _ret    d_ret    ?
  41. mbr    clnum    d_int    ?
  42. mbr    fp    f_ptr    ?
  43. mbr    args    d_int    ?
  44. ;
  45. routine crit
  46.     push    bp
  47.     push_sdi
  48.     sub    sp,8        ;area to save regs returned by fp
  49.     mov    bp,sp
  50.     push    [bp].clnum    ;make proc critical for class clnum
  51.     call    critstart
  52.     mov    sp,bp
  53.     lea    si,[bp].args    ;SI <-- begining of argument list
  54.     ldint    cx,[bp]._bp    ;CX <-- old BP, 4 bytes past last arg
  55.     sub    cx,si        ;CX <-- size of arglist in bytes
  56.     mov    di,bp
  57.     sub    di,cx        ;base of new argument list
  58.     mov    sp,di        ;SP <-- ptr to base of new arglist
  59.     mov    ax,ss        ;DS = ES <== SS
  60.     mov    ds,ax
  61.     mov    es,ax
  62.     cld
  63.     repz    movsb        ;copy old arglist to new
  64.     mov    ax,dgroup
  65.     mov    ds,ax
  66.     fncall    [bp].fp        ;execute critical function
  67.     mov    sp,bp
  68.     stint    [bp]._ax,ax    ;save registers
  69.     stint    [bp]._bx,bx
  70.     stint    [bp]._cx,cx
  71.     stint    [bp]._dx,dx
  72.     push    [bp].clnum    ;make proc not critical for class clnum
  73.     call    critend
  74.     mov    sp,bp
  75.     ldint    ax,[bp]._ax    ;restore registers
  76.     ldint    bx,[bp]._bx
  77.     ldint    cx,[bp]._cx
  78.     ldint    dx,[bp]._dx
  79.     add    sp,8        ;restore stack
  80.     pop_sdi
  81.     pop    bp
  82. return    crit
  83. ;
  84. end_code
  85. ;
  86.     
  87.