Skip to content

sccreeper/goputer

Repository files navigation

goputer logo

Go + Computer = goputer


A computer emulator/virtual machine that intends to demonstrate how basic computers work at a low level.


Contents


Features

Complete

  • Custom assembly language and compiler.
  • Custom runtime.
  • Standalone executables.
  • Frontends to show VM output.
  • A WASM based runtime that runs in a web browser.
  • Expansion cards/modules.

Working on

  • IDE for easy development.

In the future

  • Rewrite of compiler.
  • High level language.
  • Non-native plugins via Lua.

Documentation & getting started.

See the project wiki or try the playground at goputer.oscarcp.net.


Project layout

  • frontends Contains source for the frontends.
  • frontends/web The WASM frontend.
  • frontends/gp32 The Go frontend.
  • frontends/goputerpy The Python frontend.
  • examples A list of example code to get started with.
  • cmd/goputer The CLI tool for compiling, running & disassembling code.
  • cmd/launcher The GUI for running code.
  • pkg Shared code. Includes the compiler, VM runtime and constants for instructions and registers.

Build instructions

Build instructions for Linux, other platforms are not supported at the moment as native plugins do not work at all. See plugin

Docker

If you have Docker installed, you can build goputer in Docker without installing additional dependencies by running:

./docker_entrypoint.sh

This will build the container and then run mage dev inside the container, outputting to the build directory.

Note: This uses a Fedora container, so the output will only work on Linux based systems.

Linux

Perquisites

  • Languages

    • Python ^3.10
    • Go ^1.19
    • NodeJS ^18.X
  • Build tools

  • Library requirements

    Requirements for different display servers & audio.

    Ubuntu
    x11
    libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev
    
    Wayland
    libgl1-mesa-dev libwayland-dev libxkbcommon-dev 
    
    Audio
    libasound2-dev
    
    Fedora
    x11
    mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel
    
    Wayland
    mesa-libGL-devel wayland-devel libxkbcommon-devel
    
    Audio
    alsa-lib-devel
    

Building

  1. Install the prerequisites that are mentioned above.

  2. Check that everything works.

    $ node --version
    v18.12.1
    $ mage --version
    Mage Build Tool v1.14.0
    Build Date: 2022-11-09T16:45:13Z
    Commit: 300bbc8
    built with: go1.19.3
    $ poetry --version
    Poetry version 1.1.13
    
  3. Clone the repository from GitHub

    git clone https://github.com/sccreeper/goputer
    cd goputer
    
  4. Build the project. (This step shouldn't take that long depending on your hardware)

    mage dev
    

    Alternatively you can run mage all to not build the examples.

  5. Go to the build directory and run the hello_world example.

    cd build
    ./goputer run -f gp32 -e ./examples/hello_world
    

Testing

There a small suite of tests written for testing the core of goputer.

To run them use:

go test ./tests -v

Credits

GP32 Frontend

goputerpy Frontend

Web playground/frontend.

CLI tool

  • CLI - urfave/cli
    • Used by the compiler for getting input from the terminal.
  • Color - fatih/color
    • Used for colouring & formatting the terminal output i.e. making it look nice.
  • Termlink - savioxavier/termlink
    • Inserting links into the terminal.

GUI launcher

Other


License

MIT - Refer to the LICENSE file

About

A computer emulator/virtual machine intended to demonstrate how computers work at a low level.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published