diff --git a/README.md b/README.md index a385e1a..9b88af3 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ - [cputest](cputest) - CPU test suite - [gcc](gcc) - experiments in compiling C code - [rust](rust) - experiments in compiling Rust code - - [okameron](okameron) - demo program written in [Okameron](https://github.com/TalonFox/okameron) \ No newline at end of file + - [okameron](okameron) - demo GUI program written in [Okameron](https://github.com/TalonFox/okameron) + - [okameron-cli](okameron-cli) - demo CLI program written in [Okameron](https://github.com/TalonFox/okameron) diff --git a/okameron-cli/.gitignore b/okameron-cli/.gitignore new file mode 100644 index 0000000..c9afac6 --- /dev/null +++ b/okameron-cli/.gitignore @@ -0,0 +1,2 @@ +*.asm +*.fxf diff --git a/okameron-cli/Makefile b/okameron-cli/Makefile new file mode 100644 index 0000000..a1c579b --- /dev/null +++ b/okameron-cli/Makefile @@ -0,0 +1,10 @@ +OKAMERON := ../../okameron/okameron.lua +FOX32ASM := ../../fox32asm/target/release/fox32asm + +all: TermOkm.fxf + +%.fxf: %.asm + $(FOX32ASM) $< $@ + +%.asm: %.okm + lua $(OKAMERON) -arch=fox32 -startup=start.asm $< OS.okm > $@ diff --git a/okameron-cli/OS.okm b/okameron-cli/OS.okm new file mode 100644 index 0000000..28a0b74 --- /dev/null +++ b/okameron-cli/OS.okm @@ -0,0 +1,5 @@ +(* FIXME: this module should probably be moved somewhere global so all applications can use it *) + +MODULE OS; + EXTERN PROCEDURE read, write, string_length, end_current_task, save_state_and_yield_task: INT; +END. diff --git a/okameron-cli/TermOkm.okm b/okameron-cli/TermOkm.okm new file mode 100644 index 0000000..bde0396 --- /dev/null +++ b/okameron-cli/TermOkm.okm @@ -0,0 +1,39 @@ +(* terminal I/O demo. invoke as: *) +(* 1> TermOkm *) +(* 1> TermOkm fox *) + +MODULE TermOkm; + IMPORT OS; + + EXTERN terminalStreamPtr: PTR; + EXTERN arg0Ptr: PTR; + EXTERN arg1Ptr: PTR; + EXTERN arg2Ptr: PTR; + EXTERN arg3Ptr: PTR; + + PROCEDURE Main(); + VAR input: CHAR; + BEGIN + Print("hello "); + IF arg0Ptr THEN + Print(arg0Ptr); + ELSE + Print("world"); + END; + Print("!\nPress any key to exit.\n"); + + input := 0; + WHILE 1 DO + read(1, terminalStreamPtr, PTROF(input)); + IF input THEN + end_current_task(); + END; + save_state_and_yield_task(); + END; + END; + + PROCEDURE Print(string: POINTER TO CHAR;); + BEGIN + write(string_length(string), terminalStreamPtr, string); + END; +END.