Posted By
GeorgeHug on 2021-11-14 13:37:36
| Error in Plus/4 Kernal Rom
I posted about this in comp.sys.cbm, and Fonsis suggested I post it here as well.
I was going over some of my old CBM files from back in the day, and ran across an error I had found in the Plus/4 kernal rom. I don't think I ever found a way to report it to anyone, so I thought I would see if anything has changed.
The error is in the 6551 ACIA servicing routine where a byte is read in from the ACIA:
LDA $FD00 BEQ $EAC2 STA $07D5
Incoming bytes are first stored at $07D5, and later moved from there into the input buffer. But as the rom is written, any null byte (00) received would be later stored as whatever the most recent non-null byte was. And it's impossible to receive a null byte. The solution is to reverse the second and third instructions:
LDA $FD00 STA $07D5 BEQ $EAC2
Or you could duplicate the beginning of the IRQ servicing up to this point in your code, with the correction, then jump back into the rom.
Of course, this being the Plus/4, it may be that nobody would ever care about this, but it would be nice to make a record in case anyone ever wanted to make other revisions to the ROM, or actually make use of the UART capability of the Plus/4.
George Hug
|
|
Posted By
gerliczer on 2021-11-14 13:42:42
| Re: Error in Plus/4 Kernal Rom
My memory is a bit hazy on this but I think SVS has already documented this in his Ultimate Map. Am I right? Nonetheless, thank you very much for sharing your knowledge.
|
|
Posted By
Csabo on 2021-11-14 14:04:11
| Re: Error in Plus/4 Kernal Rom
Yes, it there:
|
|
Posted By
GeorgeHug on 2021-11-25 19:10:36
| Re: Error in Plus/4 Kernal Rom
In case anybody might need it, I decided to write replacement IRQ servicing code that bypasses the error in the kernel rom. It duplicates the first part of the IRQ servicing routine, does the ACIA stuff, then jumps back to ROM for all the other IRQ stuff. There's a BASIC loader that installs the new code (120 bytes) into the tape buffer (but it could go anywhere below $8000). In addition to fixing the BEQ problem, I took out all the xon/xoff software flow control code, which I think is useless. I don't have a CBM machine anymore, so I have no way to test the new code. Anyway, this might be an easier fix than flashing a new rom.
I'll list the BASIC program and the source code for the ML portion below. If anyone wants the actual .PRG, it can be found in my Github CBM repo:
https://github.com/gbhug5a/My_CBM_stuff
10 rem this code bypasses the "beq" bug 12 rem in the +4's irq acia received- 14 rem byte routine, and eliminates the 16 rem xon/xoff software flow control 18 rem code in both xmit and receive. 20 rem the irq service routine vector 22 rem ($0314) normally points to $ce0e. 24 rem this code duplicates that code up 26 rem to the acia, fixes that, then 28 rem jumps back into rom. the code is 30 rem poked into the cassette buffer at 32 rem $0333, but can be placed anywhere 34 rem visible in ram when kernel and 36 rem basic roms are banked in. sys 38 rem to the first byte to take over 40 rem $0314. no need to re-assemble for 42 rem a different location. the code 44 rem detects where it has been placed. 46 rem sys (first byte + 26) to restore 48 rem the the $0314 vector to $ce0e. 100 cb = 819 110 for i = 0 to 119 120 read a 130 poke cb+i,a 140 next 150 sys cb 160 v= (peek(789)*256) + peek(788) 170 print "irq ram vector now";v 180 data 120,32,85,252,186,202,189,0 190 data 1,24,105,36,141,20,3,232 200 data 189,0,1,105,0,141,21,3 210 data 88,96,120,169,14,141,20,3 220 data 169,206,141,21,3,88,96,173 230 data 9,255,41,2,240,3,32,96 240 data 206,44,216,7,16,63,173,1 250 data 253,141,212,7,16,55,173,212 260 data 7,41,8,240,24,173,212,7 270 data 41,247,141,212,7,173,0,253 280 data 141,213,7,173,211,7,201,63 290 data 240,3,32,220,234,173,212,7 300 data 41,16,240,17,173,16,253,41 310 data 2,240,10,162,0,44,206,7 320 data 16,3,32,131,234,76,43,206
.6502
;code to bypass error in +4 acia irq receive-byte routine, ;and eliminate xon/xoff software flow control for ;transmit and receive.
.org $0333 ;object code can be moved anywhere ; without reassembly ;sys entry to set irq vector to newirq ;sys restore (entry + 26) to restore ; default vector
entry:
sei jsr $fc55 ;just rts there tsx ;pc now in stack dex lda $0100,x clc adc #(newirq - entry - 3) ;point to newirq sta $0314 inx lda $0100,x adc #0 sta $0315 ;irq vector now newirq cli rts ;return from sys
restore: ;restore = entry + 26
sei ;restore vector to $ce0e lda #$0e sta $0314 lda #$ce sta $0315 cli rts
newirq: ;$035a (858) if entry = $0333
lda $ff09 ;not related to acia and #$02 beq checkacia jsr $ce60
checkacia:
bit $07d8 ;acia present? bpl backtorom lda $fd01 ;read status reg sta $07d4 ;save status reg bpl backtorom ;bit 7 set if acia triggered irq
receive:
lda $07d4 ;new byte received? and #$08 beq transmit lda $07d4 and #$f7 sta $07d4 lda $fd00 ;new byte sta $07d5
lda $07d3 ;number of bytes in queue cmp #$3f beq transmit ;discard byte if full
jsr $eadc ;add new byte to input queue
transmit:
lda $07d4 and #$10 ;transmit buffer empty? beq backtorom lda $fd10 ;pin k of user port = cts and #$02 beq backtorom ;modem says don't send ldx #$00 bit $07ce ;anything to send? bpl backtorom jsr $ea83 ;send it
backtorom:
jmp $ce2b ;acia done, continue rest of irq
|
|
Posted By
Hifi on 2021-11-26 08:06:18
| Re: Error in Plus/4 Kernal Rom
Hey GUYs! Helló,helló Újra Itt Vagyok!!!! Ezt 30évekkel ezelőtt kellett volna észre venni ,DE NEM...... DE MOST is IDŐSZERÜNIK tűnik.... DE NAGY KÖSZÖNET a FELISMERÉSNEK...... CSAK a JÓINDULAT SZÓL belőlem...... HiFiofTLT
| Re: Error in Plus/4 Kernal Rom
Hey GUYs! Hello, hello here I am again!!!! This should have been noticed 30 years ago, BUT IT WASN'T...... BUT EVEN NOW it seems TIMELY.... BUT THANK YOU SO MUCH FOR FINDING THIS...... I'm speaking with ONLY the BEST INTENTION...... HiFiofTLT
|
|
Posted By
GeorgeHug on 2021-12-15 17:45:29
| Re: Error in Plus/4 Kernal Rom
I've completely rewritten the alternate ACIA servicing code. The new version is on my Github:
https://github.com/gbhug5a/My_CBM_stuff/tree/main/Plus4_IRQ_ACIA_error
In addition to the "BEQ" error, it now fixes the double-interrupt problem on transmit, and turns off transmit interrupts if there's no outgoing traffic.
I have no way to see if the new code works. I've looked at a number of Plus/4 terminal programs, and most of them bring their own servicing code with them, so they wouldn't benefit from what I've done. One exception is Higgyterm for the Plus/4, which as far as I can tell just uses all the Kernal stuff as is. It might be interesting to see if Higgyterm would run better with my code pre-installed.
Anyway, thanks for everyone who helped me get this finished. It's been hanging for 30 years, and I just needed to get it done.
|
|
|