fox32 - a 32 bit fantasy computer

Share unrelated electronics stuff, ideas, rants, etc!
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

fox32 - a 32 bit fantasy computer

Post by ry755 »

Hi! This is my project that I've been working on for the past year and a half or so, called fox32. It's a fantasy computer (basically meaning an emulator for an architecture that doesn't exist in real life) based around a custom 32 bit CISC architecture.

The fox32 virtual machine consists of 64 MB of RAM and 512 KB of ROM. Contained in the ROM portion of the address space is fox32rom, which handles things like booting fox32os and basic stuff like drawing text to the display. Along with the CPU are various peripherals like a 640x480 video display, disk controller, RTC, keyboard and mouse, and serial port.

Here is a screenshot of fox32os, the main operating system for fox32, completely written in fox32's assembly language:

Image

Current fox32os features include:
- Cooperative multitasking
- Basic window management
- Basic widget system
- Custom relocatable executable format
- Custom filesystem (super basic at the moment)
- Event-loop-based programming paradigm

Here's a quick example of what the fox32 assembly code syntax looks like. This should look familiar for anyone used to x86 or AVR assembly:

Code: Select all

; text drawing demo

    mov r0, string     ; pointer to string
    mov r1, 16         ; X pos
    mov r2, 16         ; Y pos
    mov r3, 0xFFFFFFFF ; foreground color
    mov r4, 0xFF000000 ; background color
    call draw_str_to_background

yield_loop:
    call yield_task
    rjmp yield_loop

string: data.str "hello world!" data.8 0

    #include "fox32rom.def"
    #include "fox32os.def"
The source code for everything can be found here: https://github.com/fox32-arch
There is also a Discord server for talking about development: https://discord.gg/2Tun7FnUZ2
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: fox32 - a 32 bit fantasy computer

Post by Artcfox »

Wow! That is quite a project! Very impressive that you built up an OS around it as well. :o
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: fox32 - a 32 bit fantasy computer

Post by ry755 »

Thank you! It's been quite a learning experience :D
User avatar
danboid
Posts: 2076
Joined: Sun Jun 14, 2020 12:14 am

Re: fox32 - a 32 bit fantasy computer

Post by danboid »

"Wow!

That's one ambitious project and I see you already have more than a few github contributors onboard. Impressive!

What is the closest cpu arch to your fox32? Does it have a primary inspiration? Do you plan to convert the emulator into VHDL eventually thus making it into an actual computing platform? Thats probably some way off yet.

Have you tried Serenity or Haiku? What is your fave non mainstream OS? Does your OS intend to be compatible with anything else out there like POSIX, eventually?"

Said the unicorn to the foxes.
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: fox32 - a 32 bit fantasy computer

Post by ry755 »

danboid wrote: Sat Feb 18, 2023 6:11 am "Wow!

That's one ambitious project and I see you already have more than a few github contributors onboard. Impressive!
Thank you!! :D
danboid wrote: Sat Feb 18, 2023 6:11 am What is the closest cpu arch to your fox32? Does it have a primary inspiration? Do you plan to convert the emulator into VHDL eventually thus making it into an actual computing platform? Thats probably some way off yet.
Hmm, I'd say the opcode encoding is somewhat similar to x86 because of the highly variable-length instructions (a single instruction can be up to 10 bytes long), while also being similar to the Parallax Propeller because any instruction can optionally be made conditional. If we're just talking about the assembly mnemonics and syntax then definitely x86. As for converting it into something runnable on an FPGA (personally I prefer SystemVerilog instead of VHDL), maybe I'll look into that in the future, but right now I don't have enough experience with hardware design and description languages to do something like that yet.
danboid wrote: Sat Feb 18, 2023 6:11 am Have you tried Serenity or Haiku? What is your fave non mainstream OS? Does your OS intend to be compatible with anything else out there like POSIX, eventually?"
I've tried both Serenity and Haiku! I really love both of them, I just wish they were more compatible with the software that I need to use. My favorite non-mainstream OSes would probably be the BSDs (are those considered mainstream? probably not?). My OS isn't compatible with anything existing, its design is honestly kinda weird and if I were to ever rewrite it someday, I'd probably go with a Unix-like design. Another thing I'd change is the fact that fox32 has a paging MMU but fox32os doesn't currently use it, everything lives within a flat address space. I think it would be neat if each process lived within its own address space like what modern OSes do.
danboid wrote: Sat Feb 18, 2023 6:11 am Said the unicorn to the foxes.
Hehe, the foxes say hi to the unicorn :D
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: fox32 - a 32 bit fantasy computer

Post by ry755 »

Oh also I forgot to mention, there is a somewhat slow and work-in-progress emscripten build! You can check out fox32 in your browser at https://foxboy.dev/fox32.
User avatar
danboid
Posts: 2076
Joined: Sun Jun 14, 2020 12:14 am

Re: fox32 - a 32 bit fantasy computer

Post by danboid »

Because the BSDs are UNIX I do consider them to be mainstream. I consider FreeBSD and OpenBSD to be mainstream, just about.

Cool to hear that you've tried both Serenity and Haiku. What are the main apps don't have Haiku ports that you need for what you do? Most of the apps I use personally have been ported to Haiku, all I'm waiting on now is hardware virtualisation (for qemu or virtualbox), better GPU / multi monitor support and Qt printing support and then I could probably switch to Haiku at home for most stuff. I'd like to think that day isn't too many years away now but progress on Haiku is pretty slow.

For anyone here who hasn't tried Haiku yet, dust off one of your crappy old x86 pcs or laptops and install Haiku from a equally crappy USB disk and watch how fast it installs. It installs faster than it boots somehow. You'll likely want to switch to Haiku too after seeing how fast it installs and how fast it runs.

I've not tried it yet but Haiku now has a wine port so that potentially fills in many missing app gaps if they run under wine.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: fox32 - a 32 bit fantasy computer

Post by Artcfox »

ry755 wrote: Sat Feb 18, 2023 6:40 am Oh also I forgot to mention, there is a somewhat slow and work-in-progress emscripten build! You can check out fox32 in your browser at https://foxboy.dev/fox32.
This is impressive! It even has a painting program!
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: fox32 - a 32 bit fantasy computer

Post by ry755 »

danboid wrote: Sat Feb 18, 2023 6:59 am Because the BSDs are UNIX I do consider them to be mainstream. I consider FreeBSD and OpenBSD to be mainstream, just about.
Yeah that's fair, I guess any Unix-based system is mainstream :P
danboid wrote: Sat Feb 18, 2023 6:59 am What are the main apps don't have Haiku ports that you need for what you do?
Mainly a modern web browser honestly, although I just did some quick research and it looks like Epiphany now has a port for Haiku, so that might fill that gap. I also use Discord a lot but if it works in Epiphany (haven't checked) then that's fine. I also sometimes do schematic and PCB design using KiCad. I use Visual Studio Code with tons of extensions as my main development environment for basically everything, and I'm so used to it that I don't know if I would be easily willing to give it up. :P
danboid wrote: Sat Feb 18, 2023 6:59 am I've not tried it yet but Haiku now has a wine port so that potentially fills in many missing app gaps if they run under wine.
I haven't done any research on this but I wonder how well Electron applications run under Wine (mainly interested in VS Code). I kinda doubt they would run well, if at all.

I should try compiling fox32 on Haiku, I'm sure it would work without any changes considering it only uses SDL2.
User avatar
danboid
Posts: 2076
Joined: Sun Jun 14, 2020 12:14 am

Re: fox32 - a 32 bit fantasy computer

Post by danboid »

ry755 wrote: Sat Feb 18, 2023 8:56 am I should try compiling fox32 on Haiku, I'm sure it would work without any changes considering it only uses SDL2.
I expect so. cuzebox built for me under Haiku with no modifications to the Linux code.
Post Reply