Properly implemented support for integers
This commit is contained in:
parent
d847f01a06
commit
a88ebe0b5c
@ -2,15 +2,18 @@ with Interfaces; use Interfaces;
|
|||||||
|
|
||||||
package body Shardware is
|
package body Shardware is
|
||||||
|
|
||||||
function My_ShiftI (Value : Byte; Amount : Integer) return Integer is
|
function UnToSignedInt (Value : Unsigned_32) return Integer is
|
||||||
|
Diff1 : Integer := 0;
|
||||||
|
Diff2 : Integer := 0;
|
||||||
begin
|
begin
|
||||||
return Integer(Shift_Left(Unsigned_128(Value), Amount));
|
if Value > 2147483647 then
|
||||||
end My_ShiftI;
|
Diff1 := Integer(Value - 2147483648);
|
||||||
|
Diff2 := Diff1 - 2147483647;
|
||||||
function My_ShiftF (Value : Byte; Amount : Integer) return Float is
|
return Diff2 - 1;
|
||||||
begin
|
else
|
||||||
return Float(Shift_Left(Unsigned_128(Value), Amount));
|
return Integer(Value);
|
||||||
end My_ShiftF;
|
end if;
|
||||||
|
end UnToSignedInt;
|
||||||
|
|
||||||
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32 is
|
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32 is
|
||||||
begin
|
begin
|
||||||
@ -19,7 +22,7 @@ package body Shardware is
|
|||||||
|
|
||||||
function Bytes_To_I (Instruction : ByteArr) return Integer is
|
function Bytes_To_I (Instruction : ByteArr) return Integer is
|
||||||
begin
|
begin
|
||||||
return Integer(Bytes_To_U(Instruction));
|
return UnToSignedInt(Bytes_To_U(Instruction));
|
||||||
end Bytes_To_I;
|
end Bytes_To_I;
|
||||||
|
|
||||||
function Bytes_To_U (Instruction : ByteArr) return Unsigned_32 is
|
function Bytes_To_U (Instruction : ByteArr) return Unsigned_32 is
|
||||||
|
@ -11,8 +11,8 @@ package Shardware is
|
|||||||
type RegArrF is array (Integer range <>) of Float;
|
type RegArrF is array (Integer range <>) of Float;
|
||||||
type RegArrU is array (Integer range <>) of Unsigned_32;
|
type RegArrU is array (Integer range <>) of Unsigned_32;
|
||||||
|
|
||||||
function My_ShiftI (Value : Byte; Amount : Integer) return Integer;
|
function UnToSignedInt (Value : Unsigned_32) return Integer;
|
||||||
function My_ShiftF (Value : Byte; Amount : Integer) return Float;
|
|
||||||
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32;
|
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32;
|
||||||
|
|
||||||
function Bytes_To_I (Instruction : ByteArr) return Integer;
|
function Bytes_To_I (Instruction : ByteArr) return Integer;
|
||||||
|
@ -113,7 +113,7 @@ begin
|
|||||||
Instruction (i) := MemoryArr (PC + i);
|
Instruction (i) := MemoryArr (PC + i);
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
case My_ShiftI(Instruction (0), 8) + Integer(Instruction (1)) is -- execute the instruction
|
case My_ShiftU(Instruction (0), 8) + Unsigned_32(Instruction (1)) is -- execute the instruction
|
||||||
when 0 => null; -- NOP
|
when 0 => null; -- NOP
|
||||||
when 1 => null; -- TODO: TRAP
|
when 1 => null; -- TODO: TRAP
|
||||||
when 2 => MovU(RegisterU(Integer(Instruction (2))),
|
when 2 => MovU(RegisterU(Integer(Instruction (2))),
|
||||||
@ -138,9 +138,10 @@ begin
|
|||||||
when others => null;
|
when others => null;
|
||||||
end case;
|
end case;
|
||||||
|
|
||||||
Put_Line(Unsigned_32'Image(RegisterU(0)));
|
--Put_Line(Unsigned_32'Image(RegisterU(0)));
|
||||||
Put_Line(Unsigned_32'Image(RegisterU(1)));
|
--Put_Line(Unsigned_32'Image(RegisterU(1)));
|
||||||
--Put_Line(Integer'Image(RegisterI(0)));
|
Put_Line(Integer'Image(RegisterI(0)));
|
||||||
|
Put_Line(Integer'Image(RegisterI(1)));
|
||||||
|
|
||||||
PC := PC + 16; -- increment program counter to next instruction
|
PC := PC + 16; -- increment program counter to next instruction
|
||||||
end loop;
|
end loop;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user