          bin
ethwrite  equ     $1100
ethread   equ     $1104
time      equ     $00F80800
compac    equ     $00F8080E
full      equ     $00F80828
update    equ     $00F80864

msfstate  dc.b    0
          dc.b    0
buffer    ds.b    266

start     movem.l D0-D7/A0-A6,-(SP)
          move.l  usp,A0
          move.l  A0,-(SP)
          move.w  #0,SR

          moveq   #0,D0
          move.l  #$0100,D1
          lea     buffer,A0
          jsr     ethread

          lea     buffer,A0
          cmpi.b  #11,6(A0)
          bne     finish

***********************************************************
* the ether packet was ment for me, so here goes
          clr.b   6(A0)
          lea     msfstate,A1
          cmpi.b  #0,(A1)
          beq     msftim
          move.b  #254,6(A0)
          moveq.l #1,D1
          bra     write

***********************************************************
* board is present so go ahead with data transfer
msftim    move.l  #time,A1
          bsr     grab
          lea     4(A1),A2
          lea     7(A0),A3
          moveq.l #10,D0
tcopy     move.b  (A2)+,(A3)+
          dbra    D0,tcopy
          move.b  #255,1(A1)

          move.l  #update,A1
          bsr     grab
          lea     4(A1),A2
          lea     17(A0),A3
          moveq.l #6,D0
ucopy     move.b  (A2)+,(A3)+
          dbra    D0,ucopy
          move.b  #255,1(A1)

          move.l  #compac,A1
          bsr     grab
          lea     4(A1),A2
          lea     24(A0),A3
          bsr     strcopy
          move.b  #255,1(A1)

          move.l  #full,A1
          bsr     grab
          lea     4(A1),A2
          lea     46(A0),A3
          bsr     strcopy
          move.b  #255,1(A1)
          move.b  #94,D1

***********************************************************
* write = write buffer, length in D1 back to ether, then return
write     moveq.l #0,D0
          addq.l  #7,D1
          jsr     ethwrite

finish    move.l  #$2700,D0
          trap    #0
          move.l  (SP)+,A0
          move.l  A0,usp
          movem.l (SP)+,D0-D7/A0-A6
          rts

***********************************************************
* strcopy  = copy a string from (A2) to (A3), both affected
*            D1 = length+1 at end
strcopy   clr.l   D0
          move.b  (A2),D0
          addq.l  #1,D0
          move.l  D0,D1
scopy     move.b  (A2)+,(A3)+
          dbra    D0,scopy
          rts

***********************************************************
* grab = attempt to acquire semaphore of record at (A1)
grab      clr.b   1(A1)
          move.b  #255,2(A1)
          clr.l   D0
gloop     addq.l  #1,D0
          cmpi.l  #50,D0
          beq     gerror
          cmpi.b  #0,(A1)
          bne     gret
          cmpi.b  #0,2(A1)
          bne     gloop
gret      rts
gerror    move.b  #255,1(A1)
          move.b  #255,6(A0)
          moveq.l #1,D1
          bra     write

          bra.w   msfstate
          bra.w   start
* branch instruction are required so that
* the IMP control program knows where to set
* interrupt vectors, etc
          end
