From fb3ab7491c2e68ffd6c45a14ba867639fede3887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Szostak?= Date: Wed, 1 May 2024 17:40:25 +0200 Subject: [PATCH] Added Float operations to main program --- src/shardware.adb | 6 ++---- src/sillymachine.adb | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/shardware.adb b/src/shardware.adb index d112020..dc267f5 100644 --- a/src/shardware.adb +++ b/src/shardware.adb @@ -125,10 +125,8 @@ package body Shardware is Result := Sign * Mantissa * (2.0 ** (Exponent - 127)); elsif Exponent = 255 and Mantissa = 0.0 then Result := 1.0 / Zero; - elsif Exponent = 0 and (Mantissa > 0.0 or Mantissa < 0.0) then - Result := Sign * Mantissa * (2.0 ** (Exponent - 127)); - elsif Exponent = 0 and Mantissa = 0.0 then - Result := 0.0; + elsif Exponent = 0 then + Result := 1.0 + Sign * Mantissa * (2.0 ** (Exponent - 127)); else Result := 0.0 / Zero; end if; diff --git a/src/sillymachine.adb b/src/sillymachine.adb index 518d22b..ab36d50 100644 --- a/src/sillymachine.adb +++ b/src/sillymachine.adb @@ -134,6 +134,15 @@ begin BytesToI(TempBytes(Instruction))); when 11 => AddI(RegisterI(Integer(Instruction (2))), -- Add Register to Register (Int) RegisterI(Integer(Instruction (3)))); + when 12 => MovF(RegisterF(Integer(Instruction (2))), -- Move Float to Register + BytesToF(TempBytes(Instruction))); + when 14 => MovF(RegisterF(Integer(Instruction (2))), -- Move Register to Register (Float) + RegisterF(Integer(Instruction (3)))); + when 15 => null; -- TODO: Move Memory to Register (Float) + when 16 => AddF(RegisterF(Integer(Instruction (2))), -- Add Float to Register + BytesToF(TempBytes(Instruction))); + when 17 => AddF(RegisterF(Integer(Instruction (2))), -- Add Register to Register (Float) + RegisterF(Integer(Instruction (3)))); when 65535 => goto THE_END; -- exit opcode when others => null; end case;