Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Xeda112358 on January 15, 2012, 09:29:16 pm

Title: I/O Help
Post by: Xeda112358 on January 15, 2012, 09:29:16 pm
Okay, I have been having a tough time with this, so I need help. I am trying to send data between two calculators and I can easily send a single bit or two bits, but nothing longer seems to work. The protocol idea that I was working with looked like this (this is an outline):
Code: [Select]
         ld b,8
Send:
         rlc c                ; get the next bit of C
         ccf                  ; inverts the c flag since writing to the port will be inverted
         adc a,a            ; rotate the bit into a
         scf                  ; sets the carry flag
         adc a,a            ; sets the first bit
         out (0),a          ; send it to the port
         dec b              ; decrements the counter
         ret z                ; ends if the counter hits 0
CheckLoop:
         in a,(0)            ; Check the port
         rra                  ; We test bit 0
         jr c,Send          ; Ready to send the next bit
         jp CheckLoop    ; Eh, keep checking
Receive:
         ld b,8
Loop:
         in a,(0)            ; check the port
         rra                  ; check the bit to see if the data was being sent
         jr c,$-3
         rra                  ; get the bit that was sent
         rl c                 ; rotate it into C
         out (0),a          ;since A is 0, this will set both bits in port 0 signaling that another bit can be sent
         djnz Loop
         ret
Actually, I just typed that up and is only vaguely like the codes I have come up with before. In any event, if I take out the counters and only send one bit, it works fine and I receive it, bit if I try to send all 8 bits, it freezes (I think the receiving end).

Thanks much! I'd love to figure this out :)