Added emulator as submodule, updated makefile to run directly os in emulator

This commit is contained in:
Daniele Verducci 2023-12-02 09:31:46 +01:00
parent bb5cb5461c
commit aadd328ef3
10 changed files with 21 additions and 51 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "pat80-emulator/z80"] [submodule "pat80-emulator/z80-python-emulator"]
path = pat80-emulator/z80 path = pat80-emulator/z80-python-emulator
url = git@github.com:algodesigner/z80.git url = https://github.com/penguin86/z80-python-emulator.git

View File

@ -34,6 +34,12 @@ There is an experimental and unfinished quick load function using a python termi
![Pat80 Memory Monitor](/assets/media/photos/memory_monitor.jpg) ![Pat80 Memory Monitor](/assets/media/photos/memory_monitor.jpg)
## Emulator
The pat80 memory monitor (the os) can be run in a z80 emulator. This repository contains an emulator as submodule, already set up to run the os.
To try it, head to `pat80-computer/software/z80-assembly/os/Makefile` and run `make run` to build the rom from assembly and start the emulator. You will see some windows showing the emulated computer's memory and register status and the pat80 memory monitor prompt.
![Emulator running Memory Monitor](/assets/media/photos/emulator.png)
## Status ## Status
The project is heavily work in progress. The project is heavily work in progress.

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@ -1,11 +1,17 @@
os: build:
@echo "Building PAT80 rom..." @echo "Building PAT80 rom..."
@z80asm -i main.asm -o rom.bin || (exit 1) @z80asm -i main.asm -o rom.bin || (exit 1)
@echo "Generating label lookup table..." @echo "Generating label lookup table..."
@z80asm -i main.asm -o rom.bin -L 2>&1 | grep "Sys_" > abi-generated.asm @z80asm -i main.asm -o rom.bin -L 2>&1 | grep "Sys_" > abi-generated.asm
@echo "PAT80 Rom size:" @echo "PAT80 Rom size:"
@du -h rom.bin @du -h rom.bin
write: build
@echo "Stretching rom to EEPROM size..." @echo "Stretching rom to EEPROM size..."
@dd if=/dev/zero of=rom.bin bs=1 count=0 seek=8192 @dd if=/dev/zero of=rom.bin bs=1 count=0 seek=8192
@echo "Writing to EEPROM..." @echo "Writing to EEPROM..."
@minipro -w rom.bin -p "AT28C64B" @minipro -w rom.bin -p "AT28C64B"
run: build
@echo "Starting emulator..."
@../../../../pat80-emulator/z80-python-emulator/src/z80sbc.py -b rom.bin

View File

@ -1 +0,0 @@
pat80emu

View File

@ -1,5 +0,0 @@
build:
gcc -g -o pat80emu z80/console.c z80/z80.c main.c
clean:
rm -rf main
all: clean build

View File

@ -1,9 +1,7 @@
# PAT80 Emulator # PAT80 Emulator
Uses algodesigner's Z80 emulator (see submodule in z80 folder). This folder contains a submodule (you should fetch it if you need to run the os in an emulator).
Instances the Z80 object (representing the CPU) and:
- intercepts all memory access and returns the corresponding rom value (read from rom file) if PC is in first 32k of memory (TODO) Uses cburbridge's Z80 emulator written in python. It opens some windows showing the emulated computer's memory map, the cpu registers state and parallel terminal to interact with the os.
- intercepts all memory access and stops execution returning error if trying to write to first 32k of memory (TODO)
## Usage ## Usage
Build with `make all` To run the os in the emulator, head to `pat80-computer/software/z80-assembly/os/Makefile` and run `make run` to build the rom from assembly and start the emulator.
Run with `./pat80emu`

View File

@ -1,34 +0,0 @@
#include <stdio.h>
#include "z80/z80.h"
/*
* The intercept function is invoked on each and every CPU instruction. It
* quits the simulation when the PC register reaches address #0005 by changing
* the virtual CPU status.
*/
static void intercept(void *ctx)
{
z80 *cpu = ctx;
if (PC == 5) {
puts("\nReached address: 5, terminating the simulation...");
cpu->status = 1;
}
}
int main(int argc, char *argv[])
{
/*
* Instantiate the CPU, activate the debug mode, set the intercept
* function and run the virtual CPU until the termination criteria
* set by the intercept function, if any, are met.
*/
z80 *cpu = z80_new();
cpu->debug = 1;
// TODO: Copy rom to first 32k CPU memory
_RamWrite(0x03, 0x76); // As an example, here is how to set HALT at posizion 0x03. Use a loop to copy memory from a PAT80 OS rom file.
z80_set_intercept(cpu, cpu, intercept);
z80_run(cpu);
z80_destroy(cpu);
}

@ -1 +0,0 @@
Subproject commit 80df33fc873e8eb374c1fcb33458a1b7220d20db

@ -0,0 +1 @@
Subproject commit a5dbd3e829a94a2598b42ba976e61353c580600b