Execute SNUSP/Ada: Difference between revisions

m
Fixed syntax highlighting.
(create Ada implementation of SNUSP)
 
m (Fixed syntax highlighting.)
 
(3 intermediate revisions by 2 users not shown)
Line 1:
{{implementation|SNUSP}}{{collection|RCSNUSP}}
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Ada]]</span><hr>
{{works with|Ada 2005}}
 
Line 7 ⟶ 8:
 
memory.ads:
<langsyntaxhighlight Adalang="ada">with Ada.Finalization;
generic
type Byte is mod <>;
Line 40 ⟶ 41:
procedure Finalize (Storage : in out Memory);
 
end Memory;</langsyntaxhighlight>
 
memory.adb:
<langsyntaxhighlight Adalang="ada">with Ada.Containers.Ordered_Maps;
with Ada.Unchecked_Deallocation;
package body Memory is
Line 114 ⟶ 115:
end Finalize;
 
end Memory;</langsyntaxhighlight>
 
Next is a Machine for interpreting SNUSP code.
 
snusp.ads:
<langsyntaxhighlight Adalang="ada">with Ada.Containers.Vectors;
with Ada.Strings.Fixed;
with Ada.Text_IO;
Line 152 ⟶ 153:
end record;
 
end SNUSP;</langsyntaxhighlight>
 
snusp.adb:
<langsyntaxhighlight Adalang="ada">package body SNUSP is
 
procedure Move_IP (IP : in out Code_Pointer) is
Line 286 ⟶ 287:
end Run;
 
end SNUSP;</langsyntaxhighlight>
 
Sample usage:
 
main.adb:
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO;
with SNUSP;
procedure Main is
Line 309 ⟶ 310:
SNUSP.Run (My_SNUSP_Machine, Test_Code);
 
end Main;</langsyntaxhighlight>
 
Output:
9,485

edits