Giter VIP home page Giter VIP logo

mpmp-emu's Introduction

MPMP Emulator

TUI emulator and debugger for a custom 16-bit CPU previously designed at HTWK Leipzig "MPMP" course. Alt text

Build

Use rustup (https://www.rust-lang.org/tools/install) or use your systems package manager to install a Rust tool chain. Clone the repo, enter the root directory and do:

cargo build --release

or

cargo run --release

The executable will be located at target/release/mpmp-emu.

Usage

Make sure to use a sufficiently sized terminal window, the emulator is designed to run in fullscreen mode.

All keybindings are explained inside the application. Press [F1] to open the help screen.

Optionally it is possible to specify an input file as the first command line argument (mpmp-emu <file>), otherwise simply load files from inside the application.

This software is designed to work with the masm assembler (https://gitlab.com/moseschmiedel/masm) output and thus files are expected in ASCII hex format (see example below). Note that the hex words must be exactly 5 digits (and thus 20 bits) in length.

00a58 000a0 01108 00659 
00106 ffb5a 0007f 00090 
0068f 00868 00105 00280 
00105 0068f 00868 00105

See the helpers directory for examples in assembly code and their machine code counter parts.

mpmp-emu's People

Contributors

bubba2k avatar

Watchers

 avatar

mpmp-emu's Issues

Example assembly files (syntactically) incompatible with latest version of complementary assembler

The latest version of the assembler for this ISA (masm https://gitlab.com/moseschmiedel/masm) designed to be used with this emulator uses the ; symbol to lead single line comments. The assembly files supplied in the helpers/assembly directory (https://github.com/bubba2k/mpmp-emu/tree/main/helpers/assembly) however, use the # characters for this purpose, since the emulator was written with a personal fork of the assembler in mind.

Fix this for consistencies sake!

Vastly improve documentation

Give the README a nice facelift.
Documentation is sparse right now. The following should be better documented:

  • Full list of the emulators features
  • How to use the emulator
  • The ISA (ideally every single instruction, fair bit of work)

Update version of mio to 8.11 or greater

The version of the mio package used in this software suffers from a somewhat critical bug / vulnerability (CVE-2024-27308). Considering this emulator does not connect to the internet, this is somewhat low-priority but should be taken care of.

Facelift and refactoring

Some of this code does not look as nice as it could/should. Have a look and improve if and where necessary.

Particularly this function could maybe look a bit nicer:

fn update_cpu(&mut self) {
// If program empty or cpu halted, skip
if self.program.operations.len() == 0 || self.cpu.received_halt {
return;
}
// Free running
if self.cpu_running && self.execution_timer.has_elapsed() {
self.cpu.execute_next_prog_op(&self.program);
self.execution_timer.reset();
if self.cpu.received_halt {
self.message_log.log(Message::new(
MessageType::Info,
String::from("CPU received halt."),
))
}
}
// Single step
if self.cpu_step_requested {
self.cpu.execute_next_prog_op(&self.program);
if self.cpu.received_halt {
self.message_log.log(Message::new(
MessageType::Info,
String::from("CPU received halt."),
))
}
self.cpu_step_requested = false;
}
// Stop if a breakpoint got reached
if (self.cpu_running || self.cpu_step_requested)
&& self.program.breakpoints[self
.cpu
.pcounter
.clamp(0, (self.program.operations.len() - 1) as u16)
as usize]
{
self.cpu_running = false;
self.message_log.log(Message::new(
MessageType::Info,
format!("Reached breakpoint at {:#X}", self.cpu.pcounter),
))
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.