Implemented a memory array
This commit is contained in:
parent
ce51ce0b19
commit
9eb3ef1488
@ -16,6 +16,8 @@ procedure sillymachine is
|
|||||||
I : Integer := 0;
|
I : Integer := 0;
|
||||||
Value : Byte;
|
Value : Byte;
|
||||||
|
|
||||||
|
MemorySize : Integer := 1048576; -- default memory is 1 mb (TODO: figure out why 8 mb produces STORAGE_ERROR)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
ValidHeader (0) := 6;
|
ValidHeader (0) := 6;
|
||||||
@ -37,7 +39,7 @@ begin
|
|||||||
|
|
||||||
if Argument_Count = 0 then
|
if Argument_Count = 0 then
|
||||||
New_Line(1);
|
New_Line(1);
|
||||||
Put_Line("Usage: sillymachine <sm binary file>");
|
Put_Line("Usage: sillymachine <sm binary file> <number of megabytes for wanted memory (optional)>");
|
||||||
New_Line(1);
|
New_Line(1);
|
||||||
goto THE_END;
|
goto THE_END;
|
||||||
end if;
|
end if;
|
||||||
@ -62,7 +64,24 @@ begin
|
|||||||
end loop;
|
end loop;
|
||||||
Put_Line("Header passed");
|
Put_Line("Header passed");
|
||||||
|
|
||||||
|
if Argument_Count > 1 then
|
||||||
|
MemorySize := 1048576 * Integer'Value(Argument (2));
|
||||||
|
end if;
|
||||||
|
|
||||||
|
declare
|
||||||
|
MemoryArr : ByteArr (0 .. MemorySize);
|
||||||
|
begin
|
||||||
|
for i in 0 .. MemorySize loop -- zero initialise memory
|
||||||
|
MemoryArr (i) := 0;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
<< THE_END >>
|
<< THE_END >>
|
||||||
exception
|
exception
|
||||||
when Name_Error => New_Line(1); Put("Error: File '"); Put(FileName); Put_Line("' does not exist!"); New_Line(1);
|
when Name_Error => New_Line(1); Put("Error: File '"); Put(FileName); Put_Line("' does not exist!"); New_Line(1);
|
||||||
|
when Constraint_Error => New_Line(1); Put_Line("Error: Memory should be passed as an Integer"); New_Line(1);
|
||||||
|
when Storage_Error => New_Line(1); Put_Line("Error: Something went silly!"); New_Line(1);
|
||||||
end sillymachine;
|
end sillymachine;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user