home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 100-199 / ff113.lzh / M2Amiga / Demos / scanList.mod < prev    next >
Text File  |  1987-11-21  |  2KB  |  90 lines

  1. MODULE scanList;
  2. (* 3.11.87/ms
  3.  * scan throu the lists of Exec showing the names of the nodes
  4.  * Copyright © 1987, by Markus Schaub / AMSoft
  5.  * The author hereby gives the permission to include this program into the
  6.  * collection of demo programs of M2Amiga. Any part of this program can be
  7.  * used as example of coding with M2Amiga (although it might be a bad example)
  8.  *)
  9. FROM SYSTEM IMPORT
  10.  ADDRESS,ADR,INLINE;
  11. FROM Exec IMPORT
  12.  execBase,Node,NodePtr,List,ListPtr,Forbid,Permit,RawDoFmt;
  13. FROM Terminal IMPORT
  14.  Write,WriteLn,WriteString;
  15.  
  16. CONST
  17.  format="%08lx %02x %s";
  18.  null="no name"; (* or any other dummy string *)
  19.  
  20. TYPE
  21.  MyNodePtr=POINTER TO Node;
  22.  
  23. VAR
  24.  line: ARRAY [0..255] OF CHAR;
  25.  lineData: RECORD
  26.   adr: ADDRESS;
  27.   t: INTEGER;
  28.   str: ADDRESS
  29.  END;
  30.  
  31. PROCEDURE StuffChar;
  32. (* $E- no entry/exit code for this please, just these two 32 bit *)
  33. BEGIN (* uses the hidden secrets of Exec's RawDoFmt, your OWN risk! *)
  34.  INLINE(
  35.   16C0H,(*  MOVE.B D0,(A3)+  *)
  36.   4E75H (*  RTS  *)
  37.  )
  38. END StuffChar;
  39.  
  40. PROCEDURE ScanList(list: ListPtr);
  41. VAR
  42.  h: MyNodePtr;
  43. BEGIN
  44.  Forbid; (* just us fooling around with these lists *)
  45.  h:=MyNodePtr(list^.head);
  46.  WHILE h^.succ#NIL DO
  47.   WITH h^ DO
  48.    WITH lineData DO
  49.     adr:=h;
  50.     t:=ORD(type);
  51.     IF name#NIL THEN
  52.      str:=name
  53.     ELSE
  54.      str:=ADR(null)
  55.     END
  56.    END;
  57.    h:=MyNodePtr(h^.succ);
  58.   END;
  59.   (* lineData is a pseudo stack for this routine, no check on length of line! *)
  60.   RawDoFmt(ADR(format),ADR(lineData),ADR(StuffChar),ADR(line));
  61.   WriteString(line); WriteLn
  62.  END;
  63.  Permit;
  64.  WriteLn
  65. END ScanList;
  66.  
  67. BEGIN
  68.  WriteString("scanList, 1.0, 3.11.87, © AMSoft"); WriteLn;
  69.  WITH execBase^ DO
  70.   WriteString("Scanning memList"); WriteLn;
  71.   ScanList(ADR(memList));
  72.   WriteString("Scanning resourceList"); WriteLn;
  73.   ScanList(ADR(resourceList));
  74.   WriteString("Scanning deviceList"); WriteLn;
  75.   ScanList(ADR(deviceList));
  76.   WriteString("Scanning intrList"); WriteLn;
  77.   ScanList(ADR(intrList));
  78.   WriteString("Scanning libList"); WriteLn;
  79.   ScanList(ADR(libList));
  80.   WriteString("Scanning portList"); WriteLn;
  81.   ScanList(ADR(portList));
  82.   WriteString("Scanning taskReady"); WriteLn;
  83.   ScanList(ADR(taskReady));
  84.   WriteString("Scanning taskWait"); WriteLn;
  85.   ScanList(ADR(taskWait));
  86.   WriteString("Scanning semaphoreList"); WriteLn;
  87.   ScanList(ADR(semaphoreList))
  88.  END
  89. END scanList.
  90.