Implemented Moving numbers from memory to registers instructions
This commit is contained in:
parent
10bd1f4e9c
commit
9807fee8a0
@ -142,6 +142,15 @@ package body Shardware is
|
||||
return Result;
|
||||
end BytesToF;
|
||||
|
||||
function ReadMem (Memory : ByteArr; Address : Unsigned_32; Length : Unsigned_32) return ByteArr is
|
||||
Result : ByteArr (1 .. Length);
|
||||
begin
|
||||
for i in 1 .. Length loop
|
||||
Result (i) := Memory (Address - 1 + i);
|
||||
end loop;
|
||||
return Result;
|
||||
end ReadMem;
|
||||
|
||||
procedure Trap (Registers : RegArrU; Memory : in out ByteArr; MemorySize : in out Unsigned_32) is
|
||||
begin
|
||||
case Registers(0) is
|
||||
@ -155,6 +164,7 @@ package body Shardware is
|
||||
for i in 1 .. Length loop
|
||||
Memory (Pointer + Unsigned_32(i)) := Character'Pos(CharBuff (i));
|
||||
end loop;
|
||||
Memory (Pointer + Unsigned_32(Length) + 1) := 10;
|
||||
end;
|
||||
when 1 =>
|
||||
declare
|
||||
|
@ -26,6 +26,8 @@ package Shardware is
|
||||
function BytesToI (TheBytes : ByteArr) return Integer;
|
||||
function BytesToF (TheBytes : ByteArr) return Float;
|
||||
|
||||
function ReadMem (Memory : ByteArr; Address : Unsigned_32; Length : Unsigned_32) return ByteArr;
|
||||
|
||||
procedure Trap (Registers : RegArrU; Memory : in out ByteArr; MemorySize : in out Unsigned_32);
|
||||
|
||||
procedure MovU (Register : in out Unsigned_32; Value : Unsigned_32);
|
||||
|
@ -118,17 +118,20 @@ begin
|
||||
BytesToU(TempBytes(Instruction)));
|
||||
when 3 => MovU(RegisterU(Integer(Instruction (2))), -- Move Register to Register (Unsigned_32)
|
||||
RegisterU(Integer(Instruction (3))));
|
||||
when 4 => null; -- TODO: Move Memory to Register (Unsigned_32)
|
||||
when 4 => MovU(RegisterU(Integer(Instruction (2))), -- Move Memory to Register (Unsigned_32)
|
||||
BytesToU(ReadMem(MemoryArr, BytesToU(TempBytes(Instruction)), 4)));
|
||||
when 5 => MovI(RegisterI(Integer(Instruction (2))), -- Move Int to Register
|
||||
BytesToI(TempBytes(Instruction)));
|
||||
when 6 => MovI(RegisterI(Integer(Instruction (2))), -- Move Register to Register (Int)
|
||||
RegisterI(Integer(Instruction (3))));
|
||||
when 7 => null; -- TODO: Move Memory to Register
|
||||
when 7 => MovI(RegisterI(Integer(Instruction (2))), -- Move Memory to Register (Integer)
|
||||
BytesToI(ReadMem(MemoryArr, BytesToU(TempBytes(Instruction)), 4)));
|
||||
when 8 => MovF(RegisterF(Integer(Instruction (2))), -- Move Float to Register
|
||||
BytesToF(TempBytes(Instruction)));
|
||||
when 9 => MovF(RegisterF(Integer(Instruction (2))), -- Move Register to Register (Float)
|
||||
RegisterF(Integer(Instruction (3))));
|
||||
when 10 => null; -- TODO: Move Memory to Register (Float)
|
||||
when 10 => MovF(RegisterF(Integer(Instruction (2))), -- Move Memory to Register (Float)
|
||||
BytesToF(ReadMem(MemoryArr, BytesToU(TempBytes(Instruction)), 4)));
|
||||
when 11 => AddU(RegisterU(Integer(Instruction (2))), -- Add Register to Unsigned_32
|
||||
BytesToU(TempBytes(Instruction)));
|
||||
when 12 => AddU(RegisterU(Integer(Instruction (2))), -- Add Register to Register (Unsigned_32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user