68 lines
1.7 KiB
Ada
68 lines
1.7 KiB
Ada
with Interfaces; use Interfaces;
|
|
|
|
package body Shardware is
|
|
|
|
function My_ShiftI (Value : Byte; Amount : Integer) return Integer is
|
|
begin
|
|
return Integer(Shift_Left(Unsigned_128(Value), Amount));
|
|
end My_ShiftI;
|
|
|
|
function My_ShiftF (Value : Byte; Amount : Integer) return Float is
|
|
begin
|
|
return Float(Shift_Left(Unsigned_128(Value), Amount));
|
|
end My_ShiftF;
|
|
|
|
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 Integer(My_ShiftI(Instruction (7), 24)
|
|
+ My_ShiftI(Instruction (8), 16)
|
|
+ My_ShiftI(Instruction (9), 8)
|
|
+ Integer(Instruction (10)));
|
|
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;
|