syscall wrote:
Hello everyone, just thought I let you know that I managed to get 68,2kbit/s with on the fly checksuming from this sucker
Looks to me like with a little bit of tweaking
you might get 115200
Need two stop bits.
Timing would be really tight though.
First when you loop back nothing changes the
accumulator so you can add cksum first
Second, sta doesn't change the carry and nothing
at the end or beginning of the loop will change the
carry so you can arrange to clear the carry as part
of inter-bit delay by clearing the bit that will
eventually be shifted into the carry with an and
and then adc cksum after the sta and before iny
and then add the carry from that back in after you
loop (there by saving a cycle assuming the buffer
starts on a page boundary).
Third saving cksum won't change the carry
and reading the port won't change the accumulator
so you can delay saving cksum to the inter-bit time
bit time at 115200 is 8.68c (1us/c)
Code:
ldx #$3f
lda #0
tay
sta zero
clc
wb: bit portb <- startbit
bvc wb ;not taken = 3c long 3+4+2=9c short 2c
;so jitter is 7c
adc zero ;3
cpx portb ;4 b0 9c-16c we need 8.68-17.36
sta cksum ;3
ror @ ;2
cpx portb ;4 b1 18c-25c we need 17.36-26.04
ror @ ;2
bit zp ;3
cpx portb ;4 b2 27c-34c we need 26.04-34.47
ror @ ;2
and #$E0 ;2 clc for cksum add when bit 4
; gets shifted out
cpx portb ;4 b3 35c-42c we need 34.47-43.4
ror @ ;2
bit zp ;3
cpx portb ;4 b4 44c-51c we need 43.4-52.08
ror @ ;2
bit zp ;3
cpx portb ;4 b5 53c-60c we need 52.08-60.76
ror @ ;2
bit zp ;3
cpx portb ;4 b6 62c-69c we need 60.76-69.4
ror @ ;2
nop ;2
cpx portb ;4 b7 70c-77c we need 69.4-78.14
ror @ ;2
sta sekbuf,y ;4
adc cksum ;2
iny ;2
cpy count ;2
bne wb ;3
adc #$00
sta cksum
rts
It's probably possible to move the port read for the start
bit to the end of the loop, which might be desireable, since
the loop back is 19c, and the time to the start bit ie two
stop bits is 17.28.
It seems you might tend to the later read/longer jitter
but I haven't tried to work it out.
hmm, maybe I have that exactly backwards.
I guess you'd want the port read to come a
couple cycles later.
Wouldn't really matter anyway.
edit: tweaked the timing, removed a goof