home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / DOOG / CTASK.ZIP / MINRES.ASM < prev    next >
Assembly Source File  |  1989-12-23  |  2KB  |  102 lines

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