; IPS SLAVE implementation.
; ISR

ips_isr
                jsr     ips_dri
                bclr    PORTA,x TX
                bset    STATUS  IPS_REC
                rti



;shifter data ud
;Inddata - Shift I/O
;Uddata - Shift I/O
ips_dri                       
                ldx     #REGBASE
                ldab    #$08                    ;T‘ller
                ldaa    SHIFTO                  ;Skifte register
                
                ;Vent p† at CLK g†r h›j
_clk_hi         brclr   PORTA,x CLK *           ;Clk=0, kig igen

                ;Gem indg†ende bit i carry
                brset   PORTA,x RX _jen         ;Clk=1 => G† til _jen hvis Rx=1
                clc                             ;Ellers Carry=0
                bra     _rola                   ;G† til skift
_jen            sec                             ;if(Rx=1) Carry=1

                ;Rot‚r carry in/ud
_rola           rola                            ;Skift

                ;Send carry
                bcs     _jen_ud                 ;if(Carry=1), goto _jen_ud
                bclr    PORTA,x TX              ;Ellers s‘t TX=0
                bra     _ips_che                ;Og se om alt er shiftet
_jen_ud         bset    PORTA,x TX              ;S‘t TX til 1
_ips_che        decb                            ;--
                beq     _ips_dri                ;--
                brset   PORTA,x CLK *
                bra     _clk_hi

                ;Vent p† at clock er lav
_ips_dri        brset   PORTA,x CLK *
                brn     *
                brn     *
                brn     *
                staa    SHIFTI
                rts
