Compare commits
2 Commits
7d89deaa02
...
64d57bdb31
Author | SHA1 | Date | |
---|---|---|---|
64d57bdb31 | |||
9960d81a44 |
@ -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).
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user