68 lines
1.6 KiB
Ada
68 lines
1.6 KiB
Ada
with Interfaces; use Interfaces;
|
|
|
|
package body Shardware is
|
|
|
|
function UnToSignedInt (Value : Unsigned_32) return Integer is
|
|
Diff1 : Integer := 0;
|
|
Diff2 : Integer := 0;
|
|
begin
|
|
if Value > 2147483647 then
|
|
Diff1 := Integer(Value - 2147483648);
|
|
Diff2 := Diff1 - 2147483647;
|
|
return Diff2 - 1;
|
|
else
|
|
return Integer(Value);
|
|
end if;
|
|
end UnToSignedInt;
|
|
|
|
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32 is
|
|
begin
|
|
return Unsigned_32(Shift_Left(Unsigned_128(Value), Amount));
|
|
end My_ShiftU;
|
|
|
|
function Bytes_To_I (Instruction : ByteArr) return Integer is
|
|
begin
|
|
return UnToSignedInt(Bytes_To_U(Instruction));
|
|
end Bytes_To_I;
|
|
|
|
function Bytes_To_U (Instruction : ByteArr) return Unsigned_32 is
|
|
begin
|
|
return Unsigned_32(My_ShiftU(Instruction (7), 24)
|
|
+ My_ShiftU(Instruction (8), 16)
|
|
+ My_ShiftU(Instruction (9), 8)
|
|
+ Unsigned_32(Instruction (10)));
|
|
end Bytes_To_U;
|
|
|
|
procedure MovI (Register : in out Integer; Value : Integer) is
|
|
begin
|
|
Register := Value;
|
|
end MovI;
|
|
|
|
procedure AddI (Register : in out Integer; Value : Integer) is
|
|
begin
|
|
Register := Register + Value;
|
|
end AddI;
|
|
|
|
procedure MovF (Register : in out Float; Value : Float) is
|
|
begin
|
|
Register := Value;
|
|
end MovF;
|
|
|
|
procedure AddF (Register : in out Float; Value : Float) is
|
|
begin
|
|
Register := Register + Value;
|
|
end AddF;
|
|
|
|
procedure MovU (Register : in out Unsigned_32; Value : Unsigned_32) is
|
|
begin
|
|
Register := Value;
|
|
end MovU;
|
|
|
|
procedure AddU (Register : in out Unsigned_32; Value : Unsigned_32) is
|
|
begin
|
|
Register := Register + Value;
|
|
end AddU;
|
|
|
|
|
|
end Shardware;
|