diff --git a/pat80-computer/software/z80-assembly/os/README.md b/pat80-computer/software/z80-assembly/os/README.md index e96f6bd..203417c 100644 --- a/pat80-computer/software/z80-assembly/os/README.md +++ b/pat80-computer/software/z80-assembly/os/README.md @@ -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). diff --git a/pat80-computer/software/z80-assembly/os/main.asm b/pat80-computer/software/z80-assembly/os/main.asm index 63ae60e..852226e 100644 --- a/pat80-computer/software/z80-assembly/os/main.asm +++ b/pat80-computer/software/z80-assembly/os/main.asm @@ -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' diff --git a/pat80-computer/software/z80-assembly/os/monitor.asm b/pat80-computer/software/z80-assembly/os/monitor.asm index d7e6486..0f71766 100644 --- a/pat80-computer/software/z80-assembly/os/monitor.asm +++ b/pat80-computer/software/z80-assembly/os/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' @@ -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 @@ -320,19 +316,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 +507,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