Added Float operations to main program

This commit is contained in:
Bartłomiej Szostak 2024-05-01 17:40:25 +02:00
parent 98e70c1898
commit fb3ab7491c
No known key found for this signature in database
GPG Key ID: 562DACF230A18086
2 changed files with 11 additions and 4 deletions

View File

@ -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;

View File

@ -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;