%begin

%include "inc:util.imp"
%constant %integer boardaddr = 16_7FFC0    ;! Change as appropriate
%recordformat DEVICE FM(%byte bstatus,data,intvec,dstatus,x,mode,y,command)
@boardaddr %record(device fm) device

%routine set baud(%integer code)
  %constinteger mode1=16_4e,mode2=16_30,comm=16_37,reset=8
  device_bstatus = reset; device_bstatus = 0
  device_mode = mode1;    device_mode = mode2+code
  device_dstatus = 0;     device_dstatus = 0
  device_dstatus = 0;     device_command = comm
%end

%routine put(%Integer sym)
   %While device_dstatus&1=0 %cycle; %repeat
   device_data =sym
%End

%integerfn get
    %while device_dstatus&2=0 %cycle; %Repeat
    %Result = device_data&16_7F
%End

!-------------------------------------------------------------------------------

%routine putstring(%string (255) s)
   %integer i
   %return %if s=""
   %for i=1,1,length(s) %cycle; put(charno(s,i)); %repeat
%end

!-------------------------------------------------------------------------------

%routine putline(%string (255) s)
    putstring(s)
    put(13)
%end

%integer i,p
%bytearray buff(0:2047)
%constinteger b9600 = 13, b19200 = 14
set baud (b9600)
putline("1.100")
i=get ;!The 'O'
i=get ;!The next 'O'
p=0
%for i=0,1,1279 %cycle
   buff(i)=get
%repeat
%endofprogram
