%begin; !ID: Show ether station address and firmware version etc
%include "inc:fs.imp"
%include "inc:util.imp"
%include "inc:atdecs.imp"
%integer i,z
%bytearray b(1:4)

  %routine pdate(%integer d,m,y)
    phex2(d); printsymbol('/')
    phex2(m); printsymbol('/')
    phex2(y)
  %end

  %routine rwait
    %cycle; %repeatuntil eths&1#0
  %end

  %integerfn dc
    rwait %until eths&4#0
    %result = ethd
  %end

  %integerfn cc
  %integer x
    %cycle
      rwait %until eths&2#0
      x = ethc
      %result = x %if x&\15=0
      %if x&\15#0 %start
        printstring("[^"); phex2(x); phex2(dc); printsymbol(']')
      %finish
    %repeat
  %end

!%real %fn Speed
!   %constshortarray loopa(0:6) = %c
!   { MOVE.L  #37376,D0        } 16_203C, 0, 37376,
!   { SUBQ.L  #1,D0            } 16_5380,
!   { BNE     delay            } 16_6600, 16_fffc,
!   { RTS                      } 16_4E75
!   %integer I, J
!   @16_3f00 %routine loop
!   %for i = 0, 1,6  %cycle; shortinteger(16_3f00+i<<1) = loopa(i); %repeat
!   j = cputime; %while j = cputime %cycle; %repeat
!   loop
!   J = CPU Time - J
!   %result = (640 / J) + 0.5
!%end

%routine kb(%integer b)
  write(b>>10,0); printstring(" kB")
%end

  printstring("Main firmware version ")
  pdate(dd,mm,yy); newline
  z = 0
  eths = z;              !Interrupts off
  twait; ethc = 8;       !Set Peek Address
  twait; ethd = 3;       !Low byte
  twait; ethd = z;       !High byte
  %for i = 1,1,4 %cycle
    twait; ethc = 13;    !Peek command
    z = cc %until z=14;  !Await Poke response
    b(i) = dc;           !Get the value
  %repeat
  eths = 6;              !Interrupts on again
  printstring("Ether firmware version ")
  pdate(b(2),b(3),b(4))
  newline
  printstring("Station address ")
  phex2(b(1)); newline
  printstring("Your port "); phex2(lp)
  printstring(" is connected to port "); phex2(rp)
  printstring(" of filestore "); phex2(rs); newline

  ! JHB additions (courtesy of USEFUL)

   printstring("Main store ")
   kb(memtop-membot); printstring(" from "); phex(membot); newline
   printstring("Free store ")
   kb(freetop-freebot); printstring(" from "); phex(freebot); newline
!  Print string("Your CPU is running at about")
!  Print (Speed, 1, 2);  Print String (" MHz");  New Line
%endofprogram
