Skip to content

Commit

Permalink
Add okameron-cli demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 committed Apr 30, 2024
1 parent bd4efbf commit 51e0550
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- [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)
2 changes: 2 additions & 0 deletions okameron-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.asm
*.fxf
10 changes: 10 additions & 0 deletions okameron-cli/Makefile
Original file line number Diff line number Diff line change
@@ -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 > $@
5 changes: 5 additions & 0 deletions okameron-cli/OS.okm
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 39 additions & 0 deletions okameron-cli/TermOkm.okm
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 51e0550

Please sign in to comment.