From efbc5e94b3791e3d5a39414eb2ab200c91b3e90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Szostak?= Date: Sun, 21 Apr 2024 13:05:09 +0200 Subject: [PATCH] Implemented code execution --- src/sillymachine.adb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sillymachine.adb b/src/sillymachine.adb index 6721441..30fc977 100644 --- a/src/sillymachine.adb +++ b/src/sillymachine.adb @@ -19,6 +19,9 @@ procedure sillymachine is ExecSize : Integer := 0; MemorySize : Integer := 1048576; -- default memory is 1 mb (TODO: figure out why 8 mb produces STORAGE_ERROR) + PC : Integer := 0; -- Program Counter + Instruction : ByteArr (0 .. 15); + begin ValidHeader (0) := 6; @@ -93,8 +96,20 @@ begin end loop; Bin_IO.Close(F); - for i in 0 .. 30 loop - Put_Line(Byte'Image(MemoryArr (i))); + PC := 64; -- initialise program counter to entry point + while True loop + for i in 0 .. 15 loop -- load the instruction + Instruction (i) := MemoryArr (PC + i); + end loop; + + case Instruction (0) is -- execute the instruction + when 0 => Put_Line("-- japko --"); + when 1 => Put_Line("-- banan --"); + when 255 => goto THE_END; + when others => New_Line(1); + end case; + + PC := PC + 16; -- increment program counter to next instruction end loop; end;