Implemented reading from standard input

This commit is contained in:
Bartłomiej Szostak 2024-05-02 20:14:48 +02:00
parent d088328294
commit 10bd1f4e9c
No known key found for this signature in database
GPG Key ID: 562DACF230A18086

View File

@ -145,7 +145,17 @@ package body Shardware is
procedure Trap (Registers : RegArrU; Memory : in out ByteArr; MemorySize : in out Unsigned_32) is
begin
case Registers(0) is
when 0 => null;
when 0 =>
declare
Pointer : Unsigned_32 := Registers (4) - 1;
Length : Integer := Integer(Registers (3));
CharBuff : String (1 .. Length);
begin
Get_Line(CharBuff ,Length);
for i in 1 .. Length loop
Memory (Pointer + Unsigned_32(i)) := Character'Pos(CharBuff (i));
end loop;
end;
when 1 =>
declare
Pointer : Unsigned_32 := Registers (4) - 1;
@ -155,7 +165,7 @@ package body Shardware is
for i in 1 .. Length loop
CharBuff (i) := Character'Val(Memory (Pointer + Unsigned_32(i)));
end loop;
Put_Line(CharBuff);
Put(CharBuff);
end;
when others => null;
end case;