4 Commits

7 changed files with 36 additions and 75 deletions

View File

@ -35,8 +35,8 @@ There is an experimental and unfinished quick load function using a python termi
![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/` 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.
The pat80 memory monitor (the os) can be run in a z80 emulator. You can find a very simple one I wrote ad hoc in `pat80-emulator`. It's based (and depends on) the excellent [Z80 emulator library by redcode](https://github.com/redcode/Z80). Follow the instructions on `pat80-emulator/README.md` to build and run it.
The emulator requires a rom file to run. To obtain a pat80 rom, head to `pat80-computer/software/z80-assembly/os/` 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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -1,3 +1,5 @@
PAT80_EMU_PATH := "../../../../pat80-emulator/build/pat80-emulator"
build:
@echo "Building PAT80 rom..."
@z80asm -i main.asm -o rom.bin || (exit 1)
@ -13,5 +15,9 @@ write: build
@minipro -w rom.bin -p "AT28C64B"
run: build
@echo "Starting emulator..."
@../../../../pat80-emulator/z80-python-emulator/src/z80sbc.py -b rom.bin
@echo "Starting emulator" $(PAT80_EMU_PATH)
@if [ -f "$(PAT80_EMU_PATH)" ]; then\
"$(PAT80_EMU_PATH)" "rom.bin";\
else\
echo -e "\e[31mYou must build the emulator first. Check pat80-emulator/README.md\e[0m";\
fi

View File

@ -1,15 +1,24 @@
# Pat80 Operating System and Memory Monitor
## Intro
This folder contains the Pat80 Operating System.
It is a System Monitor that makes available also some system API to access hardware (monitor, sound, keyboard, parallel terminal...).
## Build
### Requirements
z80asm, minipro
z80asm
minipro (if you want to write to an EEPROM)
### Make
The os can be build issuing command `make`.
The os can be **built** issuing command `make build`.
Two files will be generated:
- `rom.bin` is the rom file to be flashed on the eeprom
- `abi-generated.asm` is the file to be included in any Pat80 application to access system APIs (see README.md in ../applications/)
The build routine will then try to write the rom to a MiniPRO.
The os can be **written to an EEPROM** with a minipro-compatible programmer issuing command `make write`. This runs the build and then tries to write the rom to a MiniPRO.
The os can otherwise be **runned in the emulator** issuing command `make run`. This requires to have the emulator executable already built (follow the instructions on `pat80-emulator/README.md` to build it).

View File

@ -111,7 +111,7 @@ IO_7: EQU 0xE0
;include 'drivers/hd44780.asm'
;include 'drivers/keyboard.asm'
include 'drivers/ps2_keyboard.asm'
;include 'drivers/ps2_keyboard.asm'
include 'drivers/arduino_terminal.asm'
include 'drivers/sn76489.asm'
include 'monitor.asm'

View File

@ -25,7 +25,6 @@
; S (SET) $pos $val Replaces byte at $pos with $val
; L (LOAD) $pos $val
; R (RUN) $pos Starts executing code from $pos
; A (ADB) Enters in Assembly Depoy Bridge mode: loads all the incoming bytes in application memory and starts executing.
; The commands are entered with a single letter and the program completes the command
include 'libs/strings.asm'
@ -38,13 +37,13 @@ MON_COMMAND_SET: DB "SET",0
MON_COMMAND_ZERO: DB "ZERO",0
MON_COMMAND_LOAD: DB "LOAD",0
MON_COMMAND_RUN: DB "RUN",0
MON_COMMAND_ADB: DB "ADB",0
MON_COMMAND_MEMTEST: DB "MEMTEST",0
MON_COMMAND_QUIT: DB "QUIT",0
MON_ARG_HEX: DB " 0x",0
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nMEMTEST checks ram boundaries\nQUIT exits",0
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD [ADDR] loads a program or data from tape at ADDR\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nMEMTEST checks ram boundaries\nQUIT exits",0
MON_MSG_ADB: DB 10,"Waiting for data.",0
MON_ERR_SYNTAX: DB " Syntax error",0
MON_COMMAND_LOAD_PRESSPLAY: DB "Press play on tape",0
; MON_RAMTEST_INTRO: DB " Checking memory... ",0
; MON_RAMTEST_RAMSTART: DB " Ram starts at 0x",0
MON_DUMP_BYTES_LINES: EQU 8
@ -84,9 +83,6 @@ Monitor_main:
ld hl, MON_COMMAND_RUN
cp (hl)
jp z, monitor_run
ld hl, MON_COMMAND_ADB
cp (hl)
jp z, monitor_adb
; ld hl, MON_COMMAND_MEMTEST
; cp (hl)
; jp z, monitor_memtest
@ -298,10 +294,18 @@ monitor_zero: ; TODO: bugged, doesn't exit cycle
ld (hl), 0 ; set byte to 0 in memory
ret
; Asks user for a memory position, then wait for data from tape and place it
; from the specified position on until it receives 4 consecutive 0x00 (EOF)
; @uses b, c, h, l
monitor_load:
ld bc, MON_COMMAND_LOAD + 1 ; autocomplete command
call Sys_Print
; TODO: When implemented, re-enable interrupts before run application
; Now read the memory address from the user
call monitor_arg_2byte ; returns the read bytes in hl
; Ask user to press play
ld bc, MON_COMMAND_LOAD_PRESSPLAY
; TODO: wait for data
jp monitor_main_loop
monitor_run:
@ -320,19 +324,6 @@ monitor_run:
; execute code
jp (hl)
monitor_adb:
ld bc, MON_COMMAND_ADB + 1 ; autocomplete command
call Sys_Print
; start copying incoming data to application space
call monitor_copyTermToAppMem
; call monitor_enable_int ; re-enable interrupts
;jp APP_SPACE ; Start executing code
; ld bc, APP_SPACE
; call Sys_Print
jp monitor_main_loop
; Prints "0x" and read 1 hex byte (2 hex digits, e.g. 0x8C)
; Can be cancelled with Q/ENTER
; @return a the read byte, b the exit code (0=valid byte in a, 1=Q, 2=ENTER)
@ -524,53 +515,6 @@ monitor_printAsciiByte:
call Sys_Printc
ret
; Copy data from parallel terminal to application memory. This is tought to be used with the ADB function of the Pat80 Python Terminal.
; Uses TERM_DATA_AVAIL_REG to check if a byte is available before reading it.
; The first two received bytes (heading bytes) defines the stream length (MSB first), the rest of the bytes are copied to memory.
; The copy is completed when the number of bytes defined in the heading bytes are received.
; @uses a, b, c, d, h, l
monitor_copyTermToAppMem:
; d contains the current status.
; 2 = waiting for first heading byte
; 1 = waiting for second heading byte
; 0 = heading bytes received, now receiving binary stream
ld d, 2
ld hl, APP_SPACE ; we will write in APP_SPACE
monitor_copyTermToAppMem_loop:
ld a, d
cp 2 ; check if we are receiving first header byte
jp z, monitor_copyTermToAppMem_loop_rec_head_byte_1
ld a, d
cp 1 ; check if we are receiving second header byte
jp z, monitor_copyTermToAppMem_loop_rec_head_byte_2
; we are receiving binary stream: read byte and save to memory
call Term_readb ; reads a byte from terminal
ld (hl), a ; copy byte to memory
inc hl ; move to next memory position
dec bc ; decrement remaining bytes counter
; check if we reached the number of bytes to be transferred
ld a, b
cp 0
jp nz, monitor_copyTermToAppMem_loop ; continue loop
ld a, c
cp 0
jp nz, monitor_copyTermToAppMem_loop ; continue loop
; all bytes received, return
ret
monitor_copyTermToAppMem_loop_rec_head_byte_1:
; we are receiving first header byte: read byte and save to b
call Term_readb ; reads a byte from terminal
ld b, a
dec d
jp monitor_copyTermToAppMem_loop ; continue loop
monitor_copyTermToAppMem_loop_rec_head_byte_2:
; we are receiving second header byte: read byte and save to c
call Term_readb ; reads a byte from terminal
ld c, a
dec d
jp monitor_copyTermToAppMem_loop ; continue loop
; Runs a memory test to identify ram memory boundaries and check the ram is working.
; Starting from last memory position, writes 0xFF, reads it back, writes 0x00, reads it back.
; Exits when the first value differs from the written value (this may be caused by a bad ram

View File

@ -1,5 +1,7 @@
# Pat80 emulator
![Emulator running Memory Monitor](/assets/media/photos/emulator.png)
## Setup
Install the required Z80 emulator by redcode following the instructions for your Linux distribution at https://github.com/redcode/Z80