OS 1.2 serial driver overflow flag bugs - or a feature?

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
gfoot
Posts: 350
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

OS 1.2 serial driver overflow flag bugs - or a feature?

Post by gfoot »

I've been playing with serial communication today, and was referring to the OS 1.2 disassembly on MMFS.net: https://mdfs.net/Docs/Comp/BBC/OS1-20/DC1C

There seemed to be a lot of bugs regarding testing of the overflow flag. E.g. at DCA1:

Code: Select all

DCA1	CLV         ; Clear V flag
DCA2	LDA &FE08   ; Read ACIA status register
DCA5	BVS &DCA9   ; b6 set, jump with serial parity error
This branch will never be taken because DCA1 cleared the flag and LDA does not affect the flag. Perhaps once upon a time that's was a BIT instruction.

Again later it does this sort of thing:

Code: Select all

DCA9	LDX &EA     ; Get RS423 timeout counter
DCAB	DEX         ; Decrement it
DCAC	BMI &DCDE   ; If 0 or <0, RS423 owns 6850, jump to DCDE
DCAE	BVS &DCDD   ; If &41..&80, nobody owns 6850, jump to exit
And again later on:

Code: Select all

DCE1	LSR A       ; Move RxRDY into Carry
DCE2	BCC &DCEB   ; If no RxData, jump to check DCD and TxRDY
;
; Data in RxData, check for errors
;
DCE4	BVS &DCEB   ; If IRQ=1 (now in b6) RxIRQ must have occured, so jump to DCEB
Again this branch will never be taken.

However, it occurred to me that I might be reading too much into the annotations. It is possible that the point here is that this code may be entered from elsewhere with the overflow flag set, rather than from the IRQ1V handler, and these tests might really be there to disable some of the code in that case.

Seen that way, the first one is skipping over a test of the 6850's interrupt bit, the second is avoiding some cassette handling, and the third is also skipping style interrupt related checks.

Has anyone looked into this before? I was only reading it because keyboard interrupts were interfering with my communication and I wanted to see how to read from the 6850 directly. So that's now working well at 76800 baud with interrupts disabled, and I no longer need the OS code, but it's interested to know why it is written how it is.
User avatar
hoglet
Posts: 11123
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: OS 1.2 serial driver overflow flag bugs - or a feature?

Post by hoglet »

gfoot wrote:
Thu May 12, 2022 11:27 pm
Has anyone looked into this before? I was only reading it because keyboard interrupts were interfering with my communication and I wanted to see how to read from the 6850 directly. So that's now working well at 76800 baud with interrupts disabled, and I no longer need the OS code, but it's interested to know why it is written how it is.
I recommend you look at Toby Lobster's excellent MOS 1.20 reassembly, which makes everything clear:
https://tobylobster.github.io/mos/mos/S-s11.html#SP7

The instuction after the CLV is an entry point:

Code: Select all

§7. irq1CheckACIA.

 Check for ACIA Interrupt or Update ACIA

 Two modes of operation (V CLEAR and V SET)

 On Entry:
       V CLEAR means check that the ACIA generated the interrupt, and if so then update
               the RS-423 or cassette as needed
       V  SET  means just update the RS-423
.irq1CheckACIA = $dca2
Dave
gfoot
Posts: 350
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Re: OS 1.2 serial driver overflow flag bugs - or a feature?

Post by gfoot »

hoglet wrote:
Fri May 13, 2022 6:42 am
I recommend you look at Toby Lobster's excellent MOS 1.20 reassembly, which makes everything clear:
https://tobylobster.github.io/mos/mos/S-s11.html#SP7
Ah yes that looks more accurate, thanks!
Post Reply

Return to “8-bit acorn software: other”