    SLAN CRT-SLAVE(1) PROGRAM ROUTINES
    ==================================

+-------------------------+
I                         I              IND AB / JOHN REHN
I PROGRAM INITIALIZATION  I              REV 0   851218  
I                         I
+-------------------------+
            I
+-------------------------+
I       IDLE LOOP         I
I+-----------------------+I 
II       RAM TEST        II
I+-----------------------+I
I+-----------------------+I
II        ROM TEST       II
I+-----------------------+I                      
+------------------------+I

+---------------------------------------+
I             RECEIVE BYTE              I
I+-------------------------------------+I
II         RECEIVE NEXT BYTE           II
II+-----------------------------------+II
III         CHECK COMMAND             III
III+=================================+III
III:       REQUEST FOR DATA          :III
III:  DATA  DPRAM ==> OUTPUT BUFFER  :III
III+=================================+III
III:         DATA TO CRT             :III
III:  DATA  INPUT BUFFER ==> DPRAM   :III
III:=================================+III
III:       STATUS REQUEST            :III
III:   STATUS ==> OUTPUT BUFFER      :III
III+=================================+III
III:    REQUEST FOR RETRANSMISSION   :III
III+=================================+III
II+-----------------------------------+II
II+-----------------------------------+II
III     INIT REPLY TRANSMISSION       III
II+-----------------------------------+II
I+-------------------------------------+I
+---------------------------------------+

+---------------------------------------+
I         TRANSMIT BYTE                 I
+---------------------------------------+
!!
						rev 0 851218

CASE Program Initialization
  initialize port 3 alternate functions (P3 = CBH)
  read memory location for interrupt from CPU2 (= reset interrupt)
  read memory location for interrupt to CPU2 (= reset interrupt)
  initialize two port 1 pins to enable reading interrupts to/from CPU2
  reset all RAM cells from 00H - 7FH
  initialize stack pointer
  set serial port to mode 3 and multiprocessor comm (SCON = E0H)
  set double baud rate (PCON = 80H)
  set timer 1 to mode 2 to be a baud rate generator (TMOD = 33H)
  set baud rate to 38.4 kBaud (TH1 = FFH, which provides that the
   oscillator frequency is 7.3728 MHz)
  enable timer 1 as baud rate generator (TCON = 40H)
  enable seriel port interrupt (IE = 90H)
END Program Initialization

REPEAT CASE Idle Loop
  * RAM test (similar to that for trackball)
  * ROM test (            -"-              )
END Idle Loop
!!
                                                   Rev. 0   851218
CASE Receive Byte
  move character from receive buffer to input buffer
  WHEN address byte (SCON.2 = 1)
    CASE Address
      WHEN own device or own multicast or broadcast address
        reset input byte pointer
        	disable address filter (SCON.5 = 0)
        move character to input buffer
        increment byte pointer
      OTHERWISE
      	enable address filter (SCON.5 = 1) (this action is necessary
        to enable resynchronization upon retry after timeout if
        the slave unit missed the stop character from master)
    END Address
  WHEN already in receiving mode
    * receive next byte
END Receive Byte
!!
                                                   Rev. 0     851218
CASE Receive Next Byte
  move character to input buffer
  WHEN not stop character
    increment byte pointer
    CASE Input Buffer Full
      WHEN input buffer full 
	enable address filter (SCON.5 = 1)
    END Input Buffer Full
  OTHERWISE
    enable address filter (SCON.5 = 1)
    CASE Check Check Sum
      decrement input buffer pointer
      clear check byte
      REPEAT XOR Byte
        decrement input buffer pointer
	xor byte to check byte
      END XOR Byte WHEN input buffer pointer = address of input buffer
      WHEN msb is one 
        make one's complement of check byte
      WHEN check byte does not match received check sum
        indicate check sum error in status
        EXIT Receive Next Byte
    END Check Check Sum
    * check command and generate reply
    * initiate reply transmission
END Receive Next Byte
!!
                                                  rev 0   851218
REPEAT CASE check command and generate reply
  increment input buffer pointer 
  get command ( by input buffer pointer )
  CASE check command
  WHEN data command
    wait here until interupt to CPU2 is reset
    increment input buffer pointer
    get byte count ( by input buffer pointer )
    
    CASE check 
    WHILE byte count