home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / commodore-scene-files / Coverdisks / CDU / V4D02.D64 / cmd1v1.4.asm < prev    next >
Encoding:
Assembly Source File  |  2019-04-13  |  5.7 KB  |  264 lines

  1. e
  2. _*********************************************************
  3. _*                                                       *
  4. _*       module name : PROGSTOP.ASM                      *
  5. _*                                                       *
  6. _*                Maintenance log                        *
  7. _*                ---------------                        *
  8. _*                                                       *
  9. _*   date      time                     action           *
  10. _*   ----      ----                     ------           *
  11. _* 14/02/89   23:30                initial coding        *
  12. _* 28/03/89   22:15                 tidy up              *
  13. _* 03/04/89   23:00             changed brackets         *
  14. _* 19/05/89   17:50     major recode for both routines   *
  15. _* 20/05/89   19:20     fix suspend bug, allow quiesce   *
  16. _*                   and suspend of suspended program    *
  17. _* 21/05/89   18:00    added free storage error check    *
  18. _* 21/05/89   18:50    fixed the quiesce storage error   *
  19. _* 22/05/89   18:50    update for new storage methods    *
  20. _* 18/06/89   19:10    Save stack don't remove info      *
  21. _* 05/07/89   22:10  Page 0 and 1 can be in both ram blk *
  22. _*********************************************************
  23.  
  24.  
  25. _*********************************************************
  26. _*                                                       *
  27. _*       routine : Suspend - suspends a program          *
  28. _*                 Quiesce - terminates a program        *
  29. _*                                                       *
  30. _*   entry                                               *
  31. _*   -----                                               *
  32. _*   CHARBUFF - characters of the command                *
  33. _*   Y        - current position after command found in  *
  34. _*              CHARBUFF                                 *
  35. _*.......................................................*
  36. _*   used                                                *
  37. _*   ----                                                *
  38. _*   A,X,Y                                               *
  39. _*   PRGNAME                                             *
  40. _*   NAMELEN                                             *
  41. _*.......................................................*
  42. _*   exit                                                *
  43. _*   ----                                                *
  44. _*   none                                                *
  45. _*********************************************************
  46.  
  47. _ These 2 commands suspend or remove a program in the table. on entry, Y
  48. _ points to the command, so the following info should be blank then name CR.
  49.  
  50. suspend    equ *
  51.     ¥ #prgnorun         _ set suspend flag in table
  52.     db  $2c        _ skip next instruction
  53. quiesce    equ *
  54.     ¥ #noprog        _ set remove flag for table
  55.     » option
  56.  
  57.  
  58. _ Now we need to read the name of the program from the program buffer 
  59. _ and then locate it in the table
  60. _ if found then change the flag and display a message.
  61.  
  62.     £ readname        _ common routine to get name from buffer
  63.     £ locname        _ find name in the table
  64.     ä fndname
  65.  
  66.           ¥ #2
  67.     ¢ dispmess        _ display error message 2
  68.  
  69. _
  70. _ Name found, so we will either suspend or quiesce a program.
  71. _
  72.  
  73. fndname    equ *
  74.  
  75.     ƒ #flag
  76.     ¥ [tabpntr],y
  77.     æ #prgrun
  78.     ê notrun
  79.  
  80. _
  81. _  Program is active, so we will decrement the number of programs 
  82. _ running. If Suspending an already suspended program nothing happens
  83. _ but it is possible to quiesce a suspended program. 
  84. _
  85.  
  86.     ö progrun
  87.  
  88. notrun    equ *
  89.     ¥ option            _ reset the flag in table
  90.     » [tabpntr],y
  91.  
  92.     ¥ option            _ suspend or quiesce ?
  93.     æ #prgnorun
  94.     à allfree
  95.  
  96. _ we are quiescing a program, just free memory. The stack doesn't have
  97. _ to be touched.
  98.  
  99. _
  100. _ Free the program area.
  101. _
  102.  
  103.     ƒ #ramprg
  104.     ¥ [tabpntr],y
  105.     » ramused
  106.     ƒ #strtadd    
  107.     ¥ [tabpntr],y
  108.     » startram
  109.     Ü
  110.     ¥ [tabpntr],y
  111.     » startram+1
  112.     ƒ #endadd
  113.     ¥ [tabpntr],y
  114.     » endram
  115.     Ü
  116.     ¥ [tabpntr],y
  117.     » endram+1
  118.     £ frestor        _ free program area
  119.     â freezero
  120. errorfre    equ *
  121.     ¥ #13
  122.     ¢ dispmess
  123.  
  124.  
  125. _
  126. _ Free the page 0 area.
  127. _
  128.  
  129. freezero    equ *
  130.     ƒ #zeroram
  131.     ¥ [tabpntr],y
  132.     » ramused
  133.     ƒ #zerooff    
  134.     ¥ [tabpntr],y
  135.     » startram+1
  136.     » endram+1
  137.     ¥ #0
  138.     » startram
  139.     ¥ #pagend
  140.     » endram
  141.     £ frestor
  142.     â freeone
  143.     ä errorfre
  144.  
  145. _
  146. _ Free the page one area.
  147. _
  148.  
  149. freeone    equ *
  150.     ƒ #oneram
  151.     ¥ [tabpntr],y
  152.     » ramused
  153.     ƒ #oneoff    
  154.     ¥ [tabpntr],y
  155.     » startram+1
  156.     » endram+1
  157.     ¥ #0
  158.     » startram
  159.     ¥ #pagend
  160.     » endram
  161.     £ frestor
  162.     â allfree
  163.     ä errorfre
  164.  
  165. allfree    equ *
  166.     
  167. _
  168. _ Check to see if we are trying to suspend or quiesce the current
  169. _ program. If not, then it is ok just to leave the flag change etc.
  170. _ The switching logic just won't find it on the next search.
  171. _
  172.  
  173.     ¥ tabpntr+1
  174.     æ current+1
  175.     ê nofurther
  176.     ¥ tabpntr
  177.     æ current
  178.     ê nofurther
  179.     ¢ updprg
  180.  
  181. nofurther equ *
  182.     ¬
  183.  
  184.  
  185. _
  186. _ Ok, we are trying to stop or suspend the current program.
  187. _
  188.  
  189. updprg    equ *
  190.     ¥ option
  191.     æ #noprog
  192.     à contnext
  193.     
  194. _
  195. _ Ok, trying to suspend the program, so the stack must be saved.
  196. _ As this is the currently interrupted program, the stack address
  197. _ has been saved.
  198.  
  199.     ¥ savestk
  200.     ƒ #regsp
  201.     » [current],y
  202.  
  203. _
  204. _ find next program to run, if there is one.
  205. _
  206.  
  207.  
  208. contnext  equ *        
  209.  
  210.     ¥ progrun
  211.     à loopprg        _ go to dfltprg program
  212.     £ locnext        _ locate next program into current
  213.  
  214. _
  215. _ Run routine will set up the stack to simulate the program being run.
  216. _
  217.  
  218.     ¢ runcurr        _ run the current program
  219.  
  220. loopprg   equ *
  221.  
  222. _
  223. _ To simulate as though the looping program has been interrupted, we must
  224. _ place the interrupt logic on the op sys stack. As the return address is
  225. _ there, we must have that last and place the interrupt code before it.
  226. _
  227.  
  228.     Ñ
  229.     ▓
  230.     Ñ
  231.     │
  232.  
  233.  
  234.     ¥ #<initext1
  235.     ú
  236.     ¥ #>initext1
  237.     ú
  238.     ¥ #0
  239.     ú
  240.     ú
  241.     ú
  242.     ú
  243.     ¥ #config
  244.     ú
  245.  
  246.     ╖
  247.     ú
  248.     ╡
  249.     ú
  250.  
  251. _
  252. _ System pages are in, so we just return to the NMI calling routine. No
  253. _ Pages will be switched in on return to the NMI routine as there are no
  254. _ programs running.
  255. _
  256.  
  257.     ¬
  258.  
  259. option    db 0
  260.  
  261.     IEND
  262.  
  263.