Working on floats (Implemented Bytes to Bits converter)
This commit is contained in:
parent
a88ebe0b5c
commit
26528c5f96
@ -15,6 +15,29 @@ package body Shardware is
|
||||
end if;
|
||||
end UnToSignedInt;
|
||||
|
||||
function BytesToBits (Instruction : ByteArr) return BitArr is
|
||||
CurByte : Byte := 0;
|
||||
Buff : BitArr (1 .. 32);
|
||||
Counter : Integer := 0;
|
||||
begin
|
||||
for i in 1 .. 32 loop
|
||||
Buff (i) := False;
|
||||
end loop;
|
||||
for i in 7 .. 10 loop
|
||||
CurByte := Instruction (i);
|
||||
for j in reverse 1 .. 8 loop
|
||||
if CurByte mod 2 > 0 then
|
||||
Buff (j + Counter) := True;
|
||||
else
|
||||
Buff (j + Counter) := False;
|
||||
end if;
|
||||
CurByte := CurByte / 2;
|
||||
end loop;
|
||||
Counter := Counter + 8;
|
||||
end loop;
|
||||
return Buff;
|
||||
end BytesToBits;
|
||||
|
||||
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32 is
|
||||
begin
|
||||
return Unsigned_32(Shift_Left(Unsigned_128(Value), Amount));
|
||||
@ -25,6 +48,12 @@ package body Shardware is
|
||||
return UnToSignedInt(Bytes_To_U(Instruction));
|
||||
end Bytes_To_I;
|
||||
|
||||
function Bytes_To_F (Instruction : ByteArr) return Float is
|
||||
Result : Float := 0.0;
|
||||
begin
|
||||
return Result;
|
||||
end Bytes_To_F;
|
||||
|
||||
function Bytes_To_U (Instruction : ByteArr) return Unsigned_32 is
|
||||
begin
|
||||
return Unsigned_32(My_ShiftU(Instruction (7), 24)
|
||||
|
@ -7,15 +7,20 @@ package Shardware is
|
||||
package Bin_IO is new Ada.Sequential_IO (Byte);
|
||||
type ByteArr is array (Integer range <>) of Byte;
|
||||
|
||||
type BitArr is array (Integer range <>) of Boolean;
|
||||
|
||||
type RegArrI is array (Integer range <>) of Integer;
|
||||
type RegArrF is array (Integer range <>) of Float;
|
||||
type RegArrU is array (Integer range <>) of Unsigned_32;
|
||||
|
||||
function UnToSignedInt (Value : Unsigned_32) return Integer;
|
||||
|
||||
function BytesToBits (Instruction : ByteArr) return BitArr;
|
||||
|
||||
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32;
|
||||
|
||||
function Bytes_To_I (Instruction : ByteArr) return Integer;
|
||||
function Bytes_To_F (Instruction : ByteArr) return Float;
|
||||
function Bytes_To_U (Instruction : ByteArr) return Unsigned_32;
|
||||
|
||||
procedure MovI (Register : in out Integer; Value : Integer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user