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
|
||||
|
||||
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
|
||||
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;
|
||||
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
|
||||
@ -19,7 +22,7 @@ package body Shardware is
|
||||
|
||||
function Bytes_To_I (Instruction : ByteArr) return Integer is
|
||||
begin
|
||||
return Integer(Bytes_To_U(Instruction));
|
||||
return UnToSignedInt(Bytes_To_U(Instruction));
|
||||
end Bytes_To_I;
|
||||
|
||||
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 RegArrU is array (Integer range <>) of Unsigned_32;
|
||||
|
||||
function My_ShiftI (Value : Byte; Amount : Integer) return Integer;
|
||||
function My_ShiftF (Value : Byte; Amount : Integer) return Float;
|
||||
function UnToSignedInt (Value : Unsigned_32) return Integer;
|
||||
|
||||
function My_ShiftU (Value : Byte; Amount : Integer) return Unsigned_32;
|
||||
|
||||
function Bytes_To_I (Instruction : ByteArr) return Integer;
|
||||
|
@ -113,7 +113,7 @@ begin
|
||||
Instruction (i) := MemoryArr (PC + i);
|
||||
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 1 => null; -- TODO: TRAP
|
||||
when 2 => MovU(RegisterU(Integer(Instruction (2))),
|
||||
@ -138,9 +138,10 @@ begin
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
Put_Line(Unsigned_32'Image(RegisterU(0)));
|
||||
Put_Line(Unsigned_32'Image(RegisterU(1)));
|
||||
--Put_Line(Integer'Image(RegisterI(0)));
|
||||
--Put_Line(Unsigned_32'Image(RegisterU(0)));
|
||||
--Put_Line(Unsigned_32'Image(RegisterU(1)));
|
||||
Put_Line(Integer'Image(RegisterI(0)));
|
||||
Put_Line(Integer'Image(RegisterI(1)));
|
||||
|
||||
PC := PC + 16; -- increment program counter to next instruction
|
||||
end loop;
|
||||
|
Loading…
x
Reference in New Issue
Block a user