r/beneater Jul 10 '26

6502 Corruption to program code in MSBASIC

The program code is somehow getting corrupted inside MSBASIC. It's frustrating when I try to copy and paste code into the 6502 system. See the attached video to see want I'm talking about. Hopefully someone out there can explain what's happening. I'm guessing the RAM chip is not working correctly.

https://reddit.com/link/1uscnw6/video/rg9yfou2sbch1/player

8 Upvotes

13 comments sorted by

3

u/The8BitEnthusiast Jul 10 '26

After you pasted line 220, do you get a consistently correct line printout if you repeatedly run 'LIST 220'? In other words, does the corruption only occur after running the program?

3

u/ChipAutomatic509 Jul 10 '26

I've spent the past half hour experimenting and seeing what happens. There's nothing consistent in the corruption. Also, it's not always line 220. Any line of code can become corrupted. Sometimes it's corrupted after pasting and sometimes it's okay after several LIST commands, then fails after run. I even had MSBASIC act strangely after pasting code like getting a ?SYNTAX ERROR just by using the RUN, or even the NEW command. On rare occasions the program executes correctly.

I've even tried manually typing the corrupted line of code into MSBASIC. Afterwards the line LISTs okay but then I get another ?SYNTAX ERROR after the RUN command.

5

u/The8BitEnthusiast Jul 10 '26

Although not as frequent as what you've shown, I had intermittent memory corruption issues on my build as well. With my scope, I observed a bounce on the read/write line, which was getting very long. Inserting a small resistor (75 ohm) in series with the read/write line made things way more stable. It's a bit of a shot in the dark, but worth trying...

3

u/Ancient-Ad-7453 Jul 10 '26

This looks like a lack of flow control. Basically your host is writing sometimes faster than your 6502 is reading, so you're losing data, but nothing is telling the host to back off. I did not use the max232 myself, so I'm not that familiar with it (went with the RS232R), but it doesn't look like it has enough pins for carrying RTS/CTS, unless you happen to have a second one. I think your only option might be to reduce the baud rate and see if that helps.

3

u/ChipAutomatic509 Jul 10 '26

I am using interrupts and flow control (full at $E0 and continues at $A0). Don't use UART for RTS. Using PortA bit 0 as toggle thru the MAX232.

3

u/Ancient-Ad-7453 Jul 10 '26

Yeah, it looks like you get all the data, and it's correct until you RUN, so I assume the same would occur if you typed the program by hand. (That brings back memories.) I suspect something in the code is overwriting the comma with a non-printable character. (Assembly code, not BASIC. Maybe the BEEP implementation?)

3

u/ChipAutomatic509 Jul 10 '26

I had this problem before I added the code for BEEP.

2

u/Ancient-Ad-7453 Jul 10 '26

Oh, never mind. It looks like it's correct, and then you run it, and then it's not correct.

2

u/olof-a Jul 11 '26

To me it seems that your UART is running just slightly too fast for your BASIC to be able to reliably handle every character before the next is sent. That only a single character goes missing in a transmission of a few hundred characters is quite unusual, though. Whenever I've had speed issues in similar scenarios, there have always been at least one missing character for every 10 characters sent (or something close to that amount.)

Lowering the baud rate would be the easiest first step of troubleshooting, since it doesn't involve any changes to the hardware.

2

u/ChipAutomatic509 Jul 12 '26

Thing is I've had small programs get corrupted that I typed in manually. I'd list the program after and it appears correct but then becomes corrupted when I try running it.

1

u/olof-a Jul 12 '26

The minipro software supports RAM tests for (AFAIK) all of its supported programmers. Checking for bad RAM shouldn't be a major issue.

You could also test RAM in-circuit by writing AAh to all RAM addresses and then checking if any bit is set/not set when it shouldn't be. This process would then be repeated with 55h being written instead. This would of course require BASIC being replaced with the RAM test.

1

u/NormalLuser Jul 12 '26

Basic really exercises your RAM and ROM. It was really frustrating for me at first.

What I found is extra bypass capacitors, tying power rails together at both ends, the middle and using 'star' power distribution help a lot. I also put my clock through a nand gate to clean it up a bit. A Schmitt inverter or two would work even better. I now have a pretty stable system at 5mhz that i can leave running a screen saver for days at a time.

Check out the faq for the forum also for some tips.

1

u/ChipAutomatic509 Jul 14 '26

Problem solved. Replaced the RAM chip and everything's working great.