6502 based OS - for real

You need an actual VIC.

Moderator: Moderators

Post Reply
xlar54
Vic 20 Newbie
Posts: 15
Joined: Tue Sep 27, 2005 11:41 pm

6502 based OS - for real

Post by xlar54 »

Guys, I think we are getting really close to pulling this together. Emulation is great, but I would propose we pull it down to a lower level.

There are a couple of projects out there such as Cosmos (for C# developers) which build a bootloader and can run managed code as an operating system. Another example is MikeOS, an x86 package which compiles and build a very simple kernal and OS which can even be programmed in C. MikeOS even has FAT12 support already.

What I am working on is a proof of concept which boots to a 6502 CPU emulator. It uses the guts of VICE for emulation. The goal is a 6502 based operating system on modern hardware.

Im currently using Cosmos. The emulation works, and Im adding a built in ML monitor. The 6502 can only access 64K RAM, but by using undocumented opcodes, we could easily add task switching capability, and access to much more memory. BASIC would be next.

On top of that, add access to external drives, and this could be really interesting. Cosmos is not ready for prime time just yet, so Id like to redo the emulation in x86 using MikeOS as the foundation.

Id be really curious if anyone else out there is liking this idea and would like to get involved.

Here's a quick screenshot. This boots directly from a CD-ROM on any x86 machine:

http://imgur.com/KLY1P.jpg
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

So, what's the point?

1. Your program/OS would emulate a 6502-based computer, that is not supposed to be realised in real HW. This misses the use of an emulator to aid in cross-developing programs.

2. If the purpose of your OS is to provide a platform independent means to run a program, why not use Java? There is no good reason to use a CPU emulation for this, if it only provides a seriously weaker programming model than the host CPU.

3. If you add extra instructions, then it's not a 6502 anymore. Period.
xlar54
Vic 20 Newbie
Posts: 15
Joined: Tue Sep 27, 2005 11:41 pm

Post by xlar54 »

Mike wrote:So, what's the point?

1. Your program/OS would emulate a 6502-based computer, that is not supposed to be realised in real HW. This misses the use of an emulator to aid in cross-developing programs.

2. If the purpose of your OS is to provide a platform independent means to run a program, why not use Java? There is no good reason to use a CPU emulation for this, if it only provides a seriously weaker programming model than the host CPU.

3. If you add extra instructions, then it's not a 6502 anymore. Period.
The goal isnt to use the emulator for cross development - its just tinkering with creating a 6502 based system on moden hardware. Java is obviously too high level for this task. And im not adding new instructions, Im just using instructions that were not designed with any particular purpose, it still executes correctly written 6502 code, which does indeed make it 6502 emulation. For instance, opcode x02, x12, and x22 are known as crash opcodes - serves no purpose but to crash the system. They do nothing else. Using it for something else to extend custom functionality would be just fine. Some instructions dont even function the same way twice on the same chip. I thought about going with full-blown 65816 emulation instead, which provides 6502 mode as well as extended 16 bit mode using the same trick. I just dont know enough about it yet. I do know that that X bit of the staus register is always set on the 6502 and does nothing, so it may also be useful to switch modes or extend functionality.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

I can understand xlar54 - I think he has the same reasons as I had when writing my VirtualCBM (which is basically some sort of pimped CBM emulator). To see if I can do it and just have fun while creating this software. There is no real need for such things, but honestly there is no real need for tinkering with a VIC or any other old computer either...
If I would understand anything about hardware I would built my own 6502 based computer and write an OS for it, this would be lots of fun. As I discovered I like to write tools more than applications or games, so this would fit my preferences.
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

I gather this is a soft project only; it's not targeted for real hardware. If that is the case, like Mike, I am a little curious as to its objective, too. Don't get me wrong, I think it worthwhile for personal achievement to complete such a project -- but you did solicit for others to get involved, too, so it begs a few questions. Specifically for me, what I/O did you have in mind, i.e., video, sound, user inputs, storage, networking, timers? What differentiates this OS from the existing base of emulated home computers?

And like today's cellphones, it's all about the apps. And the apps come from app developers. What's the plan to allow for development on this new platform? Keep in mind that the days of hand-coded assembly are gone, or until peeps like me start to lose their marbles and regress. :P

But then, you mentioned BASIC would be next. So, are you thinking that a high-level interpreted language would be the developer's doorway into this emulated environment, to run their apps on a wide-variety of "modern hardware"? If that's your intention, why bother with an emulated 6502 CPU at all? Or are you taking Microsoft's BASIC for 6502 and re-implementing and extending it on your OS? That seems far too drab for me to want to write an app for it. Am I limited to text? Again, it goes back to the I/O question.

Myself, I have imagined an uncomplicated development environment (like what I grew up with in VIC 20, et al) on today's computers. A way of introducing programming to the masses, without the steep learning curve of Java (free), or the platform-specific and costly Microsoft products, or running it on the complexity from a web-app-db tiered architecture. Sounds like a good objective, but who's looking to invest time tinkering in such a small and limited environment like we had? Children, perhaps, could benefit from it as an educational tool, and BASIC is a good place to start -- but why BASIC on an emulated 6502?

There are so many languages out there already. Dark BASIC comes to mind for the video game enthusiast. Perl, PHP, and Ruby are all easy interpreted languages that can run standalone (to learn their syntax and OOP) and the programmer can grow that skill into today's enterprise apps. And then there is the app and library richness that is JAVA and .NET platform (Microsoft and Mono).

A bit more of your thoughts on where this is going with I/O (emulated, integrated?) and what apps is it targeted for. Regardless, have fun with it.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
xlar54
Vic 20 Newbie
Posts: 15
Joined: Tue Sep 27, 2005 11:41 pm

Post by xlar54 »

Thanks guys. Yeah, Im definitely not imagining the next big thing like a Linux competitor. But I do enjoy tinkering with 6502 assembly, and having a real usable platform to do it on, instead of an emulator, seems like an interesting project to me. I have zero interest in x86 or other CPUs really.

This system boots up running an emulated 6502 CPU, and all the ram in you need. For IO, it is memory mapped, just like the 64 and 128, and the code will be open, so that people can write their own kernals. Right now it does nothing but boot up, hit the BRK instruction at 0000, and end up in a ML monitor.

If nothing else, it will be a learning OS, about simple CPUs. Practically speaking, it could be used to develop just about anything I suppose.

The real question then is, why would one boot up to a raw 6502 environment, instead of use an emulator in a Win32 or Linux environment for things such as this. I guess for simplicity and enjoying the good ol' days directly on modern hardware. If such a machine existed with a real 6502 processor, but running at modern speed, access to modern hardware, Id own one for sure. This project basically aims to be that.
Post Reply