Open Collections

UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Microsput : a microcomputer operating system for planar magnetron sputtering McMahon, Richard William 1982

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-UBC_1982_A7 M25.pdf [ 22.33MB ]
Metadata
JSON: 831-1.0095276.json
JSON-LD: 831-1.0095276-ld.json
RDF/XML (Pretty): 831-1.0095276-rdf.xml
RDF/JSON: 831-1.0095276-rdf.json
Turtle: 831-1.0095276-turtle.txt
N-Triples: 831-1.0095276-rdf-ntriples.txt
Original Record: 831-1.0095276-source.json
Full Text
831-1.0095276-fulltext.txt
Citation
831-1.0095276.ris

Full Text

MICROSPUT: A MICROCOMPUTER OPERATING SYSTEM FOR PLANAR MAGNETRON SPUTTERING by RICHARD WILLIAM MCMAHON B . A . S c , The U n i v e r s i t y of B r i t i s h Columbia, 1979  A THESIS SUBMITTED IN PARTIAL FULFILMENT OF THE  REQUIREMENTS FOR THE DEGREE OF MASTER OF APPLIED SCIENCE in  THE  FACULTY OF GRADUATE STUDIES (Department of P h y s i c s )  We accept  this  t h e s i s as conforming"  to the r e q u i r e d  THE  standard  UNIVERSITY OF BRITISH COLUMBIA OCTOBER 1982 Richard W i l l i a m McMahon, 1982  In p r e s e n t i n g  t h i s t h e s i s i n p a r t i a l f u l f i l m e n t of  requirements f o r an advanced degree at the  the  University  of B r i t i s h Columbia, I agree t h a t the L i b r a r y s h a l l make it  f r e e l y a v a i l a b l e f o r reference  and  study.  I further  agree t h a t p e r m i s s i o n f o r e x t e n s i v e copying of t h i s t h e s i s f o r s c h o l a r l y purposes may department or by h i s or her  be granted by  the head of  representatives.  my  It is  understood t h a t copying or p u b l i c a t i o n of t h i s t h e s i s f o r f i n a n c i a l gain  s h a l l not be  allowed without my  permission.  Department O f  Physics  The  U n i v e r s i t y o f B r i t i s h Columbia  1956  Main Mall  Vancouver, Canada V6T  1Y3 18 October  1982  written  ii  ABSTRACT  A Microcomputer and  control  record  and  display  successfully turn  planar  data was  sacrificing  comprehensiveness  in  p a c k a g e was  t h e p l a n a r magnetron  dubbed M i c r o S p u t , without  software  from  the  designed  precision  of  employed  developed  sputtering process  t o be  as  of p r o c e s s  allowed  unprecedented  magnetron  sputtering  plasma  flexible  as  control  or  monitor  and  to  The  system,  possible,  MicroSput  was  voltage control,  investigations process.  process,  equipment.  operations performed. to provide  to  of  the  of  which  the  iii  TABLE OF CONTENTS  ABSTRACT  i i  L I S T OF FIGURES ACKNOWLEDGMENT  v .  vi  INTRODUCTION CHAPTER  1  TWO  Overview  of M i c r o S p u t S t r u c t u r e  8  CHAPTER THREE MicroSput  Software S p e c i f i c  to Sputtering  15  CHAPTER FOUR MicroSput CHAPTER Data  Generalized  Parameter  Software  25  FIVE Filing  and P l o t t i n g  41  CHAPTER SIX El 2 A n a l o g / D i g i t a l  Input/Output  Interface  Programming  56  CHAPTER SEVEN MicroSput  MultiTasking  Software  70  CHAPTER EIGHT General  Purpose  M i c r o S p u t Subprogram M o d u l e s  84  CONCLUSION  87  REFERENCES  88  APPENDIX A Unit  Interfaces  89  APPENDIX B Compiler APPENDIX C  L i s t i n g o f Program  Sputter  120  Compiler  L i s t i n g s of  Parameter  Units  L i s t i n g s of  E12 I n t e r f a c e  APPENDIX D Compiler  Units  APPENDIX E Compiler  L i s t i n g s of M u l t i t a s k i n g  APPENDIX F Compiler  L i s t i n g s of G e n e r a l  Units  Units  V  LIST  FIGURE  Gas FIGURE  Leak  Display  Screen  Image  'sputter'  16  Valve  Characteristics  22  Editing  Screen  Image  'prmedit'  34  Walking  Screen  Image  'walker'  37  'paramsav'  48  Filing  Screen  Image  7 Plotting  Screen  Image  'plotset'  54  8  Analog FIGURE  6  6  Parameter FIGURE  Units  5  Parameter FIGURE  Compilation  4  Parameter FIGURE  MicroSput  3  Parameter FIGURE  of  2  Parameter FIGURE  FIGURES  1  Structure FIGURE  OF  Input  Multiplexing  Image  Development  Screen  Image  'trigana'  .  .  .  67  9  Screen  Test  Pattern  'test'  83  vi  ACKNOWLEDGMENT  I would  like  appreciation  and  thanks.  constructive Dr.  Dr.  Robert  and  criticism  comment  on  Juan R o s t w o r o w s k i  The heavily fixed  Felton  initial  microcomputer  versions.  problems.  and  project;  he  of  way  their  graduation  manipulated a l l  Michael  t o and  Brett  and  commented on Brian  advantage of  system development  P h y s i c s Departmental  i s proof  equipment  of  of  the  f o r use  technical i n an  c h a l l e n g e ; the  their  t o Mary Ann stages  the  f o r the  t e s t e d and  listened  work t o t a k e  i s a constant  indebted  i n time  my  the  Dr.  my  Sullivan resources  of  Centre.  computer  setting  generously  e x p a n d my  on  throughly  w i t h many t e c h n i c a l  the Computing  MicroSput  inspiration  throughout  t h e document  the v a r i o u s software  me  the  went c o n i d e r a b l y out  aspects  helped  with  provided  consistently  John A f f i n i t o  frustrations  h e l p e d me  s p u t t e r i n g group deserve  deadline. of  who  Parsons  Charles Schwerdtfeger  to e d i t  s i n c e r e g r a t i t u d e and  thesis preparation.  f e l l o w members o f our  special  and  my  t o the many p e o p l e  development The  to express  f o r her  programming.  support.  to  Design  rely of  evolving laboratory  work of  expertise in this  Potts  work c o n t i n u e s  Stan  Knotek  situation.  and  I am  patient assistance during  Tom also the  1  INTRODUCTION  Planar deposition can  be  magnetron process  the  s y s t e m can  employed  gas be  f l o w s and  used  to  One  clear  p l a s t i c substrates  application  transparent  the  1978  began t h e  order  to  first  the  as  of  coatings  films  of  arbitrary  p l a s t i c and  of  heat  as  stoichiometry films  fabrication  on  of  infrared reflective  attached can  transfer  such  sputtering  stoichiometric  Clear,  film  plastic  a PM  i s i n the  [5],  on  process parameters  window g l a z i n g ,  g r o u p i n the  of  a PM  intimate  process,  the  experimental at  provide to  the  a  be  to  windows,  expected  to  t h r o u g h a window  sputtering infrared  s y s t e m was films  system  or cut  by  control  were p r o d u c e d  the  precedents  precision  i n the  purpose  system,  use  possible  designed  control.  for  at  UBC  in  r e f l e c t i v e coatings.  and  I t was the  a  of  the  in-house. 1980  that  optimum  l i t e r a t u r e for  In  using  microcomputer  felt  would be  experimental  with  built  i n May  same t i m e work began on  automatic  a general  P h y s i c s Department  f a m i l i a r i t y as  r e p e a t a b i l i t y and  t h e r e were no  of  thin  i s non-thermal, i t  plasma v o l t a g e ,  non-stoichiometric  a microcomputer stability,  deposit  is useful  to  research  manual c o n t r o l ; program to  sputtering  rate  [6]. a  gain  sputtering  control  applied  development  depositing  i s a high  where c o n t r o l l e d  component  60%  the  insulation  d i r e c t l y to  radiative  In  The  window  either  more t h a n  to  deposit  [4].  applied  Because  With adequate c o n t r o l  various  coatings  sputtering  [1-3].  successfully  substrates.  (PM)  by  using  system  reached.  Since  microcomputer  sputtering  system, i t  2  was  necessary  to design  hardware, b e g i n n i n g at By  October  of  experiments.  No  attributed  the  simply at  cycle  point  about  ground  increase  computer  at  had  two  Z80  80K  the  The  built  delivery point  An  of  i n t o w h i c h the  increasingly  complex.  hardware h o s t : printer Two  time.  on  RAM,  of  the  tasks  The  IQ  120  VDT  tended  serial  provided  equipment. was  With a time  a  reference  to d e v e l o p towards a and  control  to elapsed  equipment  was  were p l a c e d  also  disk  input/output  a hardware c l o c k  p r o g r a m was,  I t was  UCSD  a TU-ART  experimental  methods.  of  equipment.  4FDC f l o p p y  d r i v e s , and  according  i n d i v i d u a l pieces  useful  Cromemco computer  48K  Measurement  servicing  execution  ran  A Soroc  the  1980  be  structure  sputtering  and  The  disk  software  f o r each parameter  desired  program  in-house a n a l o g / d i g i t a l  approach.  in a l l  p r o g r a m was  The  of  in Pascal  printer.  performed  t o a queue,  pieces  programming the  used  w h i c h would c o n t i n u a l l y  system.  in October  a l l algorithms,  being  the  view.  loop  i n t e r f a c e to  i n the  more m u l t i t a s k i n g  of  floppy  Teletype  to  time;  microcomputer,  mini  interaction.  s y s t e m was  turning  a  sputtering  i n system performance c o u l d  various  II o p e r a t i n g  to d r i v e  operator  the  one  the  c o n t r o l was  that  been w r i t t e n  included  controller,  of  like  level.  automatic  actual  checking  Version  hardware  for  1980  consisted  software  Pascal  port  the  software,  from a c o n v e n i e n c e p o i n t  that  The  to  the  the  however,  outgrowing  more memory, l a r g e r d i s k  time:  done  on  were  according basis  of  becoming  i t s modest  d r i v e s , and  a  faster  were a l l n e e d e d . conflicting  e m e r g i n g among t h e  plans  research  f o r the group.  computer One  system's f u t u r e  proposal  was  to  were  scrap  3  the  existing  system. provide  software  O n l y an  in favor  flexibility  Furthermore, the Basic  sputtering  personnel  PM  s p u t t e r i n g c o n t r o l ; there development  conflicting  i n an  not.  any  was  E a c h of t h e  his particular  Finally,  scientific  would  not o n l y  and d i s p l a y e d . even d u r i n g  Process  system  be c o n t r o l l e d , but d a t a c o n t r o l would  lower p r i o r i t y  S u g g e s t i o n s of s p e c i f i c experimental  jobs  c o n d i t i o n s would  p r o b l e m w h i c h might made more s l o w l y  b e t t e r be  solved.  but e v e n t u a l l y ,  i t was  O n l y by a d h e r i n g  structure,  g e n e r a l i t y , and c o n s i s t a n c y reached.  methods e n f o r c e d  to the high  development system.  would  be s a v e d  interaction.  for particular  as t o t h e more  Program hoped, goals would  would of  be  be  rarely  program  optimal  language b e t t e r  general  c h a n g e s would  C l e a r l y the s t r u c t u r e d  by t h e P a s c a l  structure.  uninterrupted  required  be a n a l y s e d  required.  p e r f o r m a n c e be  c a r r y on  s u c h as o p e r a t o r  modifications  existing  point in  i n c r e a s i n g the program for continued  the  breakthrough in  towards a s i n g l e comprehensive s p u t t e r i n g o p e r a t i n g Equipment  was  system, modify h i s  to suit  taste.  experimental  language  seemed t o be l i t t l e  towards  proposal  was  the Basic  needs and programming  s y s t e m had not p r o v i d e d  continued The  under  of t h e s p u t t e r i n g p r o g r a m  experimental computer  would,  argued, could  programming  by a l l g r o u p members; P a s c a l  version  i n t e r p r e t i v e Basic  necessary  understood  own  line  i n t e r p r e t i v e s y s t e m , i t was  t h e programming  laboratory.  o f an on  system  programming s u i t e d the second  proposal. Without would  any c l e a r c o n s e n s u s as t o w h i c h programming  eventually  probationary  p r o v e s u p e r i o r , work c a r r i e d  manner w i t h  the P a s c a l  system.  on  method  i n a somewhat  Another  16K  of  RAM,  4  two  S h u g a r t 250K 8" d i s k d r i v e s , and an  purchased. Version of the  The  arrival  IV added  modularity  in Version  use o f t h i s of  compiled  v e r s i o n ; there  quasi-concurrent  IV.  f e a t u r e was  changes  of V e r s i o n program  system supported  of p r o g r a m  tasks  the  on a p r i o r i t y  a n t i c i p a t e d but d e l a y e d  t h a t would  segments  was  be r e q u i r e d . a l s o a new  in place  have  system.  by A p r i l  feature  soon  A new  of  voltage  sputtering control  software  s y s t e m was  the  voltage  c o n t r o l mode i n r e a c t i v e s p u t t e r i n g e x p e r i m e n t s what was  p l a s m a dc c u r r e n t  previously  between a m e t a l l i c and a f u l l y voltage  control within  deposit  f i l m s of a r b i t r a r y  scientific  software  Development was  concurrency  support.  modularity  reacted  the t r a n s i t i o n  target region  stoichiometry  Use  [7]. we  [4].  to j u s t i f y  of t h e allowed  transition By  stable  were a b l e  to  T h i s p r o v e d t o be the  previous  work.  of t h e s o f t w a r e  programming  source.  known as a runaway  b r e a k t h r o u g h needed  development  choice  as t h e f e e d b a c k p a r a m e t e r t o  the high  the  sharing  valuable  control  us t o e x p l o r e  because  The  and  basis;  1981.  of t h e new  power, o r v o l t a g e  by  t o program  r e q u i r e d more memory t h a n  was  current,  new  no l i m i t  allowed  would  package  of  virtually  total  of a s i n g l e omnibus  by t h e computer  added  A  IV; d e v e l o p m e n t  allowed  One  was  eagerly  of memory among p r o g r a m  sputtering  of t h e UCSD p - S y s t e m  p r o g r a m modules had been  The  execution  t h e programming  feature  1981  460G p r i n t e r were  g r e a t l y t o t h e d e v e l o p m e n t momentum.  seven s e p a r a t e l y previous  in early  IDS  reworked to take  package  continued.  The  a d v a n t a g e of t h e p - S y s t e m  Even g r e a t e r  e m p h a s i s was  placed  and g e n e r a l i t y . . A l l c o m m u n i c a t i o n s w i t h  on  t h e VDT  were  5  done  i n a manner  command s e t . overall  independent  of t h e m a n u f a c t u r e r ' s  The name M i c r o S p u t  s e t of program modules.  was r e a d y  f o r use i n O c t o b e r ,  documentation The  of M i c r o S p u t  objective  control,  record  This  1982.  of M i c r o S p u t  magnetron  system.  be c h a r a c t e r i z e d  system  must be m e a s u r e d o r  c o n t r o l h a r d w a r e e x i s t s , must  compared w i t h o p e r a t o r - s p e c i f i e d  For interest extend  a research  and a l t e r  recording  sputtering  MicroSput  achieves  large pool  this  of s e p a r a t e l y  (see F i g .  1).  be o f g e n e r a l  non-sputtering The  the s e t of parameters of  easily  One must be a b l e t o  as r e s e a r c h  results,  of s p u t t e r i n g  hardware.  compiled,  independent  together  For t h i s  at higher  utility  i t i s hoped  use f o r t h e o p e r a t i o n  routines  programming  reason, MicroSput system;  a  of both  i s referred to that  MicroSput  s p u t t e r i n g and  experiments.  structure  overview  system  e s s e n t i a l a d a p t a b i l i t y by p r o v i d i n g  t h e a u t h o r a s an o p e r a t i n g  will  be s e n t t o  devices.  or m o d i f i c a t i o n  which a r e i n c r e a s i n g l y t i e d levels  t o generate  may a l s o  i s mutable.  the software  the a d d i t i o n  setpoints  The v a l u e s  to the experimenter  necessitate  an  of a s e t o f i n t e r - r e l a t e d  These v a l u e s  d i s p l a y and/or  p i e c e s of  The s t a t e o f t h e s p u t t e r i n g  and, where a s s o c i a t e d  suitable  thesis.  from t h e v a r i o u s  by t h e v a l u e s  signals.  of t h i s  and  planar  calculated  by  The e x p l a n a t i o n  version  a reactive  parameters.  hardware c o n t r o l  software  which comprise  sputtering  be  t o the  i s to i n t e r a c t i v e l y monitor,  and d i s p l a y d a t a  sputtering  t o apply  latest  i s the topic  vacuum and e l e c t r o n i c e q u i p m e n t  can  was c o i n e d  specific  of t h i s  thesis  of the MicroSput  i s as f o l l o w s .  system; a s h o r t  C h a p t e r Two i s  explanation  of each  6  o  Sputter  Plotter ParamSave  Walker  ParamEdi t ParamUt i 1 Parameter  PlotUtil  TrigAna  El2Sched  E12AnaI0  ScrnBuf f  E12DigI0 E1 2ISR  ReadRybd Schedule Starter  DataBus  Wr i t C o n s ExtraScr  Figure  1.  Mi s c F u n c  Clock ErrMessg  S t r u c t u r e of M i c r o S p u t c o m p i l a t i o n u n i t s . U n i t s a t t o p of t h e F i g u r e have a c c e s s t o those below.  7  of  t h e module g r o u p i n g s  details  t h e t o p module l e v e l ,  generalized Four  in F i g . 1 i s presented.  and  parameter  Five.  level  Chapter  the program S p u t t e r .  modules a r e d e a l t  the a n a l o g / d i g i t a l i n t e r f a c e hardware.  general  use and  Eight. the  in multitasking t h o s e of g e n e r a l  Chapter  global  Nine  The in Chapters  use  f o r any  programs  listings  of M i c r o S p u t .  The  at sign  listings  f o r the P a s c a l  pointer.  ('@')  i n Chapter  i n Chapter  Appendices  made by e a c h module and  to  M o d u l e s of  programs a r e e x p l a i n e d  c o n c l u d e s the t h e s i s .  declarations  with  Three  S i x p r e s e n t s t h e modules d e v e l o p e d  operate  Seven,  Chapter  include  the e n t i r e  i s used  i n the  8  CHAPTER Overview  MicroSput  i s written  p-System V e r s i o n extensions heavily  relies  of MicroSput  i n Pascal  IV.0 o p e r a t i n g  to standard  Pascal  and r u n s on t h e UCSD  A unit  types,  v a r i a b l e s , procedures,  packages  together  and c h e c k i n g  Because a c o m p i l a t i o n other  UCSD p - S y s t e m a l l o w s specific  of  parts:  data  types,  modules,  a pyramid  use.  entered  with  defining a  type  the keyboard.  and r o u t i n e s o f  on and t y i n g  A compilation  a v a i l a b l e t o programs  (or other  s e p a r a t e l y , the  unit  i n the i n t e r f a c e . part  together i s c o m p r i s e d of  a l l declarations  f u n c t i o n s , and units) using  which p r o v i d e s  i n the implementation  are ideal  consistent  and c o m p i l e d  v a r i a b l e s , procedures,  routines declared  which can  s t r u c t u r e d h i e r a r c h y of  units relying  the  compilation  number o p e r a t i o n s , and  u n i t c a n use t h e d a t a  (2) t h e i m p l e m e n t a t i o n ,  a  Units  t o an x-y p l o t t e r ,  bounds o f d a t a  and  declared  structure  constants,  self  ( 1 ) the i n t e r f a c e , which p r o v i d e s  constants,  processes  compiled  t o form  some complex  m o d u l e s o f more g e n e r a l two  i s called  f o r use a t r u n t i m e .  u n i t s , and u n i t s a r e w r i t t e n  increasingly  subprogram  f u n c t i o n s , and p r o c e s s e s  programming  such as sending  complex a n d s u p p l y i n g reading  the MicroSput  compiled  i s a group of s e p a r a t e l y  l i n k e d i n t o a program grouping  p-System  and (3) m u l t i t a s k i n g .  unit.  for  Three  upon w h i c h  A UCSD p - S y s t e m s u b p r o g r a m module  be  Structure  system.  are (l) separately  (2) memory o v e r l a y s ,  TWO  the u n i t ,  the r e a l i z a t i o n of  D a t a and r o u t i n e s  may be u s e d  to help  in this  9  realization; part  however  are available  contain  o n l y d e c l a r a t i o n s made  explicitly.  an i n i t i a l i z a t i o n  initializations begins  program  i s terminated.  and/or h a l t i n g  and a l l h a l t i n g  Memory o v e r l a y s a l l o w program  which  memory  (RAM).  read  i n t o RAM  Procedures, as code will  stack,  code w h i c h  a dynamic  will  be  processes.  access  segment.  may be e x p l i c i t l y  running  i s requested  allows quasi  declared unit  Only  t h e segment o f  need  be i n RAM a t any  b e c a u s e of an e x p a n d i n g or a c a l l  t o a r o u t i n e i n an used  segments  which  concurrent  execution  of s e p a r a t e  s y n c h r o n i z a t i o n and e x c l u s i o n a r e  v i a waiting  can continue  may w a i t the  i n random  t h e memory c o n t a i n i n g t h e l e a s t  Process  accomplished  upon  p-System  overlaid.  Multitasking  process  t h e main  routines in a compilation  memory a l l o c a t i o n ,  segment,  t h e main  after  of a UCSD  i s a code  segment.  i s actually  When memory  overlaid  i n RAM  A l l remaining  may  o f p r o g r a m code w h i c h c a n be  f u n c t i o n s , and p r o c e s s e s  code  before  p a r t s are executed  The minimum amount  a c t a s one f u r t h e r  instant.  are executed  the execution  or o v e r w r i t t e n  implementation  part; a l l  i s too large to f i t e n t i r e l y  segments.  program  Each u n i t ' s  of t h e u s e d u n i t s  program  i n the i n t e r f a c e  f o r and s i g n a l l i n g  past  a wait  i t w a i t s h a s been  for a single  highest p r i o r i t y )  statement  signalled.  semaphore,  only  Any number of p r o c e s s e s  execution  which has  each time the  semaphore  i s signalled.  statement  f o r c e s t h e o p e r a t i n g s y s t e m t o c h e c k a l l p r o c e s s e s and  continue  execution  with  execution  A  i f t h e semaphore  b u t o n l y one ( t h a t  can continue Every  semaphores.  of a s i g n a l  the highest p r i o r i t y  process  or a wait  which  i s no  10  longer is  waiting.  lowest,  stack  size  highest)  is limited  a task;  only  MicroSput  Listings  and  i s assigned  allocated  i t s own  of  Appendix  programming  by  its priority  the  interface  A.  The  The  u n i t s are  p a r t s of  u n i t s are  level.  i s 128,  most  these  grouped general  integer, and  and  provides  conversions.  handling  MiscFunc and  the  unit  display send  a  an  which are  next  (VDT).  data level  as  tim_rec,  a  b i t integer  t o t h e VDT  sizes  MicroSput  processes  are  it  only  w h i c h must  file  32 b i t operations  method  purpose i s an of  of from  error. mathemetical  extension  the  the  to  the  UCSD p - S y s t e m with  the  i s a s e t of p r o c e d u r e s  video which  screen.  of M i c r o S p u t  stack  UCSD  a clean exit  method of c o m m u n i c a t i n g WritCons  the  ErrMessg,  u s e f u l i n any  type  part  to  These u n i t s c o n t a i n  general  subprograms  useful for multitasking.  for process  i s the  be  ExtraScreenOps  i s provided  contained  shown a t  supplies a systematic  of  1.  level,  u s e f u l 32  assortment  standardized  formatted  modules a r e  e r r o r s , producing  operations.  terminal  The  table  fatal  ScreenOps, which  to allow  s e t of  in F i g .  d i s p l a y of a message d e s c r i b i n g t h e  contains  character  a  d e f i n e s the  ErrMessg  detected  p r o g r a m and  and  shown  units Clock,  r o u t i n e s w h i c h might Clock  i t s stack  program  WritCons.  p-System program.  and  main  according  MicsFunc,  and  The  figure  the  declarations  evaluation  i n the  b o t t o m of F i g . 1, c o n s i s t s of ExtraScreenOps,  (0  amount of a v a i l a b l e memory.  compilation  the  a priority  data  or more words) when i t i s s t a r t e d .  is itself  The  in  255  ( o f 40  program  Each p-System p r o c e s s  and  S t a r t e r a c t s as priorities;  s t a r t e d with be  includes units a look  up  since a l l  information  e d i t e d when one  from t h i s wishes  to  unit,  11  change and  the system p r i o r i t i e s .  p r o v i d e s a l l t h e r o u t i n e s needed  asynchronous data for  DataBus d e f i n e s a type  transfer  f o r synchronous  between p r o c e s s e s .  s y n c h r o n i z a t i o n of p r o c e s s e s  handshake and/or  Schedule  allows  w i t h hardware e v e n t s :  the  s y s t e m c l o c k , VDT i n p u t s t a t u s , and e x t e r n a l d e v i c e s a r e p o l l e d (the  latter  units);  v i a a handshake t o e x t e r n a l d e v i c e  and p r o c e s s  timeout  queued and s e r v i c e d . VDT i n p u t .  ReadKybd  ScrnBuff  and o p e r a t o r  disk  images, and c h a n n e l s  t o t h e VDT s c r e e n  command w a i t s a r e  s u p p l i e s formatted  provides a normally  b a c k g r o u n d VDT s c r e e n processes  waits  scheduling  asynchronous  r e s i d e n t p o o l of  formatted  o n l y when t h e c o r r e c t  data  screen  from image  is displayed. The  g e n e r a l and m u l t i t a s k i n g module g r o u p i n g s  on  any UCSD p-System  on  standard  clock). the  i / o hardware  Conversely,  standard  digital  written  room  used  multiplexing;  1  specific  118D a t UBC.  for digital E12ISR  provides access  t o t h e computer  only  the system  the analog/ system i n  i n c l u d e s the i n t e r r u p t  output  i s n o t meant  p u l s i n g and a n a l o g t o be used  E12DigI0 d e f i n e s a type  i n p u t s and o u t p u t s ;  UBC P h y s i c s E l e c t r o n i c s  service input  by u n i t s  t o t h e T T L i n p u t s and o u t p u t s .  the analog  operate  A l l r o u t i n e s i n t h e E12 g r o u p a r e  E12ISR  i n t h e E12 g r o u p .  operates  ( t h e VDT, d i s k d r i v e s ,  i / o hardware, but i n s t e a d o p e r a t e s  i n Assembler.  routines  because they  t h e E12 s u b p r o g r a m g r o u p makes no use o f  i/o interface  Hennings  those  implementation,  are useable  other  d i g i t a l and E12AnaI0  the m u l t i p l e x e d  L a b J o b No. E12.  1 2  integrating interrupt The to  analog  input  i s kept c o n s t a n t l y  level  the standard  multitasking  of M i c r o S p u t  system  routines  t h e E12 d i g i t a l  handshake w i t h  the Schedule  and a n a l o g  operator  multiplexing for  input  and adds  t h e g e n e r a l and  and a n a l o g  inputs  state process  run.  routines  group.  (via a  select  waits.  TrigAna  t h e E12 a n a l o g  method, and t o save t h e m u l t i p l e x i n g  the next MicroSput  PlotUtil  provides  allows  input information  a s e t of  t o c o n t r o l an x-y p l o t t e r  connected to  E12 i n t e r f a c e . The  f o u r t h MicroSput  generalized  parameters.  information  record,  and  from  together  u n i t ) and queues and s e r v i c e s  to i n t e r a c t i v e l y  non-interactive the  modules t i e s  g r o u p s , and t h e n o n - s t a n d a r d E12 s p e c i f i c  E12Sched p o l l s  the  by  service routines. third  digital  converting  The u n i t  which  single character  limit,  module l e v e l  screen  command  key, t h e p a r a m e t e r  wait  name, u n i t s , and v a l u e ,  read  back  from a d a t a  from  the analog  file.  t o an a n a l o g  channel  number, t h e u n s e a l e d  factor,  the unsealed  being  noted,  parameter points  value  and t h e amount  value  and upper  s e r v i c e s , the f o r the  and t h e p a r a m e t e r v a l u e a s  the parameter  information  a parameter  information  I f the parameter  then  with  name, u n i t s ,  between p a r a m e t e r  parameter  points  Parameter d e f i n e s  image, p o s i t i o n and f o r m a t  inputs,  and works  i n c l u d e s the parameter  t h e minimum p r o c e s s  display  defines  record,  input  i s measured  information  which  value,  value  includes  the input  record the input  scaling  from w h i c h an i n p u t must d r i f t that  drift  must be.  i s a l s o c o n t r o l l e d , the parameter  to a control information  record,  I f the  information  which  before  record  i n c l u d e s the  13  setpoint,  t h e r a t e o f change o f t h e p a r a m e t e r v a l u e , t h e  derivative and  feedback  multiplier,  a l s o p r o v i d e s a s e t of r o u t i n e s which  non-interactive manipulations the a n a l o g  input  displaying  the l a t e s t  list  units  miscellaneous  i n f o r m a t i o n between  routines useful  reads The  the operator  and c h e c k s  MicroSput  unit  The o p e r a t o r  save,  the  the data  frequency  file write  t o read  scans  file).  a l l controlled  parameters as read  line  from  t o e d i t the fields.  parameter s e t p o i n t . values  on f l o p p y  t o w r i t e t o , the parameters and f o r a u t o m a t i c  The o p e r a t o r may a l s o  saving, select a  ( t h i s may, b u t need n o t , be t h e d a t a '  to plot, from  specification.  information record  time,  ParamUtil  p a r a m e t e r and  the operator  the f i l e  saving.  parameters,  parameters. * Another  one c o n t r o l l e d  integration  The M i c r o S p u t  choose parameters  m a n i p u l a t i o n s of  t h e s a v i n g of p a r a m e t e r  selects  of data data  some  r o u t i n e p r o v i d e s a prompt  allows  and c o n t r o l  interactively  and s a v i n g t h e  and W a l k e r p r o v i d e  for a controlled  ParamEdit  ParamSave p e r f o r m s disk.  increment,  t h e bounds of a new s e t p o i n t  parameter, analog, Walker  the c o n t r o l  runs.  a l l measured p a r a m e t e r s ,  prompts  perform  c h a r a c t e r command and name of a l l  a l l measured and c o n t r o l l e d  routine  The u n i t  as reading  for interactive  One P a r a m U t i l  the s i n g l e  parameters,  ParamEdit,  position,  such  v a l u e , and i n i t i a l i z i n g  ParamUtil,  the parameters. specifying  of the parameters,  information, calculating  of parameter The  to  image,  formatting information f o r the s e t p o i n t d i s p l a y .  Parameter  or  and t h e s c r e e n  unit  Plotter  and p l o t s  the data  read  allows  the values file.  the operator to of those  14  The  top MicroSput  uses a set read, and  of  record,  level  generalized  i s the  program S p u t t e r .  p a r a m e t e r s and  associated  d i s p l a y , a n d / o r c o n t r o l a l l the  e l e c t r o n i c equipment.  Sputter processes  sputtering  to  vacuum  15  CHAPTER THREE MicroSput  The  highest  program S p u t t e r only  part  Software S p e c i f i c  level  (see l i s t i n g  of MicroSput  parameters according therefore to  the only  be added  parameter stack  file  although  file  and p r i o r i t y  variables  (see l i s t i n g ) ,  servicing  initializes calls  procedure 2)  Since the be For  i s then  Sputlnit  overlaid),  in Sputter  i s t h e segment  a few p a r a m e t e r  prompting  specific  procedure  Prmlnit  and t i m e d i s p l a y s and s t a r t s  information  records  c r e a t e s and (by s u c c e s s i v e  (the process  stack  by s u c c e s s i v e c a l l s  The p a r a m e t e r  to the S t a r t e r  d i s p l a y screen  t o t h e VDT, and S p u t l n i t  i s only  s i z e s and  image ( s e e terminated.  r e q u i r e d once p e r r u n o f  i s from t h i s  p o i n t on s w a p p a b l e  and t h e r e f o r e does n o t waste v a l u a b l e  the remainder  loops,  Seven).  the Parameter  the date  processes  written  initialization  is  f u n c t i o n P r m G e t ) , and s t a r t s t h e  are determined  segment  (see Chapter  calls  a l l parameter  it  one may a l s o want t o change t h e  of the a n a l o g / d i g i t a l i n t e r f a c e ) ,  Strtlnfo).  i s the  be e d i t e d when p a r a m e t e r s a r e  initializes  initializes  servicing  priorities  Fig.  which  t o the Parameter  parameter  This unit  hardware n a t u r e ;  r o u t i n e t o be e x e c u t e d  in turn  B).  i s the  ( s e e C h a p t e r F o u r ) and t h e p r o c e s s  file  Sputlnit,  up  exact  w h i c h must  procedure  (which  i n MicroSput  i n Appendix  to t h e i r  or a l t e r e d ,  first  unit  which t r e a t s the v a r i o u s s p u t t e r i n g  information  size The  compilation  To S p u t t e r i n g  of t h e M i c r o S p u t the operator  MicroSput, ( i . e . may  RAM  space.  r u n , t h e main program  by d i s p l a y i n g t h e f o l l o w i n g  task string  @ name  M i c r o S p u t  units  value  I  t ime: date: C O R O N A  vacuum  coaters i n c .  Figure  2.  Parameter d i s p l a y s c r e e n  image  'sputter'.  setpoint  17  across  t h e t o p of t h e VDT s c r e e n :  D(atalog  P(lot  corresponding the  T(ime Q ( u i t " .  S ( e t p o i n t W(alk  The o p e r a t o r  enters the  interaction  mode, when d e s i r e d , by t y p i n g one of  following characters:  S, W, D, P, E , T, o r Q ( i n upper or  lower  case, The  a l l other  responses  setpoint interaction  initialize the  E(dit  "Sputter:  and t o a l t e r  ParamUtil  parameter  are ignored).  mode a l l o w s  parameter  procedure  the operator to  setpoints.  A call  PrmEdSet, w h i c h prompts  name, c h e c k s b e f o r e  accepting  f o r the  the entered  value,  and r e t u r n s w i t h  a p o i n t e r t o the parameter  record  of the parameter  just  required  changed.  by t h e hardware n a t u r e  where t h i s  i s necessary  when one a l t e r s dc  current  control  source.  feedback  erased  continues  the present  Since  information  c a n t h e n be  the only  cases  s e t of parameters i s  the high voltage  plasma  o n l y one of c u r r e n t , v o l t a g e , o r power a t any g i v e n  instant,  t h e o t h e r two  l o o p s must be d i s a b l e d , a n d t h e i r  from t h e s c r e e n .  until  in fact  a- s e t p o i n t c o n t r o l l i n g  c a n be i n e f f e c t  parameter values  with  setpoint  Any f u r t h e r c h a n g e s  of t h e p a r a m e t e r  made f r o m w i t h i n t h e p r o g r a m S p u t t e r ;  i s made t o  the escape  setpoint  The s e t p o i n t i n t e r a c t i o n  key i s p r e s s e d  mode  i n s t e a d of a parameter  select ion. The  walk  automatic entire  interaction  scanning  mode a l l o w s  the operator  (or 'walking') of a parameter  operation- i s performed  by a c a l l  t o s e t up t h e  setpoint.  t o the Walker  The  procedure  ParamWalk. The select  data  read  parameters  logging  interaction  and/or w r i t e data t o save,  mode a l l o w s  files  the i n t e g r a t i o n  the operator t o  and t o s p e c i f y t h e time  f o r those  s a v e s , and  18  for  automatic  entire  operation  procedure  select  plot  i s performed  data  the p l o t  mode,  file  by a c a l l  interaction  the operator  frequency.  The  t o t h e ParamSave  run.  mode a l l o w s  has s p e c i f i e d  file,  the data  In t h a t c a s e ,  both  and t h e new p o i n t s b e i n g  entire  r e c o r d save  p a r a m e t e r s and b o u n d s .  same a s t h e w r i t e current  saving, the data  ParamFile.  The  log  data  operation  I f , while  the read  plotted  i n the data  file  will  t o be t h e  be t h a t o f t h e  the o l d p o i n t s a l r e a d y  added  i s performed  the operator to  to i t are plotted.  by a c a l l  i n the The  to the P l o t t e r  procedure  PlotSetup. The  time  initial  time  logging  write  performed  interaction from  which  file  The  edit  the  Sputter  the  operator  t h e VTD d i s p l a y  time  by a c a l l  procedure  i s prompted w i t h  the ParamEdit  interactively parameter TrigAna  edit  procedure  and t h e d a t a  This reset i s  TimSetTO.  modes b o t h  SputEdit.  create c a l l s to  In t h e e d i t  the f o l l o w i n g s t r i n g : R(eturn".  PrmEdit,  case,  "Edit: call  the operator to  contained  'T' g e n e r a t e s  T r i g S e t u p , which a l l o w s  mode  'P' p r o d u c e s a  which a l l o w s  a number o f c o n s t a n t s  information records.  interactively inputs.  procedure  of t = 0 , t h e  of t h e t i m e  procedure  interaction  P a r a m e t e r s T ( r i g g e r s dcS(upply to  a reset  entry are referenced.  to the Clock  and q u i t  segment  mode i s s i m p l y  i n the  a call  t o the  the operator to  c h o o s e t h e m u l t i p l e x i n g method o f t h e a n a l o g  'S' c a u s e s  the operator  "Supply  Gain:  selects  one o f t h e t h r e e  inverse  of i t s feedback  t o be f u r t h e r  I ( c u r r e n t V ( o l t a g e W(power". supply  prompted  The o p e r a t o r  p a r a m e t e r s and t y p e s  loop gain.  with:  i n the  T h i s a t t e n u a t i o n i s the  19  change for  i n analog  a given  power  change  In t h e q u i t  mode c a s e ,  i s presented  re-loaded  voltage  current  i n the e d i t  mode b e i n g  the screen  with:  "R(eturn  I f the operator  types  parameters. overall doing  A l l of t h e s e  parameter  output;  read  t o or [escjape  specified Of  delay  between  these  number,  full  different  there  inputs:  scale value,  the parameter and send  reading,  reads  to the screen  they  data  the c o n t r o l fora  two P a r a m e t e r  input value  specified  of the o p e r a t o r  by f o u r This  from  process  i t s last  PrmShow w r i t e s t h e  ( i f t h e p a r a m e t e r d i s p l a y image  i s above an o p e r a t o r  channel  procedures.  to d r i f t  and s c a l e s t h e v a l u e .  features  a s name,  MeasTask.  c h e c k s t o s e e i f a w a r n i n g message s h o u l d  the remainder  hardware  such  readings  e x t r a _ l , and  are processed  process  calling  f o r the analog  out  loop  value; i f  four a r e simple  anode, r f _ b i a s ,  etc.),  of t h e S p u t t e r  loops, a l t e r n a t e l y  the v a l u e  for a l l  continually  v a l u e ; and w a i t  (other than  PrmRead w a i t s  value  i s running,  a r e no d i s t i n g u i s h i n g  parameters  starts  then  processes  have t h e same g e n e r a l  s e t of parameters,  d i s p l a y s of analog Since  servicing  period.  the present  extra_2.  image i s  MicroSput.  calculate  d i s p l a y t h e new p a r a m e t e r  from  P r e s s i n g t h e e s c a p e key  or c a l c u l a t e  i s controlled,  ( v o l t s ) , or  exited.  'R', t h e s c r e e n  processes  s t r u c t u r e — w h i l e MicroSput  the f o l l o w i n g :  simply  contains  required  image i s c l e a r e d , and t h e  and s p u t t e r i n g i s c o n t i n u e d .  program S p u t t e r  (0... 10'volts)  (amps), v o l t a g e  t h e n o r m a l method o f t e r m i n a t i o n o f The  and  i n supply  'R' r e s u l t s  MicroSput:".  the  control  (watts).  operator  is  output  i s active),  be d i s p l a y e d upper  specified  limit),  delay  (i.e.  if  and w a i t s  between  20  services fed  The s u b s t r a t e dc b i a s v o l t a g e i s  t h r o u g h a 100:1 v o l t a g e  analog 33:1  of t h a t parameter.  input;  voltage The  divider  the f l o a t i n g  2  divider  anode dc v o l t a g e  with  range s e t t i n g Sputter  PresTask  PrmRead, t h e n  complete,  PresTask  i f less  maximum  (minimum) g a i n ,  outputs."  multiplied  i s checked.  All  controlled  value.  than  11500), t h e  i s n o t a l r e a d y on  p r o c e d u r e ChangeRange i s  input  scaling  a p a i r of  factor  i s then  d i s p l a y decimal  by one, and a w a i t  field  o f one s e c o n d f o r  i s performed. p a r a m e t e r s use t h e P a r a m e t e r  Prmlncrm t o determine parameter  the loop i s  input value ( i n  o r d i v i d e d by t e n , t h e v a l u e  to settle  gauge  the Parameter  t h e new d e c a d e u s i n g  The a n a l o g  & display  L i k e MeasTask, t h e  I f t h e range  the l o c a l  read  the p r e s s u r e  calling  1000 ( o r g r e a t e r  decremented or incremented t h e meter  3  input.  However, b e f o r e  the analog  ChangeRange s e l e c t s  digital  first  PrmShow.  than  range v a l u e  decades.  loops,  checks  present  called.  i s a l s o a simple  from one o f t h r e e  procedure  millivolts):  i s f e d through a  t h e a d d i t i o n a l need t o c h o o s e  process  parameter  t o t h e anode p a r a m e t e r a n a l o g  sputtering pressure  parameter  to the r f _ b i a s  t h e next  d e s i r e d increment  function i n the  Prmlncrm p r o d u c e s a c o n t r o l i n c r e m e n t  designed  A l l i n t e r f a c i n g between M i c r o S p u t h a r d w a r e and h i g h v o l t a g e equipment i s done t h r o u g h h i g h v o l t a g e 1/16 amp f u s e s (Buss HJV 1/16). 2  3  MKS B a r a t r o n  Type  170M-6B c a p a c i t i v e manometer.  C u r r e n t l y b i t s 5 & 6: both high s e l e c t s 1 T o r r f u l l s c a l e , 6 h i g h , 5 low s e l e c t s 100 mTorr f u l l s c a l e , and 6 low, 5 h i g h s e l e c t s 10 mTorr f u l l s c a l e . 4  21  to  d r i v e the  parameter  towards  d e p e n d s upon t h e  absolute  setpoint  value  reading 10%,  of  the  value than  and  10%,  they  Prmlncrm c a l l e r of  situations  the  MicroSput custom  may  of  v a r i e s , to  sum  a l l past  crossover  to decay  must  then  loop gain. will  d r i v e up  to  driver  and  6  the  leak  first  direction  GasTask approximates the  5  Granville Phillips  6  UBC  7  Hastings  Physics  The  by  the  of  the  Each  7  gas  severe of  these  e x p o n e n t i a l l y with  leak the  (see F i g . 3 ) . both  the or  216.  NALL-5.  a  Sputter  position  No.  E62.  of  the  closing).  characteristics  Job  using  5  meters.  position  (opening  true valve  Model  flow  start  depends on  of m o t i o n  valves,  several  valves.  E l e c t r o n i c s Lab  Type H-5  leak  f o u r gas  i t s own  Model  value  non-linear control  f o u r gas  applied control pulses  valve,  properly,  be v a r i a b l e .  approximation,  exponent  t o match  control  increment  For  i f less  the  c o n t r o l to perform  s c a l e the  than  parameter  i s chosen two  the scale  i s greater  towards  between t h e  f o r parameter  the  the  full  t o skew t h e  (the decay c o n s t a n t  Unfortunately, and  designed  GasTask d e a l s w i t h  valves of  percentage  of  value  i s s e r v i c e d by  GasTask.  non-linearities  are  scale factor  four channel  parameter  process  I f the  a percentage  f o r c e the  feedback  this  as  which  d i f f e r e n c e between  s p e c i f i e d ) r a t e of c h a n g e ;  exponentially  In o r d e r  the  i n a manner  (operator  skew r a t e s a t t h e  inverse  flow  will  of  expressed  that parameter.  at a constant  methods). the  value  c o n t r o l increments  setpoint the  the  i t s setpoint  by  choosing  22  *  t  CvJ  +  O OS  O  o+ 0.0  0.5  1.0  1.5  sum of pulse lengths (seconds)  Figure  3.  C o n t r o l c h a r a c t e r i s t i c f o r gas l e a k v a l v e #1. T r i a n g l e s p o i n t i n g upwards and downwards r e p r e s e n t i n c r e a s i n g and d e c r e a s i n g f l o w , r e s p e c tively. I n i t i a l f l o w s a r e 0.04 cc/m upwards, 0.05 cc/m downwards.  23  each v a l v e ' s  exponent  from a s e t of  determined at d i f f e r e n t GasTask a l s o accounts in  valve  #1)  amount on  by  every  for severe  way,  any  valves,  avoiding  just  initial  by  i n the a  slow c o n t r o l slew  The  gas  digital  outputs.  timer  GasTask might pulse  be  power.  The  dc  supply,  current,  start  8  of  disasters.  The  are  2%  sent  pulses  A  pulse,  serve final  sent  run.  can 2  seconds) second).  calling  which u s e s a  other  the  be  custom d r i v e r by  to  processing  s c a l e per  t o the  of  assumed  to c l o s e  (e.g.  s i n c e the  in favour  second  empirical  manifold  full  are  an  one  the MicroSput  wait  of  (over  v a l v e s are  error will  procedure DigPulse,  parameters are supply:  sply_ctrl  9  using  the  programmable  execution  of  processes  when  value  a s s o c i a t e d with  sply_ctrl, i s the  i s c a l c u l a t e d and  voltage,  The  by  motion.  the  arrives.  current  and  the  (e.g.  suspended  Four M i c r o S p u t dc  rate  t o r e s e t the  r e s e t time  voltage  c o n t r o l pulse  v a l v e , m e t e r , and  c o n t r o l pulses  E12DigIO assembler interrupt  backlash  large between-service  and  four  valve  backlash  overpressure  p r o b l e m of d e l a y  valve  before  constants  d i r e c t i o n s of  change of d i r e c t i o n .  In t h i s  only  r a t e s and  i n c r e a s i n g the  have been o p e n i n g  handled  flow  empirical  high  current, voltage,  control voltage  d i s p l a y e d by  or power p a r a m e t e r  the  sent  to  whichever  of  is controlling  the  and the  supply.  C u r r e n t l y b i t s 0 and 1 s e l e c t t h e v a l v e , a d d r e s s i n g a c c o r d i n g t o t h e v a l v e number i n base two, a c t i v e low. Bit 2 a c t i v e low w i l l c l o s e t h e s e l e c t e d v a l v e , w h i l e b i t 3 a c t i v e low w i l l open i t . 8  9  Plasma Therm Type MDS  5000D.  24  The  c u r r e n t and v o l t a g e v a l u e s  connected leg  t o a custom  o f t h e dc s u p p l y  a r e read  from a n a l o g  floating  ammeter  isolated  cathode v o l t a g e ,  respectively.  processes  t h e power p r o c e s s  the  signal  new power  has  variable  B o t h c u r r e n t and v o l t a g e  commands  by t y p i n g Q ( u i t ,  detected  a fatal  'running',  1 0  and o p e r a t e  t h e main S p u t t e r  task  on  to halt  e r r o r and r e s e t t h e g l o b a l S c h e d u l e t h e main  task  resets  by c a l l i n g  w k H a l t , t h e ReadKybd p r o c e d u r e t h e ParamSave p r o c e d u r e  procedure  to c a l c u l a t e  [ e s c j a p e , o r when a s u b s i d i a r y t a s k  down a l l s u b s i d i a r y p r o c e s s e s  sbHalt,  f e d by t h e  value.  When t h e o p e r a t o r execution  i n t h e anode  1 0  and a 100:1 v o l t a g e d i v i d e r  inputs  'running'  and s h u t s  the Walker  procedure  r k H a l t , the ScrnBuff  procedure  p f H a l t , and t h e P l o t t e r  plHalt.  UBC P h y s i c s E l e c t r o n i c s  boolean  L a b J o b No. G90.  25  CHAPTER FOUR MicroSput  In  any  programming  recording,  i t s own  conceptual a  of  can  done a t  this and  or  route may,  little a later  will  on  lead  duplication  and  and  the  new  Extension may,  at  type; be  of  be  the  t o any  some p o i n t ,  made a v a i l a b l e .  p a r a m e t e r s v i a the  generalized  t o be  require this  units:  ParamSave, and  generalized  however,  fits  complete  is  parameter  will of  standard  r e d e f i n i t i o n of  avoid  further  i s understood  within i t . t o new the  program  services sputtering  problems  parameter  data  r e v i s i o n must process  method. level  of M i c r o S p u t  Parameter, ParamUtil, (see  one  Future a d d i t i o n  p a r a m e t e r method  without  having  r e p e t i t i v e programming  routines,  i n t e r f a c e d to  a  general,  a standardized  the  write  programming  more memory t h a n  providing  MicroSput  Plotter  In  of  former  programmers w i t h o u t  require  p a r a m e t e r programming  compilation  other  designing  trivial,  The  f u r t h e r custom  l a r g e amount o f  by  t o make use  manipulations.  standards.  generalized  a means t o do  The  by  or  parameter  s u n d r y p a r a m e t e r s and  to a  equipment  each  the  waste of memory.  parameters w i l l  service  between  date  providing  to  the  routines,  a microcomputer,  t y p e and  monitoring,  and  parameter  Conversely,  involves  data  forethought;  to conform  available. data  of  generalized  requires  learn  set  Software  process parameters,  must d e c i d e whether  custom  method  to  s i t u a t i o n which  similarities  library  be  Parameter  a n d / o r c o n t r o l l i n g of  software engineer with  Generalized  listings  includes  ParamEdit,  i n Appendix C ) .  six  Walker, These  26  modules d e f i n e to  the information  interactively  electronic  monitor  equipment  continuous,  slowly  and p r o v i d e  and r e c o r d a n d d i s p l a y d a t a  the  i n room  varying process  The operate  i n Chapter data  pointers  only in  records  the f i r s t .  Chapter  1.  MicroSput  runs.  initializes  by  c a n be u n a m b i g u o u s l y  i n the f i l e Sputter  value,  second  used  later  parameter  record  and s e t p o i n t  records  high  t h e s e t of  are outlined  f o r every  MicroSput  between  level  program)  s e t of r e c o r d s  below  parameter  i n the f i l e .  by c a l l i n g  such  entry  the f i r s t ,  etc.  to a linked  (such  that  name,  e x i s t s ) are assigned  the f i r s t  parameter  be d i s p l a y e d a t t h e t o p o f t h e image,  i n the run f o r searches field  The row p o s i t i o n  image of t h e p a r a m e t e r  ( i f the l a t t e r  t o PrmGet  by PrmGet w i l l just  initialized  each  contain  records,  uti1:system.param  d i s p l a y screen  sequential calls  the  information  records  triplet  ( o r any o t h e r  modules  r e f e r r e d t o by m e n t i o n i n g  of these  of the r e c o r d  the parameter  initialized  fields  level  f u n c t i o n PrmGet, g i v i n g a non v a r i a b l e name w h i c h  the parameter  units,  and c o n t r o l  information  p o i n t e r s t o and r e a d s  Parameter  identifies in  ParamSave and P l o t t e r a r e  and c o n t r o l i n f o r m a t i o n  A copy  i s kept  make use o f  Five.  The d a t a  parameter  the  Units  the parameter  to analog  three  The g e n e r a l i z e d  s t r u c t u r e s upon w h i c h a l l p a r a m e t e r  Since  from any  t o u s e on t h e m i c r o c o m p u t e r  a r e the parameter, analog,  records.  all  parameter.  118D o f H e n n i n g s a t UBC, s i n c e t h e y  E12 subprogram group.  described  required  which measures and/or c o n t r o l s a  p a r a m e t e r modules a r e r e s t r i c t e d system  the routines  list  PrmGet a l s o adds t h e of parameters, which i s  o f an o p e r a t o r  a s name o r s i n g l e  specified  character  command  27  key) . The  body of PrmGet  ParamlO, a l o n g  with  by  code of  the h a l t i n g  function save  of  file  PrmPut and  the  end  display  screen  display  positions  initialization  the  up  input wait procedure  their  require not  be  data  E12Start  i n an  method, and  may  units  first.  order vary  that a l l unit  only  implemented the  beginning  therefore The  be  ensures the  unit on  overlaid  useful  procedure  calling  which  started  initialization  parts  up  run  time  next.  One run  linking can  be  o n l y when  P r m l n i t , PrmGet, and are  r u n , and  may are  PrmPut  needed a t  may  execution. c o n t a i n s a number of  p r o c e s s i n g , most of w h i c h to operate  i s a measured one  ErrorNoted  the  Triglnit,  in turn  ParamlO, s i n c e t h e y  a p o i n t e r to the parameter  ErrMessg  units,  starts  initializations  p a r t s have been  d u r i n g normal  t h a t the p a r a m e t e r  full  the M i c r o S p u t  f o r parameter  parameter  display  completely  the p - S y s t e m  begins.  of  their  message  procedure  program t o the  segment  or end  be  their  Parameter c o m p i l a t i o n u n i t  procedures passed  i n the  warning  initializing  the T r i g A n a  initialization  t h e main p r o g r a m e x e c u t i o n are  one  and  to  parameter  m u l t i p l e x i n g by  other  The  The  inverse  w a r n i n g message, P r m l n i t  as  depending from  run.  cannot  codes,  the  r e c o r d s out  date,  and  and  performs  is called  t o P r m l n i t b e f o r e any  and  r o u t i n e s from  initialized  unit,  Besides  servicing  Those two  and  passed  date,  initialization  executed  sure  time,  time,  segment f u n c t i o n  PrmPut, w h i c h  the parameter  proceed.  of  by  Parameter  the MicroSput  must be  can  respectively.  of  i n the  Prmlnit.  image name and  servicing  El2Sched  the  PrmGet, dumping  at  analog  i s contained  is called,  on.  short are  PrmRead  ( i f measure halting  is n i l ,  MicroSput  28  execution).  A call  to the E12Sched p r o c e d u r e WaitAnalog  returned  from u n t i l  observed  t o have d r i f t e d .  then  used  the a n a l o g  to determine  derivative  The  the  with respect  input  c h a n n e l has  input  v a l u e as w e l l  to time.  The  is called  t o mark t h e new  PrmAnaSet  specifies  the v a l u e t o d r i f t  controlled  controlled the  parameters,  parameters.  resolution  parameter  settles  into  displayed drift  been c h a n g i n g  from W a i t A n a l o g  analog  input  change  i n time t h a t  service value  routine  using  significant  range  can  The  in value divided  interval  minimum w a i t  t i m e between p a r a m e t e r  whichever  Processes  next d e s i r e d  the  Parameter and  first  the s c r e e n  drift  wait.  The  t o the  El2AnaI0  specifies  t h e minimum  interrupt  of change of t h e by  t o be e i t h e r  has  t h e change one  services,  input  i n time.  q u a r t e r of  or one  the  half  i s smaller.  servicing  the  an e r r o r  i s taken  i f the  value  value  must have p a s s e d b e f o r e t h e  the change  below  I t i s necessary to  v i a the  the r a t e  just  digit,  a r e communicated  T h i s minimum  second,  display  also  setpoint,  i s either  t h e coming  latter  approximate  the  i f the parameter  routine  and  r e a d i n g , f o r non  in order that  during  its first  t o be  when t h e p a r a m e t e r  service  p r o c e d u r e AnaSetBound.  from  latest  allowable error  interrupt  and  requirements.  amount of d r i f t  once  v a l u e be c o r r e c t and  drift  or z e r o ,  as  value i s scaled,  o r out of bounds.  i t s specified  position  or the  least  value i s stable,  previously return  of t h e  The  read  E l 2 A n a I 0 p r o c e d u r e AnaRead i s  PrmAnaSet  for  been  i s not  the c o n t r o l l e d  increment  function  parameters  i n the parameter  Prmlncrm.  h a l t s MicroSput  Like  can  calculate  v a l u e by a c a l l  PrmRead, Prmlncrm  i f the parameter  has  no  to  notes  control  29  information  record.  If c o n t r o l  operator  specification  disabled  control  Prmlncrm w i l l above t h e will as  be  the  return with limit  returned.  The  signal,  provides  the  latter  limit  matter  the  of  no  of be  time  i n t o an  value  the  minus  ongoing (PI)  services.  control  so as  to ensure a by  feedback  gain  i s chosen  such  in practice,  only  take  i s more t h a n  10%  of  full  control control,  effect  no  the  parameter  specified  parameter  the  increment,  that  will,  the  However,  than  skew r a t e l i m i t  is  calculated  r a t e of change of  between  to f i n d  value  that error  the v a l u e ,  proportional integral  greater  derivative  value  the  will  has  mode),  I f the  negative  when added  in absolute  skew r a t e of The  i s used  the  zero.  s e t p o i n t and  zero elapsed  limited  operator.  order  of  (by  operator  interaction  increment  times  initialized  i f the  edit  below z e r o ,  loop gain  first  been  increment  increment,  w h i c h method  latter.is value  an  Otherwise,  feedback  value.  in  or  parameter  d i f f e r e n c e between t h e  derivative  not  of a s e t p o i n t ) or  ( i n the  upper  has  the that  when  the  the  scale different  from  the s e t p o i n t . Newly measured or c a l c u l a t e d VDT  screen  three  by  calling  completely  parameter screen, process.  the  but  must  One  reasons,  cannot  i n s t e a d pass  problem  can  i s that  directly  the v a l u e the  number t o ASCII  a serial  line  real  it  over  t o t h e VDT.  of  p e r h a p s a dozen p a r a m e t e r  space  To  (about  250  by  value  to  s e r v i c e processes  a the  updating  statement words) t o  c h a r a c t e r s , then  i n c r e a s e the  the  For  called  w r i t e the  p-System w r i t e  the  the  PrmShow.  to a screen  stack  of  d i s p l a y e d on  a procedure  r e q u i r e s a l a r g e amount of conversion  be  Parameter procedure  independent  s e r v i c e process  values  stack  would use  do send  sizes up  30  about the  s i x k i l o b y t e s of RAM.  screen  time:  by  parameter  servicing  t h e m e n t i o n e d ASCII  transmission not  A second  control.  should  only  actually  b a c k g r o u n d VDT as  conversion  done w i t h  measurement and  written  processes  require a substantial  n e c e s s a r i l y be  soon as  p a r a m e t e r may  be  The  be  screen  as  problem with  and  high a p r i o r i t y  is active,  image  s t a b l e and  serial  f i n a l problem  images  that  i s added  not  to the is  do  procedure  the  a c t u a l w r i t i n g only  parameter reloaded.  upper  d i s p l a y screen The  limit;  value  beeped: the is the  value  and  even  this  then  c h e c k e d , and  specified far  the  i s waited  delay)  of  the  whatever  (a t a s k  and  with  of  time  by  time  calling  process  or when t h a t  and image  parameter's  i s s e t and  I f the  t h e VDT  parameter.  elapsed  the  parameter's  to a u d i b l y  t o the  the  is received  have o c c u r r e d  a call  is  determine The  clock  between  executing u s i n g up  Schedule  some of  procedure  WaitTick. The PrmList,  remaining and  parameter's  Parameter  PrmEdited. setpoint with  g l o b a l r o u t i n e s are  PrmPoint the  updates a  given  be  the  a separate  operator,  the  values  d i f f e r e n c e remains  the  s w i t c h may  out  the  parameter  though  t o the  warning  operator  servicing  s e r v i c e delay  PrmShow so  is active  been s e t by  need  immediately.  value  is signalled.  feature allows  a c t u a l frequency  signals  when a new  boolean  yet  c o n v e r s e l y must  serviced  i s a l s o compared  ParamWarn  beep has  which  image  i f g r e a t e r , the  Parameter process boolean  sbTossReal,  as  i s that  PrmShow t h e r e f o r e d i s p l a y s t h e p a r a m e t e r v a l u e ScrnBuff  time,  of many p o s s i b l e  i s reloaded,  thus  execution  line  amount of c p u  w r i t t e n when one  w r i t i n g to  PrmPoint,  controlled  number, s e n d s  i t to  the  31  parameter  display  written),  and,  t h e change  t o the  The  of a  rather  than  ensures that and  same manner as  function  be  calls  which t o d r i f t . of p a r a m e t e r  to return  simply d e c l a r i n g altered  processes are  very  short.  WaitTick, display  the  segment, While  time,  variable  by  units.  external  since  ScrnBuff  procedure  warning  found  by  insures time,  through  The  finding  i f an  warning  ParamWarn w a i t s  when t h e c o m p l e t e a true  loops,  warning.  list  procedure  i s d e c l a r e d as a code  needed v e r y  upper  limit  t o t h e VDT  list  set.  limit  often.  error  names w i l l  has  has  been  screen (via  looking  parameter in error  for a  T h i s s e a r c h method  error  f o r another  to  sbTossNow.  name of the p a r a m e t e r  the p r o b l e m a t i c parameter  signal  t o be  the parameter  one  run. ShowTime  the Schedule  in fact  notes  edited,  Parameter.  s b T o s s S t r i n g ) a message naming t h e  i f more t h a n  alternately.  been  the S c r n B u f f p r o c e d u r e  loops, flashing  w i t h the boolean  that  global,  screen updating process  expected  of the e r r o r .  cycling  parameter  t h e VDT  i s r u n n i n g , and  ParamWarn  as  PrmEdited  i t simply  by c a l l i n g  l o n g e r , and  i t i s not  MicroSput  signalled,  second  note  r e t u r n s the  of t h e M i c r o S p u t  i n the u n i t runs,  to  pointer,  i n f o r m a t i o n r e c o r d s has  by c a l l i n g  i s somewhat  PrmList  the p o i n t e r  MicroSput  signalling  PrmAnaSet  t h e v a l u e of t h i s  included  w a i t i n g one  and  ParamWarn  While  the value i s  information records.  t h e r e f o r e e n a b l e s PrmPut a t t h e end  alternately  and  list  o r more p a r a m e t e r  Two is  from  linked  i t cannot  one  ( i n the  f o r measured parameters,  in setpoint  pointer use  screen  occurs at a given be  flashed  upper  been c y c l e d  limit  through  error without  is  32  The  MicroSput  compilation unit  routines  useful f o r operator  searches  the parameter  like  a l l MicroSput  independent. information given. the  record  i s returned,  otherwise  (e.g.  commands and names ( e . g .  the t r a i l e r those  must_ctrl being  '[esc]'.  If the boolean  every  time  saving or  i s s e t , then  PrmPrmpt  considered  mode.  i s called,  The time  each parameter  allowed  by a c a l l  prompt  procedure  line  name  is  too long  up  into  must_meas  then  i f the boolean  line  t o change  i s rebuilt  to b u i l d  f o r the operator t o t h e prompt  procedure  name  edit  t h e prompt  of higher  space  the parameter  line i s  interaction to  respond.  l i n e , the  priority  tasks i s  Polllnputs.  When  i s made t o t h e ReadKybd  which p r o m p t s t h e o p e r a t o r  to f i t across  i s set,  i n the parameter  i s added  at the s p e c i f i e d  A(rgon'),  from t h e a n a l o g  s i n c e most o p e r a t o r  a call  from  single  I(current  The prompt  and e x e c u t i o n  i s ready,  string  parameters which a r e capable  needed  t o the Schedule  PromptCapIn,  new s t r i n g  line  so a s t o n o t waste memory  to pass waiting  system s t a t e i s p o l l e d  the  the n i l pointer i s  similarly  the operator  t o be u n i m p o r t a n t  i s expected  After  those  c h a r a c t e r command w h i l e  interaction  time  parameter's  a r e read  are included.  i t and t o a l l o w  single  only  name;  i s case  *V(oltage  p a r a m e t e r s whose v a l u e s  controlled  the given  ' S e t p o i n t : ' ) , the parameter  i n p u t s a r e i n c l u d e d i n t h e prompt;  of  with  PrmNamed  a pointer to that  three  The f u n c t i o n PrmNamed  f o r a parameter  name o p e r a t i o n s ,  I f found,  title  character  only  interaction.  contains  The f u n c t i o n PrmPrmpt composes a prompt  given  and  list  ParamUtil  VDT s c r e e n  the screen,  position. PromptCapIn  p o r t i o n s w h i c h c a n be c y c l i c a l l y  by w r i t i n g t h e I f the s t r i n g will  break i t  v i e w e d by t y p i n g ' ? ' .  33  PromptCapIn characters or  i s not r e t u r n e d (inthis  the escape  escape  case,  from u n t i l  a parameter  one of t h e s p e c i f i e d single character  command  key) i s t y p e d  ( i n upper  or lower c a s e ) .  I f the  key was t h e o p e r a t o r  response,  PrmPrmpt  the n i l  pointer.  Otherwise,  to the parameter  the parameter  information  list  record  returns  i s s c a n n e d and a p o i n t e r  containing  the response i s  returned. One example of t h e u s e o f PrmPrmpt function not  PrmEdSet.  value  accepting  from  i t only  the screen  PrmPrompt The  with  new  compilation PrmEdit  This procedure  u n i t ParamEdit  discussed  performs  interactive  PrmEdSet  returns  contains  only  records.  with the  a t the beginning  PrmEdit  of t h i s  are to provide  begins  image,  one g l o b a l  execution  'prmedit'  a name o r s t r i n g and a b l a n k  segment).  of the parameter,  PrmEdit  i s the l a r g e s t  w h i c h needs t o be done o n l y programming  chapter.  a fast,  and t o e n s u r e a l l o p e r a t o r  VDT s c r e e n  editing  the g e n e r a l i z e d parameter  the procedure  fields,  limit.  to begin  ( w h i c h t h e r e f o r e a c t s as a code  and c o n t r o l i n f o r m a t i o n  when u s i n g  of  number,  and t h e upper  i s then c a l l e d  setpoint.  example o f m e n i a l programming  editing  i n a new  result.  procedure,  analog,  this  i f the r e s u l t i s  c l e a r s the s p e c i f i e d  and r e a d s  PrmPoint  ParamUtil  PrmPrompt;  i f i t i s between z e r o  Parameter procedure  processing  of  calls  n i l , t h e ReadKybd p r o c e d u r e F e t c h R e a l  setpoint  The  The l a t t e r  i s the  user  once  method  The main  concerns  friendly  method of  inputs are v a l i d .  by l o a d i n g  (see F i g . 4 ) .  the e d i t i n g This  background  image c o n s i s t s  d e s c r i b i n g each of the e d i t a b l e parameter area  i n which data  from e a c h  field  c a n be  N(ame U(nits I(d L(imit C(hannel i n F ( u l l scale S(lew r a t e E(nable  Parameter  D(ecimals  W(ait  B(eep  Constants name: units: id upper l i m i t : decimal f i e l d minimum w a i t between s e r v i c e s ( s e c o n d s ) beep c o n s o l e e a c h s e r v i c e :  Measurement  Constants analog input channel: f u l l scale ( 1 0 V ) value:  Control  Constants maximum slew r a t e : control enabled:  Figure  4.  Parameter e d i t i n g s c r e e n  % full  image  scale  'prmedit'.  35  written. screen  L i k e a l l MicroSput  images w i t h d a t a  fields,  coordinates  i n a table  source  so t h a t c h a n g e s  file  without  i s prompted  PrmPrmpt. written  The d a t a  Some o f t h e d a t a friendly  form.  multiplied presented to  by t h e f u l l  as the parameter's  i s n o t measured will  be s e n t  fields  to erase  from  scale  an a n a l o g  procedures. i n a user  scaling  factor i s  v a l u e , which  i s presumed  I f the parameter  input or i s not c o n t r o l l e d ,  t o t h e measurement a n d / o r c o n t r o l field  entries.  data A prompt  and command c h a r a r a c t e r match s e t a r e c o n s t r u c t e d o f  used  change. exiting  t o whether  t o determine I f a data the e d i t ,  which enables records  or not the parameter The ReadKybd p r o c e d u r e  t h e o p e r a t o r ' s c h o i c e of data  field  i s chosen,  the Parameter h a l t i n g termination.  t o v a r i o u s ReadKybd p r o c e d u r e s field  names and s i n g l e those  r a t h e r than  the Parameter procedure  upon M i c r o S p u t  image d a t a  •with  input  use t o t h e o p e r a t o r .  measured and/or c o n t r o l l e d .  calls  full  procedure  i n p u t r e a d i n g o f 10,000 and  any p r e v i o u s p a r a m e t e r  commands a c c o r d i n g  is  t o be p r e s e n t e d  analog  A  p a r a m e t e r a r e then  to WritCons  the analog  scale  references.  t o the ParamUtil  the chosen  must be c o n v e r t e d F o r example,  blanks  line  from  image c a n be made  for coordinate  by v a r i o u s c a l l s  be o f more immediate  value  at the t o p of the procedure  f o r by a c a l l  t o the screen  keeps t h e f i e l d  i n the screen  the f i l e  fields  u s i n g b a c k g r o u n d VDT  PrmEdit  of c o n s t a n t s  s e a r c h i n g through  parameter  procedures  code t o save  which blank  c h a r a c t e r commands a r e c h e c k e d i n use.  I f the f i r s t  f i e l d to  i s called  the e d i t e d  are read  b e f o r e a c c e p t i n g new v a l u e s .  already  PromptCapIn  immediately  PrmEdited  A l l data  value i s  i n by  out the screen  New  parameter  for conflicts  c h a r a c t e r o f a new name  36  is  not a l r e a d y  conscripted the  full  a n o t h e r p a r a m e t e r ' s command key,  f o r use w i t h t h e newly  scale  automatically error  change  such that  resolution changes set  input  effect.  o r number of d e c i m a l s t o  alter  field  editing  to q u i t ,  upon w h i c h  for.  The  formerly  active  The  given  stopped, thirty  steps,  or  determine  stack  started.  The  mode s c r e e n screen  rate.  The  disable setpoint  the  parameter  i s reloaded  operator i s prompted  and  PrmEdit  p r e s s e s t h e e s c a p e key  instead  subprogram  size  latter  level  The  and  unit  pointer  to n i l ,  and  waits for a signal  and  motion  t o be  is called  to is  operator  and  interaction The  the operator i s  The  time r e q u i r e d  walk  (see F i g . 5 ) .  command e x c e p t  the walking p r o c e s s WalkSetp. r a n g e bounds,  code  s c a n t i m e t o be  from t h e  loaded  are w r i t t e n Any  across a  PrmWalk.  ' w a l k s e t ' t o be  f o r a command.  Walker  the p r o c e s s WalkSetp  t o PrmWalk c a u s e s t h e p a r a m e t e r image  setpoint  procedure S t r t l n f o  priority,  segment p r o c e d u r e  module  initialization  chooses the d e f a u l t  Starter  image d a t a f i e l d s  prompted  services  be aware o f t h e  until  'walks', a parameter  arbitrarily  minutes.  A call  image  the walking parameter  and  interaction  continues  screen  parameter  range a t a g i v e n  initializes  will  Any  selection.  generalized  interactively  parameter  another e d i t  from when t h e o p e r a t o r  a parameter  delay  drift  the  displayed.  the o p e r a t o r  'Q'  of  display  be below  digit  the a c t u a l  types  returned  will  significant  b o o l e a n so t h a t  Parameter  Changes t o  t h e measurement maximum a c c e p t a b l e  of t h e l e a s t  t h e beep  named p a r a m e t e r .  a l l acceptable d r i f t  which might  i t is  'E'  (exit)  parameter  to  will walk,  t o c o v e r t h e range  can  Walk: @  walk  P(arameter  L(ow  H(igh  T(ime  U(p  D(own  S(top  E(xit  parameter: range: cover  <= range  setpoint  Figure  in  setpoint  <=  minutes  motion i s  5.  Parameter  walking screen  image ' w a l k s e t ' .  ^1  38  all  be e d i t e d .  decreasing can  Walking  c a n be d i r e c t e d  setpoint, starting  be r e m a i n d i s a b l e d .  walking  i s enabled,  resolution setpoint  (and v a l u e )  required  t o cover  calculated. PrmWalk  Upon r e c i e v i n g  significant  display,  process  s e t p o i n t v a l u e , or  digit  delay  image i s r e l o a d e d , and  from.  WalkSetp  reached inner  while  viaa call  waiting  l o o p ; and t h e s i g n a l  elapsed  time  have d e l a y e d setpoint  of:  read  since last  to restart  service  on t h e a c t u a l  than  elapsed  time  WaitTick.  When M i c r o S p u t  execution  parameter  i s most  likely  processes  for.  The i n n e r  processes  by a c a l l  t o complete  t h e new  t o the  out the process  to begin  may  delay  process  or t o r e s t a r t ,  or d i s a b l e a  t e r m i n a t i n g the r u n . U n f o r t u n a t e l y , the  UCSD p - S y s t e m has been d e s i g n e d unit's  e x e c u t e s an  i s h a l t e d , the WalkSetp  be w a i t i n g on i t s s i g n a l  walk b e f o r e  process  required); calculate  again c a l l i n g  the operator  procedure  (higher p r i o r i t y  time,  since  the process  t h e s y s t e m c l o c k and c a l c u l a t e t h e  PrmPoint; and wait  probably  MicroSput  i s waited  Parameter procedure  will  t o begin  and t h e s e t p o i n t has n o t  the walking  WalkSetp longer  based  and w h i l e  t o the Schedule  i s enabled  t h e end of i t s walk,  loop consists  signal,  for a signal  e x e c u t i o n , WalkSetp l o o p s as f o l l o w s : i s waited  that  waits  continues  WaitTick;  recieving  initially  Upon  time  time  that step size i s  walking.  delay  t o be t h e  on t h e p a r a m e t e r  range w i t h screen  command, i f  i s chosen  and the p r o c e s s  The p r e v i o u s l y a c t i v e  i n c r e a s i n g or  the e x i t  step size  the s p e c i f i e d  i s returned  The  a t the present  the walking  of the least  towards  must c o m p l e t e  so t h a t a l l o f a c o m p i l a t i o n their  execution  before  the u n i t ' s  39  halting  code w i l l  variable  this  the  Most u n i t s u s i n g  supply  rather  each  boolean  than  semaphore  after  internal  wait,  the running  a g l o b a l running  a h a l t i n g procedure  program's end.  a global  a c t u a l program t e r m i n a t i o n .  u n i t Schedule d e c l a r e s  purpose.  Walker,  before  semaphores must be s i g n a l l e d  i s r e s e t but b e f o r e  MicroSput  i s running  i t s r u n must be c h e c k e d  a l l system  boolean  T h i s means t h a t  s p e c i f y i n g that MicroSput  terminating and  be e x e c u t e d .  The  variable for  semaphores, i n c l u d i n g  t o s i g n a l t h e semaphores a t  The p r o c e d u r e wkHalt  i s provided  for this  reason. As adding their to  mentioned at the beginning t o and a l t e r i n g  information  the parameter  servicing Strtlnfo to  records list,  process.  new p a r a m e t e r  uti1:system.param, program a l l o w s record  i s needed.  edit  the c a s e ) ,  name, s t a c k  information execute  the operator  wants t o add  and w r i t e t h e  the process  one must a l s o e d i t size  using  that  and p r i o r i t y .  unit  To add  t o the f i l e util:patchparam.  to create  e n t r i e s and, f o r each e x i s t i n g  programmed name, whether  Sputter  to start  record  the f i l e  a method f o r  p a r a m e t e r s and  I f one s i m p l y  If i t i s desired  the process  chapter,  of M i c r o S p u t  one need o n l y  (as i s normally  include  the  the l i s t  of t h i s  or d e s t r o y file  information  entry,  or not the parameter  This  t o change t h e  i s m e a s u r e d , and  whether o r n o t i t i s t o be c o n t r o l l e d . If is  the a c t u a l s t r u c t u r e of a parameter  t o be c h a n g e d ,  This  program  then  the f i l e  uti1:fmtparam w i l l  i s e d i t e d once t h e new r e c o r d  It  reads the data  it  according  information  from t h e o l d f i l e  be o f u s e .  structure  util:system.param,  t o t h e new s t r u c t u r e p r o v i d e d  record  i s known. reformats  by t h e programmer,  and  w r i t e s the  system file,  filer e.g.  new  can  be  data used  records  file  course,  i f the parameter  edited their latter  then  to  form  can  be  must be  the  sure  records  The backup  to  t o remove t h e o l d  i s working  properly.  Of  information record structure i s level  t o the M i c r o S p u t done by  new  not  the e d i t e d system  a l l parameter  librarian  utilrnewsystem.param.  and  and  i n c o r p o r a t e the changes,  new  codefile  until  One  file  t o change t h e o l d r e c o r d s t o a  util:oldsystem.param  util:system.param.  changed,  to the  executing  u n i t s must  recompiled,  file, the  higher  returned in  microsput.code.  file  s u p p l i e d as p a r t of  and  be  The  util:library.code,  t h e UCSD p - S y s t e m .  the  41  CHAPTER Data  The filing  Filing  FIVE  and  Plotting  o n l y t y p e of d a t a M i c r o S p u t  and  displaying  or more of  is currently  a r e t h e e l a p s e d time  the parameter  Development  Cruncher,  i n w h i c h t h e o p e r a t o r c o u l d w r i t e h i s own  functions  of the parameter into MicroSput,  t o t h e o p e r a t o r as p o s s i b l e idea  proved  analysis  two  axes  to p r i n t include  though,  soon  t o be  or to i n v e r t  existing  axis  without  writing  o t h e r needs g e n e r a l l y forward  'hidden'  filing  MicroSput  now  analysis,  o t h e r than  elapsed  and  i n use  t i m e , must be  plotting  d o e s not  the p l o t t i n g done by  user  line  was  the  select  satisfy  often  a need  v a l u e s , to  version  a Cruncher  written  an  function.  o n l y by  of parameter  axes  l o g a r i t h m of  corrupting  s t a n d a r d than The  This  data  r o u t i n e s t o the  non  units.  include  on  a whole new  Cruncher  available  c o n s t a n t s i n the  c o u l d be met  unit  plot.  enough t o  or take  where t h e y were much more complex and the  This  to simply  There  chosen  of  somewhat  the parameter  calculations,  straight  not  experiment.  or more i n t e r a c t i v e l y  the o r i g i n a l l y  Perhaps  of C r u n c h e r  function  T h e s e and  list  elapsed time.  e x t e n s i o n of t h e  found  one  compilation unit  a x e s c h o i c e s f o r t h e x-y  some or a l l of  function  and  i t s f u n c t i o n s were made  the p r o v i s i o n  needs of e v e r y  r e c o r d s of one  and  of M i c r o S p u t .  f u n c t i o n s was  the e d i t i n g  v a l u e s and  t o be a v e r y u s e f u l  capabilities  inevitably,  editable  of  v e r s i o n s of  had  linked  a user  ( i n seconds)  MicroSput  was  included  values.  capable  point those in  of  module.  values  Data  and  programs a f t e r  the  42  MicroSput  experiment  documentation filing  and  in be  be  with  the  sufficient  the  r o u t i n e s themselves,  former  longer  term  MicroSput  a truly  perform  line  to e d i t  and on  programs.  on  concept  spectrometer just  may  of M i c r o S p u t  d e v i c e s w h i c h do  parameter  a  few  attempt  standard  ( s u c h as  spectral  to handle value  eight  data  the  therefore line  data  It i s also  data  will analysis  hoped t h a t  manipulation  t o skew  can  done d u r i n g  from  this  writing  one  space  up  one  method  file  new  disk drive  will  be  The  p-System  files  will  saved  than  also  new  will  will  I f so,  present data  limit  in a l l f i l e s ,  One of  aware t h a t a  to three  quarters  no M i c r o S p u t  one  file  processing  i s open f o r the  new  every One  files  needed.  available  hence r a p i d l y  i s open a t any  added w i t h  and  intensity  problems.  ( t h i s p r o b l e m does not  is six drives.  be  the  A l s o , t h e p-System method of  a method of c o r r e l a t i n g  probably  be  to e v e n t u a l l y d i v i d e  disk  s t o r e a l l the  optical  independently  one'should  to another;  analysis  the g e n e r a l i z e d  determining  equipment  wait.  size  per  case,  other  into  l o g g i n g and  of a mass or  i n t o many s m a l l a r e a s ,  file  any  use  when more t h a n  write  efficiently  the  file  d i s k tends  t h e maximum d a t a only  the  one  d i s k space  disk  f i t readily  lines)  data.  allocating on  to i n c l u d e data  i n c h f l o p p y d i s k r e q u i r e s up  second be  not  f o r purposes  the parameter  be  f o r the user  this  developed.  from  In  I t i s hoped t h a t  a b l e t o more f u l l y  Expansion  of  be  plotting  eventually than  will  i s complete.  on  new may  a method of  occur  instant).  be  able  a large,  device.  to  fast  from  when Perhaps a  MicroSput  the d a t a  Perhaps  decreasing  hard  the  the e l a p s e d interpolating  disk.  various  time data  would from  43  some o f t h e f i l e s written. the  A completely  data  single  attempted  type  different  s a v i n g and p l o t t i n g  data  process  t o match up w i t h  file  wishing  a l l types.  i s the unit  name  a one b y t e  included  t h e keyword, a one b y t e  out  data  (size  when r e a d i n g  associated  name  keyword.  Data  words o f i t ) . the f i l e  i t s effectiveness  compatabi1ity  a r e concerned,  bulky  and c o m p l i c a t e d  considering  non-standard The  unit  The PDAT f i l e  list the  reading get  and f i n a l l y t h e  testing  insofar  were s o r t e d  of t h e D a t a L o g  a s speed  and d a t a  was c o n s i d e r e d t o be t o o version,  i s supported  t o the problem  and f i n a l l y  MicroSput  by i t .  No  of d i s p l a y i n g  filing.  the data  string[8])  integration records.  a PDAT f i l e  o r p u t t h e name l i s t  of s a v e d  ended by t h e empty time  i n seconds  A PDAT d a t a  of t h e e l a p s e d  o f e a c h named p a r a m e t e r .  A l l data  them a s p a r a m e t e r  s t r u c t u r e i s headed by a l i s t  values consisting  and w r i t i n g  data  '.PDAT' t o d i s t i n g u i s h  f o l l o w e d by t h e d a t a  value  then  t o t h e keyword and  equipment  names ( i . e . o f t y p e  of r e a l  was  was w r i t t e n a s a r e c o r d w h i c h  the u n i t  ParamSave h a n d l e s  data.  real),  the r e c o r d type  data.  have t h e s u f f i x  (''),  Each  wrote a r e c o r d  The r e c o r d t y p e s  has y e t been g i v e n  files  parameter  first  f o r the c u r r e n t MicroSput  no n o n - s t a n d a r d  consideration  file  Although  module p r o v e d  T h i s a p p r o a c h was  record size,  according  identifier.  so t h a t a  DataLog) but unused.  i n the f i l e ;  assigned  actual  t h e o t h e r s would be  a p p r o a c h would be t o r e w r i t e  t o use the DataLog  identifying  from  p o r t i o n s of M i c r o S p u t  would h a n d l e  (the r e s u l t  that  name  (type  record i s a  time  f o l l o w e d by  The a d v i s e d method o f  i s to declare a f i l e  v i a an a r r a y [ l . . 3 ] o f r e a l  of r e a l s , typed  buffer  44  using  t h e p-System  integration  intrinsic  value  once p e r d a t a  of  valid  bytes  these the If  three  o r more u n u s e d  a PDAT f i l e  record  halting failure)  this  fatal  write  file  will  will  Writing  i s recommended i f  of r e a l s ,  become  the f i l e  Patch.  boolean  t r u e when t h e l a s t  occur,  recovery  n o t be d e t e c t e d  PDAT f i l e  without  directory  entry  the system  filer.  Use t h e f i l e r  the  file  existance  the  m i x e d A S C I I / h e x mode).  by v i e w i n g  (other  Reboot t h e  than  i t sdirectory)  'make' command  Exit  to create a  This w i l l  create a  f i l e ' s block  The p a r a m e t e r  to the f i l e ;  name l i s t  of the block.  viewing  space, the  the f i l e r .  c a n now be used  t h e new  appear a t the b e g i n n i n g  the  Do n o t p e r f o r m any  lies.  t h e p-System p r o g r a m P a t c h  Should  be r e t r i e v e d i f  i n t h e l a r g e s t empty d i s k file  file  directory.  will  specifying i t s length.  desired,  was w r i t t e n  a s a power  followed.  t o the disk  same s p a c e where t h e l o s t  (such  i n the disk  i s exactly  for a f i l e  a MicroSput run,  and t h e w r i t e  most o f t h e d a t a  method  or move f i l e s a b o u t .  during  i n some i n s t a n c e s  commands w h i c h may w r i t e  data  space  buffer.  be s a f e l y c l o s e d by t h e ParamSave  n o t be e n t e r e d  p - S y s t e m and e n t e r  clearly  array  characters),  t h e p-System p r o g r a m  error occurs will  However,  misfortune  following  real  eight  number  read.  the e r r o r w i l l  information  i n each  read_data  The maximum  (one l e n g t h ,  i s t r e a t e d as a f i l e  a detected  code.  parameter  or w r i t e .  a s t h e ASCII  e o f (end o f f i l e )  existing  read  t o be v i e w e d u s i n g  h a s been  If any  characters  i s ever  intrinsic  record  p e r name i s n i n e  trailing  file  get or put the  t i m e , and g e t o r p u t e a c h l i s t e d  or  leaving  moveleft,  If  to confirm zero  (using  should  No f u r t h e r ASCII  each block  successively,  45  one  can determine  noting  the f i r s t  will, file  t h e maximum p o s s i b l e e x t e n t block  i n which  however, n o t n e c e s s a r i l y  sensible strings be t h e a c t u a l  by  appear.  last  block  This of t h e  a s non-ASCII d a t a may have been p r e v i o u s l y w r i t t e n t o t h e  disk.  I f Patch  length,  i s used  the system  remake t h e f i l e , plot  some d a t a  either  before  plotted.  will  system  filer  length. buffer  to find  filer  from  betray  t h e new l e n g t h .  the f i l e ,  or a f t e r  t h e maximum p o s s i b l e  counting  i t i s evident  clicks  the a c t u a l  t h a t garbage block,  remove and make commands t o c o r r e c t  when t h e s y s t e m c r a s h e d  i n the f i l e ' s  will  at  128 r e a l  saved The  (plus,  unit  param_time,  numbers, o r i n t h e c a s e as always,  param_time  i s the l a t e s t  elapsed  file.  ParamFile  files,  selects  single  or m u l t i p l e r e c o r d s a v i n g .  saving reads  interactively file  the read  file  and d i s p l a y i n g  block  physically amount t o  records. real  and p f H a l t . time  variable,  read  The v a r i a b l e  from  the data  read  opens and c l o s e s r e a d a n d w r i t e parameters,  integration  In the l a t t e r  of r e c o r d s a v i n g can a l s o  c a n be i n t e r a c t i v e l y  unfilled  r o u t i n e s , f u n c t i o n ParamGet and  ParamReset, P a r a m F i l e ,  periodicity  Use t h e  o f o n l y one p a r a m e t e r  time'), 64 d a t a  procedures  the write  i s being  This w i l l  ParamSave d e c l a r e s one g l o b a l  and f o u r g l o b a l  clicks  the f i l e  n o t have been  t o t h e d i s k and i s i r r e t r i e v a b l e .  and  so t h e c o u n t e d  l e n g t h of the f i l e .  written  being  Run M i c r o S p u t ,  the disk d r i v e  once p e r f i l e  U n f o r t u n a t e l y , a l l data  most  file  remove and make commands c a n be used t o  specifying  The d r i v e  clicks  list  of the f i l e  be s e t .  mode, t h e  Write  d i s a b l e d and e n a b l e d .  header, determining the read data  the read  integration  t i m e , and  file  data  ParamReset file  time.  parameter ParamGet i s  46  called  t o read  read_data  one d a t a  internal  end,  i n t o the read  v a r i a b l e s , but r e t u r n s  been e n c o u n t e r e d . all  record  after  false  file  i f an end o f f i l e has  The p r o c e d u r e p f H a l t , l i k e  semaphores once and must  parameters'  wkHalt, s i g n a l s  be c a l l e d  a t t h e program  the g l o b a l Schedule boolean v a r i a b l e running  has been  reset. The operator file  procedure ParamFile  repeatedly  with  informs  a string  enable/disable  mode.  F(iles  enable/disable save mode,  single  E(xit'. status,  record  the ParamFile saving  Further  s i n g l e records  record  the write  data  the s i n g l e / m u l t i p l e record  Toggling  which  PrmFile,  from m u l t i p l e t o the data  i t will  c a n be w r i t t e n  automatically  save  'S(tatus  t o t h e segment p r o c e d u r e  loop.  after  as  write  writing  be d i s a b l e d .  by e n a b l i n g  data  be d i s a b l e d a f t e r  writing  each  record  saved). The  data  (it will  'S' t o g g l e s  a u t o m a t i c a l l y -enables  f o r one r e c o r d ,  i s  Typing  'L' t o g g l e s  process  each time  are a l s o presented  'F' p r o d u c e s a c a l l  'E' e x i t s  him o f t h e c u r r e n t  s t a t u s and s i n g l e o r m u l t i p l e  The command c h o i c e s  L(ogging  and  which  loops,.prompting the  segment p r o c e d u r e  read  and w r i t e  file  data  Relative  t o RAM and s i m p l e  consists between  i n t e g r a t i o n t i m e , and d a t a  often  take  of w a i t i n g tracks.  when p e r f o r m i n g inadvertantly  interactively  input/output  save c y c l e port  time.  operations,  disk  a l a r g e amount o f c p u t i m e , most of w h i c h  f o r the disk  to revolve  O p e n i n g and c l o s i n g o f d i s k checking  removed,  chooses the  names, s e l e c t s t h e p a r a m e t e r s f o r  writing,  operations  PrmFile  operations  o r t h e head t o skew files,  especially  t o e n s u r e no d a t a  i s t h u s a slow  operation.  f i l e s are  In o r d e r  that  47  execution by  of important  PrmFile  are  operations, c a l l s  s p r i n k l e d throughout  disk  operation.  Polllnputs,  called.  execute  to run):  determine  original  TaskSwitch  The  a signal  first  read  image d a t a read  further  PrmFile  the  ensuing  current  image  a file  CheckError every  priority  i s then  routine  call  (and t h e r e f o r e a l l o w  exited.  n o t be  other  i s checked  i f so, the The P r m F i l e  individually  file  areas. or w r i t e  wishes  name e x i t s file with  remaining  to their  file  times,  respective  t o choose  or t o escape interaction  from  case,  and answers depends on t h e  the a check Once a f i l e  for.  the read  interaction,  (see F i g .  and c y c l e  i s asked  and t h e o p e r a t o r  i tclosed.  file  a r e sent  In e i t h e r  of q u e s t i o n s  name i s prompted  respective  lists  file  i s open a l r e a d y ,  i s to write the  integration  The o p e r a t o r  operations.  series  procedure  'paramsav' t o t h e s c r e e n  and w r i t e  file  specified  will  files,  s t a t e of t h e f i l e s  operator  a l l higher  function ErrorNoted  j o b of t h e P r m F i l e  between  If  calls  every  i n the f o l l o w i n g d i s c u s s i o n .  parameter  screen  or wait  i s immediately  The names o f any open  and  procedure  after  procedure  e r r o r has been d e t e c t e d ;  call  b a c k g r o u n d VDT s c r e e n 6).  from u n t i l  affected  TaskSwitch  one c a l l  the Schedule  the ErrMessg  and C h e c k E r r o r  mentioned  procedure  i s required after  i f a fatal  ParamFile  i s not o v e r l y  including  calls  The l o c a l  T h i s procedure  processes  PrmFile,  i s not r e t u r n e d  i s done.  which might  processes  of the l o c a l  TaskSwitch  which  processing  to  control  supplied  responses.  i s made t o e n s u r e t h e has been c l o s e d , a new  P r e s s i n g t h e r e t u r n key i n l i e u  or w r i t e closed.  file  interaction  I f a new w r i t e  t h e same name a s an e x i s t i n g  file  of a  with the file is  on t h e d i s k ,  Filestatus: W(rite R(ead <esc> Write F i l e s t a t u s : P(arameter l i s t @  C(ycle  time  write  Write  file  file  name: integration  parameters  time read  information  name: save c y c l e time: i n t e g r a t i o n time:  Read  I(ntegrate  seconds seconds  information  time:  Figure  seconds  6.  Parameter  filing  screen  image  'paramsav'.  Q(uit parameters  49  the  operator  must v e r i f y  a nonsensical write  file  a p r o b l e m w h i c h might Specification pressing  read  t h e r e t u r n key o n l y .  by  the former, case,  without  the read  are read  interaction set  name c a n c a u s e a d e t e c t e d  of a n o n e x i s t a n t  t h a t o f an open w r i t e  time  i t i s t o be d e s t r o y e d .  be w o r t h c o r r e c t i n g  as  either  that  Supplying  file  results  interrupting file's  case,  the l o c a l file  procedure  prompted  to select  multiple  r e c o r d save c y c l e t i m e ,  two  selection  enter zero times  to  the i n t e g r a t i o n  (the l a t t e r  time  time  pressed.  screen. editing. operator  E a c h change  list  PrmPrmpt  The o u t e r types  required to times  between  only c y c l e be when t h e  selection, return with  second  repeated a pointer  i s not a l r e a d y  list  key was  i n the  i n the l i s t ,  i s recorded  command.  loop continues I f ,at this  it  on t h e  the end of w r i t e parameter  EditWStatus  the q u i t  In t h e  or n i l i f the escape  t o parameter  flags  time,  i n t e g e r of one s i x t i e t h  i n the parameter  The n i l p o i n t e r  i s repeatedly  integer overflow  i t i s incorporated i n ; i f i t i s already  removed.  i s c a l l e d to  and 546 s e c o n d s w i l l  s e l e c t e d parameter,  I f the pointed  file  EditWStatus.  i s simply  In  integration  integration  integration  i s to avoid  t o the Parameter procedure  list,  be a c c e p t e d ;  In t h e w r i t e p a r a m e t e r  the operator  list,  limit  will  name  read  In t h e w r i t e  or t o q u i t  Only  i s s t o r e d as a signed  resolution). calls  i n seconds.  being  and d a t a  The o p e r a t o r  the operator  s e c o n d s and t h e c y c l e time  accepted cycle  cases,  t h e new t i m e ,  between  list  file  write process.  EditWStatus  the w r i t e parameter  future.  t h e same r e a d  i n the l a t t e r  parameter  error,  h a s t h e same r e s u l t a s  the data  information.  fatal  i n t h e near  from t h e d i s k and d i s p l a y e d .  up t h e w r i t e  time  file  Specifying  list  u n t i l the point, the write  is  50  parameter closed.  list  i s empty, t h e  Otherwise,  t h e new  a r e w r i t t e n t o the signalled  t h a t a new  does not  actually  been e n a b l e d . between  new  file  latter  case,  and  PrmFile  operator  by  started  the  called  by from  the  initializes  status  (nil),  r e a d and  is  as  follows.  either  with  as,  but  not  conditions executed,  to exit  time  ParamPut.  t h e ParamPut  waits  code.  MicroSput  file  continue completing  data  and  to run,  i s executed  enabled;  c o n d i t i o n s are  to remain the  the  the parameter  w r i t e s them t o t h e d i s k .  outer  value  and  true.  write  file  ParamPut  has  loops for  being  While  opened  as  soon  the  inner loop i s  loop.  The  execution  I f the c y c l e  Strtlnfo  is exited  true, a longer  ParamPut  integration  which w a i t s  loop  the  priority.  a s s o c i a t e d with write f i l e  being  as  pointers  procedure  size  also  such  list  t h a t a new  continues  inner loop  signals  stack  is  in turn i s  PDatStrt  and  Starter  for a signal  In  the  This process  P D a t S t r t , which  The  choose  are w r i t t e n to  states (closed),  second).  has  image i s r e l o a d e d ,  w r i t e parameter  one  writing  call.  initialization  file  is  PrmFile.  r e a d and  write  time  process  to  (false),  b e f o r e , both  loop determines and  process  data  ParamSav v a r i a b l e s  A short  write  saving  internal  While  or b o t h  and  elapsed  file  saving process  allowed  or  and  integration  of  initially  been o p e n e d .  data  screen  ParamFile  and  segment  to determine  ParamPut  The  i s once a g a i n  the  ParamSav  (arbitrarily  used  and  the d a t a  interaction,  data  a number  enabled  time  and  segment p r o c e d u r e  the  list  the p r e v i o u s l y a c t i v e  Parameter value  i s aborted  s a v i n g u n l e s s or u n t i l  r e t u r n s from  .PDAT f i l e  file  i s ready.  r e a d or w r i t e f i l e  the  writing  parameter  write  begin  The  data  time  second time  inner  averages  i s greater  than  51  the  integration  called  TimSubTO  integration,  t o determine  reading  copied  case  data  read_data  measured  integrated present write  value  file  case,  available.  greater  than  the d i f f e r e n c e , The  procedure  opened d a t a record.  read  but only  time,  of  the write  file  has been  i s transferred  procedure  CopyWtoR.  WaitTick  t o rewind  s e l e c t e d , a copy file  t h a t new d a t a  cycle  i s called  to prepare  starting  data  from t h e  time i s t o wait  i n n e r ParamPut  i f the f i l e  Once r e s e t ,  Otherwise, the  s a v i n g mode h a s been  I f t h e save  i s used  t o the read  list is  information  i s signalled  t h e second  f o r reading,  i s also  (and, f o r the  In t h e r e a d d a t a  i s disabled.  responds  value  I f so, the corresponding  r e c o r d data  ParamReset may be c a l l e d  any t i m e ,  buffer  i s used.  ParamReset  at  t h a t time  i s s c a l e d and w r i t t e n .  completing  file  i s w r i t t e n t o the f i l e .  t o whether o r n o t t h e v a l u e  inputs.  the i n t e g r a t i o n  are again  f o r a l l channels,  t o the parameter  t h e ParamGet p r o c e s s  writing  i s called to  The w r i t e p a r a m e t e r  according  I f the s i n g l e  data  of the input  w r i t t e n to the f i l e  file,  the analog  channel  time  i s enabled,  being  parameter value  selected,  out  from  The C l o c k  c l o c k reading during the  input averages  file  fields)  WaitTick  offset  elapsed  of r e a d i n g the w r i t e  record  procedure  param_time.  values  sums.  TimSubTO and A n a l n S t a t u s  The a v e r a g e  to the global  traversed,  integration  the average  of t h e w r i t e  AnalnStatus i s  t o record the s t a r t  and t h e a n a l o g  respectively.  is  i s called  and t h e S c h e d u l e  integration,  is  input  out the i n t e g r a t i o n .  called  If  the El2AnaIO procedure  t o dump t h e a n a l o g  procedure  wait  time,  loop.  an a l r e a d y  at the f i r s t the data i s open.  data  read  file  I f reading  of the w r i t e  file  b u f f e r by t h e l o c a l c a n be r e a d  from  this  52  copied the  read  file  copy made; end o f f i l e  t h o u g h new d a t a In  o n l y up t o t h e l a s t  any c a s e ,  the data  and r e a d d a t a  data  number  The file  and  read  integration  the P a s c a l standard  fields.  and ParamGet  returned reading could  returned  from.  In t h i s  and c o p y i n g  the data  loading  t h e next  file  end has been  will  switching  file,  reached  be t r u e .  record i s loaded  I f new  fact i s has n o t  and ParamGet i s allowed  a s a ParamPut  while  execution  f o l l o w e d by t h e s w i t c h  Finally,  read  the f a l s e  I f t h e end o f f i l e  read  data  information  from.  ParamGet o v e r w r i t i n g t h e r e s t . a r e t u r n from  reset.  f o r reading, that  o v e r w r i t e p a r t of the data,  have c a u s e d  g e t on  loaded  no t a s k  real  get i n s t r u c t i o n ,  the r e s u l t  case,  parameter  The f i r s t  h a s n o t been e n a b l e d ,  t h e new r e a d d a t a  even  subsequenty.  and t h e r e a d p a r a m e t e r  file  point  and t h e r e a d  t o read  I f the read  h a s a l r e a d y been  reached,  this  are read.  implicit  i s returned; otherwise  write data  been  time  f u n c t i o n ParamGet a t t e m p t s  r e a d i n g of the data  noted  i s reset  i s p o i n t e d t o by one f u r t h e r  read_data  result  be t r u e beyond  file  r e c o r d i n t o param_time  record  point written before  may have been w r i t t e n t o t h e f i l e  list  mimicing  will  data  back t o  i f none o f t h e above  ParamGet, t h e new w r i t e d a t a  record  i s waited f o r .  Parameter v a l u e data compilation  module P l o t t e r .  explicitly  available:  and  the p l o t t i n g ,  starts  semaphore.  plotting  plotting  variable  running  two P l o t t e r  P l o t S e t u p , which  The p r o c e d u r e  internal  Only  i s performed  and p l H a l t plHalt  by t h e  routines are  interactively  which  s i g n a l s an  must be c a l l e d  s e t s up internal  t o shut  down t h e  process  after  the g l o b a l  Schedule  boolean  h a s been  reset  but b e f o r e  the program i s  53  actually  terminated.  PlotSetup the  segment  c o n s i s t s of  procedure  PlotSet.  segment  procedures  segment  procedures can  extra and is  dummy  non  key  pen  will  the  plot  to  The  b a c k g r o u n d VDT current  the  bounds of  the  screen  PlotSet  will  disabled the  while  operator  choosen either  as  arrow loop  keys is  the are  exited  plotting  procedure  plot  is  by  the  at  the  is  top  their  to  reading  the  entire  select by  which  pressing  or  'S'  is  passed the  PlotAxes  minimum  (send),  is  in new  called  a n d maximum  the  bound  the  (see  Fig.  units,  is  to  be  case  the  axes  draw  a  which  bounds,  the  The case  PlotUtil  rectangle  extents,  be  the  input.  which  to  can  bounds  case  in  data  is  and  key,  of  in  key,  time  escape  set  fields  allowing  plot  manual  and  plotting  loops,  file  of  size.  escape  the  data  In  x-y  plot  (elapsed  select  data.  the  Otherwise,  and  the  extension,  their  p r e s s e s the  keys  the  respective  parameters  arrow  these to  loaded  PlotSet  an  hand c o r n e r  parameters,  only),  of  is  so  VDT  physical  'plotset'-  to  allow  via  by  called,  the  made.  part,  calls  right  no c h a n g e s .  axes  by  call  not  available  MicroSput  set  operator  the  used to  PlotBounds  its  to  does  generated  PlotSet  axes  a  initializing  code  to  changes are  done,  by  the  line:  interface  globally  written  with  extent  procedure  for  the  change  PlotUtil plot  If  either  the  determined  to  image  are  exited  or  be  operator  abscissa  manually  in  made  time  screen  the  to  an  determining  no  be  UCSD p - S y s t e m  ASCII  moved up  the  image.  The  ScreenOps or  choices  the  programming  begins  only  first  be  enable  be  the  can  The  recorder  The  only  supplied unit  one  declared  PlotSet  and  ExtraScreenOps.  7).  be  variables;  standard,  p-System  to  routine.  escape  only  the around  ParamSave  Plotter:  X,  Y  (axis)  D(ata  or  <arrows>  Set  (  (bounds)  S(end  up a x e s & b o u n d s x-y plotter  <esc>  for  then  )  send  Figure  7.  Parameter  the  plotting  data  or  (  )  screen  escape  image  'plotset'.  UI  55  procedure plotting is  ParamReset i s enabled,  t o reset the data  and t h e i n t e r n a l  plotting  read  file,  process  PlotData  signalled. The  which  process  in turn  PlotData  i s called  PlotStrt  initializes  plotting  enabled  The  is called  status  size  PlotData  executes  to start  plotting,  until  ParamGet values  plotting  i s false,  by c a l l i n g  PlotLift.  plotting  and w a i t  and  a short delay, delay.  values,  code.  s u c h as t h e  and t h e a x e s p a r a m e t e r s i s called  t o look  and an i n n e r  t o run,  of a w a i t  loop.  (nil).  up t h e P l o t D a t a  continues  a loop c o n s i s t i n g  the chosen parameter  the P l o t U t i l procedures  These p r o c e d u r e s  same s h o r t  data  PlotStrt,  t o be  The i n n e r  loop  i s d i s a b l e d o r t h e ParamSave f u n c t i o n  position wait  initialization  While MicroSput  repeatedly  signalled cycles  (false)  Strtlnfo  and p r i o r i t y .  by. t h e p r o c e d u r e  by t h e P l o t t e r  some i n t e r n a l  S t a r t e r procedure  stack  i s started  move  for i t to halt, and l i f t  Plot,  read_data PlotDrop,  t h e pen t o t h e g i v e n  and  x and y  d r o p t h e pen o n t o t h e p a p e r t h e pen back up, w a i t i n g t h e  56  CHAPTER SIX E12  Analog/Digital  Input/Output I n t e r f a c e  Programming  Two l e v e l s of MicroSput subprogram modules are used to . operate the E12 a n a l o g / d i g i t a l input/output listings  i n Appendix D).  Multitasking  The E12 l e v e l  i n t e r f a c e (see  is self-reliant;  l e v e l uses the E12, m u l t i t a s k i n g ,  and general  levels.  A l l MicroSput programming using  specific  to the microcomputer system i n room 118D of the  Hennings B u i l d i n g at UBC, since only built.  The UBC Physics  versions  unit  the E12 i n t e r f a c e i s  one such i n t e r f a c e was  E l e c t r o n i c s Lab now uses a decendant of  the El 2 i n t e r f a c e , c a l l e d the Phys 44 bus, f o r general electronics  the E12  interfacing.  To a v o i d  of MicroSput w i l l  built  purpose  i n obsolecence,  use commercially  future  available  i n t e r f a c i n g equipment which adheres to the S100 microcomputer bus  standard, the RS232 s e r i a l communication standard, or the  GPIB p a r a l l e l communication standard wherever p o s s i b l e .  The  Phys 44 bus w i l l be used when no a c c e p t a b l e commercial equipment can  be o b t a i n e d . The  E12 i n t e r f a c e i n c l u d e s :  c l o c k ; eight  a s i x t y Hertz t h i r t y - t w o b i t  o p t o - i s o l a t e d TTL i n p u t s ; eight o p t o - i s o l a t e d TTL  outputs; one s i x t e e n channel m u l t i p l e x e d  b i p o l a r s i n g l e ended  i n t e g r a t i n g analog input with one t h i r t i e t h time, one m i l l i v o l t overscale, unipolar  second  r e s o l u t i o n , ten v o l t f u l l  and an input  conversion  s c a l e , twelve v o l t  impedence of 180 kiloohms; eight  s i n g l e ended analog outputs with ten v o l t f u l l  i n t o a high  impedance load or f i v e v o l t f u l l  scale  scale into a f i f t y  57  ohm l o a d ,  four  of w h i c h have e i g h t  1...4), and f o u r 5...8).  i n assembler.  interrupt  neither made as the as  i n t h e E12 s t a n d  alone  The u n i t E12ISR c o n t a i n s  servicing; since  directly  (outputs  o f w h i c h have t w e l v e b i t r e s o l u t i o n  A l l of the r o u t i n e s  written  b i t resolution  calls  by t h e c p u r a t h e r  (outputs modules a r e  a l l the  t o E12ISR r o u t i n e s  a r e made  t h a n v i a t h e p - S y s t e m , E12ISR may  be o v e r l a i d n o r moved a b o u t  i n RAM.  This  rigidity is  known t o t h e p - S y s t e m by d e c l a r i n g t h e a s s e m b l e r  .PROC and .FUNC. relocatable  The modules E l 2 D i g I O and E l 2 A n a I 0  contain  ( i . e . s w a p p a b l e and moveable) r o u t i n e s  .RELPROC and .RELFUNC) w h i c h  interrupt  routines  s e r v i c i n g to provide  i n t e r a c t with full  stand  (declared  and complement t h e  alone  operation  of t h e  E1 2 i n t e r f a c e . Because c o m p i l a t i o n  units are, in general;  memory management of t h e p-System, a s s e m b l e r module a r e n o t c a p a b l e Interdependent together areas,  assembler  lifetime.  position  locked  included  as g l o b a l data.  utility  (performed El2DigI0 boolean  by k e e p i n g  which c o n t a i n s  routines.  Global  routines  The f i r s t  routine) value  includes  unit.  in another.  Global  data  c a n , t h e r e f o r e , be i n other  memory and  those addresses  declared  needed  by an i n t e r r u p t s e r v i c e  i n one  t o be l i n k e d  for digital  routine  the current  in a table  v a r i a b l e i n E12ISR  jumps t o a number o f  data  t o the  i n p o s i t i o n throughout a  of r o u t i n e s  units only  routines  those  a r e meant  compilation  Assembler  of the a d d r e s s e s  jumptabl,  calling  hand, a r e f i x e d  informed  is  routines  i n t o t h e same h o s t  on t h e o t h e r  program  of d i r e c t l y  subject  internal output  pulsing  but c o n t r o l l e d by an  digital  output  t o i n d i c a t e whether o r n o t a p u l s e  word, a  i s a c t i v e , the  58  time  at which to p a s s i v a t e the  passivation, E12  digital  Global by  an  a mask s p e c i f y i n g  routines operate  though o n l y expansion  and  to sixteen b i t s  data  needed  interrupt  input  values  calculation, differs value  negated  declared to the  f o r an  a boolean read.  routine, InitE12isr, v a r i a b l e and  board. and  a programmable  a count  count  will  sixtieth control motors. maximum  of up  has  interval  second the The  gas  later.  of  timer  count.  pulse  by r e c o r d of  those  change  been r e a d  i n the the  and  the  the  the  input  set  channel  input value  only  addresses  timer of  on  the  sixty-four the  one  of  the  two  by  the  timer  TTL  microseconds with  output sixty  a  full  one pulses  to  Hertz  ac  therefore corresponds  In o r d e r  to get  is  Cromemco TU-ART  approximately  uses the  is  a c t u a l jump t a b l e  l e a k v a l v e s , w h i c h a r e d r i v e n by  minimum u s e a b l e  interval  f o r use  interrupt  MicroSput  read  a maximum e r r o r ,  Programming  t h e r e f o r e c a u s e an  has  performed  s e r v i c e routine, DigServ,  a resolution  t o 255.  that  locations specified  pulsing interrupt  T h i s timer  value  indicating  copies  hardware.  by  word, even  packed  r a t e of  which c o p i e s  interrupt  serviced  count  the  performed.  and  E12ISR c o n t a i n s  s e r v i c e r o u t i n e s to the  digital  be  controlled  input  the  interrupt  The  easily  a priority  upon b e i n g  jumptabl  i / o may  by more t h a n  scheme, and  pulsed.  i n order  readings,  indicating  maximum e r r o r ,  being  input m u l t i p l e x i n g (also  of p a s t  necessary  boolean  multiplexing t o be  sum  of  available,  includes a s i x t e e n channel  from a s e t v a l u e  and  are  value  a sixteen b i t d i g i t a l  of TTL  for analog  the d i g i t a l  which b i t s  s e r v i c e r o u t i n e but  reading,  readings,  on  e i g h t are p h y s i c a l l y  El2AnaI0 procedures) the  pulse,  longer  to  the  pulses,  59  one  can  not  times: be  simply  restart  the  timer  some computer a c t i v i t i e s ,  performed  cumulative  by  periodically  effect  of  these  a p u l s e much l o n g e r beyond t h e i r  than  a predetermined  such  specified,  intended p o s i t i o n .  a l l interrupts.  length errors w i l l and  may  DigServ  drive  error  The  unit  i s not  to the d i g i t a l  p u l s i n g and  routines.  type  zero through  set  the c o r r e s p o n d i n g  procedures digital bits  specified  (but  not  later. pulse, calls  InitEl2isr  through low).  seven The  DigWrites By to  over  high  the  f a r the  the  code w a i t s  the  s e t of  i s a member of  new  The  b i t i s high.  DigWrite  of t h e values  and  d e v i c e s are  changes  the the  written values a specified  E12DigI0  bits  assumed t o use and  time  in a  code of  DigWrites  f o r p u l s i n g t o end  The  DigPulse  remaining  initialization  jump t a b l e  the  c u r r e n t s t a t e s of  l e n g t h of t i m e  p o r t i o n of E12  the m u l t i p l e x e d a n a l o g  r o u t i n e AnaServ by  the  access  zero active  again  high.  largest  a l l channels  long  i/o operating  supplied values.  r e w r i t e s the  (controlled  outputs  read  t h e complement  seconds.  t o copy  halting  servicing  service  takes  r e t u r n s the  in s i x t i e t h  digital  respectively.  i n a mask t o the  DigPStat  in  the v a l v e s f a r  programming  i n p u t or o u t p u t  DigStatus  t h e mask), and  E12  level  i f a number  TTL  outputs,  performs a DigWrite,  result  so t h e d i s a b l e d  i s d e c l a r e d t o be  fifteen;  D i g R e a d and  i n p u t s and  other  digital  integers then  The  cumulative.  El2DigI0 provides higher  The  only  instead terminates  p u l s e s a c c o r d i n g t o a hardware c l o c k r e a d i n g , interrupt  of  as d i s k a c c e s s , can  disabling  subpulse  number  ensures  keeping  programming  input.  The  i s dedicated  interrupt  t h e maximum p o s s i b l e d a t a  the a n a l o g  input c o n s t a n t l y  rate  60  converting  and m u l t i p l e x i n g  specified  priorities.  priority  Each c h a n n e l  between z e r o and e i g h t  channel  numbers,  starting  is  repeated throughout  an  internal  restarted is  counter  at channel  the MicroSput  times.  sweep, p r i o r i t y  every  fourth  every  128th sweep.  A sweep o f i n p u t  sixteen run.  and e n d i n g  Each  a t 128.  zero.  sweep, e t c . t h r o u g h  sweep d e c r e m e n t s  or not a channel  two d i v i d e s  Thus a l l p r i o r i t y one e v e r y  second  evenly  into  zero channels are  sweep, p r i o r i t y  to p r i o r i t y  Channels with p r i o r i t y  a t one,  The c o u n t e r i s  Whether  sweep depends on whether  the c o u n t e r p r i o r i t y every  inclusive.  i t reaches  a c c o r d i n g t o user  i s assigned a multiplex  by one, s t a r t i n g  a t 128 when  r e a d on t h a t  read  the input channels  seven  channels  of e i g h t  two read  a r e never  read. Like DigServ, timer  t o generate  second. will  that  trigger  interrupts  except  every  data  the input value  rate  point  i s read.  i s a c h i e v e d , t h e next  The t i m e  service  routines.  with the p r e v i o u s l y  record f o r the channel  r e c o r d can then  be s p e c i f i e d  address  just  read.  by s i m p l y  channel to  just  i s taken; a l l  itself  The i n d e x  calculated  To  i s r e a d and s a v e d  f o r the channel  interrupt  sixtieth  the channel i s  a l l necessary data  the AnaServ  one  interval  (as i t g e n e r a l l y  AnaServ m a n i p u l a t i o n s can proceed  interrupt  information the  test),  o f change c a l c u l a t i o n s  At t h i s  further  loaded  second  and c o n v e r t e r i s t r i g g e r e d .  triggered.  other  approximately  have a l r e a d y been c a l c u l a t e d ;  use i n r a t e  that  an i n t e r r u p t  a maximum  will  selected for  u s e s a TU-ART programmable  I f an i n p u t c o n v e r s i o n h a s c o m p l e t e d  have e v e r y  insure  AnaServ  a r e e n a b l e d so without  register  affecting IX i s  of the channel Data  fields in  s u p p l y i n g the o f f s e t  "61  from t h e IX v a l u e , manipulated between than  allowing a l l channel  u s i n g t h e same a s s e m b l e r  this  and a p r e v i o u s  the s p e c i f i e d  digital time  input  previous  decimal  the input  dropped. zero.  The l a t t e r  values  The new r e a d i n g  times  bytes,  reading  t h e maximum  i s converted  t h e sum c o u n t e r occurs,  b i t ) and t h e count  from t h e d r i f t  s u p p l i e d and a l l o w s t o be  overflow  the sign  immediately  i s subtracted  from  i n t o the  incremented.  before  The  the channel's  o f 12000 r e q u i r e s l e s s  i s s e t t o 128.  in resolution.  setpoint value,  drift.  I f the value  channel  information  Since  than  t h e sum d o e s .  from.  will  The a v e r a g e  The r e a d i n g absolute  compared  record  i s set.  interrupt  three If right  value  be u n a f f e c t e d e x c e p t f o r  value  i s then  t o t h e maximum  The next reenabled,  subtracted  of the d i f f e r e n c e  i s o u t o f bounds, t h e r e a d y  f o r , AnaServ  returned  coded  t h e sum i s d i v i d e d by two ( i . e . s h i f t e d  and t h e r e s u l t  prepared  12000 i s  to natural binary.  I t i s a l s o added  sum d i v i d e d by c o u n t ,  one b i t l o s s  taken,  i s saved.  a r e saved.  reading i s  from b i n a r y  i s t r u e , the value  will  one  calculation,  i s user  reading  latter  call  ( t h e maximum v a l i d  sum, a n d t h e sum c o u n t  the  is  time  i f true, the value  (e.g. cathode voltage)  I f the r e s u l t  three byte  is  i s l i m i t e d ) , the  and t h e c u r r e n t  ( a s s u p p l i e d by t h e c o n v e r t e r )  boolean.  interval  i s c a l c u l a t e d ; i f greater  i s checked;  f o r the reading  negative  the  The t i m e  s i g n b i t i s c h e c k e d and e x c l u s i v e o r ' d w i t h  invert  256  reading,  flag  11999); o t h e r w i s e  of  reading  t o be  minimum (a c o n d i t i o n needed t o e n s u r e t h e  overload  substituted  input  code.  e r r o r i n a r a t e o f change c a l c u l a t i o n  interval,  The  records  allowable b i t i n the  channel  conversion  and t h e i n t e r r u p t  62  The  p r e p a r a t i o n f o r next  follows.  The  number  of t h e c h a n n e l  decremented  by one.  substituted  and  the c h a n n e l  sweep c o u n t  has  been  number  of t i m e s two  according a one  I f the  result  divides  into  out.  The  comparison  priority  of t h e c h a n n e l  the  calculation  resulting  i s compared  the c h a n n e l  i s redone.  One  128  sixteen  sweep c o u n t be  power o f two  right  i s saved f o r  t o t h e power of two;  that  otherwise  this  method  increasingly  inefficient  factor  i s increased  above z e r o ; i n d e e d t h e c a l c u l a t i o n  r o u t i n e ( s ) must The  compilation unit  programming be  transfer all,  of  interrupts  record.  as  completed  sensitive  packed  array  information  16 p r i o r i t y  record  data  will  will  loop  setting  Care  occurring  must  by  when a d a t a  o v e r w r i t e some, but  steps.  The  invert  one  is arbitrarily  procedure booleans  are c l e a r e d  The  z e r o e n t r y ; i f not nulled. and  the  not  disable  information records.  f o r at l e a s t  fields  the  level  outputs.  a r r a y s of c h a n n e l  priority  channel  may  program  numbers among t h e c h a n n e l i s checked  i f less  priority  from a r e a s c o n t r o l l e d  interrupts  priority  found,  priority  In g e n e r a l , E12AnaI0 r o u t i n e s  d u r i n g the  AnalnGo d i s t r i b u t e s  i n p u t s and  t o and  routines,  i s only p a r t i a l l y  The  The  problem.  a c c e s s t o the a n a l o g  service  the  are e i g h t .  E12AnaI0 p r o v i d e s h i g h e r  t a k e n when p a s s i n g d a t a  interrupt  as the minimum c h a n n e l  be wary of t h i s  before  channel p r i o r i t i e s .  should note  if a l l priorities  The  is calculated  shifted  is selected,  is  I f the  is substituted.  become  infinately  as  is  i s decremented.  i t can  with a l l sixteen  or e q u a l t o t h e n  triggered  i s zero, channel  to zero,  t o t h e number of t i m e s  is shifted  just  sweep c o u n t  reduced  eventual  than  channel c o n v e r s i o n proceeds  The  analog  AnaServ  and  63  interrupt change,  i s enabled.  for a single  The p r o c e d u r e  channel, the point  m e a s u r e d , t h e amount by w h i c h minimum t i m e  interval  calculation. exceeded  necessary  the  AnaRead  the d r i f t data the  error  latest  returned.  three  that  exceeded  caller:  Drift  t h e AnaServ  buffer  sends  boolean.  exceeded  AnaWrite,  AnalnStatus  booleans  value, to divide  and a l s o  resets  i s useful  for a  of r e c o r d s c o n t a i n i n g  a r e not r e s e t  Analog  by t h i s  AnalnStatus to AnalnStop  i s s u p p o r t e d by  output  channel, ensuring  0...255 f o r c h a n n e l s  5...8.  The o u t p u t  1...4 and  v a l u e s a r e saved  in a  r e a d back u s i n g AnaOutRead, or a s  The E12AnaI0 i n i t i a l i z a t i o n InitEl2isr  a l l channel d r i f t  minimum change  output  sum i s  AnaOutRead, and A n a O u t S t a t u s .  t h e range  t h e E12ISR p r o c e d u r e  second  input  ready  and dump r o u t i n e .  a value to the s p e c i f i e d  with AnaOutStatus.  initializes  so  ( i t i s easiest  the P a s c a l c a l l e r )  a n d c a n be i n d i v i d u a l l y  a group  half  i n time  interrupt.  0...4095 f o r c h a n n e l s  and  call,  latest  an a l l c h a n n e l a r r a y  error  i t i s within  calls  by t h i s  input  r e a d i n g , sum, and number o f r e a d i n g s i n t h a t  routines:  AnaWrite  error  p r e s e n t o n l y t h e newly  as a m u l t i c h a n n e l i n t e g r a t e  disables  and t h e  o f change  b u t sums and c o u n t s a r e z e r o e d , a l l o w i n g  perform  a drift is  must e x c e e d ,  f o r a rate  fetches a channel's  two from w i t h i n  logging  call,  will  i n r e a d i n g , and change  latter  drift  are a l l reset  s u c c e s s i v e AnaReady c a l l s  change  from w h i c h  and p r e s e n t s them a s a s e t of r e a d y  The b o o l e a n s  channels.  that  i s used t o  AnaReady draws t o g e t h e r a l l t h e d r i f t  booleans  channels.  AnaSetBound  t o copy  t h e jump  s e t v a l u e s , maximum d r i f t  code table, errors,  i n t i m e v a l u e s t o z e r o , minus one, and one  respectively.  AnaReady  i s called  to reset a l l  64  channel  ready  channel, again  setting  AnaWrite  a l l outputs  interrupt  The  E12  units:  servicing  channel m u l t i p l e x i n g MicroSput during  Three WaitBit,  allows run.  procedures  and  procedure  no  determine polling  the  The  Starter  procedure  the  previously The  i t s own  E12AnaI0 and  input  between values  E12Start,  latter  and  are  Strtlnfo  of t h e  by  semaphores  is called  internal  initialization  segment  currently  is started.  Schedule  the  to  input El2Sched  code  since i t  h a v i n g a l l been  initialized.  internal  procedure  by  the  of t h o s e  flags  input states  and  initialized  saves  operations to provide  initializes  or a n a l o g  synchronized  i s implemented  process, Poller,  on E 1 2 D i g I 0 ,  process P o l l e r  DvceJoin,  polling from  thereby  handshake. each  time  process  internal  call  the Schedule  of  E12Start latter  a c t s as a  booleans  E12  three  plotter.  priority  relies  returned  x-y  be  editing  uses  and  be  device  invert  stack size  cannot  El2Sched  TrigAna  interactive  o f an  The  code  to  includes  a r e d e c l a r e d by E l 2 S c h e d :  digital  being processed.  and  PlotUtil  WaitAnalog.  El2Strt.  indicate  PlotUtil.  input s t a t e s .  non-interactive control  to  s u b p r o g r a m module l e v e l  priorities  r u n s , and  a MicroSput  AnalnStop  f o r p r o c e s s i n g w h i c h must  or a n a l o g  output  E12AnaI0 h a l t i n g  ends by c a l l i n g  E 1 2 S c h e d , T r i g A n a , and  with d i g i t a l  The  once p e r  i s halted.  Multitasking  scheduling unit  is called  to zero.  z e r o e s a l l o u t p u t s , and  ensure  task  booleans.  b e g i n s by  joining DvceJoin  loops.  procedure  the  Schedule  the Schedule  unit's  and  calls  DvceAcpt  the h i g h p r i o r i t y  to Schedule  calling  The  input state latter  Polllnputs;  external are  polling  l o o p s once  such c a l l s  are  per  65  liberally external Poller  sprinkled  throughout  MicroSput.  d e v i c e h a n d s h a k e , and  l o o p s as  follows.  After  while MicroSput  I f one  the E l 2 D i g I O procedure DigRead  inputs.  input  WaitBit are  calls;  have been analog any  I f one  r e a d and  observed  interrupt  servicing.  are  a call  signalled.  An  t o the Schedule  termination,  a final  r e t u r n e d • from  and  have a l s o  Polllnputs  the P o l l e r  off  the Schedule  the  digital  all  o u t s t a n d i n g W a i t B i t and  and  digital  been  i n agreement  input  channels  of bounds by  r e q u e s t e d by  the  call  WaitAnalog  i s then performed  AcptHshk.  During  by  MicroSput  a s s u r e s AcptHshk i s a DvceQuit  call  a l l semaphores a s s o c i a t e d  i n p u t s are  the  Semaphores c o r r e s p o n d i n g t o  loop exited;  h a n d s h a k e , and analog  out  a c c e p t o r handshake  procedure  the  are outstanding,  which  t o have d r i f t e d  are  r e q u e s t e d by  calls  AnaReady d e t e r m i n e s  such c h a n n e l s which  calls  to those  o r more W a i t A n a l o g  procedure  input  checks  semaphores c o r r e s p o n d i n g t o t h o s e  signalled.  the'El2AnaI0  v a l u e s a r e compared  the  c o n t i n u e s t o run,  o r more W a i t B i t c a l l s  outstanding, The  joining  signalled  WaitAnalog  breaks with  (thereby allowing  calls  t o be r e t u r n e d  from) . The  p r o c e d u r e s W a i t B i t and  until  a specified  state  or a s p e c i f i e d  previously  TTL  input analog  s e t bounds,  calls  queued and  serviced  and W a i t A n a l o g for  a b i t or c h a n n e l  input  a r e not  Only  one  drifted  wait  s u c c e s s i v e W a i t B i t or  according to process p r i o r i t y .  specific  beyond i t s  p r o c e s s can  t h e same b i t or c h a n n e l  the Schedule  r e t u r n e d from  a c h i v e d the g i v e n  c h a n n e l has  at a time;  specifying  call  b i t number has  respectively.  on a g i v e n b i t or c h a n n e l WaitAnalog  WaitAnalog  procedure  number a r e Both W a i t B i t  Polllnputs  semaphore, w h i c h  ensures  and an  wait  66  of t h e E 1 2  immediate  check  preceding  paragraph.  The  variable  two  procedures,  ana_names  string[8]) each  which MicroSput channel.  checks  information TrigRead  channel  higher  level  T h e s e names d e f a u l t  t o see file  Triglnit  i s a sixteen  upon e x e c u t i o n of the T r i g A n a first  s t a t e as o u t l i n e d  c o m p i l a t i o n module T r i g A n a d e c l a r e s one  ana_names, and  with  input  is called  been  t o do  util:system.prio).  read; so  and  i f not,  Note t h a t  the  file  within  the T r i g R e a d p r o c e d u r e ;  created  on  s t a c k when T r i g R e a d  TrigRead  i s exited.  globally  within  program  procedure  if  checks  subtracted  from  efficiency  of  the  then  start  string  up  local  procedure i n the  implicitly  and  d e s t r o y e d when  with  f i l e s declared  t h e heap t h r o u g h o u t  calls the  the  unused, at l e a s t the  300  local  interrupt  is called  servicing. number:  since  no  minimum number i s  numbers t o e n s u r e  interrupt  file  is declared  i t i s thus  AnalnStop that  ''  Triglnit  f o r t h e minimum p r i o r i t y  read; otherwise  a l l priority  on  associate  boolean  variable  is generally  procedure  the AnaServ  may  to the n u l l  invert  The  names ( i . e .  procedures  associated  Triglnit  the p r i o r i t i e s  t o be  a r r a y of  is called,  active  file  to a c t u a l l y  the E l 2 A n a I O are  buffers  remain  are wasted.  Trigger  eight,  channels  a unit  e x i s t a n c e ; i f the  words o f RAM  Trigger  File  TrigSetup.  ( t h e i n f o r m a t i o n i s kept  locally  the  variable,  i n i t i a l i z a t i o n code.  i f the p r i o r i t y  has  and  i n the  maximum  p r o c e s s , and  AnalnGo i s  called. TrigSetup also already (see  read.  Fig. 8).  begins  by  The  background  The  channel  r e a d i n g the screen  input  image  names, w h i c h may  file  'trigana' have been  i f i t ' s not i s loaded changed  Set  Analog  Triggering;  1..16(channel  I(nvert  P(riority  Q(uit  Channel: chan Each channel i s t r i g g e r e d every ( 2 * * p r i o r i t y ) t h scan, s t a r t i n g w i t h c h a n n e l 16. P r i o r i t y range i s 0..7. Average sampling frequency d e p e n d s on a l l c h a n n e l p r i o r i t i e s and i s lower t h a n shown when i n t e r r u p t s a r e o f t e n d i s a b l e d , such as during disk access. Channels with i n v e r t true are r e c o r d e d as the n e g a t i v e of t h e i r a c t u a l p h y s i c a l value.  Figure  8.  Analog  input  name  invert  priority  readings/sec  1 2 3 4 5 6 7 8 9 10 1 1 12 1 3 1 4 1 5 16  multiplexing  s c r e e n image  'trigana'  CTl ~0  68  from t h e i r  default as  value  are  displayed,  well  for  a l l c h a n n e l s of  done t o d e t e r m i n e on  the  as  a higher  the  priority  the  the  arbitrarily displayed  selected  and  chooses to active  r e s u l t s are  an  The  toggle  the  the  through  channel  new  priority or  eight).  The  are  b o o l e a n s and  priorities  redone and  priorities,  the  to the  upon p r o g r a m  plotter.  E12 1 1  loaded  TrigAna  by of  calling the  operator  previously  the  following.  i t s number), ' I ' ) , or In  the  a number  to  to latter  zero  triggering (i.e.  and  average data the  new  Trigger.  write  the  rate  invert If  i n v e r t b o o l e a n s or  h a l t i n g code w i l l  Multitasking Five  f o r no  displayed,  of  'P').  typing  is  exited.  typing  typing  is  the  The  based  conversion  A prompt  typing  (by  by  return  c h a n g e s have been made t o any  The  (by  priority  sixteen  until  consists  i n d i v i d u a l channels'  calculations  disk  (by  i s entered  carriage  Channel  TrigSetup  i n v e r t boolean  channel's p r i o r i t y  second  for q u i t ) .  and  and  each c h a n n e l ,  continued  'Q'  procedure,  A calculation is  interaction.  i n t e r a c t i o n loop  c h o o s e s a new  seven,  priority  typing  on  thirtieth  displayed. initial  eight.  rate  one  image i s r e l o a d e d  channel's  change the case,  i t (by  TrigSetup  operator  and  MicroSput  i n v e r t boolean  l e s s than  i n t e r a c t i o n loop  leave  screen  for  level  input  average data  existing priorities  t i m e , and  The  by  any trigger  new  values  termination. level  procedures are  unit  PlotUtil  declared:  o p e r a t e s an  x-y  PlotBounds,  P l o t U t i l c u r r e n t l y u s e s a n a l o g o u t p u t s 7 and 6 f o r x and y axes, r e s p e c t i v e l y . Pen m o t i o n i s d e t e c t e d w i t h d i g i t a l i n p u t b i t 7, and pen z - a x i s c o n t r o l i s f e d from d i g i t a l o u t p u t b i t 7. The m o d i f i c a t i o n s p e r f o r m e d on the H e w l e t t - P a c k a r d 7044A X-Y 1 1  69  Plot,  PlotLift,  be c a l l e d ordinate Plot pen  P l o t D r o p , and P l o t A x e s .  values f o r the p l o t  scales  and o f f s e t s  to the r e s u l t i n g  returning.  Schedule  coordinates.  PlotLift  of  the p l o t ,  right, and  lower  finally  Plot  and P l o t D r o p l i f t  calls  and d r o p  respectively;  the z - a x i s motion  lifts  and lower  left  t h e pen calls  a one t w e n t i e t h  i s completed.  i t , moves i t t o t h e upper  right,  before  each p r o c e d u r e  t h e p e n , moves i t t o t h e l o w e r  drops  t h e E12Sched  i s complete  procedure WaitTick requesting  lifts  can proceed.  x,y d a t a and moves t h e  t o e n s u r e pen m o t i o n  d e l a y t o ensure  PlotAxes  b e f o r e any p l o t t i n g  the s p e c i f i e d  from a n d on t o t h e p a p e r ,  second  must  w i t h t h e minimum and maximum a b s c i s s a and  procedure WaitBit  the  PlotBounds  left left,  hand c o r n e r s  hand c o r n e r upper  successively,  t h e pen a n d r e t u r n s .  R e c o r d e r r e q u i r e d f o r m o t i o n d e t e c t i o n and z - a x i s c o n t r o l were made and documented by M.L.W. T h e w a l t i n h i s M.Sc. T h e s i s , UBC, O c t o b e r 1975.  70  CHAPTER SEVEN MicroSput M u l t i t a s k i n g  The  MicroSput  are  useful  All  external  drives the or  f o r any  and  equipment  code of  recompilation  the  Schedule, The  on  supported  comprising  operated  two  are  the any  by  are  the  is for  error  used  f r e e and  maintaining  displaying  selected  Strter Strtlnfo, process given  searching  avoiding  Unfortunately, words f o r a  the  read  the  that  the  user  stack  the  need  to  without  stack  units  S t a r t e r , DataBus, Appendix  for  listings).  i n programming  situations  E  in that  bounds.  VDT  might  recompile  case.  entered  images  is useful and  Its single  priority  and  of  the  think  procedure,  a named  user)  declared  priority  from a  S t a r t e r each  globally in Starter's  for  i t would be  the wiser  data  change.  t h a t method would e i t h e r mean a waste of  file  input  screen.  and  size  although  ScrnBuff  screen  editable.  One  microcomputer  a l l operator  size  disk  modification  compilation  (as ammended by  names.  ( t h e VDT,  p-code i n t e r p r e t e r ;  necessary  background  a table  process  t o have S t r t l n f o file,  of  run  group  implementation.  used e x p l i c i t l y ,  specified  i s meant t o be  u n i t and  not  than  images t o  determines  by  are  to ensure  a pool  (see  prove u s e f u l  within  IV.0  the  The  group are  slower  multitasking  l a r g e number of  ScrnBuff  u n i t s may  be  by  p-System.  multitasking  b u l k i e r and  ReadKybd can  i n the  t h e s e modules  driven  the  where s u b s i d i a r y p r o c e s s e s they  by  modules w i l l of  ReadKybd, and  latter  modules  UCSD p - S y s t e m V e r s i o n  system c l o c k )  compiled  systems  compilation  Utilities  300  RAM  implementation  71  part,  or a l o n g MicroSput  within with  Strtlnfo  procedure  is  name o p e r a t i o n s , t h e u n i t  t o upper c a s e  (via a c a l l  Uppercase) before comparison  comparison  case  not found,  independent.  a call  initialization.  t o the ErrMessg  of  larger  than  set  size.  sizes  The l a t t e r  compile  can only  Starter  proceeds  as e x p e c t e d ,  overflow  occurs,  stack.  t h e minimum w o r k a b l e be done by t r i a l  separate  may prompt from  I f the run  satisfactory  stack  stack_safety  and c o m p i l e  one  f o r s t a c k _ s a f e t y remains a user  a  may want  small value  overflow  size  library.  fatal  Starter  for  i n execution  fora final  and a s s o c i a t e d h i g h t o both  p-System), and a l a r g e v a l u e decrease  in this  codefile When a  has been a t t a i n e d , i n c r e a s e t h e  (e.g. zero)  (an e r r o r  i f a stack  with a larger  many t i m e s  to leave the S t a r t e r  of the MicroSput  process  f o r the process i n  a smaller stack;  Starter  because  and e r r o r :  t h e p - S y s t e m and t r y a g a i n  the user  the rest  size  and run M i c r o S p u t .  The n e c e s s i t y t o r e c o m p i l e  situation  the MicroSput  f o r t h e p o s s i b l e need of a  t r y again with  reboot  NoteError  s t a c k _ s a f e t y i s added t o  s t a c k _ s a f e t y t o z e r o ; choose a s t a c k  question;  a n d p r o c e s s names  This feature i s provided  in determining  As  startup information  and h a l t s  to account  specified.  the d i f f i c u l t y  stack  declared  so a s t o r e n d e r t h e  procedure  An i n t e g e r c o n s t a n t  tabulated stack  stack  file  t o the MiscFunc  I f the process  d i s p l a y s a message t o t h a t e f f e c t  all  f o r a data  and t h e r e f o r e opened and c l o s e d e a c h c a l l .  other MicroSput  are converted  s t a r t u p time,  speed  MicroSput  (e.g.  fifty  The v a l u e  compromise risk  between  of stack  and t h e u n d e r l y i n g  words) a n d a s s o c i a t e d  of a l l MicroSput  e a c h o f , say,, t w e n t y p r o c e s s e s  time.  tasks  (fifty  words  u s e s up two k i l o b y t e s o f RAM,  72  requiring course,  e x t r a p - S y s t e m memory management p r o c e s s i n g ) .  i f one  is willing  error  experiments,  found  and  the exact  s t a c k _ s a f e t y can  overflow  unit  priorities.  be  nulled  without  The  between p r o c e s s e s , type  handshake  handshake d a t a  DataBus p r o c e d u r e s which case  they  generate  fields  only.  wait  some a s s o c i a t e d new  data  Any  d a t a ) , or  sources,  (and  initially which  handshake  w a i t i n g on  recieve a single  join  they  the  be  stack  Synchronous a c c e p t o r s w i l l  AcptQuit)  they  the  the  source  of  I f more than  the by  acceptors, in  (and  perhaps  use  they  may  share  Acceptors  are  t.o A c p t J o i n ) ,  AcptHshk with  ready  to leave  the  the  Asynchronous acceptors synchronous boolean a c t upon e v e r y  can  re-call  depending  on  one  the  shares  false.  (or  Asynchronous  and a l l  process  may  handshake  AcptHshk  proceed.  signals,  may  acceptors  the asynchronous a c c e p t o r source  a  semaphores, a l l a c c e p t o r  and  process  m i s s some handshake  priorities  either  Synchronous  n o t i c e and  t h e y must a l l c y c l e  before  a c c e p t o r s may  with  use;  sources  calling  to AcptQuit). time,  process  manipulated  (via a c a l l  to c y c l e ,  true, u n t i l  (via a c a l l  indeed  of  handshake s i g n a l .  handshake  continue  A c p t H s h k a t any  sources.  of  i n which case  number of a c c e p t o r s and  synchronous boolean  relative  can  p e r h a p s u p d a t e an a s s o c i a t e d  s y n c h r o n o u s or a s y n c h r o n o u s .  either  t o be  must be  be  signal;  and  s y n c h r o n i z a t i o n of  f o r t h e handshake t o o c c u r  a handshake s i g n a l  record).  a r e meant  will  call  risk  independent  processes  after  any  trial  size  is defined for this  Processes  handshake; u n l i k e p r o c e s s e s  must  the  minimum r e q u i r e d s t a c k  DataBus p r o v i d e s a method of  communication  actual  l o n g enough a t  errors.  The and  t o spend  Of  the  same  73  h a n d s h a k e , and through  a buffer,  access  for  then  to that data  buffer, only  t h e handshake  then  one  call  source  one  i s being  source  used  must e x c l u d e  buffer (via a c a l l  SrceHshk with  the  i s i n v o l v e d , or  s y n c h r o n i z a t i o n but  independently  called  handshake can  be  not  with  used,  a l l others  to SrceLock),  unlocked  transfer,  the u n l o c k e d be  then  from the  false.  If  i s being  used  S r c e H s h k can  boolean  initialized  flow  change  boolean  i f t h e handshake  data  i t must  to r e g u l a t e data  true. by  be  Before  a call  a  to  Hshklnit. The and  unit  Schedule  six global  WaitTick,  initially  s e t and  reset  check  to  execution  task all  the  reset  i t signals  to p o l l  procedures,  (synchronous),  and  AcptQuit  handshake d v c e _ p o l l as can with VDT  be  used  the  by  ticking  of  must  terminate line  task_done. a l l external device They a r e  also  A c p t J o i n , AcptHshk with  parameter.  the  WaitTick  s y s t e m c l o c k and  internal and  their  the o p e r a t o r  WaitChar execution entered  respectively.  internal  s y s t e m c l o c k and polling  the  and  input s t a t e s .  respectively  their  by  run; i t  i s a one  e x t e r n a l r o u t i n e s to synchronize  characters, The  calling  statement,  used  is  A l l processes  semaphore  are  their  run.  Polllnputs  internal  DvceQuit  running  the M i c r o S p u t  the  condition.  running,  DvceAcpt,  boolean  set throughout  the  D v c e A c p t , and  line  The  e x e c u t i n g a wait  scheduling units one  WaitChar.  variable,  DvceJoin,  t e r m i n a t i o n of  before  upon t h e  procedure: DvceJoin,  and  remains  flag  running  global  routines, Polllnputs,  DvceQuit,  is  d e c l a r e s one  processes  Schedule t h e VDT  process  keyboard,  to perform  their  Poller and poll  polls  signals by  the  state  of  the  external device  a dvce_poll  source  74  handshake. Upon as  Poller  reciept,  follows.  linked list the  from  the l i s t .  either  or the l i s t  i s checked.  semaphore  time of  i t i s s i g n a l l e d and i s similarly  i s found whose s i g n a l  t i m e has  I f a WaitChar  call  VDT i n p u t c h a r a c t e r  c h a r a c t e r i n t h e queue  i s signalled;  i s checked,  o r t h e queue  with d v c e _ p o l l for.  of every  finally  t i m e of  as a  i s r e a d and  WaitChar  I f t h e c h a r a c t e r i s a member o f t h e s e t , t h e n t h e  queue  waited  I f the s i g n a l  has been e m p t i e d .  The f i r s t  The  t i m e a t which any  i n the l i s t  of i n t e r p r e t e r  loops  i s pointed to.  t o t h e c h a r a c t e r match s e t s u p p l i e d  WaitChar  found  a link  Poller  times; the s i g n a l  has a r r i v e d , link  signal.  are outstanding, a  i s the e a r l i e s t  The n e x t  outstanding, the s i z e  parameter.  end  of the s i g n a l  i n the l i s t  etc. until  compared  the  i n terms  member  arrived,  queue  i s true,  times  semaphores a r e t o be s i g n a l l e d .  treated,  is  running  o f semaphores and s i g n a l  member o f t h e l i s t  first  removed  not  and w h i l e t h e g l o b a l  i s ordered  WaitTick the  by w a i t i n g f o r a t a s k _ d o n e  I f one o r more W a i t T i c k c a l l s  list  first  starts  etc., until  i s emptied.  i s performed,  The E r r M e s s g  either  An u n l o c k e d  running  because  because  of o p e r a t o r s e l e c t e d  in  t h e W a i t T i c k semaphore l i s t i s signalled,  a valid  character in  character i s  source  and t h e t a s k _ d o n e  or  semaphore  either  function  loop; i f true,  i s reset,  o t h e r w i s e t h e next  handshake  semaphore i s  E r r o r N o t e d i s checked i s reset.  When  of a MicroSput  a t the  running  detected  error  program t e r m i n a t i o n , a l l l i n k s are signalled,  and a d v c e _ p o l l  t h e WaitChar  s o u r c e handshake i s  performed. The specified  procedure WaitTick time  increment  simply  to wait  signals  task_done  i s z e r o or l e s s .  if  its  Otherwise,  75  the  system c l o c k  A new l i n k  f o r the WaitTick  signal  time  record  i s placed  link no  with  such  i s r e a d and added  initialized  link  signalled,  semaphore l i s t  with  t h e time  i n the l i n k e d  a greater signal exists.  t o the s p e c i f i e d  list  time,  result.  immediately  The new  before  any o t h e r  o r a t t h e end of t h e l i s t , i f  and t h e new semaphore exited  i s c r e a t e d and i t s  addition  The i n p u t p o l l i n g  d i s p o s e d and W a i t T i c k  increment.  semaphore t a s k _ d o n e i s  i s waited  for.  The r e c o r d i s  once t h e semaphore has been  signalled. The at  f u n c t i o n WaitChar can s e r v i c e  a time;  call  any f u r t h e r W a i t C h a r  i s outstanding  will  calls  be p l a c e d  o n l y one c a l l i n g w h i l e a former  i n a queue b a s e d  priority.  The c h a r a c t e r match s e t s p e c i f i e d  call  serviced  the  being  input p o l l i n g  WaitChar first  i s waited  typed  WaitChar on p r o c e s s  by t h e W a i t C h a r  f o r use by t h e P o l l e r  semaphore t a s k _ d o n e  semaphore  operator  i s recorded  for.  i s signalled,  WaitChar  c h a r a c t e r which  process  process,  and t h e  r e t u r n s with the  i s a member  o f i t s match  set. All  MicroSput  processes  encounter  a wait  statement  execution  loop.  In e v e r y  upon w h i c h t h e y  wait  d e s c r i b e d so f a r i n t h i s  at at least case  one p o i n t  the s i g n a l l i n g  can u l t i m a t e l y  in their  o f t h e semaphore  be t r a c e d back t o a  of  the task_done  semaphore, upon w h i c h t h e o v e r a l l  is  polled  I t i s p o s s i b l e t o imagine  during  once.  w h i c h no i n p u t s o c c u r .  eventually processes and  will  reach a wait getting  there  have s i g n a l l e d  last.  a time  A l l MicroSput  statement,  thesis  with  tasks  the lowest  Polllnputs  will  t a s k _ d o n e many t i m e s ,  input  signal state  interval will priority  have been  called  but by h y p o t h e s i s  76  none o f t h e i n p u t s upon w h i c h t h e p r o c e s s e s will  wait  its  are active.  wait, a l l MicroSput  then  become a c t i v e ,  Polllnputs, acted  Clearly  may be d e s i r e d oscilloscope that  than  and  The  signal  t h e new p r o c e s s must  a wait  its priority  MicroSput  formatted  former;  process  Eventually,  s m a l l t a s k , such  It i s essential  that  statement  Polllnputs  i s below  calls  those  i t  a s scan an  greater  any p r o c e s s  of a l l o t h e r  which  on e a c h  loop,  needed  asynchronous  ReadKybd p e r f o r m s error  Most ReadKybd programming  a wide a s s o r t m e n t  the execution of other processes only  most c a s e s  the completed  re-entered  i f beyond  necessary field  types  from  t h e VDT  specified  i s rejected limits.  t o allow the echoing i s being entered  any new d a t a  with  keyboard,  t o continue during the  relevant characters are accepted; i n  entry  a r e d i s a l l o w e d from moving  i s concerned  of f u n c t i o n s and p r o c e d u r e s a r e  allowing  In a l l c a s e s ,  two  c h e c k i n g VDT i n p u t , and  to read v a r i o u s data  writing  i s required to The S c h e d u l e  reason.  provided  a data  i n p u t s w i l l be  be g i v e n a p r i o r i t y  compilation unit  VDT c u r s o r c o n t r o l .  is  to c a l l  processes.  functions:  entry.  reaches  i f the inputs  remaining  task_done.  i s included f o r this  of DumpTime.  MicroSput  the  a minimum p r i o r i t y  process  Even  none o f t h e newly a c t i v e  t o do some a d d i t i o n a l  encounters  that  stop.  or e v e n t u a l l y  beam o n c e , whenever no o t h e r p r o c e s s e s a r e r e a d y .  case,  that  never  execution w i l l  one t a s k p e r l o o p :  p r o c e s s DumpTime  priority  t h e r e a r e no p r o c e s s e s  and t h u s  upon.  perform  In  When t h e l o w e s t  wait  and must be  The VDT c u r s o r  of VDT k e y b o a r d  entries.  by t h e o p e r a t o r , o t h e r  the cursor  t o the s c r e e n ) .  control When  processes  (and t h e r e f o r e from Only  when t h e c u r s o r i s  77  resting line)  in a  known p o s i t i o n ( i n t h i s  i s the  practice, reaction  cursor  this  a v a i l a b l e for data  restriction  t i m e t o prompts  processing  the  pair,  given  before  input;  cursor  as  accepting into  supplied read  the or  input,  routines  the fixed  as  entry  of  by  the  data  the  the  Read/Fetch  ( w h i c h must be  move t h e  'Fetch',  g e n e r a l l y blank  type,  an  data  out  of  operation  character  to process  priorities  character  by  so  character  u s e s may  used  is to  upper  case  (in either fixed  decimal  numerical  are  out  operations  Schedule  processing the  e n t r i e s are  data  may  of are  procedure continue  entry.  The  r e q u i r e s a s i z e a b l e amount  overhead, p a r t i c u l a r l y  programmers u s i n g  echoed;  against  to the  during  field  field  be  s e t ) , an  A l l read  that  data  be  maxima; i f t h e y  i s redone.  i s used  the  checking  The  at a time v i a c a l l s  T h i s method  data  integer, a real  the  Before  this  r o u t i n e s can  One  cursor  moves  will  length  in a given  s u p p l i e d minima and  read  in p a i r s .  i t s 'Read' t w i n .  n o t a t i o n ) , or a s t r i n g .  non-multitasking reason.  In  than  written  prefix  comprising  a parameter.  programming  cases;  prompt  operator  ( i . e . t r a n s l a t e a l l lower c a s e b e f o r e  bounds, t h e  of  the  the  executes  characters  checked against  according  t o l e r a n t , as  'Read', d o e s not  given  then  scientific  WaitChar.  of a  d i s p l a y purposes.  r o u t i n e s are  prefix  other,  s e t ) , a boolean,  done one  input  the  the  a character  character  end  i s g e n e r a l l y much s l o w e r  specified,  which  where not  i s very  the  time.  ReadKybd o p e r a t o r of  case,  i n the  the M i c r o S p u t wish to a v o i d  numerical  library use  input  for  of ReadKybd  for  this  78  One  operator  input  r o u t i n e which  i s not p a r t  Read/Fetch p a i r i s t h e f u n c t i o n PromptCapIn. supplied screen, too  a s a PromptCapIn starting  long  that  starting  i s assumed  subject  at the given  to f i t across  substrings,  parameter,  at the f i r s t  t o be a t i t l e ,  i t i s broken  e.g.  space  (the p a r t  'Setpoint:',  algorithm).  mark; t h e f a c t  available the  i s shown by a q u e s t i o n  existing  waits data  t h a t more prompt  substring, just  f o r an o p e r a t o r  display processing  and i s n o t  The d i s p l a y e d  requested  types  a  substrings are  the c u r s o r .  the cursor  uses.  before  mark d i s p l a y e d a t t h e end of  over  response,  line i s  up i n t o  s u b s t r i n g s a r e c y c l e d through each time the o p e r a t o r question  line,  I f t h e prompt  double  t o the substring c y c l i n g  A prompt  i s d i s p l a y e d across the  position.  the screen,  of a  While  i s freed  Those p r o c e s s e s  PromptCapIn f o r other  should  the cursor  by c a l l i n g  CursBorrow;  from a l l o u t s t a n d i n g  CursBorror  calls.  When done, t h e d i s p l a y  i n turn  replaces  processes at  call  PromptCapIn  prompt The  When a v a l i d  u n i t ScrnBuff  data  from M i c r o S p u t  when t h e c o r r e c t b a c k g r o u n d created  using  library  uti1:system.scrn  the  back  h a s been  returns  and e r a s e s  a l s o p e r f o r m s two f u n c t i o n s :  t h e b a c k g r o u n d VDT s c r e e n  channeling  librarian  be made  the cursor  character  d i s a b l e s the CursBorrow  will  line.  compilation  operating and  which  t h e end o f t h e prompt.  recieved, the  CursReturn  returns  have  image  image p o o l , processes  i s loaded.  t h e p - S y s t e m e d i t e r and added using  program, S c r n S a v e .  same manner t h a t  the MicroSput The l a t t e r  t h e p-System code  and b u f f e r i n g  t o t h e VDT Screen  images a r e  to the screen screen  file  t r e a t s screen  file  screen  librarian  images i n program,  79  Library,  treats  a  image c o n s i s t s of two p a r t s :  screen  image. in  o b j e c t code s e g m e n t s .  The prompt  list  a s s o c i a t i o n with  limited  to a t o t a l  pointer  character.  a MicroSput  is a series  screen  The  ScrnBuff lines  a loaded  as l i n e s  images a r e i d e n t i f i e d  name i s u s e d library  available The  both file,  location  until  image.  at zero.  The  list;  another  ScrnClear  active  image  t o t h e VDT.  screen  image  i s active,  will  is  by t h e during  image p a r t  of t h e  be l o a d e d  image  by  ( t h e VDT  Background The  image's w h e r e a b o u t s i n  w h i c h VDT  The p r o c e d u r e  fields  are  image.  call  image  t h e VDT  ScrnRefresh  If a ScrnEnter  call  remains a c t i v e  call  without  r e w r i t e the  image w i l l  while  r e t u r n t o and r e l o a d t h e f i r s t  is  i s made w h i l e  image's S c r n E n t e r performed  call  screen  will  t h e newly named s c r e e n  A ScrnReturn  (name) i s  or a ScrnReturn  to erase  images i s  o f and r e t u r n i n g  ScrnEnter  The named s c r e e n  but the f o r m e r l y a c t i v e  active  list  name v a r i a b l e .  to the c a l l i n g  can be c a l l e d  the c u r r e n t  outstanding.  used  The prompts a r e  at z e r o ) .  the screen  ScrnEnter  deactivating  loaded,  The  i t will  by a M i c r o S p u t  similar  to load a screen.  made.  t o be  buffered d i s p l a y data.  i n a manner  either  and t h e  of one of t h e  screen  and t o d e t e r m i n e  from P a s c a l p r o c e d u r e s . called  image.  1...23 of t h e VDT  to determine  to accept  lines  l o a d i n g and r e l o a d i n g of b a c k g r o u n d s c r e e n  performed  is  t h e RAM  f o l l o w s t h e prompt  procedures  list,  i t i s terminated  a r e numbered downwards, s t a r t i n g  screen  the  o f prompt  v e r s i o n of  f u n c t i o n S c r n P r o m p t c a n be c a l l e d  sequentially, starting file  t h e prompt  o f 512 c h a r a c t e r s ;  run t o d e t e r m i n e  text  text f i l e  the background screen  prompts a s s o c i a t e d w i t h numbered  The  will  be  remain  the second  image.  one  Any  image number  80  of  ScrnEnter/ScrnReturn  associated  w i t h an  ScrnPrompt  function,  p a i r s may  active  be  screen  whether  nested.  The  prompts  image a r e a v a i l a b l e ,  the a c t i v e  image has  via  the  been c l e a r e d  t  or  refreshed.  are expected image.  The  t o be  call.  between b l o c k  to  t h e VDT  screen entries  The  entries  i n c l u d e the  field,  sb_format real, data  value  TimSubTO  i s used  The  with  The type  or t i m e ) , and  Data v a l u e sb_dspl  places.  buffer.  fixed  data  record, a data  string,  value  buffering a call  and  data  screen  and  proper  decimal  display. field,  decimal record  identifier  image i s new  data, Numerical the  size  display,  of  the  i n c l u d e s an  (boolean,  integer,  first  four data  r e t u r n e d by  the C l o c k  types,  is initialized  function sbLink.  The  the  procedure  i n s t e a d of a b u f f e r e d t i m e channeling  data  boolean  i s enabled,  for real  fixed  by  displayed  screen  field  write.  of p r o c e s s  and  sb_dspl  to the  screen  or  image  includes  the data  f o r the  for display  r e c o r d by  active  field,  c o o r d i n a t e s of  for real  number of d e c i m a l  or  screen  record  the  an  PollLnputs is called  channeling  of a p a r t i c u l a r  scientific  and  and  or not  of  sb_dspl are d e c l a r e d  t o the c u r r e n t l y  recieved for that  t o use  ScrnRefresh,  upon c o m p l e t e d  and  packed  lifetime  they  c o p i e d t o t h e VDT  internal  buffering  whether  whether  the  sb_format  the  since  hand, r e m a i n s d i s k  procedure  is signalled  the d i s p l a y  been  other  the  sb_format  indicating  has  and  i n RAM,  during  t h e d i s k and  Schedule  facilitate according  displayed, data  The  process  image.  the  saved  upon e a c h S c r n E n t e r ,  record types  ScrnBuff to  from  transfers,  updating The  image, on  a t a time  ScrnReturn  prompts a r e  needed many t i m e s  I t i s read  block  field  active  active  resident. one  The  value. f o r each  function  81  creates data, also  a new  and  sb_dspl  returns with  inserts  records can  the  a pointer to  sb_dspl  a s s o c i a t e d with  then  be  updating  the  t r a v e r s e d by  process.  string,  or  given  sbTossInteger,  an  screen  values  sbTossReal,  respectively,  giving  the  by  calling  value  differs  from  displayed,  the  data  updating  field  sbToss  process  also  ( v i a a source  record l i s t .  In t h e c a s e  has  a lower  priority  t h a t of  result  of  the data  t o t h e VDT  The  ScrnBuff  initially  waits  asynchronous proceed  at  impeding  on  form  i t s own  the  t o ASCII  will  not  screen an  data  (possibly  data monitor  i s r e c i e v e d , and  following  loop  is  t o o b t a i n use  displayed, linked  data  and  and  i f there  buffer l i s t  and  data  value  internal  latter the  being screen  process  actual  sending  the  immediately. updating  process  slow) e x e c u t i o n control  The  of. t h e VDT  Update  handshake.  i s r e q u i r e d so  i s data  integer,  is actually  the  t h a t the  rate  Once  continuew  i s t r a v e r s e d and  ready  sent data  the  to run,  the  CursBorrow  If a screen  w a i t i n g t o be  can  without  ReadKybd p r o c e d u r e cursor.  The  t h a t Update  processing.  while MicroSput  i s performed.  and  handshake) to t r a v e r s e  asynchronous acceptor  handshake  called  new  the c a l l e r ,  field  of h a n d s h a k e  list  fields  f o r time)  c h a r a c t e r s and  occur  proper  sbTossNow  signals  sb_dspl  conversion  similar  sbTossBoolean,  If the  its  than  The  data  i f t h e d e s i r e d image  procedure  of  for boolean,  (except  r e c o r d p o i n t e r as p a r a m e t e r s . o l d , and  list  screen  s b T o s s S t r i n g , or  data  given  f u n c t i o n sbLink  image.  i s enabled  sb_dspl  the  The  the  image becomes a c t i v e ,  internal  Data d i s p l a y time  i t .  i t with  record into a linked  l o a d e d when i t s s c r e e n  periodically  real,  record, i n i t i a l i z e s  to  image i s  i t , the  fields  82  updated. control is is  The  ReadKybd p r o c e d u r e  CursReturn  to  the  ReadKybd p r o c e d u r e s .  awaited  via  an  returns  A further  asyncronous acceptor  cursor  data  handshake,  ready  and  signal  the  loop  repeated. The  background  MicroSput  screen  9).  image  This  screen  library is  image  for  fields  in  latter  image.  The  text  file  version  of  the  aligned  over  the  test  grid  a  light  read  from  the  constant changes  all  data  table  at  to  the  field the  screen  program-editing.  on  grid.  If  beginning will  of be  newly  table,  the  is  program  possible  (see  printed the  screen out  and  field  remembers  sizes source  with  Fig.  the  created  and  field  the  only  programmer  and  in  determining a  the  coordinates  image  purposes  for  and  reference  data  included  useful  coordinates  coordinates  of  is  development  especially  sizes  'test'  to  a file,  minimum  to  Tester: Tester: Tester:  This This This  is is is  test test test  prompt prompt prompt  zero, one, two,  which which which  is is is  not very long fairly long as very very very  @ +  — 1  1  +  +  +  +  +  +  1  +  +  +  +  +  +  —  Figure  7  2~-  9.  you can se long, so 1  Screen  image  development  test  pattern  +  'test'.  oo to  84  CHAPTER EIGHT General  The  Purpose MicroSput  most g e n e r a l  includes  and  These m o d u l e s a r e implementation,  manipulate standard  fatal  m a t h e m a t i c a l and  operations  The  unit  of m a c h i n e MicroSput the  could  procedure could  be The  for  use  standard  formatted as  For  any  UCSD p - S y s t e m  but  on  utility  only  i s not  implemented  u s e d by  as a s i m p l e  b i t signed  ErrMessg  provides  a p o t p o u r r i of  ExtraScreenOps  t o be  ScreenOps.  not  portable and  system c l o c k counts  of  The  lack since  (the  Z80).  TimReset,  MicroSput  arose. units  The and  pair.  tim__rec  and  type  need e v e r  other  begin-end  speed,  unimportant,  exception  any  extends  VDT.  computer  i f the  a  e r r o r message d i s p l a y  of c o n v e n i e n c e  the  i n t e g e r type  i n system c l o c k r e a d i n g s p-System  r o u t i n e s to  is actually  one  rewritten in Pascal  TimReset  use  w r i t t e n in assembler.  d e c l a r a t i o n s , with  easily  not  provides  i s considered  i s c u r r e n t l y run  do  w r i t i n g t o the  reasons  r o u t i n e s are  independence  32  data  MiscFunc,  p-System u n i t  implemented,  types.  Clock  Clock  be  s u p p l i e d i n the  Clock,  between computer the  MiscFunc  MicroSput  listings).  on  a number of  character operations.  WritCons performs  All  with  system c l o c k .  errors.  of  F for  method of p r o g r a m t e r m i n a t i o n and  upon d e t e c t e d  some of  provides  from t h e  level  (see A p p e n d i x  are compatible  Modules  ErrMessg,  u s e f u l f o r programming  Clock  data  units Clock,  WritCons  and  multitasking.  t h e VDT  p u r p o s e programming  the c o m p i l a t i o n  ExtraScreenOps,  Subprogram  i s d e c l a r e d by  manipulations. upward  Clock  The  from z e r o a t  the  85  rate  of  sixty  sixtieth  c o u n t s per  second, types  against  the  also  converted  or  that  be  added,  system c l o c k  t = 0,  time, to  may  to character  to  strings  may  unit  ErrorNoted. detected.  be  The  the  system c l o c k  d e c l a r e s two is called  when a  value  of  the  ioresult)  error  p-System g l o b a l  message w i l l  terminated shut  until  down.  not  be  a l l processing  boolean  the  data  utilrsystem.errs.  file  true.  and  function ErrorNoted when N o t e E r r o r  The  unit  operations MicroSput provided  MiscFunc  for real  reference relative  The  file  i s normally  of  (such  into  program w i l l  e r r o r message  i t s source  in a look  units  up  as  the  that an  i t is false,  initialization  This  error is  requesting  If  the  and  the  not is  be safely  code must i s read  i s produced  pass  from  by  which uses the  text  e r r o r messages.  The  false  but  becomes  true  is called. contains  w h i c h have p r o v e n modules.  insert  in uti1:saveerrs.code,  u t i 1 : u b c e r r o r s . t e x t as  boolean if  program  A  may  again,  MicroSput  i n a l l MicroSput  i n an  immediate  the  back  number  A boolean  w r i t t e n and  the  running  to  i s a l s o passed.  Errors occurring  file  fatal  information  parameters,  as  They  reading  e r r o r number t o use an  halt  checked  routines, NoteError  e r r o r messages, and  immediate M i c r o S p u t  tick.  procedures.  ( i n s e c o n d s ) and  of  as  one  obtained.  i n t e g e r s , the  passed  as  compared, or  Clock  table  message a r e  r e s o l u t i o n , one  of h o u r s : m i n u t e s : s e c o n d s .  be  first  by  numbers  s e t , and  ErrMessg  Two  tim_rec  subtracted,  reading  real  r e f e r e n c e may  The  The  i s r e f e r r e d t o by M i c r o S p u t  Tiiri_rec  be  second.  Base t e n numbers.  a number of  t o be  miscellaneous  needed by  l o g a r i t h m and  two  or more  a n t i l o g a r i t h m are  Signum, minimum, maximum, and  value  86  limiting  functions are available  Addition  and s u b t r a c t i o n  adding  addresses)  characters  ExtraScreenOps ScreenOps. of  table  name.  MapCommandKey  before  to simply  single  supplied.  parameter  as f a l s e  day-month-year  t h e o p e r a t o r has s e t t h a t  date  code  code  fills  a  initialization is  l o o k t h e code up.  i n format  t h e ASCII  i t s ScreenOps  initialization  made a f t e r  unit  to allow  MapDate r e t u r n s w i t h (e.g. l8-Oct-82),  u s i n g t h e system  filer  the MicroSput run. procedures  has the p r e f i x procedures  current  the data  cursor position,  a given p o s i t i o n  by  the data  this  or t r a i l i n g  Strings  will  be l e f t  types w i l l  integers,  blanks  that  justified  be r i g h t  t o t h e VDT s c r e e n s t a r t i n g  characters,  ( i nfixed  and s t r i n g s .  'Toss'. at the  move t h e c u r s o r  the twin W r i t e .  Where n o t f i x e d  i n the procedure  number o f c h a r a c t e r s i n c l u d i n g will  be u s e d  i n the given  justified.  are provided f o r boolean, reals  procedures  length i s specified  i s the t o t a l  leading  procedures  and p e r f o r m  One o f t h e  t o i t s name; t h e o t h e r  while Toss  type, a f i e l d  parameters:  are declared in pairs.  ' W r i t e ' added  send  to  data  determines  character, given  the boolean  Most W r i t C o n s  Write  when  which c o n v e r t  case a r e a l s o  MapCommandKey  The E x t r a S c r e e n O p s  the c u r r e n t date assuming  Routines  (useful  makes two e x t e n s i o n s t o t h e p - S y s t e m  control  can pass  r e a l s and i n t e g e r s .  integers  t o upper  of these mappings; c a l l s  complete  pair  strings  The f u n c t i o n  a non-standard  symbolic  of unsigned  are declared.  or e n t i r e  f o r both  decimal  i n the write. field;  W r i t e and/or blank  a l l other Toss  character  or s c i e n t i f i c  strings,  notations),  87  CONCLUSIONS  The  c o n v e n i e n c e of u s i n g M i c r o S p u t t o o p e r a t e a  sputtering regularly its  system  version  independent  record  The  by members of t h e UBC  earliest  scanning  i s evident.  system  of one  Physics  i n October  parameters  independent  of the e v o l u t i o n  computer  1980.  s y s t e m has  sputtering  parameter  may  been  group  Unwanted d r i f t  is eliminated.  of dependent  PM used  since  of  Incremental  be p e r f o r m e d ,  parameters  kept  and a  and  di splayed. The  scientific  sputtering  f o r computer  p r o c e s s has a l s o  s u c h as t h e t a r g e t outgassing  need  rate,  erosion  and  f o r by e m p i r i c a l  relationships.  The  experimental parameter control  preparation  s c a n mode.  of t h e t a r g e t  reflective  coatings.  factors  factors  are d i f f i c u l t  usually  must  of t h e  f o r the f a b r i c a t i o n  be  part  sputtering of the in i t s  i n the I n t r o d u c t i o n , proven  to  parameter  become a r e g u l a r  has a l s o  PM  strength,  procedures, using MicroSput  voltage  p r o c e s s method  geometry  recalibration  As m e n t i o n e d  invaluable  field  c o n s t a n t s i n known  has  of t h e  A number o f  magnetic  holder  These  systematic  apparatus each experiment  shown.  profile,  substrate  reproduce each experiment. accounted  been  operation  t o be  computer  an  of c l e a r ,  infrared  REFERENCES  J.A. T h o r n t o n , J . V a c . S c i . T e c h n o l . j _ 5 , 171 ( 1 9 7 8 ) , and T h i n F i l m P r o c e s s e s , e d i t e d by J . L . V o s s e n and W. K e r n ( A c a d e m i c , New Y o r k , 1 9 7 8 ) , Chap. 1 1 - 2 . R.K. W a i t s , J . V a c . S c i . T e c h n o l . JJ5, 179 ( 1 9 7 8 ) , and T h i n F i l m P r o c e s s e s , e d i t e d by J . L . V o s s e n and W. K e r n ( A c a d e m i c , New Y o r k , 1 9 7 8 ) , Chap. I I - 2 . D.B. F r a s e r , and W. K e r n  i n T h i n F i l m P r o c e s s e s , e d i t e d by J . L . V o s s e n ( A c a d e m i c , New Y o r k , 1 9 7 8 ) , Chap. I I - 3 .  R. McMahon, J . A f f i n i t o , and R.R. P a r s o n s , J . V a c . T e c h n o l . 2 0 , 376 ( 1 9 8 2 ) . J.C.C. F a n a n d F . J . B a c h n e r , R. McMahon, S o l Note Winnipeg, 1980). S. M a n i v , 18,  195  3 (Solar  C. M i n e r , and W.D. (1981).  Appl. Optics Energy  VS, 1012  Socitey  Sci. (1976).  o f Canada,  Westwood, J . V a c . S c i . T e c h n o l .  Appendix A {@L-}  Interface  Uses S c r n B u f f ;  Type a n a _ i n f o  Ctrl  Part  f o r Unit  Parameter  {@L@}  = record { a l l times are i n chan_in: 1..16; { r a w _ i n p u t : - 1 2 0 0 0 . 12000 setpt: -12000..12000 { maxerr: - 1 . . 2 4 0 0 0 ; { s t a b l e : boolean; { scale_in: real end;  info = record { a l l times are dval_dt: real; setpoint: real; D: r e a l ; set_dspl: sb_dspl_ptr end;  param_ptr = param_info  :  Page  ticks } a n a l o g i n c h a n n e l number } { unsealed input value } w a i t f o r r e a d i n g <> s e t p t } by > maxerr } l a s t reading stable? } acutal units / m i l l i v o l t in  i n seconds } { measured d ( v a l u e ) / d t p e r sec } { desired control point } { calc'd derivative multiplier } { setpoint display info }  @param_info; record hard_name: s t r i n g [ 8 ] n e x t : param_ptr; name: s t r i n g [ 8 ] ; units: string[4]; i d : char; value: r e a l ; highlim: real; d e l a y : 0..maxint; warning: boolean; beep: b o o l e a n ; name_dspl: s b _ d s p l _ p t r val_dspl: sb_dspl_ptr; unit_dspl: sb_dspl_ptr read d a t a : r e a l  { f i x e d program l a b e l } p a r a m e t e r l i s t l i n k up } " name } units } " identifier } " value } which v a l u e mustn't exceed } (min) w a i t between s e r v i c e s } w a r n i n g message d i s p l a y e d ? } beep c o n s o l e e a c h s e r v i c e ? } : { name d i s p l a y i n f o } { value " " } : { units " " } l a t e s t v a l u e form r e a d f i l e }  Appendix  A  Interface  Part  for Unit  Parameter  read_next: param_ptr; { w r i t e _ n e x t : param_ptr; { measure: @ana_info; { if c o n t r o l : @ctrl info { if end; P r o c e d u r e PrmRead (param: p a r a m _ p t r ) ; { w a i t f o r c h a n _ i n r e a d i n g t o move from if control find dval_dt }  Page  r e a d d a t a v a l u e l i n k up write " " measured, p o i n t t o i n f o controlled, " "  stable,  scale i t ,  F u n c t i o n Prmlncrm (param: p a r a m _ p t r ) : r e a l ; { c a l c u l a t e d i f f e r e n t i a l c o n t r o l i n c r e m e n t f o r param } P r o c e d u r e PrmShow (param: p a r a m _ p t r ) ; { send v a l u e (& w a r n i n g message ?) t o s c r e e n , use P r o c e d u r e PrmAnaSet (param: param_p.tr); { c a l l - AnaSetBounds f o r measured c h a n n e l P r o c e d u r e PrmPoint ( s e t p t : { change g i v e n p a r a m e t e r ' s  }  real; param: p a r a m _ p t r ) ; s e t p o i n t t o (bounded) s e t p t  F u n c t i o n P r m L i s t : param_ptr; { p o i n t t o b e g i n n i n g of l i n k e d Procedure  up d e l a y t i c k s  list  of p a r a m e t e r s  }  }  Prmlnit  ( m o n i t o r _ i m a g e : sb_name; x_time, y_time, x_date, y_date, x_warn, y_warn: i n t e g e r ) ; { I n i t i a l i z e u n i t , g i v e name of p a r a m e t e r m o n i t o r s c r e e n and c o o r d i n a t e s of t i m e , d a t e & w a r n i n g d i s p l a y : d o n ' t c a l l from i n i t i a l i z a t i o n p a r t }  F u n c t i o n PrmGet ( f i x e d _ n a m e : sb_name): p a r a m _ p t r ; { i n i t i a l i z e named p a r a m e t e r : c a l l a f t e r P r m l n i t }  image  }  } } } }  Appendix  A  Interface  Part  for Unit  Procedure PrmEdited; { c a l l t o f l a g a p a r a m e t e r has been  Parameter  edited  }  Appendix {@L-}  A  Interface  Uses S c r n B u f f ,  Part  for Unit  Parameter;  PrmPrmpt  Function { prompt  PrmEdSet: p a r a m _ p t r ; f o r & read a parameter  Page  {@L@}  F u n c t i o n PrmNamed (name: sb_name): { r e t u r n w i t h named p a r a m e t e r } Function  ParaiiiUtil  param_ptr;  (x, y: i n t e g e r ; t i t l e : string; must_meas, m u s t _ c t r l : b o o l e a n ) : p a r a m _ p t r ; { PromptCapIn f o r a (measured a n d / o r c o n t r o l l e d ? ) p a r a m e t e r i d , u s i n g t i t l e : t o s t a r t t h e prompt; r e t u r n n i l when <esc> t y p e d o r not r u n n i n g } setpoint,  return  with a l t e r e d  param }  1  Appendix  A  Interface  Procedure PrmEdit; { interactively edit  Part  for Unit  system p a r a m e t e r s  ParamEdit  }  Appendix Procedure { s e t up  A  Interface  Part  for Unit  Walker  Page  1  ParamWalk; f o r w a l k i n g of a p a r a m e t e r  P r o c e d u r e wkHalt; { s a f e l y e x i t from w a l k i n g p r o c e s s  setpoint  between  two  bounds }  }  LD it.  Appendix  Var  A  Interface  param_time:  real;  P r o c e d u r e ParamReset; { r e s e t parameter read Function  ParamGet  { update  read  Procedure  file  Part  for Unit  ParamSav  { time of l a t e s t file  (wait_ok: record  parameter  input  read  record  }  } boolean):  (wait  boolean;  for i t ? ) , return  ParamFile;  { s e t up p a r a m e t e r  Page  & output  Procedure pfHalt; { s a f e l y shut down w r i t i n g p r o c e s s  files  }  }  true  i f not eof }  1  Appendix  A  Interface  Part  Procedure PlotSetup; { i n t e r a c t i v e l y s e t up and Procedure p l H a l t ; { s h u t down p l o t t e r  for Unit  Plotter  perform a p l o t  process }  }  Appendix  A  Interface  Part  for Unit  E12ISR  Page  { T h i s u n i t i s a memory and p o s i t i o n l o c k e d segment i n t e r n a l and/or E 1 2 d i g i o . I t i s not meant t o be used o t h e r w i s e . } Const  njumpsx3 = 2 1 ;  to  El2anaio  { 3 * # e n t r i e s i n i s r jump t a b l e }  Var { Assembler data a r e a s : t h e y may be c h a n g e d by  i n g e n e r a l t h i s d a t a i s not an i s r d u r i n g s u c h u s e . }  used  by  Pascal  { D a t a a c t u a l l y u s e d as Z80 o p c o d e s : } j u m p t a b l : p a c k e d a r r a y [1..njumpsx3] of 0..255; { jumps t o some u t i l i t y r o u t i n e s i n e l 2 i s r . a } { D a t a used by d i g i t a l i s r : } p u l s e : boolean; { d i g i t a l p u l s e i s on? } c u r r d i g : s e t of 0..15; { current d i g i t a l output } p l s q u i t : 0..maxint; { l s w o r d of t i m e t o t u r n o f f p u l s e } p l s d a t a , p l s m a s k : s e t of 0..15; { used t o end p u l s e } { D a t a used by a n a l o g i s r : } anabuff: a r r a y [1..16] of p a c k e d r e c o r d reading: integer; l a t e s t r e a d i n g of i n p u t } sum_count: 0..255; # r e a d i n g s summed f o r a v e r a g e c a l c ' n } s u m _ l s b y t e : 0..255; l e a s t s i g n i f i c a n t b y t e of t h a t sum } sum_msword: i n t e g e r ; most " word " " " } 11 : i n t e g e r ; l s w o r d of t i m e when d x / d t c a l c ' n done xO: i n t e g e r ; r e a d i n g a t t i m e tO } x 1 : integer; " tl } d e l t a _ t : 0..maxint; 11 -tO, w i l l be >= min_dt } ready: boolean; c h a n n e l i s beyond s e t p o i n t by m a x e r r ? setpoint: integer; check r e a d i n g a g a i n s t t h i s v a l u e } maxerror: i n t e g e r ; and s e t r e a d y i f s t r a y e d beyond }  as  Appendix  A  Interface  m i n _ d t : 0..255; priority: 0..8; filler: 0..3; i n v e r t : boolean; newddt: b o o l e a n end; Procedure  InitE12isr;  Part  { { { { {  for Unit  E12ISR  Page  dx/dt:= x1-x0 / t 1 - t 0 ok a f t e r min_dt } i f < 8, t r i g g e r e v e r y 2 * * p r i o r i t y p a s s } unused } invert this channel's reading? } d x / d t c a l c ' n u p d a t e d by l a t e s t i s r ? }  { must be c a l l e d  by E 1 2 d i g / a n a i o  initialization  }  Appendix A { digital outputs  Interface Part  f o r Unit  E12DigI0  Page  1  i n p u t / o u t p u t r o u t i n e s f o r E12 ( a l i a s G r e y B o x ) ; 0..7 a r e i n i t i a l i z e d & h a l t e d h i g h , 8:.15 low }  Type d i g w a i t = 0..maxint; d i g i t a l = s e t o f 0..15; { e . g . [1..3,7] means b i t s P r o c e d u r e DigRead (Var d a t a : { data:= input }  1, 2, 3, and 7 a r e s e t , 0, 4, 5, 6 and 8..15 a r e r e s e t  }  digital);  P r o c e d u r e D i g W r i t e ( d a t a , mask: d i g i t a l ) ; { o u t p u t : = ( d a t a i n t e r s e c t mask) union ( c u r r e n t output i n t e r s e c t (complement(mask)) Function DigPStat: digwait; { number of t i c k s r e m a i n i n g  i n curent  pulse  ) }  ( i f any) }  P r o c e d u r e D i g P u l s e ( d a t a , mask: d i g i t a l ; ticks: digwait); { D i g W r i t e ( d a t a , mask). A f t e r t i c k s / 60 s e c o n d s , interrupt w i l l DigWrite (complement(data), mask). D i g P u l s e must n o t be c a l l e d when D i g P S t a t i s > 0 } P r o c e d u r e D i g S t a t u s (Var d a t a : { data:= c u r r e n t output }  digital);  VD VD  Appendix  A  Interface  Part  for Unit  E12AnaI0  Page  { a n a l o g i n p u t / o u t u p t r o u t i n e s f o r E12 ( a l i a s G r e y B o x ) ; o u t p u t s a r e i n i t i a l i z e d & h a l t e d t o 0. N o t e t h a t a n a l o g i n p u t c a n ONLY be done u s i n g i n t e r r p u t s  1  }  Type a n a _ i n _ c h a n = 1..16; a n a _ i n _ r a n g e = - 12000..12000; a n a _ e r r _ r a n g e = -1 .. 24000; a n a _ m i n d t _ r a n g e = 1..255; a n a _ d x _ r a n g e = -24000..24000; ana_dt_range = K . m a x i n t ; a n a _ c h a n _ f l a g s = packed a r r a y [ a n a _ i n _ c h a n ] of b o o l e a n ; a n a _ p r i o r i t i e s = packed a r r a y [ a n a _ i n _ c h a n ] of 0..8; a n a _ c h a n _ s e t = s e t of 0..15; a n a _ i n _ t a b l e = a r r a y [ a n a _ i n _ c h a n ] of p a c k e d r e c o r d reading: ana_in_range; s u m _ l s b y t e , c o u n t : 0..255; sum_msword: i n t e g e r end; a n a _ o u t _ c h a n = 1..8; a n a _ o u t _ r a n g e = 0..4095; ana out t a b l e = a r r a y [ana out c h a n ] of ana out r a n g e ;  — —  •  Procedure  AnalnGo  Procedure  AnaSetBound  — —.  ——  (inverts: ana_chan_flags; priorities: ana_priorities); { Z e r o a l l i n t e r n a l i n p u t v a l u e s and i n t e g r a t i o n sum b u f f e r s . T u r n on i n t e r r u p t d r i v e n a n a l o g i n p u t p o l l i n g , p a s s i n g i n v e r t i n p u t v a l u e b o o l e a n s and c h a n n e l p r i o r i t y v a l u e s . At l e a s t one c h a n n e l ' s p r i o r i t y must be 0 ( h i g h e s t p r i o r i t y ) . C h a n n e l s of p r i o r i t y 8 w i l l not be t r i g g e r e d . } (channel: ana_in_chan; setpoint: ana_in_range; maxerror: ana_err_range;  o o  Appendix  A  Interface  Part  for Unit  Page  E12AnaI0  mindt: ana_mindt_range); { S e t a n a l o g i n p u t c h a n n e l s e t p o i n t and m a x e r r o r , minimum d t f o r d/dt c a l c u l a t i o n , r e s e t channel ready. I n i t i a l l y a l l setpoints a r e 0, a l l m a x e r r o r s a r e - 1 , and a l l m i n d t s a r e 30 t i c k s . } P r o c e d u r e AnaReady (Var r e a d y : a n a _ c h a n _ s e t ) ; { D e t e c t which a n a l o g i n p u t s have been r e a d s i n c e i n i t i a l i z a t i o n o r t h e l a s t AnaReady o r A n a l n S t a t u s , and c u r r e n t l y d i f f e r from t h e i r s e t p o i n t by more than t h e i r m a x e r r o r . Note t h a t c h a n n e l s a r e numbered from 0 t o 15 h e r e ! } Procedure  AnaRead  (channel: ana_in_chan; Var r e a d i n g : ana_in_range; Var d e l t a _ r e a d i n g : ana_dx_range; Var d e l t a _ t i m e : a n a _ d t _ r a n g e ) ; { Read c u r r e n t v a l u e of an a n a l o g i n p u t , and t h e d i f f e r e n c e s and t i m e of the l a s t two r e a d i n g s . }  P r o c e d u r e A n a l n S t a t u s (Var a n a _ i n p u t s : a n a _ i n _ t a b l e ) ; { Read a l l c u r r e n t v a l u e s of a n a l o g i n p u t s , dump i n t e g r a t i o n Procedure AnalnStop; { Turn o f f i n t e r r u p t d r i v e n  analog  input  P r o c e d u r e AnaWrite ( d a t a : ana_out_range; { Send d a t a t o a n a l o g o u t p u t c h a n n e l . }  polling. channel:  in value  sums. }  } ana_out_chan);  F u n c t i o n AnaOutRead ( c h a n n e l : a n a _ o u t _ c h a n ) : ana_out_range; { Read c u r r e n t v a l u e of a n a l o g o u t p u t c h a n n e l . } P r o c e d u r e A n a O u t S t a t u s (Var a n a _ o u t p u t s : a n a _ o u t _ t a b l e ) ; { Read a l l c u r r e n t v a l u e s of a n a l o g o u t p u t s . }  Appendix  Const  A  I n t e r f a c e Part  s c h _ h i b i t = 7; sch_hichan =16;  for Unit  { highest { highest  E12Sched  Page  numbered d i g i t a l i n p u t b i t } numbered a n a l o g i n p u t c h a n n e l  1  }  Type s c h _ b i t n o = 0 . . s c h _ h i b i t ; sch_channo = 1..sch_hichan; Procedure E12Start; { i n i t i a l i z e E12 d e v i c e  polling  }  Procedure WaitBit ( b i t : sch_bitno; value: boolean); { Wait f o r a d i g i t a l i n p u t b i t of g i v e n v a l u e . Successive are queued. }  calls  Procedure WaitAnalog (chan: sch_channo); { Wait f o r a n a l o g i n p u t chan t o d i f f e r from i t s s e t p o i n t by more t h a n +/- i t s m a x e r r o r . S u c c e s s i v e c a l l s are queued. }  o  Appendix  Var  A  Interface Part  ana_names:  Procedure  array  for Unit  [1..16] of  TrigAna  Page  string[8];  Triglnit;  { Read c h a n n e l  invert  and p r i o r i t i e s  Procedure TrigSetup; { I n t e r a c t i v e l y change a n a l o g  trigger  from d i s k ,  priorities  start  triggering  }  }  o  Appendix  A  Interface  Part  Procedure PlotBounds (xmin, { s e t s p l o t x 6 y ranges } Procedure Procedure Procedure Procedure  P l o t (x, y: PlotLift; PlotDrop; PlotAxes;  real);  for  xmax,  Unit  ymin,  { move { lift { drop { plot  PlotUtil  ymax:  Page  real);  pen t o x , y , w a i t f o r i t t o pen o f f c h a r t } pen o n t o c h a r t } r e c t a n g l e of s i z e bounds }  stop  }  o  Appendix  Type  Interface  strt_name  Procedure  {  A  look unit  =  Part  for  Unit  Starter  Page  1  string[8];  Strtlnfo  (unit_name, process_name: strt_name; var stack, p r i o : integer; call_from_initialization_part: boolean); u p s t a c k s i z e a n d p r i o r i t y f o r named p r o c e s s ( f r o m b o d y or from i n i t i a l i z a t i o n p a r t ? ) }  of  o  Appendix  A  Interface  Part  for Unit  { t y p e handshake v a r i a b l e s must be procedures }  DataBus  manipulated  Page o n l y by  calls  to DataBus  Type handshake = r e c o r d l o c k : semaphore; n_sync_acpt: 0..maxint; n_async_acpt: 0..maxint; a t t e n t i o n : semaphore; r e a d y _ f o r _ d a t a : semaphore; d a t a _ v a l i d : semaphore; d a t a _ a c c e p t e d : semaphore end; { Any number o f s o u r c e and a c c e p t o r p r o c e s s e s , w i t h any c o n v e n i e n t p r i o r i t i e s , may s h a r e one h a n d s h a k e . The s o u r c e h a n d s h a k e w a i t s f o r s y n c h ronous a c c e p t o r s o n l y . } P r o c e d u r e A c p t J o i n ( v a r h: h a n d s h a k e ) ; { c a l l to accept f i r s t synchronous data  }  P r o c e d u r e AcptHshk ( v a r h: h a n d s h a k e ; s y n c h r o n o u s : b'oolean); { c a l l t o a c c e p t a s y n c h r o n o u s o r o t h e r than f i r s t * s y n c h r o n o u s Procedure { call  AcptQuit  ( v a r h:  upon a c c e p t a n c e  and  data  }  handshake); use  of  last  desired  synchronous  data  }  P r o c e d u r e S r c e L o c k ( v a r h: h a n d s h a k e ) ; { c a l l t o e x c l u d e a l l o t h e r s o u r c e s from handshake, a l l o w d a t a c h a n g e } P r o c e d u r e SrceHshk ( v a r h: handshake; unlocked: boolean); { c a l l a f t e r data changed—unlocked i s t r u e i f f S r c e L o c k wasn't c a l l e d first }  Appendix  A  Interface  Part  for  Unit  DataBus  Page  2  Procedure Hshklnit (var h: handshake); { initialize type handshake }  o  Appendix  A  Type s c h _ c h s e t Var  Interface  = s e t of  Part  for Unit  Page  Schedule  1  char;  running: boolean; { The c o n d i t i o n of a l l r e p e a t i n g l o o p p r o c e s s e s - - r e s e t program and shut down a l l p r o c e s s i n g }  Procedure P o l l l n p u t s ; { S i g n a l p o l l i n g p r o c e s s t o check c l o c k , k e y b o a r d , the e x t e r n a l d e v i c e p o l l } Procedure DvceJoin; { Join external device  poll  synchronous a c c e p t o r s  and  t o end  the  SrceHshk  }  Procedure DvceAcpt (synchronous: boolean); { Accept e x t e r n a l d e v i c e p o l l } Procedure DvceQuit; { Leave e x t e r n a l d e v i c e  poll  synchronous a c c e p t o r s  Procedure WaitTick ( t i c k s : i n t e g e r ) ; { Wait f o r t i c k s / 6 0 s e c o n d s ( u n l i m i t e d number  of  }  callers)  F u n c t i o n WaitChar ( c h a r s : s c h _ c h s e t ) : char; { Wait f o r a c o n s o l e c h a r a c t e r i n t h e s e t c h a r s ( c a l l e r s and w i l l be s a t i s f i e d i n t h e i r c a l l s e q u e n c e ) }  } are  queued  o  00  Appendix A  Interface  Part f o r Unit  ReadKybd  Page  { R o u t i n e s f o r r e a d i n g keyboard, a l l o w i n g Schedule p r o c e s s e s w h i l e w a i t i n g f o r keyboard c h a r a c t e r }  to s i g n a l  competing  Type r k _ c h s e t = s e t o f c h a r ; rk_long_string = string[255]; Procedure CursBorrow; Procedure CursReturn; { A p r o c e s s w a n t i n g t o w r i t e t o t h e s c r e e n must C u r s B o r r o w , do t h e write without a task switch, CursReturn } F u n c t i o n ReadCharln (return_on_match: r k _ c h s e t ) : char; Function FetchCharln (x,y: integer; return_on_match: r k _ c h s e t ) : char; { R e t u r n w i t h c h a r when a c h a r i n r e t u r n on_match has been t y p e d . The c h a r i s n o t e c h o e d t o t h e s c r e e n . T Function Function Function  ReadCapIn ( r e t u r n _ o n _ m a t c h : r k _ c h s e t ) : c h a r ; FetchCapIn (x,y: i n t e g e r ; return_on_match: r k _ c h s e t ) : char; PromptCapIn ( x , y : i n t e g e r ; prompt: rk l o n g _ s t r i n g ; return_on_match: rk_chsetT: c h a r ; { R e t u r n w i t h c h a r when a c h a r i n r e t u r n _ o n _ m a t c h has been t y p e d . A l p h a b e t i c c h a r s a r e c o n v e r t e d t o upper c a s e . The c h a r i s n o t echoed t o the s c r e e n . In t h i r d c a s e , f i r s t send prompt t o x,y, b r o k e n i n t o s e v e r a l p i e c e s by ' ' i f n e c e s s a r y , r o t a t i n g t h e p i e c e s when '?' i s t y p e d }  F u n c t i o n ReadBoolean: boolean; Function FetchBoolean (x,y: i n t e g e r ) : boolean; { ReadCapIn ( [ ' T ' , ' F ' ] ) , echo ' t r u e ' o r ' f a l s e '  }  Function Readlnteger (field,min,max: i n t e g e r ) : integer; Function F e t c h l n t e g e r (x,y,field,min,max: i n t e g e r ) : i n t e g e r ; { R e t u r n w i t h an i n t e g e r between min and max r i g h t j u s t i f i e d i n a f i e l d of g i v e n width }  Appendix  A  Interface  Part  f o r Unit  ReadKybd  Page  F u n c t i o n ReadReal ( f i e l d , d e c _ f i e l d : i n t e g e r ; min,max: r e a l ) : r e a l ; Function FetchReal ( x , y , f i e l d , d e c _ f i e l d : integer; min,max: r e a l ) : r e a l ; { R e t u r n w i t h a r e a l between min and max r i g h t j u s t i f i e d i n a f i e l d of g i v e n w i d t h w i t h d e c _ f i e l d f o l l o w i n g t h e d e c i m a l } Function ReadFloat ( f i e l d : integer; min,max: r e a l ) : r e a l ; Function FetchFloat (x,y,field: integer; min,max: r e a l ) : r e a l ; { R e t u r n w i t h a r e a l between min and max r e a d a s m a n t i s s a and exponent } P r o c e d u r e R e a d S t r i n g ( v a r s: s t r i n g ; Procedure F e t c h S t r i n g (x,y: integer; { R e t u r n w i t h new s t r i n g o f l e n g t h Procedure rkHalt; { C a l l upon p r o g r a m end t o r e t u r n  f i e l d : integer); v a r s: s t r i n g ; field: integer); <= f i e l d i n v a r i a b l e s } from a l l C u r s B o r r o w  waits }  Appendix  A  { process  Interface data  Part  d i s p l a y and  for Unit screen  ScrnBuff  image l i f o  Page stacking  routines  }  Type sb_name = s t r i n g [ 8 ] ; sb_prmt_no = 0..255; sb_prmt = s t r i n g f 2 5 5 ] ; s b _ p r m t _ p t r = @sb_prmt; sb_format = packed r e c o r d s c r n _ v a l i d : boolean; { s c r e e n image d i s p l a y e d ? } enabled: boolean; { data d i s p l a y enabled? } new_data: b o o l e a n ; { d i s p l a y e d v a l u e out of d a t e ? } x: 0..79; { c o l o f s t a r t of d a t a f i e l d } y: 0..23; { row o f d a t a f i e l d } f i e l d : 0..80; { s i z e of " " } d e c _ f i e l d : 0..79; for sb_re: # decimal places } f l o a t : boolean " ": s c i e n t i f i c n o t a t i o n } { end; s b _ k i n d = ( s b _ b o o l , s b _ i n t , s b _ r e , s b _ s t n g , sb_now); s b _ d s p l _ p t r = @sb_dspl; sb_dspl = record next_dspl: sb_dspl_ptr; { internal linkup } f o r m a t : sb f o r m a t ; { display information } { data type, value } c a s e k i n d : s b _ k i n d of sb b o o l : (b: b o o l e a n ) (i: integer) sb' i n t : (r: real); sb" r e : sb_stng: (s: s t r i n g ) end; Function  sbLink  (image: sb_name; fmt: s b _ f o r m a t ; k: s b _ k i n d ) : s b _ d s p l _ p t r ; { C r e a t e the named k i n d of d a t a , i n i t i a l i z e f o r m a t ( t y p e s b _ s t n g have maximum s l e n g t h of f m t . f i e l d ) , l i n k i n t o image's d i s p l a y { sbToss procedures:  i f value  <>  data_ptr.value  then  copy v a l u e ,  will list Toss  }  Appendix A  Interface  Part  for Unit  ScrnBuff  Page  a s soon as s c r e e n image i s v a l i d ; s t r i n g uses v a r i a b l e value t o reduce needed stack s i z e ; now u s e s c l o c k r e a d i n g - TO a t t o s s t i m e } Procedure sbTossBoolean (value: boolean; data_ptr: sb_dspl_ptr); Procedure sbTossInteger (value: integer; data_ptr: sb_dspl_ptr); Procedure sbTossReal (value: r e a l ; data_ptr: sb_dspl_ptr); Procedure sbTossString (var value: s t r i n g ; data_ptr: sb_dspl_ptr); P r o c e d u r e sbTossNow (data_ptr: sb_dspl_ptr); Procedure sbDisable (data_ptr: sb_dspl p t r ) ; { d i s a b l e d i s p l a y (sbToss re-enables) T P r o c e d u r e S c r n E n t e r (name: sb_name); { S c r n C l e a r , a c t i v a t e named s c r e e n image i s 'NIL'), S c r n R e f r e s h i t }  (or blank  screen  i f name  F u n c t i o n ScrnPrompt (prompt_num: s b _ p r m t _ n o ) : sb_prmt_ptr; { P o i n t t o g i v e n prompt ( >= 0 ) of a c t i v e s c r e e n image } Procedure  ScrnClear;  { scClrScreen Procedure { Write  (and n o t e a c t i v e s c r e e n  not v a l i d ) }  ScrnRefresh;  a c t i v e screen  image l i n e s  1..23  (clear  screen  i f none) }  Procedure ScrnReturn; { S c r n C l e a r , r e - a c t i v a t e whatever image was a c t i v e b e f o r e ScrnEnter, ScrnRefresh i t } Procedure sbHalt; { c a l l t o h a l t data d i s p l a y p r o c e s s i n g }  last  2  Appendix A { clock  Interface reading  Part  utilities  f o r Unit  Clock  }  Type t i m _ r e c = r e c o r d hiword, loword: i n t e g e r { two's complement 32 b i t i n t e g e r } tim_hms = s t r i n g [ 8 ] ; Var  tim_ovflw: boolean; { TimAdd & TimMinus o v e r f l o w  Procedure TimReset;  { reset  flag  F u n c t i o n Tim_aLTb (a,b: { result:= a < b }  to 0 }  a,b: t i m _ r e c ) ;  tim_rec;  tim_rec):  end;  }  system c l o c k  P r o c e d u r e TimAdd ( v a r sum: t i m _ r e c ; { sum:= a + b } P r o c e d u r e TimMinus ( v a r d i f f : { diff:= a - b }  Page  a,b: t i m _ r e c ) ;  boolean;  Function TimArrived ( t : t i m _ r e c ) : boolean; { r e s u l t : = t <= c l o c k r e a d i n g } Function TimlnSeconds ( t : t i m _ r e c ) : { r e s u l t : = t i n seconds }  real;  Procedure TimOfSeconds ( v a r t : t i m _ r e c ; { t:= r , where r i s i n s e c o n d s }  r: real);  -'  P r o c e d u r e TimlnHMS ( v a r hms: tim_hms; t : tim_rec); { c o n v e r t t t o hh:mm:ss, 00:00:00 <= hms <= 99:59:59 } Procedure  TimSetTO;  1  Appendix  { read  A  clock,  Interface  Part  let result  be  for Unit  Clock  known as  tO  P r o c e d u r e TimSubTO ( v a r t : t i m _ r e c ) ; { r e t u r n w i t h c l o c k r e a d i n g - tO }  }  Page  Appendix  A  I n t e r f a c e Part  f o r Unit ErrMessg  Function ErrorNoted: boolean; { T r u e i f f N o t e E r r o r has been c a l l e d .  }  P r o c e d u r e N o t e E r r o r (n, i n f o : i n t e g e r ; immediate: b o o l e a n ) ; { W r i t e n ' t h e r r o r message ( i n c l u d i n g i n f o as p a r t of t h e message) from e r r o r l o g upon program h a l t ( o r i m m e d i a t e l y & h a l t ) . }  Page  1  Appendix  A  Interface Part  for Unit  MiscFunc  Page  { power o f 10 f u n c t i o n s } F u n c t i o n TenToThe (x: r e a l ) : r e a l ; { I0**r } F u n c t i o n Log ( r : r e a l ) : r e a l ; { base 10 l o g a r i t h m  • }  { signum f u n c t i o n s } F u n c t i o n rSgn ( r : r e a l ) : r e a l ; { i f r<0.0 t h e n -1.0 F u n c t i o n iSgn ( i : i n t e g e r ) : i n t e g e r ; { i f i<0 t h e n -1 { min and max F u n c t i o n rMin F u n c t i o n rMax F u n c t i o n iMin F u n c t i o n iMax  else else  1.0 } 1 }  functions } (a,b: r e a l ) : r e a l ; { i f a<b t h e n a e l s e b } (a,b: r e a l ) : r e a l ; { i f a>b t h e n a e l s e b } (a,b: i n t e g e r ) : i n t e g e r ; { i f a<b t h e n a e l s e b } (a,b: i n t e g e r ) : i n t e g e r ; { i f a>b t h e n a e l s e b }  { limiting functions } F u n c t i o n rBounded ( r , min, max: r e a l ) : r e a l ; { rMax F u n c t i o n rAbsBndd ( r , bound: r e a l ) : r e a l ; { rBounded F u n c t i o n iBounded ( i , min, max: i n t e g e r ) : i n t e g e r ; { F u n c t i o n iAbsBndd ( i , bound: i n t e g e r ) : i n t e g e r ; {  (min, r M i n ( r , m a x ) ) } ( r , -bound, bound) } i n t e g e r rBounded } i n t e g e r rAbsBndd }  { unsigned integer functions } F u n c t i o n usiAdd (a,b: i n t e g e r ) : i n t e g e r ; { a + b } F u n c t i o n usiMinus (a,b: i n t e g e r ) : i n t e g e r ; { a - b } { character Function  functions  UpperChar  }  (c: char): char;  { string functions } P r o c e d u r e U p p e r c a s e (Var s: s t r i n g ) ;  { change c t o upper  { change  s t o upper  case  case  }  }  Appendix  { Extra {@L-}  A  Interface  Part  f o r Unit  ExtraScr  ScreenOps r o u t i n e s }  Uses S c r e e n O p s ;  {@L@}  F u n c t i o n MapCommandKey  (command: sc_key_command; call_from_initializion_part: boolean): char; { I n v e r s e of scMapCrtCommand: c a l l s t o t h i s f u n c t i o n must have the s e c o n d p a r a m e t e r t r u e i f made from an i n i t i a l i z a t i o n p a r t }  P r o c e d u r e MapDate ( v a r d a t e : * s t r i n g ) ; { r e t u r n w i t h t h e c u r r e n t d a t e a s 'dd-mmm-yy' }  Page  1  Appendix  A  Interface  { procedures  t o send  Part  f o r Unit  WritCons  formatted values to c o n s o l e : }  P r o c e d u r e W r i t e B o o l e a n (b: b o o l e a n ) ; P r o c e d u r e T o s s B o o l e a n (x, y : i n t e g e r ; b: b o o l e a n ) ; { w r i t e a b o o l e a n v a l u e as ' t r u e ' or ' f a l s e ' } F u n c t i o n WriteNot (b: b o o l e a n ) : boolean; F u n c t i o n T o s s N o t (x, y: i n t e g e r ; b: b o o l e a n ) : b o o l e a n ; { r e s u l t : = not b, W r i t e B o o l e a n ( r e s u l t ) } Procedure WriteBlanks ( f i e l d : i n t e g e r ) ; P r o c e d u r e T o s s B l a n k s (x, y, f i e l d : i n t e g e r ) ; { write f i e l d blanks } Procedure WriteErase ( f i e l d : i n t e g e r ) ; P r o c e d u r e T o s s E r a s e (x, y, f i e l d : i n t e g e r ) ; { WriteBlanks ( f i e l d ) , return cursor to s t a r t i n g Procedure { write Procedure { write  position  }  WriteLeft ( f i e l d : integer); f i e l d backspaces without e r a s i n g } WriteBackspaces ( f i e l d : i n t e g e r ) ; f i e l d b a c k s p a c e s , e r a s i n g c h a r a c t e r s a l o n g t h e way  P r o c e d u r e T o s s l n t e g e r (x, y, i , f i e l d : i n t e g e r ) ; { move c u r s o r t o x,y and w r i t e i r i g h t j u s t i f i e d given width }  in a  field  }  of  Procedure WriteReal ( r : r e a l ; field, dec_field: integer); P r o c e d u r e T o s s R e a l (x, y: i n t e g e r ; r: r e a l ; field, dec_field: integer); { w r i t e r r i g h t j u s t i f i e d i n a f i e l d of w i d t h f i e l d w i t h d e c _ f i e l d a f t e r the d e c i m a l . I f d e c _ f i e l d = 0 , t h e r e a l w i l l be w r i t t e n as an i n t e g e r . r i s rounded t o the d e c C h a r ' t h d i g i t b e f o r e w r i t i n g } Procedure WriteFloat  (r: real;  field:  integer);  Appendix A  Interface  Part  for Unit  WritCons  Page  P r o c e d u r e T o s s F l o a t (x, y: i n t e g e r ; r: real; field: integer); { write r in s c i e n t i f i c n o t a t i o n r i g h t j u s t i f i e d a f i e l d of b l a n k s } P r o c e d u r e T o s s C h a r (x, y: i n t e g e r ; ch: char); { s e n d c u r s o r t o x,y and w r i t e c h : 1 } Procedure W r i t e S t r i n g (s: s t r i n g ; field: integer); P r o c e d u r e T o s s S t r i n g (x, y: i n t e g e r ; s: s t r i n g ; field: { w r i t e s ( i f f i e l d > 0 then l e f t j u s t i f i e d in a f i e l d  integer); of b l a n k s ) }  2  Appendix 3 4 5 232 4 15 56 1 586 597 598 599 600 601 602 603 604 605 606 607 608 609 6 10 61 1 612 6 13 614 615 6 16 617 618 619 620 62 1 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638  B 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2 1 21 2 1 2 1 2 1 2 1 21 2 1 21 2d 2 1 2 1  Compiler 0: d 1 :d 1 :d 1 :d 1 : d 1 : d 1 :d 1 :d 1 :d 1 :d 1 :d 1 :d 1 :d 1 • d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 :d 1: d 1 :d 1 :d 1 :d 2 :0 2: 1 1 :0 1 :0 1 :d 3 :0 3: 1 3: 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 13 15 16 19 20 28 28 28 1 1 1 1 1 1 1 1 1 1 2 5 6 6 0 0 . 0 0 1 0 0 3  Listing  of Program  Page  Sputter  1  {$L remout:} Program S p u t t e r ; Uses  <$L-> <$L-> <$L-> <$L->  Const  x_time x_date x warn hi_gas  ScreenOps, E x t r a S c r . S c h e d u l e . ReadKybd. S c r n B u f f . <$L<5>} M i s c F u n c , E 1 2 d i g I 0 . E12AnaI0. T r i g A n a , W r i t C o n s . {$L@> C l o c k , P a r a m e t e r , P a r a m U t i l , P a r a m E d i t , W a l k e r . <$Lia} ParamSave. P l o t t e r , <$L®> <$U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; {$L(S} ==== ==  17 17 1 1 2;  y time = y d a t e = 17 y warn = { highest  < display { " { "  p o s i t i o n f o r time > " " date > " -. " warning  }  T y p e gas_num -= 0. h i _ g a s ; Var  s p l y _ c t r l , c u r r e n t , v o l t a g e , power, a n o d e , e x t r a l . e x t r a 2 : param_ptr; gas: array[gas_num] of param_ptr; power_ready: semaphore; power_noted: boolean;, backlash: array[gas_num] of integer; com: char; C t r l . d C t r l d i . d C t r l dV. d C t r l _ d W : real;  Process Process Process Process Process Process  pressure.  rf_bias,  forward; CurrTask; forward; VoltTask; forward; WattTask; forward; PresTask; forward; gas_num) GasTask (n MeasTask (param: p a r a m _ p t r ) ; forward;  Segment P r o c e d u r e Sputlnit; C o n s t u_name = ' S p u t t e r ' ; Var p i d : p r o c e s s i d ; n, s t a c k , p r i o : integer; num: s t r 1 n g [ 1 ] ; P r o c e d u r e G e t S t r t l n f o (param: p a r a m _ p t r ) ; Begi n S t r t l n f o (u_name, p a r a m ® h a r d name, s t a c k , End; < of G e t S t r t l n f o > P r o c e d u r e M e a s S t r t (param: Begin GetStrtlnfo (param); s t a r t (MeasTask (param).  p r i o.  f a 1se)  param_ptr);  p i d . stack,  prio) O  Appendix 639 640 64 1 642 643 644 645 646 647 648 649 650 65 1 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 67 1 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688  Compiler  B  2 1 2 1 2 1 21 2 1 2 1 21 21 21 2 1 2 1 2 1 21 2 1 2 1 2 1 2 1 2 1 21 21 21 2 1 2 1 21 2 1 21 21 2 1 2 1 2 1 2 1 2 1 2 1 2 1 21 21 21 21 21 21 2 1 2 1 2 26 26 26 26 26 26 26  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1  0 0 0 1 1 1 1 1 1 1 1 1 2 3 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 2 1 1 1 1 0 0 0 d d d 0 1 1 1 0  0 0 0 0 18 32 43 54 65 76 87 98 107 107 1 18 158 167 178 189 200 212 2 15 232 235 252 255 272 275 278 295 326 335 335 346 367 372 375 378 381 0 0 0 1 1 1 0 0 4 68 0  Listing End;  Page  of Program S p u t t e r { of MeasStrt  }  Begin < * * * S p u t l n i t *** } 0.4; dCtrl_dW: d C t r l _ d I : = 5.6; d C t r l _ d V : = 0.40; date, P r m l n i t ('Sputter'. x_time. y_time, x date. s p l y _ c t r l ; = PrmGet ( ' s p l y e t r 1 ' ) ; c u r r e n t : = PrmGet ( ' c u r r e n t ' ) ; v o l t a g e : = PrmGet ( ' v o l t a g e ' ) ; power : = PrmGet ( ' p o w e r ' ) ; anode:= PrmGet ( ' a n o d e ' ) ; p r e s s u r e : = PrmGet ( ' p r e s s u r e ' ) ; f o r n:= 0 t o h i _ g a s do Beg i n s t r ( n . num ) : g a s [ n ] : = PrmGet ( c o n c a t ( ' g a s [ ' , r ]' )) End; { of f o r ) r f _ b i a s : = PrmGet ( ' r f b i a s ' ) ; e x t r a 1 : = PrmGet ( ' e x t r a t ' ); e x t r a 2 : = PrmGet ( ' e x t r a 2 ' ) ; power_noted:= t r u e ; s e m i n i t ( p o w e r _ r e a d y , 0) GetStrtlnfo (current); s t a r t (CurrTask, p i d . stack, p r i o ) ; GetStrtlnfo (voltage); s t a r t (VoltTask, p i d , stack, p r i o ) ; GetStrtlnfo (power); s t a r t (WattTask, p i d , s t a c k , p r i o ) ; MeasStrt (anode); GetStrtlnfo (pressure): s t a r t (PresTask, p i d , stack, p r i o ) ; b a c k l a s h [ 0 ] : = 23;* 'back 1ash[ 1 ] : = 67; b a c k l a s h [ 2 ] : = f o r n:= 0 t o h i _ g a s do Begin GetStrtlnfo (gas(n]); s t a r t (GasTask ( n ) , p i d . s t a c k , p r i o ) End; ( of f o r ) MeasStrt (rf_bias); MeasStrt (extral); MeasStrt ( e x t r a 2 ) ; S c r n E n t e r (u_name) End; < o f Segment S p u t l n i t >  Segment P r o c e d u r e S p u t E d i t (c:- c h a r ) : Procedure E d i t D C t r l (id:char; v a r d c t r 1 dx: r e a l ) ; { e d i t supply control gain ) Beg i n scEraseToEol (0.0); ' ] w r i t e ( ' d C t r l / d ' , i d , ' ['. d C t r l dx:8, d C t r l _ d x : = R e a d F l o a t ( 8 , 1.0E-30, 1 .0E30) End; { of E d i t D C t r l >  warn,  22;  y_warn);  2  Appendix 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 7 10 7 1 1 712 713 714 715 7 16 7 17 7 18 7 19 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738  B  26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 .2 2 2 2 2 2 2  Compiler 1 1 1 1 1 1 1 1 t 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 8 8 1 1 1 1 9 9 9 9 9 9 9 9 9 9 9 9  0 1 1 2 2 2 2 2 3 3 3 3 3 3 2 1 3 3 3 3 3 2 0 0 0 0 d d 0 1 2 3 3 2 0 0 0 d d 0 1 2 2 2 3 4 4 4 3 1  0 0 1 8 13 25 30 35 38 43 55 63 71 75 82 87 89 91 94 99 1 19 130 0 0 0 0 1 1 0 0 7 7 12 26 0 0 0 1 1 0 0 0 5 1 1 18 18 25 32 37 39  Listing Begin if c then  of  Program  Sputter  Page  =  ' E ' C a s e P r o m p t C a p I n ( 0 , 0. 'Edit: Parameters T(riggers d.c.S(upply R(eturn', ['P','T','S','R']) of ' P ' : PrmEdi t ; ' T ' : Tr i gSetup: 'S': C a s e P r o m p t C a p I n ( 0 , 0, 'Supply Gain: Hcurrent V(oltage Wfpower', [ ' I ' , 'V. 'W]) of 'I': E d i t D C t r l ('I'. d C t r 1 _ d I ) : 'V: E d i t D C t r l ('V. dCtrl_dV); 'W: E d i t D C t r l {'VI', dCtrl_dW) End { o f 'M' > End { o f 'E' } e l s e Begin ScrnClear; com:= P r o m p t C a p I n ( 0 , 0, ' R f e t u r n t o o r <esc>ape f r o m M i c r o S p u t : ' , tMapCommandKey ( s c _ e s c a p e _ k e y , f a l s e ) , ' R ' ] ) ; i f (com = 'R') a n d r u n n i n g t h e n ScrnRefresh End { o f '0' > End; { o f Segment S p u t E d i t )  P r o c e d u r e D i s a b l e C t r l (param: p a r a m _ p t r ) ; { d i s a b l e c o n t r o l o f param ( c a l l o n l y when i n ' S p u t t e r ' s c r e e n Begin w i t h p a r a m ® . c o n t r o l @ . s e t _ d s p l <°>. f o r m a t do Beg i n enabled:= f a 1se; T o s s B l a n k s ( x , y, f i e l d ) End { of i f , w i t h } End; { of D i s a b l e C t r l >  Procedure GetSetpoints; V a r param: param_ptr: Beg i n Repeat param:= PrmEdSet; i f (param = c u r r e n t ) or (param = o r (param = p o w e r ) t h e n Beg i n i f param <> c u r r e n t then i f param <> v o l t a g e then i f param <> power then End { o f param i s s u p p l y } Unt i1 param = n i l ;  voltage)  DisableCtrl DisableCtrl DisableCtrl  (current); (voltage); (power)  image)  Appendix 739 740 74 1 742 743 744 745 74S 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 77 1 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788  Compiler  B 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  1 1 1 1 10 10 10 10 10 10 1 1 1 1 11 11 11 11 11 11 11 11 11 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 1 1 3 3 3 3 3 3 3 3 1 1  0 0 0 d 0 1 2 3 3 2 0 0 0 d d 0 1 2 3 3 3 3 2 0 0 0 d 0 1 2 3 3 3 3 2 1 0 0 0 d 0 1 2 3 3 3 3 2 0 0  0 0 0 1 0 0 3 3 6 9 0 0 0 1 1 0 0 2 2 23 44 54 60 0 0 0 1 0 2 7 7 1 1 23 25 31 36 ' 0 0 0 1 0 2 7 7 1 1 23 25 31 0 0  L i s t i n g o f Program End:  Page  Sputter  { of G e t S e t p o i n t s }  Procedure PowerAttn; Beg i n i f power n o t e d t h e n Beg i n power_noted:= f a l s e ; signal (power_ready) End { of if} End; { of PowerAttn >  .  Procedure C t r l S p l y ( d C t r l : r e a l ) ; C o n s t c h a n _ o u t = 8; Beg i n w i t h s p l y c t r l @ do Begin v a l u e : = r B o u n d e d ( v a l u e + d C t r l , 0.0, 10.0) AnaWrite (round (409.5*value ) , chan_out); d e l a y : = 0; if running then PrmShow ( s p l y _ c t r l ) End < of w i t h > End; < of C t r l S p l y >  Process CurrTask; Beg 1 n wh i 1 e r u n n i ng do Beg i n PrmRead ( c u r r e n t ) ; C t r l S p l y ( d C t r l _ d I * Prmlncrm ( c u r r e n t ) ) ; PowerAt t n ; if running then PrmShow ( c u r r e n t ) End; < o f whi1e ) signal (power_ready) End; { of CurrTask )  Process VoltTask; Beg i n w h i l e r u n n i n g do Begi n PrmRead (voltage); C t r l S p l y ( d C t r l _ d V * Prmlncrm (voltage)); PowerAt t n ; if running then PrmShow ( v o l t a g e ) End { o f whi1e } End; { of V o l t T a s k >  4  Appendix 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 8 1 1 812 813 8 14 8 15 8 16 8 17 818 819 820 82 1 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838  B 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 1 4 4 4 4 4 4 4 4 4 4 4 1 1 1 1 5 5 5 5 12 12 12 12 12 12 12 12 12 12 12 12 12 12 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5  0 d 0 1 2 3 4 4 4 4 4 4 3 O 0 0 d d d d d 0 1 1 1 1 1 1 1 2 3 3 3 4 2 0 0 0 1 1 1 2 3 4 4 5 6 6 6 7  0 1 0 2 8 13 13 19 32 40 53 65 71 0 0 0 1 1 2 3 3 0 0 7 1 1 20 32 39 47 59 59 74 92 97 103 0 0 0 2 8 10 14 19 19 23 28 28 32 34 47  Listing  of Program  Sputter  Page  P r o c e s s WattTask; Beg i n w i t h p o w e r s , c o n t r o l ? do w h i l e r u n n i n g do Begin wait (power_ready): power_noted:= true; v a l u e : = v o l t a g e ® . v a 1 u e * c u r rentes . v a 1 u e : dval dt:= voltage®.value * current®.control®.dva1_dt + current®.va1ue * voltage®.contro1®.dva1_ C t r l S p l y ( d C t r l _ d V * Prmlncrm (power)); i f running then PrmShow ( p o w e r ) End { of while } End; { of WattTask >  Process PresTask; Var range: integer; mask: d i g i t a l ; P r o c e d u r e ChangeRange ( i : i n t e g e r ) ; Beg i n range:= range i ; Case range of 3: D i g W r i t e (mask, mask); 2: D i g W r i t e ( [ 6 ] , mask); 1: D i g W r i t e ( [ 5 ] , mask) End; { of Case } w i t h p r e s s u r e ® , m e a s u r e ® , v a 1 _ d s p 1 ® . f o r m a t do Beg i n s c a l e in:= s c a l e _ i n * TenToThe ( i ) ; dec f i e 1 d : = d e c _ f i e l d - i ; if running then W a i t T i c k (60 - d e l a y ) { a l l o w meter t o s e t t l e End .{ o f w i t h } End: { o f ChangeRange ) +  Begi n mask:= [ 5 , 6 ] ; r a n g e : = 3; w i t h p r e s s u r e ® . m e a s u r e ® do w h i l e r u n n i n g do Beg i n PrmRead ( p r e s s u r e ) ; if running then Begi n PrmShow ( p r e s s u r e ) ; i f r a w _ i n p u t < 1000 then i f range > 1 then e l se  ChangeRange  (-1)  )  Appendix 839 840 84 1 842 843 844 845 846 847 848 849 850 85 1 852 853 854 855 856 857 858 859 860 86 1 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 88 1 882 883 884 885 886 887 888  B 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 5 :6 5 :7 5 :5 5 :3 5 •1 1 0 1 0 1 0 1 d 6 d 6 d 6 d 6 d 6 d 6 O 6 1 6 1 6 1 6 1 6 1 6 1 6 1 6 1 6 2 6 3 6 3 6 4 6 5 6 5 6 7 6 8 6 8 6 8 6 9 6 0 6 O 6 1 6 1 6 9 6 .0 6 :0 6 :8 6 :9 6 :0 6 :0 6 :9 6 :0 6 :0 6 : 1 6 : 1  51 55 67 69 71 0 0 0 1 1 1 1 2 5 0 2 7 10 17 24 24 34 40 46 46 58 64 64 85 107 107 124 128 131 139 149 157 167 177 185 195 212 215 223 233 243 251 261 269 279  L i s t i n g of  Program  Page  Sputter  else i f raw_input then i f range < End { of i f r u n n i n g End; { of w h i l e } ChangeRange ( 3 - r a n g e ) { End; { of P r e s T a s k >  > 11500 3 then ChangeRange > ensure  param  info  (1)  saved  on  gas_num) }; P r o c e s s GasTask { (n C o n s t move_open = 3 ; m o v e _ c l o s e = 2; Var p u l s e : i n t e g e r ; 1ast_move: d i g i t a l a d d r e s s , move_mask rea 1 ; d f , d t _ d f , 1imi t e d Beg i n last_move:= [move_openJ; Case n of ( a d d r e s s v a l v e w i t h a c t i v e low } address:= [0,1]; 0 address:= HI: 1 address:= [0] 2 { of C a s e > End; d f : = 0.0; wh i 1 e r u n n i n g do Beg i n PrmRead ( g a s [ n ] ) ; i f r u n n i n g then Beg i n df:= df + Prmlncrm ( g a s [ n ] ) ; i f df <> 0.0 t h e n w i t h g a s [ n ] © do Begin { non-linearity } limited: rBounded ( v a l u e , 0.01, h i g h l i m ) ; Case n of 0: i f d f > 0.0 then 1f 1im1 t e d >= 0.555 then d t _ d f : = 9.6 / l i m i t e d else i f l i m i t e d >= 0 . 0 9 2 * then d t _ d f : = 15.1 / l i m i t e d else d t _ d f : = 27.8 / l i m i t e d else i f l i m i t e d >= 2.00 then d t _ d f : = 21.7 / l i m i t e d else d t _ d f : = 15.2 / l i m i t e d ; 1: i f d f > 0.0 then i f l i m i t e d >= 0.698 then d t _ d f : = 10.9 / l i m i t e d else d t _ d f : = 16.7 / l i m i t e d else i f l i m i t e d >= 3.91 then d t _ d f : = 34.5 / l i m i t e d else i f l i m i t e d >= 0.272 then d t _ d f : = 21.3 / l i m i t e d else d t d f : = 16.7 / l i m i t e d ; 5  range.3  }  Appendix 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 91 1 912 913 914 915 916 917 9 18 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938  B 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 6 :8 6: 9 6 :0 6 :0 6 :: 1 6 :: 1 6: 9 6 :0 6 :0 : 6 :: 1 6 ;; 1 6:8 6 :8 ; 6: 8 6 :9 6 :0 6 :0 6::0 6 :0 6 :0 : 6: 2 6: 2 6 : 1' 6 :0 6 :0 6 :0 6 :0 6 :0 6: 1 6: 2 6: 2 6: 1 6 :9 6: 7 6 :5 6: 4 6: 2 1 :0 1 :0 1 :0 1: d 1 :d 7 :0 7: 1 7: 2 7: 3 7: 3 7: 2 1 :0 1 :0  295 298 306 316 324 334 344 352 362 370 380 390 399 407 4 16 4 16 428 438 439 443 450 455 455 458 477 492 500 513 520 520 525 539 54 1 54 1 54 1 555 558 0 0 0 1 1 0 2 7 7 1 1 17 0 0  L i s t i n g of Program  Sputter  2:  i f d f > 0.0 then i f l i m i t e d >= 0.406 then d t d f : = 6.10 / l i m i t e d else i f 1 I m i t e d >= 0.169 then d t _ d f : = 9.52 / l i m i t e d else d t _ d f : = 11.2 / l i m i t e d else i f 1im i t e d >- 1.15 then d t _ d f : = 55.6 / l i m i t e d else i f l i m i t e d >= 0.474 then d t d f : - 30.3 / l i m i t e d else d t _ d f : = 13.9 / l i m i t e d End: < of Case > pulse:= round ( d f * d t _ d f ) ; i f r u n n i n g a n d ( p u l s e <> 0 ) t h e n Beg i n df:= df - p u l s e / d t _ d f : pulse:= lAbsBndd ( p u l s e , d e l a y d i v 5 ) ; if pulse > 0 then move_mask:= [move_open] e l s e Begin move mask:= [ m o v e _ c l o s ] ; pulse:= - p u l s e End; i f l a s t move <> move_mask t h e n pulse:= p u l s e w h i l e D l g P S t a t <> 0 do WaitTick (DigPStat); DigWrite (address, [0,1]); D i g P u l s e ( [ ] , movemask, p u l s e ) : i f l a s t move <> move mask t h e n Beg i n l a s t move : = move_mask; if running then W a i t T i c k (back 1 a s h [ n ] ) End ( o f if} End { o f p u l s e <> 0 > End; { o f d f <> 0.0 > if running then PrmShow ( g a s [ n ] ) End f of i f ) End < of w h i l e } End; < o f GasTask }  P r o c e s s MeasTask ( ( p a r a m : p a r a m _ p t r ) ) ; { measure & d i s p l a y o n l y } Beg i n w h i l e r u n n i n g do Beg i n PrmRead ( p a r a m ) ; i f running then PrmShow ( p a r a m ) End < of whi1e ) End; { o f MeasTask }  Page  Appendix 939 940 94 1 942 943 944 945 94G 947 948 949 950 '951 952 953 954 955 95G 957 958 959 960 961 962 963 964 965 966 967 968 969 970 End  Compiler  B 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  0 0 1 1 2 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 1 1 1 1 1 1 0  0 0 0 3 8 8 1 1 16 28 33 37 37 4 1 41 46 46 51 51 56 56 61 61 63 63 7 1 86 90 93 95 97 100 0  of Compilation.  Listing  o f Program  Page  Sputter  Begin { *** main *** } SputIni t: if running then Repeat com: = P r o m p t C a p I n ( 0 , 0, W(alk D(atalog 'Sputter: S(etpoint [ 'S'.'W'.'D'.'E','P' , 'T' , ' 0 ' ] ) ; if running then C a s e com o f 'S'  GetSetpoints;  ' w  ParamWalk;  'D'  ParamF i 1 e :  -p.  PlotSetup;  'T'  TimSetTO;  ' E ',  '0' :  P(lot  E(dit  T(ime  Q(u1t'  S p u t E d i t (com)  { of Case } End U n t i l not running or (c r u n n i ng := f a l s e ; wkHalt; rkHalt: sbHalt; pfHalt; p1 Ha 11 End.  MapCommandKey  (sc_escape_key,  false));  8  Appendix 3 4 5 6 7 8 9 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 1 10 11 1 1 12 1 13 1 14 1 15 1 16 1 17  Comp i 1e r  C 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  Listing  of Unit  Page  Parameter  1  {$L remout:> Unit Parameter;  Interface  <$L->  Uses  ScrnBuff;  Type a n a _ i n f o  ctrl_info  {$L@>  { a l l times a r e i n t i c k s > - record < analog In c h a n n e l number } c h a n _ i n: 1. 16; < unsealed input v a l u e } r a w _ i n p u t : • 12000. .12000; { w a i t f o r r e a d i n g <> s e t p t > s e t p t : -12000..12000; { by > m a x e r r } m a x e r r : - 1. .24000; { last reading stable? } stable: boolean; { acutal units / m i l l i v o l t in s c a l e _ i n : real end; = record { a l l times a r e dva1_dt: rea1; se t p o i n t : r e a 1 ; D : rea1 : set_dspl: sb_dspl_ptr end ;  in < { { {  seconds } measured d ( v a l u e ) / d t p e r s e c } desired control point } calc'd derivative multiplier } setpoint display info }  param_ptr = ®param_info; param_info = record { f i x e d program l a b e l } hard_name: s t r i n g [ 8 ] ; p a r a m e t e r l i s t l i n k up } next: param_ptr; " name } name: s t r i ng[8 ] ; " units } un i t s : s t r i n g [ 4 ] ; identifier > id: char: value } va1ue: r e a 1 ; which v a l u e mustn't e x c e e d } h i g h l i m: rea1 ; (min) wait between s e r v i c e s ] de1 ay: 0. .max i n t ; w a r n i n g message d i s p l a y e d ? } warning: boolean; beep c o n s o l e each s e r v i c e ? } beep: b o o l e a n ; { name d i s p l a y I n f o ) sb_dspl_ptr : name_dspl { value " " } va1_dsp1: s b _ d s p l _ p t r ; sb_dspl_ptr ; { units " " > uni t_dspl rea 1 ; { l a t e s t v a l u e form read f i l e ] readdata: { r e a d d a t a v a l u e l i n k up } r e a d _ n e x t : param_pt r ; { write " " " } w r i t e next : param_ptr; i f measured, p o i n t t o i n f o ) ®ana_info; measure i f contro11ed, " " " ) ©Ctrl info control end;  00  Appendix  C  1 18 1 19 120 12 1 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 14 1 142 143 144 145 146 147 148 149 150 151 152 31 1 437 448 449 450 45 1 452 453 454 455 456 457 458 459 460  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 . 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of U n i t  Parameter  Page  P r o c e d u r e PrmRead (param: p a r a m _ p t r ) : { w a i t f o r c h a n i n r e a d i n g t o move f r o m i f control find dval_dt }  stable,  scale  It,  F u n c t i o n Prmlncrm (param: p a r a m _ p t r ) : real; < c a l c u l a t e d i f f e r e n t i a l c o n t r o l i n c r e m e n t f o r param  }  P r o c e d u r e PrmShow (param: p a r a m _ p t r ) ; { s e n d v a l u e (& w a r n i n g message ? ) t o s c r e e n , u s e  delay ticks  P r o c e d u r e PrmAnaSet { c a l 1 AnaSetBounds  (param: p a r a m _ p t r ) ; f o r measured channel  Procedure PrmPoint ( s e t p t : { change g i v e n parameter's  up  }  real; param: p a r a m _ p t r ) ; s e t p o i n t to (bounded) s e t p t > o  F u n c t i o n P r m L i s t : param_ptr; { p o i n t t o b e g i n n i n g of l i n k e d Procedure  list  of parameters  }  Prmlnit  ( m o n i t o r _ i m a g e : sb_name; x time, y_time, x_date, y _ d a t e . x warn, y_warn: i n t e g e r ) ; { I n i t i a l i z e u n i t , g i v e name o f p a r a m e t e r m o n i t o r s c r e e n and c o o r d i n a t e s of time, d a t e & w a r n i n g d i s p l a y : don't c a l l from i n i t i a l i z a t i o n p a r t }  image  F u n c t i o n PrmGet ( f i x e d _ n a m e : s b _ n a m e ) : param_ptr; { i n i t i a l i z e named p a r a m e t e r : c a l l a f t e r P r m l n i t } Procedure PrmEdited; { c a l l to f l a g a parameter  has  been e d i t e d  )  Implementation  {$L-} {$L-> <$L-) Const  Uses  ErrMessg, Clock, MiscFunc. ScreenOps, E x t r a S c r S c h e d u l e . E12AnaI0, E12Sched, T r i g A n a , {$L©> {$U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; {$L®>  f warn = 57; yO param = 3; y t o p param = 22; f i l e _ n a m e = 'UTIL:SYSTEM.PARAM';  Type p _ f i 1 e  = file  of  record parm: p a r a m _ i n f o ; meas: a n a _ i n f o : C t r l : C t r l info; decimals: integer end;  >  Appendix 461 462 463 464 465 466 467 468 469 470 47 1 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510  Compiler  C  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  :d :d :d :d :d •d :d • d d d d d d d d d d d d d d d 0 1 1 1 1 1 ^ 1 1 2 1 3 1 3 1 4 1 5 1 3 1 3 1 3 1 5 1 6 1 7 1 7 1 7 1 6 1 5 1 5 1 5 1 •5" 1 :6 1: 7 1• 7  1 2 4 5 7 8 13 14 14 14 14 1 1 1 1 1 1 1 30 31 32 35 0 3 6 14 17 20 23 29 29 33 33 43 53 65 67 7 1 77 77 120 124 124 127 136 140 150 155 155 164  Listing Var  of U n i t  Page  Parameter  p a r a m _ l i s t : param_ptr; warn d s p l , t i m e _ d s p l : s b _ d s p l _ p t r ; warn r e a d y : b o o l e a n ; warn sem: s e m a p h o r e ; y param: y 0 _ p a r a m . . y t o p _ p a r a m ; mon_image: s t r i n g [ 8 ] ; unchanged: boolean;  Process  ShowTime;  forward;  Segment P r o c e s s ParamWarn; C o n s t warn 1 = '!!! W a r n i n g : '; warn 2 = ' v a l u e e x c e e d s i t s u p p e r b o u n d V a r message: s t r i n g [ f _ w a r n ] ; blank: s t r i ng[1]; beep: c h a r ; param, p r e v i o u s , m e s s a g e d : p a r a m _ p t r ;  !! ' ;  Begin { ** ParamWarn ** > beep:= c h r ( 7 ) ; b1ank:= ''; messaged:= n i l ; wa i t ( w a r n _ s e m ) ; param:= p a r a m _ l i s t ; w h i l e r u n n i n g do Begin p r e v i o u s : = param; Repeat w i t h p a r a m ® do i f next Until  = n i l then param : = p a r a m else param := n e x t ; param©.warning o r (param = p r e v i o u s ) ;  then Begin i f p a r a m ® . w a r n 1ng i f param <> m e s s a g e d t h e n Beg i n message:= c o n c a t ( w a r n _ 1 , p a r a m ® . n a m e . w a r n _ 2 ) ; messaged:= param; Pol 1 Inputs End: u n i t w r i t e (1, beep. 1); s b T o s s S t r i n g (message, w a r n _ d s p l ) : i f running then WaitTick (90); i f running then  1  u n i t w r i t e (1, beep. 1); Begs b T o sns S t r i n g ( b l a n k . w a r n _ d s p l ) ;  3  1  Appendix C  Compiler  1 7 5 1 1 14 1 6 14 512 1 4 5 1 3 14 14 1 3 514 1 5 14 515 14 1 5 5 1G 14 517 1 4 1 2 14 518 14 1 0 519 1 0 14 520 1 0 14 52 1 14 1 0 522 1 d 2 523 1 d 524 2 1 d 17 525 1 d 17 526 (commented 527 {commented 528 1 d 17 529 1 d 17 530 17 1 d 531 1 d 17 532 17 2 d 533 534 17 2 d 17 2 d 535 17 2 d 536 537 17 2 d 17 2 0 538 17 2 1 539 17 2 1 540 54 1 17 2 1 17 2 1 542 17 543 2 1 544 17 2 1 17 2 1 545 17 2 1 546 17 547 2 2 17 2 3 548 549 2 3 17 17 2 3 550 17 2 3 551 17 2 3 552 17 2. 3 553 17 2: 3 554 17 2: 2 555 556 17 2: 1 17 2: 1 557 17 2: 1 558 17 2: 1 559 17 2: 1 560  169 175 178 178 180 183 186 186 0 0 0 0 1 2 1 347 ' : ') ' : '} 347 1 1 1 1 2 4 6 7 0 0 3 9 18 21 33 39 45 45 45 76 86 107 1 17 120 150 159 159 162 166 182 201  Listing  of Unit  if running then WaitTick End { of i f running ) End { of then warning } e l s e Begin warn_ready:= t r u e ; w a i t (warn_sem) End { of e l s e not warning ) End { o f whi1e } End; { o f ParamWarn }  Segment Var  Function  param_file:  Page  Parameter  ParamlO  (30)  (new_name; sb_name; x_time, y_time, x_date, y _ d a t e , x_warn. y _ w a r n : i n t e g e r ) : p a r a m _ p t r ;  p_fi1e;  { ( m o n i t o r _ i m a g e : sb_name; x_time. y_time, x_date, y_date, x_warn, y_warn: i n t e g e r ) }; { In i t i a 1 i ze un i t g i v e name o f p a r a m e t e r m o n i t o r s c r e e n and c o o r d i n a t e s of time & w a r n i n g d i s p l a y : don ' t c a 1 1 .from i n i t i a l i z a t i o n p a r t > Var p i d : p r o c e s s i d ; stack, prio: integer; f m t : sb_forn>at: date_dspl: sb_dspl_ptr; date: st r i ng[9]; Begin unchanged:= t r u e ; U p p e r c a s e (new_name); mon_image:= new_name: param_l i s t : = n i l ; warn_ready:= t r u e ; s e m i n i t (warn_sem, 0 ) ; y_param:= yO_param; f i l l c h a r (fmt. s i z e o f (fmt), 0); w i t h fmt do Beg 1 n y:= y_warn; f i e l d : = f_warn; x:= x_warn; warn_dsp1:= s b L i n k (mon_image, f m t , s b _ s t n g ) ; x : = x t i me; y:= y _ t i me; t i me _ dsp1 : = s b L i n k (mon_image, f m t , sb_now) ; sbTossNow ( t i m e _ d s p l ) ; x: = x_date; y:= y _ d a t e ; f i e l d : = 9: date_dspl:= s b L i n k (mon_image, f m t , s b _ s t n g ) ; End: MapDate ( d a t e ) ; sbTossString (date, d a t e _ d s p l ) ; S t r t l n f o ( ' P a r a m e t r ' , 'ShowTime'. s t a c k , p r i o . f a l s e ) ; s t a r t (ShowTime. p i d , s t a c k , p r i o ) ; S t r t l n f o ('Parametr'. 'Warning', s t a c k , p r i o , f a l s e ) ;  Procedure  Prmlnit  i mage  Appendix 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610  17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17  C  Compiler 2 2 2 1 1 1 1 1 3 3 3 3 3 3 1 1 1 4 4 4 4 1 1 1 1 1 1  5 5 5 5 5 5 5 5 5 5 6 6 5 5 5 7 7 7 5 5 5 5 5  1 1 1 0 0 0 0 d 0 1 1 1 1 1 0 0 d 0 1 1 1 0 0 0 0 d d d d d d d d d d d d 0 1 0 0 d 0 1 1 0 0 0 1 1  217 237 240 0 0 0 0 1 0 0 13 16 26 46 0 0 1 0 0 6 21 0 0 0 0 1 1  1 1 1 1 1 2 4 5 7 7 0 0 0 0 1 • 0 0 22 0 0 0 0 2  Listing  of-Unit  Parameter  s t a r t (ParamWarn, p i d , s t a c k , E12Start: Tr i g l n i t End; { of P r m l n i t >  Page prio);  {$1-} P r o c e d u r e PFOpen; Begin r e s e t (param f i l e , f i l e _ n a m e ) ; i f i o r e s u 1 t <> 0 then N o t e E r r o r (300, i o r e s u l t . false) else i f eof ( p a r a m _ f i l e ) then NoteError i f E r r o r N o t e d then e x i t (ParamlO) End; ( o f PFOpen } P r o c e d u r e PFGet; Begin get (param_f i l e ) ; i f i o r e s u l t <> 0 t h e n N o t e E r r o r (309, i f E r r o r N o t e d then e x i t (ParamlO) End; < o f PFGet }  (301,  0,  ioresult,  false)  false);  {$1 + } P r o c e d u r e PrmGet { ( f i x e d _ n a m e : s b _ n a m e ) : p a r a m _ p t r { i n i t i a l i z e named p a r a m e t e r : c a l l a f t e r P r m l n i t > C o n s t x_name = 46; f_name = 8; x u n i t = 56; f _ u n i t = 4; x_val = 63; f_val = 7; x_set = 72; f_set = 7; V a r param: param p t r ; fmt: s b _ f o r m a t : ' pid: processid; stack, prio: integer; F u n c t i o n Found: b o o l e a n ; Beg i n Found:= param f 1 1 e ® . p a r m . h a r d End; ( o f Found >  name =  };  new_name  F u n c t i o n L i n k (k: s b k i n d ; xx, f : i n t e g e r ) : sb_dspl_ptr; Begin w i t h fmt do Begin x:= xx; f1eld:= f End; L i n k : = s b L i n k (mon image, f m t , k ) End; Begin < ** PrmGet param:= n i l ; PFOpen;  **  }  5  Appendix 61 1 612 6 13 614 615 616 617 6 18 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 64 1 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660  C  17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17  Compiler 5 :1 5 :1 5 :1 5 :3 5 :3 5 :3 5 :3 5: 3 5: 3 5 :5 5: 6 5 :6 5 :6 5 :6 5: 6 5: 6 5 :6 5 :6 5 : :6 :6 5 : 5;:6 5::6 5 :6 5 :6 5 :6 5 :6 5 :6 5 :6 5 : 7 5 :8 5 :8 5 :8 5 :9 5 :0 5 :0 5 :9 5 : 7 5 :6 5 : 7 5 :8 5 :8 5 :8 5 :9 5 :0 5 :0 5 :9 5:8 5: 7 5: 5 5: 2  4 5 16 21 26 32 51 51 61 71 71 76 83 88 93 96 103 108 1 13 1 19 126 145 156 164 175 183 194 203 209 209 2 16 225 230 230 237 245 248 248 254 254 261 270 275 275 292 295 297 298 300 300  Listing  of Unit  Page  Parameter  i f y param >= y t o p _ p a r a m then N o t e E r r o r (302, ytop_param-yO_param, f a l s e ) e l s e Begin new ( p a r a m ) ; U p p e r c a s e (new_name); w h i l e n o t ( Found o r e o f ( p a r a m _ f i l e ) ) do PFGet i f n o t Found then N o t e E r r o r ( 3 0 3 . 0, f a l s e ) else w i t h p a r a m _ f i l e © , p a r a m ® , fmt do Beg i n p a r a m ® : = parm ; va1ue:= 0.0; warning: false; next: param_list; param l i s t : - param; r e a d _ d a t a : = 0.0; r e a d next:= n i l ; wr i t e n e x t : = n i l ; f i l l c h a r (fmt, sizeof (fmt), 0 ) : y p a r a m : y_param + 1; y:= y param; dec f i e l d : decimals; name d s p l : L i n k ( s b _ s t n g , x_name, f _ n a m e ) ; s b T o s s S t r i n g (name, n a m e _ d s p l ) ; u n i t dspl:= Link (sb_stng, x _ u n i t , f _ u n i t ) ; SbTossString (units, unit_dspl); val d s p l : L i n k (s"b_re. x _ v a l , f _ v a l ) : sbTossReal (value, v a l _ d s p l ) ; i f c o n t r o l <> n i l t h e n Beg i n new ( c o n t r o 1 ) ; 5  5  5  5  5  5  control®:=  C t r l ;  w i t h c o n t r o l © do Beg i n s e t p o i n t : 0.0: set d s p l : Link ( s b _ r e , x s e t , End { of with } End: ( of control ) i f m e a s u r e <> n i l t h e n Beg i n new ( m e a s u r e ) : m e a s u r e ® : meas; w i t h m e a s u r e ® do Beg i n ana n a m e s [ c h a n _ i n ] : name; s t a b 1e:= f a 1se End; { of with ) PrmAnaSet ( p a r a m ) End { of measure > End { of f i l e r e c o r d found } End; { o f e l s e y_param ok ) 5  5  5  5  f_set)  6  Appendix  C  Compiler  Listing  of U n i t  Parameter  P a r a m l O : = param 17 661 5 1 300 17 End; ( o f PrmGet } 1 0 662 0 1 0 663 17 0 17 1 Procedure PrmPut; 664 1 d V a r param: p a r a m _ p t r ; 17 1 8 d 665 r e c no: i n t e g e r ; 17 666 8 d 2 Begi n 667 17 8 0 0 i f not unchanged then 668 17 8 1 0 17 5 Beg i n 669 8 2 PFOpen; 5 17 8 3 670 param:= p a r a m _ l i s t : 7 671 17 8 3 w h i l e param <> n i l do w i t h p a r a m © do 17 672 8 3 9 17 Beg i n 673 17 8 5 17 r e c _ n o : = 0; 674 17 8 6 w h i l e param f i 1 e ® . p a r m . h a r d name <> hard_name do 17 19 675 8 6 27 Beg i n 676 17 8 7 PFGet; 677 17 27 8 8 r e c no:= r e c _ n o + 1 17 29 678 8 8 End; 679 17 8 7 30 {$1-} seek ( p a r a m _ f 1 l e , r e c _ n o ) ; <$I+> 34 17 8 6 680 i f i o r e s u l t <> 0 t h e n N o t e E r r o r (310, i o r e s u l t , true); 41 17 8 6 68 1 w i t h p a r a m _ f i l e © do 17 56 682 8 6 Begi n 17 8 7 59 683 parm:= p a r a m © ; 684 17 8 8 59 i f measure <> n i l t h e n meas:= m e a s u r e ® ; 64 •17 685 8 8 i f c o n t r o l <> n i l t h e n ctrl-:= control®; 79 17 686 8 8 decimals:^ va1_dspl®.format.dec_fie 1 d 94 17 687 8 8 End; { of w i t h param_f1le© } 104 17 8 7 688 ($I-> put ( p a r a m _ f i l e ) ; <$I+) 106 17 8 6 689 i f i o r e s u l t <> 0 t h e n N o t e E r r o r (304, i o r e s u l t . t r u e ) ; 17 1 12 8 6 690 param:= n e x t ; 17 127 691 8 6 i f param <> n i l t h e n 692 17 8 6 130 134 Beg i n 693 17 8 7 ($I-> reset (param_fi1e); {$1+} 134 694 17 8 8 i f i o r e s u l t <> 0 t h e n N o t e E r r o r (311, i o r e s u l t , t r u e ) 17 695 8 8 140 End ( o f not n i l ) 696 17 8 7 153 End { of w h i l e , w i t h param® ) 17 155 697 8 5 End ( o f i f not unchanged > 155 17 8 2 698 End; < o f PrmPut > 17 1 0 699 0 1 0 17 0 700 Begin ( *** ParamlO *** } 17 1 0 0 701 ParamlO:= n i l ; 17 1 1 17 702 i f x _ t i m e < 80 t h e n Prmlnit 17 1 1 21 703 else i f x _ t i m e = 80 t h e n PrmGet 704 17 29 1 1 else PrmPut 1 2 705 17 40 End; { o f Segment P a r a m l O } 1 0 706 17 0 707 1 0 17 0 17 1 0 708 0 sb_name; 709 (commented ' : '} P r o c e d u r e P r m l n i t { ( m o n i t o r _ i m a g e : x _ t i m e , y _ t i m e , x_warn, y _ w a r n : i n t e g e r ) }; 1 1 d 7 10 2  Page  7  Appendix 7 1 1 712 7 13 7 14 7 15 7 16 7 17 7 18 7 19 720 72 1 722 723 724 725 726 727 728 729 730 73 1 732 733 734 735 736 737 738 739 740 74 1 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :d 1 :d 1 :d 8 :d 8 :0 8: 1 8: 1 1 :0 1 :0 1 :0 1: d 1: d 9 :0 9: 1 1 :0 1 :0 1 :0 1 :d 1 :d 10 :0 10 : 1 1 :0 1 :0 1 :0 1 :d 12 :0 12 : 1 12 : 1 1 :0 1 :0 1 :0 1 :d 13 :0 13 : 1 1 :0 1 :0 1 :0 1 :d 14 :0 14 : 1 1 :0 1 :0 1 :0 1 :d 1 1 :0 1 1: 1 1 1 : 2, 1 1: 3 1 1: 3 1 1: 2  1 1 1 1 0 5 10 0 0 0 1 1 0 4 0 0 0 1 1 0 0 0 0 0 1 0 0 8 0 0 O 1 0 0 0 0 0 1 0 0 0 0 0 1 0 2 7 7 12 18  L i s t i n g of Unit  Page  Parameter  { I n i t i a l i z e u n i t , g i v e name o f p a r a m e t e r m o n i t o r s c r e e n and c o o r d i n a t e s o f time & w a r n i n g d i s p l a y : don't c a l l from i n i t i a l i z a t i o n part } V a r dummy: p a r a m _ p t r ; Beg i n dummy:= P a r a m l O ( m o n i t o r _ 1 m a g e , x _ t i m e , y _ t i m e . x d a t e , y _ d a t e , x_warn, y _ w a r n ) End; { of Prmlnit >  image  F u n c t i o n PrmGet ( ( f 1 x e d _ n a m e : s b _ n a m e ) : p a r a m _ p t r >; { i n i t i a l i z e named p a r a m e t e r : c a l l a f t e r P r m l n i t } Begi n P r m G e t : P a r a m l O ( f i x e d _ n a m e , 80, 0, 0, 0. 0, 0 ) End; { o f PrmGet > 5  Procedure PrmEdlted; { c a l l t o f l a g a parameter has been e d i t e d > Beg i n i f unchanged then unchanged: false End; < of PrmEdited } 5  Function E x i s t s ( e r r : boolean; i d : char; err_num: Beg i n i f e r r then NoteError (errnum, ord(id), f a l s e ) ; Exists: not e r r End; { of Exists }  integer):  boolean;  5  F u n c t i o n C t r l E x i s t s (param: param_ptr; err_num: i n t e g e r ) : b o o l e a n ; Beg i n w i t h p a r a m © do C t r l E x i s t s : E x i s t s ( c o n t r o l n i 1 , i d , e r r _ n u m ) End; { of C t r l E x i s t s } 5  5  F u n c t i o n M e a s E x i s t s (param: param_ptr; err_num: i n t e g e r ) : b o o l e a n ; Beg i n w i t h p a r a m © do M e a s E x i s t s : E x i s t s ( m e a s u r e = n i 1 , i d , err_num) End; ( of MeasExists } 5  P r o c e s s ShowTime; Begin wh i 1 e r u n n i ng do Beg i n WaitTick (60); i f r u n n i n g then sbTossNow ( t i m e _ d s p l ) End; { of while running >  8  Appendix C 7G1 762 763 764 765 766 767 768 769 770 77 1 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 79 1 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 1 1: 1 : 0 1 :0 1 :0 1 :d 1 :d 4 :d 4 :d 4 :0 4 :1 4 :1 4 :2 4 :3 4 :3 4 :3 4 :: 4 4 :5 4 :5 4 :: 4 4 :; 3 4 :: 3 4: 3 4: 3 4: 2 1 :0 1 :0 1 :0 1: d 1 :d 5: d 5 :0 5: 1 5: 2 5: 3 5 :4 5: 4 5: 4 5: 4 5: 4 5: 6 5 :6 5 :6 5 :4 5: 4 5: 3 1 :0 1 :0 1 :0 1 :d 1: d  22 0 0 0 1 1 1 5 0 0 4 6 6 15 29 36 36 39 42 42 57 61 66 76 0 0 0 1 1 1 0 0 9 15 15 19 27 30 36 52 58 73 97 1 18 132 0 0 0 1 1  Listing  of U n i t  Page  Parameter  s i g n a l (warn_sem) { shut End: < o f ShowTime >  down ParamWarn p r o c e s s }  P r o c e d u r e PrmShow { ( p a r a m : p a r a m _ p t r ) >: { s e n d v a l u e (& w a r n i n g m e s s a g e ? ) t o s c r e e n , u s e up d e l a y Var t l . t 2 : t i m _ r e c ; Begin ( ** PrmShow +* > w i t h t1 do time (hiword, loword): w i t h p a r a m ® . t 2 do Begin sbTossReal (value. v a l _ d s p l ) ; warning:= v a l u e > h i g h l i m ; i f warning and warn_ready then Beg i n warn r e a d y : = f a l s e ; s i g n a l (warn_sem) End; { of i f warning } i f beep t h e n write (chr (7)); time (hiword, loword): TimMinus ( t 2 , t 2 , t 1 ) ; if running then W a i t T i c k (de1 a y - 1 o w o r d ) End < of with } End; { o f PrmShow >  P r o c e d u r e PrmAnaSet { ( p a r a m : p a r a m _ p t r ) >; { c a l 1 AnaSetBounds f o r measured channel ) Var e r r : i n t e g e r ; Begi n i f M e a s E x i s t s ( p a r a m . 305) t h e n w i t h p a r a m ® , m e a s u r e ® do Beg i n i f s t a b l e then err:maxerr else err:= -1 ; i f contro1 = n i l then setpt:= raw_input else w i t h c o n t r o l ® do if s e t dspl®.format.enabled then setpt:= round ( s e t p o i n t / s c a l e i n ) else setpt:= raw_input; AnaSetBound (chan i n , s e t p t , e r r . i B o u n d e d ( d e l a y d i v 4. 1, 3 0 ) ) End End; < o f PrmAnaSet )  P r o c e d u r e PrmRead < ( p a r a m : p a r a m _ p t r ) >; ( w a i t f o r c h a n i n r e a d i n g t o move f r o m s t a b l e ,  s c a l e 1t,  9  Appendix 81 1 812 813 814 815 816 817 818 8 19 820 82 1 822 823 824 825 826 827 828 829 830 83 1 832 833 834 835 836 837 838 839 840 84 1 842 843 844 845 846 847 848 849 850 85 1 852 853 854 855 856 857 858 859 860  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :d : 2 :d : 2 :0 : 2 : 1 2 : 3 2 :4 2 :4 2 :5 2:6 2 :6 2:6 2 :6 2 :6 2 :8 2 :9 2 :8 2:7 2 :6 2 :5 2 :3 1 :0 1 :0 1 :0 1 :d 1 :d 3 :d 3 :0 3: 1 3: 1 3: 3 3:4 3:5 3 :5 3 :5 3 :6 3 :6 3: 5 3 :4 1 :0 1 :0 1 :0 1: d 1 :d 6 :0 6: 1 6: 2 6 : 3 6 :4 6: 4 6:4  1 1 0 0 15 15 23 28 28 4 1 53 66 69 72 76 91 107 109 1 10 112 0 0 0 1 1 1 0 0 5 20 29 29 33 45 57 64 91 121 0 0 0 1 1 0 0 9 15 15 32 40  Listing  of U n i t Parameter  if control find dval_dt > V a r dx, d t : i n t e g e r : Begin i f M e a s E x i s t s ( p a r a m , 306) t h e n w i t h param®, measure® Begin WaitAnalog ( c h a n _ i n ) ; if running then Begin AnaRead ( c h a n i n , r a w _ i n p u t , dx. d t ) : value:= s c a l e i n * raw_input; s t a b l e : = a b s ( r a w _ i n p u t - s e t p t ) <= m a x e r r ; i f c o n t r o l <> n i l then Begin if s t a b l e then stable: a b s (dx * d e l a y ) d i v d t <= m a x e r r ; c o n t r o l ® . d v a l _ d t : = s c a l e _ i n * dx / ( d t / 6 0 . 0 ) End; < of c o n t r o l ) PrmAnaSet (param) End ( of i f running ) End { of with > End; { o f PrmRead >  Page  do  5  F u n c t i o n P r m l n c r m { ( p a r a m : p a r a m _ p t r ) : r e a l }; { c a l c u l a t e d i f f e r e n t i a l c o n t r o l i n c r e m e n t f o r param } V a r s i gna1 : rea1 ; Beg i n Prmlncrm:= O.O; { i n c a s e doesn't e x i s t or not e n a b l e d ) i f C t r l E x i s t s (param, 307) t h e n w i t h p a r a m ® , c o n t r o l ® do if s e t dspl®.format.enabled then Beg i n i f v a l u e >= h i g h l i m then signal:= highlim - value else i f v a l u e <= 0.0 then signal:= -value else signal:= setpo1nt-va1ue - D*dval_dt; Prmlncrm:= d e l a y / 6 0 . 0 * r A b s B n d d ( s i g n a l , h i g h l i m * 0 . 1 / ( D + 1 End { o f i f enabled } End; { of Prmlncrm >  Procedure PrmPoint { ( s e t p t : r e a l ; param: p a r a m _ p t r ) ) ; { change g i v e n p a r a m e t e r ' s s e t p o i n t to (bounded) s e t p t ) Begin ' i f C t r l E x i s t s ( p a r a m , 308) t h e n w i t h p a r a m ® , c o n t r o l © do Begin s e t p o i n t : = r B o u n d e d ( s e t p t , 0.0, h i g h l i m ) ; sbTossReal ( s e t p o i n t , s e t _ d s p l ) ; i f m e a s u r e <> n i l t h e n PrmAnaSet (param)  10  Appendix 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 End  of  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 6 :3 1 :0 1 :0 1 :0 1 :d 1 :d 7 :0 7: 1 1 :0 1 :0 1 :0 1 :0 1: 1 1: 1 :0  Compilation  47 0 0 0 1 1 0 0 0 0 0 0 0 3 0  Listing  End;  of  Unit  Page  Parameter  End { of with } { of PrmPoint >  F u n c t i o n P r m L i s t {: p a r a m _ p t r } ; { p o i n t to b e g i n n i n g of l i n k e d l i s t Beg i n PrmList:= p a r a m _ l i s t End; { of P r m L i s t }  Begin  { unit  initialization  of  & h a l t i ng  parameters  code }  * * +.  param End.  1i s t : = P a r a m l O  ('',  81. 0.  0.  0.  0,  0)  { save  param_file  }  Appendix 3 4 5 6 7 8 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 38 1 382 383 384 385 386  C  Compiler L i s t i n g  of Unit  ParamUtil  Page  1 {$L remout:} 0 d 0 1 Uni t ParamUt11 : 1 d 2 1 1 .d 2 1 1 d 2 1 Interface 1 d 2 1 1 d 2 {$L-} Uses S c r n B u f f , P a r a m e t e r : {$L®> 1 1 d 2 1 1 d 2 F u n c t i o n PrmNamed (name: sb_name): param_ptr; 1 1 d 2 { r e t u r n w i t h named p a r a m e t e r > 1 1 d 2 1 1 d 2 F u n c t i o n PrmPrmpt ( x , y: i n t e g e r ; title: string; 1 1 d 2 must meas, m u s t _ c t r l : b o o l e a n ) : p a r a m _ p t r ; 1 d 2 { PromptCapIn f o r a (measured and/or c o n t r o l l e d ? ) parameter i d . 1 1 d 2 u s i n g t i t l e : t o s t a r t t h e prompt; {commented ' : ' > r e t u r n n i l when <esc> t y p e d o r n o t r u n n i n g ) 1 1 d 2 1 1 d 2 1 F u n c t i o n PrmEdSet: param_ptr; 1 d 2 { prompt f o r & r e a d a p a r a m e t e r s e t p o i n t , r e t u r n w i t h a l t e r e d param ) 1 1 d 2 1 1 d 2 1 1 d 2 I m p l e m e n t a t i on 1 d 1 2 1 d 0 2 1 d 0 2 {$L-> Uses ScreenOps, E x t r a S c r . M i s c F u n c . S c h e d u l e , ReadKybd; {$L©} 1 d 2 0 1 d 0 2 1 d 0 2 F u n c t i o n PrmNamed { (name: sb_name): p a r a m _ p t r }; 1 d 0 2 { r e t u r n w i t h named p a r a m e t e r > 1 1 d 2 Var param: p a r a m _ p t r ; 1 2 .d 2 done: b o o l e a n ; 2 2 d 2 F u n c t i o n Found (p name: sb_name): b o o l e a n ; 3 2 :d 2 Begin . . 0 2 5 :0 U p p e r c a s e (p_name); 4 2 5: 1 Found:= p_name = name 7 2 5: 1 End; { o f Found ) 2 :0 0 2 Beg i n 2 :0 0 2 U p p e r c a s e (name); 4 2 2: 1 param:= PrmL i s t ; 7 2 2: 1 Repeat 1 1 2 2: 1 done:= Found ( p a r a m © , n a m e ) ; 1 1 2:2 2 i f n o t done t h e n param:= p a r a m ® . n e x t 19 2 2: 2 U n t i l done o r ( p a r a m = n i l ) ; 23 2: 1 2 PrmNamed:= param 32 2: 1 2 End; { o f PrmNamed } 1 :0 0 2 1 :0 0 2 1 :0 0 2 F u n c t i o n PrmPrmpt { ( x , y: i n t e g e r ; title: string; {commented : ') must meas, m u s t _ c t r l : b o o l e a n ) : p a r a m _ p t r >; 1 :d 1 2  Appendix  C  Compiler  387 2 1 :d 388 {commented ' 1 :d 2 389 3 :d 2 390 3 :d 2 391 2 3 :d 392 393 2 3 :d 394 2 3 :0 2 3 :1 395 2 3 :1 396 397 3 :1 2 3 :1 398 2 3 :3 399 2 3:4 2 400 2 3:4 401 2 3 ;5 : 402 2 3 :6 403 404 2 3 :6 : 2 3 :6 : 405 406 2 3 :6 : 407 2 3 :6 3 :5 408 2 3:4 2 409 2 3: 3 4 10 4 1 1 2 3: 1 3: 2 4 12 2 4 13 2 3: 1 4 14 3: 1 2 3: 1 4 15 2 4 16 2 3: 3 4 17 2 3: 3 2 3: 2 4 18 4 19 2 3: 1 1 :0 2 420 1 :0 2 42 1 1 :0 422 2 1 :d 423 2 424 1 :d 2 4 :d 2 425 4 :0 2 426 4: 1 427 2 4: 1 428 2 4:2 429 2 4: 3 2 430 4: 3 431 2 4: 1 432 2 1 :0 433 2 1 :0 434 2 1 :0 435 2 436 2 :0  1 :  ')  1 1 2 130 146 0 8 15 29 33 43 43 55 70 70 1 16 125 149 170 170 172 172 180 185 246 259 262 266 270 279 283 0 0 0 1 1 1 0 0 13 17 26 58 61 0 0 0 0  Listing  of Unit  ParamUtil  Page  { PromptCapIn f o r a (measured and/or c o n t r o l l e d ? ) parameter i d . u s i n g t i t l e : t o . s t a r t t h e prompt; r e t u r n n i l when <esc> t y p e d o r n o t r u n n i n g } V a r param: p a r a m _ p t r ; s : sb_prmt; match: s e t of c h a r ; i d e n t i t y : char; Begi n s:= ' <esc>': match:= [MapCommandKey ( s c _ e s c a p e _ k e y , false)]; param:= PrmL i s t : w h i l e param <> n i l do w i t h p a r a m © do Beg i n i f ( n o t m u s t _ c t r l o r ( c o n t r o l <> n i l ) ) and ( n o t must meas o r ( m e a s u r e <> n i l ) ) t h e n Beg 1 n s:= c o n c a t (' ('. name, s ) ; s[3]:= i d ; i f UpperChar (name[1]) = i d then d e l e t e ( s , 5, 1 ) ; match:= match + [ i d ] ; Pol 1 I n p u t s End; < if > param:= n e x t End; { while with > i f r u n n i n g then i d e n t i t y : ^ P r o m p t C a p I n ( x , y, c o n c a t ( t i t l e , ':', s ) , m a t c h ) ; i f n o t r u n n i n g o r ( i d e n t i t y = MapCommandKey ( s c _ e s c a p e _ k e y , false)) then param:= n i l e l s e Begin param:= PrmL i s t : w h i l e p a r a m © . i d <> i d e n t i t y do param:= p a r a m © . n e x t End; ( of e l s e } PrmPrmpt:= param End; { o f PrmPrmpt >  F u n c t i o n PrmEdSet { : p a r a m _ p t r }; < prompt f o r & r e a d a p a r a m e t e r s e t p o i n t , r e t u r n w i t h a l t e r e d param > V a r param: p a r a m _ p t r ; Beg i n param:= PrmPrmpt ( 0 . 0, ' S e t p o i n t ' . f a l s e , t r u e ) : i f param <> n i l t h e n w i t h p a r a m ® , c o n t r o l ® . s e t _ d s p 1 © . f o r m a t do P r m P o i n t ( F e t c h R e a l ( x . y, f i e l d , d e c _ f i e l d , 0.0, h i g h l i m ) . param); PrmEdSet:= param End; { of PrmSetpt )  End.  2  Appendix  End  of  C  Compiler  Compilation.  Listing  of U n i t  ParamUtil  Page  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 239 344 345 34G 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379  C 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 2 2 2 4  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 1 1 1 0 0 d O  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 130 162 163 165 165 1 0 0 1 1 38 40 0 0 1 0  Listing  of U n i t  Page  ParamEdit  {$L remout:> Uni t P a r a m E d i t ;  Interface Procedure PrmEdit { interactively edit  system parameters }  Implementat i o n  ($L-> ($L->  Uses  M i s c F u n c . W r i t C o n s , Schedu1e, T r i g A n a , P a r a m e t e r , ParamUt i1  Procedure PrmEdit { interactively edit Const  Var  system parameters }  e d i t _ i m a g e == 'PRMEDIT' ; 6 y_name = x_name = 34 6 y unit = x u n i t = 55 y_i d = 6 x_1d =69 y_uppr = 7 x_uppr = 41 7 y_dec = x dec = 69 y wa i t = 8 x_wa i t = 69 y_beep = 9 x b e e p = 55 y c h a n = 14 x c h a n = 50 y _ f u l l = 15 x _ f u l 1 = 53 y s1ew = 20 x s l e w = 47 y _ e n a b = 21 x_enab - 45  f f  name un i t  = =  8; 4 ;  f _dec f wa i t  =  1 : 6;  f_chan  =  2;  =  2;  •  f_s1ew  ch: char; prompt: sb_prmt; v a l i d i d s . match: s e t o f c h a r : param: p a r a m _ p t r : f re. d_re: integer;  P r o c e d u r e AddPrompt ( i : i n t e g e r ) ; Var prompt p t r : s b _ p r m t _ p t r ; Beg i n prompt_ptr:= ScrnPrompt ( 1 ) ptr©) prompt:= c o n c a t ( p r o m p t . prompt Pol 1 I n p u t s ; i f not r u n n i n g then e x i t (PrmEdit) End; < o f AddPrompt } Procedure Begin  Noteld;  ReadKybd <$L©}  d_  Appendix 380 38 1 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 4 10 41 1 412 4 13 4 14 4 15 4 16 417 4 18 4 19 4 20 42 1 422 423 424 425 426 427 428 429  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 4 :1 2 :0 2 :0 2 :d : 5 : :0 5 : 1 2 :0 : 2 :0 : 2 :d : 6 : :d 6 : :0 6 : 1 6 : 2 6 : 3 6 : 3 6 :3 6 : 4 6 : 3 6 :3 6 : 3 6 : 3 6 : 3 6 :4 6 :5 6 : 5 6 : 5 6 : 5 6 :4 6 : 2 2 :0 2 :0 2 :d 7 :0 7: 1 7: 2 7: 3 7: 3 7: 3 7: 2 2 :0 2 :0 2:d 8 :0 8: 1 2 :0 2 :0 2 :d 9 :0 9: 1 2 :0  0 0 0 1 0 0 0 0 1 1 0 0 5 5 12 2 1 2 1 26 37 44 52 77 96 96 98 11 1 113 1 19 12 1 0 0 1 0 0 4 4 7 1 1 24 0 0 1 0 0 0 0 1 0 0 0  Page  L i s t i n g of U n i t ParamEdit w i t h paramo do valid_ids:= End; { of Removeld } Procedure Pool Id; Beg i n w i t h p a r a m ® do valid_ids:= End; { of N o t e l d }  valid_ids  - [id]  . valid_ids  + [id]  P r o c e d u r e FetchName; V a r oldname, newname: sb_name; Begin w i t h p a r a m ® do Begin oldname:= name; name:= ''; Repeat FetchString (x_name, y_name, newname, f_name) U n t i l PrmNamed (newname) = n i l ; name:= newname; s b T o s s S t r i n g (name, n a m e _ d s p l ) ; i f measure <> n i l t h e n ana_names[measure®.chan_1n] if UpperChar (name[1]) i n v a l i d _ i d s then Beg i n Pool Id; id:= U p p e r C h a r ( n a m e [ 1 ] ) : Noteld; T o s s C h a r (x i d , y i d , i d ) End { of i f } End < of w i t h ) End; ( o f 'N' ) Function FullScale: real; Begin w i t h p a r a m ® do Begin i f measure = n i l then F u 1 1 S c a l e : = 1.0E38 else F u l l Scale:= measure®.sea 1 e _ i n * End { of w i t h > End; < of F u l l S c a l e } Procedure ChangeBeep; Beg i n w i t h p a r a m ® do beep:= End; ( of ChangeBeep } P r o c e d u r e BeepOn; Beg i n if not param®.beep End; { o f BeepOn }  then  TossNot  10000.0  (x_beep, y_beep,  ChangeBeep  beep)  2  Appendix 430 431 432 433 434 435 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 46 1 462 463 464 465 466 467 468 469 470 47 1 472 473 474 475 476 477 478 479  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 2 2 10 10 2 2 2 11 11 11 11 11 11 2 2 2 12 12 12 12 12 12 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  0 d 0 1 0 0 d 0 1 2 3 3 2 0 0 d 0 1 2 2 2 1 0 0 0 1 1 1 2 3 3 2 1 1 1 2 3 3 5 6 7 8 7 6 6 6 6 6 6 •6  0 1 0 0 0 0 1 0 0 6 6 33 36 0 0 1 0 0 4 9 26 33 0 0 0 0 13 20 26 26 28 31 37 44 44 50 50 66 80 80 90 90 101 1 12 124 1 36 146 163 172 189  Listing  of U n i t  ParamEdit  Page  Procedure SetDecimal ( d s p l : s b _ d s p l _ p t r ) ; Beg i n dspl®.format.dec_field:= d_re End; { of SetDecimal > Procedure CalcMaxerr; Begin w i t h p a r a m ® . m e a s u r e ® do Beg i n maxerr:= t r u n c (0.499999 PrmAnaSet ( p a r a m ) End { of w i t h ) End; { of C a l c M a x e r r } Procedure FetchFul1; Begin w i t h p a r a m ® do m e a s u r e ® . s e a 1e i n : = F e t c h R e a l (x f u l l , / 10000.0: CalcMaxerr End: < of F e t c h F u l 1 }  y  / scale_in  full,  / pwroften  f _ r e . d_re.  (d_re));  1.0E-32,  1.0E38)  Begin < * * ParamEdt *** } v a l i d _ i d s : = ['0'..'9'. ' A ' . . ' Z ' ] ; param:= PrmL i s t ; w h i l e param <> n i l do Beg i n Noteld; param:= p a r a m ® . n e x t End; { of w h i l e ) ScrnEnter (edit_1mage); +  if running then Repeat param:= PrmPrmpt ( 0 . 0, ' P a r a m E d i t ' , f a l s e , false); i f param <> n i l t h e n w i t h p a r a m ® do Beg i n w i t h v a l d s p l ® . f o r m a t do Beg i n f re:= f i e l d ; d re:dec_field End; T o s s S t r i n g (x name, y name, name, f _ n a m e ) ; TossString (x_unit, y_unit, units. f_unit); TossChar ( x _ i d , y _ i d , i d ) ; TossReal (x_uppr, y_uppr, h i g h l i m , f _ r e , d _ r e ) ; T o s s l n t e g e r ( x d e c , y_dec, d r e , f _ d e c ) : T o s s R e a l (x_wa11, y_wa11, d e l a y / 6 0 . 0 . f _ w a i t , d_wa11); T o s s B o o l e a n (x_beep, y_beep, b e e p ) ;  Appendix 480 48 1 482 483 484 485 486 487 488 489 490 49 1 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 5 10 51 1 512 513 514 515 516 517 518 5 19 520 52 1 522 523 524 525 526 527 528 529  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 2 :6 2 :6 2 :6 2 :6 2 :6 2 :6 2 :8 2 :8 2 :7 2 :6 2 :8 2 :9 2 :9 2 :9 2 :9 2 :8 2 :6 :6 2 : 2 : 8 :8 2 : 2 : 7 2 :6 2 :8 2 :9 2 :9 2:9 2: 9 2 :8 2 :8 2 :6 2: 7 2: 7 2: 7 2 :8 2 :8 2 :8 2 :0 2 :0 2 :9 2 :8 2 :0 2 :0 2 :0 2 :0 2 :0 2 :9 2: 8 2: 9 2 :8 2 :0  199 208 2 19 222 235 240 243 249 255 257 267 267 270 290 300 313 315 320 323 329 333 335 345 345 348 368 389 401 403 403 403 445 453 459 463 468 468 479 489 494 494 496 502 519 529 529 534 539 563 563  Listing  of U n i t  ParamEdit  Page  prompt:= name; prompt!1]:= UpperChar (prompt[1]) AddPrompt ( 0 ) ; '0' ] match:= [ ' N ' , 'U', ' I ' . 'L', ' D ' , i f m e a s u r e = n i1 then B e g i n chan); TossBlanks (x_chan, y_chan, re) TossBlanks ( x _ f u l l , y_ful1, End { of then } else w i t h m e a s u r e ® do Beg i n AddPrompt (1 ) ; match:= m a t c h + [ ' C , 'F'J; T o s s l n t e g e r (x_chan, y_chan, chan i n , f _ c h a n ) ; re) TossReal ( x _ f u l l , y _ f u l i , F u l l S c a l e , f re,. d End; { of e l s e } i f c o n tro1 = nil then Begin T o s s B l a n k s ( x _ s l e w , y_slew, f_s1ew ) ; T o s s B l a n k s ( x _ e n a b , y _ e n a b , 5) End { of t h e n } else w i t h c o n t r o l ® do Begin AddPrompt ( 2 ) ; match:= m a t c h + t'S', ' E '] ; T o s s l n t e g e r (x_slew, y_slew, round (10.0/(D+1.0)), f _ s l e w ) : dspl®.format.enabled) T o s s B o o l e a n ( x _ e n a b , y_enab, s e t End;  { of e l s e >  Repeat O(uit'), match); ch:= P r o m p t C a p I n ( 0 , 0, concat(prompt, i f c h <> '0' t h e n PrmEdited: i f running then Case ch of 'N': FetchName; 'U' : Beg i n FetchString (x_unit, y_unit, units, f_unit); SbTossString (units, unit_dspl) End; ' I ' : Beg i n Pool Id; T o s s B l a n k s ( x _ i d , y _ i d , 1); id:= FetchCapIn ( x _ i d , y _ i d , v a l i d _ i d s ) ; TossChar (x_1d, y _ i d , i d ) ; Noteld End; ' L ' : h i g h 1 im: = F e t c h R e a l ( x _ u p p r , y _ u p p r , f _ r e , d _ r e , 0.0, FullScale): ' D ' : Beg i n d_re:= F e t c h l n t e g e r ( x _ d e c , y _ d e c , f _ d e c , 0, f _ r e - 3 ) ;  Appendix 530 531 532 533 534 535 536 537 538 539 540 54 1 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 57 1 572 573 574 575 576 577 End  of  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 579 2 :0 2 :0 586 2 : 1 594 2 :0 602 2 :0 612 2 :9 612 617 2 :8 617 2 :0 625 2 :0 648 2 :0 2 :0 662 662 2 :9 667 2 :8 2 : 8 672 2 :0 680 2 : 1 680 2 : 1 699 2 : 1 702 2 : 1 7 15 728 2 :0 2 :8 739 744 2 :8 752 2 :0 2 : 1 752 2 : 1 767 2 : 1 776 2 :0 776 2 :8 780 797 2 :0 2 : 1 797 2 : 1 815 2 : 2 823 823 2 :3 2 : 3 848 2 : 2 858 2 : 1 860 871 2 :0 874 2 :8 879 2 :6 2 :6 880 880 2 :5 886 2 :2 894 2 :2 2 : 1 894 1 :0 0 1 :0 0 1 :0 0 0 :0  Compilation.  Listing  of  Unit  'W' :  'B': 'C':  'F' : 'S':  'E':  End Until  { ch  End (of Unt i1 param  ParamEdit  Page  5  SetDecimal (val_dspl); i f c o n t r o l <> n i l t h e n SetDecimal (contro1 ©.set_dsp1): i f m e a s u r e <> n i l t h e n CalcMaxerr; BeepOn End; { o f 'D' > Beg i n de1ay:= r o u n d ( 6 0 . 0 * F e t c h R e a l ( x _ w a i t , y _ w a i t , f _ w a i t , d_wa1t, 0.01, 99.99)); i f m e a s u r e <> n i l t h e n PrmAnaSet (param); BeepOn End; < o f 'W } ChangeBeep: w i t h m e a s u r e ® do Beg i n a n a _ n a m e s [ c h a n _ i n ] : = ''; chan_in:= F e t c h l n t e g e r ( x _ c h a n , y _ c h a n , f _ c h a n , 1, 16); a n a _ n a m e s [ c n a n _ i n ] : = name End: { of 'C } FetchFul1 ; w i t h c o n t r o l © do Beg i n D:10.0 / Fetchlnteger(x_s1ew,y_s1ew,f_s1ew,1.10) 1.0; BeepOn End; { o f 'S' ) w i t h c o n t r o l ® , s e t _ d s p 1 © . f o r m a t do Begi n enabled:= TossNot ( x e n a b , y_enab, e n a b l e d ) ; i f e n a b l e d then Beg i n s e t p o i n t : = r B o u n d e d ( v a l u e , 0.0, highlim); sbTossReal ( s e t p o i n t . s e t _ d s p l ) End: ( of i f > i f m e a s u r e <> n i l t h e n PrmAnaSet ( p a r a m ) End ( o f 'E' } Case } = '0' i f w i t h param® > = nil;  ScrnReturn End: { of PrmEdit  >  End.  cn  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 247 342 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385  C  0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ' 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 , 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 1 1 1 1 1 0 0 0 0 d  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 10 1 1 12 14 16 16 16 1 1 1 1 1 2 0 0 3 6 12 2 1 37 0 0 O 0 1  Listing  of Unit  Page  Walker  {$L remout:} U n i t Walker; Interface P r o c e d u r e ParamWalk; < s e t up f o r w a l k i n g P r o c e d u r e wkHalt; < s a f e l y e x i t from  i of a parameter s e t p o i n t  walking  process  between  two b o u n d s }  }  I m p l e m e n t a t i on  {$L-} {$L-> {$L-}  U s e s C l o c k , S c h e d u l e , W r i t C o n s , ReadKybd, S c r n B u f f , Parameter, ParamUtil, <$L®> <$U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; ($L®>  T y p e move  Var  = (down,  stop, up);  param: p a r a m _ p t r ; bottom, top, dset d t , minutes: w delay: integer; m o t i o n : move; tO: t i m r e c ; wa1k: s e m a p h o r e :  Process  WalkSetp;  real;  forward;  Segment P r o c e d u r e W a l k l n i t ; Var p i d : p r o c e s s i d ; stack, p r i o : integer; Beg i n param:= n i l ; mot ion:= s t o p : m i n u t e s : = 30.0; sem i n i t ( w a l k . O ) ; S t r t l n f o ('WALKER', 'WALKSETP', s t a c k , s t a r t (WalkSetp, p i d , s t a c k , p r i o ) End; { of Walklnit }  Segment  Procedure  PrmWalk;  prio,  true);  {$L®}  1  Appendix 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 4 10 41 1 412 4 13 4 14 415 4 16 417 418 4 19 420 42 1 422 423 424 425 426 427 428 429 430 43 1 432 433 434 435  2 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14  C  Compiler  Listing  of U n i t  Walker  Page  s e t p o i n t b e t w e e n two b o u n d s } { s e t up f o r w a l k i n g o f a p a r a m e t e r { parameter d i s p l a y } f name 8 8 18 yname C o n s t xname frang =12: { range } 1 1 yrang 43 12 xh i gh x 1 ow { range bound u n i t s } 4 fun i t 51 xhunt 20 x 1 unt d t ime = 1: { t ime > 6 f t i me 13 20 y t i me x t i me 7 < motion d i s p l a y > f move 16 24 ymove xmove Var  1 :0  5:4  2 3 5 6 6 1 1 0 4 0 0 0 4 13 22 27 O 0 1 0 0 4 4 8 8 0 0 1 0 0 2 3 6 1 1 16 20 22 35 35 53 62 73  ch: char; prompt: s b _ p r m t _ p t r ; f _ r e , d_re: integer; mov: move;  P r o c e d u r e TossMove: Type m o v e s t r i n g = s t r i n g [ f m o v e ] ; Procedure TossStr ( s : movestring): Begin T o s s S t r i n g (xmove, ymove. s. fmove) End: { of T o s s S t r ) Begin { ** T o s s M o v e ** } C a s e mov o f down: T o s s S t r ('down'); stop: TossStr ('stopped'): up T o s s S t r ('up' ) End { of Case } End; < of TossMove > P r o c e d u r e S e t M o t i o n (m: m o v e ) : Begin i f param <> n i l t h e n Beg i n mov:= m; TossMove End; ( of S e t M o t i o n > End; { of S e t M o t i o n ) P r o c e d u r e TossParam; Begin TossMove; i f param = n.i 1 then Begin T o s s B l a n k s (xname, yname, f n a m e ) ; T o s s B l a n k s (x1ow, yrang, f r a n g ) : TossBlanks (xhigh, yrang. frang) End < of n i l > else w i t h p a r a m ® , c o n t r o l s , s e t _ d s p l ® . f o r m a t do Begi n f_re:= f i e l d ; d_re:= d e c _ f i e l d : T o s s S t r i n g (xname. yname, name, f n a m e ) ; TossReal (xlow, yrang, bottom, f _ r e . d_re) T o s s S t r i n g (xlunt, yrang, u n i t s , funit);  CO  Appendix 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 45 1 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 48 1 482 483 484 485  14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14  C  Compiler 5 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  4 4 3 0 0 0 1 1 1 1 1 1 2 3 3 3 4 4 5 6 6 6 6 8 8 7 6 5 4 5 6 4 5 6 6 4 5 4 5 4 5 4 5 4 2 1 1 2 3 3  82 94 102 0 0 0 0 2 9 18 20 29 35 35 51 59 65 68 68 68 83 84 87 91 100 102 106 106 1 10 1 10 1 14 133 133 137 146 158 158 177 177 182 182 187 187 188 195 207 218 227 227 236  L i s t i n g of Unit  Walker  Page  TossReal (xhigh, yrang, top, f _ r e , d _ r e ) : T o s s S t r i n g (xhunt, yrang, u n i t s , funit) End { of not n i l > End: { of TossParam } Begin { *** PrmWalk +** } mov:= mot i on; S c r n E n t e r ('WALKSET'): prompt:= S c r n P r o m p t ( 0 ) ; TossParam; TossReal (xtime, ytime, minutes, ftime, dtlme): if running then Repeat ' , 'E' ] ) ; ch:= P r o m p t C a p I n ( 0 , 0. p r o m p t ® , ['P'.'L'.'H'.'T ' , ' U ' , ' D'S' i f c h <> 'E' t h e n motion:= s t o p : i f running then Case ch o f 'P' : Begin param:= PrmPrmpt ( 0 . 0. ' W a l k e r ' , f a l s e . t r u e ) ; i f param = n i l then mov:= s t o p else Begin bdttorn:= p a r a m ® . c o n t r o l ® . s e t p o 1 n t ; top:= b o t t o m End; { o f <> n i 1 > TossParam End; { o f 'P' } 'L' : i f param <> n i l t h e n bottom:= F e t c h R e a l ( x l o w , y r a n g , f _ r e , d _ r e , 0.0, 'H' : i f param <> n i l t h e n top:= F e t c h R e a l ( x h i g h , y r a n g , f _ r e , d _ r e , bottom, param®.highlim) ; 'T' : m i n u t e s : ^ F e t c h R e a l ( x t i m e , y t i m e , f t i m e . d t l m e , 0. 'U' : SetMot i o n ( u p ) ; 'D' : S e t M o t i o n (down); 'S' : SetMotion (stop) End < of Case } U n t i l not r u n n i n g o r ( c h = ' E ' ) : i f t o p = b o t t o m t h e n mov:= s t o p ; i f ( m o t i o n = s t o p ) a n d (mov <> s t o p ) t h e n Beg i n PrmPoint (param®.contro1®.setpoint, param); d s e t dt:= ( t o p - bottom) / (60.0 * m i n u t e s ) ;  (— 1  it*  10  Appendix 486 487 488 489 490 49 1 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 51 1 512 5 13 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535  C  14 14 14 14 14 14 14 14 14 14 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :3 1 :3 1 :3 1 :3 1 :3 1 :2 1 :1 1 :0 1 :0 1 :0 1 :d 2 :0 2 : 1 1 :0 : 1 :0 : 1 :0 : 1 :d : 4 : :d 4 : :d 5 :0 5 : 1 5 : 2 5 : 2 5 : 2 4 :0 4 :0 4 : 1 4 : 1 4 : 2 4: 3 4: 3 4 : 4 4 : 5 4: 5 4 : 5 4 :5 4 :5 4 :5 4: 4 4: 3 4 : 3 4:2 1 :0 1 :0 1 :0 1 :d 1: d 3 :0 3: 1 1 :0  254 270 281 290 293 296 296 0 0 0 1 0 0 0 0 0 1 1 5 0 0 4 4 20 0 0 2 5 10 10 13 18 18 22 28 33 47 53 59 63 66 74 0 0 0 1 1 0 0 O  Listing  of  Unit  Page  Walker  w d e l a y : = round (60.0 / p w r o f t e n ( d _ r e ) / i f mov = down t h e n dset_dt:= -dset_dt; w i t h tO do t i m e ( h i word, l o w o r d ) ; mot i on:= mov; s i gna1 (wa1k ) End; { of motion > ScrnReturn End; { o f Segment PrmWalk }  dset_dt);  P r o c e d u r e ParamWalk; Begin PrmWa1k End: ( o f ParamWalk >  P r o c e s s WalkSetp; V a r t , d t : t i m_rec: F u n c t i o n KeepWalking: boolean; Begin w i t h p a r a m © . c o n t r o l ® do KeepWalking:= r u n n i n g and ( ( ( m o t i o n = down) and ( s e t p o i n t > b o t t o m ) o r ( ( m o t i o n = up) a n d ( s e t p o i n t < t o p ) ) End; { of KeepWalking ) Beg i n wa11 (wa1k ) ; wh i 1 e r u n n i ng do Begin WaitTick (w_delay); w h i l e K e e p W a l k i n g do Beg i n w i t h t do time (hiword, loword); TimMinus ( d t . t . t O ) ; PrmPoint (param®.control®.setpoint + dset_dt * TimlnSeconds ( d t ) , param); tO:= t ; if KeepWalking then WaitTick (w_delay) End; { o f w h i l e KW } mot ion:= s t o p ; i f running then wait (walk) End { of w h i l e r u n n i n g } End: { of W a l k S e t p >  P r o c e d u r e wkHa1t; < s a f e l y e x i t from w a l k i n g Beg i n s i gna1 (wa1k) End: < of wkHalt )  process  )  4  Appendix 536 537 538 539 540 End  of  C 2 2 2 2 2  Compiler 1 :0 1 :0 1 :0 1: 1 :0  Compilation.  0 0 0 0 0  Listing  of U n i t Walker  Begi n Walklnit End.  Page  Compiler  Appendix C 3 4 5 6 7 8 9 IO 1 1 12 13 14 15 1G 17 18 19 20 21 22 23 24 25 226 347 540 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 57 1 572 573  0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 607 609 629 63 1 633 634 635 637 639 64 1 642 644 645  Listing  of U n i t  Page  ParamSave  1  {$L remout:> U n i t ParamSave;  Interface Var  param  time:  real;  P r o c e d u r e ParamReset: { r e s e t parameter read  { time  of l a t e s t  parameter  read  record }  file >  F u n c t i o n ParamGet ( w a i t _ o k : b o o l e a n ) : b o o l e a n : { update read f i l e r e c o r d (wait f o r I t ? ) , r e t u r n true Procedure ParamFile; { s e t up p a r a m e t e r i n p u t $ o u t p u t Procedure p f H a l t ; ( s a f e l y s h u t down w r i t i n g  process  files  i f not eof )  }  )  Implementa11 on  {$L-> {$L-> {$L-} {$L-}  Uses C l o c k , E12AnaI0, S c h e d u l e , ScreenOps, {$L©} E x t r a S c r , W r i t C o n s . ReadKybd, E r r M e s s g , ($L®> MiscFunc, ScrnBuff, Parameter, P a r a m U t i l , <$L@) ($U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; ($L®)  ($1-  turn o f f io checking:  Const  s u f f i x = '.PDAT': no f i l e = " ;  Var  ioresult  i s looked  a t when  { parameter data f i l e s u f f i x { ' f i l e name' f o r no f i l e }  necessary  >  r e a d f i l e , w r i t e f i l e : f i l e of r e a l ; { parameter save f i l e s ) r e a d l i s t , w r i t e l i s t : param_ptr; { l i s t o f 1/o p a r a m e t e r s ) readname, w r i t e n a m e : s t r i n g ! 1 8 ] ; { names o f f i l e s } readopen, writeopen: boolean; ( f i l e s opened? } r e w r i t t e n : semaphore; { w r i t e f i l e opened } enabled: boolean: { o k . t o go a h e a d a n d w r i t e d a t a } s i n g l e : boolean; ' { but o n l y f o r a s i n g l e r e c o r d } w r i t e d a t a : semaphore; { s i g n a l when e n a b l e d > ignore, integrate: integer; { t i c k s b e t w e e n 8. d u r i n g a v e r a g e s r average: r e a l ; { read f i l e ' s i n t e g r a t e , seconds } readwrite: boolean: { read f i l e = w r i t e f i l e } rw a v a i l : semaphore; { new w r i t e d a t a a v a i l a b l e i n r e a d f i l e rw v a l i d : b o o l e a n ; { " " " is valid ) Ln  Appendix 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 61 1 612 613 614 615 616 617 618 619 620 62 1 622 623  2 2 2 2 2 2 2 2 2 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  C  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 3 3 3 1 1 1 4 4 4 1 1 1 5 5 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 0 0 d 0 1 1 0 0 d 0 1 1 0 0 d 0 1 0 0 d  645 645  Listing  of Unit  Page  ParamSave  P r o c e d u r e PFPut ( e r r _ n u m : i n t e g e r ) ; forward; { p u t ( w r i t e f i l e ) . i f i o e r r o r then N o t e E r r o r (err_num)  Segment P r o c e d u r e P r m F i l e ; { s e t up p a r a m e t e r i n p u t & o u t p u t Const  x_rnam == x wnam == x c y c l == x _ w i n t == x r 1 n t =x r 1 s t =y _ l i s t ==  Type n _ s t r i n g q_string Var 2 3 7 8 9 10 10 0 0 0 0 1 0 0 2 0 0 1 0 0 8 0 0 1 0 0 0 0 1  7 7 17 18 18 64 4  y rnam y wnam y cycl y w i nt y r1nt x wist f_list  == -= •= •= == == ==  19 10 1 1 12 20 44 8  files  }  f_name  = 23  f c y c l = 7; f _ i n t = 6; {  parameter  = string[f_name]; = str1ng[39]:  ch: char; prompt: s b _ p r m t _ p t r ; c y c l e , average: r e a l ; param: p a r a m _ p t r ; y: i n t e g e r ; write_ok: boolean;  Procedure CheckError; Begi n if E r r o r N o t e d then exit End; { of CheckError )  r  (ParamFile)  Procedure TaskSwitch; Begin Pol 1 Inputs; CheckError End; { of TaskSwitch ) Procedure Error (n: integer); Beg i n NoteError (n, ioresult. f a l s e ) ; TaskSwi t c h End; ( of E r r o r ) P r o c e d u r e TossWName; Beg i n T o s s S t r i n g (x_wnam. y_wnam, w r i t e n a m e , End; ( o f TossWName > Procedure  TossRName;  f_name)  ui  Appendix  Compiler  C  624 16 625 16 626 16 627 16 628 16 629 16 16 630 631 16 632 16 633 16 634 16 635 16 636 16 637 16 638 16 639 16 16 640 64 1 16 642 16 643 16 644 16 645 16 16 646 647 16 648 16 649 16 650 16 651 16 16 652 16 653 654 16 16 655 656 • 16 657 16 658 16 659 16 16 660 16 661 662 16 663 16 664 16 665 16 666 16 667 16 668 16 669 16 670 16 67 1 16 16 672 16 673  6 6 1 1 1 7 7 7 7 1 1 1 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 1 1 1 9 9 9 9 1 1 1 10 10 10 10 10 10 10 10 10 10 1  0 1 0 0 d 0 1 1 1 0 0 d d O 1 1 1 1 1 3 3 3 3 4 5 5 5 4 2 0 0 d 0 1 1 1 0 O d d 0 1 1 1 3 4 4 3 1 0  0 0 0 0 1 0 5 8 29 0 0 1 1 0 0 10 12 14 22 27 30 35 40 62 62 77 92 1 15 1 18 0 0 1 0 5 13 15 0 0 1 1 0 0 4 8 14 14 22 22 28 0  Listing  of Unit  Page  ParamSave  Beg i n T o s s S t r i n g (x rnam. y mam, End; {• o f TossRName >  readname,  3  f_name)  F u n c t i o n Ask ( q u e s t i o n : q _ s t r i n g ) : b o o l e a n ; Begin u n i t c l e a r ( 1 ) ; { dump t y p e a h e a d b u f f e r > Ask:= P r o m p t C a p I n ( 0 , 0, q u e s t i o n , ['Y'.'N']) CheckError End; { o f Ask )  = 'Y';  F u n c t i o n FetchName ( x , y: i n t e g e r ; v a r name: n _ s t r 1 n g ) : b o o l e a n Var l e n , f i e l d : integer; Beg i n F e t c h S t r i n g ( x , y, name, f _ n a m e ) ; CheckError; i f name = n o _ f i 1 e then FetchName:= f a l s e else Begin FetchName := t r u e ; . U p p e r c a s e (name); 1 en : = l e n g t h (name); i f ( l e n <= 5) o r ( p o s ( s u f f i x , name) <> l e n - 5 ) t h e n Beg i n f i e l d : = p o s (':'. name) + 10; i f l e n > f i e l d then d e l e t e (name, f i e l d + 1 , len-field); name:= c o n c a t (name, s u f f i x ) End ( o f i f pos } End { o f name <> '' > End: ( o f FetchName } P r o c e d u r e TossPName ( x : i n t e g e r : name: Begin T o s s S t r i n g ( x , y, name, f _ l i s t ) ; TaskSw i t c h ; y:= y + 1 End; { o f TossPName > Procedure TossWList; V a r param: p a r a m _ p t r ; Beg 1 n y:= y _ 1 i s t : param:= w r i t e l i s t ; w h i l e param <> n i l do w i t h param® do Begin TossPName (x w i s t , name); param:= w r i t e _ n e x t End; { of while > i f y < 24 t h e n T o s s B l a n k s (x w i s t , y , End; { of TossWList )  n_string);  f_list) Cn  Appendix 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 71 1 712 713 714 715 716 717 7 18 719 720 72 1 722 723  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  C  Comp11er 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12  0 d d 0 1 1 1 3 4 4 3 1 1 1 1 0 0 d d 0 1 1 3 3 2 1 2 2 2 4 4 6 6 6 8 8 8 7 6 8 9 9 0 0 9 8 7 4 3 1  0 1 1 0 0 4 8 14 14 22 22 28 56 56 69 0 0 1 1 0 0 3 7 14 18 20 25 28 35 35 39 4 1 44 48 48 57 63 63 65 67 73 73 73 81 81 86 86 90 91 94  Listing  of U n i t  ParamSave  Page  4  Procedure T o s s R L i s t : V a r param: p a r a m _ p t r : Begin y:= y_list; param:= r e a d l i s t ; w h i l e param <> n i l do w i t h p a r a m © do Begi n TossPName ( x _ r l s t . name); param:= r e a d _ n e x t End; { of whi1e > f o r y:= y t o 24 do T o s s B l a n k s ( x _ r l s t , y. f _ l 1 s t ) ; if readopen then T o s s R e a l (x r i n t . y r i n t , r _ a v e r a g e . f _ i n t , 2) else T o s s B l a n k s (x r i n t , y r i n t . f _ 1 n t ) End; { of T o s s R L i s t } Procedure ToggleWrite; Var l i n k : param_ptr; Begi n i f w r i t e l i s t = param then Begin { param i s f i r s t i n l i s t : remove i t } w r i t e l i s t : = param©.writenext; param©.writenext:= n i l End else i f writelist =n i l then w r i t e l i s t : = param { 1 1 s t was empty: add param e l s e Begin { check r e m a i n d e r o f l i s t f o r param } 1i nk:= w r i t e l i s t ; Repeat w i t h link® do i f w r i t e n e x t = param then Begin < param i s i n l i s t : remove i t } wr1tenext:= wr1tenext©.wr i t e n e x t ; param©.wr1tenext:= n i l ; l i n k : = n i l { q u i t Repeat l o o p ) End { o f remove ) e l s e Begin { param n o t y e t f o u n d } i f w r i t e n e x t = n i l then Beg i n { param n o t i n w r i t e l i s t : add i t t o the 11st ) param©.writenext:= w r i t e l i s t ; w r i t e l i s t : = param End; link:= writenext { t r y next l i n k ) End < of not y e t found } Unt i1 1 i n k = n i 1 End; { of look through l i s t ) TossWL i s t  <_n  Appendix C 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 74 1 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 76 1 762 763 764 765 766 767 768 769 770 77 1 772 773  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  Comp i 1 e r L i s t i n g 1 :0 : 1 :0 : 1 :d : 13 : d 13::d 13::0 13 : 1 13 : 1 13 : 1 13 : 2 13 : 2 13 : 2 13 : 2 13 :3 13 : 3 13 : 4 13 :4 13 :4 13 :4 13 :4 13 : 4 13 :5 13 : 3 13 : 2 13 : 3 13 : 3 13 : 2 13 : 3 13 : 3 13 : 2 13 : 1 1 :0 1 :0 1 :d 14 :d 14 :d 14 :0 14 :0 14 : 1 14 : 1 14 : 1 14 : 2 14 : 3 14 : 3 14 : 2 14 : 1 1 :0 1 :0 1 :d 15 :0  0 0 1 1 2 0 0 10 12 12 29 31 34 34 34 34 34 50 52 54 57 57 57 66 66 75 96 96 105 112 12 1 0 0 1 1 7 0 0 6 13 25 34 34 45 48 55 0 0 1 0  End;  of Unit  ParamSave  { of ToggleWrite >  Procedure EditWStatus; Var c h : c h a r ; prompt: sb p r m t _ p t r ; Beg i n prompt:= S c r n P r o m p t ( 1 ) ; CheckError; Repeat ch:= P r o m p t C a p I n ( 0 . 0, p r o m p t ® , [ ' P ' , ' C ' , ' I ' , ' 0 ' ] ) : CheckError; Case c h of 'P': { determine parameters t o save > Repeat { prompt f o r p a r a m e t e r t o s a v e } param:= PrmPrmpt (0, 0, ' W r i t e P a r a m e t e r s ' , f a l s e , f a l s e ) ; CheckError; i f param <> n i l then { t o g g l e whether o r n o t param i s i n w r i t e l i s t } ToggleWr i t e Unt i1 param = n i l ; 'I' : a v e r a g e : = F e t c h R e a l (x w i n t , y _ w i n t , f _ i n t , 2, O O . rM1n ( 9 9 . 9 9 , cycle)) 'C : c y c l e : = F e t c h R e a l ( x _ c y c l , y _ c y c 1 , f _ c y c 1 , 2, a v e r a g e , 546 .1 1 ) End ( o f Case ) Unt i1 c h = '0' End: { of EditWStatus } P r o c e d u r e PutName (name: sb_name); V a r dummy: a r r a y {1..3] o f r e a l ; i : i nteger; Beg i n { f o r e a s i e r Patch: } f i l l c h a r (dummy, s i z e o f (dummy), ' ' ) ; move l e f t (name, dummy, l e n g t h (name) + 1 ) : f o r 1:= 1 t o 3 do Begin w r i t e f i 1 e @ : = dummy[i]; PFPut (402) End; { of for > TaskSwi t c h End; { o f PutName } Procedure Begin  ClosRead;  Page  5  Compiler  Appendix C 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 8 10 81 1 8 12 813 814 815 816 817 818 8 19 820 82 1 822 823  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  15 15 15 15 15 15 15 15 15 15 15 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 2 3 3 3 2 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 4 4 5 6 7 7 7 7 7 8 9  0 7 1 1 20 24 29 29 33 37 41 4 1 43 0 0 0 0 8 10 10 . 12 22 36 44 52 54 54 56 56 58 58 68 70 70 75 95 97 101 101 101 101 106 106 1 16 1 16 122 126 130 139 144 144  Listing  of U n i t  ParamSave  c1ose (readf i1e ) ; readopen:= f a l s e ; readname:= n o _ f i l e ; r e a d l i st:= n i l ; i f r e a d w r i t e then Begin readwrite:= f a l s e ; rw v a 1 i d:= t r u e ; s i gna1 (rw a v a i 1 ) End; < of i f } TaskSwi t c h ; TossRL1st End; { of ClosRead > Begin { *** P r m F i l e *** } S c r n E n t e r ('PARAMSAV'); TaskSwi t c h ; { write the information ) TossWName: a v e r a g e : ^ i n t e g r a t e / 60.0: c y c l e : = ( i g n o r e + i n t e g r a t e ) / 60.0; T o s s R e a l (x c y c l , y _ c y c l , c y c l e , f _ c y c l , 2 ) ; T o s s R e a l (x w i n t , y w i n t , a v e r a g e , f _ i n t , 2 ) ; TossRName; { l i s t the w r i t e parameters ) TossWL i s t ; { l i s t the read parameters ) TossRL i s t ; prompt:= S c r n P r o m p t ( 0 ) : CheckError; Repeat ch:= P r o m p t C a p I n ( 0 , 0, p r o m p t ® . ['W','R',MapCommandKey ( s c _ e s c a p e _ k e y , CheckError; Case c h of 'W' : Beg i n 1f w r i t e o p e n t h e n < e n s u r e a new w r i t e f i l e i s d e s i r e d ) i f Ask ( ' C l o s e o l d w r i t e f i l e ? ' ) t h e n Beg i n close (writefile, lock); e n a b l e d : = f a 1se; writeopen:= false; w r i t e n a m e : = no f i l e ; i f r e a d w r i t e then Beg i n C1osRead;  Page  6  Appendix 824 825 826 827 828 829 830 83 1 832 833 834 835 836 837 838 839 840 84 1 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 87 1 872 873  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  C  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  9 8 7 6 6 6 4 5 6 6 6 6 8 8 8 0 0 9 8 9 9 1 1 1 1 3 3 2 1 3 3 2 1 0 0 8 8 9 9 0 0 0 O 0 2 2 2 2 4 4  146 146 148 148 150 150 150 157 157 160 166 171 171 182 185 188 191 197 197 202 208 212 2 14 214 253 257 260 266 266 268 274 277 283 283 285 285 287 290 290 290 292 303 306 312 316 318 3 18 321 324 330  Listing.of  Unit  Page  ParamSave  TossRName End; ( of i f 1 TaskSw i t e n End; { of c l o s e o l d w r i t e f i l e  }  { o p e n new f i l e o n l y i f o l d one c l o s e d } i f not w r i t e o p e n t h e n Beg i n wr i t e _ o k : = f a l s e ; i f FetchName (x wnam, y_wnam, w r i t e n a m e ) then Begin { see i f a l r e a d y e x i s t s > reset ( w r i t e f i l e . writename); i f I o r e s u l t = 10 then B e g i n wr i t e _ o k : = t r u e ; c l o s e ( w r i t e f i l e . normal) { no p r o b l e m ) End { o f 10 > else i f i o r e s u l t <> 0 then Error (410) e 1 s e Beg i n , TaskSw i t c h ; { already exists; destroy i t ? > i f Ask ( c o n c a t ( ' D e s t r o y o l d ', w r i t e n a m e then Begin w r i t e ok:= true; c l o s e ( w r i t e f i l e , purge) ( remove i t } End { of d e s t r o y ) e l s e Begin close ( w r i t e f i l e , normal): { don't " writename:= n o _ f i 1 e End; { of don't d e s t r o y > TaskSwi t c h End; { of a l r e a d y e x i s t s > TossWName: i f wr i t e ok t h e n Begin < o.k. t o r e w r i t e new w r i t e f i l e } TaskSwi t c h ; rewrite (writefile, writename); 1 f i o r e s u l t <> 0 then Error (400) else Begin Edi tWStatus; { e n s u r e w r i t e l i s t i s n o t empty i f wr i t e l 1 s t = n i l then Begin c l o s e ( w r i t e f i l e , normal); w r i t e n a m e : = no f i l e :  }  7  Compiler  Append i x C 874 875 876 877 878 879 880 88 1 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 91 1 912 913 914 915 916 917 918 9 19 920 92 1 922 923  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  4 3 2 2 4 4 5 5 4 4 4 4 4 4 4 4 4 4 4 3 1 1 9 7 7 6 5 5 3 3 2 3 3 4 4 5 5 5 5 4 5 5 6 7 8 8 8 0 0 9  339 339 34 1 343 343 347 347 353 354 36 1 368 378 392 392 396 401 403 403 407 41 1 4 1 1 4 1 1 41 1 4 1 1 41 1 4 1 1 4 1 1 4 13 4 13 416 4 16 416 416 4 16 421 42 1 427 433 433 433 440 440 440 450 450 453 461 467 479 479  Listing  of U n i t  Page  ParamSave TossWName End { of n i l wri t e l 1 s t } else Begin { s a v e w r i t e l i s t names i n w r i t e f i l e } param:= w r i t e l i s t ; Repea t PutName (param®.name); param:= p a r a m ® . w r 1 t e n e x t Unt i1 param = n i l ; PutName ( ' ' ) ; { f l a g e n d o f names h e a d e r } i n t e g r a t e s round (60.0 * a v e r a g e ) ; ignore:= round (60.0 * c y c l e ) - i n t e g r a t e ; ( save I n t e g r a t i o n time } writefile®:= average; PFPut (403); TaskSw i t c h ; { t u r n on ParamPut p r o c e s s } writeopen:= true; signal (rewritten) End < o f w r i t e l i s t <> n i l } End < o f no r e w r i t e e r r o r }  End End;  < o f w r i t e n a m e <> { of w r i t e o p e n }  TaskSw i t c h End { o f o p e n new End;  { of  'W'  no_f11e  write f i l e  )  )  }  'R ' : Begin { i f r e a d f i l e a l r e a d y opened, d e t e r m i n e 1f r e a d o p e n then { e n s u r e a new f i l e i s d e s i r e d ) i f Ask ( ' C l o s e o l d r e a d f i l e ? ' ) then ClosRead;  i t s status  ( o p e n new r e a d f i l e If any e x i s t i n g one 1s c l o s e d 1f n o t r e a d o p e n then Beg i n < r e a d f i l e name, open t h e f i l e } 1f FetchName (x_rnam, y_rnam, r e a d n a m e ) t h e n Beg i n i f readname = w r i t e n a m e then readwrite:= true else Begin r e s e t ( r e a d f i l e , readname); readwrite:= f a l s e End; { of e l s e )  }  }  8  Appendix 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 94 1 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 97 1 972 973  C  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 2 2 20 20 20 20 20 20 20 20 20 20 20 20 20 20  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ' 2 1 1 1 1 1 1 1 1  8 8 8 0 0 0 0 1 2 2 4 5 5 4 2 2 1 0 0 9 8 7 6 5 3 3 2 1 1 1 0 0 0 0 d d d d d d 0 1 0 0 1 1 2 2 3 4  483 491 494 494 496 500 500 505 505 511 522 522 529 529 537 543 546 549 553 553 555 560 566 566 568 568 568 573 583 586 0 0 0 0 1 1 1 5 53 54 0 0 0 0 3 7 13 13 13 13  Listing  of Unit  Page  ParamSave  i f r e a d w r i t e o r ( i o r e s u l t = 0) then Begin { f i l e opened s u c c e s s f u l l y > TaskSw i t c h ; readopen:= t r u e ; { c r e a t e the read l i s t > if r e a d w r i t e then Begin readlist:= writelist; w h i l e r e a d l i s t <> n i l do w i t h r e a d l i s t ® do Begi n read_next:= w r i t e _ n e x t ; r e a d l i s t : = w r i t e next End: { of while } readlist:= writelist; r average:= average End { of readwrite } else ParamReset; TossRL i s t End { of s u c c e s s f u l open } else readname:= n o f 1 1 e { f i l e does not e x i s t End; { o f f i l e named > TossRName End { of not readopen } End { o f 'R' } End { o f Case } U n t i l c h = MapCommandKey ScrnReturn; Po11 I n p u t s End; { of PrmFile )  (sc_escape_key,  false);  Segment P r o c e s s P a r a m P u t ; { w r i t e l i s t e d parameter v a l u e s to w r i t e f i l e ) V a r 11, t 2 : t i m _ r e c ; raw t a b l e : a n a _ i n _ t a b l e ; param: param_ptr; F u n c t i o n SaveOK: b o o l e a n ; Begin SaveOK:= r u n n i n g a n d w r i t e o p e n a n d e n a b l e d End; { o f SaveOK } Beg i n wa i t ( r e w r i t t e n ) ; w h i l e r u n n i n g do Begin { w a i t f o r w r i t e f i l e t o be o p e n e d & e n a b l e d } Repeat i f r u n n i n g and not w r i t e o p e n then wait (rewritten);  9  Appendix 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 ' 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 101 1 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2  C  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  4 3 3 3 4 4 5 5 5 5 5 6 6 7 7 7 7 7 7 7 7 7 9 0 0 0 2 2 2 3 0 0 O 9 7 8 8 9 9 8 7 7 7 6 4 2 0 0 O d  27 41 55 55 61 61 61 7 1 7 1 74 79 85 85 85 88 91 91 96 1 13 123 128 133 142 142 146 150 176 183 193 202 235 247 252 252 260 270 270 270 274 278 278 287 287 295 297 297 0 0 0 1  L i s t i n g of  Unit  ParamSave  Page  i f r u n n i n g and n o t e n a b l e d t h e n wait ( w r i t e _ d a t a ) U n t i l n o t r u n n i n g o r ( w r i t e o p e n and e n a b l e d ) ; s a v e d a t a u n t i l n o t ( w r i t e o p e n and e n a b l e d ) } < w h i 1 e SaveOK do Beg i n { dump i n t e g r a t i o n sums } i f ignore > 0 then AnalnStatus (raw_table): { r e c o r d time, wait out i n t e g r a t i o n time } TimSubTO ( t 1 ) ; WaitTick (integrate); i f SaveOK t h e n Begin ( r e a d t i m e and a n a l o g i n p u t v a l u e s ) TimSubTO ( t 2 ) ; AnalnStatus (raw_table); { p r o c e s s and s a v e t h o s e v a l u e s } TimMinus ( t 2 , t 2 , t 1 ) ; w r i t e f i l e ® : = T i m l n S e c o n d s ( t 1 ) + 0.5 * T i m l n S e c o n d s ( t 2 ) ; if r e a d w r i t e then param_time:= writefile®; PFPut (404); param:= w r i t e l i s t ; w h i l e param <> n i l do w i t h p a r a m ® do Begin i f measure = n i l then writefile®:= v a l u e else with measure®, raw_tab1e[chan_in] do i f c o u n t <= 1 then writefile®:= s c a l e i n * r e a d i n g else writefile®:= s c a l e _ i n * (256.0*sum msword + s u m _ l s b y t e ) / c o u n t i f r e a d w r i t e then read_data:= writefile®; PFPut ( 4 0 5 ) ; param:= w r i t e _ n e x t End; { of w h i l e , w i t h } i f r e a d w r i t e and n o t r w _ v a l i d t h e n Beg i n ( n o t e new r e a d / w r i t e d a t a } rw__va 1 i d : = t r u e ; signal (rw_ava11) End; { o f s i g n a l new r e a d / w r i t e d a t a } if s i n g l e then enabled:= f a l s e ; { wait f o r i g n o r e parameter save time to pass } if running then WaitTick (ignore) End {of if } End { of whi1e } { of w h i l e r u n n i n g } End { o f Segment ParamPut > End  Segment  Procedure  PDatStrt;  Appendix 1024 22 1025 22 1026 22 1027 22 1028 22 1029 22 22 1030 103 1 • 22 1032 22 1033 22 1034 22 22 1035 1036 22 1037 22 22 1038 22 1039 22 1040 104 1 2 1042 2 1043 2 1044 2 1045 2 2 1046 1047 2 1048 2 1049 2 2 1050 105 1 2 1052 2 1053 2 1054 2 1055 2 1056 2 1057 2 1058 2 1059 2 2 1060 1061 2 1062 2 1063 2 1064 2 1065 2 1066 2 1067 2 1068 2 1069 2 2 1070 107 1 2 1072 2 1073 2  C  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1  d d 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 d d d d 0 1 2 2 2 2 2 2 2 2 2 3 3 5 5 4 3 5 5 6 7 7 6 4 3 3 1 0 0  1 2 0 0 8 16 34 44 52 62 73 91 107 0 0 0 0 1 1 2 7 , 0 • 0 0 6 21 27 42 42 69 103 1 15 120 123 123 130 139 14 1 141 148 153 153 157 161 161 163 163 17 1 0 0  Listing  of U n i t  ParamSave  Page  pid: processid: stack, p r i o : integer; Begin readlist:= nil; writelist: n i l ; readopen:= f a l s e ; writeopen: false; readname:= no f i l e ; w r i t e n a m e : - r e a d _ name: seminit (rewritten, 0); enabled:= f a l s e ; single: false; seminit (write_data, 0): i g n o r e s 1140; integrate: 60; readwrite: false; s e m i n i t (rw a v a i l , 0 ) ; rw S t r t l n f o ('ParamSav', 'ParamPut', s t a c k , p r i o , s t a r t (ParamPut, p i d , s t a c k , p r i o ) End; < of P D a t S t r t >  11  Var  3  3  3  3  3  v a 1 i d: = f a 1se; true);  P r o c e d u r e ParamF i 1 e ; Var c h : char; able: s t r i ng[8]; rept: s t r i ng[8]; Begi n Repeat i f e n a b l e d then able: 'enabled' else able:= 'disabled'; 1f s i n g l e t h e n rept:= 'single' else rept : = 'multiple'; ch:= P r o m p t C a p I n ( 0 . 0. c o n c a t ( ' D a t a L o g : S ( t a t u s ['. a b l e , '] L ( o g g i n g [ ' . r e p t , '] F( t'S'.'L'.'F'.'E']); i f r u n n i n g then Case ch of 'S': Begi n enabled:= not e n a b l e d ; i f e n a b l e d then s i g n a l (wr i t e _ d a t a ) End; < o f 'S' ) 'L ' : Begin s i n g l e : = not s i n g l e ; 1f n o t e n a b l e d t h e n Beg 1 n enab1ed:= true; signal (wr1te_data) End { o f not e n a b l e d ) End; { o f 'L' } ' F ' : PrmF i 1 e End { of Case > U n t i l E r r o r N o t e d o r ( c h = 'E') End; { of P a r a m F i l e ) 3  E ( x i t ' ),  to  Appendix 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 1 10 1111 1112 1113 1 1 14 1115 1 1 16 1117 1 1 18 1 1 19 1 120 1121 1 122 1 123  C  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ' 2 2 2 . 2 2 2 2 2  Compiler 1 :0 1 :d 1 :d 6 :0 6: 1 6: 1 1 :0 1 :0 1 :d 1 :d 7 :0 7: 1 7: 1 1 :0 1 :0 1 :0 1 :d 1 :d 2 :d 2 :d 2 :d 2 :d 2: d 2 :d 8 :d 8 :0 8 :0 8: 1 8: 1 8: 1 8: 1 8: 1 2 :0 2 :0 2: 1 2: 2 2: 2 2: 3 2: 3 2: 3 2: 3 2 :3 2: 3 2: 3 2: 3 2:4 2: 5 2 :6 2 :: 7 2 :: 7  0 1 1 0 0 5 0 0 1 1 0 0 6 0 0 0 1 1 1 3 9 14 15 1 1 0 0 0 9 9 21 21 0 0 0 6 6 6 10 17 23 26 39 4 1 4 1 46 46 57 57 70  Listing  of U n i t  Page  ParamSave  P r o c e d u r e P F P u t { ( e r r num: i n t e g e r ) ) ; { put ( w r i t e f i l e ) , i f i o e r r o r then N o t e E r r o r Beg i n p u t (wr i t e f i 1 e ) ; i f i o r e s u l t <> 0 t h e n N o t e E r r o r ( e r r num, End; ( o f PFPut >  (err_num)  }  ioresult,  false)  P r o c e d u r e PFGet ( e r r _ n u m : i n t e g e r ) ; < get ( r e a d f i l e ) , i f i o e r r o r then N o t e E r r o r (err_num) > Beg i n get (readfi 1 e ) ; i f i o r e s u l t <> 0 t h e n N o t e E r r o r ( e r r num, i o r e s u l t , false) End; < o f PFGet >  Procedure ParamReset; { r e s e t parameter read f i l e > Var o l d param, new_param: p a r a m _ p t r ; dummy: a r r a y [ 1 . . 3 ] o f r e a l ; r e a d name: s t r i n g [ 8 ] ; i : i nteger; P r o c e d u r e CopyWtoR; { copy w r i t e f i l e b u f f e r s t o r e a d f i l e b u f f e r s } V a r window: i n t e g e r ; Begin ( s a v e window p o i n t e r } m o v e l e f t ( r e a d f i l e , window, 2 ) : < copy w r i t e f i l e t o r e a d f i l e } moveleft ( w r i t e f i l e , r e a d f i l e , sizeof ( r e a d f i l e ) ) ; < r e p l a c e window p o i n t e r } m o v e l e f t (window, r e a d f i l e , 2) End; ( o f CopyWtoR > Beg 1 n i f readopen then Begin { p o i n t t o b e g i n n i n g of r e a d f i l e } read 11st: = n i l ; if r e a d w r i t e then CopyWtoR; reset (readfi1e): 1f i o r e s u I t <> 0 then N o t e E r r o r (401, i o r e s u l t . f a l s e ) ; Pol 1 Inputs; { c r e a t e new r e a d 1 1st } i f running then Repeat f o r 1:= 1 t o 3 do Begi n dummy[i]:= r e a d f i l e © ; PFGet ( 4 0 6 )  12  Appendix 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1131 1 132 1 133 1 134 1 135 1 136 1 137 1 138 1 139 1 140 114 1 1 142 1 143 1 144 1 145 1 146 1 147 1 148 1 149 1 150 1151 1 152 1 153 1 154 1 155 1 156 1 157 1 158 1 159 1 160 1 161 1 162 1 163 1 164 1 165 1 166 1 167 1 168 1 169 1 170 117 1 1 172 1 173  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ~2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 2 :6 2 :5 : 2 :5 : 2 : :5 2 :5 : 2 :5 : 2 : 5 2 :5 2 :4 2 :4 2 : 3 2 : 3 2: 2 1 :0 ; 1 :0 1 :0 : 1 :d : 1 :d 3:: d 3 :d 9::0 9: 1 3 :0 3::d 10::0 10 : 1 10 : 1 10 : 1 3 :0 3 :0 3:: 1 3:: 1 3:: 1 3:: 2 3:: 3 3: 3 3: 3 3: 5 3: 6 3::6 3 :6 : 3 :6 3::8 3::9 3::9 3::9 3 :8 3::6 3:5 3:: 4  73 8 1 89 97 100 103 1 14 120 120 132 132 140 143 0 0 0 1 1 1 2 0 0 0 1 0 0 4 14 0 0 0 2 4 9 9 9 14 27 27 34 39 43 54 54 62 67 67 73 73 77  L i s t i n g of U n i t  ParamSave  End; { of f o r i > move l e f t (dummy, r e a d name, s i z e o f ( r e a d _ n a m e ) ) ; new param:= PrmNamed ( r e a d _ n a m e ) ; i f r e a d 11st = n i l then read l i s t : new_param else o l d p a r a m © . r e a d _ n e x t : = new_param; i f new param <> n i l t h e n o l d _ p a r a m : = new_param; Pol 1 Inputs U n t i l n o t r u n n i n g o r (new_param = n i l ) ; { r e a d i n t e g r a t i o n time > r average: readfile®; PFget (407) End ( o f i f readopen > End; { o f ParamReset } 3  3  F u n c t i o n ParamGet: { read s p e c i f i e d parameters' r e a d d a t a from s p e c i f i e d read f i l e V a r param: p a r a m _ p t r ; F u n c t i o n ReadOK: b o o l e a n ; Begin ReadOK:= r u n n i n g a n d r e a d o p e n End; < o f ReadOK } Procedure WaitWrite; Begin wait (rw_ava1l); { decrement semaphore count ) P a r a m G e t : ReadOK a n d r w _ v a l i d ; rw v a l 1 d : - f a 1se End; ( of WaitWrite > Begin ParamGet: false: Pol 1 Inputs; i f ReadOK t h e n Beg i n i f rw v a 1 i d then WaitWrite { r e t u r n w i t h t h e new r e a d / w r i t e r e c o r d } else i f not eof ( r e a d f i l e ) then Begin { r e t u r n w i t h the next o l d read r e c o r d ) param t i m e : r e a d file®; PFGet ( 4 0 8 ) : param: r e a d _ l i s t ; w h i l e ReadOK a n d ( p a r a m <> n i l ) do w i t h p a r a m ® do Beg 1 n read d a t a : readfile®; PFGet ( 4 0 9 ) ; param: read_next End; { of w h i l e , with > P a r a m G e t : ReadOK End { o f not eof ) else i f r e a d w r i t e a n d w a i t ok t h e n 3  3  3  3  3  3  3  Page  13  Appendix 1 174 1 175 1 176 1 177 1 178 1 179 1 180 1 181 1 182 1 183 1 184 1 185 1 186 1 187 1 188 1 189 1 190 End  Compiler  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  3 3 1 1 1 1 1 5 5 5 5 1 1 1 1 1  6 2 0 0 0 d d 0 1 1 1 0 0 0 0 1 0  86 86 0 0 0 1 1 0 0 12 24 0 0 0 0 19 0  Listing  End End;  of Unit  Page  ParamSave  WaitWrite { wait ( o f i f ReadOK > { o f ParamGet }  f o r new  read/write  rec }  Procedure pfHalt; { s a f e l y s h u t down w r i t i n g p r o c e s s } Beg i n readopen:= f a l s e ; writeopen:^ f a l s e ; enabled: signal (rewritten); signal (rw_avail); signal close ( w r i t e f i l e , lock) End; { of p f H a l t }  Begin < initialization PDatStrt End.  14  3  false; (write_data)  >  of Compilation.  CTi  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 259 401 4G0 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 48 1 482 483 484 485 486 487 488 489 490 49 1 492 493  0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  C  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0  Listing  of U n i t  Page  Plotter  1  {$L r e m o u t : ) Unit P l o t t e r ; Interface Procedure PlotSetup; { i n t e r a c t i v e l y s e t up Procedure p l H a l t ; { s h u t down p l o t t e r  and  perform  a plot  }  process }  I m p l e m e n t a t 1 on {$L-> {$L-} <$L-> Var 3 5 13 14 15 16 16 16 3  Uses  S c r e e n O p s . E x t r a S c r , W r i t C o n s , ReadKybd, S c r n B u f f , {$L©> Schedule, P l o t U t i l , Parameter, P a r a m U t i l , ErrMessg, {$L®) M i s c F u n c , ParamSave, <$U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; <$L@}  make_plot: semaphore: xparam, yparam: p a r a m _ p t r ; xmin, xmax, y m i n , ymax; r e a l ; xlstime: boolean; enabled: boolean: f i r s t : boolean;  Function { return  rea 1 ; ( v a r x, y wa i t ok: b o o l e a n ) : b o o l e a n ; with data p o i n t s or true i f eof >  GetData  Segment P r o c e d u r e P l o t S e t ; { i n t e r a c t i v e l y s e t up and Const  perform  a plot  forward;  }  < c o o r d i n a t e s of c u r s o r f o r v a r i o u s e n t r i e s } xxmax = 67 yx = 22; < x bounds > xxmin = 6; yymax = 2 xy = 0; { y bounds } yymin = 2 1 { x p a r a m e t e r name > yxnam = 22 xxnam = 33 < x " units ) x x u n t = 43 y x u n t = 22 xynam = yynam = 1 1 2 { y " name } { y " units ) 4 y y u n t = 12 xyunt = xnew. = 53 ynew = 1 1 { p l o t new d a t a o n l y } f u n i t = 4; { f i e l d widths f rea 1 =11: f name = 8 ; .OE37; maxrea1  , up, prompt: Procedure Beg i n  down l e f t , r i g h t sb_prmt_ptr;  esc:  TossParam  xu. yu : i n t e g e r ;  (xn, yn,  char;  param:  param_ptr); cri cr.  Appendix 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 51 1 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 54 1 542 543  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  Compiler  C 2 2 2 2 2 2 2 2 2 2 1 1 1 3 3 3 3 3 3 3 1 1  1 4 4 1 1 1 5 5 5 5 5 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6  1 1 3 3 2 1 3 4 4 3 0 0 d 0 1 1 3 3 2 1 0 0 d 0 1 0 0 d 0 1 1 1 1 0 0 d d 0 1 1 1 3 3 4 5 5 5 5 4 3  0 1 4 9 12 14 18 18 27 34 0 0 1 0 0 0 3 14 23 25 0 0 1 0 0 0 0 1 0 0 8 17 25 0 0 1 1 0 0 3 9 13 25 33 33 43 61 7 1 85 91  Listing  of U n i t  Page  Plotter  i f param = n i l then Begin T o s s B l a n k s ( x n , y n . f_name); T o s s B l a n k s (xu, yu, f _ u n i t ) End < of n i l } else w i t h p a r a m © do Beg 1 n T o s s S t r i n g ( x n , y n , name, f_name) ; T o s s S t r i n g (xu, yu, u n i t s , f_unit) End { of not n i l > End: < of TossParam } P r o c e d u r e TossXParam; Beg i n i f x i s t ime then Begin T o s s S t r i n g (xxnam, yxnam, ' t i m e ' , f _ name): T o s s S t r i n g (xxunt, yxunt, 'sec', f_unit) End else T o s s P a r a m (xxnam, yxnam, x x u n t . y x u n t , End; { of TossXParam ) P r o c e d u r e TossYParam; Begin T o s s P a r a m (xynam, yynam. x y u n t , End; { o f TossYParam } Procedure TossBounds; Beg i n T o s s F l o a t ( x x m i n , yx, T o s s F l o a t (xxmax, yx, T o s s F l o a t (xy, yymin, T o s s F l o a t ( x y , yymax, End; < of TossBounds }  xmin, xmax, ymin, ymax.  P r o c e d u r e DataBounds; V a r x, y: r e a 1 ; Beg i n ParamReset; i f G e t D a t a ( x m i n , ymin, then Begin xmax:= xmin; ymax:= w h i l e G e t D a t a ( x , y, Beg 1 n i f x < xmin then else i f y < ymin then else End; { of w h i l e ) TossBounds  xparam)  yyunt. yparam)  f_real); f_real); f_real); f_real)  false) ymin; false)  do  xmin:= x xmax:= rMax ( x . xmax) ; ymin:= y ymax:= rMax ( y . ymax)  C5>  Appendix 544 545 546 547 548 549 550 55 1 552 553 554 555 556 557 558 559 560 56 1 562 563 564 565 566 567 568 569 570 57 1 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 59 1 592 593  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  Compiler  C 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 •1 1 1 1  2 0 0 0 1 1 1 1 1 1 2 2 3 3 3 2 1 1 1 1 1 1 2 2 2 2 2 2 4 4 5 4 5 5 6 5 6 6 7 6 6 7 7 3 3 2 3 3 3 5  91 0 0 0 0 6 12 18 24 30 33 33 33 36 51 57 60 67 76 78 82 82 82 82 1 18 125 125 141 144 145 150 161 166 167 172 184 189 190 195 207 2 12 212 214 226 229 229 23 1 234 234 234  Listing  of U n i t  ( of data e x i s t s { of DataBounds >  End End;  Page  Plotter 1n f i l e  )  Begin < *** m a i n body o f P l o t S e t + + * } up; = MapCommandKey ( s c _ u p _ k e y , f a l s e ) ; down:= MapCommandKey ( s c _ d o w n _ k e y , f a l s e ) ; 1 e f t : = MapCommandKey ( s c _ l e f t k e y , f a l s e ) ; r i g h t : - MapCommandKey ( s c _ r i g h t _ k e y , f a l s e ) ; e s c : = MapCommandKey ( s c _ e s c a p e _ k e y , f a l s e ) : if f i r s t then Beg i n { move pen t o t o p r i g h t c o r n e r s o o p e r a t o r c a n s e t p l o t first: false; P l o t B o u n d s ( x m l n , xmax, ymin, ymax); P l o t (xmax, ymax) ( of f i r s t ) End; ScrnEnter ('PlotSet'); ScrnPrompt ( 0 ) ; prompt : TossBounds; TossXParam; TossYParam;  size  )  3  3  Repeat ch:  PromptCapIn ( 0 . 0, p r o m p t ® , [' X ',' Y ', 'D'.up,down,1 e f t , r i g h t , ' S ' , e s c ] ) c h <> e s c t h e n enabled: false;  3  if  3  i f c h i n [ u p , down, l e f t , right] t h e n Beg i n i f ch up then ymax: F e t c h F l o a t ( x y , yymax, e l se down i f ch then ymin: FetchFloat (xy, yymin, e l se i f ch left then xmin: FetchFloat ( x x m i n , yx, e l se right ( ch t h e n ) xmax: F e t c h F l o a t (xxmax. y x , End 3  3  f real,  ymln,  maxreal)  f_real,  -maxreal,  ymax)  f'real.  -maxreal,  xmax)  3  3  3  3  3  3  f _ r e a l . xmin,  e l se Case c h of 'X' :  Beg i n xparam:  3  nil;  xistime:  3  false;  maxreal)  3  Appendix 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 6 10 61 1 612 613 614 6 15 6 16 617 618 619 620 62 1 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 64 1 642 643  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  C  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 4 4 4 4 4 4 4 4  5 5 5 5 5 4 4 3 5 5 5 6 5 5 4 4 3 3 3 3 1 1 2 3 3 3 3 3 2 2 1 0 0 0 d 0 1 0 0 0 d d 0 1 1 3 3 3 3 3  240 242 242 257 262 262 266 266 266 269 27 1 27 1 28 1 290 290 294 294 294 294 301 301 32 1 326 326 341 344 347 350 353 353 353 O 0 O 1 O 0 0 0 0 1 1 O 0 2 7 7 1 1 24 30  Listing  of U n i t P l o t t e r  Page  TossXParam; xparam:= PrmPrmpt (0, 0, 'X A x i s (<esc> f o r t i m e ) ' , f a l s e , x i s t i m e : = xparam = n i l ; TossXParam End; { o f 'X' ) 'Y ' :  'D': End  Begin yparam:= n i l ; TossYParam; Repeat yparam;= PrmPrmpt ( 0 , 0, U n t i l y p a r a m <> n i l ; TossYParam End; < o f 'Y' )  'Y A x i s ' ,  false,  false);  false)  DataBounds  < of Case >  U n t i l E r r o r N o t e d o r ( c h i n ['S', e s c ] ) ; i f c h = 'S' t h e n Beg 1 n P l o t B o u n d s ( x m i n , xmax, y m i n , ymax); P1otAxes; ParamReset: enab1ed:= true; s i g n a l (make p l o t ) End; ScrnReturn End; ( of P l o t S e t  )  Procedure PlotSetup; Beg i n PlotSet End: ( of P l o t S e t u p >  F u n c t i o n G e t D a t a { ( v a r x. y: r e a l ; wait_ok: { r e t u r n with data p o i n t s or true i f eof ) Beg i n i f ParamGet (wait_ok) then Begin i f x i s t ime then x:= p a r a m _ t i m e else x:= x p a r a m ® . r e a d d a t a ; y:= y p a r a m ® . r e a d _ d a t a ; GetData:= t r u e  boolean): boolean  };  4  Appendix 644 645 646 647 648 649 650 65 1 652 653 654 655 656 657 658 659 660 66 1 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 68 1 682 683 684 685 686 687 688 689 690 69 1 692 693  C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 4: 2 4: 1 1 :0 1 :0 1 :0 1 :d 5 :d 5 :d 6 :0 6: 1 6: 1 5 :0 5 :0 5: 1 5: 2 5: 2 5: 3 5 :4 5: 4 5: 4 5: 3 5: 1 1 :0 1 :0 1 :0 1 :d 7 :d 7 :d 7 :0 7: 1 7: 1 7: 1 7: 1 7: 1 7: 1 7: 1 7: 1 1 :0 1 :0 1 :0 1: d 1 :d 3 :0 3: 1 1 :0 1 :0 1 :0 1 :0 1: 1 :0  30 32 0 0 0 1 1 5 0 0 1 1 0 0 2 2 5 10 10 17 20 20 23 0 0 0 1 1 2 0 0 24 27 30 33 39 48 64 0 0 0 1 1 0 0 0 0 0 0 0 0  Listing  of Unit  Page  Plotter  5  End ( of not eof ) else GetData:= f a l s e End; ( of GetData }  Process PlotData; Var x, y: r e a 1 ; Function PlotOK: boolean; Beg i n i f enabled then P l o t O K : = G e t D a t a (x else PlotOK:= f a l s e End: { of PlotOK > Begin Repeat wa i t (make p l o t ) ; w h i l e P l o t O K do Begin P l o t (x, y ) ; P1otDrop; PlotLift End { of w h i l e not eof } U n t i l not r u n n i n g End; { of P l o t D a t a )  Procedure PlotStrt; Var p i d : p r o c e s s i d : stack, p r i o : integer; Beg i n xmin:= 0.0: xmax:= 1.0: ymin:= xmin: x i s t i me:= f a 1se; enab1ed:= f a 1se: f i r s t : = true; xparam:= n i l ; yparam:= n i l ; s e m i n i t (make_plot, 0 ) ; S t r t l n f o ( ' P l o t t e r ' , 'PlotData', stack s t a r t ( P l o t D a t a . p1d. s t a c k , p r i o ) End; < of P l o t S t r t }  true)  ymax :  prio,  true) ;  Procedure p l H a l t ; ( s h u t down p l o t t e r p r o c e s s > Beg i n s i g n a l (make p l o t ) End; { of p l H a l t }  Begin < initialization > PlotStrt End.  ^l o  Appendix C  End  of  Compiler  Compilation.  Listing  of  Unit  Plotter  Page  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 17 18 19 20 2 1 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  Compiler  D 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 12 13 14 15 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 177 177 1 1 177 177 1 0  Listing  of U n i t  Page  E12ISR  1  {$L remout:> Uni t E 12 i s r ; Interface a  { T h i s u n i t i s a memory and p o s i t i o n l o c k e d segment i n t e r n a l and/or E 1 2 d i g i o . I t i s n o t meant t o be u s e d o t h e r w i s e . > Const  njumpsxS  =21;  { 3 * tt e n t r i e s  Var < Assembler data a r e a s : t h e y may be c h a n g e d by  i n i s r jump  table  i n g e n e r a l t h i s d a t a i s not an i s r d u r i n g s u c h u s e . }  to  E12ana  }  used  by  Pascal  as  { D a t a a c t u a l l y u s e d as Z80 o p c o d e s : > j u m p t a b l : p a c k e d a r r a y [ 1 . . n j u m p s x 3 ] o f 0..255; { jumps t o some u t i l i t y r o u t i n e s 1n e 1 2 i s r . a > { D a t a u s e d by d i g i t a l i s r : •> pulse: boolean; { d i g i t a l p u l s e i s on? > c u r r d i g : s e t of 0 . 1 5 ; ( current d i g i t a l output } p l s q u i t : 0..maxint; { 1 sword of time t o t u r n o f f p u l s e } p l s d a t a , plsmask: s e t of 0 . 1 5 ; { u s e d t o end p u l s e } { D a t a u s e d by a n a l o g i s r : } anabuff: a r r a y [1..16] of packed r e c o r d reading: Integer; { l a t e s t r e a d i n g of Input > sum c o u n t : 0..255; { H r e a d i n g s summed f o r a v e r a g e c a l c ' n } sum I s b y t e : 0..255; { l e a s t s i g n i f i c a n t b y t e o f t h a t sum } sum msword: i n t e g e r ; { most " word " " " } t1: integer; { 1 s w o r d o f t i m e when d x / d t c a l c ' n d o n e } xO: i n t e g e r ; { r e a d i n g at time to } x1: i n t e g e r ; { " " " 11 > d e l t a t: 0..maxint: { t 1 - t 0 , w i l l be >= m1n_dt > ready: boolean: { c h a n n e l i s b e y o n d s e t p o i n t by m a x e r r ? } setpoint: Integer; { check r e a d i n g a g a i n s t t h i s v a l u e } maxerror: integer; < and s e t r e a d y 1f s t r a y e d b e y o n d > min_dt: 0 . 2 5 5 ; { d x / d t : = x1-x0 / t 1 - t 0 ok a f t e r m1n_dt > p r i o r i t y : 0..8; { 1f < 8, t r i g g e r e v e r y 2 * * p r i o r i t y p a s s } f i l l e r : 0..3; { unused } invert: boolean; { invert this channel's reading? } newddt: b o o l e a n { d x / d t c a l c ' n u p d a t e d by l a t e s t i s r ? } end; Procedure  InitE12isr;  { must be  Imp 1ementat i o n Procedure End.  InitE12isr;  external;  called  by  E12dig/ana1o  initialization  Appendix  End  of  D  Compiler  Compilation.  Listing  of Unit  E12I5R  Page  Appendix  D  Page  0  OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO  oooo oooo oooo oooo oooo oooo oooo oooo  0003 0006 0009 OOOB 000E 0011 0014 0017 0018 0O1B 001C 001C 001C 001C 001C 001F 0022 0025 0028 002B 002 E 0031 0031 003 1 0031  Assembler File:E12ISR.A  OOOO  Listing Z80  of Unit  E12ISR E x t e r n a l IV.0  Assembler  sbios  .EOU  [a.3]  location  0  . PROC I n i t E 1 2 i s r ;Copy E 1 2 i s r jump t a b l e t o j u m p t a b l , ; i n interrupt vector tables. .CONST njumpsx3 .PUBLIC j u m p t a b l .PUBLIC c u r r d i g 0030 0032 001E 0053 00B1 0040  21 1 1 01 ED 21 22 21 22 AF 32 C9  C3 C3 C3 C3 C3 C3 C3  **+* OOOO  oooo  BO **+* 3000 **** 3200  anavect digvect mask maskreg control nostrob  :Copy a c t u a l Id Id Id  ldir Id Id Id Id  xor OOOO  Id  of sbios  insert  Anaserv  i n ram  and Digserv  address  3 * number o f e n t r i e s i n j u m p t a b l jump t a b l e t o r o u t i n e s i n A n a i s r current d i g i t a l output byte  sbios+0030H sbios+0032H sbios+001EH 53H 0B1H 040H  .EOU .EOU .EOU .EOU .EOU .EOU  Page  Routines  analog i s rentry in table digital " " " " u - a r t i n t e r r u p t mask s a v e d h e r e " " " register port E12 c o n t r o 1 / d e v 1 c e a d d r e s s p o r t E 12 s t r o b e o f f  jump t a b l e t o ( j u m p t a b l ) : (HL):= a c t u a l jump t a b l e HL,jmptabl DE , j u m p t a b l (DE):= new jump t a b l e image BC,nj umpsx3 number o f b y t e s i n jump t a b l e move t h e d a t a get a d d r e s s o f Anaserv r o u t i n e HL,Anaserv i n s e r t 1n t a b l e (anavect),HL HL,Digserv repeat f o r Digserv (digvect),HL A f i r s t D i g W r i t e r e s e t s a l l unmasked ( c u r r d i g),A  bits  ret  **** **** **** **** •* * * * **** +***  jmptabl: ;jump t a b l e t o JP JP JP JP JP JP JP.  routines within D i gsend GetCfrmA SendA2C RdClkDE Strtana ISR o f f ISR_on  ;External d i g i t a l i s r data .PUBLIC pu 1 s e .PUBLIC p i s q u i t  E121sr: mask b y t e L w i t h C, u p d a t e d i g i t a l output r e a d E12 d i g i t a l input A i n t o C s e n d d a t a i n A t o E12 d e v i c e C ( l o s e A ) ;DE:= c l o c k l s w o r d ( l o s e AF, C ) t r i g g e r A/D, p r e p a r e b u f f e r s t o r e a d i t mask o f f a n a i s r I n t e r r u p t unmask a n a i s r i n t e r r u p t  area: p u l s e i s on b o o l e a n lsword of time t o t u r n  o f f pulse  Appendix 0031 0031 0031 0031 0031 0031 0031 003 1 0031 003 1 0031 0031 0031 0032 0033 0036 0037 003B 003C 003 E 0041 004 1 0042 0044 0045 0046 0047 0048 0048 004 B 004E 0050 0051 0053 0056 0057 005A 005B 005 E 0060 0060 0060 0060 0060 0060 0060 0060 0062 0065 0066  D  Assembler  Listing  of Unit  E12ISR E x t e r n a l  .PUBLIC p i s d a t a .PUBLIC p1smask  -  0001 0056  ; D i g i t a l i s r symbols: 1 d i gb i t . EOU d i g t 1 m e . EOU 56H  Page  Routines pulse "  data mask  r e l a v e n t b i t i n i n t e r r u p t mask d i g i t a l pulse i n t e r v a l timer port  32 OOOO 2 1 1E00 CB 8E 7E D3 53 3A OOOO 4F 3A OOOO 6F CD + * * * 18E4  D i gserv I f >=, mask d i g d a t a w i t h d i g m a s k ;Check c l o c k r e a d i n g a g a i n s t p l s q u i t t i m e . ; and send t o d i g i t a l output. ;Save r e g i s t e r s , c h e c k t i m e : save r e g i s t e r s ex AF exx get c l o c k reading RdClkDE cal 1 i n HL ex DE ,HL g e t q u i t t i m e i n DE Id DE , ( p i s q u i t ) A:= 0, r e s e t c a r r y A xor HL: = tt t i c k s b e y o n d t u r n o f f t i m e sbc HL , DE jump i f a t o r p a s t t u r n o f f t i m e P,pu1sdon JP ;Time n o t p a s s e d , s e n d 255 t o i n t e r v a l t i m e r (-M/60 s e c o n d ) : A dec r e s t a r t c o u n t e r w i t h 255 ( d 1 g t i me),A out get back r e g i s t e r s , enab. i n t e r u p t s , r e t u r n g e t b a k : exx ex AF e i ret ; P u l s e i s c o m p l e t e : t u r n i.t o f f a n d mask o f f i n t e r r u p t : flag pulse i s o f f (pulse),A p u l s d o n Id p o i n t t o i n t e r r u p t mask w i t h HL HL,mask Id turn o f f digserv interrupt d i g b i t.(HL) res g e t new mask i n A A,(HL) Id send t o u - a r t (maskreg),A out A.(pismask) l o a d r e g i s t e r s w i t h p u l s e mask a n d d a t a Id C. A Id A.(p1sdata) Id Id L , A send t h e o f f p u l s e , update c u r r d i g cal 1 D i gsend get back r e g i s t e r s , e n a b l e i n t e r r u p t s , r e t getbak ir  0080 0001 0005 • 3E C 1 CD + * + 59 3C  RdClkDE ;Read E12 c l o c k . EOU mode i n clklsb . EOU c1kun1 . EOU Id cal 1 Id i nc  08 D9 CD EB ED AF ED F2  * + ++  5B OOOO 52  + *+ +  3D D3 56 D9 08 FB C9  Assume i n t e r r u p t s d i s a b l e d , l o s e AF, C: 1 s w o r d i n t o DE. 080H digital i n p u t command f l a g c l o c k l s b y t e & l a t c h E12 a d d r e s s 1 c l o c k u n l a t c h E12 a d d r e s s 5 A , c 1 k 1 s b I n o s t r o b I modein ; l a t c h c l o c k , read l s b y t e of time GetCfrmA save i n E E ,C read next l s b y t e of time A  Appendix 0067 006A 006B 006D 0O60 006D 006D 006D 0060 006 F 007 1 0073 0075 0077 0079 007B 007C 007C 007C 007C 007C 007C 007 C 007D 007 E 007 F 0080 0081 0084 0085 0086 0087 0089 0089 0089 0089 0089 008B 008C 008E 0090 0092 0094 0096 0098 0099 0099 0099 0099 0099  D  CD * * * * 51 3E C5  Assembler  L i s t i n g o f Uni t E12ISR E x t e r n a l cal 1 ld ld  GetCfrmA D,C A.clkunl  Routines  Page  ;save i n D nostrobI modein ;unlatch clock  00B3 D3 B1 E6 BF D3 B1 OE B3 ED 48 F6 40 D3 B1 C9  GetCfrmA: ;Read E12 d i g i t a l i n p u t A i n t o C. Assume i n t e r r u p t s d i s a b l e d a n d n o s t r o b ; a n d mode i n b i t s o f A a r e s e t , 1 o s e F: 0B3H data i n . EOU :E12 d i g i t a l Input p o r t out ( c o n t r o 1 ) ,A and -•nostrob ;set strobe out (control). A C , d a t a 1n ld ; d i g 1 t a l Input p o r t in C, ( C ) ;read t h e d i g i t a l input p o r t Into C or nostrob ;reset strobe out (control), A ret  0003 7D A1 47 79 2F 2 1 OOOO A6 BO 77 OE 03  D1gsend ;Send d a t a i n L masked by C t o d i g i t a l o u t p u t s , u p d a t e c u r r d i g . U s e s AF. BC. HL. : interrupts are d i s a b l e d . o u t c o m d . EOU 3 ; d i g i t a l o u t p u t command Id A. L ;get v a l u e In A and C . a c c e p t o n l y unmasked b i t s B. A ld ;save i n B ld ; g e t mask A.C cpl ;complement o f mask HL.currd ig ;point to o l d output s t a t u s Id ; l e a v e o n l y masked o l d b i t s and (HL) or B ;combine w i t h r e q u e s t e d c h a n g e s (HL).A ld ;update o u t p u t s t a t u s b y t e ld ' C.outcomd  OOBO D3 BO 79 F6 40 D3 B1 E6 BF D3 B1 F6 4 0 D3 B1 C9  SendA2C :Send d a t a A t o d a t a o u t . EOU out Id or out and out or out ret  Assumes  E12 d e v i c e C (assume i n t e r r u p t s d i s a b l e d , l o s e A F ) : OBOH :E12 d a t a o u t p u t p o r t ;set d e v i c e d a t a (dataout), A A,C nostrob ( c o n t r o l ) ,A .•select d e v i c e , s t r o b e o f f -•nostrob (control), A :strobe the device nostrob ( c o n t r o l ) ,A :strobe o f f  ;External analog i s r data area : .PUBLIC a n a b u f f  ;analog  input b u f f e r s  Appendix D 0099 0099 0099 009A 009B 009D 009 F 00A1 00A2 00A 3 OOA3 OOA3 OOA3 00A 3 00A3 00A 3 00A 3 00A3 00A 3 00A3 00A 3 00A 3 00A 3 00A3 00A 3 00A 3 00A 3 00A3 00A 3 00A3 00A3 OOA3 OOA3 00A 3 00A 3 00A 3 00A 3 00A3 OOA3 OOA3 00A 3 00A 3 00A 3 OOA3 00A 3 OOA4 OOA6 00A 8 00A9 00A9  00 01 OOOO OOOO OOOO 01 00  OOOO 0055 OOBO OOOO 0005 0006 0007 OOOO 0002 0003 0004 0006 0008 OOOA OOOC OOOD 0007 000E 0010 0012 0013 0013 0006 0013 0007 0014  F5 3E FF 03 55 C5 OE BO  Assembler  L i s t i n g of Unit  E12ISR E x t e r n a l  Routines  Page  ;Internal analog i s r data area: channel to read c h a n n e l .BYTE " trigger 1 n x t c h a n .BYTE " po i n t e r t o c h a n n e l t o r e a d ' s r e c o r d I n a n a b u f f buffer . WORD " " " trigger's " " " anabuf f n x t b u f f . WORD triggering t i m e o f most r e c e n t c h a n n e l 0 t r g t ime . WORD r o t a t e through chan t r i g g e r permutations 1 .BYTE rotate power o f 2 a s s o c i a t e d w i t h r o t a t e t r igpwr .BYTE :Ana l o g anab1t a n a t i me e12stat. statbi t msbb i t s i gnb i t overb i t ;Anabuff r e a d i ng sumcnt 1sbyte msword 11 xO x1 del t a t ready rdybi t setpt maxerr m i ndt pr i o r t y i nver t invtblt newddt ddtbi t recs i ze  isr symbols: . EOU 0 . EOU 55H OBOH . EOU . EOU 0 . EOU 5 . EOU 6 7 . EOU record offsets: . EOU 0 . EOU 2 . EOU 3 4 . EOU 6 . EOU . EOU 8 . EOU 10 12 . EOU . EOU 13 7 . EOU 14 . EOU . EOU 16 . EOU 18 . EOU 19 19 . EOU . EOU 6 19 . EOU . EOU 7 . EOU 20  r e l a v e n t b i t i n i n t e r r u p t mask interval timer generates Interrupts e12 s t a t u s p o r t A/D s t a t u s b i t i n e 1 2 s t a t ( d o n e ) " msbit " " " (Inverted) " sign " overload " " " l a t e s t reading o f input tt r e a d i n g s summed o f sum  "  "  time o f dx/dt c a l c u l a t i o n r e a d i n g a t time t o " t1 t1-tO r e a d i n g beyond s e t p t by maxerr? r e a d y b o o l e a n b i t number reading setpoint and maxerror wait b e f o r e v a l i d dx/dt t r i g g e r p r i o r i t y ( b i t s 0..2) invert sign of input? i n v e r t b o o l e a n b i t number new d x / d t c a l c ' n v a l i d ? newddt b o o l e a n b i t number s i z e of e n t i r e channel r e c o r d  Anaserv: :Read l a s t t r i g g e r e d a n a l o g i n p u t I n t o v a l u e S sum b u f f e r s , t r i g g e r ; channel: r e s t a r t timer: ;Save AF a n d BC AF push C o u n t down 255 * 64 m i c r o s e c o n d s A , 255 Id ( a n a t i me),A out BC push :See i f a c o n v e r s i o n i s c o m p l e t e ld C,e12stat  t h e next  Assemb1er  Append i x D OOAB OOAD OOAF OOB1 OOB2 OOB3 OOB4 OOB5 OOB5 OOB5 OOBG OOB7 OOB9 OOBA OOBC OOBD OOBF OOCO OOC1 OOC1 OOC4 OOC4 OOC7 OOC7 OOCA OOCA OOCD OOD1 OOD2 00D3 00D3 00D7 OODB OODB OODE OOE 1 OOE 2 OOE 4 OOE 4 OOE 5 OOE 8 OOE A OOEB OOEC OOEE OOEE OOF 2 OOF 4 OOFG OOF 9  pop pop e i ret  E5 05 DD E5 OC ED 50 OC ED 58 D5 C5 CD * * * * CD 6 0 0 0 CD * * * * 9F00 53 9 F 0 0  DD 2A DD CB  9B00 13 BE  DD 4E DD 46 AF ED 42  06 07  7D DD 96 30 * * 7C A7 28 * *  of Unit in bit  ED 40 CB 40 20 * * C1 F 1 FB C9  2A ED 5D 54  Listing  12  DD CB 13 FE CB 7C 28 * * 21 F F 7 F DD 75 OC  E12ISR  External Routines  B. (C) s t a t b i t ,B nz,done BC AF  test status b i t i f d o n e , r e a d t h e new d a t a , t r i g g e r e l s e g e t b a c k BC and AF. e n a b l e i n t e r r u p t s , r e t u r n  Page  next  done : ;Save o t h e r r e g i s t e r s , r e a d & s a v e d a t a : push HL push DE • IX push read thousands/hundreds digits C i nc in D , (C ) and t e n s / o n e s d i g i t s C 1 nc E , (C) i n save r e a d i n g push DE and f l a g s push BC ; T r i g g e r new c o n v e r s i o n : trigger cal 1 ; Read new t i m e r e a d c l o c k l s b y t e i n t o DE RdClkDE cal 1 nterrupt. enable other i n t e r r u p t s : ;Mask a n a s e r v ISR_off cal 1 ;Get j u s t r e a d c h a n n e l ' s t r i g g e r t i m e , s a v e j u s t t r i g g e r e d . c h a n n e l ' s t i m e : j u s t read channel's t r i g g e r time HL.(trgtime) Id save j u s t t r i g g e r e d c h a n n e l ' s t r i g g e r time ( t r g t ime).DE Id c o p y new r e a d c h a n n e l ' s t i m e t o DE E ,L Id D.H Id ; P o i n t t o j u s t r e a d c h a n n e l ' s r e c o r d i n a n a b u f f w i t h IX: IX.(buffer) Id ddtbit,(IX+newddt) ;reset dx/dt c a l c u l a t i o n v a l i d b o o l e a n res ; S u b t r a c t p r e v ous r e a d i n g t i m e f r o m new t i m e : l s b y t e o f o l d time C, (IX + t 1 ) Id msbyte " " " B , ( I X + t 1+1 ) Id reset carry xor A HL:= delta t HL.BC sbc :Compare d e l t a t w i t h s p e c i f i e d minimum d e l t a t f o r d / d t c a l c u l a t i o n : lsbyte of delta t Id A, L A:= l s b y t e o f ( d e l t a t - minimum d e l t a t ) sub (IX+mindt) i f no b o r r o w , k e e p t h e new d e l t a t nc.keepdt msbyte o f d e l t a t (16 b i t u n s i g n e d i n t e g e r ) A.H Id i s t h e r e an msbyte > 0 t o borrow from? and A if d e l t a t too small, s k i p d/dt c a l c u l a t i o n z,chkovr jr ; D e l t a t >= s p e c i f i e d minimum d e l t a t . S a v e d e l t a t a n d t i m e : ddtbit.(IX+newddt) ;set v a l i d dx/dt c a l c u l a t i o n b i t keepdt: s e t check f o r d e l t a t > maxint 7,H bit i f n o t , ok z,$0 jr e l s e c l i p d e l t a t a t maximum a l l o w e d v a l u e HL,32767 Id lsbyte of delta t $0 Id m  (IX+deltat),L  r  Append i x D OOFC OOFF 0102 0105 0105 0108 010B 010E 0111 0111 01 12 01 13 01 16 01 18 01 1A 01 1A 01 1B 01 1E 01 1F 0120 0123 0126 0129 012C 012D 0130 0133 0136 0139 013A 013A 013C 013E 0141 0142 0142 0145 0146 0148 014B 014B 014E 0151 0155 0157 015A 015D 015D 015E 0161  Assembler  DD 74 OD DD 73 06 DD 72 07 DD DD DD DD  7E 77 7E 77  OA 08 OB 09  C1 D1 21 E02E CB 78 20 *• * 48 21 7B D5 1 1 CD 1 1 CD F 1 1 1 CD 1 1 CD 41  OOOO  0100 **** OAOO *+** 6400 **** E803 ****  CB 68 2Q* + 1 1 1027 19 DD 7E 13 A8 CB 77 C4 + * * * DD 75 DD 74 DD CB 28** DD 75 DD 74  OO 01 13 7E OA OB  7D DD 86 03 DD 77 03  Listing  of Unit  E12ISR  External  Routines  Page  Id (IX + d e l t a t + 1) ,H :msbyte " " ", r e s e t r e a d y b i t Id (IX + t 1 ) , E ; 1 s b y t e o f tIme Id (IX + t 1+1 ) ,D ;msbyte " " ;Copy o l d r e a d i n g : Id A,(IX + x 1 ) ;previous r e a d i n g , t h i s channel Id (IX+xO),A ;save i t Id A,(IX + x l + 1 ) Id (IX+XO+1),A ;Check o v e r l o a d s t a t u s , i f t r u e s e t r e a d i n g t o +/- 12000: c h k o v r : pop BC ;get b a c k f l a g s pop DE ;and r e a d i n g Id HL,12000 bit o v e r b i t,B ;test overload b i t nz,chksgn : true: skip reading conversion jr ; C o n v e r t r e a d i n g t o n a t u r a l b i n a r y i n HL: Id C,B ;save s t a t u s i n C Id ;zero b i n a r y r e s u l t r e g i s t e r HL.O A, E Id ;A: = two l e a s t s i g d i g i t s push DE ;save r e a d i n g on s t a c k Id DE , 1 cal 1 AOFHxDE ;sum:= o n e s Id DE . 10 cal 1 AOFHxDE ;sum:= sum + t e n s AF pop ;A:= two most s i g d i g i t s Id • DE,100 cal 1 AOFHxDE ;sum:=sum + h u n d r e d s Id DE,1000 cal 1 AOFHxDE :sum=sum + t h o u s a n d s Id B,C ;get s t a t u s b a c k i n B ;Add o v e r r a n g e t o r e s u 1 1 : bit msbbi t,B ;test overrange b i t nz,chksgn ;and a d d t o sum i f n e c e s s a r y jr Id DE,10000 ;most s i g b i t c o r r e s p o n d s t o 10,000(dec) add HL, DE ;Check t h i s c h a n n e l ' s i n v e r t f l a g a g a i n s t hardware s i g n b i t : c h k s g n : Id A. ( I X + i n v e r t ) ; i n v e r t i n p u t b o o l e a n In b i t s i g n b 1 t = 1 n v t b 1 t xor B ; i n v e r t o n l y If s i g n neg x o r i n v e r t f l a g g e d bit s i gnb i t,A ;test r e s u l t i s i n b i t signbit cal 1 nz,HL2comp ; i f s i g n n e g a t i v e , 2's c o m p l e m e n t HL ;Save t h e new r e s u l t i n r e a d i n g b u f f e r ( a n d a s x 1 ? ) : Id (IX+reading).L Id (IX+reading+1),H bit d d t b i t , (IX + n e w d d t ) ; c h e c k w h e t h e r d x / d t c a l c u l a t i o n was g o o d z,sumup ; f a l s e , dx/dt c a l c ' n not y e t v a l i d jr Id ( IX + x1 ) ,L ; true, " " i s v a l i d now Id ( IX + x l + 1 ) .H ;Add r e s u l t t o sum b u f f e r : sumup: Id A.L ;get l e a s t s i g b y t e o f a / d r e a d i n g add A, ( I X + l s b y t e ) ;add t o l e a s t s i g b y t e o f sum Id (IX+lsbyte),A ;and s a v e  Appendix 0164 0165 0168 016B 016B 016D 016F 017 1 0172 0175 0178 0178 017B 017D 0181 0185 0189 018D 018D 0190 0193 0194 0196 0199 0199 019C 019F 01A0 01A1 01A3 01A3 01A6 01AA 01AA 01AD 01AF 01B0 01B3 01B4 01B5 01B6 01B7 01B7 01B7 01B7 01B7 01B9 01BB 01BD 01BE  D  Assembler  L i s t i n g o f U n i t E12ISR  External  Routines  Page  CD * * * * DD E1 D1 CD * * ** E 1 C1 F1 C9  g e t most s i g b y t e o f a / d r e a d i n g A,H add w i t h c a r r y t o n e x t l e a s t s i g b y t e o f sum A,(IX+msword) (IX+msword),A and s a v e I f neg, add O f f h a n d c a r r y t o msb e l s e a d d 0 a n d c a r r y : ;Check o f HL. A,0 sign 7, H z,$0 ir A dec add c a r r y t o most s i g b y t e o f sum A,(IX+msword+1) adc $0 and s a v e (IX+msword+1),A Id ; C o u n t e r w i l l o v e r f l o w b e f o r e sum d o e s s i n c e |max r e a d 1 n g | < 128*256: increment c o u n t e r (IX+sumcnt) i nc c h e c k f o r c o u n t e r o v e r f l o w ( c t r = 256 = 0) nz,beyond ir y e s : s e t c o u n t e r t o 256 / 2 := 128 (IX+sumcnt).128 Id and d i v i d e sum by 2 ( k e e p s i g n ! ) (IX+msword+1) sra r r (IX+msword) r r ( IX+1sbyte) c a l c u l a t e d i f f e r e n c e between r e a d i n g and s e t p o i n t : ; See i f e r r o r e x c e e d e d : l s b y t e of s e t p o i n t E.(IX+setpt) b e y o n d : Id msbyte " " D,(IX+setpt+1) Id reset carry A xor HL : = v a l u e - s e t p o i n t HL.DE ' ' sbc m.HL2comp take a b s o l u t e v a l u e cal 1 ; See i f d i f f e r e n c e i s g r e a t e r t h a n s p e c i f i e d m a x e r r o r : E,(IX+maxerr ) 1sbyte of maxerror Id D.(IX+maxerr+1 ) msbyte " " Id A xor HL:= m a x e r r o r , DE:= |actual e r r o r | ex DE .HL HL: = m a x e r r o r - j a c t u a l e r r o r | sbc HL ,DE maxerror: ; Set ready i f f l a c t u a l e r r o r j exceeds no, l e a v e r e a d y b i t r e s e t p,1oad JP rdybi t.(IX+ ready) set return: ; S e t up f o r n e x t c h a n n e l , g e t b a c k r e g i s t e r s , r e - e n a b l e a n a s e r v , s e t up f o r n e x t c h a n n e l r e a d loadnxt 1 oad cal 1 IX pop pop DE unmask a n a s e r v i n t e r r u p t cal 1 ISR on pop HL pop BC AF pop ret  06 04 CB 47 28 * + 19 CB 3F  AOFHxDE : C a l c u 1 a t e HL: = HL + A S O f h B.4 Id 0. A bit $10 z,$0 ir add HL.DE sr 1 A $0  7C DD DD  8E 77  04 04  3E 00 CB 7C 28 * * 3D DD 8E DD 77  05 05  DD 34 20 * * DD 36 DD CB DD CB DD CB  02  DD DD AF ED FC  5E 56  OE OF  DD DD AF EB ED  5E 56  F2 DD  02 05 04 03  Id adc Id sign Id bit  80 2E 1E 1E  52 **** 10 1 1  52 **** CB  OD  FE  *  DE.  U s e s AF, DE, HL, B. four b i t s of A to p r o c e s s 1s l e a s t s i g b i t h i ? no, d o n ' t c h a n g e r e s u l t y e s , a d d c o n s t . DE t o r e s u l t A : = A div 2  Assembler L i s t i n g  Append i x D 01C0 01C2 01C4 01C6 01C7 01C7 01C7 01C7 01C7 01C8 01C9 01CA 01CB 01CD 01CE 01CE 01CE 01CE 01CE 01CF 01D2 01D5 01D6 01D7 01D7 01D7 01D7 01D7 0107 01D7 01DA 01DB 01DD 01DF 01E2 01E3 01E6 01E7 01E7 01E7 01E7 01E7 01E7 01EA 01ED 01ED 01F 1 01F5 01F5 01F6  of  CB 23 CB 12 10F3 C9  EB AF 67 6F ED C9  E12ISR  s1a r1 djnz ret  E D $10  External  HL2comp: ; C a l c u l a t e two's c o m p l e m e n t : ex DE ,HL A xor H. A ld L ,A Id HL , DE sbc ret  52  Strtana: ;Perform F3 CD CD FB C9  Unit  ***+ *** +  OOOO 3A 9AOO 3D CB E7 OE OO CD 8 9 0 0 OC CD 8 9 0 0 C9  3A 32  9A00 9900  DD DD  2A 22  9D00 9B00  4F 2 1 A 100  Routines DE:=  Page DE  * 2  loop f o r a l l four b i t s r e t u r n w i t h top 4 b i t s of  H L ( 2 ' s comp):= O-HL. g e t number i n DE reset carry z e r o HL HL : = 0  t r i g g e r and l o a d n x t w i t h o u t di trigger cal 1 1oadnxt cal 1 ei ret  tr i gger: ; T r i g g e r an A/D c o n v e r s i on. ;Enter with channel i n (nxtchan) OH mux .EOU A , (nxtchan) ld dec A 4 .A set C, mux Id SendA2C cal 1 C i nc SendA2C cal 1 ret  -  A now  C h a n g e s DE,  i n bottom  AF.  DE  interrupts:  r e t u r n with A & C changed: Mu1t i p 1 e x e r get channel (1..16) to t r i g g e r enable multiplexer device o f f s e t send channel # to m u l t i p l e x e r a d t r i g : = mux + 1 8 t r i g g e r the conversion  1oadnxt: ;Prepare the next channel to t r i g g e r . C h a n g e s AF, BC, DE, HL, ;Load ( c h a n n e 1 ) = c h a n n e l J u s t t r i g g e r e d : A.(nxtchan) ld (channe1),A ld ;Load ( b u f f e r ) : = p o i n t e r t o r e c o r d i n a n a b u f f f o r c h a n n e l J u s t IX,(nxtbuff ) ld (buffer),IX Id :Load r e g i s t e r s f o r n e x t c h a n n e l f e t c h : C:= c h a n n e l j u s t t r i g g e r e d C,A ld p o i n t t o r o t a t e c o u n t w i t h HL ld HL.rotate  IX.  triggered  Appendix 01F9 OIFC 01FC 01FE 01FF 0201 0201 0205 0207 0208 020A 020A 020C 020C 0200 020F 02 10 02 1 1 0213 0214 02 17 02 17 021A 021C 0210 0220 0221 0223 0223 0224 0227 022B 022C 022C 022C 022C 022C 022F 0230 0232 0233 0235 0236 0237 0237 0237 0237 0237 023A 023B  D  Assembler  Listing  of Unit  E12ISR E x t e r n a l  Routines  Page  79 32 9A00 DD 22 9DOO C9  tminus s i z e o f s i n g l e c h a n n e l a n a b u f f r e c o r d DE , - r e c s i z e ld ; T e s t c h a n n e l C f o r t r i g g e r f1 aggedIX ,DE ;point to test channel's anabuff record newchan a d d C ;next c h a n n e l t o t e s t dec :jump i f s t i l l C h a n s l e f t t o t r i g g e r i n r o t a t e nz,tryC j r ;New t r i g g e r r o t a t-1 o n : ; a n a b u f f r e c o r d f o r c h a n 16 . I X , a n a b u f f + < 15 * r e c s i z e > ld c h a n n e l 16 i s n e x t t o t r y C, 16 ld decrement r o t a t e count (HL) dec want r o t a t e i n 1..128 nz,ca1ct rg jr ; S t a r t a g a i n w i t h p r i o r 1 t y 7: (HL),128 ld ;Calculate (trigpwr) = tflsbits r e s e t 1n ( r o t a t e ) : ; A:= r o t a t e c o u n t A,(HL) c a l c t r g ld ; b i t c o u n t e r i n i t i a l i z e d t o -1 B.255 Id ;check n e x t l s b i t o f A ck1sb i t r ra 1 nc B ;1oop u n t i l r o t a t e c o u n t b i t f o u n d nc,ck1sb i t jr A,B Id ;save t h e r o t a t e power ( t r igpwr ) ,A ld ; See 1 f channe1 C i s t o be t r i g g e r e d : :get c h a n n e l ' s t r i g g e r power o f two A.(IX+priorty) ld tryC ;mask o f f n o n - p M o r t y b i t s 00001111T and ;save i n B B, A Id ;get r o t a t e c o u n t power A , ( t r i gpwr) Id ;see i f r o t a t e ' s power >= c h a n n e l ' s B cp ;yes, t r y next c h a n n e l c,newchan jr ;C : = n e x t c h a n n e l t o t r i g g e r . DE:= p o i n t e r t o i t ' s p r i o r i t y : A,C ld ;update channel t o t r i g g e r (nxtchan),A Id ;and s a v e p o i n t e r t o n e x t c h a n n e l ' s a n a b u f f (nxtbuff),IX ld ret  21 1E00 p CB 86 7E D3 53 FB C9  ISR_off: ;Mask o f f a n a s e r v i n t e r r u p t . Id HL.mask di res anabit.(HL) Id A,(HL) out (maskreg),A ei ret  21 F3 CB  ISR_on: :Unmask a n a s e r v ld di set  11 ECFF DD 19 OD 20** DD 21 20O1 OE 10 35 20** 36  80  7E 06 FF 1F 04 30FC 78 32 A200 DD 7E 13 E6 OF 47 3A A200 B8 38D9  3  1E00 C6  C h a n g e s AF, HL, d i s a b l e s / e n a b l e s interrupts. ; p o i n t t o i n t e r r u p t mask w i t h HL ;no i n t e r r u p t s w h i l e ( m a s k ) <> ( m a s k r e g ) ;turn o f f anaserv Interrupt : g e t new mask i n A ;send t o u - a r t  C h a n g e s AF, HL. d i s a b l e s / e n a b l e s interrupts, p o i n t t o I n t e r r u p t mask w i t h HL no i n t e r r u p t s w h i l e ( m a s k ) <> ( m a s k r e g ) t u r n on a n a s e r v i n t e r r u p t anabi t.(HL) interrupt, HL.mask  9  Appendix 023D 023E 0240 024 1 0242 0242 0242 0242  D  Assembler  7E D3 53 FB C9  Assembly 0  Listing  of Unit Id out ei ret  E12ISR  External  A. ( H L ) (maskreg),A  Routines  Page  10  :get new mask i n A :send t o u - a r t ; i n t e r r u p t s O.K. now  . END complete: errors flagged  454 l i n e s on t h i s assembly  CO CJ  Appendix  D  Compiler  1 3 0 0 d 1 1 d 4 2 1 1 d 5 2 1 1 d 6 2 7 {commented ' : ' > 1 1 d 8 2 1 1 d 9 2 1 1 d 2 10 1 1 1 1 d 2 i 1 d 12 2 1 1 d 13 2 1 14 1 d 2 1 1 d 15 2 1 1 d 16 2 1 1 d 17 2 1 1 d 18 2 1 1 d 19 2 1 1 d 2 20 1 1 d 2 1 2 1 1 d 22 2 n 1 1 d 23 1 24 1 d 2 1 1 d 25 2 1 1 d 26 2 1 27 1 d 2 1 1 d 28 2 1 2 1 d 29 1 1 d 2 30 1 1 d 31 2 1 1 d 32 2 1 1 d 33 2 34 1 d 2 0 1 d 76 2 0 77 1 d 2 0 1 d 78 2 0 1 1 d 79 2 1 1 d 2 80 1 1 d 81 2 1 1 d 82 2 1 1 d 83 2 1 0 84 2 0 1 1 85 2 0 1 1 2 86 2 1 1 6 87 2 1 1 18 88 2 1 1 89 2 20 1 1 27 2 90 91 2 0 0  Listing  of U n i t  Page  E12DigI0  1  {$L remout:} Unit E12digio; Interface { digital i n p u t / o u t p u t r o u t i n e s f o r E12 ( a l i a s G r e y B o x ) ; outputs 0.7 a r e i n i t i a l i z e d & h a l t e d h i g h . 8..15 low } Type d i g w a i t = 0..maxint; d i g i t a l = s e t o f 0..15; { e . g . [ 1 . . 3 . 7 ] means b i t s  Procedure DigRead (Var d a t a : { d a t a : = Input }  1, 2, 0, 4,  3, and 7 a r e s e t . 5. 6 and 8..15 are  reset  }  digital):  P r o c e d u r e D i g W r i t e ( d a t a , mask: d i g i t a l ) ; { o u t p u t : = ( d a t a i n t e r s e c t mask) union ( c u r r e n t output i n t e r s e c t (complement(mask)) Function DigPStat: digwait; { number o f t i c k s r e m a i n i n g  in curent  pulse  ( i f any)  ) }  }  P r o c e d u r e D i g P u l s e ( d a t a , mask: d i g i t a l ; ticks: digwait); { D i g W r i t e ( d a t a . mask). A f t e r t i c k s / 60 s e c o n d s , interrupt w i l l D i g W r i t e (comp1ement(data), mask). D i g P u l s e must n o t be c a l l e d when D i g P S t a t i s > 0 } Procedure D i g S t a t u s (Var d a t a : { data:= c u r r e n t output >  digital);  Implementat ion <$L-}  Uses  E12isr;  ($L@>  P r o c e d u r e DigRead; external; Procedure DigWrite; external; Procedure DigPulse; external; Procedure DigStatus; external; Function DigPStat; external; Begin I n i tE12 i s r ; pu1se:= f a 1se; DigWr i t e ( [ 0 . 7 ] , [0.15]); ***. w h i l e p u l s e do; < don't q u i t D i g W r i t e ( [ 0 . 7 ] , [ 0 . . 15]) End.  until  pulse  i s done  )  CD  Appendix End  of  D  Compiler  Listing  of Unit  E12DigI0  Page  Compilation.  00  Appendix oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo  0002 0003 0006 0007 0008 OOOA OOOD 000E 000F 0010 001 1 0012 0013 0014 0016 0017 0017 0017  D  Assembler  Listing  of Unit  Page  Routines  T h i s f i l e c o n t a i n s no .PROC. .FUNIC. .BYTE. .WORD. . A S C I I , o r .BLOCK I t i s t h e r e f o r e d y n a m i c a l l y r e l o c a t a b l e , a n d may move a b o u t In ram o r b e swapped back t o d i s k . . PUBLIC .PUBLIC . PUBLIC .PUBLIC .PUBLIC .PUBLIC OOOO 0003 0006 0009  D i g s e n d .EOU G e t C f r m A .EOU SendA2C .EOU R d C l k D E .EOU  jumptabl currd ig pu 1 s e p1squ i t p1sdata p1smask  jump t a b l e t o r o u t i n e s i n E 1 2 1 s r current d i g i t a l output byte p u l s e i s on boolean lsword of time t o t u r n o f f p u l s e pulse data p u l s e mask  jumptabl+OOH jumptabl+03H jumptabl+06H jumptabl+09H  mask read send DE:=  . RELPROC D i g R e a d , 1 ;Read d i g i t a l input into parameter ; interrupts.  00C6 0002 3E F3 CD 4 1 79 OE CD FB 78 2F E 1 E3 77 23 36 C9  d i g1 n d i splay  C6 0300  02 0600  saveA:  OO  b y t e L w i t h C, u p d a t e d i g i t a l output E12 d e v i c e A i n t o C d a t a i n A t o E12 d e v i c e C ( l o s e A) c l o c k l s w o r d ( l o s e AF, C)  #1.  U s e s AF. BC, a n d HL, d i s / e n - a b l e s  . DE F  saveA  . EOU . EOU  0C6H 2  ;digital :digital  ld di cal 1 ld ld ld cal 1 ei ld cpl pop ex ld i nc ld ret  A, digin  ;set d i r e c t i o n i n and s t r o b e o f f ; I s r ' s u s i n g E12 w o u l d I n t e r f e r e :read d i g i t a l input byte into C -.save i n p u t d a t a i n B ;get " " "A  GetCfrmA B.C A.C C,d i s p l a y SendA2C A,B HL (SP),HL (HL).A HL (HL),0  i n p u t command d i s p l a y command  ;send i n p u t t o d i g i t a l input d i s p l a y ;now d i s p l a y a n d i n p u t a g r e e ;get b a c k i n p u t d a t a ;hardware complements a c t u a l b i t v a l u e s .;return address ; p o i n t t o r e s u l t w i t h HL, r e p l a c e r e t . a d d r ; s a v e r e s u 11 ;reset high order byte of r e s u l t  ts  oooo oooo  E12DigI0 External  :Write  .RELPROC D i g W r i t e . 2 t o d i g i t a l output. Send t h e v a l u e  (parameter  #1), c h a n g i n g  only  those  Appendix D  0001 0002 0003 0004 0007 0008 0009 0009 0009 OOOO OOOO OOOO oooo oooo oooo oooo oooo  0001 0004 0005 0007 0007 OOOA OOOB OOOE 000F 0010 0012 0015 0017 0018 0019 001A 001B 001C 001D 001D 001D OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO  Listing ; ;•  oooo oooo oooo oooo  Assembler  of Unit  E12DigI0 E x t e r n a l  b i t s s e t i n t h e mask interrupts. pop pop ex di cal 1 e i ret  E 1 C1 E3 F3 CD OOOO FB C9  (parameter  HL BC (SP),HL D i gsend  Page  Routines #2).  U s e s AF, BC. a n d HL, d i s / e n - a b l e s  return address g e t mask i n C g e t v a l u e i n L, p u t back r e t u r n a d d r e s s no i n t e r r u p t s u n t i l o u t p u t s a g r e e w i t h c u r r d i g s e n d t h e masked d a t a a n d c h a n g e c u r r d i g  .RELFUNC D i g P S t a t ; R e t u r n w i t h number o f t i c k s r e m a i n i n g i n p u l s e . ; U s e s AF, C. DE, HL, d i s / e n - a b l e s i n t e r r u p t s . 0056  d i g t i me  . EOU  56H  digital  pulse  interval  timer  port  i fcurrently pulsing: xor A A: = 0 p o i n t t o p u l s e o n b o o l e a n w i t h HL HL,pu1se Id z i s s e t i f not p u l s i n g or (HL) return O i f not p u l s i n g z.pushA jr ; c a l c u l a t e number o f t i c k s r e m a i n i n g : HL:= l s w o r d o f p u l s e q u i t t i m e HL,(pisqu i t ) 1d disallow interrupts while reading clock di DE : = l s w o r d o f c l o c k r e a d i n g RdClkDE cal 1 i n t e r r u p t s now o.k. ei reset carry A xor HL:= number o f t i c k s r e m a i n i n g HL.DE sbc e n s u r e >= 0 P,pushtks JP • ( d i g t i me),A hasten turn o f f of pulse out H. A HL:= 0 ( = 0 ) pushA: Id L. A Id DE : = r e t u r n a d d r e s s DE p u s h t k s pop ( S P ) : = t i c k s r e m a i n i n g , HL:= j u n k ex (SP).HL HL : = r e t u r n a d d r e s s ex DE.HL ret (HL) JP ;See  AF 21 OOOO B6 28 *• + 2A F3 CD FB AF ED F2 D3 67 6F D1 E3 EB E9  OOOO 0900  52 56  . RELPROC D i g P u l s e . 3 ; D i g W r i t e p a r a m e t e r s tt \ a n d HI f o r p a r a m e t e r H3 t i c k s DE, HL, d i s / e n - a b l e s i n t e r r u p t s . ; U s e s AF . BC OOOO 001E 0001 0053  sb i o s mask d i gb i t maskreg  . . . .  EOU EOU EOU EOU  OOOOH sbios+001EH 1 53H  2  only.  location of start of sbios u - a r t i n t e r r u p t mask s a v e d h e r e r e l a v e n t b i t i n i n t e r r u p t mask u - a r t i n t e r r u p t mask p o r t  Append i x D OOOO OOOO OOOO OOOO OOOO 0001 0004 0005 0006 0006 0007 0008 OOOA OOOD OOOF 0010 0012 0012 0015 0016 0017 0018 001B 001C 0010 001E 001F 0022 0023 0024 0025 0028 0028 002B 002C 0020 002D 002D OOOO OOOO OOOO OOOO OOOO OOOO 0003 0006 0006 0006 0006  0056  AF 2 1 OOOO B6 CO F3 34 D3 2 1 CB 7E 03 CD C1 E 1 19 22 60 69 C 1 79 32 E3 7D 2F 32  56 1E00 CE 53 0900  OOOO  OOOO  OOOO  CD OOOO FB C9  Assembler  Listing  digtime  .EOU  E12DigI0  External  56H  Routines digital  Page pulse  interval  timer  port  ;Ensure not a l r e a d y p u l s i n g : : See i f c u r r e n t l y p u l s i n g : A A: = 0 xor p o i n t t o p u l s e o n b o o l e a n w i t h HL HL,pulse ld z i s s e t i f not p u l s i n g or (HL) if p u l s i n g , abort nz ret timer: ; R e s e t p u l s e b o o l e a n , unmask i n t e r v a l no i n t e r r u p t s u n t i l p u l s e b o o l e a n c o r r e c t di f l a g w e ' r e now p u l s i n g (HL) i nc immediate i n t e r r u p t c a u s e s D i g s e r v upon e i ( d i g t i me).A out p o i n t t o i n t e r r u p t mask w i t h HL HL,mask ld t u r n on d i g s e r v i n t e r r u p t digbit,(HL) set g e t new mask i n A A.(HL) ld send t o u - a r t (maskreg).A out ;Get a n d s a v e p a r a m e t e r s : DE : = c l o c k r e a d i n g RdClkDE cal 1 get r e t u r n a d d r e s s BC pop get count HL pop c a l c u l a t e time t o t u r n o f f p u l s e HL , DE add and s a v e ( p i s q u i t),HL ld HL:= r e t u r n a d d r e s s ld H.B L.C 1d g e t mask i n C BC pop A,C Id s a v e mask f o r t u r n i n g p u l s e o f f (p1smask ) . A Id g e t v a l u e i n L, p u t b a c k r e t u r n a d d r e s s (SP).HL ex ld A, L cp 1 save complement o f v a l u e f o r p u l s e o f f (pisdata),A ld time: ;Turn p u l s e on. a l l o w D i g s e r v t o s t a r t c h e c k i n g f o r p u l s e q u i t t u r n t h e p u l s e on D i gsend cal 1 s t a r t checking f o r p u l s e o f f time e i ret  ;Read  3A OOOO C3 OOOO  of Unit  .RELPROC D i g S t a t u s . 1 c u r r e n t d i g i t a l output . REF  saveA  ld JP  A , ( c u r r d i g) saveA  . END  into parameter  get fix  A 1 1®.  U s e s AF a n d HL.  d i g i t a l output s t a t u s up s t a c k , r e t u r n  byte  Appendix  D  Assembler  Assembly 0  complete: errors flagged  Listing  of Unit  E12DigI0  External  Routines  Page  148 l i n e s on t h i s a s s e m b l y  00  VD  Appendix  D  Compiler  3 0 4 2 5 2 6 2 7 2 8 (commented 9 (commented 10 1 1 12 13 14 15 1G 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4 1 42 43 44 45 46 47 48 49 50 51  Listing  of U n i t  Page  E12AnaI0  i  ($L remout:} Unit E12anaio; Interface { ana 1og ' 1 n p u t / o u t u p t r o u t i n e s f o r E12 ( a l i a s G r e y B o x ) ; o u t p u t s a r e i n i t i a l i z e d 8> h a l t e d t o 0. N o t e t h a t a n a l o g i n p u t c a n ONLY be d o n e u s i n g i n t e r r p u t s  }  T y p e a n a _ iinn__cchhaann = 11..16; a n a _ iinn__rraanngg ee == - 12000..12000: a n a _ e r r _ r a n g e = - 1 . .24000: a n a _ m 1 n d t _ r a n g e = 1 . .255; a n a _ d x _ r a n g e = -24000..24000; a n a _ d t _ r a n g e = 1 . .max i n t ; ana_chan_f1ags = p a c k e d a r r a y [ana i n _ c h a n ] of b o o l e a n ; a n a _ p r i o r i t i e s = p a c k e d a r r a y [ a n a i n c h a n ] o f 0. .8 ; a n a _ c h a n _ s e t = s e t o f 0..15; a n a _ i n _ t a b l e = a r r a y [ana_in_chan] of packed r e c o r d reading: ana_in_range; sum_lsbyte, count: 0 . 2 5 5 ; sum_msword: i n t e g e r end; ana_out_chan = 1..8; a n a _ o u t _ r a n g e = 0..4095; a n a _ o u t _ t a b 1 e = a r r a y [ a n a _ o u t _ c h a n ] of a n a _ o u t _ r a n g e ; Procedure  AnalnGo  (inverts: ana_chan_f1ags; priorities: anapriorities); < Z e r o a l l i n t e r n a l i n p u t v a l u e s and i n t e g r a t i o n sum b u f f e r s . T u r n on i n t e r r u p t d r i v e n a n a l o g i n p u t p o l l i n g , p a s s i n g i n v e r t i n p u t v a l u e b o o l e a n s and c h a n n e l p r i o r i t y v a l u e s . At l e a s t one c h a n n e l ' s p r i o r i t y must be 0 ( h i g h e s t p r i o r i t y ) . Channels of p r i o r i t y 8 w i l l n o t be t r i g g e r e d . )  Procedure  AnaSetBound  (channel: ana_in_chan; setpoint: ana_in_range; maxerror: ana_err_range; mindt: ana_mindt_range); { S e t a n a l o g i n p u t c h a n n e l s e i p o i n t and m a x e r r o r , minimum d t f o r d/dt c a l c u l a t i o n , r e s e t channel ready. I n i t i a l l y a l l setpoints a r e 0, a l l m a x e r r o r s a r e -1, and a l l m i n d t s a r e 30 t i c k s . )  P r o c e d u r e AnaReady ( V a r r e a d y : a n a _ c h a n _ s e t ) ; { D e t e c t which a n a l o g i n p u t s have been r e a d s i n c e i n i t i a l i z a t i o n o r the l a s t AnaReady o r A n a l n S t a t u s , a n d c u r r e n t l y d i f f e r f r o m t h e i r s e t p o i n t by more t h a n t h e i r m a x e r r o r . N o t e t h a t c h a n n e l s a r e numbered f r o m 0 t o 15 h e r e ! > O  Appendix 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 1 18 1 19 120 12 1 122 123 124 125 126 127 128 1 29 130 131 132 133 134 135 136 137 138 139 140 14 1 142  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2' 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 1 1 1 1 1 1 1 0  1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 2 2 1 1 1 1 1 1 1 1 1 0 0 2 2 46 50 79 8 1 1 10 O  Listing Procedure  of U n i t  Page  E12AnaI0  AnaRead  (channel: ana_in_chan: Var r e a d i n g : a n a _ i n _ r a n g e ; Var d e l t a _ r e a d i n g : ana_dx_range; Var d e l t a _ t i m e : a n a _ d t _ r a n g e ) : { Read c u r r e n t v a l u e o f an a n a l o g i n p u t , a n d t h e d i f f e r e n c e s i n a n d t i m e o f t h e l a s t two r e a d i n g s . >  value  Procedure A n a l n S t a t u s (Var a n a _ i n p u t s : a n a _ i n _ t a b l e ) ; { Read a l l c u r r e n t v a l u e s o f a n a l o g i n p u t s , dump i n t e g r a t i o n sums. } Procedure AnalnStop; { Turn o f f interrupt  driven  analog  input  P r o c e d u r e A n a W r i t e ( d a t a : ana o u t r a n g e ; { Send d a t a to a n a l o g o u t p u t c h a n n e l . >  polling.  }  channel:  ana_out_chan);  F u n c t i o n AnaOutRead ( c h a n n e l : a n a _ o u t _ c h a n ) : ana_out_range; { Read c u r r e n t v a l u e o f a n a l o g o u t p u t c h a n n e l . > Procedure AnaOutStatus (Var ana_outputs: a n a _ o u t _ t a b 1 e ) ; { Read a l l c u r r e n t v a l u e s o f a n a l o g o u t p u t s . } Imp 1ementat i o n  {$L-> Var  Uses  E12isr;  <$L®>  channel: integer; j u n k : ana c h a n _ s e t ;  P r o c e d u r e AnalnGo: external; P r o c e d u r e AnaSetBound; external; P r o c e d u r e AnaReady; external: P r o c e d u r e AnaRead; external; Procedure AnalnStatus; external; Procedure AnalnStop; external; Procedure AnaWrite; external; F u n c t i o n AnaOutRead; external; Procedure AnaOutStatus; external; Begin In i tE12 i s r ; { i n i t i a l i z e bounds and r e a d y } f o r c h a n n e l : = 1 t o 16 do A n a S e t B o u n d ( c h a n n e l , 0, AnaReady ( j u n k ) : for channel: 1 t o 8 do AnaWrite (0, c h a n n e l ) ;  -1,  3  *.**..  for channel: 1 t o 8 do AnaWrite (0, c h a n n e l ) ; AnalnStop { e n s u r e i n t e r r u p t s e r v i c i n g 1s c l e a r e d End. 3  }  30)  2  Appendix  End  of  D  Compiler  Listing  of U n i t  E12AnaI0  Page  Compilation.  VD to  Appendix D 0000 OOOO OOOO OOOO OOOO OOOO OOOO OOOO  oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo oooo 0003 0004 0005 0006 0007 0008 OOOA  Assembler  Listing  of Unit  E12AnaI0 E x t e r n a l  Page  Routines  T h i s f i l e c o n t a i n s no .PROC, .FUNC. .BYTE, .WORD. . A S C I I , o r .BLOCK I t i s t h e r e f o r e d y n a m i c a l l y r e l o c a t a b l e , a n d may move a b o u t i n ram o r b e swapped b a c k t o d i s k . PUBLIC j u m p t a b l PUBLIC a n a b u f f 0006 OOOC 000F 0012  SendA2C Strtana ISR o f f ISR_on  EOU EOU EOU EOU  OOOO 0006 0008 OOOA OOOC OOOD 0007 OOOE 0010 0012 0013 OOOE 0014  ;Anabuff r e c o r d r e a d i ng EOU EOU 11 EOU xO x1 EOU EOU del t a t ready EOU rdyb i t EOU EOU setpt maxerr EOU m i ndt EOU p r i o r t y . EOU EOU zeros i z EOU r e c s i ze  jumptabl+06H jumptabl+OCH jumptabl+OFH jumptabl+12H offsets: 0 6 8 10 12 13 7 14 16 18 19 14 20  jump t a b l e t o r o u t i n e s - i n analog inputs buffers  Anaisr  s e n d d a t a i n A t o E12 d e v i c e C ( l o s e t r i g g e r A/D, u p d a t e (nxtchan) ;mask o f f a n a s e r v i n t e r r u p t unmask a n a s e r v interrupt  A)  l a t e s t reading of input time o f dx/dt c a l c u l a t i o n r e a d i n g a t time t o 11 t1 - t o r e a d i n g beyond s e t p o i n t by > maxerr? r e a d y b o o l e a n b i t number reading setpoint and maxerror wait b e f o r e v a l i d dx/dt trigger p r i o r i t y / invert data kbytes a t beginning o f r e c o r d t o zero s i z e of anabuff r e c o r d  . RELPR0C AnaInGo,2 ; S t a r t a n a l o g Input p o l l i n g : i n i t i a l i z e channel i n v e r t boolean and t r i g g e r xOs a n d x 1 s , d e l t a t s ; p r i o r i t y v a l u e s , z e r o a n a b u f f r e a d i n g s , sums, t 1 s , and r e a d i e s . : P a r a m e t e r s #1 a n d #2 a r e ; i n v e r t s : ©packed a r r a y [ 1 . . 1 6 ] o f b o o l e a n ; p r i o r i t i e s : © p a c k e d a r r a y [ 1 . . 1 6 ] o f 0..8 ; respectively. U s e s AF. BC, DE, HL, IX, IY. ;Ensure CD OFOO F1 E1 D1 F5 E5 FD E1 ;Ensure  polling call pop pop pop push push pop at least  i s t u r n e d o f f , pop p a r a m e t e r s : ISR_off AF -.return a d d r e s s HL ;(HL):= p r i o r i t i e s DE ;(DE):= i n v e r t s AF :put b a c k r e t u r n a d d r e s s HL ;save p o i n t e r t o p r i o r i t i e s IY ; i n IY o n e p r i o r i t y i s 0:  Appendix OOOA OOOB OOOE 0010 0012 0013 0015 0015 0019 001 A. 001B 001C OO10 001E 001E 0021 0023 0026 0028 002 A 002B 002 C 002 E 0030 0031 0032 0034 0036 0037 0038 003B 003D 003 F 003 F 004 2 004 2 0043 0046 0049 004B 004D 004 E 004 F 0051 0052 0053 0055 0055 0058 0058  D  Assembler  AF 01 1000 ED B1 28 2B 36 00 DD 2 1 OOOO EB 5E 23 56 EB 1 1 1400 06 10 FD 7E 0 0 CB 40 28 * * 1F 1F FD 23 18 * * 17 17 CB 1C CB 1D 1F 1F DD 77 13 DD 19 10E4 CD OCOO AF 21 OOOO 1 1 0600 OE 10 06 OE 77 23 10FC 19 OD 20F6 C3  1200  Listing  of Unit xor Id cp i r  E12AnaI0 E x t e r n a l A BC, 16  Page  Routines :1ook f o r a 0 i n new p r i o r i t y ;16 c h a n n e 1 s  array  ; i f 0 found, c o n t i n u e z, f o u n d O jr ; e l s e f o r c e c h a n n e l 16 p r i o r i t y t o b e 0 dec HL (HL),0 Id ; P o i n t t o a n a b u f f w i t h IX, 1 o a d HL w i t h i n v e r t b o o l e a n s : IX , a n a b u f f foundO : Id ;(HL):= i n v e r t s ex DE .HL E,(HL) Id i nc D.'(HL) Id ;HL:= i n v e r t s ex DE .HL ; Load the i n v e r t b o o l e a n s i n t o anabuff r e c o r d s : ;size of anabuff r e c o r d DE,recs i ze 1 d ;tf c h a n n e l s B, 16 Id ;get p r i o r i t y i n A A,(IY+O) ck i n v t : I d ;even c h a n n e l number ( o d d B ) ? bit 0,B ;no. l s b i t s o f A a r e p r i o r i t y i n d e e d z, o d d Jr ; y e s , want m s b l t s o f A r ra r ra :point t o next p r i o r i t y p a i r IY i nc even jr ;move two b i t s left rla odd: r la ; r o t a t e 1 s b i t o f HL i n t o c a r r y H even: rr r r L ;move c a r r y i n t o b i t 6 o f A r ra rra ;save i n a n a b u f f r e c o r d ( I X + p r i o r t y ) ,A Id ; p o i n t t o next c h a n n e l ' s r e c o r d add IX .DE ; c o n t i n u e f o r a l l 16 c h a n n e l s ck i n v t d j nz ; S t a r t f i r s t c o n v e r s i on: Strtana cal 1 ; I n i t i a l i z e anabuff: ;A: = 0 a xor A :(HL):= a n a b u f f HL,anabuff Id ;number o f b y t e s t o s k i p p e r r e c o r d DE,recs i ze - z e r o s i z Id ; 16 c h a n n e l s i n a r r a y C , 16 Id ;number o f b y t e s t o z e r o n x t c h n : Id B,zeros i z :zero a byte (HL),A zero: Id HL i nc ;cont1nue f o r a l l z e r o s i z b y t e s zero djnz ;skip remaining bytes HL.DE add ;next c h a n n e l dec C nz,nxtchn Jr : T u r n p o l 1 i ng on: :unmask a n a s e r v I n t e r r u p t , e n a b l e i n t s ISR_on JP  Assemb1er  Append i x D 0058 0000 OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO 0001 0003 0004 0005 0006 0007 0009 0009 OOOC OOOC OOOD 0010 0013 0016 0019 001A 0010 001D 002 1 0022 0023 0023 0023 OOOO OOOO OOOO OOOO OOOO 0004 0007 0009 OOOA OOOD 001 1 0012 0014 0016 0018 001 A 001B  L i s t i ng o f U n i t E 1 2 A n a I 0  External  Routines  Page  .RELPROC A n a S e t B o u n d , 4 ;Copy a n a l o g i n p u t c h a n n e l ( p a r a m e t e r #1) s e t p o i n t ( p a r a m e t e r 01), reset channel ready. ; ( p a r a m e t e r 03) , a n d m i n d t ( p a r a m e t e r 04), ; BC, DE, HL, IX, d i s / e n a b l e s 1 n t e r r u p t s . . REF  F1 DD E 1 E1 D1 C1 F5 DD E5 CD OOOO F3 DD DD DD DD D1 DD  73 OE 72 OF 75 10 74 1 1 73  12  DD CB OD BE FB C9  IXptrC  ; Pop s t a c k : ;return address AF pop ;m i nd t IX pop ;maxerror pop HL ;setpo i nt DE pop ;channe1 BC pop :put b a c k r e t u r n push AF ;put b a c k m i n d t IX push ; P o i n t t o c h a n n e l e n t r y i n a n a b u f f a r r a y w i t h IX: ;point t o channel C s e n t r y i n anabuff IXptrC cal 1 ; I n s e r t new s e t p o i n t , m a x e r r o r , a n d m i n d t I n t o b o u n d s a r r a y : ;don't c h a n g e b o u n d s o r r e a d y u n t i l d o n e di :save s e t p o i n t ( IX+setpt) , E Id (IX+setpt+1),D ld ;save m a x e r r o r ( I X + m a x e r r ) .L ld (IX + maxerr+ 1 ) ,H ld ;get b a c k m i n d t DE pop ;and s a v e (IX+mindt),E ld ;Reset c h a n n e l ready b i t : rdybit,(IX+ready) res el ret  . RELPROC AnaReady,1 ;Read a n a l o g i n p u t c h a n n e l r e a d y ; U s e s AF, B , DE, HL, IX. DD 21 OOOO 1 1 1400 06 10 F3 DD 7E OD DD CB OD BE 17 CB 1C CB 1D DD 19 10FO FB EB  maxerror U s e s AF  ld ld ld di n x t c h n : Id res r 1 a r r r r add d j nz e i ex  IX,anabuff DE,recs i ze B, 16  flags  into  parameter  :point t o anabuff ;0 b y t e s p e r a n a b u f f :channel c o u n t e r  #1®, r e s e t  record  ;get c h a n n e l r e a d y f l a g i n A A,(IX+ready) rdybit,(IX+ready) ;reset the ready f l a g ;get r e a d y f l a g i n c a r r y :move i n t o HL H L ;point t o next c h a n n e l ' s r e c o r d IX,DE nxtchn DE , HL  :get  ready  flag  s e t i n DE  the flags.  Appendix 001C 001D 001E 001F 0020 002 1 002 2 002 2 0022 OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO 0001 0002 0004 0005 0006 0007 0008 0008 OOOB OOOC OOOF 0010 001 1 0014 0015 0015 0018 001B 001E 0021 0022 0024 0027 002 A 002 A 002B 002E 0031 0032 0034 0035  Assembler  D  Listing  of Unit  E12AnaI0  pop ex •Id i nc ld ret  E 1 E3 73 23 72 C9  External  HL (SP) ,HL (HL) ,E HL (HL),D  Page  Routines return address (HL):= r e s u l t b u f f e r , .1 s b y t e o f r e a d y  (SP):=  return  msbyte  . RELPROC AnaRead,4 ;Read c h a n n e l ( p a r a m e t e r #1) l a t e s t r e a d i n g ( p a r a m e t e r # 2 ® ) , d i f f e r e n c e ; b e t w e e n l a s t e s t two r e a d i n g s ( p a r a m e t e r # 3 ® ) , a n d d i f f e r e n c e i n t i m e ; o f t h o s e two r e a d i n g s ( p a r a m e t e r # 4 ® ) . . ; U s e s AF, BC. DE, HL, IX, IY, d i s / e n - a b l e s i n t e r r u p t s . .DEF  F 1 E 1 FD E 1 D1 C1 F5 E5 CD * * f * F3 DD 7E 00 12 13 DD 7E 01 12 DD DD DD DD AF ED FD FD  6E 66 5E 56  OA OB 08 09  52 75 00 74 01  E 1 DD 5E OC DD 56 OD FB CB BA 7B B2  ;Pop s t a c k : pop pop pop pop pop push push ;Point to latest cal 1 di ld ld i nc ld ld C a l c u l a t e (IY) Id ld ld 1d xor sbc ld Id ;Point to d e l t a pop ld ld ei res ld or  IXptrC  return address ;pointer to delta t pointer to delta x pointer to latest reading c h a n n e l number replace return address replace pointer to delta t s o u r c e b u f f e r w i t h IX, move 2 b y t e s t o ( D E ) : ( I X ) : = c h a n C s r e c o r d In a n a b u f f don't change v a l u e w h i l e r e a d i n g i t l s b y t e of r e a d i n g A,(IX+reading) (DE) .A DE ;msbyte o f r e a d i n g A,(IX+read1ng+1) (DE ) ,A = d e 1 t a x: l s b y t e o f x1 L,(IX+x1) msbyte " " H,(IX + xl+1 ) lsbyte " xO E,(IX+xO) msbyte " D.(IX+xO+1) reset carry A calculate delta x HL .DE 1sbyte of " " (IY+O).L msbyte (IY+1 ) ,H t s i n k w i t h HL, c o p y d e l t a t : ©delta t sink b u f f e r HL lsbyte of delta t E , ( IX+deltat) " " D . ( I X + d e l t a t + 1 ) msbyte  AF HL IY DE BC AF HL reading IXptrC  r d y b i t.D A. E D  mask o f f r e a d y b i t check f o r d e l t a t = 0  Appendix D 0036 0038 003B 003C 003D 003 E 003 F 003 F 003 F 003 F 0040 004 3 0047 004 8 004 A 004 C 004 E 0050 0052 0054 0056 0058 0059 005 A 005 A 005 A 0000 OOOO OOOO OOOO OOOO  oooo oooo oooo oooo oooo oooo 0001 0003 0004 0007 OOOA OOOC OOOD OOOF 0010 0013 0014 0016 0018  Assembler  20** 11 0 1 0 0 73 23 72 C9  Listing  of Unit  savdt:  IXptrC ;Point D5 11 1400 DD 2 1 OOOO OD 06 04 CB 4 1 28** DD 19 CB 39 CB 23 CB 12 10F2 D1 C9  nxtbi t  $0  jr Id Id i nc Id ret  E12AnaI0 E x t e r n a l nz.savdt DE . 1 (HL).E HL (HL).D  t o c h a n n e l C's e n t r y push DE DE,recs i ze Id IX.anabuff Id C dec B.4 Id O.C bit z.$0 Ji" IX ,DE add sr 1 C E s1a r1 D nxtbi t d j nz DE pop ret  Page  Routines 1f n o t , ok else substitute  1 s o no d e v i d e b y 0 e r r o r  i n a n a b u f f w i t h IX. U s e s F. BC, I X : d o n ' t c h a n g e DE s i z e of s i n g l e channel anabuff r e c o r d (IX):= anabuff channel 1 r e c o r d g e t c h a n n e l i n 0..15 channel - 1 d e s c r i b e d by 4 b i t s look a t l s b i t o f C 1f z e r o , n o t h i n g t o a d d " one, add r e c s i z e * 2**(B-4) C : = C div 2 DE : = DE * 2 continue f o r a l l four g e t b a c k DE  bits  .RELPROC A n a l n S t a t u s . 1 Read e n t i r e a n a l o g i n p u t r e a d i n g s a r r a y i n t o p a r a m e t e r #1®, w h i c h i s o f t y p e anabuff = array[1..16] of packed r e c o r d r e a d i n g : - 12000.. 12000 s u m _ l s b y t e , c o u n t : 0..255 sum_msword: i n t e g e r end. Z e r o t h e c o u n t , s u m _ l s b y t e , a n d sum_msword. U s e s AF, BC, DE, HL, IY d i s / e n - a b 1 es' i n t e r r u p t s . F 1 FD E1 F5 11 1200 21 OOOO OE 10 F3 06 06 7E FD 77 0 0 23 FD 23 10F7 AF  nxtchn: nxtbyt:  pop pop push Id Id Id di Id Id Id i nc i nc d j nz xor  AF IY AF DE,recs1ze-2 HL.anabuf f C, 16 B.6 A.(HL) (IY+O),A HL IY nxtbyt A  return address ( IY) : = s i n k b u f f e r s i z e of anabuff r e c o r d - 2 (HL):= s o u r c e b u f f e r channel counter don't change t h e t a b l e w h i l e k b y t e s p e r c h a n n e l t o move get s o u r c e b y t e s i nk i t p o i n t t o next move 6 b y t e s A: = 0  Appendix 0019 001B 001C 001D 001F 0020 0021 0023 0024 0025 0025 0025 0000 OOOO OOOO OOOO 0003 0003 0003 OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO 0001 0002 0003 0004 0004 0005 0007 0009 OOOA OOOB OOOD 0010 00 10 0013 0014 0015 0016. 0017 0017 0018 001A 001C 001E  D  06 04 2B 77 10FC 19 OD 20EA FB C9  Assembler  Listing  nxtzro:  ;Stop C3 OFOO  of Unit Id dec ld djnz add dec jr e i ret  E12AnaI0 E x t e r n a l B,4 HL (HL),A nxtzro HL, DE C nz,nxtchn  .RELPROC A n a l n S t o p analog input p o l l i n g : JP  ISR o f f  Page  Routines ;kbytes p e r channel t o zero :point t o previous source byte ;zero i t :zero 6 bytes ;point t o next c h a n n e l ' s s o u r c e ;next c h a n n e l  mask o f f A n a s e r v ;let  interrupt:  E12isr routine  do t h e work  .RELPROC A n a W r i t e . 2 ;Write t o analog output. Send v a l u e ( p a r a m e t e r #1) t o c h a n n e l ; U s e s AF, BC, DE, a n d HL, d i s / e n - a b l e s i n t e r r u p t s . .PRIVATE c u r r a n a : 8 :table .DEF ptHL2C. I d c u r a n i E 1 C1 D1 E5 79 FE 0 5 30** 7A A7 28** 11 FFOO CD F3 73 23 72  ****  79 FE 04 30** C6 04 4F  buffer  of current analog  output  (parameter  #2)  values  return address HL pop get channel i n C BC pop g e t v a l u e i n DE DE pop put back r e t u r n a d d r e s s HL push ;Check f o r o v e r r a n g e d a t a f o r a n e i g h t b i t c h a n n e l get channel i n A A.C ld c h e c k c h a n n e l number 5 cp i f c h a n n e l >= 5, no o v e r r a n g e p o s s i b l e nc,update jr o v e r r a n g e i f D <> 0 A.D Id A and z,update j r r e d u c e d a t a t o 255 ;overrange: DE.255 ld :Update t h e t a b l e o f c u r r e n t a n a l o g o u t p u t v a l u e s : ; p o i n t t o e n t r y C i n c u r r a n a w i t h HL, d e c C ptHL2C update: cal 1 ;no i n t e r r u p t s u n t i l o u t p u t a g r e e s w i t h t a b l e di (HL),E 1 d HL i nc (HL),D Id ; S e n d t h e new v a l u e t o t h e a n a l o g o u t p u t : get p r e d ( c h a n n e l ) i n A A,C Id c h e c k c h a n n e l number 4 cp i f c h a n n e l >- 5 t h e n d o 12 b i t o u t p u t nc,twe1ve jr no, 8 b i t d / a : d e v . a d d r . = c h a n n e l + 3 A, 4 add get d e v i c e address i n C C,A ld  Appendix D 001F 002 1 0023 0024 0025 0026 0028 002B 002D 002 F 0031 0033 0034 0035 0038 0039 003 A 003A 003 A 003A 003B 003C 003 E 004 1 0042 0043 0044 004 5 0046 0046 0046 0046 0049 004 A 004 C 004 D 004E 004E 004 E 0000 OOOO OOOO OOOO OOOO OOOO OOOO 0001 0002 0003 0006  18* + CB 27 3C 4F 7B E6 OF CD 0 6 0 0 06 04 CB 1A CB 1B 10FA OD 7B CD 0 6 0 0 FB C9  Assembler  L i s t i n g of Unit  twe1ve:  shift:  1sbyte:  ptHL2C :po i nt OD 79 CB 27 21 OOOO 85 6F DO 24 C9  2 1 OOOO F3 ED BO FB C9  jr s1a i nc Id Id and cal 1 Id rr rr d j nz dec Id cal 1 ei ret  E12AnaI0 E x t e r n a l 1sbyte A A C, A A.E OFH SendA2C B.4 D E shi f t C A.E SendA2C  Page  Routines send t h e l s b y t e A:= 2 + p r e d ( c h a n n e l ) 12 b i t c o n v e r t e r : a d d r : = 2 * c h a n - 1 f o r low o r d e r h a l f b y t e , s a v e i n C output l e a s t s i g . 4 b i t s send b y t e A t o d e v i c e C s h i f t output value r i g h t 4 b i t s 8 most s i g . b i t s i n t o E  to put  h i g h o r d e r b y t e o/p a d d r = 2 * c h a n - 2 data send b y t e A t o d e v i c e C  s e n t r y i n c u r r a n a w i t h HL. d e c r e m e n t C, c h a n g e AF: to channel ; pred(channel) dec C get p r e d ( c h a n n e l ) [ 0 . . 7 ] i n A Id A.C , A: = 2*pred(channel) s1a A ;po1nt t o a n a l o g o u t p u t s a v e t a b l e Id HL,currana add HL:= HL + A add A. L L . A Id NC ret H i nc ret  1dcuran i : ; s i n c e c u r r a n a c a n n o t b e .DEF d. A n a s t a t u s must b e d o n e h e r e : ;(HL):= s o u r c e b u f f e r HL,currana Id ;no c h a n g i n g v a l u e s w h i l e t r a n s f e r r i n g di -.move t h e d a t a ldir ei ret  .RELFUNC AnaOutRead,1 ;Read c u r r e n t a n a l o g o u t p u t c h a n n e l g i v e n b y p a r a m e t e r #1. ; U s e s AF. BC, DE, HL. d i s / e n - a b l e s i n t e r r u p t s .  D1 C1 E1 CD OOOO F3  . REF  ptHL2C  pop pop pop cal 1 di  DE BC HL ptHL2C  return address c h a n n e l number HL:= j u n k p o i n t t o c h a n n e l C's c u r r o u t e n t r y w i t h HL don't change t h e v a l u e w h i l e c o p y i n g i t  Appendix 0007 0008 0009 OOOA OOOB OOOC OOOD 000E 000E OOOE OOOO OOOO OOOO OOOO OOOO OOOO OOOO 0001 0002 0003 0006 0009 0009 0009 0009  D  Assembler  4E 23 46 FB C5 EB E9  Listing  of Unit Id inc Id el push ex jp  E12AnaI0 E x t e r n a l  Page  Routines  C,(HL) HL B,(HL)  ;get l s b y t e  BC DE,HL (HL)  ; r e t u r n v a l u e on s t a c k ;HL:= r e t u r n a d d r e s s  :and m s b y t e  .RELPROC A n a O u t S t a t u s . 1 ;Read a l l c u r r e n t a n a l o g o u t p u t v a l u e s i n t o p a r a m e t e r # 1 ® . ; U s e s F. BC, DE. a n d HL, d i s / e n - a b l e s interrupts.  E1 D1 E5 01 1000 C3 OOOO  Assembly O  .REF  ldcurani  pop pop push Id jp  HL DE HL BC,8*2 ldcurani  . END complete: errors flagged  374 l i n e s on t h i s assembly  ;return ;(DE):=  address s i nk b u f f e r  ;8 c h a n n e l s * 2 b y t e s p e r c h a n n e l ;actual r o u t i n e performed w i t h i n Anaread  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 151 162 163 164 165 166 167 168 169 170 17 1 172 173 174 175 176 177 178 179 180 18 1 182 183 184  D 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 7  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0  o 0 0 2 18 34 66 98 100 101 101 101 1 1 1 1 1 2 0  Listing  of U n i t  E12Sched  Page  <$L remout:} U n i t E12Sched; Interface Const  s c h h i b i t = 7; s c h h i c h a n = 16;  { h i g h e s t numbered < h i g h e s t numbered  d i g i t a l input b i t } analog input channel  >  Type s c h _ b i t n o = 0 . . s c h _ h i b i t ; sch channo = 1..sch_hichan; Procedure E12Start; { i n i t i a l i z e E12 d e v i c e p o l l i n g  >  Procedure W a i t B i t ( b i t : sch_b1tno; value: boolean); { Wait f o r a d i g i t a l i n p u t b i t o f g i v e n v a l u e . Successive are queued. >  calls  Procedure WaitAnalog (chan: sch_channo); { W a i t f o r a n a l o g i n p u t c h a n t o d i f f e r f r o m i t s s e t p o i n t by more t h a n +/i t s maxerror. S u c c e s s i v e c a l l s a r e queued. } Implementat i o n  <$L-} {$L-} Const  Uses Schedule, E12d1gio, E12anaio, ($L®> ($U u t i 1 : s t a r t e r . c o d e } S t a r t e r ; <$L@) pred_hichan  Type ana_pred_chan Var  bit bit bit ana ana 1ow, ana  =  15: =  < highest analog channel  -  1 )  0..pred_hichan;  n e e d e d , ana n e e d e d : b o o l e a n ; a v a i l : a r r a y [ s c h _ b i t n o ] of semaphore; l o c k : a r r a y [ s c h b i t n o ] of semaphore; a v a i l : a r r a y [sch_channo] of semaphore; l o c k : a r r a y [ s c h channo] of semaphore; h i gh: d i g i t a l ; request:'ana_chan_set;  Process Poller; forward; { A h i g h p r i o r i t y E12 w a i t  request s e r v i c i n g  Segment P r o c e d u r e E 1 2 S t r t ; Var p i d : p r o c e s s i d ; i , stack, prio: integer; Begi n  process  )  Appendix 185 186 187 188 189 190 19 1 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 2 10 21 1 212 2 13 214 215 216 2 17 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234  Compiler  D 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 4 4 4 4 4 4 4 1 1 1 1  1 1 1 1 2 3 3 2 1 2 3 3 2 1 1 0 0 0 d 0 1 0 0 0 d d 0 1 1 1 1 1 1 1 0 0 0 d d 0 1 1 1 1 1 1 0 0 0 d  0 6 16 2 1 30 30 45 60 65 74 74 90 106 11 1 126 0 0 0 1 0 0 0 0 0 1 1 0 0 9 18 36 39 41 50 0 0 0 1 1 0 0 10 22 25 27 37 0 0 0 1  Listing  of Unit  Page  E12Sched  b i t needed:= f a l s e ; ana_needed:= f a l s e ; low:= t ] : h i g h : = [ ] : ana_request:= [ ] : f o r i:= 0 t o s c h _ h i b i t do Begin seminit ( b i t _ a v a i 1 [ i ] . 0); s e m i n i t ( b i t _ l o c k [ i ] , 1) End; f o r i:= 1 t o s c h _ h i c h a n do Beg i n seminit (ana_avai1[1], 0); seminit (ana_lock[i], 1) End: S t r t l n f o ('E12Sched', ' P o l l e r ' , s t a c k , p r i o , s t a r t (Poller, p i d , stack, p r i o ) End; { of E12Strt >  Procedure E12Start; Beg i n E12Strt End; { of E12Start  false):  )  Procedure WaitBit; { Wait f o r a d i g i t a l input b i t of v a l u e } Begin wait ( b i t l o c k [ b i t ] ) : { queue s u c c e s s i v e c a l l s ) i f v a l u e then high:= high + [ b i t ] else low:= low + [ b i t ] : bit_needed:= true; Po111nputs: wa.i t ( b i t a v a l 1 [ b i t ] ) ; signal (bit_lock[bit]) { a l l o w next c a l l i n queue > End; { of WaitBit }  Procedure WaitAnalog; { W a i t f o r c h a n i n p u t t o d i f f e r f r o m s e t p o i n t > +- e r r o r Beg i n wait (ana l o c k [ c h a n ] ) ; { queue s u c c e s s i v e c a l l s ) ana r e q u e s t : = a n a _ r e q u e s t + [ c h a n - 1 ] ; ana needed:= t r u e ; Pol 1 Inputs; wait (ana_avai1[chan] ) ; signal (ana_lock(chan]) { a l l o w next c a l l i n queue } End; < of WaitAnalog >  Process  Po11er;  2  Appendix 235 236 237 238 239 240 24 1 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :d 5 :d 5 :d 5 :d 5 :0 5: 0 5 :1 5: 1 5 :1 5 :2 5 :2 5 :3 5 : ;4 5 : 4 5 : :5 5::5 5 : 5 5::6 5 : 7 5 : 7 5 :7 5 : 7 5 :7 5 :8 5 :6 5 :4 5 :4 5 : 3 5 : 4 5 : 5 5 : 5 5 :5 5 :6 5 :7 5:7 5: 7 5 :8 5 :6 5 :4 5: 4 5 : 4 5 : 3 5: 2 5: 2 5: 2 5: 1 5: 1 5 : 1 1 :0 1 :0  1 1 3 4 0 0 2 4 4 10 10 10 13 13 13 16 32 38 38 48 58 70 72 81 96 101 101 101 104 104 107 1 16 122 122 132 140 149 166 171 171 171 171 1 77 182 182 182 184 207 O 0  Listing  of U n i t E12Sched  Page  < A h i g h p r i o r i t y E12 w a i t r e q u e s t s e r v i c i n g Var d i g i n , b i t s _ r e a d y : d i g i t a l : anas_ready: ana_chan_set; i : i nteger; Beg i n { j o i n d e v i c e p o l l synchronous a c c e p t o r s } D v c e J o i n; while running Beg i n  process  3  }  do  if b i t _ n e e d e d then Begin { check d i g i t a l input f o r requested b i t s } DigRead ( d i g i n ) ; bits_ready:= digin*high + (low-digin); i f b i t s _ r e a d y <> [ ] t h e n Begin high:= h i g h - b i t s _ r e a d y ; 1ow:= low - b i t s _ r e a d y ; b i t _ n e e d e d : = h i g h + l o w <> [ ] ; i : = 0; f o r i : - 0 t o s c h _ h i b i t do i f i in b i t s _ r e a d y then signal (bit_ava11[i]) End ( o f if bits_ready > End; { o f i f b i t _ n e e d e d ) i f ana_needed then Beg i n AnaReady ( a n a s _ r e a d y ): anas_ready:- anas_ready * ana_request; i f a n a s _ r e a d y <> [ ] t h e n Beg i n ana_request:= ana_request - anas_ready; ana_needed:= a n a _ r e q u e s t <> ( ] ; f o r i:= 0 t o p r e d _ h i c h a n do if i in anas_ready then s i g n a l (ana_avai1[1+1]) End ( o f i f anas_ready } End; ( o f i f a n a _ n e e d e d ) < wait f o r next d e v i c e p o l l i f running then DvceAcpt End; { of w h i l e r u n n i n g >  > (true)  ( program e x e c u t i o n f i n i s h e d : signal a l l waiting tasks } DvceOu i t : f o r i:= 0 t o s c h _ h i b i t do signal (bit_avai1[i] ) ; f o r i:= 1 t o s c h _ h i c h a n do signal (ana_avai1[i]) End; ( of P o l l e r )  ^  O  00  Appendix 285 286 End  of  D 2 2  Compiler 1:0 :0  0 0  Listing  of U n i t  E12Sched  Page  End.  Compilation.  to o  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 17 18 133 32 1 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 34 1 342 343 344 345 346 347 348 349 350 35 1 352  Compiler  D 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 1 1 1 3 3 2 1 1 1 0 0  1 1 1 1 1 1 81 81 1 1 1 1 1 1 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 82 86 88 88 88 1 2 0 8 19 22 31 35 41 49 49 51 56 0 0  Listing  of U n i t  Page  TrigAna  {$L remout:} Unit TrigAna; Interface Var  ana_names:  array  Procedure T r i g l n i t ; { Read c h a n n e l i n v e r t  [1..16] of  and  string[8];  priorities  Procedure TrigSetup; { I n t e r a c t i v e l y change a n a l o g  trigger  from  disk,  priorities  start  triggering  }  }  Implementat ion  <$L-> {$L-} Const  Uses  ErrMessg. ReadKybd,  file_name = l o c h a n = 1; n o t r i g =8;  Type d a t a _ _ f i l e  Var  MiscFunc. WritCons. S c r n B u f f , E12anaio;  Schedule, <$L@>  'UTIL:SYSTEM.PRIO[1]'; h i c h a n = 16; { i f priority[chan] = notrig,  = file  of  chan  record i n v e r t ; ana c h a n _ f l a g s ; priority: ana_priorities end;  invert: ana_chan_f1ags; priority: ana_priorities; f i l e read, f i l e a l t e r e d : boolean;  Procedure TrigRead: Var chan: integer; prio file: data_file; Beg i n {$I-> reset ( p r i o _ f i l e , fi1e_name); {$1+} i f i o r e s u I t <> 0 then N o t e E r r o r (100, i o r e s u l t , f a l s e ) e l s e Begin 1nvert:= p r i o fi1e®.1nvert; p r i o r i t y : = p r i o fi1e®.priority; End; Pol 1 I n p u t s ; {$I-> c l o s e ( p r i o _ f i l e . normal): {$I+> f i l e read:= true End; { of T r i g R e a d )  {$L®>  never  trig'd  1  Appendix 353 354 355 35G 357 358 359 360 36 1 362 363 364 365 366 367 368 369 370 37 1 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 •o 1 :d 5 d 5 .0 5 0 5 1 5 1 5 2 5 1 5 1 5 1 5 3 5 3 5 4 5 5 5 6 5 3 5 2 1 0 1 0 1 0 1 d 2 0 2 1 2 1 1 0 1 0 1 0 1 d 1 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 3 d 6 0 6 1  0 1 1 0 0 0 2 1 1 32 33 36 41 46 46 55 69 101 105 0 0 0 1 0 0 6 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 5 21 21 0 0  L i s t i n g of U n i t  TrigAna  Page  2  Procedure Trigger; V a r c h a n . compare: integer; Begi n < ensure lowest p r i o r i t y i s z e r o } compare: notrig: f o r chan:= l o c h a n t o h i c h a n do compare: i_Min ( p r i o r i t y [ c h a n ] , compare); i f compare notrig { no c h a n n e l s t o t r i g g e r ) then AnalnStop e l s e Begin i f compare > 0 t h e n < decrease a l l p r i o r i t y proportionately } for c h a n : l o c h a n t o h i c h a n do i f p r i o r i t y [ c h a n ] <> n o t r i g t h e n p r i o r i t y t c h a n ] : = p r i o r i t y [ c h a n ] - compare: AnalnGo ( i n v e r t , p r i o r i t y ) End { of e l s e > End; { of T r i g g e r } 3  3  3  3  Procedure T r i g l n i t ; Begin i f not f i l e _ r e a d then i f not E r r o r N o t e d then End;  Procedure Const  TrigSetup;  x c h a n = 10; yO 6; xname - 37 fname 8 x i n v t - 48 f i nvt 5 xprio 60 fprio 1 xfreq 69 ffreq 6 dfreq 2  ychan  3  3  3  3  3 3  3 3  Var  TrigRead: Trigger  3  { ( ( < { { { { { {  3; fchan 2; ( channel p o s i t i o n , f i e l d o f f s e t t o add t o c h a n n e l f o r d i s p l a y l i n e chefhnel name d i s p l a y c o l u m n } " " " f i e l d width ) i n v e r t boolean d i s p l a y column ) " " " f i e l d width > p r i o r i t y d i s p l a y column } " " f i e l d width } f r e q u e n c y d i s p l a y column ) " " f i e l d width } " " decimal f i e l d width ) 3  com: char; c h a n , y: integer; p r o m p t : sb prmt p t r ; ntrig: array [1ochan..hichan]  Procedure CheckError; Beg 1 n if ErrorNoted then  exit  of  ) )  integer;  (TrigSetup)  K) O  Appendix 403 404 405 406 407 408 409 4 10 4 1 1 4 12 4 13 4 14 4 15 4 16 417 418 4 19 420 42 1 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 45 1 452  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 3 :0 3 :0 3 :d 7 :0 7 :1 7 :1 3 :0 3 :0 3 :d 3 :d 8 :d 8: 0 8 :1 8: 1 8 :1 3 :0 3 :0 3 :d 3 :d 9 :d 9: 0 9 :1 9:: 2 9 : 3 9: 3 9:: 3 9:: 3 9: 4 9 :5 9 :5 9:4 9: 3 9: 2 3 :0 3 :0 3 :d 3 :d 10 :d 10 :d 10 :0 10 : 1 10 : 1 10 : 1 10 : 1 10 : 1 10 : 1 10 : 1 10 : 2 10 : 3 10 : 4  0 0 1 0 0 2 0 0 1 1 1 0 0 3 31 0 0 1 1 1 0 0 9 9 13 29 32 46 46 62 77 79 79 0 0 1 1 1 3 0 0 2 2 30 30 38 38 47 61 61  Listing  of Unit  Page  TrigAna  End; Procedure TaskSwitch; Begin Pol 1 Inputs; CheckError End; Procedure F i n d N t r i g (chan: i n t e g e r ) ; { c a l c u l a t e number o f t i m e s e a c h c h a n n e l i s t r i g g e r e d V a r a n s , 1: i n t e g e r ; Beg i n ans : = 128; f o r 1:= 1 t o p r i o r i t y [ c h a n ] do ans:= a n s d i v 2; n t r i g[chan]:= ans End:  per c y c l e  }  P r o c e d u r e ShowData: { d i s p l a y i n v e r t b o o l e a n and t r i g g e r p r i o r i t y f o r a l l c h a n n e l s > V a r c h a n . y: i n t e g e r : Begi n f o r chan:= l o c h a n t o h i c h a n do Beg i n y:= yO + c h a n ; T o s s S t r i n g (xname, y, a n a _ n a m e s [ c h a n ] . f n a m e ) ; F i ndNTr i g ( c h a n ) ; if prior1ty[chan] <> n o t r i g t h e n Begin T o s s B o o l e a n ( x i n v t , y, i n v e r t [ c h a n ] ) ; Tosslnteger ( x p r i o , y, p r i o r i t y [ c h a n ] , f p r i o ) End; { of i f > TaskSw i t c h End ( o f FindNTr1g > End; { o f ShowData } Procedure ShowFrequencies; { display trigger frequencies f o r a l l channels } V a r p. c h a n : integer; p e r i od: rea1 : Begin { *** S h o w F r e q u e n c i e s *** > p:= 0; { f i n d p:= c y c l e p e r i o d i n 1 / 3 0 t h s o f a s e c o n d } f o r chan:'= l o c h a n t o h i c h a n do p: = p + n t r i g [ c h a n ] ; { convert p to seconds > p e r i o d : = p / 30.0; < d i s p l a y each c h a n n e l ' s f r e q u e n c y = n t r i g / p e r i o d } f o r chan:= l o c h a n t o h i c h a n do i f p r 1 o r i t y [ c h a n ] <> n o t r i g t h e n Beg i n T o s s R e a l ( x f r e q . yO+chan, n t r i g [ c h a n ] / p e r i o d , f f r e q .  dfreq)  3  Appendix 453 454 455 456 457 458 459 460 46 1 462 463 464 465 466 467 468 469 470 47 1 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 10::4 10 : 3 3 :0 3 :0 3 :0 3::0 3 : 1 3:: 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 : 1 3 :2 3 : 2 3 : 2 3: 2 3 :2 3 :4 3:4 3:4 3 :4 3 :5 3 :6 3 :6 3 :6 3: 7 3 :8 3 :8 3: 7 3 : 5 3:4 3: 3 3: 3 ' 3: 2 3 :4 3 :5 3: 5 3: 5  85 85 0 0 0 0 0 6 8 8 15 17 17 19 19 21 21 30 32 32 38 44 44 44 44 60 62 62 63 72 77 87 92 96 96 1 12 1 14 1 18 1 18 128 133 135 135 136 139 139 149 149 153 183  Listing  of U n i t  TrigAna  TaskSwi t c h End { of f o r . i f > End; < of ShowFrequencies  Page  }  Begin { *** m a i n body o f p r o c e d u r e T r i g S e t u p *** } { i f i n v e r t and p r i o r i t y a r r a y s n o t y e t i n i t i a l i z e d , do s o 1f n o t f i l e _ r e a d t h e n TrigRead; CheckError; { g e t t h e s c r e e n image > S c r n E n t e r ('TRIGANA'); CheckError; { f i n d n t r i g , d i s p l a y names, i n v e r t and p r i o r i t y d a t a } ShowData; { d i s p l a y channel f r e q u e n c i e s } ShowFrequenc i es; { l o a d prompt } prompt: ScrnPrompt ( 0 ) ; CheckError; { s t a r t w i t h c h a n n e l 16, f o r l a c k o f any b e t t e r } chan: 16; y:= yO + c h a n ; T o s s l n t e g e r (xchan, ychan, chan, f c h a n ) ;  )  3  3  Repeat { until 0(uit } { prompt f o r c h a n n e l t o c h a n g e o r c h a n g e s t o make } c o m : P r o m p t C a p I n ( 0 , 0, p r o m p t ® , ['1' . . '9'. ' I ' , 'P'. '0' ] ) ; CheckError; 3  1f com i n ['1'..'9'] then Begin T o s s E r a s e (xchan, ychan, f c h a n ) ; wr i t e (com); chan:= o r d (com) - o r d ( ' 0 ' ) ; i f chan 1 then Beg i n com:= R e a d C h a r l n ( [ ' 0 ' . . '6 ' . c h r ( 1 3 ) ] ) ; CheckError; i f com <> c h r ( 1 3 ) t h e n Beg i n wr i t e ( c o m ) ; chan:= 10 + o r d ( c o m ) - o r d ( ' O ' ) End End: y : yO chan End ( o f com i n ['1' . . '9' ] } 3  3  +  else i f com <> '0' t h e n Begin C a s e com o f ' I ' : i n v e r t [ c h a n ] : = TossNot ' P': Beg i n  (xinvt,  y,  invert[chan]); O  oo  Appendix 503 504 505 506 507 508 509 510 51 1 512 513 514 515 516 517 518 519 520 52 1 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552  Compiler  D  2 2 2 2 2 2 2 2 2 2 2 2 . 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  7 7 7 7 7 9 9 9 8 7 9 9 0 9 8 7 6 5 5 5 5 4 1 1 1 1 0 0 0 d d 0 O 1 1 1 1 3 3 3 2 1 0 0 0 0 1 1 1 1  183 189 205 207 209 21 1 226 232 236 238 240 250 264 280 293 298 299 301 306 309 31 1 316 318 330 330 330 0 0 0 1 1 0 0 8 19 22 31 35 41 49 55 55 0 0 0 0 0 6 14 17  L i s t i n g of  Unit  Page  TrigAna  T o s s E r a s e ( x p r i o , y, f p r i o ) ; com:= R e a d C h a r l n ( [ c h r ( 1 3 ) , '0' . . '7 ' ] ) ; CheckError; i f com = c h r ( 1 3 ) then B e g i n priority[chan]:= notrig: T o s s E r a s e ( x i n v t , y, finvt); T o s s E r a s e ( x f r e q , y, f f r e q ) End else Begin w r i t e (com); if p r i o r i t y [ c h a n ] = n o t r i g then T o s s B o o l e a n ( x i n v t , y, i n v e r t [ c h a n ] ) priority[chan]:= ord(com) - ord('O') End: FindNtrig (chan) End End: ( of Case ) f i l e altered:= true: Tr i gger; i f com <> ' I ' t h e n ShowFrequencies End { of com <> '0' } U n t i l n o t r u n n i n g o r (com = ' 0 ' ) : { return to o r i g i n a l screen ScrnReturn End; { of T r i g S e t u p }  image  )  Procedure SaveData; Var p r i o f i l e : d a t a _ f i l e : Beg i n < save a l t e r e d p r i o r i t y f i l e ) ($I-> rewrite ( p r i o _ f i l e , file_name); i f i o r e s u l t <> 0 then N o t e E r r o r (101, i o r e s u l t , t r u e ) e l s e Begin p r i o f11e®.1nvert:= i n v e r t ; p r i o f i 1 e®.priority: = p r i o r i t y ; put ( p r i o f i l e ) End; ($I-> close ( p r i o _ f i l e , crunch) {$1+) End; { of SaveData }  ($1+)  Begin ( i n i t i a l i z e / ha I t ) f i l e read:= f a l s e ; fi1e_a1tered:= f a l s e ; f i l l c h a r (ana names, s i z e o f ( a n a _ n a m e s ) , 0 ) : ***. if f i l e a l t e r e d then SaveData  5  Appendix 553 End  of  D 2  Compiler :0  Compilation.  0  Listing End.  of  Unit  TrigAna  Page  Appendix 3 4 5 G 7 8 9 10 1 1 12 13 14 15 16 17 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 2 10 21 1 212 213 214 215 21G 217 2 18 219 220 22 1 222 223 224 225  D 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler-Listing 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 1 1 3 7 7 3 3 3 3 3 3 1 1 1 8 8 8  d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 1 1 1 0 0 0 d d 0 1 0 0 1 1 1 2 0 0 d 0 1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 13 13 0 0 10 20 34 0 0 O 1 1 0 0 0 0 0 1 1 22 27 0 0 1 0 0 8  of Unit  PlotUtil  Page  ($L remout:> U n i t P I o t U t i1 ; Interface P r o c e d u r e P l o t B o u n d s (xmin, { s e t s p l o t x & y ranges ) Procedure Procedure Procedure Procedure  P l o t (x, y: r e a l ) ; PlotLift; PlotDrop; PlotAxes;  xmax, ymin,  ( { { <  move lift drop plot  ymax:  real);  pen t o x,y. w a i t f o r i t t o s t o p } pen o f f c h a r t ) pen onto c h a r t > r e c t a n g l e of s i z e bounds >  Imp 1ementat i on ($L-> Const  Var  Uses MiscFunc,  Schedule.  E12DigI0.  E12AnaI0.  E12Sched;  ($L@>  p e n b i t = 7; < E12 b i t f o r p e n m o t i o n 6 z a x i s } z d e l a y = 3: < t i c k s delay a f t e r z a x i s motion ) x c h a n = 7: y c h a n = 6; { analog output channels }  xlo. ylo, xhi,  yhi, xscale,  yscale:  real;  Procedure PlotBounds; Begin x l o : = xmin; x h i : = xmax; y l o : = ymin; y h i : = ymax; x s c a l e : = 4095.0 / ( x h i - x l o ) ; y s c a l e : = 4095.0 / ( y h i - y l o ) End: ( of PlotBounds )  Procedure Plot; P r o c e d u r e Send ( c h a n : i n t e g e r ; v a l u e , s c a l e , min: r e a l ) : Begin A n a W r i t e ( r o u n d ( r B o u n d e d ( s e a 1 e * ( v a 1 u e - m i n ) , 0.0, 4 0 9 5 . 0 ) ) , End; { of Plot > Beg i n Send ( x c h a n , x, x s c a l e , x l o ) : Send ( y c h a n , y, y s c a l e . y l o ) ; if r u n n i n g then W a i t B i t (pen b i t , t r u e ) { wait f o r motion to stop > End; P r o c e d u r e Pen ( d i r e c t i o n : d i g i t a l ) ; Begin DigWrite ( d i r e c t i o n , [pen b i t ] ) ; i f r u n n i n g then WaitTick (z d e l a y )  chan)  1  Appendix 22G 227 228 229 230 231 232 233 234 235 23G 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 End  of  Compiler  D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  1 1 1 4 4 1 1 1 5 5 1 1 1 1 6 6 6 6 6 6 6 6 6 1 1 1 1 1  0 0 d 0 1 0 0 d 0 1 0 0 0 d 0 1 1 1 1 1 1 1 1 0 0 0 0 1 0  Compilation.  0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 2 10 12 20 28 36 44 0 0 0 0 0 0  Listing End:  of U n i t  { of  Pen  Page  PlotUtil }.  -  Procedure P l o t L i f t ; Begin { high Pen ( [ p e n b i t ] ) End; { of P l o t L i f t > Procedure PlotDrop; Beg i n Pen ( [ ] ) ( low t o d r o p End; < of P l o t D r o p >  Procedure PlotAxes; Beg i n PlotLift; Plot (xlo, ylo) : P1otDrop; Plot (xlo, yhi) ; Plot (xhi, yhi) ; Plot (xhi, ylo) ; Plot (xlo, y l o ) ; PlotLift End; { of P l o t A x e s )  Begin if false End. { of  then { force PlotUtil )  initialization  of used  units  }  2  Appendix  Compiler  E  3 0 4 2 5 2 2 6 7 2 2 8 9 2 2 10 1 1 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 60 2 61 2 2 62 63 2 642 2 65 66 2 67 2 68 2 69 2 2 70 71 ' 2 2 72 2 73 74 2 2 75 76 2 77 2 78 2 79 2 2 80 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 2 92  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  d d d d d d d d d d d d d d d d d d d d d d d 0 1 2 3 4 4 3 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 5 7 1 1 1 1  Listing  Page  Starter  1  {$L remout:> Unit Starter; Interface Type  strt_name  = str1ng[8];  (unit_name, process_name: strt_name; var stack, p r i o : i n t e g e r ; boolean); c a 1 1 _ f rom_ i n i t i a 1 1 z a t i o n _ p a r t : o r named p r o c e s s ( f r o m body o f { l o o k up s t a c k s i z e a n d p r i o r .1 .t,y f .„ u n i t o r f r o m i n i t i a l i z a t i o n p a r t*? )» \ )  Procedure  Strtlnfo  Imp 1ementat i o n  {$L-}  Uses  Procedure 1 1 1 0 10 19 28 28 39 44 0 0 0 10 16 16 16 16 16 16 32 48 65 81 97 1 13 129 145 161  of Unit  ErrMessg,  MiscFunc:  <$L©>  Strtlnfo;  P r o c e d u r e T r y (u_name, p_name: s t r t _ n a m e ; stak, p r i o r i t y : integer) C o n s t s t a c k _ s a f e t y = 50; { add t h i s t o a l l l i s t e d s t a c k s i z e s } Beg i n i f u n i t _ n a m e = u_name t h e n i f p r o c e s s _ n a m e = p_name t h e n Beg i n stack:= stak + s t a c k _ s a f e t y ; prio:= p r i o r i t y ; exit (Strtlnfo) End < o f - i f p_name } End; { of Try } Begin < ** Uppercase  Strtlnfo > (un i t name);  Uppercase  (process_name);  L i s t t h e u n i t names, p r o c e s s names, s t a c k s i z e , & p r i o r i t y t o t r y : names must be UPPER CASE. Processes a r e l i s t e d in o r d e r of d e c r e a s i n g p r i o r i t y f o r ease of e d i t i n g o n l y . ) Try Try Try Try Try Try Try T ry T ry Try  ( 'SCHEDULE' ( ' E 1 2SCHED' ('PARAMSAV' ('SPUTTER', ('SPUTTER', ( 'SPUTTER ' , ('SPUTTER ' . ( 'SPUTTER' . ('SPUTTER ' . ('WALKER',  'POLLER', 'POLLER' , 'PARAMPUT', 'CURRENT', 'VOLTAGE', 'POWER', 'GAS[0]', 'GASt1 ] ' , 'GAS[2]', 'WALKSETP',  95. 70, 390, 1 10, 1 10. 1 10. 125, 125 , 125, 1 10.  230) 230) 210) 190) 190) 190) 190) 190) 190) 170)  ; ; ; ; ; •  M OJ  Compiler  Appendix E 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 1 10 11 1 1 12 1 13 1 14 1 15  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 O 0 0  177 177 177 177 193 209 225 24 1 257 273 289 305 320 335 335 335 339 395 399 0 0 0 0  End o f C o m p i l a t i o n .  Listing  { main Try Try Try Try Try Try Try Try Try Try  of U n i t  operator  Page  Starter  interaction  ( ' SCRNBUFF' ( 'SPUTTER' , ( 'SPUTTER ' . ( 'SPUTTER ' . ( 'SPUTTER ' . ( 'SPUTTER ' . ('PARAMETR' ('PARAMETR' ( 'PLOTTER ' , ( 'SCHEDULE '  task...  128 }  255. 1 10) 'UPDATE ' , 'PRESSURE ' . 1 10, 9 0 ) 'ANODE ' , 1 10, 9 0 ) 'RF BIAS ' , 1 10, 9 0 ) 'EXTRA 1 ' , 1 10, 9 0 ) 'EXTRA2', 1 10, 9 0 ) 245, 'WARNING'. 70) 95, 50) 'SHOWTIME'. 'PLOTDATA ' . 1 15, 30) 'DUMPTIME', 10) 50.  { T h e f o l l o w i n g c o d e w i l l o n l y be r e a c h e d i f s t a r t d a t a g o t o x y (O, 1 5 ) ; w r i t e (' ', u n i t _ n a m e , '/'. p r o c e s s _ n a m e , ' ' ) ; N o t e E r r o r ( 1 0 2 , 0. c a 1 l _ f r o m _ i n i t i a 1 i z a t i o n _ p a r t ) End;  End.  { of S t r t l n f o >  i s not found:  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  E 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0: d 1 :d 1 :d 1 :d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 :d 1: d 1: d 1 :d 2 :0 2 : 1 2: 2  Listing  of  Unit  Page  DataBus  1  ($L remout:} U n i t DataBus: Interface < type handshake v a r i a b l e s procedures } Type  handshake  must  be  manipulated  o n l y by  calls  to  DataBus  record l o c k : semaphore: n_sync_acpt: 0..maxint: n_async_acpt: 0..maxint; a t t e n t i o n : semaphore; r e a d y _ f o r _ d a t a : semaphore; d a t a _ v a l i d : semaphore; d a t a a c c e p t e d : semaphore end:  { Any number o f s o u r c e a n d a c c e p t o r p r o c e s s e s , w i t h any c o n v e n i e n t p r i o r i t i e s , may s h a r e one h a n d s h a k e . The s o u r c e h a n d s h a k e w a i t s f o r s y n c h ronous a c c e p t o r s o n l y . > P r o c e d u r e A c p t J o i n ( v a r h: handshake); < c a l l to accept f i r s t synchronous data > P r o c e d u r e A c p t H s h k ( v a r h: h a n d s h a k e ; synchronous: boolean); { c a l l to accept asynchronous or o t h e r than f i r s t synchronous Procedure ( call  AcptQuit  ( v a r h:  upon a c c e p t a n c e  and  data  )  handshake); use  of  last  desired  synchronous  data  )  P r o c e d u r e S r c e L o c k ( v a r h: handshake); { c a l l to e x c l u d e a l l o t h e r s o u r c e s from handshake, a l l o w d a t a change ) P r o c e d u r e S r c e H s h k ( v a r h: h a n d s h a k e ; unlocked: boolean); { c a l l a f t e r data changed--unlocked i s t r u e i f f S r c e L o c k wasn't c a l l e d first ) P r o c e d u r e H s h k l n i t ( v a r h: handshake); { i n i t i a l i z e type handshake } Implementat i o n 0 0  o 1 0 0 2  Procedure AcptJoin; { c a l l to a c c e p t f i r s t Beg i n wi t h h do Beg i n  synchronous  data >  Ul  Appendix 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 9 1 92 93 94 95 96 97 98 99 100 101  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 2:3 2:3 2:3 2:3 2:3 2:3 2:2 1 :0 1 :0 1 :0 1 :d 1 :d 3 :0 3: 1 3 :2 3:3 3:3 3:3 3:3 3:3 3:2 1 :0 1 :0 1 :0 1 :d 1 :d 4 :0 4: 1 4:2 4:3 4:3 4:2 1 :0 1 :0 1 :0 1 :d 1: d 5 :0 5: 1 1 :0 1 :0 1 :0 1 :d 1 :d 1: d 6 :d 6 :d 6 :0 6: 1 6:2  2 4 16 18 22 26 30 0 0 0 1 1 0 0 2 2 9 23 27 34 38 0 0 0 1 1 0 0 2 2 14 18 0 0 0 1 1 0 0 0 0 0 1 1 1 1 3 0 0 2  Listing  of U n i t  Page  DataBus  wa i t ( 1 o c k ) ; n sync acpt:= n_sync_acpt s i gna1 ( 1 o c k ) ; wa i t ( a t t e n t i on ) ; signal (ready_for_data ) ; wai t ( d a t a v a 1 i d ) End End:  +  1 :  Procedure AcptHshk; { c a l l to a c c e p t asynchronous or o t h e r than f i r s t s y n c h r o n o u s Beg i n w i t h h do Beg i n i f synchronous then signal (data_accepted) else n _ a s y n c _ a c p t : = n _ a s y n c _ a c p t + 1; wait ( a t t e n t i o n ) ; * i f synchronous then signal (ready_for_data); wa i t ( d a t a v a 1 1 d ) End • End:  P r o c e d u r e AcptOu i t; < c a l l u p o n a c c e p t a n c e and u s e o f l a s t Beg i n w i t h h do Beg i n n s y n c a c p t : = n _ s y n c _ a c p t - 1; signal (data accepted) End End:  Procedure SrceLock; { c a l l to i n h i b i t a l l o t h e r Begin wa i t ( h . 1 o c k ) End;  2  desired  s o u r c e s from  synchronous  handshake,  data  data  }  }  a l l o w data change  Procedure SrceHshk; ( c a l l a f t e r data changed--unlocked is true i f f SrceLock first > Var n sync l a t c h e d , n a s y n c l a t c h e d : 0 . . m a x i n t : n: i n t e g e r ; Beg i n w i t h h do Beg i n  wasn't  called  }  Appendix 102 103 104 105 106 107 108 109 1 10 1 1 1 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 120 12 1 122 123 124 125 126 127 128 129 130 13 1 132 133 134 135 136 137 End  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 6: 3 6: 3 6: 3 6: 3 6: 3 6:4 6 :5 6 :5 6 :5 6: 5 6:4 6: 3 6: 3 6: 3 6: 3 6: 2 1 :0 1 :0 1 :0 1 :d 1 :d 7 :0 7: 1 7 :2 7: 3 7 :3 7: 3 7: 3 7: 3 7: 3 7: 3 7: 2 1 :0 1 :0 1 :0 :0  2 7 15 33 40 46 46 49 59 68 8 1 88 106 126 144 146 O 0 0 1 1 0 0. 2 2 10 20 30 40 50 60 70 0 0 0 0  of C o m p i l a t i o n .  Listing  of U n i t  Page  DataBus  i f u n l o c k e d then wait (lock ); n sync l a t c h e d : n_sync_acpt; f o r n:= 1 t o n s y n c l a t c h e d do signal (attention); n a s y n c _ l a t c h e d : - 0; w h i l e n _ a s y n c _ a c p t > 0 do Beg i n n:= n a s y n c _ a c p t ; n a s y n c a c p t : = 0; n _ a s y n c _ l a t c h e d : = n _ a s y n c _ l a t c h e d + n; f o r n:= 1 t o n do signal (attention) End; f o r n:= 1 t o n _ s y n c _ l a t c h e d do wait ( r e a d y _ f o r _ d a t a ) ; f o r n:= 1 t o n _ s y n c _ l a t c h e d + n _ a s y n c _ l a t c h e d do signal f o r n:= 1 t o n s y n c l a t c h e d do wait ( d a t a _ a c c e p t e d ) ; s i gna1 (1ock) End End; -  3  •  Procedure Hshklnit; < i n i t i a l i z e type handshake } Begin w i t h h do Beg i n semi n i t ( 1 o c k , 1 ) ; n_sync_acpt:= 0; n async_acpt:= O; seminit (attention, 0); seminit (ready_for_data, 0); seminit (data_valid, 0); s e m i n i t ( d a t a _ a c c e p t e d , 0) End End;  End.  3  Appendix 3 4 5 G 7 8 9 10 1 1 12 13 14 15 16 17 18 19 20 2 1 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 201 212 213 2 14 215 2 16 217 2 18 2 19 220 221 222 223 224 225  E 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 • 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of U n i t  Schedule  Page  {$L remout:} Unit Schedule: Interface Type  sch chset  Var  = s e t of char;  running: boolean; { The c o n d i t i o n o f a l l r e p e a t i n g l o o p p r o c e s s e s - - r e s e t p r o g r a m a n d s h u t down a l l p r o c e s s i n g }  Procedure P o l l l n p u t s ; { S i g n a l p o l l i n g p r o c e s s to check the e x t e r n a l d e v i c e p o l l } Procedure DvceJoin; { Join external device  poll  clock,  synchronous  acceptors  and SrceHshk  }  Procedure DvceAcpt (synchronous: boolean); { Accept e x t e r n a l d e v i c e pol1 } Procedure DvceQuit: { Leave e x t e r n a l d e v i c e  poll  synchronous  acceptors >  Procedure WaitTick ( t i c k s : i n t e g e r ) ; { W a i t f o r t i c k s / 6 0 s e c o n d s ( u n l i m i t e d number o f c a l l e r s ) F u n c t i o n WaitChar ( c h a r s : s c h c h s e t ) : char; < Wait f o r a c o n s o l e c h a r a c t e r i n t h e s e t c h a r s ( c a l l e r s and w i l l be s a t i s f i e d i n t h e i r c a l l s e q u e n c e ) >  }  a r e queued  Implementat i o n  {$L-} ($L->  Uses  Er'rMessg, C l o c k , S c r e e n O p s , E x t r a S c r e e n O p s , ($U u t i 1 : s t a r t e r . c o d e } S t a r t e r ; <$L©}  Type p t r t i c k r e q u e s t = ©tick_request; t i c k request = record time to s i g n a l : tim_rec; s e m _ t o _ s i g n a 1 : semaphore; next r e q u e s t : p t r _ t i c k _ r e q u e s t end: Var  0  keyboard,  t o end the  t a s k done: s e m a p h o r e ; dvce_pol1: handshake; f i r s t request: p t r tick request; tick_needed, char_needed: boolean:  DataBus,  {$L(8}  1  Appendix 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 24 1 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 27 1 272 273 274 275  Compiler  E 2 2 2 2 2 2 2 2 2 2 2 2 2 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 3 3 1 1 1 4 4 1 1 1 5 5 1 1  d d d d d d d d d d d d d d d 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 d 0 1 0 0 d 0 1 0 0 d 0 1 0 0 d 0 1 0 0  2 6 22 23 23 23 1 1 1 1 1 1 1 1 2 0 0 3 9 12 2 1 30 39 43 58 75 90 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0  Listing  of Unit  Page  Schedule  c h a r a v a i l . c h a r _ l o c k : semaphore; match: s c h _ c h s e t ; ch: char;  Process Poller; forward; < A h i g h p r i o r i t y wait request P r o c e s s DumpTime; forward; { a lowest p r i o r i t y p r o c e s s  servicing  to absorb  process }  unneeded cpu  time  Segment P r o c e d u r e S c h d l n i t : Var p i d : p r o c e s s i d ; stack, prio: integer; Begin r u n n i ng:= t r u e ; tick needed: false; char_needed:= f a l s e ; f1rst_request:= n i l ; seminit (task_done, 0 ) : seminit (char_avail. 0); s e m i n i t ( c h a r _ l o c k , 1); Hshklnit (dvce_poll); S t r t l n f o ('Schedule', 'Poller', stack, prio, true): start (Poller, p i d , stack, prio); S t r t l n f o ('Schedule', 'DumpTime', s t a c k , p r i o , t r u e ) ; s t a r t (DumpTime, p i d , s t a c k , p r i o ) End; < o f Segment S c h d l n i t } 3  Procedure P o l l Inputs; Beg i n signal (task_done) End; Procedure DvceJoin; Begin AcptUoin (dvce_poll) End; Procedure DvceAcpt; Beg i n AcptHshk (dvce p o l l , End; Procedure DvceOuit; Beg i n AcptQuit (dvce_poll) End;  synchronous)  2  Appendix 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 31 1 312 313 314 315 316 317 3 18 319 320 32 1 322 323 324 325  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :0 1 :d 1: d 1 :d 10 :0 10 : 1 10 : 1 10 : 1 1 :0 1 :0 1 :0 1 :d 1 :d 6 :d 6 :d 6 :0 6 : 1 6 : 1 6 : 1 6 : 1 6 : 1 6 : 3 6 :3 6 :4 6 : 5 6 : 5 6 :4 6:: 3 6 : 3 6 : 3 6 : 3 6 : 3 6 : 3 6 : 5 6;: 5 6 :5 6 :4 6:: 4 6:: 3 6 :4 6:: 4 6: 6 6:: 6 6::6 6::5 6 :5 6: 4 6 :6 6::6 6 :6  Listing  of  Unit  Schedule  Page  0 1 F u n c t i o n R e q s t LE t ( r e q u e s t : p t r _ t i c k _ r e q u e s t : t: tim r e c ) : boolean; 2 { t r u e i f r e q u e s t <> n i l and r e q u e s t © . t i m e _ t o _ s i g n a 1 <= t } 1 Begin 0 5 i f request = n i l then R e q s t LE t:= f a l s e 6 else R e q s t LE t:= n o t Tim a L T b ( t . r e q u e s t © . t i m e _ t o _ s 1 g n a 1 ) 9 End; 0 0 0 1 Procedure WaitTick; 1 { A c a l l to t h i s procedure w i l l r e t u r n t i c k s / 6 0 seconds l a t e r } 1 V a r new t i m e , w a i t t i m e : t i m _ r e c ; p r i o r request, request: ptr_tick_request; 5 Beg i n 0 i f t i c k s <= 0 0 then signal (task_done) 1 8 e l s e Begin 8 ( c a l c u l a t e a b s o l u t e time of r e t u r n t o c a l l e r } 1 1 w i t h new t i m e do time (hiword, loword); 1 1 w i t h wa i t t i me do 15 Begin 15 1oword:= t i c k s ; 15 17 h i word:= 0 17 End; TimAdd (new t i m e , new_time, w a i t _ t i m e ) ; 19 24 24 { q u e u e t h e new t i c k r e q u e s t ) 24 if f i r s t _ r e q u e s t = n i l 24 then Begin { t h e new r e q u e s t i s t h e o n l y one } 25 new (request); 28 first_request:= request; 33 request©.next_request:= n i l 36 End { of i f n i l f 1 r s t _ r e q u e s t > 39 4 1 4 1 e l se i f Tim a L T b (new t i m e , f i r s t _ r e q u e s t ® . t i m e _ t o _ s i g n a 1 ) 43 then Begin { t h e new r e q u e s t g o e s a t t h e f r o n t o f t h e q u e u e 46 new ( r e q u e s t ) ; 50 request©.next^request:= f i r s t _ r e q u e s t ; 55 f i r s t request:= request 60 End ( o f i f T1m_aLTb ) 60 63 else Begin 63 65 request:= first_request; 67 p r i o r request:= request; w h i l e R e q s t LE t ( r e q u e s t , n e w _ t i m e ) do 69  3  Appendix 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 34 1 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 6: 7 6:8 6 :8 6:7 6: 7 6 :6 6 :6 6: 8 6 :8 6 :8 6: 7 6: 7 6:6 6 :8 6:8 6 :8 6: 7 6: 5 6: 5 6: 5 6: 3 6: 4 6 : 5 6: 5 6: 5 6 : 5 6: 5 6 : 5 6 :4 6:4 6 :4 6 : 3 6 : 3 6 : 2 1 :0 1 :0 : 1 :0 : 1 :d : 1 :d : 7 :0 : 7: 1 7: 1 7 :1 7 :1 7 :1 7 :1 7 :1 7 :1 1 : 0 1 :0  76 76 78 79 83 83 84 87 92 97 100 102 102 104 109 1 15 1 18 120 120 120 120 122 122 127 137 140 143 143 147 147 147 147 152 152 0 0 0 1 1 0 0 3 13 16 19 22 28 32 0 0  Listing  of U n i t  Schedule  Page  Beg i n prior_request:= request; request: request©.next_request End; { of w h i l e R e q s t _ L E _ t } 3  i f request - n i l then Begin { t h e new r e q u e s t i s t h e l a s t new ( r e q u e s t ) : p r i o r request®.next_request:= request; request®.next_request:= n i l End < of i f n i l r e q u e s t }  one  1n t h e  queue  e l s e Begin { t h e new r e q u e s t g o e s w i t h i n t h e q u e u e b o u n d s new ( r e q u e s t ) ; request®.next_request: pr1or_request©.next_request; p r i o r request©.next_request:= request End { of e l s e not n i l r e q u e s t > End; { o f e l s e n o t n i l f i r s t _ r e q u e s t } 3  (  f l a g t h e semaphore and t i m e t o s i g n a l f o r t h i s r e q u e s t w i t h r e q u e s t ® do Beg i n t i m e t o _ s i g n a l : = new_t1me; seminit (sem_to_signa1, 0); tick_needed: true; signal (task_done); { w a i t u n t i l sem t o s i g n a l i s s i g n a l l e d by P o l l e r } wait (sem_to_signa1) End; { of w i t h request® > 3  { a w a i t o f t i c k s / 6 0 s e c o n d s has dispose (request) End End;  { of e l s e t i c k s < of WaitTick )  now  been  achieved  }  > 0 >  F u n c t i o n WaitChar: ( W a i t f o r a c o n s o l e c h a r a c t e r In c h a r s } Beg i n wait (char l o c k ) ; { queue W a i t C h a r c a l l s ) match:= c h a r s : char needed: true; signal (task_done); wa i t ( c h a r _ a v a 1 1 ) ; i f not r u n n i n g then c h : c h r ( 0 ) : WaitChar.: ch; signal (char lock) { a l l o w next queued WaitChar c a l l End; < of WaitChar ) 3  3  3  }  }  4  Appendix 37S 377 378 379 380 381 382 383 384 385 386 387 388 389 390 39 1 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 4 10 41 1 412 413 414 4 15 4 16 4 17 418 4 19 420 42 1 422 423 424 425  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 0 1 d 1 d 8 d 8 d 8 d 8 d 1 10 1 11 1 12 1 13 1 13 1 12 8 0 8 0 8 0 8 1 8 1 8 1 8 1 8 1 8 2 8 3 8 3 8 3 8 4 8 4 8 5 8 5 8 4 8 4 8 3 8 4 8 4 8 5 8 5 8 6 8 7 8 7 8 7 8 7 8 7 8 7 8 8 8 7 8 8 8 9 8 9 8 8 8 6  0 1 1 1 3 4 4 0 0 2 2 6 6 0 0 0 2 6 6 9 9 13 13 17 17 21 21 21 32 36 39 39 43 43 43 48 57 57 60 60 70 79 82 95 104 1 14 1 14 1 17 120 120  Listing  of Unit  Page  Schedule  P r o c e s s P o l 1er; { A high p r i o r i t y wait request V a r now: t i m _ r e c ; num_dhars: i n t e g e r ;  servicing  5  process >  Procedure S i g n a 1 _ f i r s t _ r e q u e s t ; Beg i n w i t h f i r s t _ r e q u e s t @ do Beg i n signal (sem_to_signa1); first_request:= next_request End { o f w i t h f i rst_request<5> } End; < of Signa1_f1rst_request > Begin ch:= ' '; ( wait f o r a task to complete > wai t ( t a s k _ d o n e ) ; wh i 1 e r u n n i ng do Beg 1 n w i t h now do time  (hiword,  loword);  i f t i c k _ n e e d e d then Begin { s i g n a l a l l t i c k r e q u e s t s t h a t a r e r e a d y t o go > w h i l e Re'qst_LE_t ( f i r s t _ r e q u e s t , now) do Signa1_f1rst_request; i f f i r s t _ r e q u e s t = n i l then tick_needed:= false End; ( o f i f tick_needed ) if char_needed then Begin { check c o n s o l e queued c h a r a c t e r s > u n i t s t a t u s ( 2 . num_chars, 1); w h i l e c h a r _ n e e d e d a n d (num_chars > 0 ) d o Beg i n num_chars:= num_chars - 1; { see i f the char i s i n the s p e c i f i e d a c c e p t a b l e s e t > read (keyboard, c h ) ; if eoln (keyboard) then ch:= c h r ( 1 3 ) { c a r r i a g e r e t u r n ) else i f eof (keyboard) then ch:= MapCommandKey ( s c _ e o f _ k e y , f a l s e ) : i f c h i n match then Beg i n char_needed:= f a l s e ; signal (char_avail) End { o f i f c h i n match } End { o f w h i l e c h a r needed }  ro  Appendix 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 451 452 453 454 455 End  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 1 1 1 1 1 9 9 9 1 1 t 1 1  4 4 3 4 5 5 5 3 3 3 2 2 2 1 1 1 0 0 0 d d 0 1 1 0 0 0 0 1 0  120 122 122 125 134 139 139 139 142 142 147 153 153 153 16 1 164 0 0 0 1 1 0 2 10 0 0 0 0 0 0  Listing End; with if  of U n i t  Schedule  Page  6  { o f i f char_needed > d v c e p o l l do n_sync_acpt + n_async_acpt > 0 SrceHshk ( d v c e _ p o l l , t r u e ) ;  then  { wait f o r a task to complete } wait (task_done); < e n s u r e no e r r o r h a s b e e n d e t e c t e d } i f E r r o r N o t e d then running: false End; { of while running ) 3  { program e x e c u t i o n f i n i s h e d : signal a l l waiting tasks w h i l e f i r s t r e q u e s t <> n i l do Signal f i r s t request; signal (char_ava11): SrceHshk ( d v c e _ p o l l , t r u e ) End; { of P o l l e r }  P r o c e s s DumpTime; { a lowest p r i o r i t y p r o c e s s t o absorb unneeded Beg i n w h i l e r u n n i n g do s i g n a l (task done); signal (task_done) End; ( o f DumpTime }  Begin ( Initialization Schdlni t End.  of Unit  Schedule  cpu  time  }  of Compilation.  to to  Appendix 3 4 5 6 7 8 g 10 11 12 13 14 15 1S 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4 1 42 43 44 45 46 47 48 49 50 51  E 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0 :d 1 :d 1: d 1: d 1 d 1 d d  1 1 1 1 1 1  1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 •d  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of Unit  ReadKybd  Page  1  {$L remout:} U n i t ReadKybd; Interface { Routines f o r r e a d i n g keyboard, a l l o w i n g Schedule t o s i g n a l processes while w a i t i n g f o r keyboard c h a r a c t e r } Type  competing  rk_chset = s e t of char; rk_long_string = string[255];  Procedure CursBorrow; Procedure CursReturn: < A p r o c e s s w a n t i n g t o w r i t e t o t h e s c r e e n must w r i t e without a task switch, CursReturn >  CursBorrow,  do t h e  Function ReadCharln (return_on_match: rk c h s e t ) : char; Function FetchCharln (x.y: integer; return_on_match: r k _ c h s e t ) : char; { R e t u r n w i t h c h a r when a c h a r i n r e t u r n on m a t c h h a s b e e n t y p e d . The c h a r i s n o t e c h o e d t o t h e s c r e e n . } F u n c t i o n R e a d C a p I n ( r e t u r n on m a t c h : r k c h s e t ) : c h a r ; Function FetchCapIn (x.y: integer; r e t u r n on m a t c h : r k c h s e t ) : c h a r ; F u n c t i o n PromptCapIn ( x . y : i n t e g e r : prompt: rk l o n g s t r i n g : r e t u r n _ o n match: r k c h s e t ) : c h a r ; < R e t u r n w i t h c h a r when a c h a r i n r e t u r n on m a t c h h a s b e e n t y p e d . A l p h a b e t i c chars a r e c o n v e r t e d to upper case. The c h a r i s n o t echoed to the s c r e e n . In t h i r d c a s e , f i r s t send prompt t o x.y. b r o k e n i n t o s e v e r a l p i e c e s by ' ' i f necessary, r o t a t i n g the p i e c e s when ' ? ' i s t y p e d > F u n c t i o n ReadBoolean: boolean; Function FetchBoolean (x,y: integer): { ReadCapIn ( [ ' T ' . ' F ' ] ) , echo ' t r u e  boolean; ' or 'false' >  Function Readlnteger (field,min,max: integer): integer; Function FetchInteger.(x,y,fie1d,min,max: Integer): Integer; { R e t u r n w i t h a n i n t e g e r b e t w e e n m i n a n d max r i g h t j u s t i f i e d i n a f i e l d of g i v e n width } F u n c t i o n ReadReal ( f i e 1 d , d e c _ f i e l d : i n t e g e r ; min,max: r e a l ) : r e a l ; Function FetchReal (x,y,fie1d,dec f i e l d : integer; min,max: r e a l ) : r e a l ; { R e t u r n w i t h a r e a l b e t w e e n m i n a n d max r i g h t j u s t i f i e d i n a f i e l d of g i v e n width w i t h dec f i e l d f o l l o w i n g the decimal ) Function ReadFloat ( f i e l d : integer; min,max: r e a l ) : r e a l ; Function FetchFloat ( x . y , f i e l d : integer; min,max: r e a l ) : r e a l ; < R e t u r n w i t h a r e a l b e t w e e n m i n a n d max r e a d a s m a n t i s s a a n d exponent >  Appendix 52 53 54 55 56 57 58 59 60 6 1 182 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 31 1 312 313 314 315 3 16 317 318 319 320 32 1 322 323 324 325 326 327 328 329 330 33 1 332  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10  E  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 2 0 0 0 1 2 1 1 1 1 2 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 7 8 20 20 20 1 1 1 1 1 2 1 1 17 2 1 25 36 37 38 38 1 0 0 5 0 0 0 0 9 17 25 25 25 25 29  Listing  of U n i t  ReadKybd  Page  P r o c e d u r e R e a d S t r i n g ( v a r s: s t r i n g ; Procedure F e t c h S t r i n g (x,y: integer; { R e t u r n w i t h new s t r i n g o f l e n g t h Procedure rkHalt; { C a l l upon p r o g r a m  end  to return  2  field: integer); v a r s: s t r i n g ; field: integer); <= f i e l d i n v a r i a b l e s >  from  a l l CursBorrow  waits  }  Implementat i o n  <$L-) <$L-} Var  Uses  ScreenOps, ExtraScreenOps, ErrMessg, WritCons. DataBus. Schedule; ($L®>  <$L©>  BS, CR. DEL. L E F T : c h a r ; c u r s x, c u r s y: i n t e g e r ; c u r s busy: b o o l e a n ; c u r s a v a i l : handshake;  Procedure  RubChar  Procedure  RubString  Segment  Var  MiscFunc,  ( V a r s:  string);  ( V a r s:  F u n c t i o n ReadNumber  forward;  string);  forward;  (field, dec_field: integer; min,max: r e a l ) : r e a l ;  r e t u r n on m a t c h : s c _ c h s e t ; f r s t d i g . d o t _ p o s , l e n , c t r : 0..21; r , s i gn: r e a 1 : num s t r : s t r i n g [ 2 1 ] : one c h : s t r i ng[ 1 ]; ch: c h a r ;  Procedure CheckError; { C h e c k f o r UBC s y s t e m e r r o r Beg i n i f E r r o r N o t e d then Begin ReadNumber:= min; End; Beg i n i f min > max then Begin N o t e E r r o r (110, one ch:= ' ';  0,  Repeat ( Read t h e n u m _ s t r { E r a s e work s p a c e } WriteErase (field);  )  exit  false):  as  (ReadNumber)  End  CheckError  a string  until  End;  no  errors  are detected }  Ul  Appendix 333 334 335 336 337 338 339 340 34 1 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382  10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10  E  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 6 6 6 7 6 7 5 4 6 6 6 6 6 5 4 4 3 3 3 2 2 2 2 2 2 2 3 4 4 3 3 3 2 2 3  29 29 37 64 86 95 97 97 106 121 129 143 167 171 184 187 194 202 224 240 247 252 263 265 276 283 31 1 333 338 349 358 358 363 363 363 372 380 392 4 14 428 445 450 450 480 484 489 489 489 495 5 17  Listing  of Unit  Page  ReadKybd  num_ s t r 1 c h a r a t a t i m e t o a l l o w m u l t i t a s k i n g > num_str:= ''; r e t u r n _ o n _ m a t c h : = [ B S . C R , D E L , L E F T , ' - ' '0' . . '9' ] ; r e t u r n on m a t c h i f d e c _ f i e l d > 0 then return_on_match: ch:= W a i t C h a r (return_on_match): CheckError;  { Read t h e  :  while and  not e o l n (keyboard) ( ( c h i n [BS.DEL,LEFT]) or ((1ength(num_str) < f i e l d ) and ((pos('.',num_str)=0) or -str) < dec f i e l d ) ) ) ) (1ength(num_str)-pos('. do B e g i n i f ch i n [BS,DEL,LEFT] then Begin i f c h - DEL t h e n RubString (num_str) else RubChar ( n u m _ s t r ) : 0) t h e n i f ( d e c _ f i e l d > 0) a n d ( p o s ('.',num_ s t r ) return_on_match:= return_on_match + [ ' . ' 1; i f l e n g t h (num_str) = 0 then return_on_match:= return_on_match + [ '-' ] End else Begin w r i t e (ch) ; one_ch[1]:= ch; num_str:= c o n c a t (num_str,one_ch); match - [ return_ If c h = '.' t h e n return_on_match return_on_match:= return_on_match ['-'] " End; ch:= W a i t C h a r (return_on_match); CheckError End; Check f o r d e c i m a l po i n t , n o t e s i g n ) len:= l e n g t h (num s t r ) ; i f 1 en <= 0 t h e n num_str:= '.' e 1 se W r i t e L e f t (len); -1.0; then Begin sign: i f num s t r [ 1 ] = '-' ' e l s e Begin s i g n : • 1.0; d o t _ p o s : = pos ( . ' , n u m _ s t r ) : then i f dot_pos = 0 Beg i n num_str:= c o n c a t (num s t r , • ); dot_pos:= 1 e n g t h (num s t r ) End; :  { Convert s t r i n g to real } r:= 0.O; f o r c t r : = f r s t _ d i g to dot_pos-1 r : = r + (ord(num s t r [ c t r ] ) - 4 8 )  f rst dig f rst" dig  = 2 = 1  do pwrof t e n ( d o t _ p o s - c t r - 1 ) ;  End End;  Appendix 383 384 385 38G 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 4 10 4 1 1 4 12 4 13 4 14 4 15 4 16 4 17 418 419 420 42 1 422 423 424 425 426 427 428 429 430 431 432  10 10 10 10 10 10 10 10 10 10 10 10 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  E  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 20 20 20 20 20 20 20 20 1 1 1 1 2 1 21 21 21 21 21 21 21 1 1 1 1 4 4 1 1 1 5 5 1 1 1 1 6 6  2 3 2 2 1 1 1 1 1 0 0 O d d O 1 1 2 3 3 2 0 0 0 d d 0 1 1 2 3 3 2 0 0 0 d 0 1 0 0 d 0 1 0 0 0 d d 0  552 577 61 1 616 616 639 639 639 648 0 0 0 1 1 0 0 4 9 9 12 18 0 0 0 1 1 0 0 4 9 9 12 13 0 0 0 1 0 0 • 0 0 1 0 0 0 0 0 1 1 0  Listing  of U n i t  ReadKybd  Page  for c t r : = 1 to 1ength(num_str)-dot_pos do r:= r + ( o r d ( n u m _ s t r [ c t r + d o t _ p o s ] ) - 4 8 ) / p w r o f t e n ( c t r ) r:= r+ s i gn Until  ( r <=  max)  and  ( r >=  min);  < Send t h e f o r m a t t e d s t r i n g t o t h e s c r e e n } WriteRead ( r , f i e l d , dec_field); ReadNumber:= r End; { o f Segment F u n c t i o n ReadNumber >  P r o c e d u r e RubChar; Var l e n ; i n t e g e r ; Beg i n 1 en:= 1 e n g t h ( s ) ; i f l e n > 0 then Beg i n WriteBackspaces (1); d e l e t e ( s , 1 en, 1) End End;  Procedure RubString; Var l e n : i n t e g e r ; Begin 1 en:= 1 e n g t h ( s ) : i f 1 en > 0 t h e n Begi n WriteBackspaces (len); s : = End End;  Function ReadCharln; Beg i n ReadCharln:= WaitChar End;  (return  Function FetchCharln; Beg i n g o t o x y (x, y ) ; FetchCharIn:= End:  F u n c t i o n ReadCapIn; Var ch: c h a r ; Beg 1 n  on  match)  WaitChar  (return_on_match)  4  Compiler  Appendix E 433 434 435 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 45 1 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 48 1 482  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  6 6 6 6 1 1 1 7 7 1 1 1 8 8 8 8 8 22 22 22 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8  1 2 1 1 0 0 d 0 1 0 0 d d d d d d 0 1 1 0 0 0 1 1 1 1 1 1 1 2 2 3 3 3 3 2 1 1 1 1 2 2 2 2 2 2 2 4 4  0 0 18 33 0 0 1 0 0 0 0 1 1 2 7 47 49 0 0 3 0 0 0 7 17 17 31 35 35 49 54 54 54 64 71 79 79 81 86 88 88 88 96 96 103 11 1 1 12 1 16 1 16 131  Listing  of U n i t  Page  ReadKybd  Repeat . ch: = UpperChar (WaitChar (return_on_match + U n t i l ( c h i n return_on_match) or ErrorNoted: ReadCapIn:= c h End; Function Begin gotoxy End:  ['a'..'z']))  FetchCapIn; (x. y ) :  FetchCapIn:=  ReadCapIn  (return_on_match)  F u n c t i o n PromptCapIn; Var c h : c h a r ; t i t l e , i n d e x , room, l e n , xO: i n t e g e r ; 1 i ne: s t r 1 n g [ 7 9 ] ; t a i l : s t r i ng[3]; Procedure TaskSwitch; Begin Po11 I n p u t s ; i f E r r o r N o t e d then exit (PromptCapIn) End: { of TaskSwitch } Begin { +** P r o m p t C a p I n *** } { r e c o r d c u r s o r p o s i t i o n , e r a s e the l i n e from t h e r e ) x0:= x; s c E r a s e T o E o l (xO, y ) ; < i n i t i a l i z e prompt t r a i l e r , move c u r s o r t o p o s i t i o n } t a l l : = ' ? ': t a i 1 [ 3 ] := c h r ( 8 ) ; PromptCapIn:= c h r ( 0 ) ; < i n case of task e r r o r > < l o o k f o r l e a d i n g prompt t i t l e - - e . g . 'Commands: ' } t i t l e : = p o s (' ', p r o m p t ) + 1; i f t i t l e > 1 then Beg i n { w r i t e t h e t i t l e , remove i t f r o m p r o m p t , p o i n t c u r s o r b e y o n d u n i t w r i t e (1. prompt!1]. title); d e l e t e (prompt, 1, t i t l e ) ; x : = x + title; TaskSwi t c h End; curs_y:= y: i ndex:= 1; Repeat ( u n t i l v a l i d ch recieved > ( e r a s e a n y e x i s t i n g d i s p l a y on r e m a i n d e r o f l i n e y } scEraseToEol (x. y ) ; { f i n d room f o r p r o m p t , r e m a i n i n g l e n g t h o f prompt } room:= 78 - x; len:= l e n g t h (prompt) - ( i n d e x - 1 ) ; i f l e n <= room then Begin { r e m a i n i n g l e n g t h f i t s i n room: w r i t e i t . no ' ? ' } if l e n > 0 then u n i t w r i t e (1, prompt[index], l e n ) ; uni t w r i te ( 1 , t a i 1 [ 1 ] , 1);  5  Appendix 483 484 485 486 487 488 489 490 49 1 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 5 1 1 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 53 1 532  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 8 :4 8 :4 8 :4 8 :3 8 :2 8 :2 8 :4 8 :5 8 :5 8 :4 8 :4 8 :4 8 :4 8 :4 8 :4 8 :4 8 :4 8 :3 8 : :2 8 : 2 8 : 2 8 : 2 8 : 1 8: 1 8: 1 8: 1 1 :0 1 :0 1 :0 1 :d 9 :d 9 :0 9: 1 9: 1 9: 1 9: 1 1 :0 1 :0 1 :d 10 :0 10 : 1 1 :0 1 :0 1 :0 1 :d 1 1:0 1 1: 1 1 :0 1 :0 1: d  14 1 149 149 149 151 153 153 153 169 170 183 185 185 195 205 2 13 213 216 219 222 227 246 246 256 256 262 0 0 0 1 1 0 0 3 18 21 0 0 1 0 0 0 0 0 1 0 0 0 0 1  Listing  of Unit  Page  ReadKybd  c u r s x:= x + 1 en + 1 : { c y c l e b a c k t o b e g i n n i n g o f prompt > i ndex:= 1 End e l s e Begin { r e m a i n i n g l e n g t h d o e s n o t f i t i n room: find a ' ' break Repeat w h i l e p r o m p t [ i n d e x + r o o m ] <> ' ' do room:= room - 1; room:- room - 1 U n t i l p r o m p t [ i n d e x + r o o m ] = ' '; TaskSwi t c h : < w r i t e r e m a i n i n g prompt up t o b r e a k , t r a i l w i t h a ' ? ' } u n i t w r i t e (1, p r o m p t [ i n d e x ] , room); uni twr1te (1. t a i1[ 1 ] . 3); c u r s x:= x + room + 1; { c y c l e t o n e x t p a r t o f prompt } i n d e x : = i n d e x + room + 2 End; curs_busy:= f a l s e ; SrceHshk ( c u r s _ a v a i l , t r u e ) ; ch:= R e a d C a p I n ( r e t u r n _ o n _ m a t c h + [ ' ? ' ] ) ; curs_busy:= true Unt i1 c h <> ' ? ' : { remove prompt ) s c E r a s e T o E o l (xO, y ) ; PromptCapIn:= ch End;  F u n c t i o n ReadBoolean; Var b: b o o l e a n ; Begin Wr i t e E r a s e ( 5 ) ; b:= R e a d C a p I n ( [ ' T ' . ' F ' ] ) Wr i t e B o o 1 e a n ( b ) ; ReadBoo1ean:= b End;  =  'T';  F u n c t i o n FetchBoo1ean: Beg i n gotoxy (x, y ) ; FetchBoo1ean:= End;  Function Readlnteger; Beg i n Readlnteger:= trunc End; Function  Fetchlnteger;  (ReadNumber  ReadBoolean  (field,  0,  min,  max))  6  Appendix 533 534 535 536 537 538 539 540 54 1 542 543 544 545 546 547 548 549 550 55 i 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 58 1 582  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 12 :0 : 12 : 1 12 : 1 1 :0 : 1 :0 : 1 :0 1 :d 13 :0 13 : 1 1 :0 1 :0 1 :d 14 :0 14 : 1 14 : 1 1 :0 1 :0 1 :0 1 :d 15 :d 15 :d 15 :d 15 :d 15 :d 15 :d 23 :0 23 : 1 23 : 2 15 :0 15 :0 15 :0 15 : 1 15 :2 15 : 1 15 : 1 15 : 2 15 : 2 15 :2 15 :2 15 : 3 15 : 3 15 : 3 15 : 3 15 : 2 15 : 2 15 : 2 15 : 2 15 : 2 15 : 2 15 : 1  0 0 5 0 0 0 1 0 0 0 0 1 0 0 5 0 0 0 1 1 1 1 3 7 1 0 0 5 0 0 0 0 8 16 20 20 23 37 42 42 45 46 62 62 80 91 101 103 1 14 1 15  Listing  of U n i t  Begin gotoxy (x.y); Fetchlnteger:= End:  Page  ReadKybd  trunc  (ReadNumber  Function ReadReal; Begin R e a d R e a l : = ReadNumber End: Function FetchReal; Beg i n gotoxy (x.y); F e t c h R e a l : = ReadNumber End;  (field,  (field.  (field.  dec_field,  dec_field.  0. m i n ,  min,  min,  7  max))  max)  max)  Function ReadFloat; C o n s t h i _ m a n t i s s a = 9.999999; h i e x p o n e n t = 37; Var m a n t _ f i e l d , e x p o n e n t : i n t e g e r ; mant i s s a , r : r e a 1 : Procedure CheckError; < Check f o r UBC s y s t e m e r r o r ) Begin i f E r r o r N o t e d then Begin ReadFloat: min; exit (ReadFloat) End End; Beg i n { c h e c k f o r m i n > max e r r o r > i f m i n > max t h e n Begin N o t e E r r o r ( 1 1 1 , 0. f a l s e ) ; CheckError End; mant f i e l d : = f i e l d - 4; Repeat WriteBlanks (mant_field); w r i t e ('Esxx ' ) ; WriteLeft (fie1d-mant_f1e1d): Repeat WriteLeft (mant_field); mant i s s a : = ReadReal ( m a n t _ f i e l d , m a n t _ f i e l d - 3 , -h1_mant1ssa, CheckError U n t i l ( m a n t i s s a = 0.0) o r ( a b s ( m a n t i s s a ) >= 1 . 0 ) ; wr i t e ( ' E ' ) ; exponent: Readlnteger (3, -hi_exponent, hi_exponent) CheckError; r:= m a n t i s s a * T e n _ t o _ t h e ( e x p o n e n t ) ; WriteLeft (field) U n t i l ( r >= min) a n d ( r <= max): 3  3  to OJ  o  Appendix 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 61 1 6 12 6 13 6 14 615 6 16 6 17 6 18 6 19 620 62 1 622 623 624 625 626 627 628 629 630 631 632  fc' 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler  15 : 1 15 : 1 1 :0 1 :0 1 :d 16 :0 16 : 1 16 : 1 1 :0 1 :0 1 :0 1 :d 17 :d 17 :d 17 :d 17 :d 24 :0 24 : 1 17 :0 17 :0 17 : 1 17 : 1 17 : 1 17 : 1 17 : 1 17 : 1 17 : 2 17 : 3 17 : 3 17 : 3 17 : 4 17 : 4 17 :6 17 :7 17 : 7 17 : 7 17 :6 17 : 3 17 : 3 17 : 2 1 :0 1 :0 1 :d 18 :0 18 : 1 1 :0 1 :0 1 :0 1: d 2 :0  131 136 0 0 1 0 0 5 0 0 0 1 1 2 3 1 0 0 0 0 0 4 19 48 50 59 85 85 91 96 101 106 1 16 1 16 126 131 153 156 185 185 0 0 1 0 0 0 0 0 1 0  Listing  of  Unit  WriteFloat (r, ReadF1 o a t : = r End:  ReadKybd  Page  field):  Function FetchFloat; Begin gotoxy (x,y ) ; FetchFloat:= ReadFloat End;  (field,  min,  max)  Procedure ReadString; Var ch: c h a r : one c h : s t r i n g [ 1 ] : Procedure CheckError; { C h e c k f o r UBC s y s t e m e r r o r ) Begin if E r r o r N o t e d then Begin s:= ''; exit (ReadString) End; Beg i n WriteErase (field); s : = ''; one ch:= ' ': ch:= W a i t C h a r ([ BS . CR , DEL . LEFT , ' '..'->']): CheckError; w h i l e not e o l n ( k e y b o a r d ) and ( ( c h i n [ B S , D E L , L E F T ] ) o r ( l e n g t h ( s ) < f i e l d ) ) do Beg i n i f ( c h = BS) o r ( c h = L E F T ) then RubChar ( s ) else i f c h = DEL then RubString (s) else i f c h >- ' ' t h e n Beg i n w r i t e (ch) ; one_ch[1]:= ch; s:= c o n c a t ( s , o n e _ c h ) End; ch:= W a i t C h a r ( [ BS , CR , DEL . LEFT , ' '..'->']): CheckError End End; Procedure FetchStr1ng; Beg i n gotoxy (x.y); ReadString End:  Procedure Beg i n  CursBorrow;  (s,  field)  8  Appendix E 633 634 635 636 637 638 639 640 64 1 642 643 644 645 646 647 648 649 650 651 652 653 654 655 End  2 2 2 2 2 2 2 2 2 2 2 2 2 . 2 2 2 2 2 2 2 2 2 2  Compiler 2: 1 1 :0 1 :0 1 :d 3 :0 3: 1 1 :0 1 :0 1 :0 1 :d 19 :0 19 : 1 1 :0 1 :0 1 :0 1 :0 1: 1 1: 1 1: 1 1: 1 1: 1 1: 1 :0  0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 7 10 17 24 27 0  Listing  of Unit  w h i l e c u r s busy End:  Page  ReadKybd a n d r u n n i n g do  AcptHshk  (curs  9  false)  Procedure CursReturn; Beg i n g o t o x y ( c u r s x, c u r s _ y ) End;  Procedure rkHalt; Beg i n SrceHshk ( c u r s a v a i l , End:  true)  Beg i n BS : = MapCommandKey ( s c _ b a c k s p a c e _ k e y , t r u e ) ; CR:= c h r ( 1 3 ) ; DEL:= MapCommandKey ( s c _ d e l _ k e y , t r u e ) ; LEFT:= MapCommandKey ( s c l e f t _ k e y . t r u e ) ; curs_busy:= true; Hshklnit (curs a v a i l ) End.  of Compilation.  NJ NJ  Appendix  E  Compiler  3 O 0 d 4 1 d 2 2 1 d 5 6 2 1 d 1 d 7 2 8 2 1 d 9 2 1 d 1 d 10 2 1 d 1 1 2 1 d 12 2 13 1 d 2 14 1 d 2 15 2 1 d 2 1 d 16 17 2 1 d 18 2 1 d 1 d 19 2 1 d 2 20 21 2 1 d 22 1 d 2 23 1 d 2 24 2 1 d 25 2 1 d 1 d 26 2 27 2 1 d 1 d 28 2 29 1 d 2 2 1 d 30 1 d 31 2 1 d 32 2 1 d 33 2 34 1 d 2 1 d 35 2 36 1 d 2 37 1 d 2 1 d 38 2 39 2 1 d 1 d 2 40 41 {commented 1 d 42 2 43 2 1 d 44 1 d 2 45 1 d 2 1 d 46 2 47 1 d 2 48 1 d 2 49 1 d 2 2 1 d 50 1 d 51 2  Listing  of  Unit  ScrnBuff  Page  1  {$L remout:} Unit ScrnBuff; Interface { process Type  data  d i s p l a y and  screen  image  1ifo stacking routines >  sb_name = s t r i n g [ 8 ] ; s b _ p r m t _ n o - 0..255; sb_prmt = s t r i n g [ 2 5 5 ] ; sb_prmt_ptr = ®sb_prmt; sb_format = packed r e c o r d scrn_valid: boolean; { s c r e e n image d i s p l a y e d ? } { data d i s p l a y enabled? } enabled: boolean; { d i s p l a y e d v a l u e out of d a t e ? } new_data: b o o l e a n ; { c o l of s t a r t of data f i e l d } x: 0..79; { row o f d a t a f i e l d } y: 0..23; { s i z e of " " } f i e l d : 0..80: { f o r s b _ r e : ft d e c i m a l p l a c e s } d e c _ f i e l d : 0. .79; { " ": s c i e n t i f i c n o t a t i o n } f1 o a t : boolean end; s b _ r e , s b _ s t n g , sb_now); sb_kind = (sb_bool, sb_1nt s b _ d s p l _ p t r = ®sb_dspl: sb_dspl = record { 1 n t e r n a 1 1 i nkup ) next_dspl: sb_dspl ptr; ( display information } format: sb_format: c a s e k i n d : sb k i n d o f < data type, value } sb_boo1 (b: b o o l e a n ) ; sb_1nt: ( i : 1nteger); sb_re: (r: rea1); sb_stng ( s: s t r i ng) end;  Function  sbLink  ( i m a g e : sb_name: fmt: s b _ f o r m a t ; k: s b _ k 1 n d ) : s b _ d s p l _ p t r ; { C r e a t e t h e named k i n d o f d a t a , i n i t i a l i z e f o r m a t ( t y p e s b _ s t n g h a v e maximum s l e n g t h o f f m t . f i e l d ) , l i n k i n t o Image's d i s p l a y  will list }  { sbToss procedures: i f v a l u e <> d a t a _ p t r . v a 1 u e then copy v a l u e . Toss as s o o n as s c r e e n image i s v a l i d ; , s t r i n g uses v a r i a b l e value to reduce needed stack s i z e ; now u s e s c l o c k r e a d i n g - TO a t t o s s t i m e } Procedure sbTossBoolean (value: boolean; data_ptr: sb_dspl_ptr): Procedure sbTossInteger (value: integer; data_ptr: sb_dspl_ptr); Procedure sbTossReal (value: real; data_ptr: sb_dsp1_ptr); Procedure SbTossString (var value: s t r i n g ; data_ptr: sb_dspl_ptr); P r o c e d u r e sbTossNow (data_ptr: sb_dspl_ptr); Procedure sbDisable (data_ptr: s b _ d s p l _ p t r ) ; ( d i s a b l e d i s p l a y (sbToss re-enables) }  Appendix 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 7 1 72 73 ' 74 27 1 385 396 397 398 399 400 401 402 403 404 405 406 407 408 409 4 10 4 1 1 4 12 413 4 14 4 15 416 4 17 4 18 4 19 420  E 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of  Unit  Page  ScrnBuff  P r o c e d u r e S c r n E n t e r (name: sb name): ( S c r n C l e a r , a c t i v a t e named s c r e e n image 1s ' N I L ' ) , S c r n R e f r e s h i t }  (or blank  screen  1f  name  F u n c t i o n S c r n P r o m p t (prompt_num: s b _ p r m t _ n o ) : sb_prmt_ptr; { P o i n t t o g i v e n prompt ( >= 0 ) o f a c t i v e s c r e e n image } Procedure ScrnClear; { s c C l r S c r e e n (and note  active  Procedure ScrnRefresh; { W r i t e a c t i v e s c r e e n image  screen  lines  Procedure ScrnReturn; { S c r n C l e a r , r e - a c t i v a t e whatever ScrnEnter, ScrnRefresh i t } Procedure sbHalt; { c a l l to h a l t data  not  1..23  valid)  (clear  image was  display processing  )  screen  active  i f none) }  before  last  }  Implementation  {$L-} {$L-> ($L-> Const  Type  Uses  ScreenOps. ErrMessg, Clock, WritCons, DataBus, S c h e d u l e , ReadKybd, M i s c F u n c , ($L©) {$U u t i 1 : s t a r t e r . c o d e ) S t a r t e r ; {$L®}  ($L@)  f i l e n a m e = 'UTIL:SYSTEM.SCRN'; d s p l empty s i z e = 4; scrn  info  = packed r e c o r d i m a g e b l k s : 0..255; { M o f b l k s o f image } p r m t s b l k : 0..255; { prompts b l o c k # } image b y t e s : i n t e g e r ; { l e n g t h o f image } num p r m t s : 0..255; ( number o f p r o m p t s ) p r m t _ w o r d s : 0..255 { l e n g t h of prompts ) end; one_direc = record name: s b name; { s c r e e n image i d e n t i f i e r } info: scrn info; { " " information } end; d i r e c _ t y p e = a r r a y [0..31] of o n e _ d 1 r e c ; prmt t y p e = p a c k e d a r r a y [ 0 . 5 1 1 ] o f 0..255; r f r s h _ p t r = ©rfrsh; rfrsh = record next r f r s h : r f r s h _ p t r ; { l i n k up } name: sb_name; { r e l a v e n t s c r e e n Image } d s p l _ l i s t : sb_dspl_ptr { l i s t of d i s p l a y i n f o r m a t i o n end; stack link = record  2  Appendix E 42 1 422 423 424 425 426 427 428 429 430 43.1 432 433 434 435 436 437 438 439 440 44 1 442 443 444 445 446 447 448 449 450 45 1 452 453 454 455 456 457 458 459 460 46 1 462 463 464 465 466 467 468 469 470  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12  Compiler 1 :d 1 :d 1 :d 1 :d 1 .d 1 :d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d • 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 2 0 2 1 1 0 1 0 1 0 1 d 1 d 3 0 3 1 3 2 1 0 1 0 1 0 1 d 1 d 4 0 4 1 4 1 4 2 4 2  1 1 1 1 1 1 1 1 4 1 42 43 44 45 46 47 59 64 65 66 68 69 69 69 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 5 0 0 0 1 1 0 0 4 9 19  Listing  of Unit  ScrnBuff  Page  f o r m e r : © s t a c k 11nk; case Info to w r i t e : boolean of true : ( i n f o : s c r n 1nfo; rfrsh_link: rfrsh_ptr) end;  Var  3  { 11nk up >  ( screen•not n i l } { screen info } " ptr } ( refresh  screen f i l e : file; b l o c k : ©direc_type; image_words: integer; t o s : © s t a c k 1i nk; prompts: ©prmt_type; prmtptr: sb_prmt_ptr; rfrsh list: rfrsh ptr; t o s s _ d a t a : handshake: i o name: s b name; search_ptr: rfrsh_ptr; 11nk_data_ptr: s b _ d s p l _ ptr ; l i n k f m t : sb f o r m a t ; 1 i nk k: s b k i nd;  Function  Segment  Toslnfo:  Procedure  boolean;  ScrnIO ( j  P r o c e d u r e NewBlock; Beg i n i f b l o c k = n i l then End;  new  forward;  i nteger) ;  (block)  P r o c e d u r e DspzPrmts; { d i s p o s e o f prompts } Beg i n i f p r o m p t s <> n i l t h e n v a r d i s p o s e (prompts, tos©.1nfo.prmt End;  words)  Procedure Search; { p o i n t t o named r f r s h l i s t entry (or n i l i f not found) Begin search ptr:= r f r s h list; i f s e a r c h p t r <> n i l t h e n w h i l e ( s e a r c h p t r © . n a m e <> 1o_name) and ( s e a r c h p t r © . n e x t r f r s h <> n i l ) do  to OJ  Appendix 47 1 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 51 1 512 513 514 515 5 16 517 5 18 519 520  E  12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ' 12  Compiler 4: 3 27 34 4: 1 4: 2 39 4: 3 50 1 :0 0 1 :0 0 1 :0 0 1 :d 1 5 :d 1 5 :0 O 5: 1 0 5: 2 3 5: 3 3 5: 5 16 5 :6 21 5: 7 2 1 24 5: 7 5 :8 24 5 :9 30 5 :0 30 5 :0 35 5 :0 46 5 :9 46 5 : 7 • 49 5: 7 53 5 :8 . 56 5:: 9 56 5::9 61 5::9 61 61 5:: 8 5::6 63 5: 2 63 1 :0 0 1 :0 0 1 :0 0 1 :d 1 1 6 :d 6 :0 0 6: 1 0 6: 1 2 6 :2 7 6 :3 19 24 6 :4 24 6 :4 24 6 :4 24 6 :5 44 6: 6 6 :6 52 6 :5 52 54 6 :5  Listing  1f  of U n i t  ScrnBuff  Page  s e a r c h _ p t r : = s e a r c h ptr®.next r f r s h ; s e a r c h p t r <> n i l t h e n i f s e a r c h _ p t r ® . n a m e <> i o name t h e n search ptr:= n i l  End;  Procedure FlagData ( v a l i d : boolean); Var d a t a p t r : sb d s p l p t r ; Beg i n w i t h tos® do Begin i f ( r f r s h _ l i n k <> n i l ) a n d r u n n i n g t h e n with 1f d s p l _ l i s t <> n i l t h e n Begin data_ptr:= d s p l _ l i s t ; Repeat w i t h d a t a _ p t r ® , f o r m a t do Beg i n s c r n v a 1 i d:= v a 1 i d; i f e n a b l e d then new_data:= t r u e ; d a t a p t r : = next d s p l End Until data p t r = n i l ; if va11d then Beg i n SrceHshk ( t o s s _ d a t a , t r u e ) ; . . < pol1 inputs f o r control processes ) Pol 1 I n p u t s End End { o f i f d s p l l i s t <> n i l } End { o f w i t h tos® } End; { of FlagData >  rfrsh  link®  Procedure WriteScreen; V a r i , n: i n t e g e r ; Beg i n NewB1ock; w i t h t o s ® . i n f o do , f o r n:= 1 t o image b l k s do i f r u n n i n g then Begin { a t t e m p t t o r e a d t h e s c r e e n Image b u f f e r } <$I-} i f b l o c k r e a d ( s c r e e n f i l e , b l o c k ® , 1. p r m t s _ b l k + n ) N o t e E r r o r (126, i o r e s u l t . false); <$I + > Pol 1 I n p u t s ; ( c o p y t h e image t o t h e ' s c r e e n }  <>  4  Appendix E 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 54 1 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 56 1 562 563 564 565 566 567 568 569 570  12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12  Compiler 6• 5 6• 5 6 :5 6 5 6 4 6 4 6 1 6 1 6 1 1 0 1 0 1 0 1 d 1 d 1 d 7 d 7 d 8 0 8 1 8 1 8 1 7 0 7 0 7 0 7 1 7 1 7 2 7 2 7 2 7 3 7 3 7 3 7 3 7 3 7 4 7 5 7 5 7 4 7 4 7 3 7 2 7 2 7 1 1 0 1 0 1 0 1 d 9 0 9 1 9 1  54 63 78 92 92 99 99 107 107 0 0 0 1 1 1 1 1 0 0 10 12 0 0 0 0 2 7 7 7 7 13 28 28 28 38 38 61 82 82 82 86 92 92 0 0 0 1 0 0 8  Listing  of Unit if  ScrnBuff  n = image_blks  Page then i : = image b y t e s mod 512 else i : = 512; u n i t w r i t e ( 1 . block®. 1):  if running then Pol 1 Inputs End; {of if } { b u f f e r i s no l o n g e r n e e d e d > di spose (b1ock); { f l a g d i s p l a y data } FlagData (true) End; { of WriteScreen }  Procedure LoadScreen: { r e a d t h e prompts, w r i t e  t h e image >  P r o c e d u r e C h e c k E r r o r (bomb: b o o l e a n ; e r r num: i n t e g e r ) ; { n o t e e r r o r o n bomb, p o l l i n p u t s } Beg i n i f bomb t h e n N o t e E r r o r (err_num, ioresult, false); Pol 1 I n p u t s ; if ErrorNoted then exit (LoadScreen) End; { of CheckError ) Begin { *** L o a d S c r e e n **+ ) NewBlock; w i t h t o s ® . i n f o do Beg i n { r e a d the prompts i n t o b l o c k b u f f e r ) <$I-> C h e c k E r r o r ( b l o c k r e a d ( s c r e e n f i l e , block®, 1, p r m t s b l k ) <> 1, 122) ; <$I + > { move t o p r o m p t s b u f f e r } i f prmt_words > 0 then Begin C h e c k E r r o r ( v a r n e w ( p r o m p t s , prmt w o r d s ) <> prmt words m o v e l e f t ( b l o c k ® , p r o m p t s ® , prmt words + prmt w o r d s ) End; { c a l c u l a t e screen buffer size } image_words:= 1mage_blks*256 End: < o f w i t h tos® ) { c o p y t h e l o a d e d image t o t h e s c r e e n } Wr1teScreen End; { of LoadScreen )  Procedure ClearScreen; Beg i n i f T o s l n f o then FlagData scC1rScreen  (false);  5  Appendix 571 572 573 574 575 57G 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 61 1 6 12 613 614 615 616 617 618 619 620  E  12 12 . 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12  Compiler 1 :0 1 :0 1 :0 1 :d 10 :d 10 :d 10 :d 10 :d 10 :d 1 1:0 1 1: 1 1 1: 1 1 1: 1 10 :0 10 :0 10 :d 10 :d 12 :d 12 :d 12 :0 12 : 1 12 :: 1 12 :: 1 12 :: 1 12: 1 12 : 1 12 : 1 12 :2 12 :2 12 : 1 12 : 1 12 : 1 12 : 1 12 : 1 10: 0 10: 0 10: 0 10: 0 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 1 10: 2  0 0 0 1 1 2 3 3 1 0 0 10 12 0 0 1 1 1 2 0 0 2 2 20 20 20 23 23 26 34 47 47 53 53 0 0 0 0 0 2 2 7 7 9 9 19 19 27 34 36  Listing  of Unit  ScrnBuff  Page  6  End;  Procedure EnterScreen; Var new_tos: ®stack_link; new i n f o : b o o l e a n ; P r o c e d u r e C h e c k E r r o r (bomb: b o o l e a n ; err_num: i n t e g e r ) ; { n o t e e r r o r o n bomb, p o l l i n p u t s ) Beg i n i f bomb t h e n N o t e E r r o r ( e r r num, i o r e s u l t , false); Pol 1 Inputs; i f E r r o r N o t e d then exit (ScrnEnter) End; { of CheckError } Procedure Getlnfo; { l o o k f o r i n f o c o r r e s p o n d i n g t o name i n d i r e c t o r y } Var c u r r d i r e c : integer; found: boolean; Beg i n NewB1ock; ($1-) C h e c k E r r o r ( b l o c k r e a d ( s c r e e n f i l e , b l o c k ® , 1, 0 ) <> ($1 + ) < a t t e m p t t o p o i n t t o t h e r e q u e s t e d s c r e e n image ) c u r r _ d i r e c : = - 1; Repeat c u r r _ d i r e c : = c u r r d i r e c + 1: f o u n d : = b 1 o c k ® [ c u r r _ d i r e c ] . n a m e = i o name U n t i l f o u n d o r ( c u r r d i r e c >= 3 1 ) ; ( e n s u r e d i r e c t o r y e n t r y was f o u n d } C h e c k E r r o r ( n o t found, 121); { c o p y d i r e c t o r y e n t r y t o new t o s ® . i n f o } tos®.info:= block®[curr d i r e c ] . i n f o End; { of G e t l n f o > Begin { *** E n t e r S c r e e n *** > ( g e t r i d o f any o l d prompts > DspzPrmts; ( c o n v e r t name t o u p p e r c a s e > U p p e r c a s e ( i o name): ( c l e a r c u r r e n t Image, r e s e t v a l i d ClearScreen; { p u s h c u r r e n t l y a c t i v e image > n e w _ i n f o : = i o name <> 'NIL'; i f new i n f o then new (new t o s , t r u e ) else new (new t o s . f a l s e ) ; w i t h new tos® do Beg i n  }  U)  Appendix 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 64 1 642 643 644 645 646 647 648 649 650 65 1 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670  12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12  E  Compiler 10 : 3 10 : 3 10 : 3 10 : 3 10 : 4 10 :4 10 : 5 10 :5 10 : 5 10 : 5 10 : 5 10 : 5 10 :4 10 : 2 1 :0 1 :0 1 :0 1 :d 13 :d 13::d 13::d 14 ::0 14 :: 1 13 ::0 13 :0 13 ::0 13 :0 13 : 1 13: 1 13: 1 13: 1 13: 2 13: 2 13 :4 13 :4 13 :4 13: 5 13: 5 13: 4 13 :4 13 :4 13: 3 1 :0 1 :0 1 :0 1 :d 15 :0 15 : 1 15 : 1 1 :0  36 40 43 48 51 51 51 53 53 55 61 61 61 63 0 0 0 1 1 4 4 0 O 0 0 0 0 0 3 3 8 20 24 28 30 30 40 58 58 66 73 81 0 0 0 1 0 0 2 0  Listing  of  Unit  Page  ScrnBuff  7  former: = t o s : tos:= new_tos; 1nfo_to_wr1te:= new_info; i f new i n f o t h e n Begin { r e a d t h e new t o s s c r e e n ' s i n f o } Getlnfo: { p o i n t t o a c t i v e r f r s h 11st e n t r y } Search; r f r s h link:= search ptr; { r e a d p r o m p t s , w r i t e image } LoadScreen End { of i f new_info } End; { o f w i t h new tos® > End; { of E n t e r S c r e e n >  Procedure PromptScreen; Var i . o f f s e t , dumbptr: Procedure Error; Beg i n N o t e E r r o r (124, End;  integer;  j , false)  Begin { *** P r o m p t S c r e e n *** } { l o a d t h e p o i n t e r t o t h e r e q u e s t e d prompt l i n e } prmtptr:= n11; i f not T o s l n f o then Error else i f j >= tos®.info.num_prmts then Error e l s e Begin o f f s e t : = 0; { c a l c u l a t e o f f s e t : = p o s i t i o n of r e q u e s t e d s t r i n g i n f o r i:= 1 t o j do o f f s e t : = o f f s e t + p r o m p t s ® [ o f f s e t ] + 1; { add o f f s e t t o prompts, p l a c e r e s u l t i n p r m t p t r } m o v e l e f t ( p r o m p t s , dumbptr, 2 ) ; dumbptr:= u s i A d d ( d u m b p t r , o f f s e t ) ; m o v e l e f t ( d u m b p t r , p r m t p t r , 2) End End; { of P r o m p t S c r e e n }  Procedure RefreshScreen; Begin ClearScreen; i f T o s l n f o then WriteScreen End: { of S c r n R e f r e s h }  prompts  )  to co  Appendix G7 1 G72 G73 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 69 1 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 70"9 7 10 7 1 1 7 12 713 714 7 15 7 16 717 718 7 19 720  12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 2 2 2 2 2 2 2 16 16  Compiler  E 1 1 1 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2  0 0 d d 0 0 1 1 1 1 1 1 1 3 3 4 5 5 5 5 4 3 2 0 0 0 0 1 1 1 2 2 2 2 2 2 2 0 0 0 0 d d d d d d d d d  0 0 1 1 0 0 0 2 2 4 6 13 17 17 20 22 22 26 26 35 42 42 47 0 0 0 0 0 1 6 13 17 2 1 25 29 33 33 O 0 0 0 1 1 1 1 1 1 1 1 1  Listing  of U n i t  Page  ScrnBuff  Procedure ReturnScreen: Var o l d t o s : ® s t a c k _ l i n k ; Begin { g e t r i d o f any o l d p r o m p t s } DspzPrmts: < c l e a r c u r r e n t image, r e s e t v a l i d > C1earScreen; i f tos = n 1 1 then N o t e E r r o r (128, 0. f a l s e ) e l s e Begin { pop s c r e e n , d i s p o s e o f o l d t o p o f o l d tos: = tos; w i t h o l d tos® do Beg i n tos:= former; i f i n f o to w r i t e then dispose ( o l d t o s , true) else dispose (old_tos, false) End; i f T o s l n f o then LoadScreen End { o f e l s e o l d t o s <> n i l } End: { of R e t u r n S c r e e n )  stack }  Begin { *** S c r n I O *** > i f j <= 255 then PromptScreen else Case j of 256 DspzPrmts; 257 Search; EnterScreen; 258 C1earScreen; 259 RefreshScreen; 260 ReturnScreen 261 End End; < o f Segment S c r n I O }  Process  Update;  Segment  Procedure  forward;  Scrnlnit  Procedure I n i t ; Var p i d : p r o c e s s i d ;  (initialize:  boolean)  8  Appendix E 72 1 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16  Compiler 2 :d 2 :0 2: 1 2: 1 2: 1 2: 1 2: 1 2: 1 2: 1 1 :0 1 :0 1 :0 1 :d 1: d 3 :d 3 :0 3 :0 3: 1 3: 1 3: 1 3: 2 3: 2 3: 3 3:: 3 3 :: 4 3 :: 5 3::5 3 :: 5 3 :5 : 3 :: 4 3 :: 2 3 :: 2 3 :: 1 3:: 1 3: 1 3: 1 3: 1 3: 3 3: 3 3 :4 3 :2 3 :1 3 :1 3 :1 3 :2 3 :3 3 :3 3 :3 3 :3 3 :3  2 0 0 12 16 32 49 49 61 0 0 0 1 1 1 0 0 0 5 1 1 16 16 16 22 25 25 29 33 41 44 46 46 46 50 58 66 74 74 88 98 102 106 1 12 1 17 127 127 131 137 145 147  Listing  of Unit  ScrnBuff  Page  stack, prio: integer: Begin block: n i l ; prompts: n i l ; tos:= n i l ; r f r s h _ 1 1 s t : = n i l ; Hshklnit (toss_data): Strtlnfo ('ScrnBuff, 'Update', s t a c k , p r i o , true): s t a r t (Update, p i d , s t a c k , p r i o ) ; { open s c r e e n _ f i l e ) ($1-) reset (screen_fi1e, filename); ($I+> i f l o r e s u l t <> 0 t h e n N o t e E r r o r (127, i o r e s u l t . t r u e ) End; { of Init > 3  3  Procedure Link; { C r e a t e g i v e n k i n d o f d a t a , l i n k i n t o g i v e n image's d i s p l a y l i s t Var s i z e : i n t e g e r ; Beg i n ( l o o k f o r a l r e a d y c r e a t e d ( ? ) image r e f r e s h ) U p p e r c a s e (1o_name); ScrnIO (257); { s e a r c h f o r name i n r e f r e s h l i s t > i f s e a r c h _ p t r - n i l then Beg i n { s t a r t a new image r e f r e s h l i s t > new ( s e a r c h _ p t r ) ; w i t h . s e a r c h p t r ® do Beg i n next r f r s h : - r f r s h list; r f r s h _ l i s t : = search_ptr; name:= i o name; dsp1 11st:= n i l End { of w i t h search_ptr® } End; ( o f i f s e a r c h p t r <> n i l ) { c r e a t e new l i n k d a t a p t r . i n i t i a l i z e , l i n k Into p o i n t e d t o l i s t } C a s e 1i n k k o f sb b o o l : new ( 1 i n k _ d a t a _ p t r , s b _ b o o l ) ; sb i n t : new ( 1 i n k _ d a t a _ p t r , s b _ 1 n t ) : sb_re: new ( 1 1 n k _ d a t a _ p t r , sb_re); sb s t n g : Begin s i z e : = d s p l _ e m p t y _ s 1 z e + ( 1 1 n k _ f m t . f 1 e 1 d + 2 ) d l v 2; i f varnew ( 1 1 n k _ d a t a _ p t r , s i z e ) <> s i z e t h e n N o t e E r r o r (129, s i z e , f a l s e ) End; sb now: new ( I 1 n k _ d a t a p t r , sb_now) End: < o f C a s e 11nk_k } w i t h s e a r c h p t r ® , l i n k d a t a p t r ® . f o r m a t do Beg 1 n next_dspl:= dspl_list; dspl l i s t : - link data p t r ; f o r m a t : = 1i nk fmt; 1f n e x t _ d s p l = n i l then, s c r n v a l i d : false 3  9  Appendix E 77 1 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 81 1 812 813 8 14 8 15 8 16 817 8 18 8 19 820  Compiler  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 2 •2 .i '& 1  -.2  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 5  *  15 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1  3 3 3 3 2 0 0 0 0 1 1 1 0 0 0 0 d 0 1 1 1 0 0 0 d 0 0 d 0 0 d 0 0 d 0 0 d 0 0 0 d 0 1 1 1 1 1 0 0 0  153 168 173 178 181 0 0 0 0 0 0 3 0 0 0 0 1 0 0 2 5 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 10 16 22 25 29 0 0 0  Listing  of Unit  Page  ScrnBuff  else s c r n v a l i d : = next_dsp1 ©.format.scrn_va1id; enabled:= false; new d a t a : = f a l s e ; k i nd:= 11nk_k End { of w i t h l i n k data ptr© > End; { of Link }  Begin { +** S c r n l n i t *** } if initialize then Init else Link End; { o f Segment S c r n l n i t >  Function Toslnfo; Beg i n i f tos = n i 1 then TosInfo:= else TosInfo:= End;  false tos©.info_to_write  Procedure ScrnEnter; Begin i o name:= name;  ScrnIO  F u n c t i o n ScrnPrompt; Begin S c r n I O (prompt_num); Procedure ScrnClear; Begin S c r n I O ( 2 5 9 ) End; Procedure ScrnRefresh; Begin S c r n I O ( 2 6 0 ) End; Procedure ScrnReturn; Begin S c r n I O ( 2 6 1 ) End;  Function sbLink; Beg i n i o name:= i mage; 1 i n k fmt:= f m t ; 1 i nk_k:= k; S c r n I n i t ( f a 1se); sbLink:= 1ink_data_ptr End; { of sbLink )  (258) End:  ScrnPrompt:=  prmt_ptr  End  10  Appendix 82 1 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 84 1 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 86 1 862 863 864 865 866 867 868 869 870  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  E  Compiler 1 :d 14 :0 14 : 1 1 :0 1 :0 1 :0 1 :0 1 :0 1 :d 17 :0 17 : 1 17 : 2 17 : 3 17 :3 17 : 3 17 :5 17 :5 17 : 4 17 : 3 17 : 2 1 :0 1 :0 1 :0 1 :d 3 :0 3: 1 3: 2 3: 3 3:4 3 :4 3 : 3 1 :0 : 1 :0 : 1 : 0 1 :d 4 :0 4 :1 4 :2 4 :3 4 :4 4 :4 4 :3 1 :0 1 :0 1 :0 1 :d 5 :0 5: 1 5: 2 5: 3  1 0 0 0 0 0 0 0 1 0 0 6 6 1 1 19 27 32 35 37 42 0 0 0 1 0 0 2 16 16 2 1 22 0 0 0 1 0 0 2 16 16 2 1 22 0 0 0 1 O 0 2 20  Listing  of U n i t  ScrnBuff  Procedure sbHalt; Beg i n SrceHshk ( t o s s data, End; { of H a l t )  Page  true)  P r o c e d u r e N o t e D a t a ( d a t a _ p t r : sb d s p l p t r ) ; Begin w i t h d a t a _ p t r @ , f o r m a t do Beg i n enabled:= true; . i f r u n n i n g and s c r n _ v a l i d and n o t new d a t a then Begin new_data:= t r u e : SrceHshk ( t o s s data, t r u e ) End else new d a t a : = t r u e End { of with ) End; { of NoteData }  Procedure sbTossBoolean; Beg i n w i t h d a t a _ p t r © do i f not f o r m a t . e n a b l e d o r Beg i n b : = va1ue; NoteData (data p t r ) End End: { of sbTossBoo1ean }  Procedure sbTossInteger; Beg i n w i t h d a t a p t r © do i f not format e n a b l e d or Begin i : = va1ue; NoteData (data p t r ) End End; { of SbTossInteger )  Procedure sbTossReal; Beg i n w i t h d a t a _ p t r © do i f not f o r m a t . e n a b l e d Beg i n  or  (b <>  value)  then  ( i <>  value)  then  value)  then  '  ( r <>  1 1  Appendix  E  87 1 2 2 872 873 2 874 2 875 2 876 2 877 2 878 2 879 2 2. 880 881 2 882 2 883 2 884 2 885 2 886 2 887 2 888 2 889 2 890 2 891 2 892 2 893 2 894 2 895 2 896 2 897 2 898 2 899 2 900 2 2 901 902 2, 903 ' 2 904 2 905 2 906 2 907 2 908 2 2 909 910 2 91 1 2 912 2 913 2 914 2 915 2 916 2 917 . 2 918 2 919 2 2 920  Compiler 5:4 5 :4 5: 3 1 :0 1 :0 1 :0 1 :d 6 :0 6: 1 6: 1 6: 2 6: 2 6: 2 6 :4 6 :5 6 :5 6:4 1 :0 1 :0 1 :0 1 :d 7 :0 7: 1 1 :0 1 :0 1 :0 1 :d 8 :0 8: 1 1 :0 1 :0 1 :0 1 :d 16 : d 16 :d 16 :d 18 :d 18 :d 18 :0 18 : 1 18 : 1 18 : 1 16 : :0 16 : :0 16 : :0 16 : 1 16 : ; 1 16 : 2 16 : :3 16 :3  20 26 27 0 0 0 1 0 0 6 6 9 24 44 44 51 52 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 2 2 1 3 0 0 3 7 0 0 0 2 7 13 13 16  Listing  of U n i t  Page  ScrnBuff  r : = va1ue; NoteData (data p t r ) End End; < of sbTossReal }  Procedure sbTossString; Beg i n w i t h d a t a _ p t r ® , f o r m a t do ( ensure v a l u e doesn't overflow s b u f f e r } if length (value) > f i e l d then N o t e E r r o r (123, l e n g t h ( v a l u e ) , f a l s e ) else 1f n o t e n a b l e d o r ( s <> v a l u e ) t h e n Begin s : = va1ue; NoteData (data p t r ) End { of i f } End; < of s b T o s s S t r i n g }  P r o c e d u r e sbTossNow: Beg i n NoteData ( d a t a _ p t r ) End; { o f sbTossNow }  Procedure sbDisable; Begin data_ptr®.format.enab1ed:= End; { of s b D i s a b l e )  false  P r o c e s s Update; Var d a t a _ p t r : s b _ d s p l _ p t r ; P r o c e d u r e DsplNow; V a r now: tim_rec; hms: t i m hms; Begi n TimSubTO (now): T i m _ i n hms (hms, now); w i t h data_ptr@>, f o r m a t do End; ( o f DsplNow > Begin { *** U p d a t e + * + } AcptHshk ( t o s s _ d a t a , f a l s e ) ; w h i l e r u n n i n g do Beg i n CursBorrow; i f r u n n i n g and T o s l n f o then  T o s s S t r i n g ( x , y.  12  Appendix E 92 1 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 94 3 944 945 946 947 948 949 950 951 952 953 954 End  of  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 16 :4 16 : 5 16 :6 16 : 7 16 : 7 16 :8 16 :9 16 :0 16 : 1 16 : 2 16 : 2 16 : 2 16 : 2 16 : 2 16 : 4 16 : 4 16 : 4 16 : 3 16 : 2 16 : 2 16 : 2 16 : 1 16 :0 16 : 9 16::6 16:: 3 16 : 3 16 : 2 1 :0 : 1 :0 : 1 :0 1 :O 1 :: 1 :0  26 29 36 36 40 46 52 52 69 69 74 78 92 112 1 12 112 138 166 170 192 192 199 199 199 202 205 208 216 0 0 0 0 10 0  Compilation.  Listing  of Unit  ScrnBuff  Page  w i t h tos© do i f r f r s h _ l i n k <> n i l t h e n Beg i n d a t a p t r : - r f r s h link©.dspl list; w h i l e d a t a _ p t r <> n i l do w i t h d a t a _ p t r ® , f o r m a t do Begin i f new d a t a and e n a b l e d a n d s c r n _ v a l i d t h e n Beg i n new_data:= f a l s e : Case k i n d of sb b o o l : TossBoolean ( x , y, b ) ; sb i n t : T o s s l n t e g e r ( x , y, i , f i e l d ) ; sb r e : Begin if f l o a t then T o s s F l o a t ( x , y, r , f i e l d ) else T o s s R e a l ( x , y, r , f i e l d , d e c End; sb_stng: T o s s S t r i n g ( x , y, s, f i e l d ) ; sb_now: DsplNow End < of Case } End; { of i f ) data_ptr:= next_dspl End { o f w i t h data_ptr© ) End; < of i f running e t c . ) CursReturn; i f r u n n i n g then AcptHshk ( t o s s _ d a t a , f a l s e ) End { of while running > End; { of Update >  Begin Scrnlnit End.  (true)  13  Appendix 3 4 5 6 7 8 9 10 1 1 12 13 14 15 16 17 18 19 20 2 1 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4 1 42 43 44 45 46 47 48 49 50 51  F 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0 1 1 1 1 1 1 1 1 .1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of Unit  Page  Clock  <$L remout:> Unit Clock; Interface Type  Var  < clock  reading u t i l i t i e s >  tim rec = record hiword, loword; i n t e g e r { two's complement 32 b i t i n t e g e r > t i m hms = s t r i n g [ 8 ] : tim ovflw: boolean; < TimAdd & T i m M i n u s o v e r f l o w  Procedure  TimReset;  { reset  flag >  system  clock  P r o c e d u r e TimAdd ( v a r sum: t i m _ r e c : { sum:= a + b >  a. b:  P r o c e d u r e TimMinus ( v a r d i f f : { diff : = a - b } F u n c t i o n Tim a L T b ( a . b : { resu1t:= a < b >  tim_rec;  tim_rec):  end;  to 0 } t i m_rec) ;  a.b:  t i m_rec);  boolean;  Function TimArrived ( t : tim r e c ) : boolean; ( r e s u l t : = t <= c l o c k r e a d i n g } F u n c t i o n TimlnSeconds ( t : t i m _ r e c ) : { r e s u l t : = t i n seconds )  real;  Procedure TimOfSeconds ( v a r t : t i m _ r e c ; { t:= r , where r i s i n s e c o n d s )  r:  rea1 ) ;  t: t i m r e c ) ; P r o c e d u r e TimlnHMS ( v a r hms: tim_hms; < c o n v e r t t t o hh:mm:ss, 0 0 : 0 0 : 0 0 <= hms <= 99:59:59 P r o c e d u r e TimSetTO: { read clock, l e t r e s u l t  be known a st o  P r o c e d u r e TimSubTO ( v a r t : t i m _ r e c ) ; ( r e t u r n w i t h c l o c k r e a d i n g - tO > Imp 1ementat i o n  Function ErrorNoted: boolean; { T r u e i f f N o t e E r r o r has been  called. }  }  1  Appendix 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80 8 1 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101  F 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4  Compiler 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 2 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 3 19 19 19 1 1 1 1  Listing  of U n i t  Clock  Page  2  immediate: b o o l e a n ) ; P r o c e d u r e N o t e E r r o r (n, i n f o : i n t e g e r ; n f o a s p a r t o f t h e mess a g e ) { W r 1 t e n ' t h e r r o r message ( i n c l u d i n g f r o m e r r o r l o g upon p r o g r a m h a l t ( o r i m m e d i a t e l y & h a l t ) . } Uses  ErrMessg;  Const  Var  lolim =3; hi 1 im = 6;  tO: t i m _ r e c ; s i gn i f : a r r a y  { array  [1  positions  .8] o f  tim rec;  of  low 8 h i g h  signif  < significance  limits  / digit  of  >  hms  }  e x t e r n a 1; Procedure TimReset; P r o c e d u r e TimAdd; external; external; P r o c e d u r e TimMinus; F u n c t i o n Tim a L T b ; external; externa 1 ; Function TimArrived;  1  1 1 1  1 1 1 1 1 1 1 1 0 0 10 0 0 0 0 8 15 22 29 36 42 42 47 56 56 58  Segment P r o c e d u r e C l o k l n i t ; { hiword, loword of Const hourlOhi = 32 houMOlo = -2688 ( s i g n i f i c a n c e of hourlo = 19392 hourhi = 3 < e a c h d i g i t i n hms minlOlo = -29536 minlOhi = 0 minlo = 3600 m i nh i = 0 s e c 101o = 600 seelOh 1 = 0 seclo = 60 sechi = 0 lolimlo = O 1o1i mh i = 0 hilimlo = -26940 h i 1imhi = 329 P r o c e d u r e L o a d ( i , h i , 1o: i n t e g e r ) ; Beg i n w i t h s i gn i f [ i ] do loword:= l o End Beg i n h i word: = h i ; End; { of Load > Begin ( *** C l o k l n i t *** } < l o a d t i m hms d i g i t s i g n i f i c a n c e a r r a y } L o a d ( 1 . h o u r 1 0 h i , h o u r 101o); Load (2, h o u r h i , h o u r l o ) ; Load (4, m i n l O h i , m i n l O l o ) ; Load (5, m i n h i , m l n l o ) ; Load (7, s e c i O h i , s e d O l o ) ; Load (8, s e c h i , s e c l o ) ; < u s e s i g n 1 f [ 1 o 1 i m ] and [ h i l i m ] f o r r a n g e e n t r i e s > Load ( l o l i m , l o l i m h i , lolimlo); Load ( h i l i m . h i l i m h i , h i l i m l o ) ; { r e s e t system c l o c k & to > T1mReset; { c a n ' t T i m S e t T O s i n c e r e s e t t a k e s up t o 1/60 s e c t o t a k e e f f e c t  } >  }  >  ^1  Appendix  F  Compiler  4 1 1 102 4 1 0 103 104 1 0 4 4 105 1 0 1 d 106 2 107 2 1 d 7 0 108 2 7 1 2 109 2 7 2 1 10 7 3 11 1 2 1 12 2 7 3 1 13 7 2 2 1 0 1 14 2 1 15 1 0 2 1 0 1 16 2 1 d 1 17 2 1 18 1 d 2 1 19 8 0 2 8 1 2 120 12 1 2 8 1 122 2 8 2 123 2 8 3 1 24 2 8 3 2 8 2 125 1 0 126 2 127 2 1 0 128 2 1 0 1 d 2 129 130 {commented 1 d 131 2 9 d 132 2 133 9 d 2 134 2 9 0 135 2 9 0 136 9 1 2 137 2 9 1 138 9 1 2 139 2 9 1 2 9 3 140 14 1 9 3 2 142 2 9 3 143 2 9 4 144 2 9 5 145 2 9 5 146 2 9 6 147 2 9 6 148 2 9 6 149 2 9 7 9 8 150 2 151 9 8 2  58 0 0 0 1 1 0 5 5 5 13 23 0 0 0 1 1 0 0 8 10 10 21 32 0 0 0 1 : '} 1 1 3 0 0 5 29 37 4 1 4 1 48 48 57 64 64 64 66 79 86 86 89  Listing  of Unit  Page  Clock  f i l l c h a r (to, sizeof (to) , 0) End; { o f Segment C l o k l n i t >  Function TimlnSeconds; { result: t i n seconds } Begin w i t h t do Begin i f loword < 0 then hiword: h i w o r d + 1; Timlnseconds:= (65536.0 * hiword + loword) End End; 3  3  / 60.O  Procedure TimOfSeconds; { t:= r . where r i s i n s e c o n d s } Begin r : - r * 60.0: w i t h t do Beg i n hiword: round ( r / 65536.0); loword: round ( r - 65536.0*hiword) End End; 3  3  P r o c e d u r e TimlnHMS: { c o n v e r t t t o hh:mm:ss, 00:00:00 <= hms < 99:59:59: l o n g i n t e g e r s f o r s p e e d & memory s a v i n g s > Var i , d i g i t : integer; sum: t i m_rec; Beg i n { check f o r range e r r o r } 3  then NoteError (1, t.hiword, f a l s e ) i f Tim_aLTb ( t , s i g n i f [ 1 o l i m ] ) o r Tim_aLTb e l s e Begin { i n i t i a l i z e hms > hms: ' ' ; { c a l c u l a t e a l l hms d i g i t s ) for d i g i t : 1 t o 8 do i f not ( d i g i t i n [ l o l i m , h i l i m ] ) then Beg i n { c a l c u l a t e i : the d i g i t ' t h d i g i t } 3  3  3  1  : while sum: Begin  3  3  0: T i m _ a L T b (sum, t ) do sign1f[digit];  1  i : TimAdd 3  + 1 ; (sum, sum, s 1 g n i f [ d i g i t ] )  avoid  (s1gnif[hi1im],  3  Appendix 152 153 154 155 156 157 158 -159 160 161 162 163 164 165 166 167 168 169 170 17 1 172 173 174 175 176 1 77 178 179 End  of  Compiler  F 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  9 9 9 9 9 9 9 1 1 1 1 1 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  7 7 6 6 6 5 2 O 0 0 d d 0 1 0 0 0 d d 0 1 1 0 O 0 0 1 0  100 104 104 1 17 122 129 130 0 0 0 1 1 0 0 0 0 0 1 1 0 0 8 0 0 0 0 0 0  Listing  of  Unit  Page  Clock  4  End: { of whi1e > s u b t r a c t i * s i g n i f from t } T i m M i n u s (sum, sum, s i g n i f [ d i g i t ] ) ; T i m M i n u s ( t , t . sum); hms[digit]:= chr ( i + ord('O')) End < of f o r , i f } { o f no r a n g e e r r o r } < o f TimlnHMS } (  End End;  P r o c e d u r e TimSetTO; { r e a d c l o c k , l e t r e s u l t be known as Beg i n w i t h tO do time (hiword, loword) End;  to  }  P r o c e d u r e TimSubTO; { r e t u r n w i t h c l o c k r e a d i n g - tO } Beg i n w i t h t do time (hiword. loword); T i m M i n u s ( t . t . tO) End;  Begin CI o k I n i t End.  Compilation.  NJ ID  Appendix F  Assembler  Listing  of Unit  Clock  External  Routines  Page  ; T h i s f i l e c o n t a i n s no .PROC. .FUNIC, o r i n t e r n a l d a t a a r e a s . It i s therefore ; d y n a m i c a l l y r e l o c a t a b l e , a n d may move a b o u t i n ram o r b e swapped o u t t o d i 0000 0040 0091  sb i os .EOU j m p t a b l .EOU c l k r e a d .EOU  oooo 0003 0003 0003 0000 OOOO OOOO OOOO OOOO OOOO 0001 0002 0003 0005 0006 0007 0009 0009 0009 OOOA OOOB OOOE OOOE OOOF 0010 0012 0014  clkinit  C3 9 4 0 0  ;time  .EOU  jmptabl+0054H  JP  clkinit  1A 8E DD 77 0 0 23 13 DD 23 10F5 C3 OOOO  :sbios  .RELPROC TimAdd.3 type a d d i t i o n : sum ( p a r a m 1 ® ) : = .REF  C1 E 1 D1 DD E 1 C5 AF 06 04  l o c a t i o n o f s b i o s i n ram s b i o s jump t a b l e sbios clock read routine  .RELPROC T i m R e s e t system c l o c k :  ;reset 0094  0000H sbios+0040H jmptabl+0051H  pop Pop pop pop push xor Id  clock  initialization  routine  a ( p a r a m 2 ® ) + b (param3@)  ckover BC HL DE IX BC A B,4  :return address :pointer to b ;pointer to a ; p o i n t e r t o sum ;replace return address : reset carry :4 b y t e s i n t i m e _ t y p e  addbyte: :add c u r r e n t b y t e o f b t o c u r r e n t b y t e o f a , s a v e i n c : Id A,(DE) :current byte of a adc A.(HL ) :add w i t h c a r r y t o c u r r e n t b y t e Id (IX+O),A ; save r e s u l t i n c u r r e n t byte o f : p o i n t t o n e x t b y t e o f a . b. a n d sum: i nc HL :point t o next byte o f b i nc . ,. „ „ „ „ a DE . > . i. i. .. it i nc IX d j nz addbyte ckover ;check f o r a n d f l a g o v e r f l o w JP r  .RELPROC T i m M i n u s . 3 time_type subtraction: diff  (param!©):  a  e  s  (param2®) - b  u  (param3©):  Appendix  oooo oooo oooo oooo oooo 0001 0002 0003 0005 0006 00O7 0009 0009 0009 OOOA OOOB OOOE OOOE OOOF 0010 0012 0014 0015 0016 0019 001 A 0010 001E 001E 00 1E OOOO OOOO OOOO OOOO OOOO OOOO OOOO OOOO  oooo  0001 0002 0003 0004 0005 0009 OOOC OOOF 0010 001 1 0013  F  Assembler  C1 E1 D 1 DD E 1 C5 AF 06 04  1A 9E DD 77 0 0 23 13 DD 23 10F5 60 68 E2 * * * + 2C 22 OOOO C9  Listing  of Unit  m i nus:  Clock  .DEF  ckover,  .PU8LIC  t i movf1w  pop pop pop pop push xor ld  BC HL DE IX BC A B.4  3  .PRIVATE  01  pop pop pop pop push d e L T h l : Id cal 1 ld r 1 ca xor and 1d  Page  minus  •  time  manipulation over/underflow  boolean  return address pointer to b pointer to a pointer to d i f f replace return address reset borrow 4 bytes i n time_type c u r r e n t b y t e o f a, save i n c: current byte of a s u b t r a c t with borrow c u r r e n t b y t e o f b save r e s u l t i n c u r r e n t b y t e of d i f f diff: p o i n t t o next b y t e o f b " a " " " " " result HL : - 0 if  no o v e r f l o w , r e s e t t i m o v f l w else s e t timovflw f l a g overflow i fcarry s e t  .RELFUNC T i m a L T b , 2 (boolean): a (paraml®) < b .DEF . REF  2 1 OOOO OOOO 0300  Routines  subbyte ; s u b t r a c t c u r r e n t b y t e o f b from A. (DE) ld A,(HL) sbc (IX+O).A ld ;po i n t t o n e x t b y t e o f a . b, a n d i nc HL i nc DE IX i nc subbyte d j nz H.B ckover : ld L.B Id PO. $ 1 JP L 1 nc ( t imovfIw),HL ld $1 ret  :resu1t  C 1 E1 D1 F 1 C5 DD CD 3A 07 AD E6 6F  External  (param2®):  deLThl m i nus diff:2 BC HL DE AF BC IX.diff m i nus A.(diff+3) L 1 L . A  dummy d i f f e r e n c e  buffer  return address pointer to b pointer to a j u n k u n n e c e s s a r y p - c o d e word save r e t u r n a d d r e s s on s t a c k p o i n t e r t o dummy d i f f HL: = t i m o v f l w : a - b o v e r f l o w e d check s i g n o f d i f f load s i g n b i t into b i t 0 a < b i f f d i f f < 0 or overflow, not both keep o n l y b i t 0 HL : = b o o l e a n r e s u l t 3  2  Append i x F 0014 0015 0016 0016 0016 0000 OOOO OOOO OOOO OOOO OOOO OOOO OOOO 0003 0007 OOOA OOOC OOOD OOOE 001 1 0014 0015 0017 0018 001A 001B 001D 001 E 001E 001E 001E  A s s e m b l e r L i s t 1 n g o f Uni t C l o c k ex  E3 E9  JP  External  Routines  (SP).HL (HL)  Page  put r e s u l t return  on s t a c k ,  return  address  i n HL  *  ;resu1t  .RELFUNC T i m A r r i v e d , 1 (boolean): not ( clock 3  . REF .PRIVATE CD ED 22 FD E 1 F 1 1 1 CD C1 CB 3F CB C5 FD C9  9100 53 OOOO 0200 E 1  OOOO OOOO 19 1 1 E5  Assemb1y comp1ete: errors flagged 0  cal 1 Id ld pop pop pop ld cal 1 pop rr ccf rl push push ret  . END on130 t h 1ines i s assembly  reading  < t (paraml©)  ) :  deLThl now:2  (now),DE c1kread  (now+2),HL IY HL AF DE,now deLThl BC C C BC IY  clock  reading  buffer  DE:= l s w o r d , HL:= msword o f c l o c k save 1 sword " msword return address pointer tot j u n k u n n e c e s s a r y p - c o d e word pointer to clock reading g e t (SP) := now < t get boolean r e s u l t in c a r r y complement i t put back i n b i t 0 s a v e b o o l e a n ( S P ) : = n o t (now < t ) return address  reading  Appendix F 3 4 5 6 7 8 9 10 1 1 12 13 14 15 1G 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 1 10 1 1 1 1 12 1 13 1 14 1 15 1 16 1 17  0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4  Compiler 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 0 1 O 0 1 1 1 1 1 1 3 3 3 3 5 5 5 5 5  1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  ErrMessg  Page  1  {$L remout:> Unit ErrMessg; Interface Function < True  ErrorNoted: boolean; i f f N o t e E r r o r has been  called.  >  Procedure NoteError (n, i n f o : integer; immediate: b o o l e a n ) ; { W r i t e n ' t h e r r o r message ( i n c l u d i n g i n f o a s p a r t o f t h e message) f r o m e r r o r l o g upon p r o g r a m h a l t ( o r i m m e d i a t e l y & h a l t ) . ) Implementat i o n ($L-> Var  1 1 1 1 1 1 1 1 341 342 384 388 0 0 0 0 8 12 14 65 75 78 83 93 96 99 104 109 1 15 122 1 30  of Unit  Uses ScreenOps;  ($L®>  e r r detected: boolean; e r r num, e r r i n f o : i n t e g e r ;  Segment P r o c e d u r e W r i t e E r r ; C o n s t l o g name = ' u t i 1 : s y s t e m . e r r s ' ; Var e r r o r _ l o g : f i l e o f r e c o r d n: i n t e g e r ; s: s t r i n g [ 7 7 ] end; p: i n t e g e r ; message: s t r i n g [ 8 3 ] ; err flag: string[6]; P r o c e d u r e Unknown; Beg i n w r i t e ('Unknown e r r o r ( i n f o = ', e r_ r 1nfo, ' ) ' , c h r ( 7 ) ) End: Begin { WriteErr > scErasEOS (0, 20); scDown; w r i t e l n ( c h r ( 7 ) , '===>>> UBC P h y s i c s E r r o r H', e r r num, ': i f ( e r r num < 1) o r ( e r r num > 9 9 9 ) then Unknown e l s e Begin ($I-> reset (error_log, log_name); {$! + > 1f i o r e s u l t <> 0 then Unknown e l s e Begin w h i l e ( e r r o r _ l o g ® . n < e r r num) and n o t e o f ( e r r o r l o g ) and ( i o r e s u l t = 0 ) do ($1-) g e t ( e r r o r l o g ) ; {$! + } w i t h e r r o r log® do  <<<=  Co  Appendix  F  Compiler  118 119 120 121 122 123 124 125 126 127  4 4 4 4 4 4 4 4 4 4  1:6 1:6 1:6 1:8 1:8 1:8 1:9 1:0 1:0 1:0  134 138 141 145 156 172 179 179 192 201  128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144  4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2  1:9 1:8 1:7 1:4 1:3 1:2 1:0 1:0 1:0 1:d 2:0 2:1 1:0 1:0 1:0 1:d 3:0  215 215 236 236 236 240 0 0 0 1 0 0 0 0 0 1 0  145 146 147 148 149 150 151 152 153 154 155 156 157 158 159  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  3:0 3:1 3:2 3:3 3:3 3:3 3:2 3:1 3:2 3:3 3:3 3:2 1:0 1:0 1:0  0 0 6 6 9 12 12 15 18 18 20 25 0 0 0  160 161 162 163 164  2 2 2 2 2  1:0 1:1 1:1 1:1 :0  0 0 3 6 0  End  of  Listing  of U n i t ErrMessg  Page  i f n <> e r r _ n u m then Unknown else Begin message: s; p:= pos ('##', m e s s a g e ) + 1; i f p > 1 then Begin str (err_info, err_flag); d e l e t e ( m e s s a g e , p, 1); i n s e r t ( e r r _ f l a g , message, p) End: I of i f p > 1 ) w r i t e (message, c h r ( 7 ) ) End < of e l s e n = err_num > End; { of e l s e i o r e s u l t = 0 > {$1-} c l o s e ( e r r o r _ l o g , normal) ($1+) End { o f e r r _ n u m i n r a n g e 1..999 > End; < of W r i t e E r r > 3  Function ErrorNoted; Begin ErrorNoted: err_detected End; 3  Procedure Begin  NoteError;  ( e n s u r e second e r r o r d o e s n ' t wipe out f i r s t i f immediate or not e r r _ d e t e c t e d then Begin err_detected:= true; e r r _ n u m : - n; err_info:= info End; i f immediate then Begin WriteErr; e x i t (program) End End:  unless  immediate  }  Begin { ErrMessg i n i t i a l i z a t i o n > err_detected:= false; *** : i f e r r _ d e t e c t e d then WriteErr End.  Compilation. 4^  Appendix 3 4 5 S 7 8 9 10 1 1 12 13 14 15 1G 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1  F 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 0 : d 1 :d 1: d 1 :d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 2 0 2 1 1 0 1 0 1 d 3 0 3 1 1 0  Listing  of U n i t  MiscFunc  Page  {$L remout:} U n i t MiscFunc; { miscellaneous short  f u n c t i o n s and  procedures  }  Interface { power o f  10  functions }  F u n c t i o n TenToThe ( r : r e a l ) : r e a l ; { 10**r ) F u n c t i o n Log ( r : r e a l ) : r e a l ; { b a s e 10 l o g a r i t h m ) { signum f u n c t i o n s } F u n c t i o n rSgn ( r : r e a l ) : r e a l ; { i f r<0.0 t h e n -1.0 F u n c t i o n 1Sgn ( i : i n t e g e r ) : i n t e g e r ; { i f 1<0 t h e n -1 { min and max F u n c t i o n rMin F u n c t i o n rMax F u n c t i o n 1Min F u n c t i o n iMax  { unsigned integer functions ) F u n c t i o n u s i A d d (a,b: i n t e g e r ) : i n t e g e r ; { a + b } F u n c t i o n usiMinus (a,b: i n t e g e r ) : i n t e g e r ; < a - b { character functions > F u n c t i o n UpperChar ( c : c h a r ) :  char;  } }  (min, rMin(r.max)) ( r , -bound, bound) i n t e g e r rBounded } i n t e g e r rAbsBndd >  )  { change c  to upper  { change  s to upper  case  }  functions >  Procedure 0 0 0 0 0 0 0 0 1 0 0 0  1.0 } 1 )  functions ) (a.b real): real; { i f a<b t h e n a e l s e b ) (a.b real): real; { i f a>b t h e n a e l s e b } (a.b Integer): integer; { i f a<b t h e n a e l s e b (a.b integer): integer; { i f a>b t h e n a e l s e b  { limiting functions } F u n c t i o n r B o u n d e d ( r , min, max: real): real; { rMax F u n c t i o n rAbsBndd ( r , bound: r e a l ) : r e a l ; { rBounded F u n c t i o n i B o u n d e d ( i , min, max: i n t e g e r ) : Integer; { F u n c t i o n iAbsBndd ( 1 . bound: i n t e g e r ) : i n t e g e r : {  { string  else else  Uppercase  ( V a r s:  string);  case  }  Imp1ementat i on Const  ln10  = 2.302585;  F u n c t i o n TenToThe; Beg i n TenToThe:= exp ( l n 1 0 * r ) End; F u n c t i o n Log; Beg i n Log:= l n ( r ) / End;  ln10 Ul Ul  Appendix 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  F  Compiler 1 :0 1 :0 1 :d 4 :0 4 : 1 4 : 1 1 :0 1 :0 * 1 :d 5 :0 5: 1 5 : 1 1 :0 1 :0 1 :0 1: d 6 :0 6 : 1 6 : 1 1 :0 1 :0 1 :d 7 :0 7: 1 7 : 1 1 :0 1 :0 1: d 8 :0 8 : 1 8 : 1 1 :0 : 1 :0 : 1 :d : 9: 0 9 :1 9 :1 1 :0 1 :0 1 :0 1 :d 10: 0 10: 1 1 :0 1 :0 1 :d 1 1 0: 1 1 1: 1 :0 1 :0  Listing  of  Unit  MiscFunc  0 0 1 F u n c t i o n rSgn; 0 Beg i n 0 i f r < 0.0 t h e n rSgn : -1.0 9 else rSgn : 1 .0 0 End; 0 1 F u n c t i o n iSgn; Beg i n 0 0 i f 1 < 0 then i Sgn: - 1 5 e l se iSgn: 1 End; 0 0 0 1 Function rMin; 0 Beg i n 0 if a < b then rM i n : a 8 e l se rM i n : b 0 End; 0 1 F u n c t i o n rMax; 0 Begi n 0 if a > b then rMax: a 8 e 1 se r M a x : b 0 End: 0 1 Function iMin; Begi n 0 0 i f a < b then iMin: a 5 e 1 se i M 1 n : b 0 End; 0 1 F u n c t i o n iMax; 0 Begi n 0 i f a > b then i Max: a 5 e 1 se i Max:- b 0 End: 0 0 1 F u n c t i o n rBounded; 0 Beg i n 0 rBounded: rMax ( m i n . rM1n ( r , End; 0 0 1 F u n c t i o n rAbsBndd; 0 Beg i n 0 rAbsBndd: rBounded ( r -bound, End; 0 0  Page  2  3  3  3  3  3 3  3 3  3  3  3  3  3  ISJ  Cn  Appendix 102 103 104 105 106 107 108 109 1 10 11 1 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 End  F 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :d 12 :0 12 : 1 1 :0 1 :0 1 :d 13 :0 13 : 1 1 :0 1 :0 1 :0 1 :d 14 :0 14 : 1 1 :0 1 :0 1 :d 15 :0 15 : 1 1 :0 1 :0 1 :0 1 :d 16 :0 16 : 1 16 : 1 1 :0 1 :0 1 :0 1 :d 17 :d 17 :0 17 : 1 1 :0 1 :0 1 :0 :0  1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 14 0 0 0 1 1 0 0 0 0 0 0  Listing  of Unit  F u n c t i o n iBounded; Begin iBounded: iMax ( m i n , End; 3  F u n c t i o n iAbsBndd; Beg i n iAbsBndd: iBounded End; F u n c t i o n usIAdd: Beg i n usiAdd: a + b End; 3  Function usiMinus; Begi n usiMinus: a - b End:  iM1n  (i,  3  3  Page  MiscFunc  { note  (1,  max))  -bound,  that  { note  bound)  IV.0  that  3  run  IV.0  time e r r o r  run  05  does  05  time e r r o r  not  does  happen  not  )  happen  •  F u n c t i o n UpperChar; Beg i n i f c i n ['a'..'z'] then else End;  Procedure Uppercase; Var i : i n t e g e r ; Begin f o r i:= 1 t o l e n g t h End;  UpperChar: UpperChar:  3 3  chr c  (ord(c)  -  32)  • ( s ) do  s[i]:  3  UpperChar  (s[1])  End.  of C o m p i l a t i o n .  to  Appendix F 3 4 5 6 7 8 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 1 10 11 1 1 12 1 13 1 14 1 15 1 16 1 17  0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4  Compiler d d d d d d d d d d d d d d d d d 1 d r d 1 d 1 d 1 d 1 d 1 d 1 d 1 d 1 0 1 1 1 1 1 2 1. 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 2  0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 11 11 11 1 5 7 0 0 4 4 4 17 30 37 46 55 64 73 82 91 100 109 1 18 127 136 145 146 157 205  Listing  of Unit  Page  ExtraScr  1  {$L remout:> Unit ExtraScreenOps; Interface { E x t r a ScreenOps <$L->  Uses  routines >  ScreenOps;  <$L@>  F u n c t i o n MapCommandKey  (command: s c k e y command: c a l l from i n i t i a l i z i o n p a r t : b o o l e a n ) : c h a r ; { I n v e r s e o f scMapCrtCommand: c a l l s t o t h i s f u n c t i o n must h a v e t h e s e c o n d p a r a m e t e r t r u e i f made f r o m a n i n i t i a l i z a t i o n p a r t }  P r o c e d u r e MapDate ( v a r d a t e : s t r i n g ) ; { r e t u r n w i t h t h e c u r r e n t d a t e a s 'dd-mmm-yy' } I m p l e m e n t a t i on  Var  map: a r r a y  [sc_key_command] o f c h a r ;  Segment P r o c e d u r e E x t r a D a t ( v a r d a t e : str i ng[2]; V a r d, y m: s t r i n g [ 3 ] ; t i n f o : s c info type: Beg i n s c U s e l n f o ( s c g e t ,t i n f o ) ; w i t h t_ 1 n f o . s c d a t e do Beg i n s t r (day, d ) ; str (year, y ) ; C a s e month o f 0 m:= '00'; 1 m : = 'dan' 2 m:= ' F e b ' m: = 'Mar' 3 4 m : = ' Apr ' m:= 'May' 5 6 m:= 'Oun' 7 m:= 'Ju1 ' 8 m:= 'Aug' 9 m:= 'Sep' m : = ' Oct' 10 1 1 m: = 'Nov' 12 m : = ' Dec' End; { o f Case } date = concat (d m, y) End { of w i t h }  string);  Ul CD  Appendix F 1 18 1 19 120 12 1 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 14 1 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 End  4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :0 . 1 :0 1 :0 1: d 3 :0 3: 1 1 :0 1 :0 1 :0 1: d 4: d 4 :0 4: 1 4: 1 4: 2 4: 3 4: 2 4: 1 4: 1 4: 1 4: 2 4: 2 4: 3 1 :0 1 :0 1 :0 1: d 2 :0 2: 1 2: 1 2: 1 1 :0 1 :0 1 :0 1 :d : 5 : :d 5 :0 5: 1 5: 2 1 :0 1 :0 1 :0 1 :0 1 :1 0  0 0 0 1 0 0 0 0 0 1 1 0 0 2 8 8 14 28 31 34 39 44 50 0 0 0 1 0 0 0 5 0 0 0 1 1 0 0 9 0 0 0 0 0 0  L i s t i n g of U n i t E x t r a S c r End;  < o f Segment  ExtraDat  P r o c e d u r e MapDate; Beg i n ExtraDate (date) End; { of ExtraDate  Page  2  }  }  F u n c t i o n OneMap (command: sc_key_command): c h a r ; Var t e s t : c h a r ; Begin test:= chr ( 0 ) ; i f s c H a s K e y (command) t h e n Repeat test:= succ ( t e s t ) U n t i l (scMapCrtCommand ( t e s t ) = command) o r i f t e s t < c h r (255) then OneMap:= t e s t else i f command = s c _ b a c k s p a c e _ k e y then OneMap:- OneMap ( s c _ l e f t _ k e y ) else i f command = s c _ e o f _ k e y then OneMap:= OneMap ( s c _ e t x _ k e y ) End;  255) ;  F u n c t i o n MapCommandKey; Begi n if ca11_from_1nitia 1ization_part then MapCommandKey:= OneMap (command) else MapCommandKey:= map [command] End;  Procedure InitMap; V a r command: sc_key_command; Beg 1 n f o r command:= s c _ b a c k s p a c e _ k e y to sc_not_legal map [command]:= OneMap (command) End;  Beg i n I n i tMap End.  of Compilation. NJ Ul  Appendix 3 4 5 6 7 .8 9 10 1 1 12 13 14 15 1G 17 18 19 20 2 1 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4 1 42 43 44 45 46 47 48 49 50 51  F 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d 1 d 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  Listing  of U n i t  WritCons  Page  ($L remout:> Unit WritCons; Interface  { procedures  to send  formatted v a l u e s to c o n s o l e : )  P r o c e d u r e W r i t e B o o l e a n (b: b o o l e a n ) ; P r o c e d u r e T o s s B o o l e a n ( x , y: i n t e g e r ; b: b o o l e a n ) ; { w r i t e a b o o l e a n v a l u e as ' t r u e ' o r ' f a l s e ' } F u n c t i o n WriteNot (b: b o o l e a n ) : b o o l e a n ; F u n c t i o n T o s s N o t ( x . y: i n t e g e r ; b: b o o l e a n ) : { r e s u l t : = n o t b, W r i t e B o o l e a n ( r e s u l t ) >  boolean;  Procedure WriteBlanks ( f i e l d : integer); P r o c e d u r e T o s s B l a n k s ( x , y, f i e l d : integer); < write f i e l d blanks > Procedure WriteErase ( f i e l d : integer); P r o c e d u r e T o s s E r a s e ( x . y, f i e l d : integer): { WriteBlanks ( f i e l d ) , r e t u r n c u r s o r to s t a r t i n g Procedure { write Procedure { write  position >  WriteLeft ( f i e l d : integer): f i e l d backspaces without e r a s i n g > WriteBackspaces ( f i e l d : integer); f i e l d backspaces, e r a s i n g c h a r a c t e r s along  P r o c e d u r e T o s s l n t e g e r ( x , y, i , f i e l d : integer); { move c u r s o r t o x.y and w r i t e i r i g h t j u s t i f i e d in given width )  t h e way  a  field  }  of  Procedure Procedure  WriteReal ( r : r e a l ; field, dec_field: integer) T o s s R e a l ( x , y: i n t e g e r ; r: rea1; f i e l d , dec f i e l d : i n t e g e r ) ; { w r i t e r r i g h t j u s t i f i e d i n a f i e l d of width f i e l d w i t h d e c _ f i e l d a f t e r the d e c i m a l . I f d e c f i e l d = 0, t h e rea1 w i l l be wr i t t e n a s an i n t e g e r . r i s rounded to the d e c C h a r ' t h d i g i t b e f o r e w r i t i n g }  Procedure WriteFloat ( r : r e a l ; field: integer); P r o c e d u r e T o s s F l o a t ( x , y: i n t e g e r ; r: r e a l ; field: integer); < w r i t e r i n s c i e n t i f i c n o t a t i o n r i g h t j u s t i f i e d a f i e l d of b l a n k s P r o c e d u r e T o s s C h a r ( x , y: i n t e g e r ; ch: ( s e n d c u r s o r t o x,y and w r i t e ch:1 )  )  char):  Procedure W r i t e S t r i n g (s: s t r i n g ; field: integer); P r o c e d u r e T o s s S t r i n g ( x , y: i n t e g e r ; s: s t r i n g ; field: < w r i t e s ( i f f i e l d > 0 then l e f t j u s t i f i e d i n a f i e l d  integer); of b l a n k s )  )  Imp 1ementat i on o  Appendix 52 164 165 166 167 168 169 170 17 1 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 2 10 2 1 1 2 12  F  2 2 2 2 2 .2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1 :d 1 :d 1 :d 1 :d 1 :d 1: d 1 :d 1 :d 2 :0 2 : 1 2 : 1 1 :0 1 :0 1 :d 3 :0 3 : 1 1 :0 1 :0 1 :d 4 :0 4 : 1 1 :0 1 :0 1 :d 5 :0 5 : 1 1 :0 1 :0 1 :0 1 :d 1 :d 6 :d 6 :d 6 :0 6 : 1 6 : 1 6 : 1 1 :0 1 :0 1 :d 7 :0 7 : 1 1 :0 1 :0 1 :0 1 :d 8 :0 8 : 1 8 : 1 1 :0  Listing  {$L-}  of U n i t  Page  WritCons  Uses ScreenOps,  ExtraScreenOps.  MiscFunc;  ft Var  0 0 9 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 11 25 0 0 1 0 0 0 0 0 1 0 0 3 0  backspaces:  packed  Procedure WriteBoolean; Beg 1 n If b t h e n W r i t e S t r i n g else WriteString End;  array  [0..79] of  ( ' t r u e ', ('false',  Procedure TossBoolean; Begin gotoxy (x,y); WriteBoolean End: Function WriteNot; Beg i n W r i t e B o o l e a n (not b ) ; End; Function Beg i n gotoxy End:  char;  5) 5)  (b)  WriteNot:=  not  b  TossNot; (x, y ) ;  TossNot:=  WriteNot  Procedure WriteBlanks; ( use blank compression } C o n s t DLE = 16; Var b l a n k s : packed a r r a y [0..1] Beg i n b l a n k s [0]:= DLE : b l a n k s [ 1 j : = 32 + f i e l d ; u n i t w r i t e ( 1 , b l a n k s , 2) End; Procedure TossBlanks; Begin gotoxy (x.y); WriteBlanks End:  Procedure WriteErase: Begin Wri t e B l a n k s ( f i e l d ) ; WriteLeft (field) End;  of  (b)  0..255;  (field)  {  2  Appendix 2 13 2 14 2 15 216 . 2 17 2 18 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 24 1 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262  F 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 1:0 1 :d 9 :0 9 : 1 1:0 1:0 1:0 1 :d 10 : 0 10 : 1 1:0 1:0 1 :d 1 1: 0 1 1: 1 1 1: 1 1:0 1:0 1:0 1 :d 12 : 0 12 : 1 1:0 1:0 1:0 1 :d 13 : 0 13 : 1 13 : 1 13 : 1 13: : 2 13: : 2 1 ::0 1 ::0 1 :d : 14 : 0 14 :: 1 14 : 1 1 :0 1 :0 1 :o 1 :d 15 : d 15 : d 15: 0 15 : 1 15 : 1 15 : 3 15 : 3 15 : 2  0 1 0 0 O 0 0 1 0 O 0 0 1 0 0 3 O 0 0 1 0 0 0 O 0 1 0 0 1 16 21 39 0 0 1 0 0 4 0 0 0 1 1 2 0 0 2 8 10 1 1  Listing  of U n i t  WritCons  Procedure TossErase; Beg i n gotoxy (x.y); WriteErase End;  Procedure WriteLeft; Beg i n u n i t w r i t e ( 1 , backspaces, End;  Page  (field)  field)  Procedure WriteBackspaces; Beg i n WriteLeft (field); WriteErase ( f i e l d ) End;  Procedure Tosslnteger; Begin gotoxy (x.y); write End;  (i:field)  Procedure WriteReal; Beg i n if dec_field > 0 then write (r:f1 eld:dec_fie1d) e l s e i f a b s ( r ) > maxint then write (r:field:1) else write (round(r):f1e1d) End: Procedure TossReal; Beg i n gotoxy (x.y); WriteReal ( r , f i e l d , End;  Procedure WriteFloat; Var exponent: integer; mant i s s a : r e a 1 ; Beg i n if r = 0 . 0 then Begin exponent:= 0 ; mant i ssa:= 0 . 0 End  dec  field)  Appendix F 2G3 264 265 266 267 268 269 270 27 1 272 273 274 275 276 277 278 279 280 28 1 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 End  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  Compiler 15 : 1 15 : 3 15 : 3 15 : 2 15 : 1 15 : 1 15 : 1 15 :2 15 : 1 15 : 2 1 :0 1 :0 1 :d 16 :0 16 : 1 1 :0 1 .0 1 :0 1 :d 17 :0 17 : 1 1 :0 1 :0 1 :0 1 :d 18 :d 18 :0 18 : 1 18 : 1 18 :: 1 18 :: 1 18 :: 1 1 :0 1 :0 1 :d 19: 0 19 : 1 1 :0 1 :0 1 :0 1 :0 1 :1 0  15 17 30 37 4 1 55 56 87 11 1 139 0 0 1 0 0 0 O 0 1 0 0  o  0 0 1 1 0 59 15 27 4 1 0 0 1 0 5 0 0 0 0 0 0  Listing  of U n i t  WritCons  Page  4  e l s e Begin exponent:= round ( L o g ( a b s ( r ) ) - 0 . 4 9 9 9 9 9 ) ; mantissa:= r / Ten t o t h e ( e x p o n e n t ) End; W r i t e R e a l ( m a n t i s s a , f i e l d - 4 , i min ( f i e l d - 7 , 5 ) ) ; i f e x p o n e n t >= 0 then i f exponent > 9 then w r i t e ('E+', e x p o n e n t ) else w r i t e ('E+0', e x p o n e n t ) e l s e i f e x p o n e n t < -9 t h e n w r i t e ('E', e x p o n e n t ) else w r i t e ('E-0', - e x p o n e n t ) End; Procedure TossFloat; Beg i n gotoxy (x.y); WriteFloat ( r , field) End;  Procedure TossChar; Begin gotoxy (x.y); write (ch) End;  Procedure Wr1teStr1ng: Var l e n : i n t e g e r ; Begin l e n : = 1ength ( s ) ; i f f i e l d <= 0 t h e n fie1d:= len else 1 en:= i M i n ( l e n . f i e l d ) : if l e n > 0 then u n i t w r i t e (1. s [ 1 ] , l e n ) ; if f i e l d > l e n then WriteBlanks (field-len) End; Procedure TossString; Begin gotoxy (x.y); WriteString End:  Beg i n fillchar End.  (backspaces.  (s.  field)  80. MapCommandKey  ( s c backspace  key  of Compilation.  isj OJ  

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0095276/manifest

Comment

Related Items