*
fifo    equ    #$60000
fitop   equ    #$1000
rambot  equ    #$20000
ramtop  equ    #$39ffe
*
tval    equ    #$00f5
save    equ    #$21002
*
led     equ    #$70000
off     equ    #$000f
green   equ    #$000e
rdreq   equ    #$000d
*
*
        org    $030000
rfserv: move.l led,a2
        move.w off,(a2)      * clear interupt
        move.b #$00,d7       * clear flag
*
*        move.l save,a2       * the address of the next space in table
*        move.l (a2),a1       * write address
*        move.l fval,a0       * the address of the next value
*        move.w (a0),d0       * next value should be
*
        move.l fifo,a2
        move.w (a2),d2       * get next fifo value
        move.w d2,(a3)+      * save incoming value
*        cmp.w  tval,d2
*        beq okay
*        add.w  #$01,d6
*
*        move.w (a0),d0       * save next value
*        move.l a1,(a2)       * save next space in table
*
okay:   rte
*
*
*
        org    $031000
*
start:  move.l led,a2
        move.w green,(a2)    * clear leds
        move.l #$21004,a2
        move.w tval,(a2)    * clear expected fifo value
        move.l rambot,a3
        move.l #$0,d6
        move.l #$0,d7
*
*
loop:   and.w  #$f9ff,sr
        move.b #$01,d7
        move.l led,a4
        move.w rdreq,(a4)
inlop:  cmp.b #$00,d7
        bne inlop
        or.w  #$0700,sr
        cmp.l #$20800,a3
        bne    loop
*
        move.l led,a4
        move.w green,(a4)
        trap   #0
wait:   jmp    wait
*

error:  move.l led,a2
        move.w off,(a2)
        trap   #0
error2: jmp    error2
*
*
        org    $03fe50
        jmp    rfserv
*
        END
