First os version with ABI number and working system calls

This commit is contained in:
Daniele Verducci su MatissePenguin
2020-12-30 19:58:32 +01:00
parent b1f9788772
commit ef58b417e6
12 changed files with 81 additions and 49 deletions

View File

@ -0,0 +1,12 @@
# Pat80 Applications
## Intro
This folder contains some example applications.
The folder `brief` contains little applications that can be entered directly via keyboard in the memory monitor.
The folder `big` contains complete applications to be loaded via sdcard or tape.
## How to write an application
When the Pat80 operating system is built, a `abi-generated.asm` file is built along with the rom binary. This file contains the description of the OS available API.
An application targeting the last version of the OS should include this file, to make the system calls labels available inside the application code.
The application can obtain the operating system ABI version (ABI -> https://en.wikipedia.org/wiki/Application_binary_interface) via the Sys_ABI call (it is a 16 bits integer returned in BC).
The application's first command should be an ABI check: if the OS version is not compatible with the app, the app should exit displaying an error message.

View File

@ -0,0 +1,7 @@
org 0xA000
include '../../bios/abi-generated.asm'
STRING: DB "Hello",0
ld bc, STRING
call Sys_Print
jp 0

View File

@ -1,3 +0,0 @@
ld bc, 0xA000
call 0x0010
jp 0

View File

@ -1,9 +0,0 @@
org 0x00A0
test:
nop
nop
nop
nop
nop
jp test

View File

@ -1,16 +0,0 @@
; Prints "Hello world" in terminal
; Usage: assemble this file with z80asm and insert the resulting bytes
; via Memory Monitor from address 0xA000 to test SET and RUN commands.
org 0xA000 ; Set starting position to ram
ld bc, HELLO_WORLD_STR
Term_print:
ld a, (bc) ; bc is the pointer to string's first char
cp 0 ; compare A content with 0 (subtract 0 from value and set zero flag Z if result is 0)
jp z, term_print_end
out (0x00),a ; output char to IO device 0, addr 0
inc bc ; increment bc to move to next char
jp Term_print
term_print_end:
halt
HELLO_WORLD_STR: DB "Hello world!",0