6502 ROR bug KB9 Basic patch...

34 views
Skip to first unread message

Ronny Ribeiro

unread,
Jan 15, 2023, 10:42:45 AM1/15/23
to PAL 6502 computer
Hi everyone!

I was randomly reading at Hans Otten website and I came across this:
Does anyone know whether the version of KB9 in PAL-1's ROM is patched against this bug?
As the article sais, the patch is supposed to speed up KB9 quite a bit for number crunching.

Best Regards,

Ronny

Jim McClanahan

unread,
Jan 15, 2023, 11:11:06 AM1/15/23
to Ronny Ribeiro, PAL 6502 computer
The ROM has the original, unpatched version of MS BASIC. It does load from ROM into RAM, so you can patch it before you run it. I'd have to check to see if there's room to maybe have a menu option to load and patch.

The other option would be to have a ROM image that has the patched version. (I can't say that I'm married to authenticity which you can see with the working delete/ backspace patches in various pieces of code in the ROM.)

My first computer was an OSI C1P so I've lived with this bug my entire time around computers. :-)

Thanks,
Jim

--
You received this message because you are subscribed to the Google Groups "PAL 6502 computer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pal6502+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pal6502/128cc0ba-d830-49e8-8488-32b1c42595aen%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ronny Ribeiro

unread,
Jan 15, 2023, 3:42:44 PM1/15/23
to PAL 6502 computer
Hi Jim, thanks for the reply.

I did manage to patch KB9 directly from the memory. It worked: patched image runs 10% faster for a typical floating point calculation (determination of pi).
I wonder how many programs written back in the day are working around this bug. The bugged 6502 batch affected many KIM computers, so I think a lot of software were written with a work around for them.
The 6502 processors that have the ROR bug are ceramic/gold packaged, extremely rare because MOS Technologies corrected the problem for subsequent batches right on 1976, so It is guaranteed that none of us, PAL owners, have one in our beloved computers XD (they are really museum pieces!)
I'm gonna create a patched version of the ROM image so those who have a EPROM programmer can give it a try.

Best Regards,

Ronny

Jim McClanahan

unread,
Jan 15, 2023, 4:29:54 PM1/15/23
to Ronny Ribeiro, PAL 6502 computer
The code to build various versions of 6502 BASIC is here:


It doesn't seem to be as easy as looking at the table though. OSI ran their first batch of ROMs for the 400 superboard. That was old enough where it probably wasn't safe to assume you could use ROR. Later versions (after 1977) apparently assumed the ROR instruction worked. (These were mainly produced by OSI, so they weren't as likely to have scrounged parts as the earlier bargain boards.)

If you had a disk system, I believe all versions of BASIC in RAM used the ROR code.

The later OSI ROM also had the garbage collect bug. I'm not sure if the older ROMs had that problem or not. To be honest, I had always assumed there was just one version of BASIC in ROM for OSI until today. I'm going to have to dig a little deeper.

Thanks,
Jim W4JBM

Ronny Ribeiro

unread,
Jan 15, 2023, 5:31:17 PM1/15/23
to PAL 6502 computer
Here follows the patched ROM image.  
I tested it and it seems to be working. It is around 10% faster in floating point calculations.
Best Regards,

Ronny
PAL1_ROM_v1.0_KB9_ROR_patched.bin.zip

Hans Otten

unread,
Jan 19, 2023, 9:44:36 AM1/19/23
to PAL 6502 computer
Thanks for this version.

See First example 

I compiled from source from Pagetable, flag ROR workaround to false, CLD added 

; CONFIG_NULL := 1                      ; patch HO 2021
;CONFIG_ROR_WORKAROUND := 1             ; patch HO 2021
  • In init.s add this line at label COLD_START

    COLD_START:
    .ifdef SYM1
            jsr     ACCESS
    .endif
    .ifdef KBD
      .
      .
      .
    .else
      .ifndef CBM2
            cld                     ; patch for KIM-1 HO 2021
            ldx     #$FF
            stx     CURLIN+1

With these flags I made KB6: much faster, smaller, less accurate

; CONFIG_NULL := 1                      ; patch HO 2021
;CONFIG_ROR_WORKAROUND := 1             ; patch HO 2021
CONFIG_SMALL := 1                       ; patch H0 2021

Reply all
Reply to author
Forward
0 new messages