home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 330_02 / minres.asm < prev    next >
Assembly Source File  |  1990-10-12  |  2KB  |  89 lines

  1.     .model    large,c
  2.     dosseg
  3. ;
  4.     include    tsk.mac
  5. ;
  6. ;    This is a sample for a minimal program that makes the
  7. ;    CTask kernel resident.
  8. ;
  9.     public    _acrtused
  10.     public    _psp
  11.     public    alloc_resource
  12. ;
  13.     Pubfunc    tsk_alloc
  14.     Pubfunc    tsk_free
  15. ;
  16.     Globext    install_tasker
  17.     Globext    preempt_on
  18.     Globext    set_priority
  19.     Globext    schedule
  20. ;
  21. _acrtused    equ    9876h
  22. ;
  23. NULL    segment para public 'BEGDATA'
  24. NULL    ends
  25. ;
  26. stacklen    =    256
  27. ;
  28.     .stack    stacklen
  29. ;
  30.     .data?
  31. ;
  32. alloc_resource    resource <>
  33. ;
  34. _psp    dw    ?
  35. ;
  36.     .data
  37. ;
  38. main_name    db    "CTRES",0
  39. ;
  40.     .code
  41. ;
  42. ;    Dummy allocation routines. The memory allocation is never called
  43. ;    by CTask if you don't explicitly request it.
  44. ;
  45. tsk_free:
  46. tsk_alloc:
  47.     xor    ax,ax
  48.     mov    dx,ax
  49.     ret
  50. ;
  51. ;    The main program. 
  52. ;    NOTE: This sample program does *not* clear uninitialized memory
  53. ;          to zero. CTask has explicit initialization code for all
  54. ;          of it's variables.
  55. ;
  56. main:
  57.     mov    ax,@data
  58.     mov    ds,ax
  59.     mov    _psp,es
  60.     cld
  61.     mov    ax,es:[2ch]    ; Environment pointer in PSP
  62.     mov    es,ax
  63.     mov    ah,49h        ; Release environment
  64.     int    21h
  65. ;
  66. ;    install_tasker (0, 0, IFL_DISK | IFL_PRINTER | IFL_INT15);
  67. ;
  68. ifls    =    IFL_DISK OR IFL_PRINTER OR IFL_INT15
  69.     callp    install_tasker,<0,0,ifls,<ds,#main_name>>
  70. ;
  71. ;    set_priority (NULL, PRI_STD);
  72. ;
  73.     callp    set_priority,<<0,0>,PRI_STD>
  74. ;
  75.     call    preempt_on
  76.     call    schedule
  77. ;
  78.     mov    dx,offset STACK        ; stack end
  79.     add    dx,15            ; round up
  80.     mov    cl,4
  81.     shr    dx,cl            ; convert to paragraphs
  82.     add    dx,@data        ; add data start segment
  83.     sub    dx,_psp            ; minus program segment
  84.     mov    ax,3100h        ; TSR
  85.     int    21h
  86. ;
  87.     end    main
  88.  
  89.