home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CTASK22.ZIP / TSKRES.ASM < prev    next >
Assembly Source File  |  1990-10-12  |  2KB  |  121 lines

  1. ;
  2. ;    --- Version 2.2 90-10-12 10:46 ---
  3. ;
  4. ;    CTask - Residency check.
  5. ;
  6. ;    Public Domain Software written by
  7. ;        Thomas Wagner
  8. ;        Ferrari electronic Gmbh
  9. ;        Beusselstrasse 27
  10. ;        D-1000 Berlin 21
  11. ;        Germany
  12. ;
  13. ;    This file is new with Version 2.1. The routine to check
  14. ;    whether a primary kernel is resident was moved here
  15. ;    from tskdos.asm, and the link_ctask routine was added.
  16. ;
  17. ;    This avoids linking unneeded modules for secondary kernels,
  18. ;    and allows code sharing.
  19. ;
  20. ;---------------------------------------------------------------------------
  21. ;
  22.     name    tskres
  23. ;
  24.     include    tsk.mac
  25. ;
  26.     .tsk_model
  27. ;
  28.     IF    DOS
  29.     Pubfunc    ctask_resident
  30.     Pubfunc    link_ctask
  31.     ENDIF
  32. ;
  33.     IF    NOT SINGLE_DATA
  34.     public    tsk_global
  35.     ENDIF
  36.     public    tsk_version
  37. ;
  38.     .tsk_data
  39. ;
  40.     IF    NOT SINGLE_DATA
  41. tsk_global    dd        0
  42.     ENDIF
  43. ;
  44. tsk_version    db        "CTask21"
  45. ;
  46.     .tsk_edata
  47.     IF    DOS
  48.     .tsk_code
  49. ;
  50. Globalfunc ctask_resident,<uses si di>
  51. ;
  52.     IFDEF    LOAD_DS
  53.     push    ds
  54.     mov    ax,@CTASK_DATA
  55.     mov    ds,ax
  56.     ENDIF
  57. ;
  58.     mov    dx,offset tsk_version
  59.     mov    bx,1234h
  60.     mov    ax,3000h
  61.     int    21h
  62.     xor    ax,ax            ; init return code to false
  63.     cmp    bx,0fff0h        ; make sure we don't get segment wrap
  64.     jae    not_resident        ; can't be right if offset too high
  65.     cmp    cx,0fff0h        ; can't be up there, either
  66.     jae    not_resident
  67.     or    cx,cx
  68.     jz    not_resident        ; or down there
  69.     mov    di,bx
  70.     mov    es,cx
  71.     mov    si,offset tsk_version
  72.     mov    cx,8
  73.     repe cmpsb
  74.     jnz    not_resident        ; Not resident if no match
  75. ;
  76. ;    CTask is resident, set global variable pointer
  77. ;
  78.     mov    word ptr tsk_global,bx
  79.     mov    word ptr tsk_global+2,es
  80.     mov    ax,1
  81. ;
  82. not_resident:
  83.     IFDEF    LOAD_DS
  84.     pop    ds
  85.     ENDIF
  86.     ret
  87. ;
  88. ctask_resident    endp
  89. ;
  90. ;
  91. Globalfunc link_ctask
  92. ;
  93.     IFDEF    LOAD_DS
  94.     push    ds
  95.     mov    ax,@CTASK_DATA
  96.     mov    ds,ax
  97.     ENDIF
  98. ;
  99.     call    ctask_resident
  100.     or    ax,ax
  101.     jz    link_fail
  102.     les    bx,tsk_global
  103.     les    ax,es:stub_table[bx]
  104.     mov    bx,es
  105.     or    ax,bx
  106.     jz    link_fail
  107.     mov    ax,1
  108. ;
  109. link_fail:
  110.     IFDEF    LOAD_DS
  111.     pop    ds
  112.     ENDIF
  113.     ret
  114. ;
  115. link_ctask    endp
  116. ;
  117.     .tsk_ecode
  118.     ENDIF
  119.         end
  120.  
  121.