Skip to content

estarq/i8051emu

Repository files navigation

i8051emu

i8051emu

A free and open-source Intel 8051 emulator built with Python (Brython) and React (with MUI) as a final thesis (BE).

Building

Clone the repo (Installing Git):
git clone https://github.com/estarq/i8051emu

Change directory:
cd i8051emu

Use Compose (Installing Compose):
docker compose up -d

or

Build an image:
docker build -t i8051emu .

Run as a container:
docker run -d -p 3000:3000 --name i8051emu i8051emu

Web

Install dependencies (Installing Node.js):
npm install --legacy-peer-deps

Compile JSX, bundle up dependencies, optimize the output:
npm run build

Electron

Follow the steps for Web, then:

Change directory:
cd electron

Install dependencies:
npm install

Build for Mac (arm64, x64):
npm run distMac

Build for Linux (AppImage):
npm run distLinux

Build for Window:
npm run distWindows

Executable files are saved to electron/dist/.

Webserver is required because of restrictions of the "file" protocol (Brython makes Ajax calls), thus Electron app utilizes Express to serve static content and the firewall may prompt to accept incoming network connections.

Tests

Most of the python code is covered with unit tests (pytest).
Please note that because of Brython, not everything that passes the tests is guaranteed to work, so it's necessary to test everything in a browser.

Download

Mac, Linux, Windows

Download the latest release.

Pull from Docker Hub:
docker pull estarq/i8051emu
Superuser privileges may be required.

Installation

Mac

Doubleclick on .dmg file and move i8051emu.app to Applications.

Linux

Doubleclick on .AppImage file.
Make it executable if necessary:
chmod +x i8051emu-1.0.0.AppImage

Windows

Doubleclick on .exe file.

Download an image and run it as a container:
docker run -d -p 3000:3000 --name i8051emu estarq/i8051emu
Superuser privileges may be required.

How to use

App Bar Icons

1st - Loading an Intel HEX file from the disk
2nd - Resetting the state of the microcontroller leaving the content of the ROM
3rd - Execution of the next instruction
4th - Execution of the program up to the clicked row
5th - Automatic execution of the next instruction every 500 ms. When clicked, the icon turns into a pause button

Main Table

Each line represents one assembly instruction.
The row highlighted in blue is next in the sequence of program execution.

Description of the columns:
Addr - the ROM address where the instruction is stored
Bytes - number of bytes (1-4) that the instruction occupies in the ROM memory
Opcode - instruction machine code (0-255)
Arg1, Arg2 - subsequent arguments of the instruction (0-255 each)
Mnemonic - disassembled form of the instruction

All numbers except those ending with h (hexadecimal numbers) are decimal.

Memory Table

Contains consecutive cells of the selected memory (RAM by default). The memory type can be changed by selecting the desired memory type from the drop-down list. Rendering is virtualized using react-virtualized and mui-virtualized-table, which causes errors in browsers not based on Chromium.

All numbers are decimal.

Key Registers Table

Contains the most important registers of the microcontroller along with their values.

All numbers are decimal.

Flags Table

Contains flags of IE, IP, PSW, TCON, and TMOD registers. The flag name in bold indicates that it is set.

Ports Table

Contains consecutive bits (binary representations) of the P0-P3 ports.

External Devices Table

Contains consecutive bits (binary representations) of the CSDS, CSDB, CSKB0, and CSKB1 registers.

State Icons

1st - Seven-segment display
2nd - Buzzer
3rd - LED

The device icon in bold indicates that the device is on.

Seven-segment Display

The digits (with dots) represent the state of the CSDS register. The segments represent the state of the CSDB register.

Sequential Keyboard

This keyboard is associated with a seven-segment display and uses the CSDS register to determine whether to respond to a given key.

In continuous operation mode (next instruction every 500ms), hold the button for a while so that the microcontroller has enough time to notice the change.

Matrix Keyboard

This keyboard is not associated with a seven-segment display. Clicking on the button changes the relevant bit in the CSKB0 or CSKB1 register.

In continuous operation mode (next instruction every 500ms), hold the button for a while so that the microcontroller has enough time to notice the change.

License

Licensed under the MIT license.