A83: Convertion of a TI85 link routine


[Prev][Next][Index][Thread]

A83: Convertion of a TI85 link routine




I try to convert a link routine of a program which works on TI85 but I
doesn't work. There are two commands use : PutByte and GetByte. Here is the
original source:
*****************************
GetByte:
        push bc
        LD      B,008H
R0:
        LD      DE,0FFFFH
        JR      R2
R1:
        IN      A,(PORT)
        AND     003H
        jr      z, GB_End
        CP      003H
        JR      NZ,R3
        IN      A,(PORT)
        AND     003H
        jr      z, GB_End
        CP      003H
        JR      NZ,R3
R2:
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R1
        jr      GB_End
R3:
        SUB     002H
        JR      NC,R8
        LD      A,0D4H
        OUT     (PORT),A
        RR      C
        LD      DE,0FFFFH
R4:
        IN      A,(PORT)
        AND     003H
        CP      002H
        JR      Z,R5
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R4
        jr      GB_End
R5:
        LD      A,0C0H
        OUT     (PORT),A
        LD      D,004H
R6:
        DEC     D
        JR      Z,R7
        IN      A,(PORT)
        AND     003H
        CP      003H
        JR      NZ,R6
R7:
        DJNZ    R0
        LD      A,C
        jr      GB_End
R8:
        LD      A,0E8H
        OUT     (PORT),A
        RR      C
        LD      DE,0FFFFH
R9:
        IN      A,(PORT)
        AND     003H
        CP      001H
        JR      Z,R5
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R9
GB_End
        pop bc
        ret




PutByte:
        push bc
        LD      C,A
        LD      B,8             ; 8 Bits
PB_Next_Bit:
        LD      A, $C0          ; Set W1 and R1
        OUT     (7),A

Cont:
        RR      C
        JR      NC, PB_SendZero
PB_SendOne:
        LD      A, $E8
        JR      PB_Output_val
PB_SendZero:
        LD      A, $D4
PB_Output_val:
        OUT     (7),A

        LD      DE, $FFFF       ; For time-out
PB_Wait_for_W0_and_R0:
        IN      A,(7)
        AND     3
        JR      Z, PB_Continue
        IN      A,(7)
        AND     3
        JR      Z, PB_Continue
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ, PB_Wait_for_W0_and_R0
        JR      PB_End          ; If error return.

PB_Continue:
        LD      A, $C0          ; Set W1 and R1
        OUT     (7),A

        LD      DE, $FFFF       ; Reload time-out
PB_Wait_for_W1_and_R1:
        DEC     DE
        LD      A,D
        OR      E
        JR      Z, PB_End
        IN      A,(7)
        AND     3
        CP      3
        JR      NZ, PB_Wait_for_W1_and_R1

        DJNZ    PB_Next_Bit

        ld      DE, $06FF              ; Small delay
PB_EW:
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ, PB_EW

PB_End:
        POP    BC
        RET
*****************************
What must be change to work on a TI83. I tried to convert it myself, this is
that I think it should be.
*****************************
GetByte:
        push bc
        LD      B,008H
R0:
        LD      DE,0FFFFH
        JR      R2
R1:
        IN      A,(BPORT)
        AND     $C
        jr      z, GB_End
        CP      $C
        JR      NZ,R3
        IN      A,(BPORT)
        AND     $C
        jr      z, GB_End
        CP      $C
        JR      NZ,R3
R2:
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R1
        jr      GB_End
R3:
        SUB     002H
        JR      NC,R8
        LD      A,0D4H
        OUT     (BPORT),A
        RR      C
        LD      DE,0FFFFH
R4:
        IN      A,(BPORT)
        AND     $C
        CP      002H
        JR      Z,R5
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R4
        jr      GB_End
R5:
        LD      A,0C0H
        OUT     (BPORT),A
        LD      D,004H
R6:
        DEC     D
        JR      Z,R7
        IN      A,(BPORT)
        AND     $C
        CP      $C
        JR      NZ,R6
R7:
        DJNZ    R0
        LD      A,C
        jr      GB_End
R8:
        LD      A,0E8H
        OUT     (BPORT),A
        RR      C
        LD      DE,0FFFFH
R9:
        IN      A,(BPORT)
        AND     $C
        CP      001H
        JR      Z,R5
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ,R9
GB_End
        pop bc
        ret

PutByte:
        push bc
        LD      C,A
        LD      B,8             ; 8 Bits
PB_Next_Bit:
        LD      A, D0HD1H   ; Set W1 and R1
        OUT     (BPORT),A

Cont:
        RR      C
        JR      NC, PB_SendZero
PB_SendOne:
        LD      A, D0LD1H
        JR      PB_Output_val
PB_SendZero:
        LD      A, D0HD1L
PB_Output_val:
        OUT     (BPORT),A

        LD      DE, $FFFF       ; For time-out
PB_Wait_for_W0_and_R0:
        IN      A,(BPORT)
        AND     $C
        JR      Z, PB_Continue
        IN      A,(BPORT)
        AND     $C
        JR      Z, PB_Continue
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ, PB_Wait_for_W0_and_R0
        JR      PB_End          ; If error return.

PB_Continue:
        LD      A, D0HD1H          ; Set W1 and R1
        OUT     (BPORT),A

        LD      DE, $FFFF       ; Reload time-out
PB_Wait_for_W1_and_R1:
        DEC     DE
        LD      A,D
        OR      E
        JR      Z, PB_End
        IN      A,(BPORT)
        AND     $C
        CP      $C
        JR      NZ, PB_Wait_for_W1_and_R1

        DJNZ    PB_Next_Bit

        ld      DE, $06FF              ; Small delay
PB_EW:
        DEC     DE
        LD      A,D
        OR      E
        JR      NZ, PB_EW

PB_End:
        POP    BC
        RET
*****************************
Why it doesn't work?

On the TI82 or 85, the value returned by the link port are 0, 1, 2 or 3,
that made operations easy to do. Is there on the TI83 values like that,
which are following themselves?
I'm sorry for my very bad english.

Cédric

------------------------------------------------------
E-mail : delmas.temp@wanadoo.fr
ICQ : 38856763
Site WEB : http://www.multimania.com/delmasce/



Follow-Ups: