Working with the original MS BASIC 6502 code on my Mac/Unix

I’ve always wanted to experiment with the MS parser, and now that they have released the code that’s a possibility.

But that code appears to be in MACRO-11 or something similar, and none of the compilers I can find will handle it. An assembler isn’t very hard to write, but I’d STRONGLY prefer to use an existing one. Any pointers?

On the same topic, what about running the resulting code? There’s any number of 6502 emulators out there, and I’m leaning in the direction of a KIM-1 version because that’s the simplest and there’s C code out there. But am I overlooking something more obvious?

1 Like

What about the versions released in the past. e.g.

I’ve used this to succesfully create various MSBasics that I’ve run on my own 6502 SBCs…

Build your own SBC. Or build someone elses. The Ben Eater project will work well for this. There is also a nice one I used a while back when I was building my own SBCs - it’s called Symon and written in Java, so ought to “just work”. It was fine on my Linux desktop..

Hope it goes well. Many 6502 fans here :slight_smile:

-Gordon

1 Like

Regarding running object files, speaking for the PET, VICE lets you mount ROM images (“.bin” files) in the Settings > Settings > Machine, selecting the ROM tab.
Similarly you may drag-and-drop bin-files on the web-based PET emulator at masswerk.at/pet. (Best include the base address in hex in the filename to identify the ROM slot this should go into. See masswerk.at/nowgobang/2023/pet-option-roms for what ROM slots / partitions are available on various PETs.)

This way, you will have (a) the entire target environment readily available (i.e., I/O and memory is already in place, just as expected by the code) and (b) may experiment with just a particular modification, while everything else still relies on the standard ROM.
(Both emulators mentioned above may have issues with IEEE-488 bus emulation for various unrelated reasons, though.)

I guess, other emulators will have similar capabilities. And, of course, VICE does also C64 emulation.

1 Like

Quick update:

I decided to go with the mist64 version of mbasic as that works under cc/ca65. I considered modifying an existing assembler to ready MACRO code, which is not difficult, but this seems like something that is likely to make other people less inclined to try it. And the mist64 version is close enough to the original to fit my needs.

I’ll definitely be testing using the online PET emulator, which is my platform of choice for “canonical” MS BASIC. But I also wanted something even more generic and local, so I went looking for a really simple 6502 emulator platform. I did look at Sysmon, but I’m not a Java guy.

So I’m currently using bsoz, which is only a couple of pages of C code. It has versions of the Apple I and KIM-1, but the KIM code is missing the terminal emulation so it’s not all there yet. I don’t think that will be a major issue.

I have added the ability to load ROMs using positional parameters:

bsoz kim1.rom@0 mbasic.rom@2000

Now I’m working on statistics and I’m looking for input here. I have added the underlying code - just a table of 256 32-bit words that hold the number of times any particular opcode is called.

But my concern is that it’s either on or off right now, and that’s not really what I need - I want to benchmark particular bits of work in mbasic, not things like how many cycles it burned printing “H”.

This is something you can do in a debugger by issuing “trace on” or somesuch, but ideally I’d like to automate this on the command line so I can automate collection.

I’m wondering if anyone has any suggestions on how I might do this?

I thought of added a switch like --trace 0200-0400,600-780 and such, but that seems like something that would grow to infinite size in real-world use.

I also thought of adding fake opcodes for things like trace-on and print-stats, but that would require modifying the original source and I’m souring on that approach.

Anyone have any ideas?

I think in the past I’ve used fake opcodes - or possibly BRK instructions - for this kind of talk-to-the-emulator-machinery thing. But a complex command line is another approach, and I’m pretty sure I’ve used that too. Often in an adhoc way, changing the source temporarily to measure something of interest.