max_stars_repo_path stringlengths 4 261 | max_stars_repo_name stringlengths 6 106 | max_stars_count int64 0 38.8k | id stringlengths 1 6 | text stringlengths 7 1.05M |
|---|---|---|---|---|
programs/oeis/138/A138694.asm | neoneye/loda | 22 | 104807 | <reponame>neoneye/loda
; A138694: Numbers n such that the set {2*n+p^2, p any prime} contains exactly one prime.
; 1,4,7,10,16,19,22,25,31,37,40,46,49,52,61,64,70,79,82,85,91,94,109,112,115,121,124,127,130,136,142,151,154,169,172,175,187,190,196,205,211,217,220,226,229,235,241,247,250,256,274,277,280,289,292,295,304,316,319,322,325,334,337,346,355,367,376,382,394,400,406,409,415,424,427,436,439,451,460,466,469,472,481,484,487,502,505,511,520,526,541,544,547,550,571,577,586,589,592,604
add $0,1
seq $0,24898 ; Positive integers k such that 6*k - 1 is prime.
sub $0,2
mul $0,3
add $0,1
|
tests/mobs-test_data-tests-mobinventory_container.ads | thindil/steamsky | 80 | 21977 | <reponame>thindil/steamsky<gh_stars>10-100
package Mobs.Test_Data.Tests.MobInventory_Container is
end Mobs.Test_Data.Tests.MobInventory_Container;
|
programs/oeis/169/A169959.asm | neoneye/loda | 22 | 99319 | ; A169959: a(n) = binomial(10*n, n).
; 1,10,190,4060,91390,2118760,50063860,1198774720,28987537150,706252528630,17310309456440,426342151127100,10542859559688820,261594860525768000,6509613950241656640,162392216278033616560,4059949873964357469950,101696990867999141755140,2551721502411051845896450,64123483527473864490450300,1613587787967350073386147640,40653923943460392790400375200,1025409606362681046915375402900,25890147452233383641232524047200,654299391596539695304568407146100,16549715289785911653429214282587510,418935883643139765637832361914865600
mov $1,10
mul $1,$0
bin $1,$0
mov $0,$1
|
libsrc/_DEVELOPMENT/font/fzx/fonts/ao/Dutch/_ff_ao_DutchLatin5.asm | meesokim/z88dk | 0 | 246414 | <reponame>meesokim/z88dk
SECTION rodata_font_fzx
PUBLIC _ff_ao_DutchLatin5
_ff_ao_DutchLatin5:
BINARY "font/fzx/fonts/ao/Dutch/Dutch_Latin5.fzx"
|
source/asis/asis-compilation_units-relations.adb | faelys/gela-asis | 4 | 1262 | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $:
-- Purpose:
-- Procedural wrapper over Object-Oriented ASIS implementation
------------------------------------------------------------------------------
-- Implementation restriction --
-- not implemented Inconsistent list generation --
------------------------------------------------------------------------------
with Ada.Finalization;
with Ada.Unchecked_Deallocation;
with System;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions;
with Asis.Implementation;
with Asis.Elements;
with Asis.Ada_Environments;
with Asis.Clauses;
with Asis.Expressions;
with Asis.Iterator;
with Ada.Wide_Text_IO;
package body Asis.Compilation_Units.Relations is
package Utils is
-- Compilation_Unit_List_Access --
type Compilation_Unit_List_Access is
access all Compilation_Unit_List;
procedure Deallocate is
new Ada.Unchecked_Deallocation
(Compilation_Unit_List, Compilation_Unit_List_Access);
function In_List
(List : in Compilation_Unit_List_Access;
Last : in ASIS_Integer;
Unit : in Compilation_Unit)
return Boolean;
function Append
(List : in Compilation_Unit_List_Access;
Unit : in Compilation_Unit)
return Compilation_Unit_List_Access;
function Append
(List : in Compilation_Unit_List_Access;
Units : in Compilation_Unit_List)
return Compilation_Unit_List_Access;
procedure Remove_From_List
(List : in out Compilation_Unit_List_Access;
Unit : in Compilation_Unit);
procedure Remove_From_List
(List : in out Compilation_Unit_List;
From : in List_Index;
Unit : in Compilation_Unit);
-- Tree --
type Root_Tree is
new Ada.Finalization.Limited_Controlled with private;
type Root_Tree_Access is access all Root_Tree;
type Tree_Node is
new Ada.Finalization.Limited_Controlled with private;
type Tree_Node_Access is access all Tree_Node;
-- Tree_Node_Array --
type Tree_Node_Array is array (Positive range <>) of Tree_Node_Access;
type Tree_Node_Array_Access is access all Tree_Node_Array;
procedure Deallocate is
new Ada.Unchecked_Deallocation
(Tree_Node_Array, Tree_Node_Array_Access);
function Append
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access;
function In_List
(List : in Tree_Node_Array_Access;
Last : in Natural;
Node : in Tree_Node_Access)
return Boolean;
-- Root_Tree --
type Orders is (Ascending, Descending);
procedure Dependence_Order
(This : in Root_Tree_Access;
Order : in Orders);
function Add_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access;
function Add_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Spec_Unit : in Compilation_Unit;
Body_Unit : in Compilation_Unit;
Skip_Spec : in Boolean := False)
return Tree_Node_Access;
function Add_Subunit
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access;
procedure Append
(This : in Root_Tree_Access;
Unit : in Compilation_Unit);
procedure Glue_Nodes
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access);
procedure Glue_Nodes_Checked
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access);
procedure Set_Parent
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Parent : in Tree_Node_Access);
procedure Clear
(This : in out Root_Tree);
procedure Add_Body_Dependents
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access);
function Find
(This : in Root_Tree_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access;
procedure Check
(This : in Root_Tree_Access;
The_Context : in Asis.Context);
function Generate_Relationship
(This : in Root_Tree_Access;
Limit_List : in Utils.Compilation_Unit_List_Access;
List_Last : in ASIS_Integer)
return Relationship;
function Create_Elaboration_Tree
(This : in Root_Tree_Access;
The_Context : in Asis.Context)
return Root_Tree_Access;
function Is_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access)
return Boolean;
function Is_Have_Circular_Dependences
(This : in Root_Tree_Access)
return Boolean;
-- Tree_Node --
function Is_Skip_Spec
(This : in Tree_Node_Access)
return Boolean;
procedure Skip_Spec
(This : in Tree_Node_Access;
Value : in Boolean);
function Nexts
(This : in Tree_Node_Access)
return Tree_Node_Array_Access;
function Get_Spec
(This : in Tree_Node_Access)
return Compilation_Unit;
function Get_Body
(This : in Tree_Node_Access)
return Compilation_Unit;
Use_Error : exception;
private
-- Tree_Node --
type Extended_Boolean is (Unknown, Extended_True, Extended_False);
type Tree_Node is
new Ada.Finalization.Limited_Controlled with record
Self : Tree_Node_Access := Tree_Node'Unchecked_Access;
-- ссылка на предыдущие елементы
Prevs : Tree_Node_Array_Access := null;
-- последующие елементы
Next : Tree_Node_Array_Access := null;
-- модуль_компиляции
Unit : Compilation_Unit := Nil_Compilation_Unit;
Unit_Body : Compilation_Unit := Nil_Compilation_Unit;
Skip_Spec : Boolean := False;
Added : Boolean := False;
Consistent : Boolean := True;
Body_Consistent : Boolean := True;
-- зависимости тела (with)
Body_Dependences : Tree_Node_Array_Access := null;
-- список циклических зависимостей
Circular : Compilation_Unit_List_Access := null;
Circular_Added : Boolean := False;
-- список пропавших юнитов
Missing : Compilation_Unit_List_Access := null;
Missing_Added : Boolean := False;
-- список несоглассованных юнитов
Inconsistent : Compilation_Unit_List_Access := null;
Inconsistent_Added : Boolean := False;
Elaborated : Boolean := False;
Body_Elaborated : Boolean := False;
Internal_Pure : Extended_Boolean := Unknown;
Internal_Preelaborate : Extended_Boolean := Unknown;
Internal_Spec_With_Body : Extended_Boolean := Unknown;
end record;
procedure Finalize
(This : in out Tree_Node);
function Is_Pure
(This : in Tree_Node_Access)
return Boolean;
function Is_Preelaborate
(This : in Tree_Node_Access)
return Boolean;
function Is_Elaborate_Body
(This : in Tree_Node_Access)
return Boolean;
procedure Retrive_Pragmas
(This : in Tree_Node_Access);
-- Root_Tree --
type Unit_Node is record
Unit : Compilation_Unit;
Node : Tree_Node_Access;
end record;
type Unit_Node_Array is array (Positive range <>) of Unit_Node;
type Unit_Node_Array_Access is access all Unit_Node_Array;
type Root_Tree is
new Ada.Finalization.Limited_Controlled with record
Self : Root_Tree_Access := Root_Tree'Unchecked_Access;
Order : Orders := Descending;
Next : Tree_Node_Array_Access := null;
-- сортированный список всех
-- елементов для быстрого
-- определения наличия елемента
-- в списке
Units : Unit_Node_Array_Access := null;
Last_Node : Tree_Node_Access := null;
end record;
procedure Finalize
(This : in out Root_Tree);
-- Additional --
procedure Deallocate is
new Ada.Unchecked_Deallocation
(Tree_Node, Tree_Node_Access);
procedure Deallocate is
new Ada.Unchecked_Deallocation
(Unit_Node_Array, Unit_Node_Array_Access);
type Positive_Access is access all Positive;
function Add_Node
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access;
procedure Remove
(List : in out Tree_Node_Array_Access;
Node : in Tree_Node_Access);
function Remove
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access;
function Add_Node_Ordered
(List : in Unit_Node_Array_Access;
Node : in Tree_Node_Access)
return Unit_Node_Array_Access;
function Find
(List : in Unit_Node_Array_Access;
Unit : in Compilation_Unit;
From : in Positive;
To : in Positive;
Index : in Positive_Access)
return Boolean;
function Compare
(Left : in Compilation_Unit;
Right : in Compilation_Unit)
return Integer;
function Is_Inconsistent
(Unit : in Compilation_Unit)
return Boolean;
function Is_Source_Changed
(Unit : in Compilation_Unit)
return Boolean;
end Utils;
procedure Deallocate is
new Ada.Unchecked_Deallocation
(Utils.Root_Tree, Utils.Root_Tree_Access);
procedure Check_Compilation_Unit
(Unit : in Compilation_Unit;
The_Context : in Asis.Context;
Message : in Wide_String);
procedure Normalize
(List : in Asis.Compilation_Unit_List;
Result : in Utils.Compilation_Unit_List_Access;
Last : out ASIS_Integer);
function Get_Ancestors
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
function Get_Descendants
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
function Get_Supporters
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
function Get_Dependents
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
function Get_Family
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
function Get_Needed_Units
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access;
procedure Get_Subunits
(Tree : in Utils.Root_Tree_Access;
Unit : in Compilation_Unit;
Node : in Utils.Tree_Node_Access;
The_Context : in Asis.Context);
function Get_Compilation_Unit
(Unit : in Compilation_Unit;
Target : in Asis.Element;
Number : in List_Index;
The_Context : in Asis.Context)
return Asis.Compilation_Unit;
function Have_With
(Library : in Compilation_Unit;
Unit : in Compilation_Unit;
The_Context : in Asis.Context)
return Boolean;
type Check_10_1_1_26c_26b_Information is record
Exceptions : Boolean := False;
System : Boolean := False;
end record;
function Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
The_Context : in Asis.Context)
return Check_10_1_1_26c_26b_Information;
----------------------------
-- Check_Compilation_Unit --
----------------------------
procedure Check_Compilation_Unit
(Unit : in Compilation_Unit;
The_Context : in Asis.Context;
Message : in Wide_String)
is
Kind : Asis.Unit_Kinds;
begin
Kind := Unit_Kind (Unit);
if Kind = Not_A_Unit
or else Kind = A_Nonexistent_Declaration
or else Kind = A_Nonexistent_Body
or else Kind = A_Configuration_Compilation
then
Asis.Implementation.Set_Status
(Data_Error, Message & " invalid unit " & Unit_Full_Name (Unit));
raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit;
end if;
if not Asis.Ada_Environments.Is_Equal
(Enclosing_Context (Unit), The_Context)
then
Asis.Implementation.Set_Status
(Data_Error, Message & " invalid unit's context "
& Unit_Full_Name (Unit));
raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit;
end if;
end Check_Compilation_Unit;
---------------
-- Normalize --
---------------
procedure Normalize
(List : in Asis.Compilation_Unit_List;
Result : in Utils.Compilation_Unit_List_Access;
Last : out ASIS_Integer)
is
Unit : Compilation_Unit;
begin
Last := 0;
for Index in List'Range loop
Unit := List (Index);
if not Is_Nil (Unit)
and then Unit_Kind (Unit) /= An_Unknown_Unit
then
if not Utils.In_List (Result, Last, Unit) then
Last := Last + 1;
Result (Last) := List (Index);
end if;
end if;
end loop;
end Normalize;
-------------------------
-- Elaboration_Order --
-------------------------
function Elaboration_Order
(Compilation_Units : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Relationship
is
procedure Clear;
Tree : Utils.Root_Tree_Access := null;
Elaborate_Tree : Utils.Root_Tree_Access := null;
Compilation_Units_Last : ASIS_Integer := 0;
Normalized_Compilation_Units :
Utils.Compilation_Unit_List_Access := null;
-- Clear --
procedure Clear is
begin
Deallocate (Tree);
Deallocate (Elaborate_Tree);
Utils.Deallocate (Normalized_Compilation_Units);
end Clear;
begin
if Compilation_Units = Nil_Compilation_Unit_List then
return Nil_Relationship;
end if;
for Index in Compilation_Units'Range loop
Check_Compilation_Unit
(Compilation_Units (Index), The_Context,
"Elaboration_Order:Compilation_Unit");
end loop;
Normalized_Compilation_Units := new
Asis.Compilation_Unit_List (1 .. Compilation_Units'Length);
Normalized_Compilation_Units.all := (others => Nil_Compilation_Unit);
Normalize (Compilation_Units,
Normalized_Compilation_Units,
Compilation_Units_Last);
Tree := Get_Needed_Units
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
Utils.Check (Tree, The_Context);
if Utils.Is_Have_Circular_Dependences (Tree) then
Clear;
Asis.Implementation.Set_Status
(Data_Error, "Elaboration_Order - "
& "Circular semantic dependence detected, can not create "
& "elaboration order");
raise Asis.Exceptions.ASIS_Failed;
end if;
Elaborate_Tree := Utils.Create_Elaboration_Tree (Tree, The_Context);
declare
Relation : Relationship := Utils.Generate_Relationship
(Elaborate_Tree, null, 0);
begin
Clear;
return Relation;
end;
exception
when others =>
Clear;
raise;
end Elaboration_Order;
---------------------------------
-- Semantic_Dependence_Order --
---------------------------------
function Semantic_Dependence_Order
(Compilation_Units : in Asis.Compilation_Unit_List;
Dependent_Units : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context;
Relation : in Asis.Relation_Kinds)
return Relationship
is
procedure Clear;
Compilation_Units_Last : ASIS_Integer := 0;
Normalized_Compilation_Units :
Utils.Compilation_Unit_List_Access := null;
Dependent_Units_Last : ASIS_Integer := 0;
Normalized_Dependent_Units :
Utils.Compilation_Unit_List_Access := null;
Tree : Utils.Root_Tree_Access := null;
procedure Clear is begin
Deallocate (Tree);
Utils.Deallocate (Normalized_Compilation_Units);
Utils.Deallocate (Normalized_Dependent_Units);
end Clear;
begin
if Compilation_Units = Nil_Compilation_Unit_List then
return Nil_Relationship;
end if;
for Index in Compilation_Units'Range loop
Check_Compilation_Unit
(Compilation_Units (Index), The_Context,
"Semantic_Dependence_Order:Compilation_Unit");
end loop;
Normalized_Compilation_Units := new
Asis.Compilation_Unit_List (1 .. Compilation_Units'Length);
Normalized_Compilation_Units.all := (others => Nil_Compilation_Unit);
Normalize (Compilation_Units,
Normalized_Compilation_Units,
Compilation_Units_Last);
-- Dependent_Units are ignored unless the Relation
-- is Descendants or Dependents
if (Relation = Descendants or else Relation = Dependents)
and then Dependent_Units /= Nil_Compilation_Unit_List
then
for Index in Dependent_Units'Range loop
Check_Compilation_Unit
(Dependent_Units (Index), The_Context,
"Semantic_Dependence_Order:Dependent_Unit");
end loop;
Normalized_Dependent_Units := new
Asis.Compilation_Unit_List (1 .. Dependent_Units'Length);
Normalized_Dependent_Units.all := (others => Nil_Compilation_Unit);
Normalize (Dependent_Units,
Normalized_Dependent_Units,
Dependent_Units_Last);
end if;
case Relation is
when Ancestors =>
Tree := Get_Ancestors
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
when Descendants =>
Tree := Get_Descendants
(Normalized_Compilation_Units
(1 .. Compilation_Units_Last), The_Context);
when Supporters =>
Tree := Get_Supporters
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
when Dependents =>
Tree := Get_Dependents
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
when Family =>
Tree := Get_Family
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
when Needed_Units =>
Tree := Get_Needed_Units
(Normalized_Compilation_Units (1 .. Compilation_Units_Last),
The_Context);
end case;
Utils.Check (Tree, The_Context);
declare
Relation : Relationship := Utils.Generate_Relationship
(Tree, Normalized_Dependent_Units, Dependent_Units_Last);
begin
Clear;
return Relation;
end;
exception
when others =>
Clear;
raise;
end Semantic_Dependence_Order;
-------------------
-- Get_Ancestors --
-------------------
function Get_Ancestors
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
Unit : Compilation_Unit;
Kinds : Unit_Kinds;
Result : Root_Tree_Access := new Root_Tree;
procedure Append_Node
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access);
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access);
-- Append_Node --
procedure Append_Node
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access)
is
Exist_Node : Tree_Node_Access;
begin
Exist_Node := Find (Result, Unit);
if Exist_Node /= null then
Glue_Nodes (Result, Node, Exist_Node);
Node := null;
else
Node := Add_Child (Result, Node, Unit);
end if;
end Append_Node;
-- Retrive --
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access)
is
Internal_Node : Tree_Node_Access := Node;
Internal_Unit : Compilation_Unit := Unit;
begin
while Unit_Kind (Internal_Unit) in
A_Procedure .. A_Generic_Package_Renaming
loop
Append_Node (Internal_Unit, Internal_Node);
if Internal_Node = null then
return;
end if;
Internal_Unit := Corresponding_Parent_Declaration (Internal_Unit);
end loop;
if not Is_Nil (Internal_Unit) then
Append_Node (Internal_Unit, Internal_Node);
if Internal_Node = null then
return;
end if;
-- add Standart as root
Append_Node
(Library_Unit_Declaration ("Standard", The_Context),
Internal_Node);
end if;
end Retrive;
begin
Dependence_Order (Result, Ascending);
for Index in List'Range loop
Unit := List (Index);
if Find (Result, Unit) = null then
Kinds := Unit_Kind (Unit);
if Kinds in A_Subunit then
Asis.Implementation.Set_Status
(Data_Error, "Subunit not valid for Ancestors request "
& Unit_Full_Name (Unit));
raise Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit;
elsif Kinds in A_Library_Unit_Body then
Unit := Corresponding_Parent_Declaration (Unit, The_Context);
end if;
Retrive (Unit, null);
end if;
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Get_Ancestors;
---------------------
-- Get_Descendants --
---------------------
function Get_Descendants
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
Result : Root_Tree_Access := new Root_Tree;
Unit : Compilation_Unit;
Second_Unit : Compilation_Unit;
Kinds : Unit_Kinds;
procedure Retrive
(Target : in Compilation_Unit;
Node : in Utils.Tree_Node_Access);
-- Retrive --
procedure Retrive
(Target : in Compilation_Unit;
Node : in Utils.Tree_Node_Access)
is
function Process
(Index : in List_Index)
return Boolean;
Exist_Node : Utils.Tree_Node_Access := null;
Children_List : Asis.Compilation_Unit_List :=
Corresponding_Children (Target, The_Context);
-- Process --
function Process
(Index : in List_Index)
return Boolean
is
begin
Kinds := Unit_Kind (Unit);
Exist_Node := Find (Result, Unit);
Second_Unit := Nil_Compilation_Unit;
if Exist_Node /= null then
Glue_Nodes (Result, Node, Exist_Node);
if Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body (Unit, The_Context);
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration (Unit, The_Context);
end if;
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Unit)
then
Remove_From_List (Children_List, Index + 1, Second_Unit);
end if;
return False;
end if;
if Kinds in
A_Procedure_Instance .. A_Generic_Package_Renaming
then
Exist_Node := Add_Child (Result, Node, Unit);
elsif Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body (Unit, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Unit)
then
Exist_Node := Add_Child (Result, Node, Unit, Second_Unit);
Remove_From_List (Children_List, Index + 1, Second_Unit);
else
Exist_Node := Add_Child (Result, Node, Unit);
end if;
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration (Unit, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Unit)
then
Exist_Node := Add_Child (Result, Node, Second_Unit, Unit);
Remove_From_List (Children_List, Index + 1, Second_Unit);
Unit := Second_Unit;
else
Exist_Node := Add_Child (Result, Node, Unit);
end if;
else
Exist_Node := Add_Child (Result, Node, Unit);
end if;
return True;
end Process;
begin
for Index in Children_List'Range loop
Unit := Children_List (Index);
if not Is_Nil (Unit) then
if Process (Index) then
Kinds := Unit_Kind (Unit);
if Kinds = A_Package
or else Kinds = A_Generic_Package
or else Kinds = A_Package_Instance
then
Retrive (Unit, Exist_Node);
end if;
end if;
end if;
end loop;
end Retrive;
Declarations_List :
Utils.Compilation_Unit_List_Access := null;
Declarations_Last : ASIS_Integer := 0;
begin
Dependence_Order (Result, Descending);
Declarations_List := new Asis.Compilation_Unit_List (1 .. List'Length);
for Index in List'Range loop
Unit := List (Index);
Kinds := Unit_Kind (Unit);
if Kinds in A_Subunit then
Asis.Implementation.Set_Status
(Data_Error, "Subunit not valid for Descendants request "
& Unit_Full_Name (Unit));
end if;
if Kinds in A_Library_Unit_Body then
Unit := Corresponding_Declaration (Unit);
Kinds := Unit_Kind (Unit);
end if;
if Kinds = A_Package
or else Kinds = A_Generic_Package
or else Kinds = A_Package_Instance
then
if not In_List (Declarations_List, Declarations_Last, Unit) then
Declarations_Last := Declarations_Last + 1;
Declarations_List (Declarations_Last) := Unit;
end if;
end if;
end loop;
for Index in 1 .. Declarations_Last loop
Unit := Declarations_List (Index);
if Find (Result, Unit) = null then
Second_Unit := Corresponding_Body (Unit, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Unit)
then
Retrive (Unit, Add_Child (Result, null, Unit, Second_Unit));
else
Retrive (Unit, Add_Child (Result, null, Unit));
end if;
end if;
end loop;
Deallocate (Declarations_List);
return Result;
exception
when others =>
Deallocate (Declarations_List);
Deallocate (Result);
raise;
end Get_Descendants;
--------------------
-- Get_Supporters --
--------------------
function Get_Supporters
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
Unit : Compilation_Unit;
Kinds : Unit_Kinds;
Result : Root_Tree_Access := new Root_Tree;
Node : Tree_Node_Access := null;
Std : Compilation_Unit :=
Library_Unit_Declaration ("Standard", The_Context);
procedure Append_Unit
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access);
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean := False);
procedure Retrive_Declarations
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean);
procedure Retrive_Body
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean);
procedure Retrive_Subunit
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access);
procedure Retrive_With_Clause
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False);
procedure Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False);
-- Append_Unit --
procedure Append_Unit
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access)
is
Exist_Node : Tree_Node_Access;
begin
Exist_Node := Find (Result, Unit);
if Exist_Node = null then
Node := Add_Child (Result, Node, Unit);
else
if Node /= null then
Glue_Nodes_Checked (Result, Node, Exist_Node);
Node := null;
end if;
end if;
end Append_Unit;
-- Retrive --
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean := False)
is
Internal_Node : Tree_Node_Access := Node;
begin
if Is_Nil (Unit) then
return;
end if;
Kinds := Unit_Kind (Unit);
if Kinds in A_Nonexistent_Declaration .. An_Unknown_Unit then
Append_Unit (Std, Internal_Node);
elsif Kinds in A_Subunit then
Retrive_Subunit (Unit, Node);
elsif Kinds in A_Procedure_Body .. A_Package_Body then
Retrive_Body (Unit, Node, First_Node);
else
Retrive_Declarations (Unit, Node, First_Node);
end if;
end Retrive;
-- Retrive_Declarations --
procedure Retrive_Declarations
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean)
is
Parent : Compilation_Unit;
Internal_Node : Tree_Node_Access := Node;
begin
if not First_Node then
Append_Unit (Unit, Internal_Node);
if Internal_Node = null then
return;
end if;
end if;
if Is_Identical (Unit, Std) then
return;
end if;
Check_10_1_1_26c_26b (Unit, Internal_Node);
Retrive_With_Clause (Unit, Internal_Node);
Parent := Corresponding_Parent_Declaration (Unit, The_Context);
while Unit_Kind (Parent) in
A_Procedure .. A_Generic_Package_Renaming
loop
Append_Unit (Parent, Internal_Node);
if Internal_Node = null
or else Is_Identical (Unit, Std)
then
return;
end if;
Check_10_1_1_26c_26b (Parent, Internal_Node);
Retrive_With_Clause (Parent, Internal_Node);
Parent := Corresponding_Parent_Declaration (Parent, The_Context);
end loop;
Retrive (Parent, Internal_Node);
end Retrive_Declarations;
-- Retrive_Body --
procedure Retrive_Body
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
First_Node : in Boolean)
is
Internal_Node : Tree_Node_Access := Node;
begin
if not First_Node then
Append_Unit (Unit, Internal_Node);
if Internal_Node = null then
return;
end if;
end if;
Check_10_1_1_26c_26b (Unit, Internal_Node, True);
Retrive_With_Clause (Unit, Internal_Node, True);
Retrive
(Corresponding_Parent_Declaration (Unit, The_Context),
Internal_Node);
end Retrive_Body;
-- Retrive_Subunit --
procedure Retrive_Subunit
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access)
is
Parent : Compilation_Unit;
vNode : Tree_Node_Access := Node;
begin
Check_10_1_1_26c_26b (Unit, null, True);
Retrive_With_Clause (Unit, null, True);
Parent := Corresponding_Subunit_Parent_Body (Unit);
while Unit_Kind (Parent) in A_Subunit loop
Append_Unit (Unit, vNode);
if vNode = null then
return;
end if;
Check_10_1_1_26c_26b (Parent, vNode, True);
Retrive_With_Clause (Parent, vNode, True);
Parent := Corresponding_Subunit_Parent_Body (Parent);
end loop;
Retrive (Parent, vNode);
end Retrive_Subunit;
-- Retrive_With_Clause --
procedure Retrive_With_Clause
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False)
is
With_List : constant Asis.Context_Clause_List :=
Asis.Elements.Context_Clause_Elements (Unit);
Internal_Unit : Compilation_Unit;
Exist_Node : Tree_Node_Access;
begin
for Index in With_List'Range loop
if Clause_Kind (With_List (Index).all) = A_With_Clause then
Internal_Unit := Get_Compilation_Unit
(Unit, With_List (Index), Index, The_Context);
if not Is_Nil (Internal_Unit) then
if not For_Body then
Retrive (Internal_Unit, Node);
else
Exist_Node := Find (Result, Internal_Unit);
if Exist_Node = null then
Exist_Node := Add_Child (Result, null, Internal_Unit);
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
Retrive (Internal_Unit, Exist_Node, True);
else
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
end if;
end if;
end if;
end if;
end loop;
end Retrive_With_Clause;
-- Check_10_1_1_26c_26b --
procedure Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False)
is
procedure Retrive_For_Body
(Unit : in Compilation_Unit);
Except : Compilation_Unit := Library_Unit_Declaration
("Ada.Exceptions", The_Context);
Sys : Compilation_Unit := Library_Unit_Declaration
("System", The_Context);
State : Check_10_1_1_26c_26b_Information;
-- Retrive_For_Body --
procedure Retrive_For_Body
(Unit : in Compilation_Unit)
is
Exist_Node : Tree_Node_Access;
begin
Exist_Node := Find (Result, Unit);
if Exist_Node = null then
Exist_Node := Add_Child (Result, null, Unit);
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
Retrive (Unit, Exist_Node, True);
else
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
end if;
end Retrive_For_Body;
begin
State := Check_10_1_1_26c_26b (Unit, The_Context);
if State.Exceptions then
if not For_Body then
Retrive (Except, Node);
else
Retrive_For_Body (Except);
end if;
end if;
if State.System then
if not For_Body then
Retrive (Sys, Node);
else
Retrive_For_Body (Sys);
end if;
end if;
end Check_10_1_1_26c_26b;
begin
Dependence_Order (Result, Ascending);
for Index in List'Range loop
Unit := List (Index);
if Find (Result, Unit) = null then
Retrive (Unit, null, True);
end if;
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Get_Supporters;
--------------------
-- Get_Dependents --
--------------------
function Get_Dependents
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
procedure Append_To_Node
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Glued : in out Tree_Node_Array_Access);
procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean);
function Have_Except
(Unit : in Compilation_Unit)
return Boolean;
function Have_Sys
(Unit : in Compilation_Unit)
return Boolean;
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access);
Result : Root_Tree_Access := new Root_Tree;
Unit, Body_Unit : Compilation_Unit;
Kinds : Unit_Kinds;
Except : Compilation_Unit := Library_Unit_Declaration
("Ada.Exceptions", The_Context);
Sys : Compilation_Unit := Library_Unit_Declaration
("System", The_Context);
procedure Append_To_Node
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Glued : in out Tree_Node_Array_Access)
is
Exist_Node : Tree_Node_Access := null;
Second_Unit : Compilation_Unit;
begin
Exist_Node := Find (Result, Unit);
Kinds := Unit_Kind (Unit);
if Kinds in A_Procedure .. A_Generic_Package then
if Exist_Node /= null then
if Is_Child (Result, Exist_Node) then
Set_Parent (Result, Exist_Node, Node);
else
Glue_Nodes_Checked (Result, Node, Exist_Node);
end if;
if not Is_Skip_Spec (Exist_Node) then
Glued := Append (Glued, Exist_Node);
else
Skip_Spec (Exist_Node, False);
end if;
else
Second_Unit := Corresponding_Body (Unit, The_Context);
Exist_Node := Add_Child (Result, Node, Unit, Second_Unit);
end if;
elsif Kinds in A_Library_Unit_Body then
if Exist_Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
else
Second_Unit := Corresponding_Declaration (Unit, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Unit)
then
Exist_Node := Find (Result, Second_Unit);
if Exist_Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
else
Exist_Node := Add_Child
(Result, null, Second_Unit, Unit, True);
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
else
Exist_Node := Add_Child (Result, null, Unit);
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
end if;
elsif Kinds in A_Subunit then
if Exist_Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
else
Exist_Node := Add_Child (Result, null, Unit);
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
else
if Exist_Node /= null then
Glue_Nodes_Checked (Result, Node, Exist_Node);
if not Is_Skip_Spec (Exist_Node) then
Glued := Append (Glued, Exist_Node);
else
Skip_Spec (Exist_Node, False);
end if;
else
Exist_Node := Add_Child (Result, Node, Unit);
end if;
end if;
end Append_To_Node;
procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean)
is
begin
null;
end Post_Operation;
-- Have_Except --
function Have_Except
(Unit : in Compilation_Unit)
return Boolean
is
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean);
Control : Traverse_Control := Continue;
State : Boolean := False;
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean)
is
use Asis.Elements;
begin
if Declaration_Kind (Element) =
A_Choice_Parameter_Specification
then
State := True;
Control := Terminate_Immediately;
end if;
end Pre_Operation;
procedure Check_Choice_Iterator is new
Asis.Iterator.Traverse_Element
(Boolean, Pre_Operation, Post_Operation);
begin
Check_Choice_Iterator
(Asis.Elements.Unit_Declaration (Unit), Control, State);
return State;
end Have_Except;
-- Have_Sys --
function Have_Sys
(Unit : in Compilation_Unit)
return Boolean
is
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean);
Control : Traverse_Control := Continue;
State : Boolean := False;
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Boolean)
is
use Asis.Elements;
begin
if Expression_Kind (Element) = An_Attribute_Reference
and then Attribute_Kind (Element) = An_Address_Attribute
then
State := True;
Control := Terminate_Immediately;
end if;
end Pre_Operation;
procedure Check_Choice_Iterator is new
Asis.Iterator.Traverse_Element
(Boolean, Pre_Operation, Post_Operation);
begin
Check_Choice_Iterator
(Asis.Elements.Unit_Declaration (Unit), Control, State);
return State;
end Have_Sys;
-- Retrive --
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access)
is
use Utils;
Exist_Node : Tree_Node_Access := null;
Glued : Tree_Node_Array_Access := null;
begin
if Is_Nil (Unit) then
return;
end if;
-- subunits --
if not Is_Nil (Get_Body (Node)) then
Get_Subunits (Result, Get_Body (Node), Node, The_Context);
end if;
-- childrens --
declare
Children_List : Asis.Compilation_Unit_List :=
Corresponding_Children (Unit, The_Context);
Children : Compilation_Unit;
Second_Unit : Compilation_Unit;
begin
for Index in Children_List'Range loop
Children := Children_List (Index);
if not Is_Nil (Children) then
Second_Unit := Nil_Compilation_Unit;
Kinds := Unit_Kind (Children);
Exist_Node := Find (Result, Children);
if Exist_Node /= null then
if Is_Child (Result, Exist_Node) then
Set_Parent (Result, Exist_Node, Node);
else
Glue_Nodes_Checked (Result, Node, Exist_Node);
end if;
if not Is_Skip_Spec (Exist_Node) then
Glued := Append (Glued, Exist_Node);
else
Skip_Spec (Exist_Node, False);
end if;
if Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body
(Children, The_Context);
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration
(Children, The_Context);
end if;
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Remove_From_List
(Children_List, Index + 1, Second_Unit);
end if;
else
if Kinds in
A_Procedure_Instance .. A_Generic_Package_Renaming
then
Exist_Node := Add_Child (Result, Node, Children);
elsif Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body
(Children, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Exist_Node := Add_Child
(Result, Node, Children, Second_Unit);
Remove_From_List
(Children_List, Index + 1, Second_Unit);
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration
(Children, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Exist_Node := Add_Child
(Result, Node, Second_Unit, Children);
Remove_From_List
(Children_List, Index + 1, Second_Unit);
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
end if;
end if;
end loop;
end;
-- with --
declare
Units : Asis.Compilation_Unit_List :=
Compilation_Units (The_Context);
Library : Compilation_Unit;
begin
for Index in Units'Range loop
Library := Units (Index);
if not Is_Nil (Library) then
if Have_With (Library, Unit, The_Context) then
Append_To_Node (Library, Node, Glued);
end if;
end if;
end loop;
end;
-- Ada.Exceptions --
if Is_Identical (Unit, Except) then
declare
Units : Asis.Compilation_Unit_List :=
Compilation_Units (The_Context);
Library : Compilation_Unit;
begin
for Index in Units'Range loop
Library := Units (Index);
if not Is_Nil (Library) then
if Have_Except (Library) then
Append_To_Node (Library, Node, Glued);
end if;
end if;
end loop;
end;
end if;
-- System --
if Is_Identical (Unit, Sys) then
declare
Units : Asis.Compilation_Unit_List :=
Compilation_Units (The_Context);
Library : Compilation_Unit;
begin
for Index in Units'Range loop
Library := Units (Index);
if not Is_Nil (Library) then
if Have_Sys (Library) then
Append_To_Node (Library, Node, Glued);
end if;
end if;
end loop;
end;
end if;
declare
Next : Tree_Node_Array_Access := Nexts (Node);
Next_Node : Tree_Node_Access;
Next_Unit : Compilation_Unit;
begin
if Next /= null then
for Index in Next'Range loop
Next_Node := Next (Index);
if Glued = null
or else not Utils.In_List
(Glued, Glued.all'Last, Next_Node)
then
Next_Unit := Get_Spec (Next_Node);
Kinds := Unit_Kind (Next_Unit);
if Kinds in
A_Procedure .. A_Generic_Package_Renaming
then
Retrive (Next_Unit, Next_Node);
elsif Kinds in
A_Procedure_Body .. A_Package_Body
then
Get_Subunits
(Result, Next_Unit, Next_Node, The_Context);
end if;
end if;
end loop;
end if;
end;
Deallocate (Glued);
exception
when others =>
Deallocate (Glued);
raise;
end Retrive;
begin
Dependence_Order (Result, Descending);
for Index in List'Range loop
Unit := List (Index);
if Find (Result, Unit) = null then
Kinds := Unit_Kind (Unit);
if Kinds in A_Procedure .. A_Generic_Package_Renaming then
Body_Unit := Corresponding_Body (Unit, The_Context);
if not Is_Identical (Body_Unit, Unit) then
Retrive (Unit, Add_Child
(Result, null, Unit, Body_Unit, True));
else
Retrive (Unit, null);
end if;
elsif Kinds in A_Procedure_Body .. A_Protected_Body_Subunit then
Get_Subunits
(Result, Unit, Add_Child (Result, null, Unit), The_Context);
end if;
end if;
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Get_Dependents;
----------------
-- Get_Family --
----------------
function Get_Family
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access);
Result : Root_Tree_Access := new Root_Tree;
Unit, Body_Unit : Compilation_Unit;
Kinds : Unit_Kinds;
-- Retrive --
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access)
is
use Utils;
Exist_Node : Tree_Node_Access := null;
Glued : Tree_Node_Array_Access := null;
begin
if Is_Nil (Unit) then
return;
end if;
-- subunits --
if not Is_Nil (Get_Body (Node)) then
Get_Subunits (Result, Get_Body (Node), Node, The_Context);
end if;
-- childrens --
declare
Children_List : Asis.Compilation_Unit_List :=
Corresponding_Children (Unit, The_Context);
Children : Compilation_Unit;
Second_Unit : Compilation_Unit;
begin
for Index in Children_List'Range loop
Children := Children_List (Index);
if not Is_Nil (Children) then
Second_Unit := Nil_Compilation_Unit;
Kinds := Unit_Kind (Children);
Exist_Node := Find (Result, Children);
if Exist_Node /= null then
Glue_Nodes_Checked (Result, Node, Exist_Node);
if Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body
(Children, The_Context);
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration
(Children, The_Context);
end if;
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Remove_From_List
(Children_List, Index + 1, Second_Unit);
end if;
else
if Kinds in
A_Procedure_Instance .. A_Generic_Package_Renaming
then
Exist_Node := Add_Child (Result, Node, Children);
elsif Kinds in A_Procedure .. A_Generic_Package then
Second_Unit := Corresponding_Body
(Children, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Exist_Node := Add_Child
(Result, Node, Children, Second_Unit);
Remove_From_List
(Children_List, Index + 1, Second_Unit);
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
elsif Kinds in A_Library_Unit_Body then
Second_Unit := Corresponding_Declaration
(Children, The_Context);
if not Is_Nil (Second_Unit)
and then not Is_Identical (Second_Unit, Children)
then
Exist_Node := Add_Child
(Result, Node, Second_Unit, Children);
Remove_From_List
(Children_List, Index + 1, Second_Unit);
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
else
Exist_Node := Add_Child (Result, Node, Children);
end if;
end if;
end if;
end loop;
end;
declare
Next : Tree_Node_Array_Access := Nexts (Node);
Next_Node : Tree_Node_Access;
Next_Unit : Compilation_Unit;
begin
if Next /= null then
for Index in Next'Range loop
Next_Node := Next (Index);
Next_Unit := Get_Spec (Next_Node);
Kinds := Unit_Kind (Next_Unit);
if Kinds in
A_Procedure .. A_Generic_Package_Renaming
then
Retrive (Next_Unit, Next_Node);
elsif Kinds in
A_Procedure_Body .. A_Package_Body
then
Get_Subunits
(Result, Next_Unit, Next_Node, The_Context);
end if;
end loop;
end if;
end;
end Retrive;
begin
Dependence_Order (Result, Descending);
for Index in List'Range loop
Unit := List (Index);
if Find (Result, Unit) = null then
Kinds := Unit_Kind (Unit);
if Kinds in A_Procedure .. A_Generic_Package_Renaming then
Body_Unit := Corresponding_Body (Unit, The_Context);
elsif Kinds in A_Procedure_Body .. A_Protected_Body_Subunit then
Body_Unit := Unit;
Unit := Corresponding_Declaration (Unit, The_Context);
end if;
if not Is_Identical (Body_Unit, Unit) then
Retrive (Unit, Add_Child (Result, null, Unit, Body_Unit));
else
Retrive (Unit, Add_Child (Result, null, Unit));
end if;
end if;
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Get_Family;
----------------------
-- Get_Needed_Units --
----------------------
function Get_Needed_Units
(List : in Asis.Compilation_Unit_List;
The_Context : in Asis.Context)
return Utils.Root_Tree_Access
is
use Utils;
Result : Root_Tree_Access := new Root_Tree;
Unit, Body_Unit : Compilation_Unit;
Kinds : Unit_Kinds;
Std : Compilation_Unit :=
Library_Unit_Declaration ("Standard", The_Context);
procedure Append_Unit
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access;
Unit_Body : in Compilation_Unit := Nil_Compilation_Unit);
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean := True);
procedure Retrive_Declarations
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean);
procedure Retrive_Body
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean);
procedure Retrive_Subunits
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access);
procedure Retrive_With_Clause
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False);
procedure Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False);
-- Append_Unit --
procedure Append_Unit
(Unit : in Compilation_Unit;
Node : in out Tree_Node_Access;
Unit_Body : in Compilation_Unit := Nil_Compilation_Unit)
is
Exist_Node : Tree_Node_Access;
begin
Exist_Node := Find (Result, Unit);
if Exist_Node = null then
if Is_Identical (Unit, Std) then
Node := Add_Child
(Result, Node, Unit, Nil_Compilation_Unit, True);
Node := null;
else
Node := Add_Child (Result, Node, Unit, Unit_Body);
end if;
else
if Node /= null then
Glue_Nodes_Checked (Result, Node, Exist_Node);
Node := null;
end if;
end if;
end Append_Unit;
-- Retrive --
procedure Retrive
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean := True)
is
Internal_Node : Tree_Node_Access := Node;
begin
if Is_Nil (Unit) then
return;
end if;
Kinds := Unit_Kind (Unit);
if Kinds in A_Nonexistent_Declaration .. An_Unknown_Unit then
null;
elsif Kinds in A_Subunit then
declare
Internal_Unit : Compilation_Unit := Unit;
begin
while Unit_Kind (Internal_Unit) in A_Subunit loop
Internal_Unit := Corresponding_Subunit_Parent_Body
(Internal_Unit, The_Context);
end loop;
Retrive_Declarations
(Corresponding_Declaration (Internal_Unit, The_Context),
Node, Add_Node);
end;
elsif Kinds in A_Procedure_Body .. A_Package_Body then
Retrive_Body (Unit, Node, Add_Node);
else
Retrive_Declarations (Unit, Node, Add_Node);
end if;
end Retrive;
-- Retrive_Declarations --
procedure Retrive_Declarations
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean)
is
Parent : Compilation_Unit;
Internal_Node : Tree_Node_Access := Node;
begin
Body_Unit := Corresponding_Body (Unit, The_Context);
if Add_Node then
if not Is_Identical (Body_Unit, Unit) then
Append_Unit (Unit, Internal_Node, Body_Unit);
else
Append_Unit (Unit, Internal_Node);
end if;
if Internal_Node = null then
return;
end if;
end if;
if Is_Identical (Unit, Std) then
return;
end if;
Check_10_1_1_26c_26b (Unit, Internal_Node);
Retrive_With_Clause (Unit, Internal_Node);
if not Is_Nil (Body_Unit) then
Retrive_Body (Body_Unit, Internal_Node, False);
end if;
Parent := Corresponding_Parent_Declaration (Unit, The_Context);
while Unit_Kind (Parent) in
A_Procedure .. A_Generic_Package_Renaming
loop
Body_Unit := Corresponding_Body (Parent, The_Context);
if not Is_Identical (Body_Unit, Parent) then
Append_Unit (Parent, Internal_Node, Body_Unit);
else
Append_Unit (Parent, Internal_Node);
end if;
if Internal_Node = null then
return;
end if;
Check_10_1_1_26c_26b (Parent, Internal_Node);
Retrive_With_Clause (Parent, Internal_Node);
if not Is_Nil (Body_Unit) then
Retrive_Body (Body_Unit, Internal_Node, False);
end if;
Parent := Corresponding_Parent_Declaration (Parent, The_Context);
end loop;
Retrive (Parent, Internal_Node);
end Retrive_Declarations;
-- Retrive_Body --
procedure Retrive_Body
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
Add_Node : in Boolean)
is
Internal_Node : Tree_Node_Access := Node;
begin
if Is_Nil (Unit) then
return;
end if;
if Add_Node then
Append_Unit (Unit, Internal_Node);
if Internal_Node = null then
return;
end if;
end if;
Check_10_1_1_26c_26b (Unit, Internal_Node, True);
Retrive_With_Clause (Unit, Internal_Node, True);
Retrive_Subunits (Unit, Internal_Node);
end Retrive_Body;
-- Retrive_Subunits --
procedure Retrive_Subunits
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access)
is
Sub : Asis.Compilation_Unit_List := Subunits (Unit, The_Context);
Sub_Unit : Compilation_Unit;
Exist_Node : Tree_Node_Access;
vNode : Tree_Node_Access := Node;
begin
for Index in Sub'Range loop
Sub_Unit := Sub (Index);
if not Is_Nil (Sub_Unit) then
Exist_Node := Find (Result, Sub_Unit);
if Exist_Node = null then
Exist_Node := Add_Subunit (Result, Node, Sub_Unit);
Check_10_1_1_26c_26b (Unit, Exist_Node, True);
Retrive_With_Clause (Unit, Exist_Node, True);
Retrive_Subunits (Sub_Unit, Exist_Node);
else
Glue_Nodes (Result, Exist_Node, Node);
end if;
end if;
end loop;
end Retrive_Subunits;
-- Retrive_With_Clause --
procedure Retrive_With_Clause
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False)
is
With_List : constant Asis.Context_Clause_List :=
Asis.Elements.Context_Clause_Elements (Unit);
Internal_Unit : Compilation_Unit;
Exist_Node : Tree_Node_Access;
begin
for Index in With_List'Range loop
if Clause_Kind (With_List (Index).all) = A_With_Clause then
Internal_Unit := Get_Compilation_Unit
(Unit, With_List (Index), Index, The_Context);
if not Is_Nil (Internal_Unit) then
if not For_Body then
Retrive (Internal_Unit, Node);
else
Exist_Node := Find (Result, Internal_Unit);
if Exist_Node = null then
Body_Unit := Corresponding_Body
(Internal_Unit, The_Context);
if not Is_Identical (Body_Unit, Internal_Unit) then
Exist_Node := Add_Child
(Result, null, Internal_Unit, Body_Unit);
else
Exist_Node := Add_Child
(Result, null, Internal_Unit);
end if;
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
Retrive (Internal_Unit, Exist_Node, False);
else
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
end if;
end if;
end if;
end if;
end loop;
end Retrive_With_Clause;
-- Check_10_1_1_26c_26b --
procedure Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
Node : in Tree_Node_Access;
For_Body : in Boolean := False)
is
procedure Retrive_For_Body
(Unit : in Compilation_Unit);
Except : Compilation_Unit := Library_Unit_Declaration
("Ada.Exceptions", The_Context);
Sys : Compilation_Unit := Library_Unit_Declaration
("System", The_Context);
State : Check_10_1_1_26c_26b_Information;
-- Retrive_For_Body --
procedure Retrive_For_Body
(Unit : in Compilation_Unit)
is
Exist_Node : Tree_Node_Access;
begin
Exist_Node := Find (Result, Unit);
if Exist_Node = null then
Body_Unit := Corresponding_Body (Unit, The_Context);
if not Is_Identical (Body_Unit, Unit) then
Exist_Node := Add_Child (Result, null, Unit, Body_Unit);
else
Exist_Node := Add_Child (Result, null, Unit);
end if;
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
Retrive (Unit, Exist_Node, False);
else
if Node /= null then
Add_Body_Dependents (Result, Exist_Node, Node);
end if;
end if;
end Retrive_For_Body;
begin
State := Check_10_1_1_26c_26b (Unit, The_Context);
if State.Exceptions then
if not For_Body then
Retrive (Except, Node);
else
Retrive_For_Body (Except);
end if;
end if;
if State.System then
if not For_Body then
Retrive (Sys, Node);
else
Retrive_For_Body (Sys);
end if;
end if;
end Check_10_1_1_26c_26b;
begin
Dependence_Order (Result, Ascending);
for Index in List'Range loop
Unit := List (Index);
if Find (Result, Unit) = null then
Retrive (Unit, null);
end if;
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Get_Needed_Units;
--------------------
-- Get_Subunits --
--------------------
procedure Get_Subunits
(Tree : in Utils.Root_Tree_Access;
Unit : in Compilation_Unit;
Node : in Utils.Tree_Node_Access;
The_Context : in Asis.Context)
is
use Utils;
Sub : Asis.Compilation_Unit_List := Subunits (Unit, The_Context);
Sub_Unit : Compilation_Unit;
Exist_Node : Tree_Node_Access;
begin
for Index in Sub'Range loop
Sub_Unit := Sub (Index);
if not Is_Nil (Sub_Unit) then
Exist_Node := Find (Tree, Sub_Unit);
if Exist_Node = null then
Exist_Node := Add_Child (Tree, Node, Sub_Unit);
Get_Subunits (Tree, Sub_Unit, Exist_Node, The_Context);
else
Glue_Nodes (Tree, Node, Exist_Node);
end if;
end if;
end loop;
end Get_Subunits;
--------------------------
-- Get_Compilation_Unit --
--------------------------
function Get_Compilation_Unit
(Unit : in Compilation_Unit;
Target : in Asis.Element;
Number : in List_Index;
The_Context : in Asis.Context)
return Asis.Compilation_Unit
is
use Utils;
Names : constant Asis.Name_List := Asis.Clauses.Clause_Names (Target);
Declaration : Asis.Element;
Internal_Unit : Asis.Compilation_Unit;
Result_List : Compilation_Unit_List_Access := null;
begin
for Index in Names'Range loop
if Expression_Kind (Names (Index).all) = An_Identifier then
Declaration := Asis.Expressions.Corresponding_Name_Declaration
(Names (Index));
else
-- A_Selected_Component
Declaration := Asis.Expressions.Corresponding_Name_Declaration
(Asis.Expressions.Selector (Names (Index)));
end if;
if Assigned (Declaration) then
Internal_Unit :=
Asis.Elements.Enclosing_Compilation_Unit (Declaration);
if Unit_Kind (Internal_Unit) in
A_Procedure .. A_Generic_Package_Renaming
then
Result_List := Append (Result_List, Internal_Unit);
end if;
end if;
end loop;
if Result_List = null then
return Nil_Compilation_Unit;
end if;
if Result_List.all'Length > 1 then
Ada.Wide_Text_IO.Put_Line
("[Warning] Founded more then one unit for one with_clause "
& "in unit " & Unit_Full_Name (Unit) & " clause number "
& List_Index'Wide_Image (Number));
end if;
declare
Result : Asis.Compilation_Unit :=
Result_List.all (Result_List.all'First);
begin
Deallocate (Result_List);
if Is_Nil (Result) then
Ada.Wide_Text_IO.Put_Line
("[Warning] Unit for with_clause in unit "
& Unit_Full_Name (Unit) & " clause number "
& List_Index'Wide_Image (Number) & " not found");
else
if Unit_Kind (Result) in A_Procedure_Body .. A_Package_Body then
Result := Corresponding_Declaration (Result, The_Context);
end if;
end if;
return Result;
end;
end Get_Compilation_Unit;
---------------
-- Have_With --
---------------
function Have_With
(Library : in Compilation_Unit;
Unit : in Compilation_Unit;
The_Context : in Asis.Context)
return Boolean
is
With_List : constant Asis.Context_Clause_List :=
Asis.Elements.Context_Clause_Elements (Library);
Internal_Unit : Compilation_Unit;
begin
for Index in With_List'Range loop
if Clause_Kind (With_List (Index).all) = A_With_Clause then
Internal_Unit := Get_Compilation_Unit
(Library, With_List (Index), Index, The_Context);
if not Is_Nil (Internal_Unit)
and then Is_Identical (Internal_Unit, Unit)
then
return True;
end if;
end if;
end loop;
return False;
end Have_With;
--------------------------
-- Check_10_1_1_26c_26b --
--------------------------
function Check_10_1_1_26c_26b
(Unit : in Compilation_Unit;
The_Context : in Asis.Context)
return Check_10_1_1_26c_26b_Information
is
-- 10.1.1 (26.c)
-- 10.1.1 (26.b)
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Check_10_1_1_26c_26b_Information);
procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Check_10_1_1_26c_26b_Information);
Except : Compilation_Unit := Library_Unit_Declaration
("Ada.Exceptions", The_Context);
Sys : Compilation_Unit := Library_Unit_Declaration
("System", The_Context);
Is_Except : Boolean;
Is_Sys : Boolean;
Control : Traverse_Control := Continue;
State : Check_10_1_1_26c_26b_Information;
procedure Pre_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Check_10_1_1_26c_26b_Information)
is
use Asis.Elements;
begin
if not Is_Except
and then Declaration_Kind (Element) =
A_Choice_Parameter_Specification
then
State.Exceptions := True;
end if;
if not Is_Sys
and then Expression_Kind (Element) = An_Attribute_Reference
and then Attribute_Kind (Element) = An_Address_Attribute
then
State.System := True;
end if;
end Pre_Operation;
procedure Post_Operation
(Element : in Asis.Element;
Control : in out Traverse_Control;
State : in out Check_10_1_1_26c_26b_Information)
is
begin
null;
end Post_Operation;
procedure Check_Choice_Iterator is new
Asis.Iterator.Traverse_Element
(Check_10_1_1_26c_26b_Information, Pre_Operation, Post_Operation);
begin
Is_Except := Is_Identical (Unit, Except);
Is_Sys := Is_Identical (Unit, Sys);
Check_Choice_Iterator
(Asis.Elements.Unit_Declaration (Unit), Control, State);
return State;
end Check_10_1_1_26c_26b;
------------
-- Utils --
------------
package body Utils is
-------------
-- In_List --
-------------
function In_List
(List : in Tree_Node_Array_Access;
Last : in Natural;
Node : in Tree_Node_Access)
return Boolean
is
begin
for Index in 1 .. Last loop
if List (Index) = Node then
return True;
end if;
end loop;
return False;
end In_List;
----------------------
-- Dependence_Order --
----------------------
procedure Dependence_Order
(This : in Root_Tree_Access;
Order : in Orders)
is
begin
This.Order := Order;
end Dependence_Order;
---------------
-- Add_Child --
---------------
function Add_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access
is
Kinds : Unit_Kinds;
begin
if Is_Nil (Unit) then
return Node;
end if;
declare
New_Node : Tree_Node_Access := new Tree_Node;
begin
Kinds := Unit_Kind (Unit);
if Kinds in A_Procedure .. A_Generic_Package_Renaming
or else Kinds = A_Nonexistent_Declaration
then
New_Node.Unit := Unit;
else
New_Node.Unit_Body := Unit;
end if;
if Node = null then
This.Next := Add_Node (This.Next, New_Node.Self);
else
Node.Next := Add_Node (Node.Next, New_Node.Self);
New_Node.Prevs := Add_Node (New_Node.Prevs, Node.Self);
end if;
This.Units := Add_Node_Ordered (This.Units, New_Node.Self);
return New_Node;
end;
end Add_Child;
-- Add_Child --
function Add_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Spec_Unit : in Compilation_Unit;
Body_Unit : in Compilation_Unit;
Skip_Spec : in Boolean := False)
return Tree_Node_Access
is
Kinds : Unit_Kinds;
begin
if Is_Nil (Spec_Unit)
and then Is_Nil (Body_Unit)
then
return Node;
end if;
if not Is_Nil (Spec_Unit) then
Kinds := Unit_Kind (Spec_Unit);
if Kinds not in A_Procedure .. A_Generic_Package_Renaming
and then Kinds = A_Nonexistent_Declaration
then
Asis.Implementation.Set_Status
(Data_Error, "Add_Child - "
& "invalid unit specification "
& Unit_Full_Name (Spec_Unit));
raise Asis.Exceptions.ASIS_Failed;
end if;
end if;
if not Is_Identical (Spec_Unit, Body_Unit) then
if not Is_Nil (Body_Unit) then
Kinds := Unit_Kind (Body_Unit);
if Kinds in A_Procedure .. A_Generic_Package_Renaming
or else Kinds = A_Nonexistent_Declaration
then
Asis.Implementation.Set_Status
(Data_Error, "Add_Child - "
& "invalid unit body " & Unit_Full_Name (Body_Unit));
raise Asis.Exceptions.ASIS_Failed;
end if;
end if;
end if;
declare
New_Node : Tree_Node_Access := new Tree_Node;
begin
New_Node.Unit := Spec_Unit;
if not Is_Identical (Spec_Unit, Body_Unit) then
New_Node.Unit_Body := Body_Unit;
end if;
New_Node.Skip_Spec := Skip_Spec;
if Node = null then
This.Next := Add_Node (This.Next, New_Node.Self);
else
Node.Next := Add_Node (Node.Next, New_Node.Self);
New_Node.Prevs := Add_Node (New_Node.Prevs, Node.Self);
end if;
This.Units := Add_Node_Ordered (This.Units, New_Node.Self);
return New_Node;
end;
end Add_Child;
-----------------
-- Add_Subunit --
-----------------
function Add_Subunit
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access
is
Kinds : Unit_Kinds;
begin
if Is_Nil (Unit) then
return Node;
end if;
Kinds := Unit_Kind (Unit);
if Kinds not in
A_Procedure_Body_Subunit .. A_Protected_Body_Subunit
then
Asis.Implementation.Set_Status
(Data_Error, "Add_Subunit - "
& "invalid subunit " & Unit_Full_Name (Unit));
raise Asis.Exceptions.ASIS_Failed;
end if;
declare
New_Node : Tree_Node_Access := new Tree_Node;
begin
New_Node.Unit_Body := Unit;
if Node = null then
This.Next := Add_Node (This.Next, New_Node.Self);
else
Node.Prevs := Add_Node (Node.Prevs, New_Node.Self);
New_Node.Next := Add_Node (New_Node.Next, Node.Self);
end if;
This.Units := Add_Node_Ordered (This.Units, New_Node.Self);
return New_Node;
end;
end Add_Subunit;
------------
-- Append --
------------
procedure Append
(This : in Root_Tree_Access;
Unit : in Compilation_Unit)
is
begin
if Is_Nil (Unit) then
return;
end if;
if Find (This, Unit) /= null then
Asis.Implementation.Set_Status
(Asis.Errors.Internal_Error,
"Elaboration order dublicate unit: " & Unit_Full_Name (Unit));
raise Asis.Exceptions.ASIS_Failed;
end if;
declare
Kinds : Unit_Kinds;
New_Node : Tree_Node_Access := new Tree_Node;
begin
Kinds := Unit_Kind (Unit);
if Kinds in A_Procedure .. A_Generic_Package_Renaming
or else Kinds = A_Nonexistent_Declaration
then
New_Node.Unit := Unit;
else
New_Node.Unit_Body := Unit;
end if;
if This.Last_Node = null then
This.Next := Add_Node (This.Next, New_Node.Self);
else
This.Last_Node.Next := Add_Node
(This.Last_Node.Next, New_Node.Self);
New_Node.Prevs := Add_Node
(New_Node.Prevs, This.Last_Node.Self);
end if;
This.Last_Node := New_Node;
This.Units := Add_Node_Ordered (This.Units, New_Node.Self);
end;
end Append;
----------------
-- Glue_Nodes --
----------------
procedure Glue_Nodes
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access)
is
begin
if To_Node.Prevs /= null
and then In_List (To_Node.Prevs, To_Node.Prevs'Last, Node)
then
return;
end if;
Node.Next := Add_Node (Node.Next, To_Node.Self);
To_Node.Prevs := Add_Node (To_Node.Prevs, Node.Self);
end Glue_Nodes;
------------------------
-- Glue_Nodes_Checked --
------------------------
procedure Glue_Nodes_Checked
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access)
is
Circular : Compilation_Unit_List_Access := null;
Prev_Node : Tree_Node_Access := null;
begin
if To_Node.Prevs /= null then
Prev_Node := To_Node.Prevs (To_Node.Prevs.all'First);
if In_List (To_Node.Prevs, To_Node.Prevs'Last, Node) then
return;
end if;
end if;
while Prev_Node /= null loop
if Prev_Node = To_Node then
if Circular /= null then
for Index in reverse Circular.all'Range loop
Node.Circular := Append (Node.Circular, Circular (Index));
end loop;
Node.Circular := Append (Node.Circular, Node.Unit);
Node.Circular := Append
(Node.Circular, Circular (Circular.all'Last));
Deallocate (Circular);
else
-- 2 pair (self and parent)
Node.Circular := Append
(Node.Circular,
(Prev_Node.Unit, Node.Unit, Prev_Node.Unit));
end if;
return;
end if;
Circular := Append (Circular, Prev_Node.Unit);
if Prev_Node.Prevs /= null then
Prev_Node := Prev_Node.Prevs (Prev_Node.Prevs.all'First);
else
Prev_Node := null;
end if;
end loop;
if Circular /= null then
Deallocate (Circular);
end if;
Node.Next := Add_Node (Node.Next, To_Node.Self);
To_Node.Prevs := Add_Node (To_Node.Prevs, Node.Self);
end Glue_Nodes_Checked;
-------------------------
-- Add_Body_Dependents --
-------------------------
procedure Add_Body_Dependents
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
To_Node : in Tree_Node_Access)
is
begin
Node.Body_Dependences := Add_Node (Node.Body_Dependences, To_Node);
end Add_Body_Dependents;
--------------
-- Is_Child --
--------------
function Is_Child
(This : in Root_Tree_Access;
Node : in Tree_Node_Access)
return Boolean
is
begin
if This.Next /= null then
return In_List (This.Next, This.Next'Last, Node);
else
return False;
end if;
end Is_Child;
----------------
-- Set_Parent --
----------------
procedure Set_Parent
(This : in Root_Tree_Access;
Node : in Tree_Node_Access;
Parent : in Tree_Node_Access)
is
begin
Parent.Next := Add_Node (Parent.Next, Node.Self);
Node.Prevs := Add_Node (Node.Prevs, Parent.Self);
end Set_Parent;
-----------
-- Clear --
-----------
procedure Clear
(This : in out Root_Tree)
is
begin
Finalize (This);
end Clear;
-----------
-- Check --
-----------
procedure Check
(This : in Root_Tree_Access;
The_Context : in Asis.Context)
is
Kinds, Parent_Kinds : Unit_Kinds;
Order : Orders;
procedure Check_Consistent
(Node : in Tree_Node_Access);
function Set_Inconsistent
(Node : in Tree_Node_Access;
Prev : in Tree_Node_Access;
List : in Compilation_Unit_List_Access)
return Compilation_Unit_List_Access;
procedure Check_Body_Consistent
(Node : in Tree_Node_Access);
procedure Check_Missing
(Node : in Tree_Node_Access);
procedure Asc
(Node : in Tree_Node_Access);
procedure Desc
(Node : in Tree_Node_Access);
-- Check_Consistent --
procedure Check_Consistent
(Node : in Tree_Node_Access)
is
Prev_Node : Tree_Node_Access;
begin
if Is_Inconsistent (Node.Unit) then
return;
end if;
Node.Consistent := False;
if Is_Source_Changed (Node.Unit) then
Node.Inconsistent := Append
(Node.Inconsistent, (Nil_Compilation_Unit, Node.Unit));
else
Prev_Node := null;
if Order = Ascending then
if Node.Prevs /= null then
Prev_Node := Node.Prevs (Node.Prevs.all'First);
end if;
else
if Node.Next /= null then
Prev_Node := Node.Next (Node.Next.all'First);
end if;
end if;
if Prev_Node /= null
and then not Is_Nil (Prev_Node.Unit)
then
Node.Inconsistent := Append
(Node.Inconsistent, (Prev_Node.Unit, Node.Unit));
else
Node.Inconsistent := Append
(Node.Inconsistent, (Node.Unit, Node.Unit));
end if;
end if;
if Order = Ascending then
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Node.Inconsistent := Set_Inconsistent
(Node.Next.all (Index), Node, Node.Inconsistent);
end loop;
end if;
else
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Node.Inconsistent := Set_Inconsistent
(Node.Prevs.all (Index), Node, Node.Inconsistent);
end loop;
end if;
end if;
end Check_Consistent;
-- Set_Inconsistent --
function Set_Inconsistent
(Node : in Tree_Node_Access;
Prev : in Tree_Node_Access;
List : in Compilation_Unit_List_Access)
return Compilation_Unit_List_Access
is
Result : Compilation_Unit_List_Access := List;
begin
if not Node.Consistent
and then Node.Inconsistent /= null
then
if Is_Nil
(Node.Inconsistent (Node.Inconsistent'First))
then
Result := Append
(Result, (Nil_Compilation_Unit, Node.Unit));
end if;
Node.Inconsistent (Node.Inconsistent'First) := Prev.Unit;
Result := Append (Result, Node.Inconsistent.all);
Deallocate (Node.Inconsistent);
return Result;
end if;
if not Is_Nil (Node.Unit) then
Node.Consistent := False;
Result := Append (Result, (Prev.Unit, Node.Unit));
end if;
if Order = Ascending then
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Result := Set_Inconsistent
(Node.Next.all (Index), Node, Result);
end loop;
end if;
else
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Result := Set_Inconsistent
(Node.Prevs.all (Index), Node, Result);
end loop;
end if;
end if;
return Result;
end Set_Inconsistent;
-- Check_Body_Consistent --
procedure Check_Body_Consistent
(Node : in Tree_Node_Access)
is
procedure Check_Body
(Target : in Tree_Node_Access);
Prev_Unit : Compilation_Unit;
-- Check_Body --
procedure Check_Body
(Target : in Tree_Node_Access)
is
begin
if not Is_Nil (Target.Unit_Body) then
Prev_Unit := Target.Unit_Body;
if not Target.Body_Consistent then
Node.Body_Consistent := False;
Node.Inconsistent := Append
(Node.Inconsistent, (Prev_Unit, Node.Unit_Body));
end if;
end if;
end Check_Body;
begin
if not Is_Nil (Node.Unit_Body) then
if not Node.Consistent then
Node.Body_Consistent := False;
Node.Inconsistent := Append
(Node.Inconsistent, (Node.Unit, Node.Unit_Body));
end if;
if not Is_Inconsistent (Node.Unit_Body) then
Node.Body_Consistent := False;
if Is_Source_Changed (Node.Unit_Body) then
Node.Inconsistent := Append
(Node.Inconsistent,
(Nil_Compilation_Unit, Node.Unit_Body));
else
Node.Inconsistent := Append
(Node.Inconsistent, (Node.Unit_Body, Node.Unit_Body));
end if;
end if;
if Node.Body_Dependences /= null then
for Index in Node.Body_Dependences.all'Range loop
Prev_Unit := Node.Body_Dependences (Index).Unit;
if not Is_Inconsistent (Prev_Unit) then
Node.Body_Consistent := False;
Node.Inconsistent := Append
(Node.Inconsistent, (Prev_Unit, Node.Unit_Body));
end if;
end loop;
end if;
if Unit_Kind (Node.Unit_Body) in A_Subunit then
if Order = Ascending then
if Node.Next /= null then
Check_Body (Node.Next (Node.Next'First));
end if;
else
if Node.Prevs /= null then
Check_Body (Node.Prevs (Node.Prevs'First));
end if;
end if;
end if;
end if;
if Order = Ascending then
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Check_Body_Consistent (Node.Next.all (Index));
end loop;
end if;
else
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Check_Body_Consistent (Node.Prevs.all (Index));
end loop;
end if;
end if;
end Check_Body_Consistent;
-- Check_Missing --
procedure Check_Missing
(Node : in Tree_Node_Access)
is
procedure Check_Missing
(Node : in Tree_Node_Access;
Target : in Tree_Node_Access)
is
begin
if Target = null
or else Is_Nil (Target.Unit)
then
return;
end if;
Parent_Kinds := Unit_Kind (Target.Unit);
if Parent_Kinds = A_Nonexistent_Declaration then
Node.Missing := Append
(Node.Missing, (Node.Unit, Target.Unit));
end if;
end Check_Missing;
begin
if Node.Missing /= null then
return;
end if;
if Order = Ascending then
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Check_Missing (Node, Node.Next (Index));
end loop;
end if;
else
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Check_Missing (Node, Node.Prevs (Index));
end loop;
end if;
end if;
if Is_Nil (Node.Unit_Body) then
return;
end if;
if Unit_Kind (Node.Unit) = A_Nonexistent_Declaration then
Node.Missing := Append
(Node.Missing, (Node.Unit_Body, Node.Unit));
end if;
if Node.Body_Dependences /= null then
for Index in Node.Body_Dependences.all'Range loop
Parent_Kinds :=
Unit_Kind (Node.Body_Dependences (Index).Unit);
if Parent_Kinds = A_Nonexistent_Declaration then
Node.Missing := Append
(Node.Missing,
(Node.Unit_Body,
Node.Body_Dependences (Index).Unit));
end if;
end loop;
end if;
if Unit_Kind (Node.Unit_Body) in A_Subunit then
if Order = Ascending then
if Node.Next /= null then
if Unit_Kind
(Node.Next (Node.Next'First).Unit_Body) =
A_Nonexistent_Body
then
Node.Missing := Append
(Node.Missing,
(Node.Unit_Body,
Node.Next (Node.Next'First).Unit_Body));
end if;
end if;
else
if Node.Prevs /= null then
if Unit_Kind
(Node.Prevs (Node.Prevs'First).Unit_Body) =
A_Nonexistent_Body
then
Node.Missing := Append
(Node.Missing,
(Node.Unit_Body,
Node.Prevs (Node.Prevs'First).Unit_Body));
end if;
end if;
end if;
end if;
end Check_Missing;
-- Asc --
procedure Asc
(Node : in Tree_Node_Access)
is
begin
if Node = null then
return;
end if;
if not Is_Nil (Node.Unit) then
if Node.Consistent then
Check_Consistent (Node);
end if;
Check_Missing (Node);
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Asc (Node.Prevs.all (Index));
end loop;
end if;
end Asc;
-- Desc --
procedure Desc
(Node : in Tree_Node_Access)
is
begin
if Node = null then
return;
end if;
if not Is_Nil (Node.Unit) then
Kinds := Unit_Kind (Node.Unit);
if Node.Consistent then
Check_Consistent (Node);
end if;
Check_Missing (Node);
end if;
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Desc (Node.Next (Index));
end loop;
end if;
end Desc;
Std_Node : Tree_Node_Access;
begin
Order := This.Order;
if This.Order = Ascending then
Std_Node := Find
(This, Library_Unit_Declaration ("Standard", The_Context));
if Std_Node /= null then
if Std_Node.Next /= null then
for Index in Std_Node.Next.all'Range loop
Asc (Std_Node.Next (Index));
end loop;
for Index in Std_Node.Next.all'Range loop
Check_Body_Consistent (Std_Node.Next (Index));
end loop;
end if;
end if;
else
if This.Next /= null then
for Index in This.Next.all'Range loop
Desc (This.Next (Index));
end loop;
for Index in This.Next.all'Range loop
Check_Body_Consistent (This.Next (Index));
end loop;
end if;
end if;
end Check;
---------------------------
-- Generate_Relationship --
---------------------------
function Generate_Relationship
(This : in Root_Tree_Access;
Limit_List : in Utils.Compilation_Unit_List_Access;
List_Last : in ASIS_Integer)
return Relationship
is
Consistent_List : Compilation_Unit_List_Access := null;
Inconsistent_List : Compilation_Unit_List_Access := null;
Missing_List : Compilation_Unit_List_Access := null;
Circular_List : Compilation_Unit_List_Access := null;
Consistent_Length : Asis.ASIS_Natural := 0;
Inconsistent_Length : Asis.ASIS_Natural := 0;
Missing_Length : Asis.ASIS_Natural := 0;
Circular_Length : Asis.ASIS_Natural := 0;
procedure Genegate_Inconsistent
(Node : in Tree_Node_Access);
procedure Genegate_Circular
(Node : in Tree_Node_Access);
procedure Genegate_Missing
(Node : in Tree_Node_Access);
procedure Process
(Node : in Tree_Node_Access);
-- Genegate_Inconsistent --
procedure Genegate_Inconsistent
(Node : in Tree_Node_Access)
is
begin
if Node.Inconsistent /= null
and then not Node.Inconsistent_Added
then
Node.Inconsistent_Added := True;
if Inconsistent_List = null then
Inconsistent_List := Append
(Inconsistent_List, Node.Inconsistent.all);
else
if not Is_Nil (Node.Inconsistent (Node.Inconsistent'First))
and then Is_Inconsistent
(Node.Inconsistent (Node.Inconsistent'First))
then
Node.Inconsistent (Node.Inconsistent'First) :=
Node.Inconsistent (Node.Inconsistent'First + 1);
end if;
Inconsistent_List := Append
(Inconsistent_List, Node.Inconsistent.all);
end if;
end if;
end Genegate_Inconsistent;
-- Genegate_Circular --
procedure Genegate_Circular
(Node : in Tree_Node_Access)
is
begin
if Node.Circular /= null
and then not Node.Circular_Added
then
Node.Circular_Added := True;
for Index in
Node.Circular.all'First .. Node.Circular.all'Last - 1
loop
Circular_List := Append
(Circular_List, (Node.Circular.all (Index),
Node.Circular.all (Index + 1))
);
end loop;
end if;
end Genegate_Circular;
-- Genegate_Missing --
procedure Genegate_Missing
(Node : in Tree_Node_Access)
is
begin
if Node.Missing /= null
and then not Node.Missing_Added
then
Node.Missing_Added := True;
Missing_List := Append (Missing_List, Node.Missing.all);
end if;
end Genegate_Missing;
-- Process --
procedure Process
(Node : in Tree_Node_Access)
is
-- Add_To_Consistent --
procedure Add_To_Consistent
(Unit : in Compilation_Unit)
is
begin
if Limit_List /= null then
if In_List (Limit_List, List_Last, Unit) then
Consistent_List := Append (Consistent_List, Unit);
end if;
else
Consistent_List := Append (Consistent_List, Unit);
end if;
end Add_To_Consistent;
begin
if Node.Added then
return;
end if;
Node.Added := True;
if Node.Consistent then
if not Node.Skip_Spec
and then not Is_Nil (Node.Unit)
then
Add_To_Consistent (Node.Unit);
end if;
if Node.Body_Consistent
and then not Is_Nil (Node.Unit_Body)
then
Add_To_Consistent (Node.Unit_Body);
end if;
end if;
Genegate_Inconsistent (Node);
Genegate_Missing (Node);
Genegate_Circular (Node);
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Process (Node.Next.all (Index));
end loop;
end if;
end Process;
begin
if This.Next = null then
return Nil_Relationship;
end if;
for Index in This.Next.all'Range loop
Process (This.Next.all (Index));
end loop;
if Consistent_List /= null then
Consistent_Length := Consistent_List.all'Length;
end if;
if Inconsistent_List /= null then
Inconsistent_Length := Inconsistent_List.all'Length;
end if;
if Missing_List /= null then
Missing_Length := Missing_List.all'Length;
end if;
if Circular_List /= null then
Circular_Length := Circular_List.all'Length;
end if;
declare
Result : Relationship
(Consistent_Length, Inconsistent_Length,
Missing_Length, Circular_Length);
begin
if Consistent_List /= null then
Result.Consistent := Consistent_List.all;
end if;
if Inconsistent_List /= null then
Result.Inconsistent := Inconsistent_List.all;
end if;
if Missing_List /= null then
Result.Missing := Missing_List.all;
end if;
if Circular_List /= null then
Result.Circular := Circular_List.all;
end if;
Deallocate (Consistent_List);
Deallocate (Inconsistent_List);
Deallocate (Missing_List);
Deallocate (Circular_List);
return Result;
end;
exception
when others =>
Deallocate (Consistent_List);
Deallocate (Inconsistent_List);
Deallocate (Missing_List);
Deallocate (Circular_List);
raise;
end Generate_Relationship;
----------------------------------
-- Is_Have_Circular_Dependences --
----------------------------------
function Is_Have_Circular_Dependences
(This : in Root_Tree_Access)
return Boolean
is
function Process
(Node : in Tree_Node_Access)
return Boolean;
Result : Boolean := False;
-- Process --
function Process
(Node : in Tree_Node_Access)
return Boolean
is
Result : Boolean := False;
begin
if Node.Circular /= null then
return True;
else
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Result := Process (Node.Next.all (Index));
exit when Result;
end loop;
end if;
end if;
return Result;
end Process;
begin
if This.Next /= null then
for Index in This.Next.all'Range loop
Result := Process (This.Next.all (Index));
exit when Result;
end loop;
end if;
return Result;
end Is_Have_Circular_Dependences;
-----------------------------
-- Create_Elaboration_Tree --
-----------------------------
-- A_Partition_Elaboration_Policy_Pragma, -- H.6 (3)
-- A_Preelaborable_Initialization_Pragma, -- 7.6 (5)
function Create_Elaboration_Tree
(This : in Root_Tree_Access;
The_Context : in Asis.Context)
return Root_Tree_Access
is
procedure Process_Pure_Spec
(Node : in Tree_Node_Access);
procedure Process_Pure_Body
(Node : in Tree_Node_Access);
procedure Process_Preelaborate_Spec
(Node : in Tree_Node_Access);
procedure Process_Preelaborate_Body
(Node : in Tree_Node_Access);
procedure Process_Spec
(Node : in Tree_Node_Access);
procedure Process_Body
(Node : in Tree_Node_Access);
procedure Elab_Spec
(Node : in Tree_Node_Access);
procedure Elab_Body
(Node : in Tree_Node_Access;
All_Bodys : in Boolean := False;
Only_Body : in Boolean := True);
procedure Elab_Subunits
(Node : in Tree_Node_Access;
All_Bodys : in Boolean);
procedure Elab_Pragmed_Bodys
(Node : in Tree_Node_Access;
Unit : in Compilation_Unit);
procedure Append_Inconsistent
(Node : in Tree_Node_Access);
Result : Root_Tree_Access := new Root_Tree;
Root_Node : Tree_Node_Access;
Std : Compilation_Unit :=
Library_Unit_Declaration ("Standard", The_Context);
-- for circular elaboration order
Elaboration_Line : Compilation_Unit_List_Access := null;
procedure Elab_Spec
(Node : in Tree_Node_Access)
is
begin
if not Node.Elaborated
and then Node.Consistent
and then not Is_Nil (Node.Unit)
then
if Elaboration_Line /= null then
-- test circular --
if In_List
(Elaboration_Line, Elaboration_Line.all'Last, Node.Unit)
then
Node.Circular := Append
(Node.Circular, Elaboration_Line.all);
return;
end if;
end if;
Elaboration_Line := Append
(Elaboration_Line, Node.Unit);
if Node.Next /= null then
for Index in Node.Next.all'Range loop
Elab_Spec (Node.Next (Index));
end loop;
end if;
Elab_Pragmed_Bodys (Node, Node.Unit);
Append (Result, Node.Unit);
Node.Elaborated := True;
Remove_From_List (Elaboration_Line, Node.Unit);
end if;
if Is_Elaborate_Body (Node) then
-- An_Elaborate_Body_Pragma -- 10.2.1(22)
Elab_Body (Node);
end if;
end Elab_Spec;
-- Elab_Body --
procedure Elab_Body
(Node : in Tree_Node_Access;
All_Bodys : in Boolean := False;
Only_Body : in Boolean := True)
is
Unit : Compilation_Unit := Node.Unit_Body;
begin
if Node.Body_Elaborated then
Elab_Subunits (Node, All_Bodys);
return;
end if;
if not Node.Body_Consistent
or else Is_Nil (Unit)
then
return;
end if;
if Only_Body
and then Unit_Kind (Unit) not in
A_Procedure_Body .. A_Package_Body
then
return;
end if;
if not Only_Body
and then Unit_Kind (Unit) not in A_Subunit
then
Elab_Subunits (Node, All_Bodys);
return;
end if;
if Elaboration_Line /= null then
-- test circular --
if In_List
(Elaboration_Line, Elaboration_Line.all'Last, Unit)
then
Node.Circular := Append
(Node.Circular, Elaboration_Line.all);
return;
end if;
end if;
Elaboration_Line := Append (Elaboration_Line, Unit);
if Node.Body_Dependences /= null then
for Index in Node.Body_Dependences.all'Range loop
Elab_Spec (Node.Body_Dependences (Index));
end loop;
end if;
Elab_Pragmed_Bodys (Node, Unit);
if All_Bodys then
if Node.Body_Dependences /= null then
for Index in Node.Body_Dependences.all'Range loop
Elab_Body (Node.Body_Dependences (Index), True, True);
end loop;
end if;
end if;
Append (Result, Unit);
Node.Body_Elaborated := True;
Remove_From_List (Elaboration_Line, Unit);
Elab_Subunits (Node, All_Bodys);
end Elab_Body;
-- Elab_Subunits --
procedure Elab_Subunits
(Node : in Tree_Node_Access;
All_Bodys : in Boolean)
is
Next_Node : Tree_Node_Access;
begin
if not Node.Body_Elaborated then
return;
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Next_Node := Node.Prevs (Index);
if Unit_Kind (Next_Node.Unit_Body) in
A_Procedure_Body_Subunit .. A_Protected_Body_Subunit
then
Elab_Body (Next_Node, All_Bodys, False);
end if;
end loop;
end if;
end Elab_Subunits;
-- Elab_Pragmed_Bodys --
procedure Elab_Pragmed_Bodys
(Node : in Tree_Node_Access;
Unit : in Compilation_Unit)
is
-- An_Elaborate_Pragma -- 10.2.1(20)
-- An_Elaborate_All_Pragma -- 10.2.1(21)
use Asis.Elements;
With_List : constant Asis.Context_Clause_List :=
Context_Clause_Elements (Unit, True);
El : Element;
Internal_Unit : Compilation_Unit;
begin
for Index in With_List'Range loop
El := With_List (Index);
if Element_Kind (El) = A_Pragma then
if Pragma_Kind (El) = An_Elaborate_Pragma then
Internal_Unit := Get_Compilation_Unit
(Unit, With_List (Index), Index, The_Context);
Elab_Body (Find (Result, Internal_Unit));
elsif Pragma_Kind (El) = An_Elaborate_All_Pragma then
Internal_Unit := Get_Compilation_Unit
(Unit, With_List (Index), Index, The_Context);
Elab_Body (Find (Result, Internal_Unit), True);
end if;
end if;
end loop;
end Elab_Pragmed_Bodys;
-- Process_Pure_Spec --
procedure Process_Pure_Spec
(Node : in Tree_Node_Access)
is
-- A_Pure_Pragma -- 10.2.1(14)
begin
if not Node.Elaborated
and then not Is_Nil (Node.Unit)
then
if Is_Pure (Node) then
Elab_Spec (Node);
end if;
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Pure_Spec (Node.Prevs (Index));
end loop;
end if;
end Process_Pure_Spec;
-- Process_Pure_Body --
procedure Process_Pure_Body
(Node : in Tree_Node_Access)
is
-- A_Pure_Pragma -- 10.2.1(14)
begin
if Is_Pure (Node) then
Elab_Body (Node);
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Pure_Body (Node.Prevs (Index));
end loop;
end if;
end Process_Pure_Body;
-- Process_Preelaborate_Spec --
procedure Process_Preelaborate_Spec
(Node : in Tree_Node_Access)
is
-- A_Preelaborate_Pragma -- 10.2.1(3)
begin
if not Node.Elaborated
and then not Is_Nil (Node.Unit)
then
if Is_Preelaborate (Node) then
Elab_Spec (Node);
end if;
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Preelaborate_Spec (Node.Prevs (Index));
end loop;
end if;
end Process_Preelaborate_Spec;
-- Process_Preelaborate_Body --
procedure Process_Preelaborate_Body
(Node : in Tree_Node_Access)
is
-- A_Preelaborate_Pragma -- 10.2.1(3)
begin
if Is_Preelaborate (Node) then
Elab_Body (Node);
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Preelaborate_Body (Node.Prevs (Index));
end loop;
end if;
end Process_Preelaborate_Body;
-- Process_Spec --
procedure Process_Spec
(Node : in Tree_Node_Access)
is
begin
if not Node.Elaborated
and then not Is_Nil (Node.Unit)
then
Elab_Spec (Node);
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Spec (Node.Prevs (Index));
end loop;
end if;
end Process_Spec;
-- Process_Body --
procedure Process_Body
(Node : in Tree_Node_Access)
is
begin
Elab_Body (Node);
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Process_Body (Node.Prevs (Index));
end loop;
end if;
end Process_Body;
-- Append_Inconsistent --
procedure Append_Inconsistent
(Node : in Tree_Node_Access)
is
begin
if Node.Inconsistent /= null then
Result.Next (Result.Next'First).Inconsistent :=
Append (Result.Next (Result.Next'First).Inconsistent,
Node.Inconsistent.all);
end if;
if Node.Prevs /= null then
for Index in Node.Prevs.all'Range loop
Append_Inconsistent (Node.Prevs (Index));
end loop;
end if;
end Append_Inconsistent;
begin
Root_Node := Find (This, Std);
Root_Node.Elaborated := True;
Append (Result, Std);
if Root_Node.Prevs = null then
return Result;
end if;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Pure_Spec (Root_Node.Prevs (Index));
end loop;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Pure_Body (Root_Node.Prevs (Index));
end loop;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Preelaborate_Spec (Root_Node.Prevs (Index));
end loop;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Preelaborate_Body (Root_Node.Prevs (Index));
end loop;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Spec (Root_Node.Prevs (Index));
end loop;
for Index in Root_Node.Prevs.all'Range loop
Deallocate (Elaboration_Line);
Process_Body (Root_Node.Prevs (Index));
end loop;
-- inconsistent
for Index in Root_Node.Prevs.all'Range loop
Append_Inconsistent (Root_Node.Prevs (Index));
end loop;
return Result;
exception
when others =>
Deallocate (Result);
raise;
end Create_Elaboration_Tree;
-------------
-- Is_Pure --
-------------
function Is_Pure
(This : in Tree_Node_Access)
return Boolean
is
begin
if This.Internal_Pure = Unknown then
Retrive_Pragmas (This);
end if;
if This.Internal_Pure = Extended_True then
return True;
else
return False;
end if;
end Is_Pure;
---------------------
-- Is_Preelaborate --
---------------------
function Is_Preelaborate
(This : in Tree_Node_Access)
return Boolean
is
begin
if This.Internal_Preelaborate = Unknown then
Retrive_Pragmas (This);
end if;
if This.Internal_Preelaborate = Extended_True then
return True;
else
return False;
end if;
end Is_Preelaborate;
-----------------------
-- Is_Elaborate_Body --
-----------------------
function Is_Elaborate_Body
(This : in Tree_Node_Access)
return Boolean
is
begin
if This.Internal_Spec_With_Body = Unknown then
Retrive_Pragmas (This);
end if;
if This.Internal_Spec_With_Body = Extended_True then
return True;
else
return False;
end if;
end Is_Elaborate_Body;
---------------------
-- Retrive_Pragmas --
---------------------
procedure Retrive_Pragmas
(This : in Tree_Node_Access)
is
begin
if Is_Nil (This.Unit) then
return;
end if;
declare
Pragma_List : constant Asis.Pragma_Element_List :=
Asis.Elements.Corresponding_Pragmas
(Asis.Elements.Unit_Declaration (This.Unit));
begin
for Index in Pragma_List'Range loop
if Pragma_Kind (Pragma_List (Index).all) = A_Pure_Pragma then
This.Internal_Pure := Extended_True;
end if;
if Pragma_Kind (Pragma_List (Index).all) =
A_Preelaborate_Pragma
then
This.Internal_Preelaborate := Extended_True;
end if;
if Pragma_Kind (Pragma_List (Index).all) =
An_Elaborate_Body_Pragma
then
This.Internal_Spec_With_Body := Extended_True;
end if;
end loop;
end;
if This.Internal_Pure = Unknown then
This.Internal_Pure := Extended_False;
end if;
if This.Internal_Preelaborate = Extended_True then
This.Internal_Preelaborate := Extended_False;
end if;
if This.Internal_Spec_With_Body = Unknown then
This.Internal_Spec_With_Body := Extended_False;
end if;
end Retrive_Pragmas;
------------------
-- Is_Skip_Spec --
------------------
function Is_Skip_Spec
(This : in Tree_Node_Access)
return Boolean
is
begin
return This.Skip_Spec;
end Is_Skip_Spec;
---------------
-- Skip_Spec --
---------------
procedure Skip_Spec
(This : in Tree_Node_Access;
Value : in Boolean)
is
begin
This.Skip_Spec := Value;
end Skip_Spec;
--------------
-- Get_Spec --
--------------
function Get_Spec
(This : in Tree_Node_Access)
return Compilation_Unit
is
begin
return This.Unit;
end Get_Spec;
--------------
-- Get_Body --
--------------
function Get_Body
(This : in Tree_Node_Access)
return Compilation_Unit
is
begin
return This.Unit_Body;
end Get_Body;
-----------
-- Nexts --
-----------
function Nexts
(This : in Tree_Node_Access)
return Tree_Node_Array_Access
is
begin
return This.Next;
end Nexts;
--------------
-- Finalize --
--------------
procedure Finalize
(This : in out Root_Tree)
is
Node : Tree_Node_Access;
begin
if This.Next /= null then
for Index in This.Next.all'Range loop
Node := This.Next.all (Index);
if Node /= null then
Deallocate (Node);
end if;
end loop;
Deallocate (This.Next);
end if;
Deallocate (This.Units);
end Finalize;
-- Finalize --
procedure Finalize
(This : in out Tree_Node)
is
Node : Tree_Node_Access;
begin
if This.Next /= null then
for Index in This.Next.all'Range loop
Node := This.Next.all (Index);
if Node /= null then
Deallocate (Node);
end if;
end loop;
Deallocate (This.Next);
end if;
if This.Prevs /= null then
for Index in This.Prevs.all'Range loop
Remove (This.Prevs (Index).Next, This.Self);
end loop;
Deallocate (This.Prevs);
end if;
Deallocate (This.Circular);
Deallocate (This.Missing);
Deallocate (This.Inconsistent);
Deallocate (This.Body_Dependences);
end Finalize;
----------
-- Find --
----------
function Find
(This : in Root_Tree_Access;
Unit : in Compilation_Unit)
return Tree_Node_Access
is
Index : aliased Positive;
begin
if This.Units = null then
return null;
end if;
if Find
(This.Units, Unit, 1, This.Units.all'Last, Index'Unchecked_Access)
then
return This.Units.all (Index).Node;
else
return null;
end if;
end Find;
------------
-- Append --
------------
function Append
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access
is
begin
return Add_Node (List, Node);
end Append;
--------------
-- Add_Node --
--------------
function Add_Node
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access
is
Array_Access : Tree_Node_Array_Access := List;
begin
if Array_Access = null then
Array_Access := new Tree_Node_Array (1 .. 1);
else
declare
Tmp_Array : Tree_Node_Array_Access :=
new Tree_Node_Array (1 .. Array_Access.all'Length + 1);
begin
Tmp_Array (1 .. Array_Access.all'Length) := Array_Access.all;
Deallocate (Array_Access);
Array_Access := Tmp_Array;
end;
end if;
Array_Access.all (Array_Access.all'Last) := Node;
return Array_Access;
end Add_Node;
------------
-- Remove --
------------
procedure Remove
(List : in out Tree_Node_Array_Access;
Node : in Tree_Node_Access)
is
begin
if List = null or else Node = null then
return;
end if;
for Index in List'Range loop
if List (Index) = Node then
List (Index) := null;
return;
end if;
end loop;
end Remove;
-- Remove --
function Remove
(List : in Tree_Node_Array_Access;
Node : in Tree_Node_Access)
return Tree_Node_Array_Access
is
Internal_List : Tree_Node_Array_Access := List;
begin
if Internal_List = null
or else Node = null
then
return Internal_List;
end if;
for Index in List'Range loop
if Internal_List (Index) = Node then
if List'Length = 1 then
Deallocate (Internal_List);
return null;
else
declare
New_Arry : constant Tree_Node_Array_Access :=
new Tree_Node_Array (1 .. List'Length - 1);
begin
New_Arry (1 .. Index - 1) := List (1 .. Index - 1);
New_Arry (Index .. New_Arry'Last) :=
List (Index + 1 .. List'Last);
Deallocate (Internal_List);
return New_Arry;
end;
end if;
end if;
end loop;
return List;
end Remove;
----------------------
-- Add_Node_Ordered --
----------------------
function Add_Node_Ordered
(List : in Unit_Node_Array_Access;
Node : in Tree_Node_Access)
return Unit_Node_Array_Access
is
procedure Process
(Unit : Compilation_Unit);
Array_Access : Unit_Node_Array_Access := List;
Index : aliased Positive;
procedure Process
(Unit : Compilation_Unit)
is
begin
if Array_Access = null then
Array_Access := new Unit_Node_Array (1 .. 1);
Array_Access.all (1) := (Unit, Node);
else
if Find
(Array_Access, Unit,
1, Array_Access.all'Last, Index'Unchecked_Access)
then
raise Use_Error;
end if;
declare
Tmp_Array : Unit_Node_Array_Access :=
new Unit_Node_Array (1 .. Array_Access.all'Length + 1);
begin
Tmp_Array (1 .. Index - 1) :=
Array_Access.all (1 .. Index - 1);
Tmp_Array (Index) := (Unit, Node);
Tmp_Array (Index + 1 .. Tmp_Array.all'Last) :=
Array_Access.all (Index .. Array_Access.all'Last);
Deallocate (Array_Access);
Array_Access := Tmp_Array;
end;
end if;
end Process;
begin
if not Is_Nil (Node.Unit) then
Process (Node.Unit);
end if;
if not Is_Nil (Node.Unit_Body) then
Process (Node.Unit_Body);
end if;
return Array_Access;
end Add_Node_Ordered;
----------
-- Find --
----------
function Find
(List : in Unit_Node_Array_Access;
Unit : in Compilation_Unit;
From : in Positive;
To : in Positive;
Index : in Positive_Access)
return Boolean
is
L, H, I : Natural;
C : Integer;
Result : Boolean := False;
begin
L := From;
H := To;
while L <= H loop
I := (L + H) / 2;
C := Compare (List.all (I).Unit, Unit);
if C < 0 then
L := I + 1;
else
H := I - 1;
if C = 0 then
Result := True;
L := I;
end if;
end if;
end loop;
Index.all := L;
return Result;
end Find;
-------------
-- Compare --
-------------
function Compare
(Left : in Compilation_Unit;
Right : in Compilation_Unit)
return Integer
is
use Asis;
use System;
begin
if Left.all'Address < Right.all'Address then
return -1;
elsif Left.all'Address > Right.all'Address then
return 1;
else
return 0;
end if;
end Compare;
-------------
-- In_List --
-------------
function In_List
(List : in Compilation_Unit_List_Access;
Last : in ASIS_Integer;
Unit : in Compilation_Unit)
return Boolean
is
begin
for Index in 1 .. Last loop
if Asis.Compilation_Units.Is_Identical (List (Index), Unit) then
return True;
end if;
end loop;
return False;
end In_List;
----------------------
-- Remove_From_List --
----------------------
procedure Remove_From_List
(List : in out Compilation_Unit_List_Access;
Unit : in Compilation_Unit)
is
begin
if List = null then
return;
end if;
for Index in List'Range loop
if Is_Identical (List (Index), Unit) then
if List'Length = 1 then
Deallocate (List);
else
declare
Internal : constant Compilation_Unit_List_Access :=
new Compilation_Unit_List (1 .. List'Length - 1);
begin
Internal (1 .. Index - 1) := List (1 .. Index - 1);
Internal (Index .. Internal'Last) :=
List (Index + 1 .. List'Last);
Deallocate (List);
List := Internal;
end;
end if;
exit;
end if;
end loop;
end Remove_From_List;
-- Remove_From_List --
procedure Remove_From_List
(List : in out Compilation_Unit_List;
From : in List_Index;
Unit : in Compilation_Unit)
is
begin
for Index in From .. List'Last loop
if Is_Identical (List (Index), Unit) then
List (Index) := Nil_Compilation_Unit;
return;
end if;
end loop;
end Remove_From_List;
------------
-- Append --
------------
function Append
(List : in Compilation_Unit_List_Access;
Unit : in Compilation_Unit)
return Compilation_Unit_List_Access
is
Result : Compilation_Unit_List_Access := List;
begin
if Result = null then
Result := new Compilation_Unit_List (1 .. 1);
else
declare
Tmp_Array : Compilation_Unit_List_Access :=
new Compilation_Unit_List (1 .. Result.all'Length + 1);
begin
Tmp_Array (1 .. Result.all'Length) := Result.all;
Deallocate (Result);
Result := Tmp_Array;
end;
end if;
Result.all (Result.all'Last) := Unit;
return Result;
end Append;
-- Append --
function Append
(List : in Compilation_Unit_List_Access;
Units : in Compilation_Unit_List)
return Compilation_Unit_List_Access
is
Result : Compilation_Unit_List_Access := List;
begin
if Result = null then
Result := new Compilation_Unit_List (1 .. Units'Length);
Result.all := Units;
else
declare
Tmp_Array : Compilation_Unit_List_Access :=
new Compilation_Unit_List
(1 .. Result.all'Length + Units'Length);
begin
Tmp_Array (1 .. Result.all'Length) := Result.all;
Tmp_Array (Result.all'Length + 1 .. Tmp_Array'Last) := Units;
Deallocate (Result);
Result := Tmp_Array;
end;
end if;
return Result;
end Append;
---------------------
-- Is_Inconsistent --
---------------------
function Is_Inconsistent
(Unit : in Compilation_Unit)
return Boolean
is
begin
return True;
end Is_Inconsistent;
-----------------------
-- Is_Source_Changed --
-----------------------
function Is_Source_Changed
(Unit : in Compilation_Unit)
return Boolean
is
begin
return False;
end Is_Source_Changed;
end Utils;
end Asis.Compilation_Units.Relations;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
oeis/323/A323223.asm | neoneye/loda-programs | 11 | 18382 | ; A323223: a(n) = [x^n] x/((1 - x)*(1 - 4*x)^(5/2)).
; 0,1,11,81,501,2811,14823,74883,366603,1752273,8218733,37964449,173172249,781607349,3496163949,15517771749,68412846069,299828796219,1307168814519,5672308893819,24511334499219,105519144602439,452695473616239,1936085243038839,8256615564926439,35118869432948739,149014825833363291,630882333681271011,2665434033483548051,11239616196936001291,47310313574218735611,198807242558806219755,834116944752237604875,3494476322687231530065,14619615539506297035405,61083432268574158851825,254903924909828668143177
lpb $0
mov $2,$0
sub $0,1
seq $2,51133 ; a(n) = binomial(2n,n)*n*(2n+1)/2.
add $1,$2
lpe
div $1,3
mov $0,$1
|
src/util-streams-texts.adb | Letractively/ada-util | 0 | 18823 | -----------------------------------------------------------------------
-- Util.Streams.Files -- File Stream utilities
-- Copyright (C) 2010, 2011, 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
package body Util.Streams.Texts is
procedure Initialize (Stream : in out Print_Stream;
To : in Output_Stream_Access) is
begin
Stream.Initialize (Output => To, Input => null, Size => 4096);
end Initialize;
-- ------------------------------
-- Write an integer on the stream.
-- ------------------------------
procedure Write (Stream : in out Print_Stream;
Item : in Integer) is
S : constant String := Integer'Image (Item);
begin
if Item > 0 then
Stream.Write (S (S'First + 1 .. S'Last));
else
Stream.Write (S);
end if;
end Write;
-- ------------------------------
-- Write an integer on the stream.
-- ------------------------------
procedure Write (Stream : in out Print_Stream;
Item : in Long_Long_Integer) is
S : constant String := Long_Long_Integer'Image (Item);
begin
if Item > 0 then
Stream.Write (S (S'First + 1 .. S'Last));
else
Stream.Write (S);
end if;
end Write;
-- ------------------------------
-- Write a string on the stream.
-- ------------------------------
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Strings.Unbounded.Unbounded_String) is
begin
Stream.Write (Ada.Strings.Unbounded.To_String (Item));
end Write;
-- ------------------------------
-- Write a date on the stream.
-- ------------------------------
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Calendar.Time;
Format : in GNAT.Calendar.Time_IO.Picture_String
:= GNAT.Calendar.Time_IO.ISO_Date) is
begin
Stream.Write (GNAT.Calendar.Time_IO.Image (Item, Format));
end Write;
-- ------------------------------
-- Get the output stream content as a string.
-- ------------------------------
function To_String (Stream : in Buffered.Buffered_Stream) return String is
use Ada.Streams;
Size : constant Natural := Stream.Get_Size;
Buffer : constant Streams.Buffered.Buffer_Access := Stream.Get_Buffer;
Result : String (1 .. Size);
begin
for I in Result'Range loop
Result (I) := Character'Val (Buffer (Stream_Element_Offset (I)));
end loop;
return Result;
end To_String;
-- ------------------------------
-- Initialize the reader to read the input from the input stream given in <b>From</b>.
-- ------------------------------
procedure Initialize (Stream : in out Reader_Stream;
From : in Input_Stream_Access) is
begin
Stream.Initialize (Output => null, Input => From, Size => 4096);
end Initialize;
-- ------------------------------
-- Read an input line from the input stream. The line is terminated by ASCII.LF.
-- When <b>Strip</b> is set, the line terminators (ASCII.CR, ASCII.LF) are removed.
-- ------------------------------
procedure Read_Line (Stream : in out Reader_Stream;
Into : out Ada.Strings.Unbounded.Unbounded_String;
Strip : in Boolean := False) is
C : Character;
begin
while not Stream.Is_Eof loop
Stream.Read (C);
if C = ASCII.LF then
if not Strip then
Ada.Strings.Unbounded.Append (Into, C);
end if;
return;
elsif C /= ASCII.CR or not Strip then
Ada.Strings.Unbounded.Append (Into, C);
end if;
end loop;
exception
when Ada.IO_Exceptions.Data_Error =>
return;
end Read_Line;
end Util.Streams.Texts;
|
ladspa/examples/amp-stereo.ads | Lucretia/aplug | 2 | 4164 | -- Amp.Stereo
--
--
------------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
with Interfaces.C;
with Interfaces.C.Strings;
with LADSPA;
private package Amp.Stereo is
package C renames Interfaces.C;
function Instantiate (Descriptor : access constant LADSPA.Descriptors;
Sample_Rate : C.unsigned_long) return LADSPA.Handles with
Convention => C;
procedure Clean_Up (Instance : in LADSPA.Handles) with
Convention => C;
procedure Connect_Port (Instance : in LADSPA.Handles;
Port : in C.unsigned_long;
Data_Location : in LADSPA.Data_Ptr) with
Convention => C;
-- procedure Activate (Instance : in out Handles) with
-- Convention => C;
-- procedure Deactivate (Instance : in out Handles) with
-- Convention => C;
procedure Run (Instance : in LADSPA.Handles; Sample_Count : in C.unsigned_long) with
Convention => C;
-- procedure Run_Adding (Instance : in out Handles; Sample_Count : in unsigned_long) with
-- Convention => C;
-- procedure Run_Adding_Gain (Instance : in out Handles; Gain : in Data) with
-- Convention => C;
-- private
use type LADSPA.All_Port_Descriptors;
use type LADSPA.Port_Range_Hint_Descriptors;
package Stereo_Ports is new LADSPA.Port_Information (Port_Type => Port_Numbers);
Stereo_Port_Descriptors : aliased constant Stereo_Ports.Descriptor_Array :=
(Gain => (LADSPA.Input or LADSPA.Control),
Input_1 => (LADSPA.Input or LADSPA.Audio),
Output_1 => (LADSPA.Output or LADSPA.Audio),
Input_2 => (LADSPA.Input or LADSPA.Audio),
Output_2 => (LADSPA.Output or LADSPA.Audio));
Stereo_Port_Names : constant Stereo_Ports.Name_Array :=
(Gain => C.Strings.New_String ("Gain"),
Input_1 => C.Strings.New_String ("Input (Left)"),
Output_1 => C.Strings.New_String ("Output (Left)"),
Input_2 => C.Strings.New_String ("Input (Right)"),
Output_2 => C.Strings.New_String ("Output (Right)"));
Stereo_Port_Range_Hints : constant Stereo_Ports.Range_Hint_Array :=
(Gain => (Hint_Descriptor => LADSPA.Bounded_Below or LADSPA.Logarithmic or LADSPA.Default_1,
Lower_Bound => 0.0,
Upper_Bound => <>),
Input_1 => (Hint_Descriptor => LADSPA.Default_None,
others => <>),
Output_1 => (Hint_Descriptor => LADSPA.Default_None,
others => <>),
Input_2 => (Hint_Descriptor => LADSPA.Default_None,
others => <>),
Output_2 => (Hint_Descriptor => LADSPA.Default_None,
others => <>));
use type Interfaces.C.unsigned_long;
-- This is required so that on finalisation of the library (unload), the globally allocated data is destroyed.
type Stereo_Descriptors is new LADSPA.Root_Descriptors with null record;
overriding procedure Finalize (Self : in out Stereo_Descriptors);
Stereo_Descriptor : constant Stereo_Descriptors := (Ada.Finalization.Limited_Controlled with
Data => (
Unique_ID => 1049,
Label => C.Strings.New_String ("amp_stereo"),
Properties => LADSPA.Hard_RT_Capable,
Name => C.Strings.New_String ("Stereo Amplifier"),
Maker => C.Strings.New_String ("<NAME> (LADSPA example plugins) & <NAME> (Ada port)"),
Copyright => C.Strings.New_String ("None"),
Port_Count => Port_Numbers'Pos (Port_Numbers'Last) + 1, -- Pos starts at 0!
Port_Descriptors => Stereo_Port_Descriptors'Address,
Port_Names => Stereo_Port_Names (Stereo_Port_Names'First)'Access,
Port_Range_Hints => Stereo_Port_Range_Hints'Address,
Instantiate => Instantiate'Access,
Connect_Port => Connect_Port'Access,
-- Activate => Activate'Access,
Run => Run'Access,
Clean_Up => Clean_Up'Access,
others => <>
));
end Amp.Stereo; |
oeis/006/A006093.asm | neoneye/loda-programs | 11 | 8566 | ; A006093: a(n) = prime(n) - 1.
; Submitted by <NAME>
; 1,2,4,6,10,12,16,18,22,28,30,36,40,42,46,52,58,60,66,70,72,78,82,88,96,100,102,106,108,112,126,130,136,138,148,150,156,162,166,172,178,180,190,192,196,198,210,222,226,228,232,238,240,250,256,262,268,270,276,280,282,292,306,310,312,316,330,336,346,348,352,358,366,372,378,382,388,396,400,408,418,420,430,432,438,442,448,456,460,462,466,478,486,490,498,502,508,520,522,540
mul $0,2
trn $0,1
seq $0,173919 ; Numbers that are prime or one less than a prime.
|
tools-src/gnu/gcc/gcc/ada/exp_tss.ads | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 20285 | <reponame>enfoTek/tomato.linksys.e2000.nvram-mod<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ T S S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Type Support Subprogram (TSS) handling
with Types; use Types;
package Exp_Tss is
-- A type support subprogram (TSS) is an internally generated function or
-- procedure that is associated with a particular type. Examples are the
-- implicit initialization procedure, and subprograms for the Input and
-- Output attributes.
-- A given TSS is either generated once at the point of the declaration of
-- the type, or it is generated as needed in clients, but only one copy is
-- required in any one generated object file. The choice between these two
-- possibilities is made on a TSS-by-TSS basis depending on the estimation
-- of how likely the TSS is to be used. Initialization procedures fall in
-- the first category, for example, since it is likely that any declared
-- type will be used in a context requiring initialization, but the stream
-- attributes use the second approach, since it is more likely that they
-- will not be used at all, or will only be used in one client in any case.
-- A TSS is identified by its Chars name, i.e. for a given TSS type, the
-- same name is used for all types, e.g. the initialization routine has
-- the name _init for all types.
-- The TSS's for a given type are stored in an element list associated with
-- the type, and referenced from the TSS_Elist field of the N_Freeze_Entity
-- node associated with the type (all types that need TSS's always need to
-- be explicitly frozen, so the N_Freeze_Entity node always exists).
function TSS (Typ : Entity_Id; Nam : Name_Id) return Entity_Id;
-- Finds the TSS with the given name associated with the given type. If
-- no such TSS exists, then Empty is returned.
procedure Set_TSS (Typ : Entity_Id; TSS : Entity_Id);
-- This procedure is used to install a newly created TSS. The second
-- argument is the entity for such a new TSS. This entity is placed in
-- the TSS list for the type given as the first argument, replacing an
-- old entry of the same name if one was present. The tree for the body
-- of this TSS, which is not analyzed yet, is placed in the actions field
-- of the freeze node for the type. All such bodies are inserted into the
-- main tree and analyzed at the point at which the freeze node itself is
-- is expanded.
procedure Copy_TSS (TSS : Entity_Id; Typ : Entity_Id);
-- Given an existing TSS for another type (which is already installed,
-- analyzed and expanded), install it as the corresponding TSS for Typ.
-- Note that this just copies a reference, not the tree. This can also
-- be used to initially install a TSS in the case where the subprogram
-- for the TSS has already been created and its declaration processed.
function Init_Proc (Typ : Entity_Id) return Entity_Id;
pragma Inline (Init_Proc);
-- Obtains the _init TSS entry for the given type. This function call is
-- equivalent to TSS (Typ, Name_uInit). The _init TSS is the procedure
-- used to initialize otherwise uninitialized instances of a type. If
-- there is no _init TSS, then the type requires no initialization. Note
-- that subtypes and implicit types never have an _init TSS since subtype
-- objects are always initialized using the initialization procedure for
-- the corresponding base type (see Base_Init_Proc function). A special
-- case arises for concurrent types. Such types do not themselves have an
-- _init TSR, but initialization is required. The initialization procedure
-- used is the one fot the corresponding record type (see Base_Init_Proc).
function Base_Init_Proc (Typ : Entity_Id) return Entity_Id;
-- Obtains the _Init TSS entry from the base type of the entity, and also
-- deals with going indirect through the Corresponding_Record_Type field
-- for concurrent objects (which are initialized with the initialization
-- routine for the corresponding record type). Returns Empty if there is
-- no _Init TSS entry for the base type.
procedure Set_Init_Proc (Typ : Entity_Id; Init : Entity_Id);
pragma Inline (Set_Init_Proc);
-- The second argument is the _init TSS to be established for the type
-- given as the first argument. Equivalent to Set_TSS (Typ, Init).
function Has_Non_Null_Base_Init_Proc (Typ : Entity_Id) return Boolean;
-- Returns true if the given type has a defined Base_Init_Proc and
-- this init proc is not a null init proc (null init procs occur as
-- a result of the processing for Initialize_Scalars. This function
-- is used to test for the presence of an Init_Proc in cases where
-- a null init proc is considered equivalent to no Init_Proc.
end Exp_Tss;
|
programs/oeis/273/A273420.asm | jmorken/loda | 1 | 161305 | <reponame>jmorken/loda<filename>programs/oeis/273/A273420.asm<gh_stars>1-10
; A273420: First differences of number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 705", based on the 5-celled von Neumann neighborhood.
; 3,17,20,31,41,47,57,63,73,79,89,95,105,111,121,127,137,143,153,159,169,175,185,191,201,207,217,223,233,239,249,255,265,271,281,287,297,303,313,319,329,335,345,351,361,367,377,383,393,399,409,415,425,431
mov $2,$0
mov $11,$0
lpb $2
mov $4,2
mov $8,$0
mov $10,3
lpb $4
mov $1,$0
mov $0,3
mov $4,1
sub $4,$1
mov $8,0
mov $10,6
lpe
mov $1,$4
add $5,$2
lpb $5
add $0,2
add $0,$4
sub $5,$1
lpe
add $1,1
mov $9,$1
clr $1,6
add $8,$10
add $9,$8
lpe
sub $5,$9
sub $0,$5
mov $1,$0
add $1,3
mov $13,$11
mul $13,4
add $1,$13
|
out/QIO/Signature.agda | k4rtik/agda-soas | 0 | 5181 | {-
This second-order signature was created from the following second-order syntax description:
syntax QIO
type
T : 0-ary
P : 0-ary
term
new : P.T -> T
measure : P T T -> T
applyX : P P.T -> T
applyI2 : P P.T -> T
applyDuv : P P (P,P).T -> T
applyDu : P P.T -> T
applyDv : P P.T -> T
theory
(A) a:P t u:T |> applyX (a, b.measure(b, t, u)) = measure(a, u, t)
(B) a:P b:P t u:P.T |> measure(a, applyDu(b, b.t[b]), applyDv(b, b.u[b])) = applyDuv(a, b, a b.measure(a, t[b], u[b]))
(D) t u:T |> new(a.measure(a, t, u)) = t
(E) b:P t:(P, P).T |> new(a.applyDuv(a, b, a b. t[a,b])) = applyDu(b, b.new(a.t[a,b]))
-}
module QIO.Signature where
open import SOAS.Context
-- Type declaration
data QIOT : Set where
T : QIOT
P : QIOT
open import SOAS.Syntax.Signature QIOT public
open import SOAS.Syntax.Build QIOT public
-- Operator symbols
data QIOₒ : Set where
newₒ measureₒ applyXₒ applyI2ₒ applyDuvₒ applyDuₒ applyDvₒ : QIOₒ
-- Term signature
QIO:Sig : Signature QIOₒ
QIO:Sig = sig λ
{ newₒ → (P ⊢₁ T) ⟼₁ T
; measureₒ → (⊢₀ P) , (⊢₀ T) , (⊢₀ T) ⟼₃ T
; applyXₒ → (⊢₀ P) , (P ⊢₁ T) ⟼₂ T
; applyI2ₒ → (⊢₀ P) , (P ⊢₁ T) ⟼₂ T
; applyDuvₒ → (⊢₀ P) , (⊢₀ P) , (P , P ⊢₂ T) ⟼₃ T
; applyDuₒ → (⊢₀ P) , (P ⊢₁ T) ⟼₂ T
; applyDvₒ → (⊢₀ P) , (P ⊢₁ T) ⟼₂ T
}
open Signature QIO:Sig public
|
src/deb/keyboard.asm | amindlost/wdosx | 7 | 86094 | <gh_stars>1-10
; ############################################################################
; ## WDOSX DOS Extender Copyright (c) 1996, 1999, <NAME> ##
; ## ##
; ## Released under the terms of the WDOSX license agreement. ##
; ############################################################################
;
; $Header: E:/RCS/WDOSX/0.95/SRC/deb/KEYBOARD.ASM 1.2 1999/02/07 20:05:33 MikeT Exp $
;
; ----------------------------------------------------------------------------
;
; $Log: KEYBOARD.ASM $
; Revision 1.2 1999/02/07 20:05:33 MikeT
; Updated copyright.
;
; Revision 1.1 1998/08/03 03:16:40 MikeT
; Initial check in
;
;
; ----------------------------------------------------------------------------
SetUserKeyb proc near
push ebx
mov ebx,Pic1Map
inc ebx
cmp bl,9
jz @@suk00
mov eax,204h
int 31h
mov [ebx*8+offset DebugInts],edx
mov [ebx*8+offset DebugInts+4],ecx
mov edx,[ebx*8+offset UserInts]
mov ecx,[ebx*8+offset UserInts+4]
mov eax,205h
int 31h
@@suk00:
mov bl,9
mov eax,204h
int 31h
mov [ebx*8+offset DebugInts],edx
mov [ebx*8+offset DebugInts+4],ecx
mov edx,[ebx*8+offset UserInts]
mov ecx,[ebx*8+offset UserInts+4]
mov eax,205h
int 31h
pop ebx
ret
SetUserKeyb endp
SetDebKeyb proc near
push ebx
mov ebx,Pic1Map
inc ebx
cmp ebx,9
jz @@sdk00
mov eax,204h
int 31h
mov [ebx*8+offset UserInts],edx
mov [ebx*8+offset UserInts+4],ecx
mov edx,[ebx*8+offset DebugInts]
mov ecx,[ebx*8+offset DebugInts+4]
mov eax,205h
int 31h
@@sdk00:
mov bl,9
mov eax,204h
int 31h
mov [ebx*8+offset UserInts],edx
mov [ebx*8+offset UserInts+4],ecx
mov edx,[ebx*8+offset DebugInts]
mov ecx,[ebx*8+offset DebugInts+4]
mov eax,205h
int 31h
pop ebx
ret
SetDebKeyb endp |
src/aco-od_types.ads | osannolik/ada-canopen | 6 | 242 | with Interfaces;
package ACO.OD_Types is
pragma Preelaborate;
subtype Object_Index is Interfaces.Unsigned_16;
subtype Object_Subindex is Interfaces.Unsigned_8;
type Entry_Index is record
Object : Object_Index;
Sub : Object_Subindex;
end record;
type Byte_Array is array (Natural range <>) of Interfaces.Unsigned_8;
Empty : Byte_Array (1 .. 0);
type Access_Mode is (RW, RO, WO);
type Entry_Base is abstract tagged record
Accessability : Access_Mode := RW;
end record;
function Is_Readable (This : Entry_Base) return Boolean is
(case This.Accessability is
when RW | RO => True,
when WO => False);
function Is_Writable (This : Entry_Base) return Boolean is
(case This.Accessability is
when RW | WO => True,
when RO => False);
function Data_Length (This : Entry_Base) return Natural is abstract;
function Read (This : Entry_Base) return Byte_Array is abstract;
procedure Write (This : in out Entry_Base;
Bytes : in Byte_Array) is abstract;
type Entry_Ref is not null access all Entry_Base'Class;
type Entry_Array is array (Object_Subindex range <>) of Entry_Ref;
type Object_Base (Entries : not null access Entry_Array) is tagged null record;
type Object_Ref is access all Object_Base'Class;
No_Object : constant Object_Ref := null;
subtype Index_Type is Integer range -1 .. Integer'Last;
No_Index : constant := Index_Type'First;
subtype Profile_Index_Type is Index_Type range 0 .. Index_Type'Last;
type Profile_Objects is array (Profile_Index_Type range <>) of Object_Ref;
type Profile_Objects_Ref is access all Profile_Objects;
end ACO.OD_Types;
|
amazon/serializableSnapshotIsolation.als | sanjosh/tlaplus | 6 | 2998 | <gh_stars>1-10
/*
An Alloy model of Cahill's algorithm for serializable snapshot isolation
Paper: http://cahill.net.au/wp-content/uploads/2009/01/real-serializable.pdf
PhD thesis: http://cahill.net.au/wp-content/uploads/2010/02/cahill-thesis.pdf
This is a modification of textbookSnapshotIsolation.als
Alloy would allow the common parts to be factored into a shared module,
but I've chosen to keep them as single stand-alone files for now,
to make them easier to read and experiment with.
This specification includes various correctness properties, including
serializability, which can be checked by the Alloy Analyzer for
all possible sequences of operations by a small number of transactions (e.g. 3 or 4)
over a small number of keys (e.g. 2 or 3)
Instructions:
1. Download Alloy Analyzer v4 from http://alloy.mit.edu/alloy4/
I tested with v4.1.10
2. Click 'Open' and load this model (text file).
3. Click (menu) Options...SAT Solver...MiniSat
4. Click 'Execute'.
It is currently set up to find an instance in which a transaction is aborted
by Cahill's algorithm, to ensure serializability.
This analysis takes about 15 seconds. Other checks might take hours or days.
5. Click 'Show'. Don't worry about the complex graph that appears.
6. Click the "Magic Layout" button and "Yes, clear the current settings"
The display will now represent a single state of the system,
with keys and transactions as nodes,
and relationships as labelled. arcs
7. Use the "<<" and ">>" arrow buttons at the bottom of the screen to move forwards
and backwards through logical time steps.
Be sure to always start at Time$0 -- sometimes the tool shows a different time first.
8. Click "Next" in the toolbar to look at the next counter-example, if there is one.
'Next' doesn't reset the time, so use << to start at Time$0.
9. Try examining different interesting conditions, or verifying some properties.
You'll need to edit this file, in the section marked "Analysis"
E.g. The file is currently set to execute the following command,
which finds an instance (example) which satisfies both of the listed conditions:
run {
at_least_n_txn_abort_to_preserve_serializability[1]
} for 2 but 12 Time, 3 TxnId, 3 Key
You might change it to this, to verify serializability:
check { cahill_serializable } for 2 but 15 Time, 4 TxnId, 3 Key
8. Learn the Alloy language & tool via the tutorials listed at http://alloy.mit.edu/alloy4/
The best place to start is probably this one: http://alloy.mit.edu/alloy4/tutorial4/
9. For more depth, read Jackson's book:
http://www.amazon.com/Software-Abstractions-Logic-Language-Analysis/dp/0262101149
*/
open util/ordering [Time] as TimeOrder
// This algorithm for snapshot isolation is not based on timestamp ordering
// (of start times of transactions), so we don't need TxnIds to be ordered for that reason.
// However, we do use TxnIds as "version ids" for keys, so we need TxnId to be ordered
// for that reason.
//
// When using TxnIds as version ids, we must constrain the begin() action to only
// start transactions in increasing order of TxnId (rather than in arbitrary order).
// This is necessary in order to ensure that the temporal ordering of (committed) matches
// the order of their version ids (writer TxnIds).
// That doesn't lose generality (transactions can still read, write, commit or abort
// in any order). The symmetry reduction also makes visualization slightly easier
// and might reduce the cpu-time to check the model.
open util/ordering [TxnId] as TxnIdOrder
sig Time {}
sig Key {}
sig TxnId {
// Sets of transactions that are now or have previously been in this state
// (i.e. these sets monotonically grow over time)
//
// note; We explicitly record 'begin' steps (in 'started'), so that we know the
// precise lifetime of a transaction; the algorithms for snapshot isolation
// depend on whether transaction lifetimes overlap, i.e. whether they are concurrent.
// If we simply infered the 'start' time as the time of the first read or write or
// waiting-for-lock etc. then we would fail to modle transactions that begin and
// then do nothing for a while. It's not obvious that it is safe to ignore that
// set of executions.
started: set Time,
committed: set Time,
aborted: set Time,
// These relations grow monotonically over time because they act as 'history
// variables', recording the sequence of transaction operations.
// Part of this history (for active concurrent transactions, plus the most recent
// commit to each key before the oldest active transaction) is required by
// the algorithm that implements Snapshot Isolation.
// The full history is required to test the correctness conditions (e.g. serializability).
//
read: Key -> TxnId -> Time, // ReaderTxnId -> Key -> VersionIdThatWasRead -> Time
written: Key -> Time, // WriterTxnId -> Key -> Time
// These relations model the lock manager, used by the implementation of snapshot isolation.
// These do NOT grow monotonically over time, as locks can be both acquired and released.
// (It is much easier to model
waitingForXLock: Key -> Time,
holdingXLock: Key -> Time,
// Extra state required for the SERIALIZABLE algorithm
// 'txn in inConflict.t' means there is a rw-conflict from some other concurrent
// transaction to txn.
// By the definition of rw-conflict this means that
// txn has written a version of a key that is later than the version read by some
// other concurrent transaction.
//
// a rw dependency is;
// - T1 reads a version of x, and T2 produces a later version of x (this is a rw-dependency, also
// known as an anti-dependency, and is the only case where T1 and T2 can run concurrently).
//
inConflict: set Time,
// 'txn in outConflict.t' means there is a rw-conflict from txn to some other
// concurrent transaction
// By the definition of rw-conflict this means that
// txn has read a version of a key that is earlier than the version written by some
// other concurrent transaction.
//
outConflict: set Time,
// Lifetime of inConflict and outConflict;
// If a txn aborts, we do remove it from inConflict, outConflict.
// But if a txn commits, we *don't* remove a txn from those fields.
// That's how we model the part of the algorithm that requires bookeeping to
// be maintained for committed transactions at least until all transactions concurrent
// with the committed transaction has aborted. (With the current model we don't
// bother to do that cleanup as it is purely an optimization and does not affect
// semantics.)
// txn in holdingSiREADlock.t[k] means that txn has read k.
// SiREAD locks don't block readers or writers.
// Unlike normal locks, SiREAD locks continue to be held AFTER txn commits.
// They can be released for a particular txn when all transactions concurrent with
// that txn have finalized. For this model we don't bother to do that, as it is purely
// an optimization, and does not affect semantics.
// If a txn aborts then SiREAD locks are released immediately for that txn.
//
holdingSIREADlock: Key -> Time,
// This field is only present to help find interesting instances to visualize.
// It is not required by the algorithm.
// It does grow monotonically with time.
// If txn is in abortedToPreserveSerializability.t then it is also in aborted.t.
abortedToPreserveSerializability: set Time
}
// Helper for enabling conditions of public operations
pred txn_started_and_can_do_public_operations[t: Time, txn: TxnId] {
let time_up_to_and_including_t = (TimeOrder/prevs[t] + t) {
// Must have been started at or before time t
txn in started.time_up_to_and_including_t
// ... and not committed or aborted before time t
txn not in (committed + aborted).time_up_to_and_including_t
}
// And not currently blocked waiting for a lock.
// (If a transaction is blocked waiting for a lock then an *internal* operation
// can become enabled that will allow the transaction to make progress --
// e.g. the lock might become free and the transaction might be the one that
// acquires the lock. But that operation is not a 'public' operation.)
no txn.waitingForXLock.t
}
// Public operations (actions)
pred begin[t, t': Time, txn: TxnId] {
/* http://cahill.net.au/wp-content/uploads/2009/01/real-serializable.pdf
existing SI code for begin(T)
set T.inConflict = T.outConflict = false
*/
si_begin[t, t', txn]
// By definition txn cannot be in inConflict, outConflict, holdingSiREADlock etc.
// (We have asserts that very that property of basic model correctness.)
// So we just have a frame condition for that state:
inConflict.t' = inConflict.t
outConflict.t' = outConflict.t
holdingSIREADlock.t' = holdingSIREADlock.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
pred si_begin[t, t': Time, txn: TxnId] {
// Enabling condition
// Purely for the purposes of the model, we artificially constrain
// transactions to start in order of increasing TxnId, with this:
//
// started.t = TxnIdOrder/prevs[txn]
//
// This allows us to use TxnId as VersionIds for keys.
//
// The goal of using TxnIds for VersionIds is:
// - make visualization simpler (so the user can anticipate which transaction will start next)
// - reduce model-checking time by avoiding the symmetry of permuted TxnIds.
// - avoid the need for a sig of explicit VersionIds (reduce model complexity and model checking time)
// - avoid the obvious use of Time atoms as version ids, because we want to 'project' the visualization on Time, and that would hide any use of Time atoms as version-ids etc..
//
// This optimization does not affect the thoroughness of model-checking,
// (i.e. does not lose generality), because nothing else depends on any ordering
// of TxnId.
//
// Correctness argument:
//
// The property we need is that,
// for each key, *committed* version ids are monotonically increasing with time.
//
// When using TxnIds as VersionIds, this becomes:
// for each key, the TxnIds of *committed* writers to that key
// are monotonically increasing with time.
//
// The checks for basic_model_correctness verify that is true for
// all executions; see safe_to_use_txnids_as_key_versionids.
//
// We implement this temporal constraint by these rules:
// a. Constraining transactions to start in increasing order of TxnId
// b. The standard SI FirstCommitterWins rule ensures that if any set of concurrent
// transactions write to the same key, at most one of them can commit.
//
// As SI *never* does uncommitted reads, the above 2 properties imply that for
// all *committed* writes to a given key, the TxnId of the writer is monotonically
// increasing with time.
//
// Proof; We assume the contrary (that for some key k, the TxnIds of *committed*
// writes to that key are not monotonically increasing in time), and show a
// contradiction. Non-monotonic ordering means that there exist distinct
// transactions Ti and Tj, with Ti < Tj, that both write to the same key and then
// Tj commits before Ti. Rule (a) implies that Tj started after Ti, and by definition
// Tj commits before Ti; therefore Ti and Tj are concurrent transactions that both
// modify the same key, and both commit. But rule (b) says that at most one of
// Ti and Tj can commit; a contradiction.
//
started.t = TxnIdOrder/prevs[txn]
// Postcondition
started.t' = started.t + txn
// Frame condition
read.t' = read.t
written.t' = written.t
committed.t' = committed.t
aborted.t' = aborted.t
waitingForXLock.t' = waitingForXLock.t
holdingXLock.t' = holdingXLock.t
}
pred read[t, t': Time, txn: TxnId, k: Key] {
/* http://cahill.net.au/wp-content/uploads/2009/01/real-serializable.pdf
get lock(key=x, owner=T, mode=SIREAD)
if there is a WRITE lock(wl) on x {
set wl.owner.inConflict = true
set T.outConflict = true
}
// existing SI code for read(T, x)
for each version (xNew) of x that is newer than what T read:
if xNew.creator is committed and xNew.creator.outConflict: {
abort(T)
}
else {
set xNew.creator.inConflict = true
set T.outConflict = true
}
*/
// The structure of the above algorithm completely relies on mutability of fields
// and early returns.
// We have to almost completely re-order the algorithm, to state it as a
// functional constraint on execution traces.
// We have to state the enabling conditions here, because
// one path through this does abort[t,t',txn] instead of si_read[t,t',txn,k]
// and we want the same enabling conditions (plus those below) for the abort.
si_read_enabling_conditions[t, t', txn, k]
let versionid_of_k_read_by_txn
= versionid_of_k_that_would_be_read_by_txn[t, txn, k],
// ... this might contain *uncommitted* versions (that's really the point)
versionids_of_k_newer_than_read_by_txn
= (written.t).k - (versionid_of_k_read_by_txn
+ TxnIdOrder/prevs[versionid_of_k_read_by_txn]) {
// for each version (xNew) of x that is newer than what T read:
// if xNew.creator is committed and xNew.creator.outConflict: {
// abort(T)
// }
// else {
// set xNew.creator.inConflict = true
// set T.outConflict = true
// }
(some xNew: versionids_of_k_newer_than_read_by_txn |
xNew in committed.t and xNew in outConflict.t)
=> {
// This read might not be serializable; we must abort.
// Specifically, this read by txn will set up a rw-conflict from txn to xnew.
// And xnew already has a rw-conflict from xnew to some transaction Tout.
// (note; Tout may or may not be txn).
// Therefore this read could cause a 'dangerous structure' in the
// conflict graph (two consecutive rw-conflict edges that might be
// part of a cycle), with xnew as the 'pivot transaction'.
// We would prefer to abort the pivot, but it has already committed.
// So to (conservatively) ensure safety, we must abort.
abort_to_preserve_serializability[t, t', txn]
}
else {
// The read is safe. But it might still build towards a 'dangerous structure'
// in the conflict graph, so we have to do the necessary book-keeping
// to track that, as well as doing the read.
// (note; unlike the statement of the algorithm in the paper, we only
// in this model we only acquire the SIREAD lock if the read is allowed
// -- i.e. if txn does not abort because of the read. Otherwise
// acquring the SiREAD lock line would conflict with the
// dropping of the same lock in abort[], and the model would be
// over-constrained -- the abort could never occur, and so would implicitly
// become part of the enabling condition. i.e. The model checker would
// never consider read attempts that might violate serializability, so the
// entire point of the model would be wasted.)
holdingSIREADlock.t' = holdingSIREADlock.t + txn->k
// do the normal snapshot isolation read
si_do_read[t, t', txn, k]
// The form of the algorithm in the paper treats inConflict and outConflict
// as mutable flags local to each transaction. Purely due to the natural
// modelling idiom in Alloy, in our model inConflict and outConflict are
// single global relations. So we have to compute the full final constraint
// on the next state of each of those relations in one go. This means changing
// the form of the algorithm, although we want the same semantics.
// Those semantics are;
//
// if there is a WRITE lock(wl) on x {
// set wl.owner.inConflict = true
// set T.outConflict = true
// }
// for each version (xNew) of x that is newer than what T read:
// if xNew.creator is committed and xNew.creator.outConflict: {
// // abort(T) --- handled earlier
// }
// else {
// set xNew.creator.inConflict = true
// set T.outConflict = true
// }
// ToDo; when considering whether there is a WRITE lock on x,
// should we include or ignore write-locks held by txn itself?
// Michael's paper does not mention doing that, so currently
// we DON'T include write locks held by txn itself.
inConflict.t' = inConflict.t
+ versionids_of_k_newer_than_read_by_txn
+ ((holdingXLock.t).k - txn) // xlock_owner, if there is one
( some versionids_of_k_newer_than_read_by_txn
or ( some xlock_owner: TxnId - txn |
k in xlock_owner.holdingXLock.t // 'there is a WRiTE lock on x'
)
)
=> {
outConflict.t' = outConflict.t + txn
}
else {
// frame condition
outConflict.t' = outConflict.t
}
// Frame condition
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
}
pred si_read_enabling_conditions[t, t': Time, txn: TxnId, k: Key] {
txn_started_and_can_do_public_operations[t, txn]
// Bernstein's standard simplification to the model:
// no txn reads the same key more than once.
no txn.read.t[k]
// We don't model 'missing' keys, so there must already be a version of k
// that it is legal for us to read
some versionid_of_k_that_would_be_read_by_txn[t, txn, k]
}
pred si_do_read[t, t': Time, txn: TxnId, k: Key] {
si_read_enabling_conditions[t, t', txn, k]
let versionid_to_read = versionid_of_k_that_would_be_read_by_txn[t, txn, k] {
read.t' = read.t + txn->k->versionid_to_read
started.t' = started.t
written.t' = written.t
committed.t' = committed.t
aborted.t' = aborted.t
waitingForXLock.t' = waitingForXLock.t
holdingXLock.t' = holdingXLock.t
}
}
// Helper. Assumes "one time_of_start(txn)"
fun versionid_of_k_that_would_be_read_by_txn[t: Time, txn: TxnId, k: Key]
: lone TxnId
{
txn in (written.t).k
=>
// txn reads the (uncommitted) version that it wrote itself before t
txn
else
// txn reads the latest version that was committed before txn began
TxnIdOrder/max
[ all_versionids_of_k_created_before_t_by_txns_committed_before_t
[time_of_start[txn], k]
& TxnIdOrder/prevs[txn]
]
}
fun all_versionids_of_k_created_before_t_by_txns_committed_before_t[t: Time, k: Key]
: set TxnId
{
let all_versionids_of_k_created_before_t = (written.t).k, // set of writer TxnId at t
all_txnids_committed_before_t = committed.t | // set of committed TxnId at t
all_versionids_of_k_created_before_t & all_txnids_committed_before_t
}
/* Modified write algorithm, from http://cahill.net.au/wp-content/uploads/2009/01/real-serializable.pdf
get lock(key=x, locker=T, mode=WRITE)
if there is a SIREAD lock(rl) on x with rl.owner is running or commit(rl.owner) > begin(T): {
if rl.owner is committed and rl.owner.inConflict: {
abort(T)
}
else {
set rl.owner.outConflict = true
set T.inConflict = true
}
}
existing SI code for write(T, x, xNew)
# do not get WRITE lock again
*/
// Note we put most of the above logic into write_can_acquire_xlock[]
// as that is the predicate that always handles the write once we know for sure that
// this transaction can acquire the write lock.
pred start_write_may_block[t, t': Time, txn: TxnId, k: Key] {
txn_started_and_can_do_public_operations[t, txn]
// Berstein's standard simplification to the model:
// no txn writes to the same key more than once.
k not in txn.written.t
// Part of First Commiter Wins rule: if txn attempts to write to a key that has
// been modified and committed since txn began, then txn cannot possibly
// commit, so we might as well abort txn now.
//
// Alternative: we could just fail the individual write, and allow the transaction
// to proceed. (We could model that by including the above FCW check in the
// enabling-condition, so that Alloy doesn't even attempt to generate behaviors
// that attempt to violate the FCW rule in that way.)
// I choose to not do that, as in the vast majority of cases the transaction
// won't have any realistic alternative than abort, so we simply model the abort.
some versions_of_k_committed_since_txn_began_and_before_t[t, txn, k] => {
// This write would be pointless, due to the FCW rule (see above).
abort[t, t', txn]
}
else {
// This write is not forbidden by the FCW rule.
// Do we need to wait for this key's xlock before we can write?
//
// (Note that we know that txn itself cannot already be holding the xlock,
// as our enabling-conditions prevent a transaction from writing
// to a key more than once. But we do the correct test anyway (i.e. don't
// wait for a lock if txn already holds it), incase we ever do choose to model
// transactions that can write to the same key more than once
some (holdingXLock.t).k - txn => {
// The key is locked by some other transaction.
// We will need to block to acquire the xlock before we can do the write.
// But blocking on xlocks could cause deadlock, so the following predicate detects
// and prevents that. The following predicate may abort txn or any other transaction
// that would be involved in a potential cycle in the waiting-for-locks graph.
// If this predicate does not abort txn, then when it returns,
// txn will be blocked on the xlock (txn->k will be in waitingForXLock.t'),
// and an internal action, finish_blocked_write[], will later become enabled if the
// lock becomes free. (Note that any number of txns might be waiting for
// the same xlock. The order of acquisition is intentionall non-deterministic,
// to force Alloy to check all possibilities.)
write_conflicts_with_xlock[t, t', txn, k]
}
else {
// Key is not locked -- so we can immediately acquire the xlock.
// and attempt to do the write.
// (In textbook snapshot isolation we could unconditionally do the write
// after acquiring the lock. But in serializable snapshot isolation we might
// need to aort txn to avoid violating serializability.)
write_can_acquire_xlock[ t, t', txn, k]
}
}
}
// Helper for start_write_may_block
fun versions_of_k_committed_since_txn_began_and_before_t[t: Time, txn: TxnId, k: Key]
: set TxnId {
// written is: WriterTxnId -> Key -> Time
(written.(TimeOrder/prevs[t] - TimeOrder/prevs[time_of_start[txn]])).k
& committed.t
}
// Helper for start_write_may_block
pred write_conflicts_with_xlock[t, t' : Time, txn: TxnId, k: Key] {
// Some other transaction is holding the xlock on this key
// (In the current model txn itself cannot be holding the xlock
// as the current model doesn't allow a transaction to write to the
// same key twice.)
// To write to this key, we must acquire the xlock.
// But if waiting for the xlock would cause a deadlock
// then we must instead abort one of the transactions
// involved in the cycle.
// Standard definition of a deadlock is a cycle in the 'waiting-for-locks' graph.
// The waiting-for-locks graph has nodes that are transactions and
// an edge from T1 to T2 if T2 is currently holding a lock that T1 is waiting for.
//
// Remember:
// waitingForXLock: Txn->Key->Time
// holdingXLock: Txn->Key->Time
//
// The current waiting-for-locks graph is therefore waitingForXLock.t
// dot-joined with the *transpose* of holdingXLock.t.
// i.e.:
// (TxnThatIsWaitingForXLock -> KeyBeingWaitedFor)
// . (KeyWhoseXLockIsHeld -> TxnThatIsHoldingKeysXlock)
//
// We want to know if a cycle would be caused in the waiting for locks graph
// if txn begin wait for k's xlock. So we add txn->k to waitingForXLock.t
// before we do the dot join.
let new_waiting_for_held_by = (waitingForXLock.t + txn->k).~(holdingXLock.t) {
// If txn starting to wait on an xlock would cause a cycle, then
// txn must be involved in that cycle, so we can check by seing
// if txn can reach itself.
txn in txn.^new_waiting_for_held_by => {
// If txn starts waiting for xlock for k, then it will cause a deadlock.
// Pick a single transaction to abort,
// that would break the potential cycle in the graph.
// We make this a non-deterministic choice from all transactions involved in the
// potential cycle, to ensure that we model-check all possible choices of victim.
// i.e. We don't enshrine a particular policy -- e.g. min write locks.
some to_abort: txns_involved_in_cycle[new_waiting_for_held_by] {
txn in to_abort => {
// We've selected txn itself as the victim to avoid deadlock.
abort[t, t', txn]
}
else {
// We've selected some transaction other than txn as the victim to avoid deadlock.
// Do the abort, and set txn to be waiting for the xlock.
//
// Note: the abort is not guaranteed to release the xlock
// that txn wants. (The abort just guarantees that when txn
// starts waiting for the xlock, that action won't create a cycle in the
// waiting-for-locks graph.)
// And we *don't* check to see if the abort has released the
// xlock that txn wants (to grant the xlock immediately to txn).
// There might be other transactions waiting for the xlock
// and we don't want to starve them. We want to model-check
// all possible combinations of acquisition.
aborted.t' = aborted.t + to_abort
holdingXLock.t' = holdingXLock.t - (to_abort <: holdingXLock.t) // drop all of to_abort's xlocks
// txn starts waiting for the lock,
// and to_abort is nolonger waiting for any locks
waitingForXLock.t' = (waitingForXLock.t + txn->k)
// ... the aborting transaction might be waiting for some other lock
- (to_abort <: waitingForXLock.t)
started.t' = started.t
read.t' = read.t
written.t' = written.t
committed.t' = committed.t
// Changes to bookeeping for SERIALIZABLE mode
inConflict.t' = inConflict.t - to_abort
outConflict.t' = outConflict.t - to_abort
holdingSIREADlock.t' = holdingSIREADlock.t - (to_abort <: holdingXLock.t)
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
}
else {
// Here we know that txn won't cause a deadlock
// when it starts waiting for k's xlock.
waitingForXLock.t' = waitingForXLock.t + txn->k
started.t' = started.t
read.t' = read.t
written.t' = written.t
committed.t' = committed.t
aborted.t' = aborted.t
holdingXLock.t' = holdingXLock.t
// SERIALIZABLE frame condition
inConflict.t' = inConflict.t
outConflict.t' = outConflict.t
holdingSIREADlock.t' = holdingSIREADlock.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
}
// Returns the set of all transactions that are involved in any cycle in the input graph.
fun txns_involved_in_cycle[waiting_for_held_by_with_cycle : TxnId->TxnId] : set TxnId {
let txns_in_waiting_for_held_by
= TxnId.waiting_for_held_by_with_cycle + waiting_for_held_by_with_cycle.TxnId |
{involved_in_cycle: txns_in_waiting_for_held_by |
no txn: TxnId |
txn in txn.^(waiting_for_held_by_with_cycle
- (involved_in_cycle->TxnId + TxnId->involved_in_cycle))
}
}
// Helper for writes.
// This will abort txn if the write would violate serializability.
// If it does not abort then it both records that txn has acquired the xlock on k
// and created a new version of k.
pred write_can_acquire_xlock[t, t': Time, txn: TxnId, k: Key] {
/* From http://cahill.net.au/wp-content/uploads/2009/01/real-serializable.pdf
get lock(key=x, locker=T, mode=WRITE)
if there is a SIREAD lock(rl) on x with
rl.owner is running
or commit(rl.owner) > begin(T):
{
if rl.owner is committed and rl.owner.inConflict: {
abort(T)
}
else {
set rl.owner.outConflict = true
set T.inConflict = true
}
}
existing SI code for write(T, x, xNew)
# do not get WRITE lock again
*/
// Note "get lock(key=x, locker=T, mode=WRITE)" is achieved by
// moving all of the code into this predicate (write_can_acquire_xlock),
// as this predicate is always called when we can unconditionally acquire the xlock.
let concurrent_sireadlock_owners = concurrent_sireadlock_owners[t, txn, k] |
some concurrent_sireadlock_owners => {
// There are one or more other transactions that have overlapping lifetimes
// with txn, and which have read an earlier version of k than will/would
// be written by this write by txn.
//
// i.e. If txn does this write, then it will create (or restate) one or more
// rw-dependencies in the conflict graph. Specifically it will result in
// outConflicts from concurrent_sireadlock_owners to txn.
// If one of the concurrent_sireadlock_ownersalready has an inConflict
// then this write could result in a 'dangerous structure' in the conflict
// graph (with that member of concurrent_sireadlock_owners as the pivot).
// If that potential pivot has already committed, then to ensure safety we
// must reject this write.
// As mentioned earlier, we choose to do model the rejection of the write
// by aborting txn, rather than modelling a write-failure and allowing
// txn to continue with other operations.
//
(some sireadlock_owner : concurrent_sireadlock_owners |
sireadlock_owner in committed.t
and sireadlock_owner in inConflict.t
) => {
// This write could potentially construct a 'dangerous structure' in the
// serializability graph.
// To guarantee that we preserve serializability we need to abort one of
// the transactions that would be involved in that structure.
// the other transaction that we know about (siread_lock_owner)
// is already committed, so we have to abort.
abort_to_preserve_serializability[t, t', txn]
}
else {
// There are some concurrent_sireadlock_owners
// but this particular write will not immediately cause
// a dangerous structure to form with those other transactions.
// So we can allow the write.
si_do_write[t, t', txn, k]
// Record the fact that all transactions in concurrent_sireadlock_owners
// now have an outbound rw-conflict (from themselves to txn).
outConflict.t' = outConflict.t + concurrent_sireadlock_owners
// Record the fact that txn now has at least one inbound rw-conflict
// (from concurrent_sireadlock_owners to txn)
inConflict.t' = inConflict.t + txn
// frame condition
holdingSIREADlock.t' = holdingSIREADlock.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
else {
// Either k's SIREAD lock is not held, or all transactions that are holding it
// are not concurrent with txn.
// There's no risk that this write would form a 'dangerous structure' in
// the serializability graph, so it is safe to do this write.
si_do_write[t, t', txn, k]
// This write does not cause any transaction to become (more) involved
// in potential 'dangerous structures' in future.
// So we just have a plain frame condition for the state that tracks that.
inConflict.t' = inConflict.t
outConflict.t' = outConflict.t
holdingSIREADlock.t' = holdingSIREADlock.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
fun concurrent_sireadlock_owners[t: Time, txn: TxnId, k: Key] : set TxnId {
/*
if there is a SIREAD lock(rl) on x with
rl.owner is running
or commit(rl.owner) > begin(T):
*/
// Really means the set of all SIREAD lock owners (for k)
// that are concurrent with txn -- even if they have committed already.
// NOTE: the paper doesn't mention whether the rl.owner can be txn.
// I assume that the intent is to NOT include txn as a potential conflict with itself.
{concurrent_SIREADlock_owner: (holdingSIREADlock.t).k - txn |
// "is running" (if it were not in started.t or if it were in aborted.t,
// then it would not be in holdingSIREADlock.t[k])
(concurrent_SIREADlock_owner not in committed.t)
// or committed after txn started
or TimeOrder/gt[time_of_commit[concurrent_SIREADlock_owner],
time_of_start[txn]]
}
}
pred si_do_write[t, t': Time, txn: TxnId, k: Key] {
// Lock it and write it
holdingXLock.t' = holdingXLock.t + txn->k
written.t' = written.t + txn->k
// In some circumstances, we are called when waitingForXLock.t
// shows that txn is waiting for k's xlock.
// On exit, txn is always holding k's xlock, so it is always correct to remove
// any such entry from waitingForXLock.
// As a transaction can only be waiting for one lock at a time (an invariant)
// we can simply remove all of txn's entries from waitingForXLock.t.
waitingForXLock.t' = waitingForXLock.t - (txn <: waitingForXLock.t)
// frame condition
started.t' = started.t
read.t' = read.t
committed.t' = committed.t
aborted.t' = aborted.t
}
// Internal operation (action)
pred finish_blocked_write[t, t': Time, txn: TxnId, k: Key] {
// Enabling condition: txn is waiting for xlock on k, and k's xlock is nolonger held.
(k in txn.waitingForXLock.t) and no (holdingXLock.t).k
// We can now acquire k's xlock and do the write.
//
// However, in serializable mode, the following predicate will abort txn if the write
// would violate serializability.
// If it succeeds in doing the write then it both records that txn has acquired
// the xlock, and done (finished) the write.
// It also records that txn is nolonger waiting for k's xlock.
write_can_acquire_xlock[t, t', txn, k]
}
pred commit[t, t': Time, txn: TxnId] {
txn_started_and_can_do_public_operations[t, txn]
/*
if T.inConflict and T.outConflict: {
abort(T)
}
existing SI code for commit(T)
# release WRITE locks held by T
# but do not release SIREAD locks
*/
(txn in inConflict.t) and (txn in outConflict.t) => {
// This transaction has both an incoming rw-conflict and an out-going rw-conflict
// so it is potentially part of a 'dangerous structure' in the conflict graph
// (it would be the 'pivot' transaction').
// To conservatively ensure safety, we must abort instead of committing.
// Note; this is the unoptimized algorith from the sigmod paper.
// A real implementation would presumably abort this transaction earlier;
// as soon as it both its inConflict and outConflict flags become set.
abort_to_preserve_serializability[t, t', txn]
}
else {
committed.t' = committed.t + txn
// Obviously we also need to drop all xlocks that are held by txn.
// That is done below, as we might need to drop locks held by loser_txns too.
// We must enforce the FirstCommiterWins rule of Snapshot Isolation;
// If there are one or more transactions that
// are currently waiting for an xlock that is held by txn (the winner),
// then we must abort those loser transactions.
let keys_xlocked_by_txn = txn.holdingXLock.t,
loser_txns = (waitingForXLock.t).keys_xlocked_by_txn {
// loser_txns might be empty, or contain any number of transactions.
// The following works in any of those cases:
// snapshot isolation doesn't have cascading aborts so we don't
// need to look transitively for the set of transactions to abort
aborted.t' = aborted.t + loser_txns
// But we do need to drop all locks held by the loser transactions
// and txn itself.
// (This might unblock other transactions. That unblocking is modelled by
// other actions becoming enabled if a transaction that is in waitingForXLock
// finds that the lock is nolonger held by anyone else.)
holdingXLock.t' = holdingXLock.t - ((loser_txns + txn) <: holdingXLock.t)
// And of course the aborted loser transactions are nolonger waiting for locks.
// And neither is the winner txn.
waitingForXLock.t' = waitingForXLock.t - (loser_txns <: waitingForXLock.t)
// Book-keeping for serializable mode.
// IMPORTANT; we do NOT remove txn from inConflict or outConflict,
// and we do NOT release any SIREAD locks that txn holds.
// But we do remove and release for any loser_txns.
inConflict.t' = inConflict.t - loser_txns
outConflict.t' = outConflict.t - loser_txns
holdingSIREADlock.t' = holdingSIREADlock.t - (loser_txns <: holdingSIREADlock.t)
// frame condition
started.t' = started.t
read.t' = read.t
written.t' = written.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
}
}
// Abort by choice, or to avoid deadlock, or to preserve the SI FirstCommitterWins rule.
pred abort[t, t': Time, txn: TxnId] {
internal_abort[t, t', txn]
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
// Abort only to avoid non-serializable histories.
// The only difference is that we track when this predicate is called,
// to help find interesting instances for visualization.
pred abort_to_preserve_serializability[t, t': Time, txn: TxnId] {
internal_abort[t, t', txn]
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t + txn
}
// This helper does not constrain abortedToPreserveSerializability.t'
pred internal_abort[t, t': Time, txn: TxnId] {
// Note; invoking si_abort[] drags in txn_started_and_can_do_public_operations[t, txn]
// as the enabling condition.
// That's what we want for a public operation, but we must make sure that
// any 'internal' attempts to abort (e.g. to avoid violations of serializability)
// satisfy that enabling condition too -- otherwise the model will become over
// constrained, and will won't even attempt to check that kind of serializability violation.
si_abort[t, t', txn]
// <NAME>'s paper doesn't list the modifications for abort
// but we assume we drop the SIREAD locks and lose the inConlict and outConflict flags.
inConflict.t' = inConflict.t - txn
outConflict.t' = outConflict.t - txn
holdingSIREADlock.t' = holdingSIREADlock.t - (txn <: holdingSIREADlock.t)
}
pred si_abort[t, t': Time, txn: TxnId] {
txn_started_and_can_do_public_operations[t, txn]
aborted.t' = aborted.t + txn
holdingXLock.t' = holdingXLock.t - (txn <: holdingXLock.t) // drop all of txn's xlocks
started.t' = started.t
read.t' = read.t
written.t' = written.t
committed.t' = committed.t
// as the enabling condition for abort[] includes txn_started_and_can_do_public_operations[t, txn]
// then we know that txn cannot be waiting for xlock.
// But in the more general case, aborting a txn should definitely cancel any waiting-for-xlock state,
// so we do that here.
waitingForXLock.t' = waitingForXLock.t - (txn <: waitingForXLock.t)
}
pred skip[t,t': Time] {
si_skip[t,t']
inConflict.t' = inConflict.t
outConflict.t' = outConflict.t
holdingSIREADlock.t' = holdingSIREADlock.t
abortedToPreserveSerializability.t' = abortedToPreserveSerializability.t
}
pred si_skip[t,t': Time] {
started.t' = started.t
read.t' = read.t
written.t' = written.t
committed.t' = committed.t
aborted.t' = aborted.t
waitingForXLock.t' = waitingForXLock.t
holdingXLock.t' = holdingXLock.t
}
// Facts for the execution-traces idiom
pred init[t: Time] {
si_init[t]
no inConflict.t
no outConflict.t
no holdingSIREADlock.t
no abortedToPreserveSerializability.t
}
pred si_init[t: Time] {
no started.t
no written.t
no committed.t
no read.t
no aborted.t
no waitingForXLock.t
no holdingXLock.t
}
fact traces {
init[TimeOrder/first[]]
all t: Time - TimeOrder/last[] | let t' = TimeOrder/next[t] {
// We allow (require) exactly one public operation (on a single transaction)
// per time-step.
// However, some algorithm-specific constraints *might* also cause
// a simultaneous operation by one or more other transactions.
// e.g. Attempting to commit a transaction might cause other transactions
// to abort.
// To follow standard literature for analyzing transaction concurrency control
// algorithms, we do desire that at most one read, write or commit
// occur at any point in time. We have assertions that verify that condition.
// If it ever matters that transactions are aborted in the same timestep
// as other operations, we can achieve that by introducing a 'pendingAbort' set,
// and only enable abort[] steps for transactions that are in that set.
// We allow (require) exactly one abstract operation per time-step
some actiontxn: TxnId {
// Public operations
begin[t,t', actiontxn]
or ( some actionkey: Key |
read[t,t', actiontxn, actionkey]
or start_write_may_block[t, t', actiontxn, actionkey]
or finish_blocked_write[t, t', actiontxn, actionkey]
)
or commit[t, t', actiontxn]
or abort[t, t', actiontxn]
or skip[t,t']
}
}
}
//
// Analysis.
//
// Note that the Alloy Analyzer only executes the first 'run' or 'check' command that it finds
// in the file. We choose the command by commenting-out the ones we don't want to execute.
//
// Find an interesting instance
run {
at_least_n_txn_abort_to_preserve_serializability[1]
} for 2 but 12 Time, 3 TxnId, 3 Key
// Full analysis
// This scope takes 559s With berkmin
//check { complete_analysis } for 2 but 15 Time, 4 TxnId, 3 Key
// berkmin takes 1062s on Dell 630 with 'for 2 but 13 Time, 3 TxnId, 2 Key '
// berkimin crashes with 'for 2 but 14 Time, 3 TxnId, 3 Key'
// minisat takes 139s on Dell 630 with '2 but 10 Time, 3 TxnId, 2 Key'
//check { basic_model_correctness } for 2 but 12 Time, 3 TxnId, 3 Key
//check { safe_to_use_txnids_as_key_versionids }
//check { monotonically_growing_txn_state_sets }
//check { begin_is_always_first_action_of_txn }
//check { txn_at_most_one_commit_or_abort }
//check { commit_or_abort_can_only_be_final_action_of_txn }
//check { correctness_of_waitingForXLock }
//check { correct_concurrent_steps }
//check { correctness_of_holdingXLock }
//check { correctness_of_abortedToPreserveSerializability[] }
//for 2 but 14 Time, 4 TxnId, 3 Key
//check { semantics_of_snapshot_isolation } for 2 but 15 Time, 4 TxnId, 3 Key
// If we intentionall break all_versionids_of_k_created_before_t_by_txns_committed_before_t
// to allow uncommitted reads, this does detect them
//check { txn_only_reads_from_latest_prior_committed_snapshot_or_itself } for 2 but 14 Time, 3 TxnId, 3 Key
// This once found a bug in which
// t1 and t2 are concurrent and
// t1 writes to k and commits, and then t2 writes to k and also commits
// (was missing code to abort immediately if we attempt a write to a key that has
// been modified and committed since we started)
// berkmin; 354s
//check { first_committer_wins } for 2 but 13 Time, 3 TxnId, 3 Key
// This once found counter examples, when write[] did not detect & prevent deadlocks.
// minisat: 406s
// berkmin: crash
//check { no_deadlock } for 2 but 13 Time, 4 TxnId, 3 Key
// If we remove the deadlock-prevention code in write_conflicts_with_xlock[]
// then this generates a deadlock graph-cycle containing 4 txns
/*
run {
some t: Time |
let waiting_for_held_by = (waitingForXLock.t).~(holdingXLock.t) |
#{txn: TxnId | txn in txn.^waiting_for_held_by} > 3
} for 5 but 15 Time, 4 TxnId, 4 Key
*/
//check { bernstein_serializable } for 2 but 13 Time, 3 TxnId, 2 Key
// Berkmin: 1745s
//check { cahill_serializable } for 2 but 14 Time, 4 TxnId, 3 Key
// Confirm that our two slightly different phrasings of the serializability condition
// are equivalent for all possible executions (in scope).
//check { cahill_serializable <=> bernstein_serializable } for 2 but 15 Time, 4 TxnId, 3 Key
// Confirm that our two slightly different phrasings of the serializability condition
// are indeed not logically equivalent (not merely different styles of the same formula.)
// This finds a counter-example
// T0 begins, writes k and commits, then
// T1 begins, writes k and commits
// cahill_mvsg has T0->T1 because of
// ( // - T1 produces a version of x, and T2 produces a later version of x (this is a ww-dependency);
// bernstein_mvsg is empty because
// not in bernstein_sg **as there is no read involved** and
// "SG(H) has nodes for the committed transaction
// in H and edges Ti -> Tj (i /= j) whenever for some key x, Tj reads x from Ti.
// That is, Ti -> Tj is present iff for some x, rj[xi] (i /= j) is an operation of C(H).
// not in version_order_edges **as there is no read involved**
// and version_order_edges requires an rk
// "for each rk[xj] and wi[xi] in C(H) where i, j, and k are distinct,
// if xi << xj then include Ti -> Tj,
// otherwise include Tk -> Ti.
//check { all t: Time | cahill_mvsg[t] = bernstein_mvsg[t] } for 2 but 7 Time, 2 TxnId, 1 Key
// visually check that 'not concurrent[]' forbids all concurrent transactions
//run { no disj t1, t2: TxnId | concurrent[t1,t2] } for 2 but 7 Time, 2 TxnId, 1 Key
/*
// Find a "read-only serializability anomaly" reported in Michael Cahill's thesis
// (found by Fekete et al in an earlier paper)
//
// Berkmin takes 3153s to find the read-only serializability anomaly
// for "for 5 but 14 Time, 4 TxnId, 3 Key"
//
// minisat 1436s on Dell 630
run {
some txn: TxnId |
txn in abortedToPreserveSerializability.TimeOrder/last[]
and #txn.read.(TimeOrder/last[]) = 2
and no txn.written.TimeOrder/last[]
} for 5 but 16 Time, 4 TxnId, 3 Key
*/
//
// Analysis assertions and predicates
//
pred complete_analysis[] {
basic_model_correctness[]
semantics_of_snapshot_isolation[]
}
pred basic_model_correctness[] {
safe_to_use_txnids_as_key_versionids[]
monotonically_growing_txn_state_sets[]
begin_is_always_first_action_of_txn[]
txn_at_most_one_commit_or_abort[]
at_most_one_start_read_write_or_commit_per_timestep[]
commit_or_abort_can_only_be_final_action_of_txn[]
correctness_of_waitingForXLock[]
correctness_of_holdingXLock[]
correctness_of_abortedToPreserveSerializability[]
}
// Verify semantic properties of snapshot isolation
//
// 1. A txn may only ready from exactly the set of transactions that had been committed
// at the time at which txn starts, or from writes done by txn itself
//
// 2. First Committer Wins: if concurrent transactions write to intersecting sets of keys,
// then at most one of them can commit.
//
// 3. Deadlocks cannot be created.
pred semantics_of_snapshot_isolation {
txn_only_reads_from_latest_prior_committed_snapshot_or_itself[]
first_committer_wins[]
no_deadlock[]
}
//
// Semantics of Snapshot Isolation
//
pred txn_only_reads_from_latest_prior_committed_snapshot_or_itself[] {
// read is: ReaderTxnId -> Key -> VersionIdThatWasRead -> Time
// check all transactions that did at least one read
all txn_doing_read: ((read.Time).TxnId).Key {
// for every transaction that txn_doing_read actually read from, *excluding* itself
all txn_read_from: (txn_doing_read.read.Time[Key] - txn_doing_read) {
// the read-from transaction must have committed
// *before* the transaction doing the read even started.
let time_of_read_from_commit = time_of_commit[txn_read_from] {
some time_of_read_from_commit
TimeOrder/lt[time_of_read_from_commit, time_of_start[txn_doing_read]]
}
}
}
}
pred first_committer_wins[] {
no disj t1, t2: TxnId |
t1 in committed.Time
and t2 in committed.Time
and concurrent[t1,t2]
and some (t1.written.Time & t2.written.Time) // intersecting sets of keys-written
}
// true iff both t1 and t2 start and their lifetimes overlap
pred concurrent[t1, t2: TxnId] {
let t1_start = time_of_start[t1],
t1_finalize = time_of_finalize[t1],
t2_start = time_of_start[t2],
t2_finalize = time_of_finalize[t2] {
some t1_start
&& some t2_start
&& TimeOrder/lt[t1_start, t2_start] // t1 started before t2 started
=> ( no t1_finalize // and ( t1 never finished
or TimeOrder/gt[t1_finalize, t2_start]) // or t1 finished after t2 started)
else // t2 started before t1 started
( no t2_finalize // and ( t1 never finished
or TimeOrder/gt[t2_finalize, t1_start]) // or t2 finished after t2 started)
}
}
pred no_deadlock[] {
// waitingForXLock: Txn->Key->Time
// holdingXLock: Txn->Key->Time
no t: Time |
let waiting_for_held_by = (waitingForXLock.t).~(holdingXLock.t) |
some txn: TxnId | txn in txn.^waiting_for_held_by
}
//
// Verifying Serializability
// [only here to find NON-serializable instances, until we implement Michael Cahill's algorithm for serializable-SI]
//
// We prove serializability by confirming that the MultiVersionSerializabilityGraph
// is acyclic, for all histories constructed by the algorithm.
// I have two definitions of the MVSG at hand
// - from Michael Cahill's PhD thesis on serializable snapshot isolation
// - From <NAME>'s book (the section on proving that MVTO is serializable)
// To check that I've implemented them correctly, I define both of them,
// and then asssert that they are equivalent (imply other) at all times in all executions.
// From Michael Cahill's PhD thesis:
//
// Verifying that a history is conflict serializable is equivalent to showing that a particular graph is free of
// cycles. The graph that must be cycle-free contains a node for each transaction in the history, and an edge
// between each pair of conflicting transactions. Transactions T1 and T2 are said to conflict (or equivalently,
// to have a dependency) whenever they perform operations whose results reveal something about the order
// of the transactions; in particular when T1 performs an operation, and later T2 performs a conflicting
// operation. Operations O1 and O2 are said to conflict if swapping the order of their execution would
// produce different results (either a query producing a different answer, or updates producing different
// database state). A cycle in this graph implies that there is a set of transactions that cannot be executed
// serially in some order that gives the same results as in the original history.
// ...
// With snapshot isolation, the definitions of the serialization graph become much simpler, as versions of
// an item x are ordered according to the temporal sequence of the transactions that created those versions
// (note that First-Committer-Wins ensures that among two transactions that produce versions of x, one
// will commit before the other starts).
//
// In the MVSG, we put an edge from one committed transaction T1
// to another committed transaction T2 in the following situations:
//
// - T1 produces a version of x, and T2 produces a later version of x (this is a ww-dependency);
// - T1 produces a version of x, and T2 reads this (or a later) version of x (this is a wr-dependency);
// - T1 reads a version of x, and T2 produces a later version of x (this is a rw-dependency, also
// known as an anti-dependency, and is the only case where T1 and T2 can run concurrently).
pred cahill_serializable {
all t: Time|
no txn: TxnId | txn in txn.^(cahill_mvsg[t])
}
fun cahill_mvsg[t: Time] : TxnId->TxnId {
{T1: committed.t, T2: committed.t |
// from one committed transaction T1 to another [distinct] committed transaction T2
T1 != T2
and some x: Key {
( // - T1 produces a version of x, and T2 produces a later version of x (this is a ww-dependency);
x in T1.written.t
and x in T2.written.t
and TxnIdOrder/gt[T2, T1]
)
or ( // - T1 produces a version of x, and T2 reads this (or a later) version of x (this is a wr-dependency);
x in T1.written.t
and some read_versionid: TxnId {
// read is ReaderTxnId -> Key -> VersionIdThatWasRead -> Time
read_versionid in T2.read.t[x]
and TxnIdOrder/gte[read_versionid, T1]
}
)
or ( // - T1 reads a version of x, and T2 produces a later version of x (this is a rw-dependency, also
// known as an anti-dependency, and is the only case where T1 and T2 can run concurrently).
some read_versionid: TxnId {
// read is ReaderTxnId -> Key -> VersionIdThatWasRead -> Time
read_versionid in T1.read.t[x]
and x in T2.written.t
and TxnIdOrder/gt[T2, read_versionid]
}
)
}
}
}
// From <NAME>'s book
//
// This is the correctness condition from p152 (chapter 5 section 5.2) of Bernstein's book:
//
// Theorem 5.4: An MV history H is 1SR iff there exists a version order, <<,
// such that MVSG(H, <<) is acyclic.
//
//
// 'version order' is defined as:
//
// // From p151
// Given an MV history H and a data item [key] x, a version order, <, for x in H is
// a total order of versions of x in H.
// A version order, <<, for H is the union of the version orders for all data items.
// For example, a possible version order for H, is x0 << x2, y0 << y1 << y3.
//
//
// The version order is defined (for MVTO) as:
//
// From p152
// Given an MV history H and a version order, <<, the multiversion serialization
// graph for H and <<, MVSG(H, <<), is SG(H) with the following version
// order edges added: for each rk[xj] and wi[xi] in C(H) where i, j, and k are
// distinct, if xi << xj then include Ti -> Tj, otherwise include Tk -> Ti.
// Recall that the nodes of SG(H) and, therefore, of MVSG(H, <<) are the
// committed transactions in H.
// (Note that there is no version order edge if j = k, that is, if a transaction reads
// from itself.)
//
//
// SG(H) is defined as follows:
//
// From p149:
// The serialization graph for an MV history is defined as for a 1V history.
//
// From p32 (section 2.3, serializability theory for monoversion histories)
// The serialization graph (SG) for H, denoted SG(H), is a directed
// graph whose nodes are the transactions in T that are committed in H and
// whose edges are all Ti -> Tj (i =/ j) such that one of Ti's operations precedes
// and conflicts with one of Tj's operations in H.
//
// Continuing p149
// But since only one kind of conflict is possible in an MV history, SGs are quite
// simple. Let H be an MV history. SG(H) has nodes for the committed transaction
// in H and edges Ti -> Tj (i /= j) whenever for some key x, Tj reads x from Ti.
// That is, Ti -> Tj is present iff for some x, rj[xi] (i /= j) is an operation of C(H).
//
// From p30
// Given a history H, the committed projection of H, denoted C(H), is the history
// obtained from H by deleting all operations that do not belong to transactions
// committed in H. Note that C(H) is a complete history over the set of committed
// transactions in H. If H represents an execution at some point in time, C(H) is the
// only part of the execution we can count on, since active transactions can be
// aborted at any time, for instance, in the event of a system failure.
pred bernstein_serializable {
// MVSG[H, <<] is acyclic
// i.e. No node (TxnId) can be reached by starting at that node and following
// a directed path in the graph.
// i.e. No node can be reached from itself in the transitive closure of MVSG[H, <<]
all t: Time|
no txn: TxnId | txn in txn.^(bernstein_mvsg[t])
// TODO: is this faster to check?
// no (iden & ^(mvsg[t]))
//
// (Actually, avoiding the set-comprehensions in version_order_edges[]
// might have more impact on speed.
}
fun bernstein_mvsg[t: Time] : TxnId->TxnId {
bernstein_sg[t] + bernstein_version_order_edges[t]
}
// SG(H)
// "Ti -> Tj is present iff for some x, rj[xi] (i /= j) is an operation of C(H).
//
// We confine the result to C(H) by only considering Ti, Tj, Tk that are in committed.t
fun bernstein_sg[t: Time] : TxnId->TxnId {
{writer_txn: committed.t, reader_txn: committed.t |
reader_txn != writer_txn // distinct
and writer_txn in reader_txn.read.t[Key] // reader read from writer
}
}
// "for each rk[xj] and wi[xi] in C(H) where i, j, and k are distinct,
// if xi << xj then include Ti -> Tj,
// otherwise include Tk -> Ti.
//
// We confine the result to C(H) by only considering Ti, Tj, Tk that are in committed.t
fun bernstein_version_order_edges[t: Time] : TxnId->TxnId {
{Ti: committed.t, Tj: committed.t |
Ti != Tj // Ti and Tj are distinct committed transactions
and some Tk : committed.t |
Tk != Ti // Tk is a committed transaction distinct from Ti and Tj
and Tk != Tj
and some x: Key |
Tj in Tk.read.t[x] // rk[xj] is in C(H) (Tj is in set of transactions that Tk read from)
and x in Ti.written.t // xi exists in C(H)
and x in Tj.written.t // xj exists in C(H)
and TxnIdOrder/lt[Ti, Tj]} // xi << xj (as version order is TxnId order)
+
{Tk: committed.t, Ti: committed.t |
Tk != Ti // Tk and Ti are distinct
and some Tj : committed.t |
Tj != Tk // Tj is distinct from Ti and Tj
and Tj != Ti
and some x: Key |
Tj in Tk.read.t[x] // rk[xj] is in C(H) (Tj is in set of transactions that Tk read from)
and x in Ti.written.t // xi exists in C(H)
and x in Tj.written.t // xj exists in C(H)
and not TxnIdOrder/lt[Ti, Tj]} // NOT xi << xj (as version order is TxnId order)
}
//
// Basic model correctness
//
pred safe_to_use_txnids_as_key_versionids[] {
// For each key, the versionid order of committed writes matches the temporal order of
// committed writes.
// i.e. No version is ever commmitted that has a lower version-id than an existing
// committed version.
// The mechanism that enforces this is
// 1. the First committer Wins Rule; if more than one concurrent transaction
// writes to a key, at most one can commit.
// 2. The artificial constraint that for this model, transactions always
// begin in order of TxnId.
// Therefore all successful writes (i.e. committed writes) to a key must be done
// by transactions with increasing TxnIds.
// i.e. Transactions commit in TxnId order.
// ... for all pairs of different transactions that have both written and committed
// ... written is WriterTxnId -> Key -> Time
all k: Key |
all disj txn1, txn2 : (written.Time).k & committed.Time |
let t1c = time_of_commit[txn1],
t2c = time_of_commit[txn2] |
TxnIdOrder/lt[txn1,txn2] iff TimeOrder/lt[t1c, t2c]
and TxnIdOrder/gt[txn1,txn2] iff TimeOrder/gt[t1c, t2c]
}
// This verifies that frame conditions are complete (i.e. don't accidentally allow spurious changes)
pred monotonically_growing_txn_state_sets[] {
monotonically_growing_txn_state_set[started]
monotonically_growing_txn_state_set[committed]
monotonically_growing_txn_state_set[aborted]
all t: Time - TimeOrder/last[] {
read.t in read.(TimeOrder/next[t])
written.t in written.(TimeOrder/next[t])
}
}
pred monotonically_growing_txn_state_set[s: TxnId->Time] {
all t: Time - TimeOrder/last[] |
s.t in s.(TimeOrder/next[t])
}
// If a transaction starts at all, then start is the first operation in that txn
pred begin_is_always_first_action_of_txn[] {
all txn: TxnId |
some txn.started =>
time_of_start[txn] = TimeOrder/min[times_of_all_events[txn]]
}
// A transaction can do at most one commit or abort.
// (can't commit or abort multlple times, and can't both commit and abort)
pred txn_at_most_one_commit_or_abort[] {
all txn: TxnId | lone time_of_finalize[txn]
}
// If a transaction commits or aborts then that commit or abort is the last operation
// of that transaction
pred commit_or_abort_can_only_be_final_action_of_txn[] {
all txn: TxnId |
let time_of_finalize = time_of_finalize[txn] |
some time_of_finalize =>
time_of_finalize = TimeOrder/max[times_of_all_events[txn]]
}
pred correctness_of_abortedToPreserveSerializability[] {
monotonically_growing_txn_state_set[abortedToPreserveSerializability]
all txn: TxnId |
some time_of_abort_to_preserve_serializability[txn] =>
time_of_abort_to_preserve_serializability[txn] = time_of_abort[txn]
}
pred correctness_of_waitingForXLock[] {
// A transaction can only be waiting for one xlock at any point in time
all txn: TxnId | all t: Time | lone txn.waitingForXLock.t
// A transaction cannot begin to wait for a particular xlock (i.e. particular key)
// more than once
all txn: TxnId | all k: Key | lone k.(start_wait_for_xlock_events[txn])
// A transaction might wait for different xlocks at different times
// We can't assert this as it is not true for all executions.
// I'd like to assert that it is true for some executions (i.e. not prohibited
// by the model). But the best way to check that is probably to
// 'run' it to find and visually inspect an instance.
// some txn: TxnId | #(wait_for_xlock_events[txn]) > 1
// Every time a transaction leaves the waitingForXLock state,
// it does so either by acquiring that particular lock or aborting
all txn: TxnId |
let swle = stop_wait_for_xlock_events[txn] |
all k: swle.Time | let post_t = k.swle |
k->post_t in acquire_xlock_events[txn]
or post_t = time_of_abort[txn]
// Multiple transactions can be waiting for the same lock (and different locks)
// We can't assert this as it is not true for all executions.
// I'd like to assert that it is true for some executions (i.e. not prohibited
// by the model). But the best way to check that is probably to
// 'run' it to find and visually inspect an instance.
// some t:Time | some k: Key | waitingForXLock.t[k] > 1
}
pred at_most_one_start_read_write_or_commit_per_timestep[] {
// (It's not true that exactly one action happens in every step, because
// some actions can force other transactions to abort in the same step.)
// read: ReaderTxnId -> Key -> VersionIdThatWasRead -> Time
// written: WriterTxnId -> Key -> Time
all t: Time - TimeOrder/first[] {
let p = TimeOrder/prev[t],
s = started.t - started.p,
r = read.t - read.p,
w = written.t - written.p,
c = committed.t - committed.p {
lone s
lone r
lone w
lone c
some s => (no r and no w and no c)
some r => (no s and no w and no c)
some w => (no s and no r and no c)
some c => (no s and no r and no w)
}
}
}
pred correctness_of_holdingXLock[] {
// - no two transactions can hold the same xlock at the same time
// holding_for_xlock is HolderTxnId->Key->Time
all t: Time | all k: Key | lone (holdingXLock.t).k
// If a transaction is finalized then all of the txn's locks are continuously held
// from time of acquisition until time of finalize (are released in the same transition as finalize).
// If a transaction is not finalized, then its locks are never released.
all txn: TxnId |
some time_of_finalize[txn] => {
all k: (acquire_xlock_events[txn]).Time |
k.(release_xlock_events[txn]) = time_of_finalize[txn]
}
else {
no release_xlock_events[txn]
}
// All writes are done while holding the appropriate xlock
// (This doesn't check that at most one write is done per time-step;
// that is checked elsewhere.)
all t: Time - TimeOrder/last[] | let p = TimeOrder/prev[t] |
all k: Key |
all txn: TxnId |
txn in (written.t).k and txn not in (written.p).k
=> txn in (holdingXLock.t).k
// A transaction can hold multiple locks at the same time
// We can't assert this as it is not true for all executions.
// I'd like to assert that it is true for some executions (i.e. not prohibited
// by the model). But the best way to check that is probably to
// 'run' it to find and visually inspect an instance.
// some txn: TxnId | txn.holding_for_xlock.t[Key] > 1
}
//
// Helpers
//
// These return an empty set if the transaction never did any event(s) of
// the specified type
// All 'event times' are the time of the POST state of the event (i.e. when the
// state change corresponding to the event first showed up).
fun time_of_start[txn: TxnId] : lone Time {
time_of_simple_event[txn, started]
}
fun read_events[txn: TxnId] : Key->TxnId->Time {
{k: Key, versionid: TxnId, post_t: Time - TimeOrder/first[] |
k->versionid not in txn.read.(TimeOrder/prev[post_t])
and k->versionid in txn.read.post_t}
}
fun start_wait_for_xlock_events[txn: TxnId] : Key->Time {
{k: Key, post_t: Time - TimeOrder/first[] |
k not in txn.waitingForXLock.(TimeOrder/prev[post_t])
and k in txn.waitingForXLock.post_t}
}
fun stop_wait_for_xlock_events[txn: TxnId] : Key->Time {
{k: Key, post_t: Time - TimeOrder/first[] |
k in txn.waitingForXLock.(TimeOrder/prev[post_t])
and k not in txn.waitingForXLock.post_t}
}
fun acquire_xlock_events[txn: TxnId] : Key->Time {
{k: Key, post_t: Time - TimeOrder/first[] |
k not in txn.holdingXLock.(TimeOrder/prev[post_t])
and k in txn.holdingXLock.post_t}
}
fun release_xlock_events[txn: TxnId] : Key->Time {
{k: Key, post_t: Time - TimeOrder/first[] |
k in txn.holdingXLock.(TimeOrder/prev[post_t])
and k not in txn.holdingXLock.post_t}
}
fun write_events[txn: TxnId] : Key->Time {
{k: Key, post_t: Time - TimeOrder/first[] |
k not in txn.written.(TimeOrder/prev[post_t])
and k in txn.written.post_t}
}
fun time_of_commit[txn: TxnId] : lone Time {
time_of_simple_event[txn, committed]
}
fun time_of_abort[txn: TxnId] : lone Time {
time_of_simple_event[txn, aborted]
}
fun time_of_abort_to_preserve_serializability[txn: TxnId] : lone Time {
time_of_simple_event[txn, abortedToPreserveSerializability]
}
fun time_of_finalize[txn: TxnId] : lone Time {
time_of_commit[txn] + time_of_abort[txn]
}
fun time_of_simple_event[txn: TxnId, r: TxnId->Time] : lone Time {
{post_t: Time - TimeOrder/first[] |
txn not in r.(TimeOrder/prev[post_t])
and txn in r.post_t}
}
fun times_of_all_events[txn: TxnId] : set Time {
time_of_start[txn]
// read_events returns a set of Key->VersionIdRead->TimeOfEvent
+ ((read_events[txn])[Key])[TxnId]
// write_events returns a set of Key->TimeOfEvent
+ write_events[txn][Key]
// *_xlock_events returns a set of Key->TimeOfEvent
+ start_wait_for_xlock_events[txn][Key]
+ stop_wait_for_xlock_events[txn][Key]
+ acquire_xlock_events[txn][Key]
+ release_xlock_events[txn][Key]
+ time_of_finalize[txn]
}
//
// Ad-hoc constraints, pulled into other predicates purely to select interesting instances.
//
pred all_txns_must_start[] {
TxnId in started.Time
}
pred all_txns_do_at_least_one_read_or_write[] {
// read is: ReaderTxnId -> KeyThatWasRead -> VersionIdThatWasRead -> Time
// written is: WriterTxnId -> KeyThatWasWritten -> Time
(TxnId in (read.Time.TxnId).Key)
or (TxnId in (written.Time).Key)
}
pred some_txn_reads_from_another[] {
some disj Ti,Tj : TxnId | Ti in (Tj.read.Time)[Key]
}
pred no_txn_reads_from_itself[] {
no Ti : TxnId | Ti in (Ti.read.Time)[Key]
}
pred at_least_one_txn_does_a_write[] {
#written.Time > 0
}
pred at_least_one_txn_does_a_read[] {
#read.Time > 0
}
pred if_any_txn_writes_it_does_not_read[] {
all txn: TxnId | some txn.written => no txn.read
}
pred at_least_one_txn_waits_for_an_xlock_and_commits[] {
some txn: TxnId |
some start_wait_for_xlock_events[txn]
and some time_of_commit[txn]
}
pred all_txns_commit_or_abort[] {
TxnId in (committed.Time + aborted.Time)
}
pred no_txns_abort[] {
no aborted.Time
}
pred at_least_one_txn_aborts[] {
#aborted.Time > 0
}
pred at_least_n_txn_abort_to_preserve_serializability[n: Int] {
#(abortedToPreserveSerializability.TimeOrder/last[]) >= n
}
// TODO: check that the model is not now over-constrained
// by changing the algorithm to intentional violate a correctness property, and confirm that the expected violations are found
|
software/pcx86/bdsrc/dos/memory.asm | jeffpar/basicdos | 59 | 242242 | <filename>software/pcx86/bdsrc/dos/memory.asm<gh_stars>10-100
;
; BASIC-DOS Memory Services
;
; @author <NAME> <<EMAIL>>
; @copyright (c) 2020-2021 <NAME>
; @license MIT <https://basicdos.com/LICENSE.txt>
;
; This file is part of PCjs, a computer emulation software project at pcjs.org
;
include macros.inc
include dos.inc
include dosapi.inc
DOS segment word public 'CODE'
EXTNEAR <get_psp,scb_release>
EXTBYTE <scb_locked>
EXTWORD <mcb_head,scb_active>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mem_alloc (REG_AH = 48h)
;
; Inputs:
; REG_AL = MCBTYPE
; REG_BX = paragraphs requested
;
; Outputs:
; On success, REG_AX = new segment
; On failure, REG_AX = error, REG_BX = max paras available
;
DEFPROC mem_alloc,DOS
mov bx,[bp].REG_BX ; BX = # paras requested
call mcb_alloc
jnc ma9
mov [bp].REG_BX,bx
ma9: mov [bp].REG_AX,ax ; update REG_AX and return CARRY
ret
ENDPROC mem_alloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mem_free (REG_AH = 49h)
;
; Inputs:
; REG_ES = segment to free
;
; Outputs:
; On success, carry clear
; On failure, carry set, REG_AX = ERR_BADMCB or ERR_BADADDR
;
DEFPROC mem_free,DOS
mov ax,[bp].REG_ES ; AX = segment to free
call mcb_free
jnc mf9
mov [bp].REG_AX,ax ; update REG_AX and return CARRY set
mf9: ret
ENDPROC mem_free
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mem_realloc (REG_AH = 4Ah)
;
; Inputs:
; REG_ES = segment to realloc
; REG_BX = new size (in paragraphs)
;
; Outputs:
; On success, carry clear
; On failure, carry set, REG_AX = error, REG_BX = max paras available
;
; TODO:
; In some versions of DOS (2.1 and 3.x), this reportedly reallocates the
; block to the largest available size, even though an error is reported.
; Do we care to do the same? I think not.
;
DEFPROC mem_realloc,DOS
mov dx,[bp].REG_ES ; DX = segment to realloc
mov bx,[bp].REG_BX ; BX = # new paras requested
call mcb_realloc
jnc mr9
mov [bp].REG_BX,bx
mov [bp].REG_AX,ax ; update REG_AX and return CARRY set
mr9: ret
ENDPROC mem_realloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mem_query
;
; This utility function simplifies implementation of the MEM /D command.
;
; TODO: While this is a useful function during development, consider dropping
; it (and the MEM /D command) in the final release.
;
; Inputs:
; CX = memory block # (0-based)
; DL = memory block type (0 for any, 1 for free, 2 for used)
;
; Outputs:
; On success, carry clear:
; REG_BX = segment
; REG_AX = owner ID (eg, PSP)
; REG_DX = size (in paragraphs)
; REG_ES:REG_DI -> name of process or type, if any
; On failure, carry set (ie, no more blocks of the requested type)
;
; Modifies:
; AX, BX, CX, DI, ES
;
DEFPROC mem_query,DOS
LOCK_SCB
mov bx,[mcb_head] ; BX tracks ES
mov es,bx
ASSUME ES:NOTHING
q1: mov ax,es:[MCB_OWNER]
test dl,dl ; report any block?
jz q3 ; yes
test ax,ax ; free block?
jnz q2 ; no
cmp dl,1 ; yes, interested?
je q3 ; yes
jmp short q4 ; no
q2: cmp dl,2 ; interested in used blocks?
jne q4 ; no
q3: jcxz q7
dec cx
q4: cmp es:[MCB_SIG],MCBSIG_LAST
stc
je q9
add bx,es:[MCB_PARAS]
inc bx
mov es,bx
jmp q1
q7: mov dx,es:[MCB_PARAS]
mov [bp].REG_AX,ax
mov [bp].REG_DX,dx
cmp ax,MCBOWNER_SYSTEM
jbe q8
mov di,MCB_NAME
cmp byte ptr es:[di],0
jne q7a
mov di,MCB_TYPE
q7a: mov [bp].REG_DI,di
mov [bp].REG_ES,es ; REG_ES:REG_DI -> string
q8: inc bx
mov [bp].REG_BX,bx
clc
q9: UNLOCK_SCB
ret
ENDPROC mem_query
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_init
;
; Inputs:
; ES:0 -> MCB
; AL = SIG (ie, MCBSIG_NEXT or MCBSIG_LAST)
; DX = OWNER (ie, MCBOWNER_NONE, MCBOWNER_SYSTEM, or a PSP segment)
; CX = PARAS
;
; Outputs:
; Carry clear
;
; Modifies:
; AX, CX, DX, DI
;
DEFPROC mcb_init,DOS
ASSUME DS:NOTHING, ES:NOTHING
sub di,di
stosb ; mov es:[MCB_SIG],al
xchg ax,dx
stosw ; mov es:[MCB_OWNER],dx
xchg ax,cx
stosw ; mov es:[MCB_PARAS],cx
mov cl,size MCB_RESERVED + size MCB_NAME
mov al,0
rep stosb
ret
ENDPROC mcb_init
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_setname
;
; Inputs:
; ES = segment
;
; Outputs:
; None
;
; Modifies:
; BX, CX, SI, DI
;
DEFPROC mcb_setname,DOS
ASSUME DS:DOS, ES:NOTHING
push es
mov di,es
dec di
mov es,di
mov bx,[scb_active]
lea si,[bx].SCB_FILENAME + 1
mov cx,size MCB_NAME
mov di,offset MCB_NAME
rep movsb
pop es
ret
ENDPROC mcb_setname
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_split
;
; Inputs:
; ES:0 -> MCB
; AL = SIG for new block
; BX = new (smaller) size for block
; CX = original (larger) size of block
;
; Outputs:
; Carry clear
;
; Modifies:
; AX, CX, DX, DI
;
DEFPROC mcb_split,DOS
ASSUME DS:NOTHING
cmp bx,cx ; are the sizes identical?
jne sp1 ; no
mov es:[MCB_SIG],al ; yes, no actual split required
jmp short sp9
sp1: push es
mov dx,es
add dx,bx
inc dx
mov es,dx ; ES:0 -> new MCB
sub cx,bx ; reduce by # paras requested
dec cx ; reduce by 1 for new MCB
sub dx,dx ; DX = owner (none)
call mcb_init
pop es ; ES:0 -> back to found block
mov es:[MCB_SIG],MCBSIG_NEXT
sp9: mov es:[MCB_PARAS],bx
ret
ENDPROC mcb_split
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_alloc
;
; Inputs:
; AL = MCBTYPE
; BX = paragraphs requested (from REG_BX if via INT 21h)
;
; Outputs:
; On success, carry clear, AX = new segment
; On failure, carry set, BX = max paras available
;
; Modifies:
; AX, BX, CX, DX, DI, ES
;
DEFPROC mcb_alloc,DOS
ASSUME ES:NOTHING
LOCK_SCB
push ax ; save AX
mov es,[mcb_head]
sub dx,dx ; DX = largest free block so far
a1: mov al,es:[MCB_SIG]
cmp al,MCBSIG_NEXT
je a2
cmp al,MCBSIG_LAST
jne a7
a2: mov cx,es:[MCB_PARAS] ; CX = # paras this block
cmp es:[MCB_OWNER],0 ; free block?
jne a6 ; no
cmp cx,bx ; big enough?
je a4 ; just big enough, use as-is
ja a3 ; yes
cmp dx,cx ; is this largest free block so far?
jae a6 ; no
mov dx,cx ; yes
jmp short a6
;
; Split the current block; the new MCB at the split point will
; be marked free, and it will have the same MCB_SIG as the found block.
;
a3: mov al,es:[MCB_SIG] ; AL = signature for new block
call mcb_split
a4: call get_psp
jnz a5
mov ax,MCBOWNER_SYSTEM ; no active PSP yet, so use this
a5: mov es:[MCB_OWNER],ax
pop ax ; AL = MCBTYPE again
mov es:[MCB_TYPE],al
mov ax,es
inc ax ; return ES+1 in AX, with CARRY clear
clc
jmp short a9
a6: cmp es:[MCB_SIG],MCBSIG_LAST; last block?
je a8 ; yes, return error
mov ax,es ; advance to the next block
add ax,cx
inc ax
mov es,ax
jmp a1
a7: mov ax,ERR_BADMCB
jmp short a8a
a8: mov ax,ERR_NOMEMORY
mov bx,dx ; BX = max # paras available
a8a: pop dx ; throw away AX
stc
a9: UNLOCK_SCB
ret
ENDPROC mcb_alloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_realloc
;
; Inputs:
; DX = segment to realloc (from REG_ES if via INT 21h)
; BX = new size (in paragraphs)
;
; Outputs:
; On success, carry clear, AX = new segment
; On failure, carry set, BX = max paras available for segment
;
; Modifies:
; AX, BX, CX, DX, DI, ES
;
DEFPROC mcb_realloc,DOS
ASSUME ES:NOTHING
LOCK_SCB
dec dx
mov es,dx ; ES:0 -> MCB
mov cx,es:[MCB_PARAS] ; CX = # paras in block
cmp bx,cx ; any change in size?
je r9 ; no, that's easy
mov al,es:[MCB_SIG]
cmp al,MCBSIG_LAST ; is this the last block?
je r2 ; yes
add dx,cx
inc dx
mov ds,dx ; DS:0 -> next MCB
ASSUME DS:NOTHING
mov al,ds:[MCB_SIG]
cmp ds:[MCB_OWNER],0 ; is the next MCB free?
jne r2 ; no
add cx,ds:[MCB_PARAS] ; yes, include it
inc cx ; CX = maximum # of paras
r2: cmp bx,cx ; is requested <= avail?
ja r8 ; no
call mcb_split ; yes, split block into used and free
jmp short r9 ; return success
r7: mov ax,ERR_BADMCB
jmp short r8a
r8: mov bx,cx ; BX = maximum # of paras available
mov ax,ERR_NOMEMORY
r8a: stc
r9: UNLOCK_SCB
ret
ENDPROC mcb_realloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_free
;
; When freeing a block, it's important to merge it with any free block that
; immediately precedes or follows it. And since the MCBs are singly-linked,
; we must walk the chain from the head until we find the candidate block.
;
; Inputs:
; AX = segment to free (from REG_ES if via INT 21h)
;
; Outputs:
; On success, carry clear
; On failure, carry set, AX = ERR_BADMCB or ERR_BADADDR
;
; Modifies:
; AX, BX, CX, DX, ES
;
DEFPROC mcb_free,DOS
ASSUME ES:NOTHING
LOCK_SCB
mov bx,[mcb_head] ; BX tracks ES
dec ax ; AX = candidate MCB
sub dx,dx ; DX = previous MCB (0 if not free)
f1: mov es,bx
cmp bx,ax ; does current MCB match candidate?
jne f4 ; no
;
; If the previous block is free, add this block's paras (+1 for its MCB)
; to the previous block's paras.
;
test dx,dx ; is the previous block free?
jz f3 ; no
f2: mov al,es:[MCB_SIG]
cmp al,MCBSIG_NEXT
je f2a
cmp al,MCBSIG_LAST
jne f7
f2a: mov cx,es:[MCB_PARAS] ; yes, merge current with previous
inc cx
mov es,dx ; ES:0 -> previous block
add es:[MCB_PARAS],cx ; update its number of paras
mov es:[MCB_SIG],al ; propagate the signature as well
mov bx,dx
sub dx,dx
;
; Mark the candidate block free, and if the next block is NOT free, we're done.
;
f3: mov es:[MCB_OWNER],dx ; happily, DX is zero
mov es:[MCB_NAME],dl
cmp es:[MCB_SIG],MCBSIG_LAST; is there a next block?
je f9 ; no (and carry is clear)
mov dx,bx ; yes, save this block as new previous
add bx,es:[MCB_PARAS]
inc bx
mov es,bx ; ES:0 -> next block
cmp es:[MCB_OWNER],0 ; also free?
jne f9 ; no, we're done (and carry is clear)
;
; Otherwise, use the same merge logic as before; the only difference now
; is that the candidate block has become the previous block.
;
jmp f2
f4: cmp es:[MCB_SIG],MCBSIG_LAST; continuing search: last block?
je f8 ; yes, return error
sub dx,dx ; assume block is not free
cmp es:[MCB_OWNER],dx ; is it free?
jne f5 ; no
mov dx,bx ; DX = new previous (and free) MCB
f5: add bx,es:[MCB_PARAS]
inc bx
jmp f1 ; check the next block
f7: mov ax,ERR_BADMCB
jmp short f8a
f8: mov ax,ERR_BADADDR
f8a: stc
f9: UNLOCK_SCB
ret
ENDPROC mcb_free
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_free_all
;
; Used during process termination to free all blocks "owned" by a PSP.
;
; Inputs:
; AX = owner (PSP)
;
; Outputs:
; On success, carry clear
; On failure, carry set, AX = ERR_BADMCB or ERR_BADADDR
;
; Modifies:
; AX, BX, CX, DX, ES
;
DEFPROC mcb_free_all,DOS
ASSUME ES:NOTHING
LOCK_SCB
mov bx,[mcb_head]
fa1: mov es,bx
cmp es:[MCB_OWNER],ax ; MCB owned by PSP?
jne fa8 ; no
push ax ; save owner
mov ax,es ; AX = MCB
inc ax ; AX = segment
call mcb_free ; free the segment
pop ax ; restore owner
jc fa9 ; assuming free was successful
mov bx,es ; we can pick up where free left off
jmp fa1
fa8: cmp es:[MCB_SIG],MCBSIG_LAST
je fa9
add bx,es:[MCB_PARAS]
inc bx
jmp fa1
fa9: UNLOCK_SCB
ret
ENDPROC mcb_free_all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; mcb_getsize
;
; Returns the size (in paras) of a segment IFF it's a valid memory block.
;
; It's tempting to simply subtract one from the segment and check for an MCB
; signature; however, it's too easy to be spoofed by a bogus signature. The
; only way to be sure it's valid is by walking the MCB chain.
;
; Inputs:
; DX = segment
;
; Outputs:
; On success, carry clear:
; AX = size of segment, in paragraphs
; CX = owner (zero if free)
; On failure, carry set (not a valid memory block)
;
; Modifies:
; AX, CX
;
DEFPROC mcb_getsize,DOS
ASSUME ES:NOTHING
LOCK_SCB
push bx
push es
mov bx,[mcb_head] ; BX tracks ES
dec dx ; DX = candidate MCB
gs1: mov es,bx
cmp bx,dx ; does current MCB match candidate?
je gs8 ; yes
cmp es:[MCB_SIG],MCBSIG_LAST; continuing search: last block?
stc
je gs9 ; yes, return error
add bx,es:[MCB_PARAS]
inc bx
jmp gs1 ; check the next block
gs8: mov ax,es:[MCB_PARAS] ; AX = size, in paragraphs
mov cx,es:[MCB_OWNER] ; CX = owner (zero if free)
gs9: inc dx ; restore DX
pop es
pop bx
UNLOCK_SCB
ret
ENDPROC mcb_getsize
DOS ends
end
|
oeis/325/A325126.asm | neoneye/loda-programs | 11 | 28542 | ; A325126: a(1) = 1; a(n) = -Sum_{d|n, d<n} rad(n/d) * a(d), where rad = A007947.
; Submitted by <NAME>
; 1,-2,-3,2,-5,6,-7,-2,6,10,-11,-6,-13,14,15,2,-17,-12,-19,-10,21,22,-23,6,20,26,-12,-14,-29,-30,-31,-2,33,34,35,12,-37,38,39,10,-41,-42,-43,-22,-30,46,-47,-6,42,-40,51,-26,-53,24,55,14,57,58,-59,30
add $0,1
mov $1,1
mov $2,1
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mod $4,$2
cmp $4,0
cmp $4,0
mov $5,$2
add $2,1
cmp $5,1
max $4,$5
sub $3,$4
lpe
mov $3,$2
mul $3,-1
add $3,1
mov $5,-1
lpb $0
dif $0,$2
mul $5,$3
lpe
dif $5,$3
mul $5,$2
mul $1,$5
lpe
mov $0,$1
|
src/Semantics/Substitution/Soundness.agda | DimaSamoz/temporal-type-systems | 4 | 4170 | <gh_stars>1-10
-- Soundness proofs of structural lemmas and substitution
module Semantics.Substitution.Soundness where
open import Syntax.Types
open import Syntax.Context renaming (_,_ to _,,_)
open import Syntax.Terms
open import Syntax.Substitution.Kits
open import Syntax.Substitution.Instances
open import Syntax.Substitution.Lemmas
open import Semantics.Types
open import Semantics.Context
open import Semantics.Terms
open import Semantics.Substitution.Kits
open import Semantics.Substitution.Traversal
open import Semantics.Substitution.Instances
open import Semantics.Bind
open import CategoryTheory.Categories using (Category ; ext)
open import CategoryTheory.Functor
open import CategoryTheory.NatTrans
open import CategoryTheory.Monad
open import CategoryTheory.Comonad
open import CategoryTheory.Linear
open import CategoryTheory.Instances.Reactive renaming (top to ⊤)
open import TemporalOps.Diamond
open import TemporalOps.Box
open import TemporalOps.OtherOps
open import TemporalOps.StrongMonad
open import TemporalOps.Linear
open import Data.Sum
open import Data.Product using (_,_)
open import Relation.Binary.PropositionalEquality as ≡
using (_≡_ ; refl ; sym ; trans ; cong ; cong₂ ; subst)
open ≡.≡-Reasoning
open import Holes.Term using (⌞_⌟)
open import Holes.Cong.Propositional
open ⟦K⟧ ⟦𝒯erm⟧
-- | Interpretation of various types of substitution as context morphisms
-- Denotation of term substitutions
⟦_⟧ₛ : ∀{Γ Δ} -> Subst Term Γ Δ -> ⟦ Δ ⟧ₓ ⇴ ⟦ Γ ⟧ₓ
⟦ σ ⟧ₛ = ⟦subst⟧ σ
-- Denotation of OPEs
⟦_⟧⊆ : ∀{Γ Δ} -> Γ ⊆ Δ -> ⟦ Δ ⟧ₓ ⇴ ⟦ Γ ⟧ₓ
⟦ s ⟧⊆ = ⟦ s ⊆ₛ 𝒯erm ⟧ₛ
-- Denotation of context exchange
⟦exch⟧ : ∀ Γ Γ′ Γ″ {A B} -> ⟦ Γ ⌊ B ⌋ Γ′ ⌊ A ⌋ Γ″ ⟧ₓ ⇴ ⟦ Γ ⌊ A ⌋ Γ′ ⌊ B ⌋ Γ″ ⟧ₓ
⟦exch⟧ Γ Γ′ Γ″ = ⟦ exₛ 𝒯ermₛ Γ Γ′ Γ″ ⟧ₛ
-- Denotation of context contraction
⟦contr⟧ : ∀ Γ Γ′ Γ″ {A} -> ⟦ Γ ⌊ A ⌋ Γ′ ⌊⌋ Γ″ ⟧ₓ ⇴ ⟦ Γ ⌊ A ⌋ Γ′ ⌊ A ⌋ Γ″ ⟧ₓ
⟦contr⟧ Γ Γ′ Γ″ = ⟦ contr-lₛ 𝒯ermₛ Γ Γ′ Γ″ ⟧ₛ
-- Denotation of middle context substitution
⟦_⌊⌋ₛ_⊢ₛ_⟧ : ∀ Γ Γ′ {A} -> Γ ⌊⌋ Γ′ ⊢ A -> ⟦ Γ ⌊⌋ Γ′ ⟧ₓ ⇴ ⟦ Γ ⌊ A ⌋ Γ′ ⟧ₓ
⟦ Γ ⌊⌋ₛ Γ′ ⊢ₛ M ⟧ = ⟦ sub-midₛ 𝒯ermₛ Γ Γ′ M ⟧ₛ
-- Denotational soundness of top substitution
⟦sub-topₛ⟧ : ∀ {Γ A} -> (M : Γ ⊢ A)
-> ⟦ sub-topₛ 𝒯ermₛ M ⟧ₛ ≈ ⟨ id , ⟦ M ⟧ₘ ⟩
⟦sub-topₛ⟧ {Γ} M {n} {⟦Γ⟧} rewrite ⟦idₛ⟧ {Γ} {n} {⟦Γ⟧} = refl
-- | Soundness theorems
-- | Concrete soundness theorems for structural lemmas and substitution
-- | are instances of the general traversal soundness proof
-- Substituting traversal is sound
substitute-sound : ∀{Γ Δ A} (σ : Subst Term Γ Δ) (M : Γ ⊢ A)
-> ⟦ substitute σ M ⟧ₘ ≈ ⟦ M ⟧ₘ ∘ ⟦ σ ⟧ₛ
substitute-sound σ M = traverse-sound ⟦𝒯erm⟧ σ M
substitute′-sound : ∀{Γ Δ A} (σ : Subst Term Γ Δ) (M : Γ ⊨ A)
-> ⟦ substitute′ σ M ⟧ᵐ ≈ ⟦ M ⟧ᵐ ∘ ⟦ σ ⟧ₛ
substitute′-sound σ M = traverse′-sound ⟦𝒯erm⟧ σ M
-- Weakening lemma is sound
weakening-sound : ∀{Γ Δ A} (s : Γ ⊆ Δ) (M : Γ ⊢ A)
-> ⟦ weakening s M ⟧ₘ ≈ ⟦ M ⟧ₘ ∘ ⟦ s ⟧⊆
weakening-sound s = substitute-sound (s ⊆ₛ 𝒯erm)
-- Exchange lemma is sound
exchange-sound : ∀{Γ Γ′ Γ″ A B C} (M : Γ ⌊ A ⌋ Γ′ ⌊ B ⌋ Γ″ ⊢ C)
-> ⟦ exchange Γ Γ′ Γ″ M ⟧ₘ ≈ ⟦ M ⟧ₘ ∘ (⟦exch⟧ Γ Γ′ Γ″)
exchange-sound {Γ} {Γ′} {Γ″} = substitute-sound (exₛ 𝒯ermₛ Γ Γ′ Γ″)
-- Contraction lemma is sound
contraction-sound : ∀{Γ Γ′ Γ″ A B} (M : Γ ⌊ A ⌋ Γ′ ⌊ A ⌋ Γ″ ⊢ B)
-> ⟦ contraction Γ Γ′ Γ″ M ⟧ₘ ≈ ⟦ M ⟧ₘ ∘ (⟦contr⟧ Γ Γ′ Γ″)
contraction-sound {Γ} {Γ′} {Γ″} = substitute-sound (contr-lₛ 𝒯ermₛ Γ Γ′ Γ″)
-- Substitution lemma is sound
substitution-sound : ∀{Γ Γ′ A B} (M : Γ ⌊⌋ Γ′ ⊢ A) (N : Γ ⌊ A ⌋ Γ′ ⊢ B)
-> ⟦ substitution Γ Γ′ M N ⟧ₘ ≈ ⟦ N ⟧ₘ ∘ ⟦ Γ ⌊⌋ₛ Γ′ ⊢ₛ M ⟧
substitution-sound {Γ} {Γ′} M = substitute-sound (sub-midₛ 𝒯ermₛ Γ Γ′ M)
-- Substitution lemma is sound
substitution′-sound : ∀{Γ Γ′ A B} (M : Γ ⌊⌋ Γ′ ⊢ A) (N : Γ ⌊ A ⌋ Γ′ ⊨ B)
-> ⟦ substitution′ Γ Γ′ M N ⟧ᵐ ≈ ⟦ N ⟧ᵐ ∘ ⟦ Γ ⌊⌋ₛ Γ′ ⊢ₛ M ⟧
substitution′-sound {Γ} {Γ′} M N = traverse′-sound ⟦𝒯erm⟧ (sub-midₛ 𝒯ermₛ Γ Γ′ M) N
-- Top substitution is sound (full categorical proof)
subst-sound : ∀{Γ A B} (M : Γ ⊢ A) (N : Γ ,, A ⊢ B)
-> ⟦ [ M /] N ⟧ₘ ≈ ⟦ N ⟧ₘ ∘ ⟨ id , ⟦ M ⟧ₘ ⟩
subst-sound M N {n} {a} rewrite sym (⟦sub-topₛ⟧ M {n} {a}) =
substitute-sound (sub-topₛ 𝒯ermₛ M) N
-- Top substitution is sound (full categorical proof)
subst′-sound : ∀{Γ A B} (M : Γ ⊢ A) (N : Γ ,, A ⊨ B)
-> ⟦ [ M /′] N ⟧ᵐ ≈ ⟦ N ⟧ᵐ ∘ ⟨ id , ⟦ M ⟧ₘ ⟩
subst′-sound M N {n} {a} rewrite sym (⟦sub-topₛ⟧ M {n} {a}) =
traverse′-sound ⟦𝒯erm⟧ (sub-topₛ 𝒯ermₛ M) N
open K 𝒯erm
open Monad M-◇
open Comonad W-□
open Functor F-□ renaming (fmap to □-f)
open Functor F-◇ renaming (fmap to ◇-f)
private module F-◇ = Functor F-◇
-- Lemma used in the soundness proof of computational substitution
subst″-sound-lemma : ∀ Γ {A B} (n k l : ℕ)
-> (D : Γ ˢ ,, A now ⊨ B now)
-> (⟦Γ⟧ : ⟦ Γ ⟧ₓ n) (⟦A⟧ : ⟦ A ⟧ₜ l)
-> ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ l (⟦ Γ ˢ ˢ⟧□ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k) l , ⟦A⟧)
≡ ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧)
subst″-sound-lemma Γ {A} n k l D ⟦Γ⟧ ⟦A⟧
rewrite substitute′-sound ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D {l} {⟦ Γ ˢ ˢ⟧□ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k) l , ⟦A⟧}
| ⟦↑⟧ (A now) (Γ ˢˢₛ 𝒯erm) {l} {⟦ Γ ˢ ˢ⟧□ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k) l , ⟦A⟧}
| □-≡ k l (□-≡ n k (⟦ˢ⟧□-twice Γ {n} {⟦Γ⟧}) k) l
| □-≡ k l (⟦ˢˢ⟧ Γ {n} {⟦Γ⟧}) l = refl
subst″-sound : ∀{Γ A B} (C : Γ ⊨ A now) (D : Γ ˢ ,, A now ⊨ B now)
-> ⟦ ⟨ C /⟩ D ⟧ᵐ ≈ bindEvent Γ ⟦ C ⟧ᵐ ⟦ D ⟧ᵐ
subst″-sound {Γ}{A}{B} (pure M) D {n} {⟦Γ⟧}
rewrite traverse′-sound ⟦𝒯erm⟧ (sub-topˢₛ 𝒯ermₛ M) D {n} {⟦Γ⟧}
| ⟦subst⟧-Γˢ⊆Γ Γ {n} {⟦Γ⟧} | ⟦ˢ⟧-factor Γ {n} {⟦Γ⟧} = refl
subst″-sound {Γ}{A}{B} (letSig_InC_ {A = G} S C) D {n} {⟦Γ⟧}
rewrite subst″-sound C (substitute′ (idₛ 𝒯erm ⁺ 𝒯erm ↑ 𝒯erm) D) {n} {⟦Γ⟧ , ⟦ S ⟧ₘ n ⟦Γ⟧}
=
begin
bindEvent (Γ ,, G always) ⟦ C ⟧ᵐ ⌞ ⟦ substitute′ ((_⁺_ {G always} (idₛ 𝒯erm) 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ ⌟ n (⟦Γ⟧ , ⟦ S ⟧ₘ n ⟦Γ⟧)
≡⟨ bind-to->>= (Γ ,, G always) ⟦ C ⟧ᵐ ⟦ substitute′ ((_⁺_ {G always} (idₛ 𝒯erm) 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ n (⟦Γ⟧ , ⟦ S ⟧ₘ n ⟦Γ⟧) ⟩
⟦ C ⟧ᵐ n (⟦Γ⟧ , ⟦ S ⟧ₘ n ⟦Γ⟧)
>>= (λ l ⟦A⟧ → ⟦ substitute′ (idₛ 𝒯erm ⁺ 𝒯erm ↑ 𝒯erm) D ⟧ᵐ l ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧))
≡⟨ cong (λ x → (⟦ C ⟧ᵐ n (⟦Γ⟧ , ⟦ S ⟧ₘ n ⟦Γ⟧) >>= x))
(ext λ l → ext λ ⟦A⟧ →
begin
⟦ substitute′ (idₛ 𝒯erm ⁺ 𝒯erm ↑ 𝒯erm) D ⟧ᵐ l ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧)
≡⟨ substitute′-sound (_↑_ {A now} (_⁺_ {G always} (idₛ 𝒯erm) 𝒯erm) 𝒯erm) D {l} {((⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧)} ⟩
⟦ D ⟧ᵐ l (⟦ (_↑_ {A now} {Γ = Γ ˢ} (_⁺_ {G always} (idₛ 𝒯erm) 𝒯erm) 𝒯erm) ⟧ₛ l ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧))
≡⟨ cong (⟦ D ⟧ᵐ l) (⟦↑⟧ (A now) {Γ ˢ ,, G always} (_⁺_ {G always} (idₛ 𝒯erm) 𝒯erm) {l} {(⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧}) ⟩
⟦ D ⟧ᵐ l (⟦ _⁺_ {G always} {Γ = Γ ˢ} (idₛ 𝒯erm) 𝒯erm ⟧ₛ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧) , ⟦A⟧)
≡⟨ cong (λ x → ⟦ D ⟧ᵐ l (x , ⟦A⟧)) (⟦⁺⟧ (G always) {Γ ˢ} (idₛ 𝒯erm) {l} {⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦ S ⟧ₘ n ⟦Γ⟧}) ⟩
⟦ D ⟧ᵐ l (⟦ idₛ {Γ ˢ} 𝒯erm ⟧ₛ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l) , ⟦A⟧)
≡⟨ cong (λ x → ⟦ D ⟧ᵐ l (x , ⟦A⟧)) (⟦idₛ⟧ {Γ ˢ} {l} {⟦ Γ ˢ⟧□ n ⟦Γ⟧ l}) ⟩
⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧)
∎
)
⟩
⟦ letSig S InC C ⟧ᵐ n ⟦Γ⟧
>>= (λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ sym (bind-to->>= Γ ⟦ letSig S InC C ⟧ᵐ ⟦ D ⟧ᵐ n ⟦Γ⟧) ⟩
bindEvent Γ ⟦ letSig S InC C ⟧ᵐ ⟦ D ⟧ᵐ n ⟦Γ⟧
∎
subst″-sound {Γ}{A}{B} (letEvt_In_ {A = G} E C) D {n} {⟦Γ⟧} =
begin
⟦ ⟨ letEvt E In C /⟩ D ⟧ᵐ n ⟦Γ⟧
≡⟨ bind-to->>= Γ ⟦ E ⟧ₘ ⟦ ⟨ C /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ n ⟦Γ⟧ ⟩
⟦ E ⟧ₘ n ⟦Γ⟧
>>= (λ k ⟦A⟧ → ⟦ ⟨ C /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧))
≡⟨ cong (λ x → ⟦ E ⟧ₘ n ⟦Γ⟧ >>= x)
(ext λ k → ext λ ⟦A⟧ → (begin
⟦ ⟨ C /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧)
≡⟨ subst″-sound C (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) {k} {⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧} ⟩
bindEvent (Γ ˢ ,, G now) ⟦ C ⟧ᵐ
⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧)
≡⟨ bind-to->>= (Γ ˢ ,, G now) ⟦ C ⟧ᵐ ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧) ⟩
⟦ C ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧)
>>= (λ l ⟦A⟧₁ → ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ l (⟦ Γ ˢ ˢ⟧□ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k) l , ⟦A⟧₁))
≡⟨ cong (λ x → ⟦ C ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧) >>= x)
(ext λ l → ext λ ⟦A⟧₁ → subst″-sound-lemma Γ n k l D ⟦Γ⟧ ⟦A⟧₁) ⟩
⟦ C ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧)
>>= (λ l ⟦A⟧₁ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧₁))
∎)) ⟩
⟦ E ⟧ₘ n ⟦Γ⟧
>>= (λ k ⟦A⟧ → ⟦ C ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧)
>>= λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ sym (>>=-assoc (⟦ E ⟧ₘ n ⟦Γ⟧) _ _) ⟩
(⟦ E ⟧ₘ n ⟦Γ⟧
>>= λ k ⟦A⟧ → ⟦ C ⟧ᵐ k (⟦ Γ ˢ⟧□ n ⟦Γ⟧ k , ⟦A⟧))
>>= (λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ cong (λ x -> x >>= _) (sym (bind-to->>= Γ ⟦ E ⟧ₘ ⟦ C ⟧ᵐ n ⟦Γ⟧)) ⟩
(⟦ letEvt E In C ⟧ᵐ n ⟦Γ⟧
>>= (λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧)))
≡⟨ sym (bind-to->>= Γ ⟦ letEvt E In C ⟧ᵐ ⟦ D ⟧ᵐ n ⟦Γ⟧) ⟩
bindEvent Γ ⟦ letEvt E In C ⟧ᵐ ⟦ D ⟧ᵐ n ⟦Γ⟧
∎
subst″-sound {Γ}{A}{B} (select_↦_||_↦_||both↦_ {A = G}{H} E₁ C₁ E₂ C₂ C₃) D {n} {⟦Γ⟧} =
begin
⟦ ⟨ select E₁ ↦ C₁ || E₂ ↦ C₂ ||both↦ C₃ /⟩ D ⟧ᵐ n ⟦Γ⟧
≡⟨⟩
⟦ select E₁ ↦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D)
|| E₂ ↦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D)
||both↦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ n ⟦Γ⟧
≡⟨⟩
bindEvent Γ (⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫) (handle
⟦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ) n ⟦Γ⟧
≡⟨ bind-to->>= Γ (⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫) (handle
⟦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ) n ⟦Γ⟧ ⟩
⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ n ⟦Γ⟧
>>= (λ l ⟦A⟧ → handle
⟦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ cong (λ x → ⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ n ⟦Γ⟧ >>= x) (ext λ m → ext λ c → lemma m c) ⟩
⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ n ⟦Γ⟧
>>= (λ m c → handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ m (⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , c)
>>= λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ sym (>>=-assoc (⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ n ⟦Γ⟧) _ _) ⟩
(⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ n ⟦Γ⟧
>>= λ m c -> handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ m (⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , c))
>>= (λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ cong (λ x -> x >>= _) (sym (bind-to->>= Γ (⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫)
(handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ) n ⟦Γ⟧)) ⟩
bindEvent Γ (⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫)
(handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ) n ⟦Γ⟧
>>= (λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
≡⟨ sym (bind-to->>= Γ (bindEvent Γ (⟪_,_⟫ ⟦ E₁ ⟧ₘ ⟦ E₂ ⟧ₘ) (handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ))
⟦ D ⟧ᵐ n ⟦Γ⟧) ⟩
bindEvent Γ (bindEvent Γ ⟪ ⟦ E₁ ⟧ₘ , ⟦ E₂ ⟧ₘ ⟫ (handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ)) ⟦ D ⟧ᵐ n ⟦Γ⟧
∎
where
lemma : ∀ m c
-> handle
⟦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ
⟦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟧ᵐ m (⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , c)
≡ (handle ⟦ C₁ ⟧ᵐ ⟦ C₂ ⟧ᵐ ⟦ C₃ ⟧ᵐ m (⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , c)
>>= λ l ⟦A⟧ → ⟦ D ⟧ᵐ l (⟦ Γ ˢ⟧□ n ⟦Γ⟧ l , ⟦A⟧))
lemma m (inj₁ (inj₁ (⟦A⟧ , ⟦◇B⟧)))
rewrite subst″-sound C₁ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) {m} {(⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦A⟧) , ⟦◇B⟧}
| bind-to->>= (Γ ˢ ,, G now ,, Event H now) ⟦ C₁ ⟧ᵐ ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ m ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦A⟧) , ⟦◇B⟧)
| (ext λ l → ext λ ⟦C⟧ → subst″-sound-lemma Γ n m l D ⟦Γ⟧ ⟦C⟧)
= refl
lemma m (inj₁ (inj₂ (⟦◇A⟧ , ⟦B⟧)))
rewrite subst″-sound C₂ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) {m} {(⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦◇A⟧) , ⟦B⟧}
| bind-to->>= (Γ ˢ ,, Event G now ,, H now) ⟦ C₂ ⟧ᵐ ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ m ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦◇A⟧) , ⟦B⟧)
| (ext λ l → ext λ ⟦C⟧ → subst″-sound-lemma Γ n m l D ⟦Γ⟧ ⟦C⟧)
= refl
lemma m (inj₂ (⟦A⟧ , ⟦B⟧))
rewrite subst″-sound C₃ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) {m} {(⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦A⟧) , ⟦B⟧}
| bind-to->>= (Γ ˢ ,, G now ,, H now) ⟦ C₃ ⟧ᵐ ⟦ substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D ⟧ᵐ m ((⟦ Γ ˢ⟧□ n ⟦Γ⟧ m , ⟦A⟧) , ⟦B⟧)
| (ext λ l → ext λ ⟦C⟧ → subst″-sound-lemma Γ n m l D ⟦Γ⟧ ⟦C⟧)
= refl
|
src/gbc/cps_inc_overflow.asm | Hacktix/TixTest-GB | 5 | 4844 | <reponame>Hacktix/TixTest-GB
; ===== Makefile Headers =====
; MBC 0x00
; RAM 0x00
INCLUDE "hardware.inc"
INCLUDE "font.inc"
INCLUDE "common.inc"
BCPS_LABEL_ADDR_BASE EQU $9821
OCPS_LABEL_ADDR_BASE EQU $9861
SECTION "Header", ROM0[0]
ds $100 - @
SECTION "Test", ROM0[$100]
EntryPoint::
jr Main
ds $150 - @
;----------------------------------------------------------------------------
; This test ROM verifies the behavior of the BCPS and OCPS registers when
; automatic increments are enabled and the CPS register contains the highest
; possible value while the corresponding CPD register is written to.
;
; CPS registers should wrap around, resulting in the next write to the CPD
; register affecting palette 0.
;----------------------------------------------------------------------------
Main::
; Wait for VBlank
ld a, [rLY]
cp SCRN_Y
jr c, Main
; Disable LCD
xor a
ldh [rLCDC], a
; Load Font Data into VRAM
call LoadFont
; Initialize Palette Loading
ld a, BCPSF_AUTOINC
ldh [rBCPS], a
ldh [rOCPS], a
; Test BG Palettes
ld hl, wReadBCPS
ld c, LOW(rBCPD)
call RunTest
ld c, LOW(rOCPD)
call RunTest ; HL is at wReadOCPS at this point
; Write BCPS Label to Screen and preserve Pointer for Result String
ld hl, BCPS_LABEL_ADDR_BASE
ld de, strLabelBCPS
call Strcpy
dec hl
push hl
; Check BCPS Results and display result
ld hl, wReadBCPS
call CheckResults
jr z, .passBCPS
ld de, strFail
jr .printResultBCPS
.passBCPS
ld de, strPass
.printResultBCPS
pop hl
call Strcpy
; Write OCPS Label to Screen and preserve Pointer for Result String
ld hl, OCPS_LABEL_ADDR_BASE
ld de, strLabelOCPS
call Strcpy
dec hl
push hl
; Check OCPS Results and display result
ld hl, wReadOCPS
call CheckResults
jr z, .passOCPS
ld de, strFail
jr .printResultOCPS
.passOCPS
ld de, strPass
.printResultOCPS
pop hl
call Strcpy
; Reset BG Palette 0 to Display Results
ld a, BCPSF_AUTOINC
ldh [rBCPS], a
ld hl, palResults
ld c, LOW(rBCPD)
call LoadPalette
; Re-enable LCD
ld a, LCDCF_ON | LCDCF_BGON
ldh [rLCDC], a
; Lock Up
jr @
;----------------------------------------------------------------------------
; Reads the state of the selected CPS register and stores it in memory, then
; writes to the CPD register to increment the CPS register.
;----------------------------------------------------------------------------
RunTest::
; Write to XCPD and read from XCPS 2*4*9 times
; 2 Writes per Color
; 4 Colors per Palette
; 9 Palettes (To cause XCPS Overflow)
ld b, 2*4*9
.testLoop
; Read from XCPS and reset C to XCPD
dec c
ldh a, [$ff00+c]
inc c
; Write to XCPD and Memory
ldh [$ff00+c], a
ld [hli], a
; Check if enough writes have occurred
dec b
jr nz, .testLoop
ret
;----------------------------------------------------------------------------
; Checks 0x48 bytes in memory starting at HL for a series of incrementing
; values with the upper 2 bits always set to 1, as XCPS registers only
; contain 6-bit values.
;----------------------------------------------------------------------------
CheckResults::
; $C0 - Initial Value for XCPS registers
; $48 - Size of memory region to check
ld bc, $C048
.checkLoop
; Load Value from HL, compare to B
ld a, [hli]
cp b
jr nz, .failedCheck
; Increment B, keep bits 6 & 7 high
ld a, b
inc a
or $C0
ld b, a
; Check if end of values is reached
dec c
jr nz, .checkLoop
.passedCheck
xor a ; Set Zero Flag
ret
.failedCheck
rla ; Reset Zero Flag
ret
SECTION "Strings", ROM0
strLabelBCPS: db "BG Palette: ", 0
strLabelOCPS: db "OBJ Palette: ", 0
strPass: db "OK!", 0
strFail: db "Fail!", 0
SECTION "Palettes", ROM0
palResults: dw $FFFF, $0000, $0000, $0000
SECTION "WRAM", WRAM0
wReadBCPS: ds 2*4*9
wReadOCPS: ds 2*4*9 |
agda/Heapsort/Impl2.agda | bgbianchi/sorting | 6 | 200 | <gh_stars>1-10
open import Relation.Binary.Core
module Heapsort.Impl2 {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import BBHeap _≤_ hiding (flatten)
open import BBHeap.Compound _≤_
open import BBHeap.Drop _≤_ tot≤ trans≤
open import BBHeap.Drop.Properties _≤_ tot≤ trans≤
open import BBHeap.Heapify _≤_ tot≤ trans≤
open import BBHeap.Order _≤_
open import BBHeap.Order.Properties _≤_
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Data.List hiding (drop)
open import OList _≤_
flatten : {b : Bound}(h : BBHeap b) → Acc h → OList b
flatten leaf _ = onil
flatten (left b≤x l⋘r) (acc rs) = :< b≤x (flatten (drop (cl b≤x l⋘r)) (rs (drop (cl b≤x l⋘r)) (lemma-drop≤′ (cl b≤x l⋘r))))
flatten (right b≤x l⋙r) (acc rs) = :< b≤x (flatten (drop (cr b≤x l⋙r)) (rs (drop (cr b≤x l⋙r)) (lemma-drop≤′ (cr b≤x l⋙r))))
heapsort : List A → OList bot
heapsort xs = flatten (heapify xs) (≺-wf (heapify xs))
|
test/Fail/NonUniqueInstance1.agda | cruhland/agda | 1,989 | 2533 | open import Common.Prelude hiding (tt)
instance
tt : ⊤
tt = record{}
NonZero : Nat → Set
NonZero zero = ⊥
NonZero (suc _) = ⊤
pred′ : (n : Nat) {{_ : NonZero n}} → Nat
pred′ zero {{}}
pred′ (suc n) = n
test : (n : Nat) {{x y : NonZero n}} → Nat
test n = pred′ n
|
programs/oeis/168/A168195.asm | neoneye/loda | 22 | 89798 | <filename>programs/oeis/168/A168195.asm
; A168195: a(n) = 2*n - a(n-1) + 1 with n>1, a(1)=5.
; 5,0,7,2,9,4,11,6,13,8,15,10,17,12,19,14,21,16,23,18,25,20,27,22,29,24,31,26,33,28,35,30,37,32,39,34,41,36,43,38,45,40,47,42,49,44,51,46,53,48,55,50,57,52,59,54,61,56,63,58,65,60,67,62,69,64,71,66,73,68,75,70,77,72,79,74,81,76,83,78,85,80,87,82,89,84,91,86,93,88,95,90,97,92,99,94,101,96,103,98
mov $1,$0
gcd $1,2
mul $1,6
add $0,$1
sub $0,7
|
commands/system/wallpaper-refresh.applescript | itsmewes/script-commands | 0 | 1733 | <filename>commands/system/wallpaper-refresh.applescript
#!/usr/bin/osascript
# @raycast.title Refresh Wallpaper
# @raycast.author <NAME>
# @raycast.authorURL https://github.com/crstauf
# @raycast.description Refresh the current display's wallpaper.
# @raycast.icon 🖼️
# @raycast.mode silent
# @raycast.packageName System
# @raycast.schemaVersion 1
tell application "System Events"
set rotinterval to change interval of current desktop
set change interval of current desktop to rotinterval
end tell
do shell script "echo Refreshed wallpaper" |
run on external mount.scpt | byronmansfield/lrbkup | 0 | 2122 | <filename>run on external mount.scpt
(*
External Drive Auto Backup
AppleScript for prompting user to run a bash script via OSX dialog GUI
when a watched folder has a new item. Intended use is to prompt for
backup script to run when external drive is mounted
Written and maintained by: <NAME> <EMAIL>
*)
-- trigger added items to folder
on adding folder items to this_folder after receiving added_items
-- check if it is storage specifically
if (added_items as string) contains "Storage" then
-- prompt user with dialog to run backup or not
set run_lrbkup to button returned of (display dialog "External hard drive Storage was mounted. Would you like to run lrbkup script?" buttons {"No", "Yes"} default button "Yes" with icon note)
-- check if run backup script is yes else do nothing
if run_lrbkup is "Yes" then
-- open a fresh new window in iTerm2 and run lrbkup script
tell application "iTerm2"
set new_term to (create window with default profile)
tell new_term
tell the current session
write text "lrbkup"
end tell
end tell
end tell
end if
end if
end adding folder items to
|
AER201.asm | angusfung/Barrel-Inspector-Robot | 0 | 21256 | <gh_stars>0
list p=16f877 ; list directive to define processor
#include <p16f877.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF
#include <rtc_macros.inc>
cblock 0x20
COUNTH
COUNTM
COUNTL
Table_Counter
lcd_tmp
lcd_d1
lcd_d2
com
dat ; was in sample code
count ; used to convert optime to decimal for display
ones ; ones digit of the converted binary number
tens ; tens digit of the converted binary number
huns ; hundreds digit of the converted binary number (hopefully not used)
binary_num ; move optime to this variable to allow binary --> decimal for display
w_temp ; saves the value in the working register
status_temp ; saves the current state of the status register (for ISR)
barrel1:4
barrel2:4 ;41
barrel3:4 ;44
barrel4:4 ;47
barrel5:4 ;50
barrel6:4 ;53
barrel7:4 ;56
;1: Stores Tall/Short Barrel, Stores E/HF/F
;2: Location (stores distance < 256 cm)
;3: Location (if distance > 256 cm)
barrelnum ;current barrel number
barreltemp
option_temp
Delay1
Delay2
TIMCNT
voltage_IR
counter_IR
lastop_IR ;checks last operation of IR
IR_DETECT
Time_High
Time_Low
ad_store
dis_counter ;increments to 17 for the encoder
dis_counter4 ;increments to 4 before incrementing 17 times for the encoder
min:2 ;temporary registers for operation time
sec:2
initmin:2
initsec:2
finalmin:2
finalsec:2
armextend ;set to 1 when arm extended
Dis_Ones
Dis_Tens
Dis_Hunds
Dis_Thous
ultra_time
threshold_time
barrel_data
endc
cblock 0x70
COUNTH1 ;const used in delay
COUNTM1 ;const used in delay
COUNTL1 ;const used in delay
endc
;Declare constants for pin assignments (LCD on PORTD)
#define RS PORTD,2
#define E PORTD,3
;ANALOG PINS
#define IR1 PORTA,0
#define IR2 PORTA,1
#define IR3 PORTA,2
#define IR4 PORTA,3
#define IR5 PORTA,5
#define IR6 PORTE,0
#define IR7 PORTE,1
#define IR8 PORTE,2
;DIGITAL PINS
#define DCA1 PORTC,1 ;DC motor A1 PWM
#define DCA2 PORTC,0 ;DC motor A2
#define DCB1 PORTC,2 ;DC motor B1 PWM
#define DCB2 PORTD,5 ;DC motor B2 ;A7
#define DCC1 PORTD,6 ;DC motor C1
#define DCC2 PORTD,4 ;DC motor C2
#define US_TRIG PORTC,5 ;Ultrasonic TRIGGER
#define US_ECHO PORTC,6 ;Ultrasonic ECHO
#define LS PORTC,7 ;Laser Sensor Bottom - Digital
;#define LSH PORTD,1 ;Laser Sensor Top - Digital
#define ES PORTD,0 ;encoder sensor
ORG 0x0000 ;RESET vector must always be at 0x00
goto init ;Just jump to the main code section.
;DCB???
;***************************************
; Delay: ~160us macro
;***************************************
LCD_DELAY macro
movlw 0xFF
movwf lcd_d1
decfsz lcd_d1,f
goto $-1
endm
;***************************************
; Display macro
;***************************************
Display macro Message
local loop_
local end_
clrf Table_Counter
clrw
loop_ movf Table_Counter,W
call Message
xorlw B'00000000' ;check WORK reg to see if 0 is returned
btfsc STATUS,Z
goto end_
call WR_DATA
incf Table_Counter,F
goto loop_
end_
endm
bank0 macro
bcf STATUS, RP0
bcf STATUS, RP1
endm
bank1 macro
bcf STATUS, RP0
bsf STATUS, RP1
endm
bank2 macro
bsf STATUS, RP0
bcf STATUS, RP1
endm
bank3 macro
bsf STATUS, RP0
bcf STATUS, RP1
endm
binconv macro
movwf binary_num
call BIN2BCD
movf huns,W
call WR_DATA
movf tens,W
call WR_DATA
movf ones,W
call WR_DATA
endm
;***************************************
; Initialize LCD
;***************************************
init
clrf INTCON ; No interrupts
; bsf INTCON, GIE ; enable global interrupts
; bsf INTCON, 5 ; enable timer 0 interrupts
; bcf INTCON, 4 ; clear timer0 interrupt flag
; bcf INTCON, 2 ; disable internal interrupts (from Port B)
; bcf INTCON, 1 ; clear internal interrupt flag.
; NEED TO FIX THESE SETTINGS
bsf STATUS,RP0 ; select bank 1
movlw b'00101111' ; set RA4 as output
movlw b'11111011' ; Set required keypad inputs
movwf TRISB
clrf TRISC ; All port C is output
;Set SDA and SCL to high-Z first as required for I2C
bsf TRISC,4
bsf TRISC,3
bsf TRISC,7
bsf TRISC,6 ;US_ECHO
clrf TRISD
bsf TRISD,0 ;the encoder is an input
bsf TRISD,1
movlw b'00000111' ;set RE0-3 as input for IR sensors
movwf TRISE
bcf STATUS,RP0 ; select bank 0
clrf PORTA
clrf PORTB
clrf PORTC
clrf PORTD
clrf PORTE
;Set up I2C for communication
call i2c_common_setup
;rtc_resetAll
;Used to set up time in RTC, load to the PIC when RTC is used for the first time
call set_rtc_time
call InitLCD ;Initialize the LCD (code in lcd.asm; imported by lcd.inc)
; Set up Pulse Width Modulation (PWM)
bsf STATUS,RP0 ; Bank1
movlw b'11111001' ; Configure PR2 with 10 kHz
movwf PR2
bcf STATUS,RP0 ; Bank0
movlw b'00001111' ; Configure RC1 and RC2 as PWM outputs
movwf CCP2CON ; RC1
movwf CCP1CON
movlw b'00000100' ; Configure Timer2
movwf T2CON ; Set to prescaler 1:1, postscaler 1:1 , enabled
movwf T1CON
; Initialize motor variable
clrf CCPR2L ; Set RC1 to 0% duty cycle
clrf CCPR1L
;bcf PORTB,0
;bcf PORTC,0
;bcf PORTC,2
;bsf PORTC,5
;bcf PORTC,6
;***************************************
; Main code
;***************************************
Main
btfss PORTB, 1
goto $-1
Display Welcome_Msg1
btfsc PORTB, 1 ;check if cleared
goto $-1
btfss PORTB, 1
goto $-1
call Switch_Lines
Display Welcome_Msg2
test
btfss PORTB, 1 ;check for input from KEYPAD
goto $-1 ;if NOT, keep polling
swapf PORTB, W ;when input is detected, swamp nibbles
;PORTB <7-4> moved to <3-0> in w
andlw 0x0F
xorlw b'00001100' ;checks if 12th key is pressed *
btfss STATUS, Z ;if pressed, then Z=1
goto test ;if NOT, then keep checking until * is pressed
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto START
;***************************************
; Look up table
;***************************************
Welcome_Msg1
addwf PCL,F
dt "Welcome!", 0
Welcome_Msg2
addwf PCL,F
dt "Press * to Start", 0
Message1
addwf PCL,F
dt "T", 0
Message2
addwf PCL,F
dt " B:", 0
Message3
addwf PCL,F
dt "Press * to Reset", 0
Message4
addwf PCL,F
dt "Press # for Info", 0
Message5
addwf PCL,F
dt " TP:", 0
Message6
addwf PCL,F
dt "L:", 0
Message7
addwf PCL,F
dt "D:", 0
Message8
addwf PCL,F
dt " OT", 0
;***************************************
; OPERATION CODE
;***************************************
START
call Clear_Display
;initializing
;intialize barrel1/2/3/4/5/6/7
movlw b'01011000' ;ASCII X
movwf barrel1
movwf barrel2
movwf barrel3
movwf barrel4
movwf barrel5
movwf barrel6
movwf barrel7
;intialize barrel1/2/3/4/5/6/7 + 1
movlw b'00100011' ;#
movwf barrel1+1
movwf barrel2+1
movwf barrel3+1
movwf barrel4+1
movwf barrel5+1
movwf barrel6+1
movwf barrel7+1
movwf barrel1+2
movwf barrel2+2
movwf barrel3+2
movwf barrel4+2
movwf barrel5+2
movwf barrel6+2
movwf barrel7+2
movwf barrel1+3
movwf barrel2+3
movwf barrel3+3
movwf barrel4+3
movwf barrel5+3
movwf barrel6+3
movwf barrel7+3
movlw d'0'
movwf barrelnum
movwf barreltemp
movlw b'00110000'
movwf Dis_Ones
movlw b'00110000'
movwf Dis_Tens
movlw b'00110000'
movwf Dis_Hunds
movlw b'00110000'
movwf Dis_Thous
movlw d'0'
movwf IR_DETECT
movwf threshold_time
bsf STATUS, C ;preset C to 1
movlw b'0'
movwf Time_High
movlw b'0'
movwf Time_Low
movwf dis_counter
movwf dis_counter4
;check if ALl the IRs work
;TEST_IR
; call CHECK_IR1
; movfw IR_DETECT
; call CHECK_DETECT
;
; call CHECK_IR2
; movfw IR_DETECT
; call CHECK_DETECT
;
; call CHECK_IR3
; movfw IR_DETECT
; call CHECK_DETECT
;
; call CHECK_IR4
; movfw IR_DETECT
; call CHECK_DETECT
;
; call Clear_Display
; goto TEST_IR
;
;
;CHECK_DETECT
; xorlw b'1'
; btfss STATUS,Z
; goto SHOWLOW
; call SHOWHIGH
;CHECK_EXIT
; return
;
;SHOWHIGH
; movlw '1'
; call WR_DATA
; return
;
;
;SHOWLOW
; movlw '0'
; call WR_DATA
; goto CHECK_EXIT
;
OPERATION_ENCODER
movlw b'0' ;reset the counter
movwf dis_counter
;call Clear_Display
btfss ES ;check if ES gets a HIGH
goto OPERATION_ENCODER
;call DISTANCECALL17
;check if 4 divisions are counted
incf dis_counter4
movfw dis_counter4
xorlw d'4'
btfss STATUS, Z ;Z=1 when dis_counter4=4
goto OPERATION_ENCODER
call DISTANCECALL17
goto OPERATION_ENCODER
DISTANCECALL17
movlw b'0'
movwf dis_counter4
movfw dis_counter
xorlw d'17' ;Z=1 if dis_counter=17
btfsc STATUS,Z
return ;if Z=1, return
call Distance_Count
incf dis_counter
goto DISTANCECALL17
;
OPERATION_START
;call Realtime
;call CHECK_DISTANCE
;btfsc STATUS, C ;if not set, then continue
;goto END_OPERATION ;if set, then turn back
;btfss ES ;check if Encoder Sensor detects
;goto START1; if doesn't detect, continue
;call Distance_Count ;if so, increment the Distance
START1
;DISTANCE DISPLAY FOR DEBUGGING ONLY
;movlw " "
;call WR_DATA
;movfw Dis_Hunds
;call WR_DATA
;movfw Dis_Tens
;call WR_DATA
;movfw Dis_Ones
;call WR_DATA
;call Clear_Display
;DISTANCE DISPLAY FOR DEBUGGING ONLY
;movfw armextend
;xorlw b'0'
;btfss STATUS,Z
;goto RETRACT_ARM_BACK ;else, retract arm
;at this point, it is clear we have no obstructions, turn on the motors
;turn on the left motor, turn on the right motor
call MOTOR_ON_RC1
call MOTOR_ON_RC2
;*************TEST*
;call RETRACT_ARM_BACK ;just to see the arm rotate back and forth with delay of 1 second
;*************TEST*
;we continue to operate until any of the 8 IR sensors detects something and
;at the same time, we are detecting if there is a column w/ the ultrasonic sesnor
;this is effectively a VERY FAST poll that checks between the IR sensors and the ultrasonic sensors
CHECK_IRSENSORS
;checks all 8 IR sensors
call CHECK_IR1
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR2
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR3
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR4
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR5
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR6
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR7
movfw IR_DETECT
call CHECK_DETECT
call CHECK_IR8
movfw IR_DETECT
call CHECK_DETECT
;if none sensors detected, check US sensor
goto CHECK_US
CHECK_DETECT
xorlw b'1'
btfss STATUS,Z ;Z=1 if IR_DETECT = 1
return ; if Z=0, return and check the next sensor
goto DETECTED ;if detected, check US
;;PURPOSE: Checks the ultrasonic, if detects it, it will stop the motors, rotate the arm
;; ;and them come back and turn the motors back on so that it can
;; ;continue to check for barrels again
;; ;if does not detect, then it will jump to keeping the motors on and
;; ;continue to check for barrels again
CHECK_US
call ULTRASONIC
;C is set when Time_High > 3
movlw b'11' ;3
subwf Time_High,W
btfss STATUS, C
call RETRACT_ARM_BACK ;this means C<3, retract arm
call MOTOR_ON_RC1
call MOTOR_ON_RC2
goto CHECK_IRSENSORS ;this means C>3, go back to checking
DETECTED
;at this point, the LSL has been detected, so stop the motors
call MOTOR_BOTH_OFF
;now check if the LSH detects anything, if it does, it means it is a
;large barrel, if not, then it is a small barrel
btfss LS; if the laser detects AND the IR sensors detect, it is a large barrel
goto SHORTBARREL ;it is a short barrel
goto TALLBARRELL ;it is a large barel
;at this point, done recording and continue with operation
goto OPERATION_START
END_OPERATION
;turn back
call RETRACT_ARM
;reset the distance
movlw b'00110000'
movwf Dis_Ones
movlw b'00110000'
movwf Dis_Tens
movlw b'00110000'
movwf Dis_Hunds
END_LOOP ;add in to retrieve final operation time
bsf DCA ;turn on motos to travel back
bsf DCB
call CHECK_DISTANCE
btfss STATUS, C ;if set, then end
goto END_LOOP ;if not, keep going
bcf DCA ;turn off DC motors
bcf DCB
goto END_DISPLAY ;exit
END_DISPLAY
call Clear_Display
Display Message3
call Switch_Lines
Display Message4
CHECK_PRESS1
btfss PORTB, 1 ;check for input from KEYPAD
goto $-1 ;if NOT, keep polling
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
goto OPTION1
OPTION1 ;checks if * was pressed
movwf option_temp
xorlw b'00001100' ; Check to see if 12th key
btfss STATUS,Z ; If status Z goes to 0, it is the 13th key, skip
goto OPTION2 ; If not check if it's B
call Clear_Display
goto Main ; If it is, restart
OPTION2 ;checks if # was pressed
movf option_temp, W
xorlw b'00001110'
btfss STATUS,Z
goto CHECK_PRESS1 ;resume polling
call Clear_Display
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto POLL1
POLL1
btfss PORTB, 1 ;check for input from KEYPAD
goto Polltime1 ;if no input, poll INFO
swapf PORTB, W ;when input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS1 ;check which key was pressed
Polltime1
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "1" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel1 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel1
call Check_Height
Display Message7
movfw barrel1+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel1+2
call WR_DATA
movfw barrel1+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL1
CHECKPRESS1
BACKWARD1 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD1 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL7
FORWARD1 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL1 ;resume polling
call Clear_Display
goto POLL2
;***************************************
; BARREL2
;***************************************
POLL2
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime2
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS2
Polltime2
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "2" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel2 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel2
call Check_Height
Display Message7
movfw barrel2+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel2+2
call WR_DATA
movfw barrel2+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL2
CHECKPRESS2
BACKWARD2 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD2 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL1
FORWARD2 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL2 ;resume polling
call Clear_Display
goto POLL3
;***************************************
; BARREL3
;***************************************
POLL3
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime3
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS3
Polltime3
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "3" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel3 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel3
call Check_Height
Display Message7
movfw barrel3+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel3+2
call WR_DATA
movfw barrel3+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL3
CHECKPRESS3
BACKWARD3 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD3 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL2
FORWARD3 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL2 ;resume polling
call Clear_Display
goto POLL4
;***************************************
; BARREL4
;***************************************
POLL4
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime4
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS4
Polltime4
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "4" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel4 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel4
call Check_Height
Display Message7
movfw barrel4+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel4+2
call WR_DATA
movfw barrel4+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL4
CHECKPRESS4
BACKWARD4 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD4 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL3
FORWARD4 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL4 ;resume polling
call Clear_Display
goto POLL5
;***************************************
; BARREL5
;***************************************
POLL5
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime5
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS5
Polltime5
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "5" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel5 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel5
call Check_Height
Display Message7
movfw barrel5+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel5+2
call WR_DATA
movfw barrel5+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL5
CHECKPRESS5
BACKWARD5 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD5 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL4
FORWARD5 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL5 ;resume polling
call Clear_Display
goto POLL6
;***************************************
; BARREL6
;***************************************
POLL6
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime6
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS6
Polltime6
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "6" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel6 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel6
call Check_Height
Display Message7
movfw barrel6+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel6+2
call WR_DATA
movfw barrel6+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL6
CHECKPRESS6
BACKWARD6 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD6 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL5
FORWARD6 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL6 ;resume polling
call Clear_Display
goto POLL7
;***************************************
; BARREL7
;***************************************
POLL7
btfss PORTB, 1 ;check for input from KEYPAD
;goto $-1 ;if NOT, keep polling
goto Polltime7
swapf PORTB, W ;When input is detected, read it in to W
andlw 0x0F
btfsc PORTB, 1 ;keep iterating until key is released
goto $-1
goto CHECKPRESS7
Polltime7
movlw "T" ;displays T for Real Time
call WR_DATA
call Realtime ;displays Real Time
Display Message2 ;displays B:
movlw "7" ;displays barrel #
call WR_DATA
Display Message5
movfw barrel7 ;T/S/E/HF/F
call Check_Type
call Switch_Lines
Display Message6
movfw barrel7
call Check_Height
Display Message7
movfw barrel7+3 ;ten digit first, how is this stored? Leave as O's for now
call WR_DATA
movfw barrel7+2
call WR_DATA
movfw barrel7+1
call WR_DATA
Display Message8
call HalfS
call Clear_Display
goto POLL7
CHECKPRESS7
BACKWARD7 ;checks if 1 was pressed
movwf option_temp
xorlw b'00000000' ;checks to see if "1" was pressed
btfss STATUS,Z ;if status Z goes to 0, it is not "1"
goto FORWARD7 ;if not, check to see if "2" was pressed
call Clear_Display
goto POLL6
FORWARD7 ;checks if 2 was pressed
movf option_temp, W
xorlw b'00000001'
btfss STATUS,Z
goto POLL7 ;resume polling
call Clear_Display
goto POLL1
goto $
;1: Stores Tall/Short Barrel, Stores E/HF/F
;2: Location (stores distance < 256 cm)
;3: Location (if distance > 256 cm)
;;
;;
;;
;;ShiftDisplayLeft
; ;call Clear_Display
;
;; Display Welcome_Msg2
;;ChangeToQuestionMark
;; movlw b'11001011'
;; call WR_INS
;; movlw "?"
;; call WR_DATA
;
;
;
;;Left movlw b'00011000' ;Move to the left
;; call WR_INS
;; call HalfS
;; goto Left ;repeat operation
;;
;***************************************
; MAIN PROGRAM SUBROUTINES
;***************************************
;***************************************
; IR SENSOR CODE
;***************************************
CHECK_IR1
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11000001' ;to select IR1
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR2
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11001001' ;to select IR2
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR3
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11010001' ;to select IR3
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR4
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11011001' ;to select IR4
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR5
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11100001' ;to select IR5
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR6
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11101001' ;to select IR6
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR7
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11110001' ;to select IR7
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
CHECK_IR8
;initialize IR_DETECT
movlw b'0'
movwf IR_DETECT
movlw b'11111001' ;to select IR8
movwf ad_store
movfw ad_store
call IR_MAINLOOP
return ;GO BACK TO OPERATION CODE
IR_MAINLOOP
movfw ad_store ;storing the ADCON value
call AD_CONV
movwf voltage_IR
call CHECK_IR
btfss STATUS,C
goto DISPLAYCHECKHIGH
goto DISPLAYLOW
return
;C is set when voltage >= 4.1
CHECK_IR
movlw b'10111101'
subwf voltage_IR,W
return
DISPLAYLOW
movlw d'0'
movwf lastop_IR
movlw b'0'
movwf IR_DETECT
return
DISPLAYCHECKHIGH
movfw lastop_IR ;check if last call was a 1
xorlw d'1'
btfsc STATUS, Z
goto INCREMENT_IR ;if it is, increment
movlw d'1' ;else, set lastop = 1
movwf lastop_IR
movlw d'1' ;set counter = 1
movwf counter_IR
goto IR_MAINLOOP
;return
INCREMENT_IR
movfw counter_IR
xorlw d'4'
btfsc STATUS,Z
goto DISPLAYHIGH
incf counter_IR
movfw counter_IR
xorlw d'4'
btfsc STATUS,Z
goto DISPLAYHIGH
goto IR_MAINLOOP
;return
DISPLAYHIGH
movlw b'1'
movwf IR_DETECT
return
;***************************************
; ULTRASONIC SENSOR CODE
;***************************************
ULTRASONIC
movlw d'16' ;initialize timer module
movwf T1CON
movlw d'0'
movwf TMR1L
movlw d'0'
movwf TMR1H
bsf US_TRIG ;10us TRIGGER HIGH
call DelayL
bcf US_TRIG ;TRIGGER LOW
btfss US_ECHO ;waiting to detect echo (HIGH)
goto $-1
bsf T1CON, 0 ;turn timer on / TMR1ON=1
btfsc US_ECHO ;waiting for echo to go LOW
goto $-1
bcf T1CON, 0 ;turn timer off
movfw TMR1L
movwf Time_Low
movfw TMR1H
movwf Time_High
return
;;***************************************
;; ENCODER SUBROUTINE
;;***************************************
;;
;; btfss PORTB, 1
;; goto $-1
;; call Clear_Display
;; call Distance_Count
;; movfw Dis_Hunds
;; call WR_DATA
;; movfw Dis_Tens
;; call WR_DATA
;; movfw Dis_Ones
;; call WR_DATA
;; btfsc PORTB, 1
;; goto $-1
;; goto TEST_ENCODER
;; goto $
;
;***************************************
; DISTANCE COUNT SUBROUTINE
;***************************************
Distance_Count
;movlw 0x0C ;Wait to begin
;Keypad
movfw Dis_Ones
xorlw b'00111001'
btfsc STATUS,Z
goto Skip_Ten
incf Dis_Ones,1
return
Skip_Ten movfw Dis_Tens
xorlw b'00111001'
btfsc STATUS,Z
goto Skip_Hund
incf Dis_Tens,1
movlw b'00110000'
movwf Dis_Ones
return
Skip_Hund movfw Dis_Hunds
xorlw b'00111001' ;ASCII 9
btfsc STATUS,Z
goto Skip_Thou
incf Dis_Hunds,1
movlw b'00110000'
movwf Dis_Ones
movwf Dis_Tens
return
Skip_Thou incf Dis_Thous,1
movlw b'00110000' ;ASCII 0
movwf Dis_Ones
movwf Dis_Tens
movwf Dis_Hunds
return
;;***************************************
;; RETRACT ARM SUBROUTINE
;;***************************************
;
;RETRACT_ARM_BACK
; ;bcf DCA1 ;turn off wheel motors
; ;bcf DCB1 ;turn off wheel motors
; bcf DCC1
; bsf DCC2 ;turn on DC motor
; ;for X seconds, need to be tested
; call HalfS
; call HalfS
; call HalfS
; call HalfS
;
; bcf DCC2 ;turn off DC motor
;
;
; ;dont move for 3 seconds
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
;
; bsf DCC1
; bcf DCC2 ;reverse arm DC direction
;
;
; call HalfS
; call HalfS
; call HalfS
; call HalfS
;
; bcf DCC1
;
;
; return
;*TEST RETRACT_ARM FOR DEMO*
;RETRACT_ARM_BACK
; bcf DCC1
; bsf DCC2 ;turn on DC motor
;
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
;
;
; bsf DCC1
; bcf DCC2 ;reverse arm DC direction
;
;
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
; call HalfS
;
;
;
; return
;
;***************************************
; CHECK DISTANCE SUBROUTINE
;***************************************
CHECK_DISTANCE
movfw Dis_Hunds ;this must be <=4
movlw b'00110100' ;max value for the hundreds place
subwf Dis_Hunds, W ;Dis_Hunds <- Dis_Hunds - 4
return
;***************************************
; SHORTBARREL SUBROUTINE
;***************************************
SHORTBARREL
incf barrelnum, 1 ;increment barrel count
call CHECK_IR1 ;check if IR1 detects
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto SHORTBARREL1 ;IR1 does not detect, then check IR5
goto SFULLORHALF ;IR1 detects, at this point, the barrel is either FULL or HALFFULL
SHORTBARREL1
call CHECK_IR5 ;check if IR5 detects
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto RECORD_SE ;IR1 and IR5 both don't detect, it is SMALL+EMPTY
goto SFULLORHALF ;IR5 detects, at this point, the barrel is either FULL or HALFFULL
SFULLORHALF
call CHECK_IR3 ;check if IR3 detects
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto SFULLORHALF1 ;IR3 does not detect, check IR7 on the other side
goto RECORD_SF ;IR3 detects, it must be SMALL + FULL
SFULLORHALF1
call CHECK_IR7 ;check if IR7 detects
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto RECORD_SHF ;IR3 and IR7 does not detect, but either IR1 or IR5 detected, so this must be SMALL + HALFFULL
goto RECORD_SF ;IR7 detects, it must be SMALL + FULL
;***************************************
; TALLBARREL SUBROUTINE
;***************************************
TALLBARRELL
incf barrelnum, 1
call CHECK_IR2 ;check if IR2 detects
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto TALLBARRELL1 ;if IR2 does not detect, check IR6 on the other side of the arm
goto TFULLORHALF ;if IR2 detects, the barrel is either FULL or HALFFULL
TALLBARRELL1
call CHECK_IR6
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto RECORD_TE ;if IR6 does not detect either, it must be EMPTY
goto TFULLORHALF ;if IR6 detects, the barrel is either FULL or HALFFULL
TFULLORHALF
call CHECK_IR4
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto TFULLORHALF1 ;if IR4 does not detect, check IR8 on the other side of the arm
goto RECORD_TF ;if IR4 detects, it must be TALL + FULL
TFULLORHALF1
call CHECK_IR8
movfw IR_DETECT
xorlw b'1'
btfss STATUS, Z
goto RECORD_THF ;if IR8 does not detect either, it must be TALL + HALLFULL
goto RECORD_TF ;if IR8 detects, it is TALL + FULL
;***************************************
; MOVE INFO TO BARREL_DATA SUBROUTINE
;***************************************
RECORD_SE
movlw b'00001100' ;(S=1/T=0)/E/HF/F
movwf barrel_data ;store it so it can be recorded
goto RECORD
RECORD_SHF
movlw b'00001010'
movwf barrel_data
goto RECORD
RECORD_SF
movlw b'00001001'
movwf barrel_data
goto RECORD
RECORD_TE
movlw b'00000100'
movwf barrel_data
goto RECORD
RECORD_THF
movlw b'00000010'
movwf barrel_data
goto RECORD
RECORD_TF
movlw b'00000001'
movwf barrel_data
goto RECORD
;***************************************
; MAIN RECORD
;***************************************
RECORD ;main record
;first need to determine which barrel it is
B_ONE
movfw barrelnum ;move barrelnum to working register
xorlw b'00000001' ; 1
btfsc STATUS, Z
goto RECORD_ONE
goto B_TWO
B_TWO
movfw barrelnum
xorlw b'00000010' ; 2
btfsc STATUS, Z
goto RECORD_TWO
goto B_THREE
B_THREE
movfw barrelnum
xorlw b'00000011' ;3
btfsc STATUS, Z
goto RECORD_THREE
goto B_FOUR
B_FOUR
movfw barrelnum
xorlw b'00000100' ;4
btfsc STATUS, Z
goto RECORD_FOUR
goto B_FIVE
B_FIVE
movfw barrelnum
xorlw b'00000101' ;5
btfsc STATUS, Z
goto RECORD_FIVE
goto B_SIX
B_SIX
movfw barrelnum
xorlw b'00000110' ;6
btfsc STATUS, Z
goto RECORD_SIX
goto B_SEVEN
B_SEVEN
goto RECORD_SEVEN ;has to be barrel 7 at this point
;***************************************
; RECORD WHEN BARREL NUMBER IS KNOWN
;***************************************
RECORD_ONE
;stores the E/HF/F bits
movfw barrel_data
movwf barrel1 ;move the data into barrel1, althought only the last three move bits are important
goto OPERATION_START ;go back to program
RECORD_TWO
movfw barrel_data
movwf barrel2
goto OPERATION_START
RECORD_THREE
movfw barrel_data
movwf barrel3
goto OPERATION_START
RECORD_FOUR
movfw barrel_data
movwf barrel4
goto OPERATION_START
RECORD_FIVE
movfw barrel_data
movwf barrel5
goto OPERATION_START
RECORD_SIX
movfw barrel_data
movwf barrel6
goto OPERATION_START
RECORD_SEVEN
movfw barrel_data
movwf barrel7
goto OPERATION_START
;***************************************
; ULTRASONIC DELAYS (10 us)
;***************************************
DelayL
movlw 0x30 ; b'00110000'
movwf 0x53 ; general purpose register
CONT3L
decfsz 0x53, f
goto CONT3L
return
;***************************************
; MOTOR SUBROUTINE (PWM)
;***************************************
MOTOR_ON_RC1
movlw b'11111111'
movwf CCPR2L
bsf PORTC, 1
return
MOTOR_ON_RC2
movlw b'11111111'
movwf CCPR1L
bsf PORTC,2
return
MOTOR_BOTH_OFF
movlw b'00000000'
movwf CCPR2L
movwf CCPR1L
return
;100% 11111111 255
;80% 11000111 199
;60% 10010101 149
;0% 00000000
;***************************************
; LCD control
;***************************************
Switch_Lines
movlw B'11000000'
call WR_INS
return
Clear_Display
movlw B'00000001'
call WR_INS
return
;***************************************
; Delay 0.5s
;***************************************
HalfS
local HalfS_0
movlw 0x88
movwf COUNTH
movlw 0xBD
movwf COUNTM
movlw 0x03
movwf COUNTL
HalfS_0
decfsz COUNTH, f
goto $+2
decfsz COUNTM, f
goto $+2
decfsz COUNTL, f
goto HalfS_0
goto $+1
nop
nop
return
;***************************************
; STORING BARREL INFO ON LCD SUBROUTINE
;***************************************
Check_Type
CHECKE
movwf barreltemp ;STORE IT TEMPORARY, LEST XORLW WILL ALTER IT
;check if barrel has been accessed
movfw barreltemp
xorlw b'01011000' ;ASCII X
btfsc STATUS, Z ;Z=1 if ASCII X
goto PRINTDEFAULT ;Z=1, so display X
movfw barreltemp ;Z!=1, so continue
btfss barreltemp,2
goto CHECKHF
movlw "E"
call WR_DATA
return
CHECKHF
movfw barreltemp
btfss barreltemp,1
goto CHECKF
movlw "H"
call WR_DATA
movlw "F"
call WR_DATA
return
CHECKF
;must be FULL at this point
movlw "F"
call WR_DATA
return
PRINTDEFAULT
movlw "X"
call WR_DATA
return
Check_Height
CHECKSHORT
movwf barreltemp ;STORE IN HERE TEMPORARILY
;check if barrel has been accessed
movfw barreltemp
xorlw b'01011000' ;ASCII X
btfsc STATUS, Z ;Z=1 if ASCII X
goto PRINTDEFAULT1 ;Z=1, so display X
movfw barreltemp ;Z!=1, so continue
btfss barreltemp,3
goto CHECKTALL
movlw "S"
call WR_DATA
movlw " "
call WR_DATA
return
CHECKTALL ;must be TALL at this point
movlw "T"
call WR_DATA
movlw " "
call WR_DATA
return
PRINTDEFAULT1
movlw "X"
call WR_DATA
movlw " "
call WR_DATA
return
;******* LCD-related subroutines *******
;***********************************
InitLCD
bcf STATUS,RP0
bsf E ;E default high
;Wait for LCD POR to finish (~15ms)
call lcdLongDelay
call lcdLongDelay
call lcdLongDelay
;Ensure 8-bit mode first (no way to immediately guarantee 4-bit mode)
; -> Send b'0011' 3 times
movlw b'00110011'
call WR_INS
call lcdLongDelay
call lcdLongDelay
movlw b'00110010'
call WR_INS
call lcdLongDelay
call lcdLongDelay
; 4 bits, 2 lines, 5x7 dots
movlw b'00101000'
call WR_INS
call lcdLongDelay
call lcdLongDelay
; display on/off
movlw b'00001100'
call WR_INS
call lcdLongDelay
call lcdLongDelay
; Entry mode
movlw b'00000110'
call WR_INS
call lcdLongDelay
call lcdLongDelay
; Clear ram
movlw b'00000001'
call WR_INS
call lcdLongDelay
call lcdLongDelay
return
;************************************
;ClrLCD: Clear the LCD display
ClrLCD
movlw B'00000001'
call WR_INS
return
;****************************************
; Write command to LCD - Input : W , output : -
;****************************************
WR_INS
bcf RS ;clear RS
movwf com ;W --> com
andlw 0xF0 ;mask 4 bits MSB w = X0
movwf PORTD ;Send 4 bits MSB
bsf E ;
call lcdLongDelay ;__ __
bcf E ; |__|
swapf com,w
andlw 0xF0 ;1111 0010
movwf PORTD ;send 4 bits LSB
bsf E ;
call lcdLongDelay ;__ __
bcf E ; |__|
call lcdLongDelay
return
;****************************************
; Write data to LCD - Input : W , output : -
;****************************************
WR_DATA
bsf RS
movwf dat
movf dat,w
andlw 0xF0
addlw 4
movwf PORTD
bsf E ;
call lcdLongDelay ;__ __
bcf E ; |__|
swapf dat,w
andlw 0xF0
addlw 4
movwf PORTD
bsf E ;
call lcdLongDelay ;__ __
bcf E ; |__|
return
lcdLongDelay
movlw d'20'
movwf lcd_d2
LLD_LOOP
LCD_DELAY
decfsz lcd_d2,f
goto LLD_LOOP
return
;*********
; BIN2BCD
; Converts a binary number to ASCII
; characters for display on the LCD
; Written by: <NAME>
; Sourced from: piclist.com --> 8 bit to ASCII Decimal 3 digits
;**********
BIN2BCD
movlw 8
movwf count
clrf huns
clrf tens
clrf ones
BCDADD3
movlw 5
subwf huns, 0
btfsc STATUS, C
CALL ADD3HUNS
movlw 5
subwf tens, 0
btfsc STATUS, C
CALL ADD3TENS
movlw 5
subwf ones, 0
btfsc STATUS, C
CALL ADD3ONES
decf count, 1
bcf STATUS, C
rlf binary_num, 1
rlf ones, 1
btfsc ones,4 ;
CALL CARRYONES
rlf tens, 1
btfsc tens,4 ;
CALL CARRYTENS
rlf huns,1
bcf STATUS, C
movf count, 0
btfss STATUS, Z
goto BCDADD3
movf huns, 0 ; add ASCII Offset
addlw h'30'
movwf huns
movf tens, 0 ; add ASCII Offset
addlw h'30'
movwf tens
movf ones, 0 ; add ASCII Offset
addlw h'30'
movwf ones
return
ADD3HUNS
movlw 3
addwf huns,1
return
ADD3TENS
movlw 3
addwf tens,1
return
ADD3ONES
movlw 3
addwf ones,1
return
CARRYONES
bcf ones, 4
bsf STATUS, C
return
CARRYTENS
bcf tens, 4
bsf STATUS, C
return
;call AD_CONV
;call WR_DATA
;call HalfS
;call Clear_Display
;goto Main
;*********
; ADC
;**********
goto INITA
INITA bsf STATUS,RP0 ;select bank 1
bcf INTCON,GIE ;disable global interrupt
movlw B'00000000' ;configure ADCON1
movwf ADCON1
clrf TRISB ;configure PORTB as output
bcf STATUS,RP0 ;select bank 0
goto ADSTART
;***************************************************************
; MAIN PROGRAM
;***************************************************************
ADSTART call AD_CONV ;call the A2D subroutine
movwf PORTB ;display the high 8-bit result to the LEDs
ENDLP goto ENDLP ;endless loop
;***************************************************************
; AD CONVERT ROUTINE
;***************************************************************
AD_CONV ;movlw B'10000001' ;configure ADCON0
movwf ADCON0
call TIM20 ;wait for required acquisition time
bsf ADCON0,GO ;start the conversion
WAIT btfsc ADCON0,GO ;wait until the conversion is completed
goto WAIT ;poll the GO bit in ADCON0
movf ADRESH,W ;move the high 8-bit to W
return
;**************************************************************
; TIME DELAY ROUTINE FOR 20us
;
; - delay of 400 cycles
; - 400*0.05us = 20us
;**************************************************************
TIM20 movlw 084H ;1 cycle
movwf TIMCNT ;1 cycle
TIMLP decfsz TIMCNT,F ;(3*132)-1 = 395 cycles
goto TIMLP
nop ;1 cycle
return ;2 cycles
;***************************************
; Real Time
;***************************************
show_RTC
;clear LCD screen
movlw b'00000001'
call WR_INS
;Get year
;movlw "2" ;First line shows 20**/**/**
;call WR_DATA
;movlw "0"
;call WR_DATA
;rtc_read 0x06 ;Read Address 0x06 from DS1307---year
;movfw 0x77
;call WR_DATA
;movfw 0x78
;call WR_DATA
;movlw "/"
;call WR_DATA
;Get month
;rtc_read 0x05 ;Read Address 0x05 from DS1307---month
;movfw 0x77
;call WR_DATA
;movfw 0x78
;call WR_DATA
;movlw "/"
;call WR_DATA
;Get day
;rtc_read 0x04 ;Read Address 0x04 from DS1307---day
;movfw 0x77
;call WR_DATA
;movfw 0x78
;call WR_DATA
;movlw B'11000000' ;Next line displays (hour):(min):(sec) **:**:**
;call WR_INS ;NEXT LINE
;Get hour
;rtc_read 0x02 ;Read Address 0x02 from DS1307---hour
;movfw 0x77
;call WR_DATA
;movfw 0x78
;call WR_DATA
;movlw ":"
;call WR_DATA
;Get minute
Realtime
rtc_read 0x01 ;Read Address 0x01 from DS1307---min
movfw 0x77
call WR_DATA
movfw 0x78
call WR_DATA
movlw ":"
call WR_DATA
;Get seconds
rtc_read 0x00 ;Read Address 0x00 from DS1307---seconds
movfw 0x77
call WR_DATA
movfw 0x78
call WR_DATA
return
call OneS ;Delay for exactly one seconds and read DS1307 again
goto show_RTC
Operationtime
rtc_read 0x01 ;Read Address 0x01 from DS1307---min
movfw 0x77
movwf min
;call WR_DATA
movfw 0x78
movwf min+1
;call WR_DATA
;movlw ":"
;call WR_DATA
;Get seconds
rtc_read 0x00 ;Read Address 0x00 from DS1307---seconds
movfw 0x77
movwf sec
;call WR_DATA
movfw 0x78
movwf sec+1
;call WR_DATA
return
;call OneS ;Delay for exactly one seconds and read DS1307 again
;goto show_RTC
;;***************************************
;; Setup RTC with time defined by user
;;***************************************
set_rtc_time
;rtc_resetAll ;reset rtc
;rtc_set 0x00, B'10000000'
;set time
;rtc_set 0x06, B'00010000' ; Year
;rtc_set 0x05, B'00000100' ; Month
;rtc_set 0x04, B'00000110' ; Date
;rtc_set 0x03, B'00000010' ; Day
;rtc_set 0x02, B'00010010' ; Hours
;rtc_set 0x01, B'00110000' ; Minutes
;rtc_set 0x00, B'00000000' ; Seconds
;return
;***************************************
; Delay 1s
;***************************************
OneS
local OneS_0
movlw 0x10
movwf COUNTH1
movlw 0x7A
movwf COUNTM1
movlw 0x06
movwf COUNTL1
OneS_0
decfsz COUNTH1, f
goto $+2
decfsz COUNTM1, f
goto $+2
decfsz COUNTL1, f
goto OneS_0
goto $+1
nop
nop
return
END
|
source/libgela/gela-embeded_links-caches.adb | faelys/gela-asis | 4 | 11357 | <filename>source/libgela/gela-embeded_links-caches.adb
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package body Gela.Embeded_Links.Caches is
package Search is new Lists.Generic_Search;
use Lists;
use Search;
use FIFO_Lists;
---------
-- Add --
---------
procedure Add
(Container : in out Cache;
Item : in Element_Ptr;
Removed : out Element_Ptr)
is
Index : Hash_Type := Hash (Item.all) mod Container.Size + 1;
Temp : Element_Ptr;
begin
if not Is_Empty (Container.Choices (Index)) then
Temp := Find (Container.Choices (Index), Item.all);
if Temp /= null then
Removed := null;
return;
end if;
Removed := First (Container.FIFO);
Remove (Container, Removed);
else
Removed := null;
end if;
Append (Container.Choices (Index), Item);
Append (Container.FIFO, Item);
end Add;
----------
-- Find --
----------
procedure Find
(Container : in out Cache;
Item : in Element;
Result : out Element_Ptr;
Touch : in Boolean := True)
is
Index : Hash_Type := Hash (Item) mod Container.Size + 1;
begin
Result := Find (Container.Choices (Index), Item);
if Result /= null and Touch then
Delete (Container.FIFO, Result);
Append (Container.FIFO, Result);
end if;
end Find;
--------------------
-- Preferred_Size --
--------------------
function Preferred_Size (Size : Hash_Type) return Hash_Type is
Try : Hash_Type := Size;
Mult : Hash_Type;
begin
loop
Mult := 2;
while Mult * Mult <= Try and Try mod Mult /= 0 loop
Mult := Mult + 1;
end loop;
exit when Mult * Mult > Try;
Try := Try + 1;
end loop;
return Try;
end Preferred_Size;
------------
-- Remove --
------------
procedure Remove
(Container : in out Cache;
Item : in Element_Ptr)
is
Index : Hash_Type := Hash (Item.all) mod Container.Size + 1;
Temp : Element_Ptr := Find (Container.Choices (Index), Item.all);
begin
if Temp /= null then
Delete (Container.Choices (Index), Item);
Delete (Container.FIFO, Item);
end if;
end Remove;
end Gela.Embeded_Links.Caches;
------------------------------------------------------------------------------
-- Copyright (c) 2006, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
programs/oeis/140/A140226.asm | jmorken/loda | 1 | 21367 | <reponame>jmorken/loda<filename>programs/oeis/140/A140226.asm
; A140226: Binomial transform of [1, 3, 3, 1, 1, -1, 1, -1, 1, ...].
; 1,4,10,20,36,60,94,140,200,276,370,484,620,780,966,1180,1424,1700,2010,2356,2740,3164,3630,4140,4696,5300,5954,6660,7420,8236,9110,10044,11040,12100,13226,14420
mov $1,1
lpb $0
add $2,$0
sub $0,1
add $3,4
mov $1,$3
add $3,$2
lpe
|
basic-assembly-programs/JUMP-AND-LOOP.asm | ralphcajipe/assembly-8086 | 0 | 163455 | <gh_stars>0
.model small
org 100h
.data
.code
main proc
mov ah, 9h
mov dx, numbers ;variable
mov cx, 4 ;loop 4 times
TestLoop:
int 21h
loop TestLoop
quit:
mov ah, 0x4c
mov al, 0x00
int 21h
numbers: db '12345678910', 13, 10, '$' ;display with new line
endp
end main |
src/data/lib/prim/Agda/Builtin/IO.agda | pthariensflame/agda | 0 | 8665 | <filename>src/data/lib/prim/Agda/Builtin/IO.agda
{-# OPTIONS --without-K #-}
module Agda.Builtin.IO where
postulate IO : ∀ {a} → Set a → Set a
{-# BUILTIN IO IO #-}
{-# HASKELL type AgdaIO a b = IO b #-}
{-# COMPILED_TYPE IO MAlonzo.Code.Agda.Builtin.IO.AgdaIO #-}
|
alloy4fun_models/trashltl/models/18/hSDqCfRrhGdbswfrd.als | Kaixi26/org.alloytools.alloy | 0 | 3379 | open main
pred idhSDqCfRrhGdbswfrd_prop19 {
always all f:Protected | f in Protected until eventually f in Trash
}
pred __repair { idhSDqCfRrhGdbswfrd_prop19 }
check __repair { idhSDqCfRrhGdbswfrd_prop19 <=> prop19o } |
Chapter11/mz.asm | nickthiru/Ghidra-Software-Reverse-Engineering-for-Beginners | 66 | 178486 | <reponame>nickthiru/Ghidra-Software-Reverse-Engineering-for-Beginners<gh_stars>10-100
format MZ
mov ah, 9h
mov dx, hello
int 21h
mov ax, 4c00h
int 21h
hello db 'Hello, world!', 13, 10, '$'
|
lib/gray86.asm | dex4er/deb-z88dk | 1 | 88630 |
; Graylib interrupt installer
; Ported for the Z88DK and modified for the TI86 by <NAME> - May 2000
;
; original code (graydraw.asm) by:
;
;------------------------------------------------------------
; Date: Sun, 5 May 1996 12:44:17 -0400 (EDT)
; From: <NAME> [<EMAIL>]
; Subject: LZ: Graydraw source!
;------------------------------------------------------------
;
; $Id: gray86.asm,v 1.3 2002/04/10 20:31:10 dom Exp $
;
XDEF graybit1
XDEF graybit2
XDEF page2
ld hl,$f500 ; ld hl,($d297) ;get end of VAT
;dec hl
;dec hl ; make sure we're clear it..
ld a,h ; now we need to get the position of
sub 5 ; the nearest screen boundary
ld h,a
ld l,0
ld (graybit2),hl ; Save the address of our 2nd Screen
ld a,h ; save the byte to send to port 0
and @00111111 ; to switch to our 2nd screen
ld (page2),a
dec h ; Set the IV for IM2 mode
ld a,h
ld i,a
ld (hl),IntProcStart&$FF ; Set the IV table
inc hl
ld (hl),IntProcStart/256
ld d,h
ld e,l
dec hl
inc de
ld bc,255
ldir
xor a ; Init counter
ld (intcount),a
jp jump_over
.IntProcStart
push af
in a,(3)
bit 1,a ; check that it is a vbl interrupt
jr z,EndInt
ld a,(intcount)
cp 2
jr z,Disp_2
.Disp_1
inc a
ld (intcount),a
ld a,(page2)
out (0),a
jr EndInt
.Disp_2
ld a,$3c
out (0),a
xor a
ld (intcount),a
.EndInt
;in a,(3) ;this stuff must be done or calc crashes
;rra ;mysterious stuff from the ROM
;ld a,0
;adc a,9
;out (3),a
;ld a,$0B
;out (3),a
pop af
ei
reti
;jp $38
.IntProcEnd
.graybit1 defw $fc00 ;GRAPH_MEM
.graybit2 defw 0
.page2 defb 0
.intcount defb 0
.jump_over
|
src/asf-contexts-exceptions.adb | Letractively/ada-asf | 0 | 26187 | <gh_stars>0
-----------------------------------------------------------------------
-- asf-contexts-exceptions -- Exception handlers in faces context
-- Copyright (C) 2011 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with ASF.Contexts.Faces;
with ASF.Applications.Messages.Factory;
package body ASF.Contexts.Exceptions is
-- ------------------------------
-- Take action to handle the <b>Exception_Event</b> instances that have been queued by
-- calls to <b>Application.Publish_Event</b>.
--
-- This operation is called after each ASF phase by the life cycle manager.
-- ------------------------------
procedure Handle (Handler : in out Exception_Handler) is
pragma Unreferenced (Handler);
use ASF.Applications;
use type ASF.Contexts.Faces.Faces_Context_Access;
function Get_Message (Event : in Events.Exceptions.Exception_Event'Class;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return ASF.Applications.Messages.Message;
procedure Process (Event : in Events.Exceptions.Exception_Event'Class;
Remove : out Boolean;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- ------------------------------
-- Get a localized message for the exception
-- ------------------------------
function Get_Message (Event : in Events.Exceptions.Exception_Event'Class;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return ASF.Applications.Messages.Message is
Name : constant String := Event.Get_Exception_Name;
Msg : constant String := Event.Get_Exception_Message;
begin
if Msg'Length = 0 then
return Messages.Factory.Get_Message (Context => Context,
Message_Id => EXCEPTION_MESSAGE_BASIC_ID,
Param1 => Name);
else
return Messages.Factory.Get_Message (Context => Context,
Message_Id => EXCEPTION_MESSAGE_EXTENDED_ID,
Param1 => Name,
Param2 => Msg);
end if;
end Get_Message;
-- ------------------------------
-- Process each exception event and add a message in the faces context.
-- ------------------------------
procedure Process (Event : in Events.Exceptions.Exception_Event'Class;
Remove : out Boolean;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Msg : constant Messages.Message := Get_Message (Event, Context);
begin
Context.Add_Message (Client_Id => "",
Message => Msg);
Remove := True;
end Process;
Context : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current;
begin
if Context = null then
return;
end if;
if Context.Get_Response_Completed then
return;
end if;
Context.Iterate_Exception (Process'Access);
end Handle;
-- ------------------------------
-- Queue an exception event to the exception handler. The exception event will be
-- processed at the end of the current ASF phase.
-- ------------------------------
procedure Queue_Exception (Queue : in out Exception_Queue;
Ex : in Ada.Exceptions.Exception_Occurrence) is
begin
Queue.Unhandled_Events.Append (ASF.Events.Exceptions.Create_Exception_Event (Ex));
end Queue_Exception;
-- ------------------------------
-- Clear the exception queue.
-- ------------------------------
overriding
procedure Finalize (Queue : in out Exception_Queue) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => ASF.Events.Exceptions.Exception_Event'Class,
Name => ASF.Events.Exceptions.Exception_Event_Access);
Len : Natural;
begin
loop
Len := Natural (Queue.Unhandled_Events.Length);
exit when Len = 0;
declare
Event : ASF.Events.Exceptions.Exception_Event_Access
:= Queue.Unhandled_Events.Element (Len);
begin
Free (Event);
Queue.Unhandled_Events.Delete (Len);
end;
end loop;
end Finalize;
end ASF.Contexts.Exceptions;
|
dino/lcs/123p/70.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 168438 | copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D94 move.l D1, (A1)+
004D96 dbra D0, $4d94
006886 move.w A0, ($70,A6) [123p+ 90]
00688A move.b #$12, ($c8,A6) [123p+ 70]
0068C8 move.w A6, ($70,A0) [123p+ 10]
0068CC move.b #$12, ($c8,A0) [123p+ 70]
006922 movea.w ($70,A6), A0
006926 tst.b ($0,A0) [123p+ 70]
0108B6 move.w A3, ($70,A2)
0108BA move.b ($72,A3), ($73,A2) [123p+ 70]
010952 move.w A3, ($70,A2)
010956 bra $1095e [123p+ 70]
012528 movea.w ($70,A6), A3
01252C move.w A6, ($68,A3) [123p+ 70]
01420C movea.w ($70,A0), A1
014210 tst.b ($0,A1) [123p+ 70]
019474 clr.w ($70,A6) [123p+ B2]
019478 move.b #$10, ($c8,A6) [123p+ 70]
0195B2 move.w ($70,A6), D0
0195B6 beq $19614 [123p+ 70]
01A36E movea.w ($70,A6), A0
01A372 tst.b ($2c,A0) [123p+ 70]
01D34E movea.w ($70,A6), A0
01D352 tst.b ($2c,A0) [123p+ 70]
01D4B8 movea.w ($70,A6), A0
01D4BC tst.b ($0,A0) [123p+ 70]
01D69C movea.w ($70,A6), A0 [123p+ 4, 123p+ 6]
01D6A0 cmpi.b #$e, ($2e,A0) [123p+ 70]
01D6FA movea.w ($70,A6), A0
01D6FE move.b ($72,A0), ($73,A6) [123p+ 70]
01D8D0 tst.w ($70,A6)
01D8D4 beq $1d93c [123p+ 70]
01D938 clr.w ($70,A6) [enemy+ C]
01D93C rts [123p+ 70]
048EA6 move.w A6, ($70,A0)
048EAA move.l #$2060000, ($4,A0) [123p+ 70]
04EF88 move.w A6, ($70,A0)
04EF8C move.l #$2060000, ($4,A0) [123p+ 70]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
software/hal/hpl/STM32/drivers/stm32-rng-interrupts.adb | TUM-EI-RCS/StratoX | 12 | 9459 | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_rng.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief RNG HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with Ada.Interrupts.Names;
package body STM32.RNG.Interrupts is
type Buffer_Content is array (Integer range <>) of Unsigned_32;
type Ring_Buffer is record
Content : Buffer_Content (0 .. 9);
Head : Integer := 0;
Tail : Integer := 0;
end record;
--------------
-- Receiver --
--------------
protected Receiver is
pragma Interrupt_Priority;
entry Get_Random_32 (Value : out Unsigned_32);
private
Last : Unsigned_32 := 0;
Buffer : Ring_Buffer;
Data_Available : Boolean := False;
procedure Interrupt_Handler;
pragma Attach_Handler
(Interrupt_Handler,
Ada.Interrupts.Names.HASH_RNG_Interrupt);
end Receiver;
--------------
-- Receiver --
--------------
protected body Receiver is
-------------------
-- Get_Random_32 --
-------------------
entry Get_Random_32 (Value : out Unsigned_32) when Data_Available is
Next : constant Integer :=
(Buffer.Tail + 1) mod Buffer.Content'Length;
begin
-- Remove an item from our ring buffer.
Value := Buffer.Content (Next);
Buffer.Tail := Next;
-- If the buffer is empty, make sure we block subsequent callers
-- until the buffer has something in it.
if Buffer.Tail = Buffer.Head then
Data_Available := False;
end if;
Enable_RNG;
end Get_Random_32;
-----------------------
-- Interrupt_Handler --
-----------------------
procedure Interrupt_Handler is
Current : Unsigned_32;
begin
if RNG_Seed_Error_Status then
Clear_RNG_Seed_Error_Status;
-- Clear then set the RNGEN bit to reinitialize and restart
-- the RNG.
Reset_RNG;
end if;
if RNG_Clock_Error_Status then
-- TODO: reconfigure the clock and make sure it's okay
-- Clear the bit.
Clear_RNG_Clock_Error_Status;
end if;
if RNG_Data_Ready then
Current := RNG_Data;
if Current /= Last then
-- This number is good.
if (Buffer.Head + 1) mod Buffer.Content'Length = Buffer.Tail
then
-- But our buffer is full. Turn off the RNG.
Disable_RNG;
else
-- Add this new data to our buffer.
Buffer.Head := (Buffer.Head + 1) mod Buffer.Content'Length;
Buffer.Content (Buffer.Head) := Current;
Data_Available := True;
Last := Current;
end if;
end if;
end if;
end Interrupt_Handler;
end Receiver;
--------------------
-- Initialize_RNG --
--------------------
procedure Initialize_RNG is
Discard : Unsigned_32;
begin
Enable_RNG_Clock;
Enable_RNG_Interrupt;
Enable_RNG;
-- Discard the first randomly generated number, according to STM32F4
-- docs.
Receiver.Get_Random_32 (Discard);
end Initialize_RNG;
------------
-- Random --
------------
function Random return Unsigned_32 is
Result : Unsigned_32;
begin
Receiver.Get_Random_32 (Result);
return Result;
end Random;
end STM32.RNG.Interrupts;
|
src/vulkan-math/vulkan-math-integers.adb | zrmyers/VulkanAda | 1 | 18776 | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 <NAME>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces;
use Interfaces;
package body Vulkan.Math.Integers is
-- 32-bit LSB mask.
LSB32_MASK : constant := 16#00000000FFFFFFFF#;
-- A 64-bit unsigned integer type.
type Vkm_Uint64 is new Interfaces.Unsigned_64;
-- A 64-bit signed integer type.
type Vkm_Int64 is new Interfaces.Integer_64;
-- A representation of a 32-bit integer as an array of 32 booleans.
type Vkm_Bits32 is array (0 .. 31) of Boolean;
for Vkm_Bits32'Component_Size use 1;
for Vkm_Bits32'Size use 32;
----------------------------------------------------------------------------
-- Local Operations
----------------------------------------------------------------------------
-- Unchecked conversion from a 64-bit signed integer to a 64-bit unsigned
-- integer.
function To_Vkm_Uint64 is new
Ada.Unchecked_Conversion(
Source => Vkm_Int64,
Target => Vkm_Uint64);
function To_Vkm_Bits32 is new
Ada.Unchecked_Conversion(
Source => Vkm_Uint,
Target => Vkm_Bits32);
function To_Vkm_Bits32 is new
Ada.Unchecked_Conversion(
Source => Vkm_Int,
Target => Vkm_Bits32);
function To_Vkm_Uint is new
Ada.Unchecked_Conversion(
Source => Vkm_Bits32,
Target => Vkm_Uint);
function To_Vkm_Int is new
Ada.Unchecked_Conversion(
Source => Vkm_Bits32,
Target => Vkm_Int);
----------------------------------------------------------------------------
-- Operations
----------------------------------------------------------------------------
function Unsigned_Add_Carry(x, y : in Vkm_Uint;
carry : out Vkm_Uint) return Vkm_Uint is
begin
if (Vkm_Uint64(x) + Vkm_Uint64(y)) > Vkm_Uint64(Vkm_Uint'Last) then
carry := 1;
else
carry := 0;
end if;
return x + y;
end Unsigned_Add_Carry;
----------------------------------------------------------------------------
function Unsigned_Sub_Borrow(x, y : in Vkm_Uint;
borrow : out Vkm_Uint) return Vkm_Uint is
begin
borrow := (if x >= y then 0 else 1);
return x - y;
end Unsigned_Sub_Borrow;
----------------------------------------------------------------------------
procedure Unsigned_Mul_Extended(x, y : in Vkm_Uint;
msb, lsb : out Vkm_Uint) is
result : constant Vkm_Uint64 := Vkm_Uint64(x) * Vkm_Uint64(y);
begin
lsb := Vkm_Uint(LSB32_MASK and result);
msb := Vkm_Uint(LSB32_MASK and Shift_Right(result, 32));
end Unsigned_Mul_Extended;
----------------------------------------------------------------------------
procedure Signed_Mul_Extended(x, y : in Vkm_Int;
msb, lsb : out Vkm_Int) is
result : constant Vkm_Int64 := Vkm_Int64(x) * Vkm_Int64(y);
begin
lsb := To_Vkm_Int(Vkm_Uint(LSB32_MASK and To_Vkm_Uint64(result)));
msb := To_Vkm_Int(Vkm_Uint(LSB32_MASK and Shift_Right(To_Vkm_Uint64(result), 32)));
end Signed_Mul_Extended;
----------------------------------------------------------------------------
function Bitfield_Extract(value, offset, bits : in Vkm_Int) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result_bits : Vkm_Bits32 := (others => value_bits(Integer(offset + bits -1)));
begin
for bit_index in 0 .. bits - 1 loop
result_bits(Integer(bit_index)) := value_bits(Integer(offset + bit_index));
end loop;
return To_Vkm_Int(result_bits);
end Bitfield_Extract;
----------------------------------------------------------------------------
function Bitfield_Extract(value : in Vkm_Uint;
offset, bits : in Vkm_Int) return Vkm_Uint is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result_bits : Vkm_Bits32 := (others => False);
begin
for bit_index in 0 .. bits - 1 loop
result_bits(Integer(bit_index)) := value_bits(Integer(offset + bit_index));
end loop;
return To_Vkm_Uint(result_bits);
end Bitfield_Extract;
----------------------------------------------------------------------------
function Bitfield_Insert(base, insert, offset, bits : in Vkm_Int) return Vkm_Int is
base_bits : Vkm_Bits32 := To_Vkm_Bits32(base);
insert_bits : constant Vkm_Bits32 := To_Vkm_Bits32(insert);
begin
for bit_index in 0 .. bits - 1 loop
base_bits(Integer(offset + bit_index)) := insert_bits(Integer(bit_index));
end loop;
return To_Vkm_Int(base_bits);
end Bitfield_Insert;
----------------------------------------------------------------------------
function Bitfield_Insert(base, insert : in Vkm_Uint;
offset, bits : in Vkm_Int) return Vkm_Uint is
base_bits : Vkm_Bits32 := To_Vkm_Bits32(base);
insert_bits : constant Vkm_Bits32 := To_Vkm_Bits32(insert);
begin
for bit_index in 0 .. bits - 1 loop
base_bits(Integer(offset + bit_index)) := insert_bits(Integer(bit_index));
end loop;
return To_Vkm_Uint(base_bits);
end Bitfield_Insert;
----------------------------------------------------------------------------
function Bitfield_Reverse(value : in Vkm_Int) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result_bits : Vkm_Bits32 := (others => False);
begin
for bit_index in 0 .. 31 loop
result_bits(bit_index) := value_bits(31 - bit_index);
end loop;
return To_Vkm_Int(result_bits);
end Bitfield_Reverse;
----------------------------------------------------------------------------
function Bitfield_Reverse(value : in Vkm_Uint) return Vkm_Uint is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result_bits : Vkm_Bits32 := (others => False);
begin
for bit_index in 0 .. 31 loop
result_bits(bit_index) := value_bits(31 - bit_index);
end loop;
return To_Vkm_Uint(result_bits);
end Bitfield_Reverse;
----------------------------------------------------------------------------
function Bit_Count(value : in Vkm_Int) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := 0;
begin
for bit_index in 0 .. 31 loop
result := result + (if value_bits(bit_index) then 1 else 0);
end loop;
return result;
end Bit_Count;
----------------------------------------------------------------------------
function Bit_Count(value : in Vkm_Uint) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := 0;
begin
for bit_index in 0 .. 31 loop
result := result + (if value_bits(bit_index) then 1 else 0);
end loop;
return result;
end Bit_Count;
----------------------------------------------------------------------------
function Find_Lsb(value : in Vkm_Int) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := -1;
begin
for bit_index in 0 .. 31 loop
if value_bits(bit_index) then
result := Vkm_Int(bit_index);
end if;
exit when result /= -1;
end loop;
return result;
end Find_Lsb;
----------------------------------------------------------------------------
function Find_Lsb(value : in Vkm_Uint) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := -1;
begin
for bit_index in 0 .. 31 loop
if value_bits(bit_index) then
result := Vkm_Int(bit_index);
end if;
exit when result /= -1;
end loop;
return result;
end Find_Lsb;
----------------------------------------------------------------------------
function Find_Msb(value : in Vkm_Int) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := -1;
begin
for bit_index in reverse 0 .. 31 loop
if not value_bits(bit_index) then
result := Vkm_Int(bit_index);
end if;
exit when result /= -1;
end loop;
return result;
end Find_Msb;
----------------------------------------------------------------------------
function Find_Msb(value : in Vkm_Uint) return Vkm_Int is
value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value);
result : Vkm_Int := -1;
begin
for bit_index in reverse 0 .. 31 loop
if value_bits(bit_index) then
result := Vkm_Int(bit_index);
end if;
exit when result /= -1;
end loop;
return result;
end Find_Msb;
end Vulkan.Math.Integers;
|
libsrc/_DEVELOPMENT/math/float/math32/lm32/z80/asm_mul10uf.asm | Frodevan/z88dk | 640 | 178406 | <reponame>Frodevan/z88dk
; float _mul10uf (float number) __z88dk_fastcall
SECTION code_clib
SECTION code_fp_math32
PUBLIC asm_mul10uf
EXTERN m32_mul10u_fastcall
; Multiply a float by 10, and make positive
;
; enter : stack = ret
; DEHL = sccz80_float number
;
; exit : DEHL = 10 * |sccz80_float|
;
; uses : de, hl
defc asm_mul10uf = m32_mul10u_fastcall
|
programs/oeis/307/A307939.asm | karttu/loda | 1 | 89465 | <reponame>karttu/loda
; A307939: Number of (undirected) Hamiltonian paths in the n-dipyramidal graph.
; 36,120,310,660,1218,2032,3150,4620,6490,8808,11622,14980,18930,23520,28798,34812,41610,49240,57750,67188,77602,89040,101550,115180,129978,145992,163270,181860,201810,223168,245982,270300,296170,323640,352758,383572,416130,450480,486670,524748,564762,606760,650790,696900,745138,795552,848190,903100,960330,1019928,1081942,1146420,1213410,1282960,1355118,1429932,1507450,1587720,1670790,1756708,1845522,1937280,2032030,2129820,2230698,2334712,2441910,2552340,2666050,2783088,2903502,3027340,3154650,3285480,3419878,3557892,3699570,3844960,3994110,4147068,4303882,4464600,4629270,4797940,4970658,5147472,5328430,5513580,5702970,5896648,6094662,6297060,6503890,6715200,6931038,7151452,7376490,7606200,7840630,8079828,8323842,8572720,8826510,9085260,9349018,9617832,9891750,10170820,10455090,10744608,11039422,11339580,11645130,11956120,12272598,12594612,12922210,13255440,13594350,13938988,14289402,14645640,15007750,15375780,15749778,16129792,16515870,16908060,17306410,17710968,18121782,18538900,18962370,19392240,19828558,20271372,20720730,21176680,21639270,22108548,22584562,23067360,23556990,24053500,24556938,25067352,25584790,26109300,26640930,27179728,27725742,28279020,28839610,29407560,29982918,30565732,31156050,31753920,32359390,32972508,33593322,34221880,34858230,35502420,36154498,36814512,37482510,38158540,38842650,39534888,40235302,40943940,41660850,42386080,43119678,43861692,44612170,45371160,46138710,46914868,47699682,48493200,49295470,50106540,50926458,51755272,52593030,53439780,54295570,55160448,56034462,56917660,57810090,58711800,59622838,60543252,61473090,62412400,63361230,64319628,65287642,66265320,67252710,68249860,69256818,70273632,71300350,72337020,73383690,74440408,75507222,76584180,77671330,78768720,79876398,80994412,82122810,83261640,84410950,85570788,86741202,87922240,89113950,90316380,91529578,92753592,93988470,95234260,96491010,97758768,99037582,100327500,101628570,102940840,104264358,105599172,106945330,108302880,109671870,111052348,112444362,113847960,115263190,116690100,118128738,119579152,121041390,122515500,124001530,125499528
pow $1,$0
gcd $1,7
add $1,35
mov $2,$0
mul $2,38
add $1,$2
mov $3,$0
mul $3,$0
mov $2,$3
mul $2,32
add $1,$2
mul $3,$0
mov $2,$3
mul $2,8
add $1,$2
|
Transynther/x86/_processed/AVXALIGN/_zr_/i3-7100_9_0xca_notsx.log_21829_1339.asm | ljhsiun2/medusa | 9 | 9252 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r15
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x2ab5, %rsi
sub $36332, %rax
vmovups (%rsi), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %rdi
nop
nop
dec %r15
lea addresses_D_ht+0x1df5d, %rsi
lea addresses_WT_ht+0x1cfb3, %rdi
clflush (%rsi)
nop
nop
nop
nop
cmp %r11, %r11
mov $54, %rcx
rep movsq
sub $50804, %r11
lea addresses_WC_ht+0x1de2d, %r11
nop
nop
nop
nop
cmp $8454, %rsi
mov (%r11), %rcx
nop
and $47347, %rdi
lea addresses_WT_ht+0xde1d, %r15
clflush (%r15)
nop
nop
nop
nop
nop
sub %rsi, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm2
vmovups %ymm2, (%r15)
nop
nop
nop
nop
and $22162, %rsi
lea addresses_WC_ht+0x1be2b, %rsi
lea addresses_normal_ht+0x1677d, %rdi
nop
xor %r14, %r14
mov $88, %rcx
rep movsq
nop
mfence
lea addresses_D_ht+0xca3d, %rsi
lea addresses_UC_ht+0x2d5d, %rdi
nop
nop
nop
nop
cmp %r10, %r10
mov $116, %rcx
rep movsb
nop
add $31543, %rcx
lea addresses_D_ht+0xbd7d, %rax
nop
nop
nop
sub %r10, %r10
movw $0x6162, (%rax)
sub $49944, %rax
lea addresses_UC_ht+0x12ebd, %r15
nop
nop
nop
nop
dec %r14
mov $0x6162636465666768, %rcx
movq %rcx, %xmm3
vmovups %ymm3, (%r15)
nop
xor $20689, %r14
lea addresses_normal_ht+0x1be5d, %rcx
nop
nop
nop
nop
nop
add %rdi, %rdi
and $0xffffffffffffffc0, %rcx
vmovntdqa (%rcx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %r10
xor $65482, %r14
lea addresses_normal_ht+0x1555d, %rax
nop
nop
add %r10, %r10
mov $0x6162636465666768, %r14
movq %r14, %xmm4
vmovups %ymm4, (%rax)
nop
nop
nop
dec %r10
lea addresses_normal_ht+0xc83d, %rdi
nop
nop
nop
add $33936, %r11
movb (%rdi), %r14b
nop
nop
nop
inc %rcx
lea addresses_UC_ht+0x1355d, %rsi
lea addresses_A_ht+0x15d5d, %rdi
nop
nop
nop
nop
nop
xor $956, %r10
mov $83, %rcx
rep movsb
nop
nop
inc %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r9
push %rax
push %rcx
push %rdi
push %rdx
// Store
lea addresses_PSE+0xbd1d, %rdi
nop
nop
nop
nop
sub $49378, %rax
movb $0x51, (%rdi)
nop
inc %r9
// Store
lea addresses_WC+0xa95d, %rcx
clflush (%rcx)
nop
add $48963, %r10
mov $0x5152535455565758, %rdi
movq %rdi, %xmm1
vmovups %ymm1, (%rcx)
nop
nop
nop
nop
and $19633, %rdx
// Faulty Load
lea addresses_UC+0x1c55d, %rdx
nop
cmp %r10, %r10
movaps (%rdx), %xmm6
vpextrq $0, %xmm6, %rcx
lea oracles, %r10
and $0xff, %rcx
shlq $12, %rcx
mov (%r10,%rcx,1), %rcx
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_PSE', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC', 'size': 32, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}}
{'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 4, 'NT': True, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 5, 'NT': True, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
oeis/122/A122012.asm | neoneye/loda-programs | 11 | 240416 | <filename>oeis/122/A122012.asm
; A122012: G.f.: x^2*(3+3*x-2*x^2)/ ( (x^2-x-1) * (x^2+x-1)).
; Submitted by <NAME>(s1)
; 0,3,3,7,9,18,24,47,63,123,165,322,432,843,1131,2207,2961,5778,7752,15127,20295,39603,53133,103682,139104,271443,364179,710647,953433,1860498,2496120,4870847,6534927,12752043,17108661,33385282,44791056
mov $1,$0
mod $1,2
mov $3,3
lpb $0
sub $0,1
add $3,$2
mov $2,$1
mov $1,$3
lpe
mov $0,$1
|
programs/oeis/084/A084903.asm | jmorken/loda | 1 | 3869 | <gh_stars>1-10
; A084903: Binomial transform of positive cubes.
; 1,9,44,170,576,1792,5248,14688,39680,104192,267264,672256,1662976,4055040,9764864,23257088,54853632,128253952,297533440,685375488,1568669696,3569352704,8078229504,18192793600,40785412096,91049951232
mov $1,$0
add $1,2
mov $2,$0
mov $4,$0
add $4,2
mov $5,-2
lpb $0
sub $0,1
mul $1,2
add $2,$4
add $2,3
add $5,1
lpe
mov $3,6
add $3,$5
add $3,$2
mul $3,2
mul $1,$3
sub $1,16
div $1,16
add $1,1
|
Driver/Net/NW/nwUtils.asm | steakknife/pcgeos | 504 | 8161 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: nwUtils.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 11/14/92 Initial version.
DESCRIPTION:
$Id: nwUtils.asm,v 1.1 97/04/18 11:48:44 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NetWareCommonCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyMemCmp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS: ds:si = first pointer
es:di = second pointer
cx = length to compare
RETURN: ax = difference of chars, 0 if equal
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CL 10/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyMemCmp proc near
uses ds,es,si,di,cx
.enter
clr ax
jcxz exit
repe cmpsb
mov al, es:[di][-1]
sub al, ds:[si][-1]
cbw
exit:
.leave
ret
MyMemCmp endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyStrCmp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: compares 2 strings
CALLED BY: GLOBAL
PASS: es:di - string 1
ds:si - string 2
RETURN: ax - 0 if match, else difference in chars
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ISR 3/11/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyStrCmp proc far
uses cx,ds,es,si,di
.enter
push di
mov cx, -1
clr ax ;
repne scasb ;
not cx ;CX <- # chars in str 1 (w/null)
pop di
repe cmpsb
jz exit ;If match, exit (with ax=0)
mov al, es:[di][-1] ;Else, return difference of chars
sub al, ds:[si][-1] ;
cbw ;
exit:
.leave
ret
MyStrCmp endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NetWareFreeRRBuffers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Free the mem block at ES. The handle is at ES:0
CALLED BY: INTERNAL
PASS: es - segment to free
RETURN: nothing
DESTROYED: es, flags preserved
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 10/15/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NetWareFreeRRBuffers proc far
uses bx
.enter
pushf
mov bx, es:[NRR_handle]
call MemFree
popf
.leave
ret
NetWareFreeRRBuffers endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NetWareCopyNTString
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: copy a null-terminated string, including the NULL
CALLED BY: INTERNAL
PASS: ds:si - source
es:di - dest
RETURN: cx - number of bytes, including NULL
ds:si, es:di - point AFTER null
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 10/16/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NetWareCopyNTString proc near
uses ax
.enter
clr cx
startLoop:
lodsb
stosb
inc cx
tst al
jnz startLoop
.leave
ret
NetWareCopyNTString endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NetWareCopyStringButNotNull
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Copy a string, but don't copy the NULL terminator
CALLED BY: INTERNAL
PASS: ds:si - source
es:di - dest
RETURN: cx - # of bytes copied
ds:si - points at NULL
es:di - points after last char copied
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 10/16/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NetWareCopyStringButNotNull proc near
uses ax
.enter
clr cx
copyLoop:
lodsb
tst al
jz endCopy
inc cx
stosb
jmp copyLoop
endCopy:
.leave
ret
NetWareCopyStringButNotNull endp
NetWareCommonCode ends
|
oeis/158/A158493.asm | neoneye/loda-programs | 11 | 93299 | <gh_stars>10-100
; A158493: a(n) = 20*n^2 + 1.
; 1,21,81,181,321,501,721,981,1281,1621,2001,2421,2881,3381,3921,4501,5121,5781,6481,7221,8001,8821,9681,10581,11521,12501,13521,14581,15681,16821,18001,19221,20481,21781,23121,24501,25921,27381,28881,30421,32001,33621,35281,36981,38721,40501,42321,44181,46081,48021,50001,52021,54081,56181,58321,60501,62721,64981,67281,69621,72001,74421,76881,79381,81921,84501,87121,89781,92481,95221,98001,100821,103681,106581,109521,112501,115521,118581,121681,124821,128001,131221,134481,137781,141121,144501
pow $0,2
mul $0,20
add $0,1
|
src11.als | NVlabs/ptxmemorymodel | 27 | 825 | <filename>src11.als
module src11[hwEvent,hwAddress,hwScope]
open util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Programs and candidate executions
sig Address {
addrmap: one hwAddress
}
fun loc : Event->Event { address.~address }
sig Scope {
subscope: set Scope,
scopemap: one hwScope
}
fun System : Scope { Scope - Scope.subscope }
fact { one System }
sig Thread extends Scope { start: one Event }
fact scope_inclusion { scope in *~sb.~start.*~subscope }
fact { subscope.~subscope in iden }
fact { no Thread.subscope }
fact { acyclic[subscope] }
fact { no A.scope & Thread }
//fact { A.scope in System }
fact { NA.scope in Thread }
fact threads_unique { start.~start in iden }
fact events_in_threads { all e: Event | one e.*~sb.~start }
abstract sig MemoryOrder {}
one sig MemoryOrderNonAtomic extends MemoryOrder {}
one sig MemoryOrderRelaxed extends MemoryOrder {}
one sig MemoryOrderAcquire extends MemoryOrder {}
one sig MemoryOrderRelease extends MemoryOrder {}
one sig MemoryOrderAcqRel extends MemoryOrder {}
one sig MemoryOrderSeqCst extends MemoryOrder {}
fun NA : set Event { MemoryOrderNonAtomic.ord }
fun RLX : set Event { MemoryOrderRelaxed.ord }
fun ACQ : set Event { MemoryOrderAcquire.ord }
fun REL : set Event { MemoryOrderRelease.ord }
fun AR : set Event { MemoryOrderAcqRel.ord }
fun SC : set Event { MemoryOrderSeqCst.ord }
fun A : Event { RLX + ACQ + REL + AR + SC }
fact WriteMO {
all w: Write | w.memory_order in
MemoryOrderNonAtomic + MemoryOrderRelaxed + MemoryOrderRelease
}
fact ReadMO {
all r: Read | r.memory_order in
MemoryOrderNonAtomic + MemoryOrderRelaxed + MemoryOrderAcquire
}
fact RMWMO {
rmw in memory_order.(
MemoryOrderRelaxed->MemoryOrderRelaxed +
MemoryOrderAcquire->MemoryOrderRelaxed +
MemoryOrderRelaxed->MemoryOrderRelease +
MemoryOrderAcquire->MemoryOrderRelease +
MemoryOrderSeqCst->MemoryOrderSeqCst
).~memory_order
}
fact FenceMO {
all f: Fence | f.memory_order in
MemoryOrderAcquire + MemoryOrderRelease + MemoryOrderAcqRel + MemoryOrderSeqCst
}
abstract sig Event {
map: one hwEvent,
sb: set Event,
memory_order: one MemoryOrder,
scope: one Scope
}
fun ord : MemoryOrder->Event { ~memory_order }
abstract sig MemoryEvent extends Event {
address : one Address
}
sig Write extends MemoryEvent {
rf: set Read,
mo: set Write
}
sig Read extends MemoryEvent {
rmw: lone Write
}
sig Fence extends Event {}
// com
fun rb : Read->Write {
~rf.mo
+
((Read - Write.rf) <: address.~address :> Write) // for read-from-init reads
}
fact com_loc { rf + mo + rb in loc }
// sb
fact strict_partial_sb { strict_partial[sb] }
// reads
fact one_source_write { rf.~rf in iden }
// writes
fact strict_partial_mo { strict_partial[mo] }
fact mo_total_per_address { all a: Address | total[mo, a.~address :> Write] }
// rmw
fact rmw_sbimm {
rmw in imm[sb] & loc
sb.~rmw in sb
}
/*
fun psc : Event->Event {
(ident[SC] + (ident[Fence & SC].hb))
.(sb + eco + ((sb - loc).hb.(sb - loc)))
.(ident[SC] + (hb.(ident[Fence & SC])))
}
*/
fun sbnl : Event->Event { sb - (sb & loc) }
fun scb : Event->Event { sb + sbnl + (hb.sbnl.hb) + mo + rb }
fun pscbase : Event->Event {
(ident[SC] + (ident[Fence & SC].(optional[hb])))
.scb
.(ident[SC] + (optional[hb].(ident[Fence & SC])))
}
fun pscF : Event->Event {
ident[Fence & SC].(hb + (hb.eco.hb)).(ident[Fence & SC])
}
fun psc : Event->Event {
pscbase + pscF
}
////////////////////////////////////////////////////////////////////////////////
// Outcome
fun conflict : Event->Event {
address.~address - iden - Read->Read
}
fun strong_r : Event->Event {
symmetric[scope.*subscope.start.*sb]
}
fun strong[r: Event->Event]: Event->Event {
r & strong_r
}
fun race : Event->Event { conflict - hb - ~hb }
pred racy { some race - strong_r }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Scoped RC11 model
fun rs : Event->Event {
(ident[Write])
.(optional[sb & loc])
.(ident[Write & A])
.*(strong[rf].rmw) // <--
}
fun sw : Event->Event {
(ident[REL+AR+SC])
.(optional[ident[Fence].sb])
.rs.(strong[rf]) // <--
.(ident[Read & A])
.(optional[sb.(ident[Fence])])
.(ident[ACQ+AR+SC])
}
fun hb : Event->Event { ^(sb + strong[sw]) }
fun com : Event->Event { rf + mo + rb }
fun eco : Event->Event { ^com }
assert ecos_equal { eco = (rf + mo + rb).(optional[rf]) }
check ecos_equal for 6
pred coherence { irreflexive[hb.(optional[eco])] }
pred atomicity { no rmw & rb.mo }
pred sc { acyclic[strong[psc]] }
pred no_thin_air { acyclic[sb + rf] }
pred src11 {
coherence
atomicity
sc
no_thin_air
}
|
Task/Guess-the-number-With-feedback/AppleScript/guess-the-number-with-feedback.applescript | LaudateCorpus1/RosettaCodeData | 1 | 1081 | <filename>Task/Guess-the-number-With-feedback/AppleScript/guess-the-number-with-feedback.applescript
-- defining the range of the number to be guessed
property minLimit : 1
property maxLimit : 100
on run
-- define the number to be guessed
set numberToGuess to (random number from minLimit to maxLimit)
-- prepare a variable to store the user's answer
set guessedNumber to missing value
-- prepare a variable for feedback
set tip to ""
-- start a loop (will be exited by using "exit repeat" after a correct guess)
repeat
-- ask the user for his/her guess, the variable tip contains text after first guess only
set usersChoice to (text returned of (display dialog "Guess the number between " & minLimit & " and " & maxLimit & " inclusive" & return & tip default answer "" buttons {"Check"} default button "Check"))
-- try to convert the given answer to an integer and compare it the number to be guessed
try
set guessedNumber to usersChoice as integer
if guessedNumber is greater than maxLimit or guessedNumber is less than minLimit then
-- the user guessed a number outside the given range
set tip to "(Tipp: Enter a number between " & minLimit & " and " & maxLimit & ")"
else if guessedNumber is less than numberToGuess then
-- the user guessed a number less than the correct number
set tip to "(Tipp: The number is greater than " & guessedNumber & ")"
else if guessedNumber is greater than numberToGuess then
-- the user guessed a number greater than the correct number
set tip to "(Tipp: The number is less than " & guessedNumber & ")"
else if guessedNumber is equal to numberToGuess then
-- the user guessed the correct number and gets informed
display dialog "Well guessed! The number was " & numberToGuess buttons {"OK"} default button "OK"
-- exit the loop (quits this application)
exit repeat
end if
on error
-- something went wrong, remind the user to enter a numeric value
set tip to "(Tipp: Enter a number between " & minLimit & " and " & maxLimit & ")"
end try
end repeat
end run
|
programs/oeis/189/A189887.asm | jmorken/loda | 1 | 88174 | ; A189887: Dimension of homogeneous component of degree n in x in the Malcev-Poisson superalgebra S^tilde(M).
; 1,1,2,3,4,6,9,11,12,14,17,19,20,22,25,27,28,30,33,35,36,38,41,43,44,46,49,51,52,54,57,59,60,62,65,67,68,70,73,75,76,78,81,83,84,86,89,91,92,94,97,99,100,102,105,107,108,110,113,115,116,118,121,123,124,126,129,131,132,134,137,139,140,142,145,147,148,150,153,155
sub $0,1
mov $1,$0
sub $1,1
lpb $0
trn $0,3
add $1,1
add $2,3
trn $2,$0
trn $0,1
add $1,3
lpe
trn $1,$2
add $1,1
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_1333.asm | ljhsiun2/medusa | 9 | 243048 | <filename>Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_1333.asm
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r15
push %r8
push %rcx
// Faulty Load
lea addresses_UC+0xdb54, %r13
clflush (%r13)
nop
nop
nop
nop
nop
and $37037, %r8
movb (%r13), %cl
lea oracles, %r13
and $0xff, %rcx
shlq $12, %rcx
mov (%r13,%rcx,1), %rcx
pop %rcx
pop %r8
pop %r15
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
arch/ARM/NXP/svd/lpc55s6x/nxp_svd-flash_cmpa.ads | morbos/Ada_Drivers_Library | 2 | 5858 | <reponame>morbos/Ada_Drivers_Library
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.FLASH_CMPA is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Default ISP mode:
type BOOT_CFG_DEFAULT_ISP_MODE_Field is
(
-- Auto ISP
Value_0,
-- USB_HID_MSC
Value_1,
-- SPI Slave ISP
Value_2,
-- I2C Slave ISP
Value_3,
-- Disable ISP fall through
Value_7)
with Size => 3;
for BOOT_CFG_DEFAULT_ISP_MODE_Field use
(Value_0 => 0,
Value_1 => 1,
Value_2 => 2,
Value_3 => 3,
Value_7 => 7);
-- Core clock:
type BOOT_CFG_BOOT_SPEED_Field is
(
-- Defined by NMPA.SYSTEM_SPEED_CODE
Value_0,
-- 48MHz FRO
Value_1,
-- 96MHz FRO
Value_2)
with Size => 2;
for BOOT_CFG_BOOT_SPEED_Field use
(Value_0 => 0,
Value_1 => 1,
Value_2 => 2);
subtype BOOT_CFG_BOOT_FAILURE_PIN_Field is HAL.UInt8;
-- .
type BOOT_CFG_Register is record
-- unspecified
Reserved_0_3 : HAL.UInt4 := 16#0#;
-- Default ISP mode:
DEFAULT_ISP_MODE : BOOT_CFG_DEFAULT_ISP_MODE_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- Core clock:
BOOT_SPEED : BOOT_CFG_BOOT_SPEED_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- unspecified
Reserved_9_23 : HAL.UInt15 := 16#0#;
-- GPIO port and pin number to use for indicating failure reason. The
-- toggle rate of the pin is used to decode the error type. [2:0] -
-- Defines GPIO port [7:3] - Defines GPIO pin
BOOT_FAILURE_PIN : BOOT_CFG_BOOT_FAILURE_PIN_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BOOT_CFG_Register use record
Reserved_0_3 at 0 range 0 .. 3;
DEFAULT_ISP_MODE at 0 range 4 .. 6;
BOOT_SPEED at 0 range 7 .. 8;
Reserved_9_23 at 0 range 9 .. 23;
BOOT_FAILURE_PIN at 0 range 24 .. 31;
end record;
subtype SPI_FLASH_CFG_SPI_RECOVERY_BOOT_EN_Field is HAL.UInt5;
-- .
type SPI_FLASH_CFG_Register is record
-- SPI flash recovery boot is enabled, if non-zero value is written to
-- this field.
SPI_RECOVERY_BOOT_EN : SPI_FLASH_CFG_SPI_RECOVERY_BOOT_EN_Field :=
16#0#;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SPI_FLASH_CFG_Register use record
SPI_RECOVERY_BOOT_EN at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype USB_ID_USB_VENDOR_ID_Field is HAL.UInt16;
subtype USB_ID_USB_PRODUCT_ID_Field is HAL.UInt16;
-- .
type USB_ID_Register is record
-- .
USB_VENDOR_ID : USB_ID_USB_VENDOR_ID_Field := 16#0#;
-- .
USB_PRODUCT_ID : USB_ID_USB_PRODUCT_ID_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for USB_ID_Register use record
USB_VENDOR_ID at 0 range 0 .. 15;
USB_PRODUCT_ID at 0 range 16 .. 31;
end record;
-- Non Secure non-invasive debug enable
type CC_SOCU_PIN_NIDEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_NIDEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- Non Secure debug enable
type CC_SOCU_PIN_DBGEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_DBGEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- Secure non-invasive debug enable
type CC_SOCU_PIN_SPNIDEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_SPNIDEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- Secure invasive debug enable
type CC_SOCU_PIN_SPIDEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_SPIDEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- JTAG TAP enable
type CC_SOCU_PIN_TAPEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_TAPEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- CPU1 (Micro cortex M33) invasive debug enable
type CC_SOCU_PIN_CPU1_DBGEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_CPU1_DBGEN_Field use
(Value_0 => 0,
Value_1 => 1);
-- ISP Boot Command enable
type CC_SOCU_PIN_ISP_CMD_EN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_ISP_CMD_EN_Field use
(Value_0 => 0,
Value_1 => 1);
-- FA Command enable
type CC_SOCU_PIN_FA_CMD_EN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_FA_CMD_EN_Field use
(Value_0 => 0,
Value_1 => 1);
-- Flash Mass Erase Command enable
type CC_SOCU_PIN_ME_CMD_EN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_ME_CMD_EN_Field use
(Value_0 => 0,
Value_1 => 1);
-- CPU1 (Micro cortex M33) non-invasive debug enable
type CC_SOCU_PIN_CPU1_NIDEN_Field is
(
-- Use DAP to enable
Value_0,
-- Fixed state
Value_1)
with Size => 1;
for CC_SOCU_PIN_CPU1_NIDEN_Field use
(Value_0 => 0,
Value_1 => 1);
subtype CC_SOCU_PIN_INVERSE_VALUE_Field is HAL.UInt16;
-- .
type CC_SOCU_PIN_Register is record
-- Non Secure non-invasive debug enable
NIDEN : CC_SOCU_PIN_NIDEN_Field := NXP_SVD.FLASH_CMPA.Value_0;
-- Non Secure debug enable
DBGEN : CC_SOCU_PIN_DBGEN_Field := NXP_SVD.FLASH_CMPA.Value_0;
-- Secure non-invasive debug enable
SPNIDEN : CC_SOCU_PIN_SPNIDEN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- Secure invasive debug enable
SPIDEN : CC_SOCU_PIN_SPIDEN_Field := NXP_SVD.FLASH_CMPA.Value_0;
-- JTAG TAP enable
TAPEN : CC_SOCU_PIN_TAPEN_Field := NXP_SVD.FLASH_CMPA.Value_0;
-- CPU1 (Micro cortex M33) invasive debug enable
CPU1_DBGEN : CC_SOCU_PIN_CPU1_DBGEN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- ISP Boot Command enable
ISP_CMD_EN : CC_SOCU_PIN_ISP_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- FA Command enable
FA_CMD_EN : CC_SOCU_PIN_FA_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- Flash Mass Erase Command enable
ME_CMD_EN : CC_SOCU_PIN_ME_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- CPU1 (Micro cortex M33) non-invasive debug enable
CPU1_NIDEN : CC_SOCU_PIN_CPU1_NIDEN_Field :=
NXP_SVD.FLASH_CMPA.Value_0;
-- unspecified
Reserved_10_14 : HAL.UInt5 := 16#0#;
-- Enforce UUID match during Debug authentication.
UUID_CHECK : Boolean := False;
-- inverse value of bits [15:0]
INVERSE_VALUE : CC_SOCU_PIN_INVERSE_VALUE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CC_SOCU_PIN_Register use record
NIDEN at 0 range 0 .. 0;
DBGEN at 0 range 1 .. 1;
SPNIDEN at 0 range 2 .. 2;
SPIDEN at 0 range 3 .. 3;
TAPEN at 0 range 4 .. 4;
CPU1_DBGEN at 0 range 5 .. 5;
ISP_CMD_EN at 0 range 6 .. 6;
FA_CMD_EN at 0 range 7 .. 7;
ME_CMD_EN at 0 range 8 .. 8;
CPU1_NIDEN at 0 range 9 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
UUID_CHECK at 0 range 15 .. 15;
INVERSE_VALUE at 0 range 16 .. 31;
end record;
-- Non Secure non-invasive debug fixed state
type CC_SOCU_DFLT_NIDEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_NIDEN_Field use
(Disable => 0,
Enable => 1);
-- Non Secure debug fixed state
type CC_SOCU_DFLT_DBGEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_DBGEN_Field use
(Disable => 0,
Enable => 1);
-- Secure non-invasive debug fixed state
type CC_SOCU_DFLT_SPNIDEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_SPNIDEN_Field use
(Disable => 0,
Enable => 1);
-- Secure invasive debug fixed state
type CC_SOCU_DFLT_SPIDEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_SPIDEN_Field use
(Disable => 0,
Enable => 1);
-- JTAG TAP fixed state
type CC_SOCU_DFLT_TAPEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_TAPEN_Field use
(Disable => 0,
Enable => 1);
-- CPU1 (Micro cortex M33) invasive debug fixed state
type CC_SOCU_DFLT_CPU1_DBGEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_CPU1_DBGEN_Field use
(Disable => 0,
Enable => 1);
-- ISP Boot Command fixed state
type CC_SOCU_DFLT_ISP_CMD_EN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_ISP_CMD_EN_Field use
(Disable => 0,
Enable => 1);
-- FA Command fixed state
type CC_SOCU_DFLT_FA_CMD_EN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_FA_CMD_EN_Field use
(Disable => 0,
Enable => 1);
-- Flash Mass Erase Command fixed state
type CC_SOCU_DFLT_ME_CMD_EN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_ME_CMD_EN_Field use
(Disable => 0,
Enable => 1);
-- CPU1 (Micro cortex M33) non-invasive debug fixed state
type CC_SOCU_DFLT_CPU1_NIDEN_Field is
(
-- Disable
Disable,
-- Enable
Enable)
with Size => 1;
for CC_SOCU_DFLT_CPU1_NIDEN_Field use
(Disable => 0,
Enable => 1);
subtype CC_SOCU_DFLT_INVERSE_VALUE_Field is HAL.UInt16;
-- .
type CC_SOCU_DFLT_Register is record
-- Non Secure non-invasive debug fixed state
NIDEN : CC_SOCU_DFLT_NIDEN_Field := NXP_SVD.FLASH_CMPA.Disable;
-- Non Secure debug fixed state
DBGEN : CC_SOCU_DFLT_DBGEN_Field := NXP_SVD.FLASH_CMPA.Disable;
-- Secure non-invasive debug fixed state
SPNIDEN : CC_SOCU_DFLT_SPNIDEN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- Secure invasive debug fixed state
SPIDEN : CC_SOCU_DFLT_SPIDEN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- JTAG TAP fixed state
TAPEN : CC_SOCU_DFLT_TAPEN_Field := NXP_SVD.FLASH_CMPA.Disable;
-- CPU1 (Micro cortex M33) invasive debug fixed state
CPU1_DBGEN : CC_SOCU_DFLT_CPU1_DBGEN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- ISP Boot Command fixed state
ISP_CMD_EN : CC_SOCU_DFLT_ISP_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- FA Command fixed state
FA_CMD_EN : CC_SOCU_DFLT_FA_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- Flash Mass Erase Command fixed state
ME_CMD_EN : CC_SOCU_DFLT_ME_CMD_EN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- CPU1 (Micro cortex M33) non-invasive debug fixed state
CPU1_NIDEN : CC_SOCU_DFLT_CPU1_NIDEN_Field :=
NXP_SVD.FLASH_CMPA.Disable;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- inverse value of bits [15:0]
INVERSE_VALUE : CC_SOCU_DFLT_INVERSE_VALUE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CC_SOCU_DFLT_Register use record
NIDEN at 0 range 0 .. 0;
DBGEN at 0 range 1 .. 1;
SPNIDEN at 0 range 2 .. 2;
SPIDEN at 0 range 3 .. 3;
TAPEN at 0 range 4 .. 4;
CPU1_DBGEN at 0 range 5 .. 5;
ISP_CMD_EN at 0 range 6 .. 6;
FA_CMD_EN at 0 range 7 .. 7;
ME_CMD_EN at 0 range 8 .. 8;
CPU1_NIDEN at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
INVERSE_VALUE at 0 range 16 .. 31;
end record;
subtype VENDOR_USAGE_VENDOR_USAGE_Field is HAL.UInt16;
-- .
type VENDOR_USAGE_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Upper 16 bits of vendor usage field defined in DAP. Lower 16-bits
-- come from customer field area.
VENDOR_USAGE : VENDOR_USAGE_VENDOR_USAGE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for VENDOR_USAGE_Register use record
Reserved_0_15 at 0 range 0 .. 15;
VENDOR_USAGE at 0 range 16 .. 31;
end record;
subtype SECURE_BOOT_CFG_RSA4K_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_DICE_ENC_NXP_CFG_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_DICE_CUST_CFG_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_SKIP_DICE_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_TZM_IMAGE_TYPE_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_BLOCK_SET_KEY_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_BLOCK_ENROLL_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_DICE_INC_SEC_EPOCH_Field is HAL.UInt2;
subtype SECURE_BOOT_CFG_SEC_BOOT_EN_Field is HAL.UInt2;
-- .
type SECURE_BOOT_CFG_Register is record
-- Use RSA4096 keys only. 00- RSA2048 keys 01, 10, 11 - RSA4096 keys
RSA4K : SECURE_BOOT_CFG_RSA4K_Field := 16#0#;
-- Include NXP area in DICE computation. 00 - not included 01, 10, 11 -
-- included
DICE_ENC_NXP_CFG : SECURE_BOOT_CFG_DICE_ENC_NXP_CFG_Field := 16#0#;
-- Include Customer factory area (including keys) in DICE computation.
-- 00 - not included 01, 10, 11 - included
DICE_CUST_CFG : SECURE_BOOT_CFG_DICE_CUST_CFG_Field := 16#0#;
-- Skip DICE computation. 00 - Enable DICE 01,10,11 - Disable DICE
SKIP_DICE : SECURE_BOOT_CFG_SKIP_DICE_Field := 16#0#;
-- TrustZone-M mode. 00 - TZM mode in image header. 01 - Disable TZ-M.
-- Boots to NonSecure. 10 - TZ-M enable boots to secure mode. 11 -
-- Preset TZM checker from image header.
TZM_IMAGE_TYPE : SECURE_BOOT_CFG_TZM_IMAGE_TYPE_Field := 16#0#;
-- Block PUF key code generation. 00 - Enable Key code generation 01,
-- 10, 11 - Disable key code generation
BLOCK_SET_KEY : SECURE_BOOT_CFG_BLOCK_SET_KEY_Field := 16#0#;
-- Block PUF enrollement. 00 - Enable enrollment mode 01, 10, 11 -
-- Disable further enrollmnet
BLOCK_ENROLL : SECURE_BOOT_CFG_BLOCK_ENROLL_Field := 16#0#;
-- Include security EPOCH in DICE
DICE_INC_SEC_EPOCH : SECURE_BOOT_CFG_DICE_INC_SEC_EPOCH_Field := 16#0#;
-- unspecified
Reserved_16_29 : HAL.UInt14 := 16#0#;
-- Secure boot enable. 00 - Plain image (internal flash with or without
-- CRC) 01, 10, 11 - Boot signed images. (internal flash, RSA signed)
SEC_BOOT_EN : SECURE_BOOT_CFG_SEC_BOOT_EN_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SECURE_BOOT_CFG_Register use record
RSA4K at 0 range 0 .. 1;
DICE_ENC_NXP_CFG at 0 range 2 .. 3;
DICE_CUST_CFG at 0 range 4 .. 5;
SKIP_DICE at 0 range 6 .. 7;
TZM_IMAGE_TYPE at 0 range 8 .. 9;
BLOCK_SET_KEY at 0 range 10 .. 11;
BLOCK_ENROLL at 0 range 12 .. 13;
DICE_INC_SEC_EPOCH at 0 range 14 .. 15;
Reserved_16_29 at 0 range 16 .. 29;
SEC_BOOT_EN at 0 range 30 .. 31;
end record;
subtype PRINCE_BASE_ADDR_ADDR0_PRG_Field is HAL.UInt4;
subtype PRINCE_BASE_ADDR_ADDR1_PRG_Field is HAL.UInt4;
subtype PRINCE_BASE_ADDR_ADDR2_PRG_Field is HAL.UInt4;
-- PRINCE_BASE_ADDR_LOCK_REG array element
subtype PRINCE_BASE_ADDR_LOCK_REG_Element is HAL.UInt2;
-- PRINCE_BASE_ADDR_LOCK_REG array
type PRINCE_BASE_ADDR_LOCK_REG_Field_Array is array (0 .. 2)
of PRINCE_BASE_ADDR_LOCK_REG_Element
with Component_Size => 2, Size => 6;
-- Type definition for PRINCE_BASE_ADDR_LOCK_REG
type PRINCE_BASE_ADDR_LOCK_REG_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LOCK_REG as a value
Val : HAL.UInt6;
when True =>
-- LOCK_REG as an array
Arr : PRINCE_BASE_ADDR_LOCK_REG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for PRINCE_BASE_ADDR_LOCK_REG_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
subtype PRINCE_BASE_ADDR_REG0_ERASE_CHECK_EN_Field is HAL.UInt2;
subtype PRINCE_BASE_ADDR_REG1_ERASE_CHECK_EN_Field is HAL.UInt2;
subtype PRINCE_BASE_ADDR_REG2_ERASE_CHECK_EN_Field is HAL.UInt2;
-- .
type PRINCE_BASE_ADDR_Register is record
-- Programmable portion of the base address of region 0.
ADDR0_PRG : PRINCE_BASE_ADDR_ADDR0_PRG_Field := 16#0#;
-- Programmable portion of the base address of region 1.
ADDR1_PRG : PRINCE_BASE_ADDR_ADDR1_PRG_Field := 16#0#;
-- Programmable portion of the base address of region 2.
ADDR2_PRG : PRINCE_BASE_ADDR_ADDR2_PRG_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Lock PRINCE region0 settings. 00 - Region is not locked. 01, 10, 11 -
-- Region is locked.
LOCK_REG : PRINCE_BASE_ADDR_LOCK_REG_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- For PRINCE region0 enable checking whether all encrypted pages are
-- erased together. 00 - Check is disabled. 01, 10, 11 - Check is
-- enabled.
REG0_ERASE_CHECK_EN : PRINCE_BASE_ADDR_REG0_ERASE_CHECK_EN_Field :=
16#0#;
-- For PRINCE region1 enable checking whether all encrypted pages are
-- erased together. 00 - Check is disabled. 01, 10, 11 - Check is
-- enabled.
REG1_ERASE_CHECK_EN : PRINCE_BASE_ADDR_REG1_ERASE_CHECK_EN_Field :=
16#0#;
-- For PRINCE region2 enable checking whether all encrypted pages are
-- erased together. 00 - Check is disabled. 01, 10, 11 - Check is
-- enabled.
REG2_ERASE_CHECK_EN : PRINCE_BASE_ADDR_REG2_ERASE_CHECK_EN_Field :=
16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PRINCE_BASE_ADDR_Register use record
ADDR0_PRG at 0 range 0 .. 3;
ADDR1_PRG at 0 range 4 .. 7;
ADDR2_PRG at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
LOCK_REG at 0 range 16 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
REG0_ERASE_CHECK_EN at 0 range 24 .. 25;
REG1_ERASE_CHECK_EN at 0 range 26 .. 27;
REG2_ERASE_CHECK_EN at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype XTAL_32KHZ_CAPABANK_TRIM_XTAL_LOAD_CAP_IEC_PF_X100_Field is
HAL.UInt10;
subtype XTAL_32KHZ_CAPABANK_TRIM_PCB_XIN_PARA_CAP_PF_X100_Field is
HAL.UInt10;
subtype XTAL_32KHZ_CAPABANK_TRIM_PCB_XOUT_PARA_CAP_PF_X100_Field is
HAL.UInt10;
-- Xtal 32kHz capabank triming.
type XTAL_32KHZ_CAPABANK_TRIM_Register is record
-- 0 : Capa Bank trimmings not valid. Default trimmings value are used.
-- 1 : Capa Bank trimmings valid.
TRIM_VALID : Boolean := False;
-- Load capacitance, pF x 100. For example, 6pF becomes 600.
XTAL_LOAD_CAP_IEC_PF_X100 : XTAL_32KHZ_CAPABANK_TRIM_XTAL_LOAD_CAP_IEC_PF_X100_Field :=
16#0#;
-- PCB XIN parasitic capacitance, pF x 100. For example, 6pF becomes
-- 600.
PCB_XIN_PARA_CAP_PF_X100 : XTAL_32KHZ_CAPABANK_TRIM_PCB_XIN_PARA_CAP_PF_X100_Field :=
16#0#;
-- PCB XOUT parasitic capacitance, pF x 100. For example, 6pF becomes
-- 600.
PCB_XOUT_PARA_CAP_PF_X100 : XTAL_32KHZ_CAPABANK_TRIM_PCB_XOUT_PARA_CAP_PF_X100_Field :=
16#0#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for XTAL_32KHZ_CAPABANK_TRIM_Register use record
TRIM_VALID at 0 range 0 .. 0;
XTAL_LOAD_CAP_IEC_PF_X100 at 0 range 1 .. 10;
PCB_XIN_PARA_CAP_PF_X100 at 0 range 11 .. 20;
PCB_XOUT_PARA_CAP_PF_X100 at 0 range 21 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype XTAL_16MHZ_CAPABANK_TRIM_XTAL_LOAD_CAP_IEC_PF_X100_Field is
HAL.UInt10;
subtype XTAL_16MHZ_CAPABANK_TRIM_PCB_XIN_PARA_CAP_PF_X100_Field is
HAL.UInt10;
subtype XTAL_16MHZ_CAPABANK_TRIM_PCB_XOUT_PARA_CAP_PF_X100_Field is
HAL.UInt10;
-- Xtal 16MHz capabank triming.
type XTAL_16MHZ_CAPABANK_TRIM_Register is record
-- 0 : Capa Bank trimmings not valid. Default trimmings value are used.
-- 1 : Capa Bank trimmings valid.
TRIM_VALID : Boolean := False;
-- Load capacitance, pF x 100. For example, 6pF becomes 600.
XTAL_LOAD_CAP_IEC_PF_X100 : XTAL_16MHZ_CAPABANK_TRIM_XTAL_LOAD_CAP_IEC_PF_X100_Field :=
16#0#;
-- PCB XIN parasitic capacitance, pF x 100. For example, 6pF becomes
-- 600.
PCB_XIN_PARA_CAP_PF_X100 : XTAL_16MHZ_CAPABANK_TRIM_PCB_XIN_PARA_CAP_PF_X100_Field :=
16#0#;
-- PCB XOUT parasitic capacitance, pF x 100. For example, 6pF becomes
-- 600.
PCB_XOUT_PARA_CAP_PF_X100 : XTAL_16MHZ_CAPABANK_TRIM_PCB_XOUT_PARA_CAP_PF_X100_Field :=
16#0#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for XTAL_16MHZ_CAPABANK_TRIM_Register use record
TRIM_VALID at 0 range 0 .. 0;
XTAL_LOAD_CAP_IEC_PF_X100 at 0 range 1 .. 10;
PCB_XIN_PARA_CAP_PF_X100 at 0 range 11 .. 20;
PCB_XOUT_PARA_CAP_PF_X100 at 0 range 21 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- ROTKH0 for Root of Trust Keys Table hash[255:224] ROTKH1 for Root of Trust Keys Table hash[223:192] ROTKH2 for Root of Trust Keys Table hash[191:160] ROTKH3 for Root of Trust Keys Table hash[159:128] ROTKH4 for Root of Trust Keys Table hash[127:96] ROTKH5 for Root of Trust Keys Table hash[95:64] ROTKH6 for Root of Trust Keys Table hash[63:32] ROTKH7 for Root of Trust Keys Table hash[31:0]
-- ROTKH0 for Root of Trust Keys Table hash[255:224] ROTKH1 for Root of
-- Trust Keys Table hash[223:192] ROTKH2 for Root of Trust Keys Table
-- hash[191:160] ROTKH3 for Root of Trust Keys Table hash[159:128] ROTKH4
-- for Root of Trust Keys Table hash[127:96] ROTKH5 for Root of Trust Keys
-- Table hash[95:64] ROTKH6 for Root of Trust Keys Table hash[63:32] ROTKH7
-- for Root of Trust Keys Table hash[31:0]
type ROTKH_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Customer Defined (Programable through ROM API)
-- Customer Defined (Programable through ROM API)
type CUSTOMER_DEFINED_Registers is array (0 .. 55) of HAL.UInt32
with Volatile;
-- SHA256_DIGEST0 for DIGEST[31:0] SHA256_DIGEST1 for DIGEST[63:32] SHA256_DIGEST2 for DIGEST[95:64] SHA256_DIGEST3 for DIGEST[127:96] SHA256_DIGEST4 for DIGEST[159:128] SHA256_DIGEST5 for DIGEST[191:160] SHA256_DIGEST6 for DIGEST[223:192] SHA256_DIGEST7 for DIGEST[255:224]
-- SHA256_DIGEST0 for DIGEST[31:0] SHA256_DIGEST1 for DIGEST[63:32]
-- SHA256_DIGEST2 for DIGEST[95:64] SHA256_DIGEST3 for DIGEST[127:96]
-- SHA256_DIGEST4 for DIGEST[159:128] SHA256_DIGEST5 for DIGEST[191:160]
-- SHA256_DIGEST6 for DIGEST[223:192] SHA256_DIGEST7 for DIGEST[255:224]
type SHA256_DIGEST_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-----------------
-- Peripherals --
-----------------
-- FLASH_CMPA
type FLASH_CMPA_Peripheral is record
-- .
BOOT_CFG : aliased BOOT_CFG_Register;
-- .
SPI_FLASH_CFG : aliased SPI_FLASH_CFG_Register;
-- .
USB_ID : aliased USB_ID_Register;
-- .
SDIO_CFG : aliased HAL.UInt32;
-- .
CC_SOCU_PIN : aliased CC_SOCU_PIN_Register;
-- .
CC_SOCU_DFLT : aliased CC_SOCU_DFLT_Register;
-- .
VENDOR_USAGE : aliased VENDOR_USAGE_Register;
-- .
SECURE_BOOT_CFG : aliased SECURE_BOOT_CFG_Register;
-- .
PRINCE_BASE_ADDR : aliased PRINCE_BASE_ADDR_Register;
-- Region 0, sub-region enable
PRINCE_SR_0 : aliased HAL.UInt32;
-- Region 1, sub-region enable
PRINCE_SR_1 : aliased HAL.UInt32;
-- Region 2, sub-region enable
PRINCE_SR_2 : aliased HAL.UInt32;
-- Xtal 32kHz capabank triming.
XTAL_32KHZ_CAPABANK_TRIM : aliased XTAL_32KHZ_CAPABANK_TRIM_Register;
-- Xtal 16MHz capabank triming.
XTAL_16MHZ_CAPABANK_TRIM : aliased XTAL_16MHZ_CAPABANK_TRIM_Register;
-- ROTKH0 for Root of Trust Keys Table hash[255:224] ROTKH1 for Root of
-- Trust Keys Table hash[223:192] ROTKH2 for Root of Trust Keys Table
-- hash[191:160] ROTKH3 for Root of Trust Keys Table hash[159:128]
-- ROTKH4 for Root of Trust Keys Table hash[127:96] ROTKH5 for Root of
-- Trust Keys Table hash[95:64] ROTKH6 for Root of Trust Keys Table
-- hash[63:32] ROTKH7 for Root of Trust Keys Table hash[31:0]
ROTKH : aliased ROTKH_Registers;
-- Customer Defined (Programable through ROM API)
CUSTOMER_DEFINED : aliased CUSTOMER_DEFINED_Registers;
-- SHA256_DIGEST0 for DIGEST[31:0] SHA256_DIGEST1 for DIGEST[63:32]
-- SHA256_DIGEST2 for DIGEST[95:64] SHA256_DIGEST3 for DIGEST[127:96]
-- SHA256_DIGEST4 for DIGEST[159:128] SHA256_DIGEST5 for DIGEST[191:160]
-- SHA256_DIGEST6 for DIGEST[223:192] SHA256_DIGEST7 for DIGEST[255:224]
SHA256_DIGEST : aliased SHA256_DIGEST_Registers;
end record
with Volatile;
for FLASH_CMPA_Peripheral use record
BOOT_CFG at 16#0# range 0 .. 31;
SPI_FLASH_CFG at 16#4# range 0 .. 31;
USB_ID at 16#8# range 0 .. 31;
SDIO_CFG at 16#C# range 0 .. 31;
CC_SOCU_PIN at 16#10# range 0 .. 31;
CC_SOCU_DFLT at 16#14# range 0 .. 31;
VENDOR_USAGE at 16#18# range 0 .. 31;
SECURE_BOOT_CFG at 16#1C# range 0 .. 31;
PRINCE_BASE_ADDR at 16#20# range 0 .. 31;
PRINCE_SR_0 at 16#24# range 0 .. 31;
PRINCE_SR_1 at 16#28# range 0 .. 31;
PRINCE_SR_2 at 16#2C# range 0 .. 31;
XTAL_32KHZ_CAPABANK_TRIM at 16#30# range 0 .. 31;
XTAL_16MHZ_CAPABANK_TRIM at 16#34# range 0 .. 31;
ROTKH at 16#50# range 0 .. 255;
CUSTOMER_DEFINED at 16#100# range 0 .. 1791;
SHA256_DIGEST at 16#1E0# range 0 .. 255;
end record;
-- FLASH_CMPA
FLASH_CMPA_Periph : aliased FLASH_CMPA_Peripheral
with Import, Address => System'To_Address (16#9E400#);
end NXP_SVD.FLASH_CMPA;
|
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xa0_notsx.log_21829_411.asm | ljhsiun2/medusa | 9 | 166523 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x10c50, %rsi
lea addresses_WT_ht+0xa010, %rdi
nop
nop
nop
nop
xor %r10, %r10
mov $123, %rcx
rep movsl
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_D_ht+0x9a50, %r15
nop
nop
nop
nop
nop
dec %r11
mov (%r15), %edi
inc %r10
lea addresses_A_ht+0x3994, %rcx
cmp %r15, %r15
movb $0x61, (%rcx)
nop
nop
nop
add %rax, %rax
lea addresses_WC_ht+0x15d38, %rsi
lea addresses_WT_ht+0x1c310, %rdi
nop
nop
sub $26126, %r15
mov $30, %rcx
rep movsl
nop
nop
inc %rax
lea addresses_A_ht+0x13040, %r15
nop
cmp $28771, %r11
movb $0x61, (%r15)
nop
nop
nop
cmp %rax, %rax
lea addresses_WT_ht+0x12530, %rdi
nop
nop
nop
nop
sub $61503, %r10
mov (%rdi), %r15d
nop
nop
nop
nop
nop
inc %rsi
lea addresses_UC_ht+0x1bd10, %rsi
lea addresses_WT_ht+0x1a884, %rdi
xor $26643, %r9
mov $86, %rcx
rep movsq
nop
nop
nop
nop
and $30378, %rax
lea addresses_WC_ht+0x3910, %r11
and $50553, %rsi
movw $0x6162, (%r11)
and %r15, %r15
lea addresses_A_ht+0x2234, %rsi
lea addresses_WT_ht+0x10310, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
dec %rax
mov $16, %rcx
rep movsl
nop
nop
nop
nop
dec %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %rdi
push %rdx
push %rsi
// Store
lea addresses_D+0x5110, %rsi
xor $26918, %r10
mov $0x5152535455565758, %r11
movq %r11, %xmm5
movntdq %xmm5, (%rsi)
nop
nop
nop
add %r11, %r11
// Load
lea addresses_RW+0x14854, %rdi
nop
nop
nop
nop
nop
xor $22031, %r15
vmovups (%rdi), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r11
nop
nop
inc %rdi
// Store
lea addresses_normal+0x3163, %r11
nop
nop
nop
cmp %r12, %r12
mov $0x5152535455565758, %r15
movq %r15, (%r11)
nop
nop
nop
nop
dec %rdx
// Faulty Load
lea addresses_D+0x5110, %rdx
nop
nop
nop
nop
nop
cmp %rsi, %rsi
mov (%rdx), %r12d
lea oracles, %r11
and $0xff, %r12
shlq $12, %r12
mov (%r11,%r12,1), %r12
pop %rsi
pop %rdx
pop %rdi
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 16, 'NT': True, 'same': True, 'congruent': 0}}
{'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}}
[Faulty Load]
{'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 8}}
{'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
src/loop.asm | bob8213/asm-tests | 0 | 169240 | <gh_stars>0
global _main
extern _printf
section .text
_main:
; Set loop counter
mov ecx, 5
l1:
; pushing ecx because printf messes with it
; probably not optimal but... ¯\_(ツ)_/¯
push ecx
push message
call _printf
add esp, 4
pop ecx
loop l1
ret
message:
db 'boop :)', 10, 0
|
lib/set_caps_to_ctrl.applescript | bjeanes/babushka-deps | 1 | 2281 | tell application "System Preferences"
activate
reveal pane "Keyboard"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Keyboard"
click button "Modifier Keys…" of tab group 1
tell sheet 1
-- if more than one keyboard is plugged in, an extra pop up button is shown
if (name of every pop up button) contains "Select keyboard:" then
set btn to pop up button "Select keyboard:"
tell btn
click
set kbds to (every menu item of menu 1)
key code 53 -- escape (to close pop up)
repeat with kbd in kbds
click btn
click kbd
my set_caps_lock_to_control()
end repeat
end tell
else
my set_caps_lock_to_control()
end if
click button "OK"
end tell
end tell
quit application "System Preferences"
on set_caps_lock_to_control()
tell application "System Events" to tell process "System Preferences" to tell window "Keyboard" to tell sheet 1
tell pop up button "Caps Lock (⇪) Key:"
click
click menu item "⌃ Control" of menu 1
end tell
end tell
end set_caps_lock_to_control
|
FormalAnalyzer/models/meta/cap_presenceSensor.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 1425 | <filename>FormalAnalyzer/models/meta/cap_presenceSensor.als
// filename: cap_presenceSensor.als
module cap_presenceSensor
open IoTBottomUp
one sig cap_presenceSensor extends Capability {}
{
attributes = cap_presenceSensor_attr
}
abstract sig cap_presenceSensor_attr extends Attribute {}
one sig cap_presenceSensor_attr_presence extends cap_presenceSensor_attr {}
{
values = cap_presenceSensor_attr_presence_val
}
abstract sig cap_presenceSensor_attr_presence_val extends AttrValue {}
one sig cap_presenceSensor_attr_presence_val_present extends cap_presenceSensor_attr_presence_val {}
one sig cap_presenceSensor_attr_presence_val_not_present extends cap_presenceSensor_attr_presence_val {}
|
TableTopTennisSimulator2012.asm | Yttrmin/TableTopTennis | 2 | 88138 | ; Table Top Tennis Simulator 2012
processor 6502
include vcs.h
org $F000
;Constants
BGColor = $48
PFColor = $34
P0Color = $C6 ; Green
P1Color = $94 ; Blue
BallColor = $0E ; White
PF0Sprite = %00110000
PaddleOnSprite = %00011000
PaddleOffSprite = %00000000
BallOn = %00000010
BallOff = %00000000
PaddleHeight = 16
BallHeight = 2
MaxPaddleY = 186-PaddleHeight
MinPaddleY = 14
P1Goal = $33; 100% Correct. Looked at wrong var. ; One cycle before playfield goal.
P0Goal = $C2; 100% Correct. Looked at wrong var. ; One cycle before playfield goal.
BallStartX = $7A
BallStartY = 96
BallBaseTone = %00000001
BallXSpeedCap = 2 ; !Exceeding the paddle width can cause tunneling!
BallYSpeedCap = 3
BallYExVelMax = BallYSpeedCap+1
BallYExVelMin = 255-BallYSpeedCap
BallVolleyIncrement = 2
AITickRate = 2
ScoreLimit = 11
StartingWaitTime = 255
EndWaitTime = 80
;Variables
; 2600 has 128 bytes of RAM, so we get $80 to $FF.
YPosP0 = $80
YPosP1 = $81
YPosBall = $82
ScoreP0 = $83
ScoreP1 = $84
P0Sprite = $85 ; Written by the processing kernel, loaded and stored by the draw kernel.
P1Sprite = $86 ; Could probably be done just on the stack, but we got all this RAM!
BallEnabled = $87
YVelBall = $88
XVelBall = $89
XPosBall = $8A
P0Delta = $8B ; Either 1 or -1 to specify whether the player's paddle went up or down this frame.
P1Delta = $8C ; Exists just so we can do multiple things based on moving Up/Down without redoing the BIT test.
VolleyCount = $8D
ScoreP0MemLoc = $8E ; Helper variable to store the offset from Numbers of the byte to draw.
ScoreP1MemLoc = $8F ; Exists because A/X/Y are occupied and saves us from having to ASL(x4), ADC, and TAY every time.
AITicks = $90
VictoryTime = $91
WaitTime = $92
NewXVelBall = $93
Start
SEI ; Disable interrupts.
CLD ; Clear BCD math bit.
LDX #$FF ; Reset stack pointer to FF.
TXS
LDA #0
ClearMem
; Clear all memory from $FF to $00 with 0s.
STA 0,X
DEX
BNE ClearMem
Initialize
LDA #BGColor
STA COLUBK
LDA #PFColor
STA COLUPF
LDA #P0Color
STA COLUP0
LDA #P1Color
STA COLUP1
LDA %00001111
STA AUDV0 ; Crank the volume up.
STA AUDV1
LDA %00000110
STA AUDF1
PositionPaddles ; DO NOT TOUCH
STA WSYNC
; ~22 Machine cycles of horizontal blank.
; First we do P0's paddle.
NOP ; NOPs take 2 cycles.
NOP
NOP
BIT ScoreP0 ; BIT takes 3, literally just a garbage statement to burn 3 cycles.
NOP
NOP
NOP
NOP ; Kill horizontal blank.
NOP
NOP ; 21 Machine cycles here.
STA RESP0 ; STA takes 3, so our paddle's set at the 24th cycle.
NOP ; Now for P1's paddle...
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BIT ScoreP0
STA RESBL ; Unused. Kept just to maintain cycle count.
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
STA RESP1 ; Now for more fine tuned adjustment...
LDA #%01110000
STA HMP1
STA WSYNC
STA HMOVE ; Shift it 7 to the left...
LDA #%00010000
STA HMP1
STA WSYNC
STA HMOVE ; And 1 more to the left and perfect!
STA HMCLR
; This could probably be cleaned up without HMOVE, but never touch it again.
LDA #96
STA YPosP0
STA YPosP1
STA YPosBall
JSR ResetBall ; Setup ball.
LDA #0
STA XVelBall
STA YVelBall
LDA #StartingWaitTime
STA WaitTime ; Give the player some breathing time to start.
STA WSYNC
STA WSYNC
EndInitialize
MainLoop
Synching
LDA #%00000010
STA VSYNC
STA WSYNC ; Need to hold the VSync signal for at least 3 scanlines.
STA WSYNC
STA WSYNC
; 2798 cycles to burn divided by 64 = 43.
; 64 is the number of cycles it takes for the timer to tick down.
; It's best to use a timer here since otherwise you'll have to manually count
; the cycles and WSYNC in the middle of your processing when appropriate.
LDA #43
STA TIM64T
; Zero out VSync since it's over.
LDA #0
STA VSYNC ; Actually start at scanline 0 here.
; There's actually some extra "visible" scanlines on the top and bottom that are unused due to
; vertical blank/overscan, at least on Stella, but I assume that's just to avoid drawing on the
; edges for real TVs, where what's visible can differ from one set to the other.
FinishSynch
BeginInput
LDA #0
STA AUDC0 ; Turn off any ricochet or scoring sound effects.
STA P0Delta ; Reset paddle movement deltas.
STA P1Delta
LDA VictoryTime
BNE EndInput
P0Up
LDA #%00010000
BIT SWCHA
BNE P0Down
INC YPosP0 ; Always increment/decrement paddle positions by 2. Only every other scanline changes the graphics registers,
; so if we only move it by 1 the paddle will seem to shrink/grow as it moves up and down.
INC YPosP0
LDA #1 ; Regardless of the actual change in position though the delta is always set to 1 or -1.
STA P0Delta
P0Down
LDA #%00100000
BIT SWCHA
BNE P1Up
DEC YPosP0
DEC YPosP0
LDA #-1
STA P0Delta
P1Up
LDA #%00000001
BIT SWCHA
BNE P1Down
;INC YPosP1
;INC YPosP1
;LDA #1
;STA P1Delta
P1Down
LDA #%00000010
BIT SWCHA
BNE EndInput
;DEC YPosP1
;DEC YPosP1
;LDA #-1
;STA P1Delta
EndInput
BeginCollision
P0Playfield ; Test for Paddle-on-Playfield collisions so they don't move outside the bounds of the game.
LDA #%10000000 ; CXP0FB (P0->PF)
BIT CXP0FB
BEQ P1Playfield
PHA ; Push return value. Garbage value.
LDA YPosP0
PHA ; Push parameter.
JSR CapToMinMax ; If we're touching the playfield, cap us!
PLA ; Pop parameter off.
PLA ; Pop return value into accumulator.
STA YPosP0 ; Store to actual variable.
P1Playfield ; Repeat for P1.
LDA #%10000000 ; CXP1FB (P1->PF)
BIT CXP1FB
BEQ PlayerBallCheck
PHA
LDA YPosP1
PHA
JSR CapToMinMax
PLA
PLA
STA YPosP1
PlayerBallCheck ; Check if we need to bounce the ball off a paddle.
LDA WaitTime
BEQ SkipWaitCheck
DEC WaitTime
LDA WaitTime
CMP #EndWaitTime
BNE SkipBallPhysics
JMP ClearWait
SkipBallPhysics
JMP EndCollision
ClearWait
LDA #0
STA WaitTime
JSR ResetBall
SkipWaitCheck
LDA P0Delta
PHA ; Push P0's delta onto the stack.
LDA #%01000000 ; CXP0FB (P0->BL)
BIT CXP0FB
BNE PlayerBallConfirmed ; If there's a hit between P0 and the PF, branch with P0's delta still on the stack.
PLA ; Else, pop it off and put P1's delta in its place.
LDA P1Delta
PHA
LDA #%01000000
BIT CXP1FB
BNE PlayerBallConfirmed ; If there's a hit between P1 and the PF, branch with P1's delta on the stack.
PLA ; Else there were no hits, pop it off stack so we don't overflow and JMP to the next collision test.
JMP BallPlayfield
PlayerBallConfirmed ; Only executed if any of the paddles hit the ball.
INC VolleyCount
LDA VolleyCount
CMP #BallVolleyIncrement
BNE BallVelChanges
BallVelChanges
LDA XVelBall
CLC
EOR #$FF
ADC #1
STA XVelBall ; Here's where that stack variable comes into play. The delta of whoever hit the ball is on the stack, although
PLA ; we don't actually know which player it was at this point. It doesn't matter though, we pop the delta off,
CLC ; clear the carry, and add it to the YVelocity. This could either slow or speed up the ball's Y speed.
ADC YVelBall ; This is how applying "spin" to the ball is done. If you move while hitting the ball, all this happens.
CMP #BallYExVelMax
BEQ CapBallToUpper
CMP #BallYExVelMin
BEQ CapBallToLower
CMP #0
JMP BallZeroYCheck
CapBallToUpper
LDA #BallYExVelMax-1
STA YVelBall
JMP PRSound
CapBallToLower
LDA #BallYExVelMin+1
STA YVelBall
JMP PRSound
BallZeroYCheck
BNE PRSound ; We don't want a YVel of 0 (ball going horizontally straight). If it ever happens, just make it 1.
LDA #1 ; Partially because it makes the AI look dumb.
JMP PRSound
PRSound ;PlayRicochetSound.
STA YVelBall
LDA #BallBaseTone
STA AUDC0
; TODO, adjust frequency based on speed?
BallPlayfield ; Ball-on-Playfield tests. Could mean it either hit a wall or hit a goal.
LDA #%10000000
BIT CXBLPF
BEQ EndCollision
; Collision with the playfield, here we go.
; The test is basically: If XPosBall < P0Goal, we're in P0's goal. Else If XPosBall > P1Goal, we're in P0's goal.
; Else we hit a wall.
TestBallP0
LDA XPosBall
CMP #P0Goal
BCC TestBallP1
; We're in P0's Goal!
LDA #1 ; P1 scored.
PHA ; Push it onto the stack as a parameter for OnScore.
JSR OnScore
PLA
JMP EndCollision
TestBallP1 ; Repeat for P1. Could these be combined into 1
CMP #P1Goal
BCS BallRicochet
; We're in P1's Goal!
LDA #-1 ; P0 scored.
PHA
JSR OnScore
PLA
JMP EndCollision
BallRicochet ; Didn't hit a player, guess we hit a wall.
LDA YVelBall
CLC
EOR #$FF ; Just flip the value and play a sound.
ADC #1
STA YVelBall
LDA #BallBaseTone
STA AUDC0
EndCollision
STA CXCLR ; Clear the collision registers.
LDA YPosBall
CLC
ADC YVelBall
STA YPosBall ; Add velocity to position and store it as the new position.
LDA XVelBall ; Set the ball's horizontal speed to XVelBall.
STA HMBL
STA WSYNC ; Always sync before an HMOVE!
STA HMOVE
; Now to calculate the new X position of the ball.
; Need to perform 4 arithmetic shifts right since XVel 1) Only uses the left nibble and 2) could be negative.
; But the 6502 doesn't have that! So first CMP it to %10000000 to copy the sign bit into the carry bit.
; Then rotate right, which replaces the leftmost-bit with the carry bit.
CMP #$80
ROR
CMP #$80
ROR
CMP #$80
ROR
CMP #$80
ROR
ADC XPosBall ; Now add that velocity to the position and we get our new position.
STA XPosBall
LDA #$00
STA COLUBK ; Reset background color.
LDA %00000001 ; Turn off Player coloring and go back to mirroring the playfield.
STA CTRLPF
LDX #0
LDA ScoreP0
; Wow it makes a lot more sense to do this here. Who'd a thunk.
ASL ; Each number graphic is made up of 8 bytes, so multiply our score by 8 to get the memory address of the number we want.
ASL
ASL
STA ScoreP0MemLoc ; And store it so we can just INC it instead of doing all this again.
LDA ScoreP1
ASL
ASL
ASL
STA ScoreP1MemLoc
LDA YPosBall ; Locks the paddles to the ball so they never miss. For testing.
;STA YPosP0
;STA YPosP1
ScoreCheck
LDA VictoryTime
BNE StillWinning
LDA ScoreP0
CMP #ScoreLimit
BEQ P0Won
LDA ScoreP1
CMP #ScoreLimit
BEQ P1Won
JMP AICheck
P0Won
INC ScoreP0
LDA #255
STA VictoryTime
JMP StillWinning
P1Won
INC ScoreP1
LDA #255
STA VictoryTime
JMP StillWinning
StillWinning
JSR OnWin
LDA VictoryTime
BNE WaitForVBlankEnd
LDA #0
STA AUDC1
JMP Start
AICheck
LDA AITicks
CMP #AITickRate
BEQ AIStart
JMP AIEnd
AIStart
LDA #0
STA AITicks
LDA YPosP1
CMP YPosBall
BEQ AIEnd
BCS AIDown
INC YPosP1
INC YPosP1
JMP AIEnd
AIDown
DEC YPosP1
DEC YPosP1
AIEnd
INC AITicks
; Kill whatever time might be left.
WaitForVBlankEnd
LDA INTIM
BNE WaitForVBlankEnd
STA WSYNC ; WSYNC so we don't enable drawing mid-way into the line.
STA VBLANK
LDY #192 ; Note we only actually loop 182 times, but we're counting down from 192.
ScanLoop
; Important: For the 182 lines there are two separate kernels.
; On even numbered scanlines, there's the "processing" kernel.
; This performs all the calculations for determining if the paddles/ball are visible on this line and need to be drawn.
; It writes these values to several global variables.
; On odd numbered scanlines, there's the "draw" kernel.
; It simply loads in those variables and saves them to the graphics registeres. It sounds weird and roundabout, but there's
; far far far too little time to perform both kernels' functions on one scanline.
; The fact that the graphics registers are only updated on odd scanlines has a lot of implications!
STA WSYNC
ProcessingLine
TYA
SEC ; Have to set carry because SBC uses the not of the carry.
; Meaning you otherwise get things like $60 - $60 = $FF
; This causes a weird bug where paddles can shift the other around by 1 line.
SBC YPosP0
BMI DisableP0 ; Basically: if (CurrentScanline - YPosP0) < 0 : Turn off paddle
CMP #PaddleHeight ; else if (CurrentScanline - YPosP0) >= PaddleHeight : Turn off paddle.
BCS DisableP0 ; else : Enable paddle.
LDA #PaddleOnSprite
STA P0Sprite
JMP P1Check
DisableP0
LDA #PaddleOffSprite
STA P0Sprite
P1Check ; Repeat for P1...
TYA
SEC
SBC YPosP1
BMI DisableP1
CMP #PaddleHeight
BCS DisableP1
LDA #PaddleOnSprite
STA P1Sprite
JMP BallCheck
DisableP1
LDA #PaddleOffSprite
STA P1Sprite
BallCheck ; And the ball...
LDA VictoryTime
BNE DisableBall
TYA
SEC
SBC YPosBall
BMI DisableBall
CMP #BallHeight
BCS DisableBall
LDA #BallOn
STA BallEnabled
JMP EndLineChecks
DisableBall
LDA #BallOff
STA BallEnabled
EndLineChecks
EndProcessingLine
DrawLine ; All we pretty much do here is load in the processing kernel's results and store them in the graphics registers.
DEY ; We don't just do this in the processing kernel because then the graphics would change mid-scanline.
; We also adjust the playfield graphics here.
STA WSYNC ; Sync to draw kernel line.
LDA Playfield0,Y ; Save some horizontal blank time.
STA COLUPF ; The color of the playfield is just PF0's current graphic. Yeah.
STA PF0
LDA Playfield1,Y
STA PF1
STA PF2
LDA P0Sprite
STA GRP0
LDA BallEnabled
STA ENABL ; Have to do it before PF1/2 or there isn't enough time.
LDA P1Sprite
STA GRP1
; Subtract 1 off our line counter.
DEY
CPY #10
; Loop for the next scanline.
BNE ScanLoop ; All finished within the horizontal blank.
ScoreDrawLine ; Starts on the 10th remaining visible scanline. Draws the score for each player.
LDA #0
STA WSYNC
LDA Playfield0,Y
STA COLUBK ; Set the background color to the color of playfield so we can free it up to be used for the numbers.
LDA #0
STA GRP0 ; Turn off alllllll graphics, including the playfield since the background now takes its place.
STA GRP1
STA ENABL
STA PF0
STA PF2
STA PF1
STA WSYNC
LDA %00000010
STA CTRLPF ; Turn on score coloring and duplication of the left half of the playfield (instead of mirroring).
LDX #8
ScoreLoop ; The actual number drawing loop. X counts from 0 to 8 and branches on 9.
STA WSYNC
LDA ScoreP0MemLoc
TAY
LDA Numbers,Y
STA PF1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
LDA ScoreP1MemLoc
TAY
LDA Numbers,Y
STA PF1
INC ScoreP0MemLoc
INC ScoreP1MemLoc
DEX
BEQ EndScore
JMP ScoreLoop
EndScore
LDA #0
STA WSYNC
STA PF1
STA PF0
STA PF2
; Get ready to set D1 bit for VBlank.
LDA #2
; Wait for final line to finish first though.
STA WSYNC
; Turn off drawing for overscan.
STA VBLANK
;************************************************************
; We get 30 lines of overscan.
; Why not use a timer like the vertical blank?
LDY #29
; Y=$08 is first scanline of bottom border.
; Y=$07 is first scanline of brown part of it.
OverScanWait
; Wait for line to finish...
STA WSYNC
; Decrement and loop.
DEY
BNE OverScanWait
; Back to main.
JMP MainLoop
; < Return Address > -> ToCap -> Min -> Max -> RetVal
; int CapToMinMax(byte ToCap)
ToCap = $03
CapRetVal = $04
CapToMinMax
TSX
LDA #96 ; We've collided, so figure out if we're at min or max.
CMP ToCap,X ; If C is set, YPosP0 < 96
BCS CapMin
JMP CapMax
CapMin
LDA #MinPaddleY
CMP ToCap,X
BCC CapReturn
STA ToCap,X
JMP CapReturn
CapMax
LDA #MaxPaddleY
CMP ToCap,X
BCS CapReturn
STA ToCap,X
CapReturn
LDA ToCap,X
STA CapRetVal,X
RTS
; Increments score for player and resets ball. Plays sound as well?
; Ball should shoot towards which player?
; void OnScore(byte PlayerWhoScored)
PlayerWhoScored = $03
OnScore
TSX
LDA PlayerWhoScored,X
CMP #-1
BEQ P0Scored
P1Scored
INC ScoreP1
JMP PostScored
P0Scored
INC ScoreP0
PostScored
; Subtract one from PlayerWhoScored ASL and set as HM?
JSR ResetBall
LDA #0
STA XVelBall
STA YVelBall
TSX
LDA PlayerWhoScored,X
ASL
ASL
ASL
ASL
STA XVelBall
STA NewXVelBall
LDA #%00001000
STA AUDC0
LDA #StartingWaitTime
STA WaitTime
LDA #0
STA XVelBall
STA YVelBall
RTS
ResetBall
LDA ScoreP0
STA WSYNC
NOP ; NOPs take 2 cycles.
NOP
NOP
BIT ScoreP0 ; BIT takes 3, literally just a garbage statement to burn 3 cycles.
NOP
NOP
NOP
NOP ; Kill horizontal blank.
NOP
NOP ; 21 Machine cycles here.
STA ScoreP0 ; STA takes 3, so our paddle's set at the 24th cycle.
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BIT ScoreP0
STA RESBL ; 1 EXTRA CYCLE AH?!
LDA #BallStartX
STA XPosBall
LDA #BallStartY
STA YPosBall
LDA ScoreP0
CLC
ADC ScoreP1
TAY
LDA StartingYVelTable,Y
STA YVelBall
LDA NewXVelBall
BNE SkipResetXVel
LDA #%00010000
SkipResetXVel
STA XVelBall
LDA #0
STA VolleyCount
RTS
; void OnWin()
OnWin
LDA #%00001000
STA AUDC1
DEC VictoryTime
BNE OnWinReturn
LDA #0
STA AUDC1
OnWinReturn
RTS
Playfield0
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %00110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
.byte %11110000
Playfield1
Playfield2
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
.byte %11111111
Numbers
Zero
.byte %00000111
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000111
One
.byte %00000010
.byte %00000010
.byte %00000010
.byte %00000010
.byte %00000010
.byte %00000010
.byte %00000010
.byte %00000010
Two
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000010
.byte %00000010
.byte %00000100
.byte %00000100
.byte %00000111
Three
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000111
Four
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
Five
.byte %00000111
.byte %00000100
.byte %00000100
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000111
Six
.byte %00000100
.byte %00000100
.byte %00000100
.byte %00000100
.byte %00000111
.byte %00000101
.byte %00000101
.byte %00000111
Seven
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
Eight
.byte %00000111
.byte %00000101
.byte %00000101
.byte %00000111
.byte %00000101
.byte %00000101
.byte %00000101
.byte %00000111
Nine
.byte %00000111
.byte %00000101
.byte %00000101
.byte %00000111
.byte %00000001
.byte %00000001
.byte %00000001
.byte %00000001
Ten
.byte %00010111
.byte %00010101
.byte %00010101
.byte %00010101
.byte %00010101
.byte %00010101
.byte %00010101
.byte %00010111
Eleven
.byte %00010100
.byte %00010100
.byte %00010100
.byte %00010100
.byte %00010100
.byte %00010100
.byte %00010100
.byte %00010100
Win
.byte %10101001
.byte %10101010
.byte %10101010
.byte %10101010
.byte %10101010
.byte %10101010
.byte %10101010
.byte %01001001
StartingYVelTable ; Picks a "random" Y direction for the ball.
.byte %00000001
.byte %11111111
.byte %11111111
.byte %00000000
.byte %00000001
.byte %00000001
.byte %11111111
.byte %11111111
.byte %00000001
.byte %11111111
.byte %00000000
.byte %00000001
.byte %11111111
.byte %00000001
.byte %11111111
.byte %00000000
.byte %00000001
.byte %00000000
.byte %00000001
.byte %11111111
;************************************************************
; Special memory locations. Tells the 6502 where to go.
org $FFFC
.word Start
.word Start |
libsrc/target/gl/stdio/fgetc_cons.asm | ahjelm/z88dk | 640 | 80169 | <reponame>ahjelm/z88dk
SECTION code_clib
PUBLIC fgetc_cons
PUBLIC _fgetc_cons
EXTERN getk
EXTERN VGL_KEY_STATUS_ADDRESS
fgetc_cons:
_fgetc_cons:
ld a,0xc0
ld (VGL_KEY_STATUS_ADDRESS),a
loop1:
ld a,(VGL_KEY_STATUS_ADDRESS)
cp $d0
jr nz,loop1
call getk
ld a,l
and a
jr z,fgetc_cons
ret
|
tests/missions-test_data-tests.ads | thindil/steamsky | 80 | 17640 | -- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with Gnattest_Generated;
package Missions.Test_Data.Tests is
type Test is new GNATtest_Generated.GNATtest_Standard.Missions.Test_Data
.Test with
null record;
procedure Test_GenerateMissions_2a8787_14c74a(Gnattest_T: in out Test);
-- missions.ads:116:4:GenerateMissions:Test_GenerateMissions
procedure Test_AcceptMission_979505_57ce38(Gnattest_T: in out Test);
-- missions.ads:127:4:AcceptMission:Test_AcceptMission
procedure Test_UpdateMissions_b5358e_60a195(Gnattest_T: in out Test);
-- missions.ads:137:4:UpdateMissions:Test_UpdateMissions
procedure Test_FinishMission_c82383_b2ab56(Gnattest_T: in out Test);
-- missions.ads:148:4:FinishMission:Test_FinishMission
procedure Test_DeleteMission_4bf0c5_8b646f(Gnattest_T: in out Test);
-- missions.ads:161:4:DeleteMission:Test_DeleteMission
procedure Test_UpdateMission_06efd0_8b6bc6(Gnattest_T: in out Test);
-- missions.ads:174:4:UpdateMission:Test_UpdateMission
procedure Test_AutoFinishMissions_ca7126_527254(Gnattest_T: in out Test);
-- missions.ads:186:4:AutoFinishMissions:Test_AutoFinishMissions
procedure Test_Get_Mission_Type_0b70ab_fb18a6(Gnattest_T: in out Test);
-- missions.ads:198:4:Get_Mission_Type:Test_Get_Mission_Type
end Missions.Test_Data.Tests;
-- end read only
|
examples/mov.asm | paulbarbu/cpu-emu | 2 | 21120 | <filename>examples/mov.asm
;MOV R4, 4
;BR ADDlbl
;MOV R1, 1
; MOV R3, 0
;MOV R5, 42
;MOV R2, 42
; MOV R0,R1
; MOV R4,(R1)
; MOV R4,(R1)1
;MOV (R1),R2
;MOV (R3), 121
; MOV (R1)1,(R1)
; MOV (R3)1,(R1)1
;JMP testlbl
;CLC
;ADDlbl:
;CLR R3
;ADD R5, R1
;MOV R1, 43
;SUB R5, R1
;OR R5, R1
;XOR R1, R1
;INC R1
mov r1, 1
PUSH r1
SEZ
SEZ
SEZ
SEZ
SEZ
SEZ
BEQ br1
INC R1
br1:
INC R1
;JMP end
PUSH R1
;PUSH R1
mov r1, 46
POP R1
;CALL func
ADD R10, 1
add r5, -1
JMP end
;POP R1
;POP R1
;INC R1
;testlbl:
func:
MOV R10, 10
RET
end: |
servo5.asm | adamlukomski/8051servocontroller | 0 | 170113 | ; ABOUT
; praca na 4800, 8bit danych, bez parzystosci, 1bit stopu, sprzetowe sterowanie przeplywem
; na razie tylko wywala znak na port2
;
;==========================================
; TIMER 2 DECLARATIONS
T2CON EQU 0C8h
TF2 EQU T2CON.7
EXF2 EQU T2CON.6
RCLK EQU T2CON.5
TCLK EQU T2CON.4
EXEN2 EQU T2CON.3
TR2 EQU T2CON.2
RCAP2H EQU 0CBh
RCAP2L EQU 0CAh
;==========================================
org 0
mov scon, #01010000b ; 8-bit uart, var baud rate
;mov tmod, #00100000b ;t1 serial, autoreload mode 1 on t1
;mov TH1, #0fah ;t1 serial 4800
;setb TR1 ;t1 serial
;clr RCLK ;t1 serial
;clr TCLK ;t1 serial
setb RCLK ;t2 serial override from t1
setb TCLK ;t2 serial override from t1
mov RCAP2H, #0ffh ;t2 serial 4800
mov RCAP2L, #0b8h ;t2 serial 4800
setb TR2 ; t2 serial start
; koniec obslugi szeregowego
; ustawienia domyslne dla servo
;==========================================
mainloop:
clr RI
jnb RI, $
mov P2, SBUF
clr TI
mov SBUF, P2
jnb TI, $
sjmp mainloop
end
|
konz/konz1/demo.adb | balintsoos/LearnAda | 0 | 2618 | with Rac;
use Rac;
procedure demo is
A : Raci := 5 / 4;
B : Raci := 3/2;
begin
kiir(A+B);
end demo;
|
ASM/src/cutscenes.asm | ActuallyAdasi/OoT-Randomizer | 289 | 84521 | <filename>ASM/src/cutscenes.asm
override_great_fairy_cutscene:
; a0 = global context
; a2 = fairy actor
lw t0, 0x1D2C (a0) ; t0 = switch flags
li t1, 1
sll t1, t1, 0x18 ; t1 = ZL switch flag
and v0, t0, t1
beqz v0, @@return ; Do nothing until ZL is played
nop
lhu t2, 0x02DC (a2) ; Load fairy index
li t3, SAVE_CONTEXT
lhu t4, 0xA4 (a0) ; Load scene number
beq t4, 0x3D, @@item_fairy
nop
; Handle upgrade fairies
addu t4, a0, t2
lbu t5, 0x1D28 (t4) ; t5 = chest flag for this fairy
bnez t5, @@return ; Use default behavior if the item is already obtained
nop
li t5, 1
sb t5, 0x1D28 (t4) ; Mark item as obtained
addiu t2, t2, 3 ; t2 = index of the item in FAIRY_ITEMS
b @@give_item
nop
@@item_fairy:
li t4, 1
sllv t4, t4, t2 ; t4 = fairy item mask
lbu t5, 0x0EF2 (t3) ; t5 = fairy item flags
and t6, t5, t4
bnez t6, @@return ; Use default behavior if the item is already obtained
nop
or t6, t5, t4
sb t6, 0x0EF2 (t3) ; Mark item as obtained
@@give_item:
; Unset ZL switch
nor t1, t1, t1
and t0, t0, t1
sw t0, 0x1D2C (a0)
; Load fairy item and mark it as pending
li t0, FAIRY_ITEMS
addu t0, t0, t2
lb t0, 0x00 (t0)
li t1, PENDING_SPECIAL_ITEM
sb t0, 0x00 (t1)
li v0, 0 ; Prevent fairy animation
@@return:
jr ra
nop
;==================================================================================================
override_light_arrow_cutscene:
li t0, LIGHT_ARROW_ITEM
lb t0, 0x00 (t0)
b store_pending_special_item
nop
override_fairy_ocarina_cutscene:
li t0, FAIRY_OCARINA_ITEM
lb t0, 0x00 (t0)
b store_pending_special_item
nop
;a3 = item ID
override_ocarina_songs:
li v0, 0xFF
addi t0, a3, -0x5A
addi t0, t0, 0x61
b store_pending_special_item
nop
override_requiem_song:
li t0, 0x64
b store_pending_special_item
nop
override_epona_song:
lui at,0x8012
addiu at,at,0xA5D0 ; v1 = 0x8012a5d0 # save context (sav)
lb t0,0x0EDE(at) ; check learned song from malon flag
ori t0,t0,0x01 ; t9 = "Invited to Sing With Child Malon"
sb t0,0x0EDE(at)
li t0, 0x68
b store_pending_special_item
nop
override_suns_song:
lui at,0x8012
addiu at,at,0xA5D0 ; v1 = 0x8012a5d0 # save context (sav)
lb t0,0x0EDE(at) ; learned song from sun's song
ori t0,t0,0x04 ;
sb t0,0x0EDE(at)
li t0, 0x6A
b store_pending_special_item
nop
override_song_of_time:
li a1, 3
li t0, 0x6B
b store_pending_special_item
nop
store_pending_special_item:
; Don't add item if it's already pending
li t1, PENDING_SPECIAL_ITEM
li t2, PENDING_SPECIAL_ITEM_END ; max number of entries
@@find_duplicate_loop:
lb t4, 0x00 (t1)
beq t4, t0, @@return ; item is already in list
addi t1, t1, 0x01
bne t1, t2, @@find_duplicate_loop ; end of list
nop
; Find free index to add item
li t1, (PENDING_SPECIAL_ITEM - 1)
@@find_empty_loop:
addi t1, t1, 0x01
beq t1, t2, @@return ; end of list
lb t4, 0x00 (t1)
bnez t4, @@find_empty_loop ; next index
nop
sb t0, 0x00 (t1) ; store in first free spot
@@return:
jr ra
nop
override_saria_song_check:
move t7, v1
lb t4, 0x0EDF(t7)
andi t6, t4, 0x80
beqz t6, @@get_item
li v1, 5
jr ra
li v0, 2
@@get_item:
jr ra
move v0, v1
set_saria_song_flag:
lh v0, 0xa4(t6) ; v0 = scene
li t0, SAVE_CONTEXT
lb t1, 0x0EDF(t0)
ori t1, t1, 0x80
sb t1, 0x0EDF(t0)
jr ra
nop
; Injection for talking to the Altar in the Temple of Time
; Should set flag in save that it has been spoken to.
set_dungeon_knowledge:
addiu sp, sp, -0x10
sw ra, 0x04(sp)
; displaced instruction
jal 0xD6218
nop
li t4, SAVE_CONTEXT
lh t5, 0x0F2E(t4) ; flags
lw t8, 0x0004(t4) ; age
beqz t8, @@set_flag
li t6, 0x0001 ; adult bit
li t6, 0x0002 ; child bit
@@set_flag:
or t5, t5, t6
sh t5, 0x0F2E(t4) ; set the flag
lw ra, 0x04(sp)
addiu sp, sp, 0x10
jr ra
nop
|
Project/Test/Assembly Test/Test 01/test_01.ng.asm | las-nish/NanoG-Compiler | 3 | 179705 | <filename>Project/Test/Assembly Test/Test 01/test_01.ng.asm<gh_stars>1-10
; generated assembly file [May 16 2021 & 17:20:32]
; link using "ld object_file.o - o exe_file" command
%define program _start
section .text
global program
program:
push rbp
mov rbp, rsp
mov QWORD [rbp-8], rdi
mov QWORD [rbp-16], rsi
mov QWORD [rbp-24], 10
mov QWORD [rbp-32], 20
mov BYTE [rbp-33], 97
mov BYTE [rbp-34], 66
mov QWORD [rbp-42], LBSTR.1
mov QWORD [rbp-50], LBSTR.2
mov r10, 5
mov r11, 10
cmp r10, r11
jg .L0
mov QWORD [rbp-58], 50
jmp .L1
.L0:
mov QWORD [rbp-66], 50
.L1:
jmp .L9
.L10:
mov r10, 10
mov rax, r10
.L9:
mov r10, 10
mov r11, 10
cmp r10, r11
je .L10
pop rbp
syscall
section .data
LBSTR.1: DB 76,97,115,97,110,0
LBSTR.2: DB 78,97,110,111,71,0
; nano_g compiler developed by <NAME> (@las_nish)
; May 16 2021 & 17:20:32 |
Codes/Chapter06/P05/P06-05.asm | ar-ekt/Dandamudi-Assembly-Solutions | 8 | 167272 | <filename>Codes/Chapter06/P05/P06-05.asm
global _start
extern ExitProcess
%INCLUDE "lib.h"
%macro geti 0
fgets buffer, 12
a2i 12, buffer
%endmacro
%macro puti 1
i2a DWORD %1, buffer
puts buffer
%endmacro
section .data
MAX_COL EQU 10
MAX_ROW EQU 10
NEWLINE db 10, 0
TAB db 9, 0
MSG_MAT1_ROW_INPUT db "Enter first matrix number of rows: ", 0
MSG_MAT1_COL_INPUT db "Enter first matrix number of columns: ", 0
MSG_MAT2_ROW_INPUT db "Second matrix number of rows = ", 0
MSG_MAT2_COL_INPUT db "Enter second matrix number of columns: ", 0
MSG_CELL_INPUT1 db "matrix", 0
MSG_CELL_INPUT2 db "[", 0
MSG_CELL_INPUT3 db "][", 0
MSG_CELL_INPUT4 db "] = ", 0
RESULT db "Result: ", 10, 0
section .bss
buffer resb 100
matrix1 resd (MAX_COL*MAX_ROW)+1
matrix2 resd (MAX_COL*MAX_ROW)+1
matrix3 resd (MAX_COL*MAX_ROW)+1
section .code
_start:
push DWORD 1
push DWORD 0
push DWORD 0
push matrix1
call matrixInput
pop ECX
pop EBX
puts NEWLINE
push DWORD 2
push ECX
push DWORD 0
push matrix2
call matrixInput
pop EDX
push EDX
push EBX
push ECX
push matrix3
push matrix2
push matrix1
call matrixMultiply
push EBX
push EDX
push matrix3
call matrixPrint
_end:
push DWORD 0
call ExitProcess
matrixInput:
%define matrix DWORD [EBP+8]
%define numCol DWORD [EBP+12]
%define numRow DWORD [EBP+16]
%define firstOrSecond DWORD [EBP+20]
enter 0, 0
push ESI
push EAX
push ECX
push EDX
cmp firstOrSecond, DWORD 1
je mat1SizeInput
jne mat2SizeInput
mat1SizeInput:
mat1RowInput:
puts MSG_MAT1_ROW_INPUT
geti
cmp EAX, MAX_ROW
jg mat1RowInput
cmp EAX, 1
jl mat1RowInput
mov numRow, EAX
mat1ColInput:
puts MSG_MAT1_COL_INPUT
geti
cmp EAX, MAX_COL
jg mat1ColInput
cmp EAX, 1
jl mat1ColInput
mov numCol, EAX
jmp cellsInput
mat2SizeInput:
mat2RowInput:
puts MSG_MAT2_ROW_INPUT
puti numRow
puts NEWLINE
mat2ColInput:
puts MSG_MAT2_COL_INPUT
geti
cmp EAX, MAX_COL
jg mat2ColInput
cmp EAX, 1
jl mat2ColInput
mov numCol, EAX
cellsInput:
mov ESI, matrix
mov ECX, 0-1
rowsInput:
inc ECX
cmp ECX, numRow
jge matrixInput_done
mov EDX, 0-1
columnsInput:
inc EDX
cmp EDX, numCol
jge rowsInput
puts MSG_CELL_INPUT1
puti firstOrSecond
puts MSG_CELL_INPUT2
puti ECX
puts MSG_CELL_INPUT3
puti EDX
puts MSG_CELL_INPUT4
geti
mov [ESI], EAX
add ESI, 4
jmp columnsInput
matrixInput_done:
pop EDX
pop ECX
pop EAX
pop ESI
leave
ret 12-8
matrixMultiply:
%define matrix1 DWORD [EBP+8]
%define matrix2 DWORD [EBP+12]
%define result DWORD [EBP+16]
%define numCol1 DWORD [EBP+20]
%define numRow1 DWORD [EBP+24]
%define numCol2 DWORD [EBP+28]
%define cellSum DWORD [EBP-4]
%define cellTemp DWORD [EBP-8]
enter 8, 0
pushad
mov EDI, result
xor ESI, ESI
mat1RowLoop:
xor ECX, ECX
mat2ColLoop:
mov cellSum, DWORD 0
xor EBX, EBX
cellLoop:
mov cellTemp, DWORD 0
mov EAX, ESI
mul numCol1
add EAX, EBX
shl EAX, 2
add EAX, matrix1
mov EDX, [EAX]
add cellTemp, EDX
xor EAX, EAX
mov EAX, EBX
mul numCol2
add EAX, ECX
shl EAX, 2
mov EDX, EAX
add EDX, matrix2
mov EAX, [EDX]
mul cellTemp
add cellSum, EAX
inc EBX
cmp EBX, numCol1
jne cellLoop
nextCol:
mov EDX, cellSum
mov [EDI], EDX
add EDI, 4
inc ECX
cmp ECX, numCol2
je nextRow
jne mat2ColLoop
nextRow:
inc ESI
cmp ESI, numRow1
je matrixMultiply_done
jne mat1RowLoop
matrixMultiply_done:
popad
leave
ret 24
matrixPrint:
%define matrix DWORD [EBP+8]
%define numCol DWORD [EBP+12]
%define numRow DWORD [EBP+16]
enter 0,0
push ESI
push EDX
push ECX
puts NEWLINE
puts RESULT
mov ESI, matrix
mov ECX, numRow
rowsPrint:
mov EDX, numCol
colsPrint:
puti [ESI]
add ESI, 4
puts TAB
sub EDX, 1
ja colsPrint
cols_done:
puts NEWLINE
sub ECX, 1
ja rowsPrint
matrixPrint_done:
pop ECX
pop EDX
pop ESI
leave
ret 12
|
oeis/166/A166036.asm | neoneye/loda-programs | 11 | 102413 | <filename>oeis/166/A166036.asm
; A166036: a(n) = (4^n+8*(-5)^n)/9.
; Submitted by <NAME>(s1)
; 1,-4,24,-104,584,-2664,14344,-67624,354504,-1706984,8797064,-42936744,218878024,-1077612904,5455173384,-27007431464,136110899144,-676259528424,3398477511304,-16923668079784,84893218305864,-423366579901544,2121230946018824,-10588562544049704,53013181464426184,-264784432345420264,1325048061633943944,-6620736708542349224,33121697941221228104,-165536432112068212584,827970390936492774664,-4138699033177857026344,20698106851907712519624,-103472087515464853046504,517434224553619103438984
mov $1,-5
pow $1,$0
mul $1,8
mov $2,4
pow $2,$0
add $1,$2
mov $0,$1
div $0,9
|
Quiz and Lab Assessment/Solution/4.asm | simonahsan2129/CSE331L-Section-1-Fall20-NSU | 1 | 241475 | <filename>Quiz and Lab Assessment/Solution/4.asm
.model small
.stack 100h
.data
msg1 db 10,13,"ENTER A HEX DIGIT: $"
msg2 db 10,13,"IN DECIMAL IS IT: $"
msg3 db 10,13,"DO YOU WANT TO DO IT AGAIN? $"
msg4 db 10,13,"INVALID CHARACTER- ENTER 0-9 OR A-F: $"
.code
again:
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,9
int 21h
mov ah,1
int 21h
mov bl,al
jmp go
go:
cmp bl,'9'
ja hex
jb num
je num
hex:
cmp bl,'F'
ja illegal
lea dx,msg2
mov ah,9
int 21h
mov dl,49d
mov ah,2
int 21h
sub bl,17d
mov dl,bl
mov ah,2
int 21h
jmp inp
inp:
lea dx,msg3
mov ah,9
int 21h
mov ah,1
int 21h
mov cl,al
cmp cl,'y'
je again
cmp cl,'Y'
je again
jmp exit
num:
cmp bl,'0'
jb illegal
lea dx,msg2
mov ah,9
int 21h
mov dl,bl
mov ah,2
int 21h
jmp inp
illegal:
lea dx,msg4
mov ah,9
int 21h
mov ah,1
int 21h
mov bl,al
jmp go
exit:
|
projects/batfish/src/batfish/grammar/z3/DatalogQueryResultLexer.g4 | luispedrosa/batfish | 0 | 2321 | lexer grammar DatalogQueryResultLexer;
options {
superClass = 'batfish.grammar.BatfishLexer';
}
@header {
package batfish.grammar.z3;
}
AND
:
'and'
;
EXTRACT
:
'extract'
;
FALSE
:
'false'
;
LET
:
'let'
;
NOT
:
'not'
;
OR
:
'or'
;
SAT
:
'sat'
;
TRUE
:
'true'
;
UNSAT
:
'unsat'
;
VAR
:
':var'
;
COMMENT
:
';' -> pushMode ( M_COMMENT ) , channel (HIDDEN)
;
BIN
:
'#b' F_Digit+
;
DEC
:
F_Digit+
;
EQUALS
:
'='
;
HEX
:
'#x' F_HexDigit+
;
LEFT_PAREN
:
'('
;
RIGHT_PAREN
:
')'
;
UNDERSCORE
:
'_'
;
VARIABLE
:
'a!' F_Digit+
;
WS
:
F_WhitespaceChar+ -> channel (HIDDEN)
;
fragment
NEWLINE_CHAR
:
'\n'
;
fragment
F_HexDigit
:
(
'0' .. '9'
| 'a' .. 'f'
| 'A' .. 'F'
)
;
fragment
F_Digit
:
'0' .. '9'
;
fragment
F_NewlineChar
:
[\n\r]
;
fragment
F_NonNewlineChar
:
~[\n\r]
;
fragment
F_WhitespaceChar
:
[ \t\u000C\r\n]
;
mode M_COMMENT;
M_COMMENT_NEWLINE
:
F_NewlineChar+ -> popMode , channel (HIDDEN)
;
M_COMMENT_NON_NEWLINE
:
F_NonNewlineChar+ -> channel (HIDDEN)
;
|
awa/src/awa-modules.ads | twdroeger/ada-awa | 0 | 10390 | <filename>awa/src/awa-modules.ads
-----------------------------------------------------------------------
-- awa-modules -- Application Module
-- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2016, 2017, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Ada.Strings.Hash;
with Ada.Strings.Unbounded;
with Ada.Containers.Indefinite_Hashed_Maps;
with Util.Log.Loggers;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Serialize.IO;
with Util.Listeners;
with EL.Expressions;
with ASF.Beans;
with ASF.Applications;
with ADO.Sessions;
with AWA.Events;
limited with AWA.Applications;
-- == AWA Modules ==
-- A module is a software component that can be integrated in the
-- web application. The module can bring a set of service APIs,
-- some Ada beans and some presentation files. The AWA framework
-- allows to configure various parts of a module when it is integrated
-- in an application. Some modules are designed to be re-used by
-- several applications (for example a _mail_ module, a _users_
-- module, ...). Other modules could be specific to an application.
-- An application will be made of several modules, some will be
-- generic some others specific to the application.
--
-- === Registration ===
-- The module should have only one instance per application and it must
-- be registered when the application is initialized. The module
-- instance should be added to the application record as follows:
--
-- type Application is new AWA.Applications.Application with record
-- Xxx : aliased Xxx_Module;
-- end record;
--
-- The application record must override the `Initialize_Module` procedure
-- and it must register the module instance. This is done as follows:
--
-- overriding
-- procedure Initialize_Modules (App : in out Application) is
-- begin
-- Register (App => App.Self.all'Access,
-- Name => Xxx.Module.NAME,
-- URI => "xxx",
-- Module => App.User_Module'Access);
-- end Initialize_Modules;
--
-- The module is registered under a unique name. That name is used
-- to load the module configuration.
--
-- === Configuration ===
-- The module is configured by using an XML or a properties file.
-- The configuration file is used to define:
--
-- * the Ada beans that the module defines and uses,
-- * the events that the module wants to receive and the action
-- that must be performed when the event is posted,
-- * the permissions that the module needs and how to check them,
-- * the navigation rules which are used for the module web interface,
-- * the servlet and filter mappings used by the module
--
-- The module configuration is located in the *config* directory
-- and must be the name of the module followed by the file extension
-- (example: `module-name`.xml or `module-name`.properties).
--
--
package AWA.Modules is
type Application_Access is access all AWA.Applications.Application'Class;
-- ------------------------------
-- Module manager
-- ------------------------------
--
-- The <b>Module_Manager</b> represents the root of the logic manager
type Module_Manager is new Ada.Finalization.Limited_Controlled
and Util.Beans.Basic.Readonly_Bean with private;
function Get_Value (Manager : in Module_Manager;
Name : in String) return Util.Beans.Objects.Object;
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Plugin : Module_Manager;
Name : String;
Default : String := "") return String;
-- Get the module configuration property identified by the <tt>Config</tt> parameter.
-- If the property does not exist, the default configuration value is returned.
function Get_Config (Plugin : in Module_Manager;
Config : in ASF.Applications.Config_Param) return String;
-- ------------------------------
-- Module
-- ------------------------------
type Module is abstract new Ada.Finalization.Limited_Controlled with private;
type Module_Access is access all Module'Class;
-- Get the module name
function Get_Name (Plugin : Module) return String;
-- Get the base URI for this module
function Get_URI (Plugin : Module) return String;
-- Get the application in which this module is registered.
function Get_Application (Plugin : in Module) return Application_Access;
-- Find the module with the given name
function Find_Module (Plugin : Module;
Name : String) return Module_Access;
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Plugin : Module;
Name : String;
Default : String := "") return String;
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Plugin : Module;
Name : String;
Default : Integer := -1) return Integer;
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Plugin : Module;
Name : String;
Default : Boolean := False) return Boolean;
-- Get the module configuration property identified by the <tt>Config</tt> parameter.
-- If the property does not exist, the default configuration value is returned.
function Get_Config (Plugin : in Module;
Config : in ASF.Applications.Config_Param) return String;
-- Get the module configuration property identified by the <tt>Config</tt> parameter.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Plugin : in Module;
Name : in String;
Default : in String := "")
return EL.Expressions.Expression;
procedure Initialize (Manager : in out Module_Manager;
Module : in AWA.Modules.Module'Class);
procedure Initialize (Plugin : in out Module;
App : in Application_Access;
Props : in ASF.Applications.Config);
-- Initialize the configuration file parser represented by <b>Parser</b> to recognize
-- the specific configuration recognized by the module.
procedure Initialize_Parser (Plugin : in out Module;
Parser : in out Util.Serialize.IO.Parser'Class) is null;
-- Configures the module after its initialization and after having read its XML configuration.
procedure Configure (Plugin : in out Module;
Props : in ASF.Applications.Config) is null;
-- Send the event to the module. The module identified by <b>To</b> is
-- found and the event is posted on its event channel.
procedure Send_Event (Plugin : in Module;
Content : in AWA.Events.Module_Event'Class);
-- Get the database connection for reading
function Get_Session (Manager : Module)
return ADO.Sessions.Session;
-- Get the database connection for writing
function Get_Master_Session (Manager : Module)
return ADO.Sessions.Master_Session;
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Plugin : in out Module;
Name : in String;
Bind : in ASF.Beans.Class_Binding_Access);
-- Add a listener to the module listner list. The module will invoke the listner
-- depending on events or actions that occur in the module.
procedure Add_Listener (Into : in out Module;
Item : in Util.Listeners.Listener_Access);
-- Find the module with the given name in the application and add the listener to the
-- module listener list.
procedure Add_Listener (Plugin : in Module;
Name : in String;
Item : in Util.Listeners.Listener_Access);
-- Remove a listener from the module listener list.
procedure Remove_Listener (Into : in out Module;
Item : in Util.Listeners.Listener_Access);
-- Finalize the module.
overriding
procedure Finalize (Plugin : in out Module);
type Pool_Module is abstract new Module with private;
type Session_Module is abstract new Module with private;
generic
type Manager_Type is new Module_Manager with private;
type Manager_Type_Access is access all Manager_Type'Class;
Name : String;
function Get_Manager return Manager_Type_Access;
-- Get the database connection for reading
function Get_Session (Manager : Module_Manager)
return ADO.Sessions.Session;
-- Get the database connection for writing
function Get_Master_Session (Manager : Module_Manager)
return ADO.Sessions.Master_Session;
-- Send the event to the module. The module identified by <b>To</b> is
-- found and the event is posted on its event channel.
procedure Send_Event (Manager : in Module_Manager;
Content : in AWA.Events.Module_Event'Class);
-- ------------------------------
-- Module Registry
-- ------------------------------
-- The module registry maintains the list of available modules with
-- operations to retrieve them either from a name or from the base URI.
type Module_Registry is limited private;
type Module_Registry_Access is access all Module_Registry;
-- Initialize the registry
procedure Initialize (Registry : in out Module_Registry;
Config : in ASF.Applications.Config);
-- Register the module in the registry.
procedure Register (Registry : in Module_Registry_Access;
App : in Application_Access;
Plugin : in Module_Access;
Name : in String;
URI : in String);
-- Find the module with the given name
function Find_By_Name (Registry : Module_Registry;
Name : String) return Module_Access;
-- Find the module mapped to a given URI
function Find_By_URI (Registry : Module_Registry;
URI : String) return Module_Access;
-- Iterate over the modules that have been registered and execute the <b>Process</b>
-- procedure on each of the module instance.
procedure Iterate (Registry : in Module_Registry;
Process : access procedure (Plugin : in out Module'Class));
private
use Ada.Strings.Unbounded;
type Module is abstract new Ada.Finalization.Limited_Controlled with record
Registry : Module_Registry_Access;
App : Application_Access := null;
Name : Unbounded_String;
URI : Unbounded_String;
Config : ASF.Applications.Config;
Self : Module_Access := null;
Listeners : Util.Listeners.List;
end record;
-- Map to find a module from its name or its URI
package Module_Maps is new
Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Module_Access,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=");
type Module_Registry is limited record
Config : ASF.Applications.Config;
Name_Map : Module_Maps.Map;
URI_Map : Module_Maps.Map;
end record;
type Module_Manager is new Ada.Finalization.Limited_Controlled
and Util.Beans.Basic.Readonly_Bean with record
Module : Module_Access := null;
end record;
type Pool_Module is new Module with record
D : Natural;
end record;
type Session_Module is new Module with record
P : Natural;
end record;
use Util.Log;
-- The logger (used by the generic Get function).
Log : constant Loggers.Logger := Loggers.Create ("AWA.Modules");
end AWA.Modules;
|
programs/oeis/273/A273745.asm | neoneye/loda | 22 | 90741 | <filename>programs/oeis/273/A273745.asm
; A273745: First differences of number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 901", based on the 5-celled von Neumann neighborhood.
; 7,17,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,256,264,272,280,288,296,304,312,320,328,336,344,352,360,368,376,384,392,400,408,416,424,432,440,448,456,464,472,480,488,496,504,512,520,528,536,544,552,560,568,576,584,592,600,608,616,624,632,640,648,656,664,672,680,688,696,704,712,720,728,736,744,752,760,768,776,784,792,800
mov $1,$0
mov $2,8
mul $2,$0
lpb $1
mov $1,1
sub $2,$0
lpe
add $0,$1
add $0,$2
add $0,7
|
programs/oeis/060/A060690.asm | neoneye/loda | 22 | 167290 | ; A060690: a(n) = binomial(2^n + n - 1, n).
; 1,2,10,120,3876,376992,119877472,131254487936,509850594887712,7145544812472168960,364974894538906616240640,68409601066028072105113098240,47312269462735023248040155132636160
mov $1,2
pow $1,$0
mov $2,$0
sub $2,1
add $1,$2
bin $1,$0
mov $0,$1
|
src/FormulaParser.g4 | AnandSaminathan/formula-tree | 0 | 5498 | parser grammar FormulaParser;
options {
tokenVocab = FormulaLexer;
}
form : propForm
| pseudoBoolForm
| ltlForm
;
propForm : relationalForm #propBase
| OPEN_PARAN formula=propForm CLOSE_PARAN #propParenthesis
| op=NOT formula=propForm #propUnary
| left=propForm op=AND right=propForm #propBinary
| left=propForm op=OR right=propForm #propBinary
| left=propForm op=IMPLIES right=propForm #propBinary
| left=propForm op=EQ right=propForm #propBinary
;
pseudoBoolForm : relationalForm #pseudoBoolBase
| OPEN_PARAN formula=pseudoBoolForm CLOSE_PARAN #pseudoBoolParenthesis
| op=NOT formula=pseudoBoolForm #pseudoBoolLogicalUnary
| left=pseudoBoolForm op=AND right=pseudoBoolForm #pseudoBoolLogicalBinary
| left=pseudoBoolForm op=OR right=pseudoBoolForm #pseudoBoolLogicalBinary
| left=pseudoBoolForm op=IMPLIES right=pseudoBoolForm #pseudoBoolLogicalBinary
| left=wholeNumber op=MUL right=pseudoBoolForm #pseudoBoolCoeff
| left=pseudoBoolForm op=(PLUS | MINUS) right=pseudoBoolForm #pseudoBoolArithBinary
| left=pseudoBoolForm op=(LT | GT | LTE | GTE) right=wholeNumber #pseudoBoolIneqBinary
| left=pseudoBoolForm op=(EQ | NEQ) right=pseudoBoolForm #pseudoBoolLogicalBinary
;
ltlForm : relationalForm #ltlBase
| OPEN_PARAN formula=ltlForm CLOSE_PARAN #ltlParenthesis
| op=GLOBAL formula=ltlForm #ltlUnary
| op=FUTURE formula=ltlForm #ltlUnary
| op=NEXT formula=ltlForm #ltlUnary
| op=NOT formula=ltlForm #ltlUnary
| <assoc=right>left=ltlForm op=UNTIL right=ltlForm #ltlBinary
| left=ltlForm op=RELEASE right=ltlForm #ltlBinary
| left=ltlForm op=AND right=ltlForm #ltlBinary
| left=ltlForm op=OR right=ltlForm #ltlBinary
| left=ltlForm op=IMPLIES right=ltlForm #ltlBinary
| left=ltlForm op=EQ right=ltlForm #ltlBinary
;
relationalForm : content=logicalValue #relationalValue
| arithmeticForm #arithmeticFormula
| content=id #relationalId
| OPEN_PARAN formula=relationalForm CLOSE_PARAN #relationalParenthesis
| left=relationalForm op=(LT | GT | LTE | GTE) right=relationalForm #relationalBinary
| left=relationalForm op=(EQ | NEQ) right=relationalForm #relationalBinary
;
arithmeticForm : content=arithValue #arithmeticValue
| content=id #arithmeticId
| OPEN_PARAN formula=arithmeticForm CLOSE_PARAN #arithmeticParenthesis
| left=arithmeticForm op=MOD right=arithmeticForm #arithmeticBinary
| left=arithmeticForm op=DIV right=arithmeticForm #arithmeticBinary
| left=arithmeticForm op=MUL right=arithmeticForm #arithmeticBinary
| left=arithmeticForm op=(PLUS | MINUS) right=arithmeticForm #arithmeticBinary
;
logicalValue : (TRUE | FALSE);
arithValue : (integer | decimal);
id : (LOWER_CASE | UPPER_CASE | UNDERSCORE | DOT) (LOWER_CASE | UPPER_CASE | DIGIT | UNDERSCORE | DOT)*;
decimal : integer DOT wholeNumber;
integer : (PLUS | MINUS)? wholeNumber;
wholeNumber : (DIGIT | DIGIT+);
|
src/drawCode/mmDraw.asm | Gip-Gip/VePseu | 5 | 95793 | <filename>src/drawCode/mmDraw.asm
; Draws the compass to the screen
; See GLOSSARY.TXT for definitions of vague words
mmDraw:
INCLUDE "drawCode/mmRender.asm"
SUBROUTINE ; The preceeding code declares it's own subroutine
LDY #NULL
STY GRP0
STY GRP1
STY WSYNC
STY HMOVE
LDX playerPos
.loop:
STA WSYNC
LDA (miniMapPtr),Y
STA GRP0
INY
LDA (miniMapPtr),Y
STA GRP1
INY
TXA
SEC
SBC mapWidth
TAX
AND #$F0
BNE .noDraw
LDA #2
STA ENABL
STA drawingPlyr
LDA #1
STA VDELBL
.noDraw:
LDA drawingPlyr
STA ENABL
LDA #NULL
STA drawingPlyr
CPY #MMSIZE
BNE .loop
LDA #NULL
STA ENABL
STA WSYNC
LDA #NULL
STA GRP0
STA GRP1
STA COLUP0
STA COLUP1
|
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0xca.log_21829_1256.asm | ljhsiun2/medusa | 9 | 92085 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xce0d, %rsi
cmp $35065, %rbx
mov $0x6162636465666768, %r9
movq %r9, (%rsi)
nop
nop
nop
nop
nop
sub $5600, %rbx
lea addresses_A_ht+0x1430d, %rsi
lea addresses_normal_ht+0x13b8d, %rdi
nop
nop
nop
and $619, %r12
mov $54, %rcx
rep movsw
nop
nop
nop
add %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %rax
push %rbp
push %rbx
// Faulty Load
mov $0x261349000000030d, %rbx
nop
nop
cmp $25958, %rbp
movb (%rbx), %r12b
lea oracles, %rbp
and $0xff, %r12
shlq $12, %r12
mov (%rbp,%r12,1), %r12
pop %rbx
pop %rbp
pop %rax
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
tools-src/gnu/gcc/gcc/ada/a-stunau.ads | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 1945 | <reponame>enfoTek/tomato.linksys.e2000.nvram-mod
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- A D A . S T R I N G S . U N B O U N D E D . A U X --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-1998, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This child package of Ada.Strings.Unbounded provides some specialized
-- access functions which are intended to allow more efficient use of the
-- facilities of Ada.Strings.Unbounded, particularly by other layered
-- utilities (such as GNAT.Patterns).
package Ada.Strings.Unbounded.Aux is
pragma Preelaborate (Aux);
function Get_String (U : Unbounded_String) return String_Access;
pragma Inline (Get_String);
-- This function returns the internal string pointer used in the
-- representation of an unbounded string. There is no copy involved,
-- so the value obtained references the same string as the original
-- unbounded string. The characters of this string may not be modified
-- via the returned pointer, and are valid only as long as the original
-- unbounded string is not modified. Violating either of these two
-- rules results in erroneous execution.
--
-- This function is much more efficient than the use of To_String
-- since it avoids the need to copy the string. The lower bound of the
-- referenced string returned by this call is always one.
procedure Set_String (UP : in out Unbounded_String; S : String);
pragma Inline (Set_String);
-- This function sets the string contents of the referenced unbounded
-- string to the given string value. It is significantly more efficient
-- than the use of To_Unbounded_String with an assignment, since it
-- avoids the necessity of messing with finalization chains. The lower
-- bound of the string S is not required to be one.
procedure Set_String (UP : in out Unbounded_String; S : String_Access);
pragma Inline (Set_String);
-- This version of Set_String takes a string access value, rather than a
-- string. The lower bound of the string value is required to be one, and
-- this requirement is not checked.
end Ada.Strings.Unbounded.Aux;
|
Transynther/x86/_processed/NC/_ht_st_zr_un_4k_/i7-7700_9_0x48.log_21829_1369.asm | ljhsiun2/medusa | 9 | 102060 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1930b, %rdi
nop
nop
nop
nop
nop
inc %rdx
mov (%rdi), %r8w
nop
nop
nop
nop
nop
and %rbx, %rbx
lea addresses_WC_ht+0x19ccb, %rcx
inc %rsi
vmovups (%rcx), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r13
nop
nop
cmp %rcx, %rcx
lea addresses_A_ht+0x5dee, %rsi
lea addresses_WT_ht+0x19acb, %rdi
nop
nop
nop
inc %r12
mov $19, %rcx
rep movsw
nop
cmp $662, %rsi
lea addresses_UC_ht+0x2b1b, %rcx
nop
nop
cmp $64397, %rbx
movb (%rcx), %r8b
nop
add $28776, %r8
lea addresses_UC_ht+0x370d, %r8
clflush (%r8)
nop
dec %rcx
movb $0x61, (%r8)
nop
nop
add $19172, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r15
push %rbp
push %rdi
push %rdx
// Store
lea addresses_RW+0xdccb, %r15
nop
nop
nop
cmp $17529, %r11
mov $0x5152535455565758, %rdx
movq %rdx, %xmm1
movups %xmm1, (%r15)
nop
nop
nop
nop
nop
sub $60281, %r15
// Load
mov $0x16900c0000000acb, %rbp
clflush (%rbp)
nop
dec %rdi
mov (%rbp), %r13d
nop
nop
nop
nop
inc %rbp
// Store
lea addresses_normal+0x11acb, %rdx
nop
nop
nop
nop
add $52702, %rbp
movw $0x5152, (%rdx)
nop
nop
sub %r14, %r14
// Store
lea addresses_WT+0xe245, %r11
nop
nop
nop
nop
add %r13, %r13
movl $0x51525354, (%r11)
nop
add $17005, %r11
// Faulty Load
mov $0x16900c0000000acb, %r13
nop
nop
nop
nop
sub %rdi, %rdi
movups (%r13), %xmm7
vpextrq $1, %xmm7, %rdx
lea oracles, %r14
and $0xff, %rdx
shlq $12, %rdx
mov (%r14,%rdx,1), %rdx
pop %rdx
pop %rdi
pop %rbp
pop %r15
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}}
{'2a': 1, '82': 106, '4e': 121, 'b3': 1, '92': 2, 'c5': 5894, 'b7': 1, '37': 20, 'ff': 3938, '2d': 1, 'a0': 1414, '40': 2702, 'bb': 8, '74': 241, '25': 1, '53': 2, '08': 1, 'a6': 1, '12': 7, '9f': 1, '31': 1, '16': 1, '73': 1, 'a8': 1, '7d': 3, '71': 1, 'e8': 4, '45': 61, '1e': 1, '43': 1, '33': 1, '4c': 116, '5d': 1, 'ca': 6, '88': 1, '5e': 579, '93': 1, '1a': 1, '0b': 1, '3f': 1, '52': 28, '0a': 1, 'e3': 1, '00': 5498, 'b1': 6, 'cf': 8, 'd6': 1, 'c2': 1, 'a4': 1, 'a1': 828, '8a': 2, '01': 16, '1f': 15, '48': 3, 'c0': 1, '46': 3, '41': 34, '9a': 10, '0d': 91, '78': 1, '0e': 22, '10': 1, 'aa': 11}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 00 00 00 aa 00 00 aa 00 00 00 00 00 00 00 00 aa 00 aa 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 00 00 00 aa 00 00 aa c5 ff ff ff ff ff ff ff ff ff aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff a8 ff ff ff ff ff ff ff ff ff 4e ff ff ff ff 4e 4e ff ff ff ff ff ff ff ff ff ff 4e ff 4e ff ff ff ff ff ff ff ff ff ff 4e ff ff 4e ff 4e ff ff ff ff ff ff ff ff ff ff 4e 4e ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4e ff ff 4e ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff c5 ff ff ff ff ff ff ff c5 ff ff ff ff c5 ff ff ff ff ff 40 ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff 4e ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff 40 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff c5 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4e ff ff ff ff ff ff 4e 4e ff ff 4e 00 ff 00 ff 4e 00 ff 4e 00 ff 4e 4e 00 ff 4e 00 ff 4e 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 4e a1 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 4e 4e 00 ff 4e 4e 00 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 ff 4e 00 4e 00 ff 4e 4e 4e 00 ff 4e 00 ff 4e 4e 4e 00 ff 4e 40 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 40 00 c5 40 40 00 c5 00 c5 00 c5 00 c5 00 c5 40 00 c5 00 c5 00 c5 00 c5 00 c5 00 40 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 40 00 c5 00 c5 00 c5 00 40 00 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 4e 00 4e 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 c5 00 4e 00 c5 00 c5 00 c5 00 c5 00
*/
|
libsrc/strings/strlcpy_callee.asm | grancier/z180 | 8 | 173630 | <gh_stars>1-10
; uint __CALLEE__ strlcpy_callee(char *dst, char *src, uint size)
; 06.2008 aralbrec
SECTION code_clib
PUBLIC strlcpy_callee
PUBLIC _strlcpy_callee
PUBLIC ASMDISP_STRLCPY_CALLEE
IF FORrcmx000
EXTERN rcmx_cpir
ENDIF
.strlcpy_callee
._strlcpy_callee
pop af
pop bc
pop hl
pop de
push af
.asmentry
; enter : hl = char *src
; de = char *dst
; bc = uint size
push hl ; save src to compute strlen later
ld a,b
or c
jr z, szexceeded1
.cpyloop
or a
jr z, done ; if end of src string was reached...
ld a,(hl)
ldi ; copy src byte to dst
jp pe, cpyloop ; repeat until size reaches zero
xor a ; one too many bytes copied...
dec de ; need to place \0 into dst
ld (de),a
dec hl ; in case last char copied was \0 for cpir following
.szexceeded1
; a = 0
; bc = 0
IF FORrcmx000
call rcmx_cpir
ELSE
cpir ; find end of char *src
ENDIF
.done
dec hl
; hl = pointing at \0 at end of char *src
; carry flag reset
pop de ; de = char *src
sbc hl,de ; hl = strlen(src)
ret
defc ASMDISP_STRLCPY_CALLEE = # asmentry - strlcpy_callee
|
guitarfx/echo2.asm | ksteensig/dsp-guitar-multieffects | 1 | 87644 |
.sect ".ivars"
.align 2
dl: .word 0x0FFF
G: .word 0x3000 ;Signed Q15
D: .word 0x7FFF ;Signed Q15
;.def echo_effect
.ref xn
*********************************************************************
* echo_effect *
* Adds echo effect to input sample *
* Takes paramters: *
* D - Delay, DG - Delay Gain *
* Difference equation: *
* y[n] = x[n] + DG * y[n-d] *
*********************************************************************
.text
echo_effect:
*Setup for echo_effect
AMOV #xn, XAR0
MOV *(#dl), T0
*Calculate Echo effect: y[n] = D*(x[n] + DG * y[n-d])
BSET FRCT
MOV *AR6(T0) << #16, AC0 ; move y[n-d] into accumulator
MPYM *(#G), AC0 ; multiply G and y[n-d]
SFTS AC0, #-16 ; Shift the output down so we can get it out. 15 = 16 right (to mov hi to low part) - 1 to remove extra sign bit.
ADD *AR0, AC0 ; add x[n] to get y[n]
MPYM *(#D), AC0 ; multiply D and x[n] + DG * y[n-d]
MOV HI(AC0), *AR0 ; move y[n] into x[n] = AR0 for next effect to use
BCLR FRCT
RET
|
source/contexts/plain/program-plain_contexts.adb | reznikmm/gela | 0 | 18302 | -- SPDX-FileCopyrightText: 2019-2021 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with System.Storage_Pools.Subpools;
with Program.Directory_Unit_Schemas;
with Program.GNAT_Unit_Naming;
with Program.Nodes.Identifiers.Set_Defining_Name;
with Program.Nodes.Operator_Symbols.Set_Defining_Name;
with Program.Parsers;
with Program.Plain_Compilations;
with Program.Plain_Contexts.Unit_Name_Resolvers;
with Program.Resolve_Standard;
with Program.Resolvers;
with Program.Storage_Pools;
with Program.Unit_Dependencies;
package body Program.Plain_Contexts is
type Plain_Compilation_Access is
access all Program.Plain_Compilations.Compilation;
type Unit_Naming_Schema_Access is
access all Program.Unit_Naming.Unit_Naming_Schema'Class;
package Symbol_List_Index_Vectors is new Ada.Containers.Vectors
(Positive,
Program.Symbol_Lists.Symbol_List,
"=" => Program.Symbol_Lists."=");
type Dependency (Context : access Program.Plain_Contexts.Context'Class) is
new Program.Unit_Dependencies.Unit_Dependency_Listener with
record
Declarations : Symbol_List_Index_Vectors.Vector;
Bodies : Symbol_List_Index_Vectors.Vector;
end record;
procedure Find_Dependecies
(Self : in out Dependency'Class;
Unit : Program.Compilation_Units.Compilation_Unit_Access;
Check : access procedure
(Unit : Program.Compilation_Units.Compilation_Unit_Access;
Lists : in out Program.Symbol_Lists.Symbol_List_Table'Class;
Report : in out Unit_Dependencies.Unit_Dependency_Listener'Class));
overriding procedure Required_Declaration
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List;
If_Any : Boolean := False);
-- Library unit declaration is required (if any when If_Any).
overriding procedure Required_Body
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List);
-- Library unit body or subunit is required
overriding procedure Required_Unit
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List;
Is_Limited : Boolean);
procedure Parse_File
(Self : aliased in out Context'Class;
Text_Name : Text;
Standard : Boolean;
Units : out Program.Parsers.Unit_Vectors.Vector;
Pragmas : out Program.Parsers.Element_Vectors.Vector);
--------------------------
-- Add_Search_Directory --
--------------------------
procedure Add_Search_Directory
(Self : in out Context'Class;
Path : Program.Text) is
begin
Program.Directory_Unit_Schemas.Directory_Unit_Schema'Class
(Self.Naming.all).Add_Directory (Path);
end Add_Search_Directory;
-----------------
-- Append_Unit --
-----------------
procedure Append_Unit
(Self : in out Context'Class;
Unit : Program.Compilation_Units.Compilation_Unit_Access)
is
Name : constant Program.Text := Unit.Full_Name;
Index : Program.Symbol_Lists.Symbol_List :=
Program.Symbol_Lists.Empty_Symbol_List; -- Standard's index is 0
begin
if Name /= "" then
Self.Symbols.Lists.Find_Or_Create (Name, Index);
end if;
if Unit.Is_Library_Unit_Declaration then
Self.Declarations.Map.Insert (Index, (Parsed, Unit));
Self.Declarations.List.Append (Index);
else
Self.Bodies.Map.Insert (Index, (Parsed, Unit));
Self.Bodies.List.Append (Index);
end if;
end Append_Unit;
-----------------------------
-- Compilation_Unit_Bodies --
-----------------------------
overriding function Compilation_Unit_Bodies (Self : Context)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access is
begin
if Self.Bodies.List.Is_Empty then
return null;
else
return Self.Bodies'Unchecked_Access;
end if;
end Compilation_Unit_Bodies;
-----------------------
-- Complete_Analysis --
-----------------------
procedure Complete_Analysis (Self : in out Context'Class) is
procedure Analyze
(Vector : in out Unit_Vector;
Symbol : Program.Symbol_Lists.Symbol_List);
-- Find and analyze all dependencies and then Unit itself, where Unit
-- is Vector.Map (Symbol).
procedure Analyze_Unit
(Unit : Program.Compilation_Units.Compilation_Unit_Access);
First : Boolean := True;
-------------
-- Analyze --
-------------
procedure Analyze
(Vector : in out Unit_Vector;
Symbol : Program.Symbol_Lists.Symbol_List)
is
use type Program.Symbol_Lists.Symbol_List;
Deps : Dependency (Self'Unchecked_Access);
Item : constant Unit_Map_Item := Vector.Map (Symbol);
begin
case Item.Status is
when Parsed =>
Vector.Map (Symbol).Status := Loading;
-- Don't look for dependencies of Standard
if Symbol /= Program.Symbol_Lists.Empty_Symbol_List then
Deps.Find_Dependecies
(Item.Unit,
Program.Unit_Dependencies
.Find_Semantic_Dependencies'Access);
-- All dependencies are parsed and listed in Deps
for J of Deps.Declarations loop
Analyze (Self.Declarations, J);
end loop;
for J of Deps.Bodies loop
Analyze (Self.Bodies, J);
end loop;
end if;
-- All dependencies analysed
Analyze_Unit (Item.Unit);
Vector.Map (Symbol).Status := Analysed;
when Loading =>
Self.Errors.Circular_Dependency (Item.Unit.Full_Name);
when Analysed =>
null; -- Nothing to do
end case;
end Analyze;
------------------
-- Analyze_Unit --
------------------
procedure Analyze_Unit
(Unit : Program.Compilation_Units.Compilation_Unit_Access)
is
Comp : constant Program.Compilations.Compilation_Access :=
Unit.Compilation;
Subpool : constant not null
System.Storage_Pools.Subpools.Subpool_Handle :=
Program.Plain_Compilations.Compilation (Comp.all).Subpool;
Unit_Name_Resolver : aliased
Program.Plain_Contexts.Unit_Name_Resolvers.Unit_Name_Resolver
(Self.Symbols.Lists'Unchecked_Access,
Self.Errors,
Self.Declarations'Unchecked_Access,
Self.Bodies'Unchecked_Access);
begin
if First then
First := False;
Program.Resolve_Standard
(Unit,
Self.Visible,
Self.Library_Env,
Subpool,
Self.Xref'Unchecked_Access);
else
Program.Resolvers.Resolve_Names
(Unit,
Unit_Name_Resolver'Unchecked_Access,
Self.Symbols.Lists,
Self.Visible'Unchecked_Access,
Self.Library_Env,
Self.Xref'Unchecked_Access);
end if;
end Analyze_Unit;
Item : Program.Symbol_Lists.Symbol_List;
Last_Decl : constant Natural := Self.Declarations.List.Last_Index;
Last_Body : constant Natural := Self.Bodies.List.Last_Index;
begin
for J in 1 .. Last_Decl loop
Item := Self.Declarations.List (J);
Analyze (Self.Declarations, Item);
end loop;
for J in 1 .. Last_Body loop
Item := Self.Bodies.List (J);
Analyze (Self.Bodies, Item);
end loop;
end Complete_Analysis;
-------------
-- Element --
-------------
overriding function Element
(Self : Unit_Vector;
Index : Positive)
return not null Program.Compilation_Units.Compilation_Unit_Access is
begin
return Self.Map (Self.List (Index)).Unit;
end Element;
----------
-- Find --
----------
function Find
(Self : Context'Class;
Value : Program.Text) return Program.Symbols.Symbol is
begin
return Self.Symbols.Find (Value);
end Find;
---------------------------
-- Find_Or_Create_Symbol --
---------------------------
procedure Find_Or_Create_Symbol
(Self : in out Context'Class;
Buffer : not null Program.Source_Buffers.Source_Buffer_Access;
Span : Program.Source_Buffers.Span;
Result : out Program.Symbols.Symbol) is
begin
Self.Symbols.Find_Or_Create (Buffer, Span, Result);
end Find_Or_Create_Symbol;
----------------------
-- Find_Dependecies --
----------------------
procedure Find_Dependecies
(Self : in out Dependency'Class;
Unit : Program.Compilation_Units.Compilation_Unit_Access;
Check : access procedure
(Unit : Program.Compilation_Units.Compilation_Unit_Access;
Lists : in out Program.Symbol_Lists.Symbol_List_Table'Class;
Report : in out Unit_Dependencies.Unit_Dependency_Listener'Class)) is
begin
Check (Unit, Self.Context.Symbols.Lists, Self);
end Find_Dependecies;
---------------
-- Find_Unit --
---------------
overriding function Find_Unit
(Self : Unit_Vector;
Name : Text) return Program.Compilation_Units.Compilation_Unit_Access
is
Cursor : constant Unit_Maps.Cursor := Self.Find_Unit (Name);
begin
if Unit_Maps.Has_Element (Cursor) then
return Unit_Maps.Element (Cursor).Unit;
else
return null;
end if;
end Find_Unit;
---------------
-- Find_Unit --
---------------
function Find_Unit
(Self : Unit_Vector'Class;
Name : Text) return Unit_Maps.Cursor
is
use type Program.Symbol_Lists.Symbol_List;
Result : constant Program.Symbol_Lists.Symbol_List :=
Self.Context.Symbols.Lists.Find (Name);
begin
if Result = Program.Symbol_Lists.Empty_Symbol_List
and then Name /= ""
then
return Unit_Maps.No_Element;
else
return Self.Map.Find (Result);
end if;
end Find_Unit;
----------------
-- Get_Length --
----------------
overriding function Get_Length (Self : Unit_Vector) return Positive is
begin
return Self.List.Last_Index;
end Get_Length;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Context'Class;
Errors : Program.Error_Listeners.Error_Listener_Access)
is
GNAT : constant Unit_Naming_Schema_Access := new
Program.GNAT_Unit_Naming.GNAT_Unit_Naming;
Dir : constant Unit_Naming_Schema_Access := new
Program.Directory_Unit_Schemas.Directory_Unit_Schema
(GNAT.all'Access);
begin
Self.Naming := Dir.all'Access;
Self.Errors := Errors;
Self.Symbols.Initialize;
end Initialize;
-----------------------
-- Immediate_Visible --
-----------------------
function Immediate_Visible
(Self : in out Context'Class;
Unit : Program.Text;
Name : Program.Text) return Program.Visibility.View_Iterator is
begin
Self.Visible.Enter_Snapshot
(Self.Library_Env.Public_View
(Self.Symbols.Lists.Find (Unit)));
return Self.Visible.Immediate_Visible (Self.Symbols.Find (Name));
end Immediate_Visible;
-------------------------------
-- Library_Unit_Declarations --
-------------------------------
overriding function Library_Unit_Declarations (Self : Context)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access is
begin
if Self.Declarations.List.Is_Empty then
return null;
else
return Self.Declarations'Unchecked_Access;
end if;
end Library_Unit_Declarations;
----------------
-- Parse_File --
----------------
procedure Parse_File
(Self : aliased in out Context'Class;
Text_Name : Text;
Standard : Boolean;
Units : out Program.Parsers.Unit_Vectors.Vector;
Pragmas : out Program.Parsers.Element_Vectors.Vector)
is
Pool : Program.Storage_Pools.Storage_Pool renames
Program.Storage_Pools.Pool;
Subpool : constant not null System.Storage_Pools.Subpools.Subpool_Handle
:= Pool.Create_Subpool;
Compilation : constant Plain_Compilation_Access :=
new Program.Plain_Compilations.Compilation (Subpool);
-- Plain_Compilation is a controlled type, so don't allocate it in
-- the (Subpool)
begin
Compilation.Initialize (Self'Unchecked_Access);
Compilation.Parse_File (Text_Name, Units, Pragmas, Standard);
Self.Compilations.Append
(Program.Compilations.Compilation_Access (Compilation));
end Parse_File;
----------------
-- Parse_File --
----------------
procedure Parse_File
(Self : aliased in out Context'Class;
Text_Name : Text)
is
Units : Program.Parsers.Unit_Vectors.Vector;
Pragmas : Program.Parsers.Element_Vectors.Vector;
begin
Self.Parse_File (Text_Name, False, Units, Pragmas);
for Unit of Units loop
Self.Append_Unit (Unit);
end loop;
end Parse_File;
-------------------
-- Required_Body --
-------------------
overriding procedure Required_Body
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List)
is
Units : Program.Parsers.Unit_Vectors.Vector;
Pragmas : Program.Parsers.Element_Vectors.Vector;
Unit : Program.Compilation_Units.Compilation_Unit_Access;
Found : constant Unit_Maps.Cursor :=
Self.Context.Bodies.Map.Find (Name);
Full_Name : constant Program.Text :=
Self.Context.Symbols.Lists.Symbol_List_Text (Name);
Text_Name : constant Program.Text :=
Self.Context.Naming.Body_Text_Name (Full_Name);
begin
if Unit_Maps.Has_Element (Found) then
Self.Bodies.Append (Unit_Maps.Key (Found));
return;
elsif Text_Name = "" then
Self.Context.Errors.No_Body_Text (Full_Name);
return; -- TODO: Mark self.context as failed?
else
Self.Context.Parse_File
(Text_Name => Text_Name,
Standard => False,
Units => Units,
Pragmas => Pragmas);
end if;
pragma Assert (Units.Last_Index = 1); -- TODO: Check unit.name = Name?
if Units.Last_Index = 1 then
Unit := Units (1);
pragma Assert (Unit.Is_Library_Unit_Body);
Self.Context.Append_Unit (Unit);
Self.Bodies.Append (Self.Context.Bodies.List.Last_Element);
end if;
end Required_Body;
--------------------------
-- Required_Declaration --
--------------------------
overriding procedure Required_Declaration
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List;
If_Any : Boolean := False)
is
use type Program.Symbol_Lists.Symbol_List;
Units : Program.Parsers.Unit_Vectors.Vector;
Pragmas : Program.Parsers.Element_Vectors.Vector;
Unit : Program.Compilation_Units.Compilation_Unit_Access;
Is_Standard : constant Boolean :=
Name = Program.Symbol_Lists.Empty_Symbol_List;
Found : constant Unit_Maps.Cursor :=
Self.Context.Declarations.Map.Find (Name);
Full_Name : constant Program.Text :=
Self.Context.Symbols.Lists.Symbol_List_Text (Name);
function Text_Name return Program.Text;
function Text_Name return Program.Text is
begin
if Is_Standard then
return Self.Context.Naming.Standard_Text_Name;
else
return Self.Context.Naming.Declaration_Text_Name (Full_Name);
end if;
end Text_Name;
begin
if Unit_Maps.Has_Element (Found) then
Self.Declarations.Append (Unit_Maps.Key (Found));
return;
elsif If_Any and not Is_Standard and Text_Name = "" then
null; -- Optional unit not found
else
Self.Context.Parse_File
(Text_Name => Text_Name,
Standard => Is_Standard,
Units => Units,
Pragmas => Pragmas);
end if;
pragma Assert
(Units.Last_Index = 1 or
(Units.Last_Index = 0 and If_Any));
if Units.Last_Index = 1 then
Unit := Units (1);
pragma Assert (Unit.Is_Library_Unit_Declaration);
Self.Context.Append_Unit (Unit);
Self.Declarations.Append
(Self.Context.Declarations.List.Last_Element);
end if;
end Required_Declaration;
-------------------
-- Required_Unit --
-------------------
overriding procedure Required_Unit
(Self : in out Dependency;
Name : Program.Symbol_Lists.Symbol_List;
Is_Limited : Boolean)
is
Saved_Count : constant Natural := Self.Declarations.Last_Index;
begin
pragma Assert (not Is_Limited);
Self.Required_Declaration (Name, If_Any => True);
if Saved_Count = Self.Declarations.Last_Index then
Self.Required_Body (Name);
end if;
end Required_Unit;
-------------------------------------
-- Set_Corresponding_Defining_Name --
-------------------------------------
overriding procedure Set_Corresponding_Defining_Name
(Self : in out Reference_Updater;
Name : not null Program.Elements.Element_Access;
Def : Program.Elements.Defining_Names.Defining_Name_Access)
is
pragma Unreferenced (Self);
begin
if Name.Is_Identifier then
Program.Nodes.Identifiers.Set_Defining_Name
(Name.To_Identifier,
Def.To_Defining_Identifier);
elsif Name.Is_Operator_Symbol then
Program.Nodes.Operator_Symbols.Set_Defining_Name
(Name.To_Operator_Symbol,
Def.To_Defining_Operator_Symbol);
else
raise Program_Error;
end if;
end Set_Corresponding_Defining_Name;
end Program.Plain_Contexts;
|
alloy4fun_models/trainstlt/models/13/CtJ7kQF3K5spPC9YF.als | Kaixi26/org.alloytools.alloy | 0 | 4660 | open main
pred idCtJ7kQF3K5spPC9YF_prop14 {
always ( all t:Train | (some t.pos and one (t.pos.signal :>Green) )implies (t.pos != t.pos' and t.pos.signal in Signal-Green) )
}
pred __repair { idCtJ7kQF3K5spPC9YF_prop14 }
check __repair { idCtJ7kQF3K5spPC9YF_prop14 <=> prop14o } |
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2983.asm | ljhsiun2/medusa | 9 | 1159 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x3fb4, %r15
nop
nop
nop
sub $22092, %r12
movb $0x61, (%r15)
nop
xor $18736, %rdi
lea addresses_UC_ht+0x16e54, %r11
nop
nop
nop
xor $46811, %r13
mov (%r11), %rdi
nop
nop
sub %r15, %r15
lea addresses_UC_ht+0x14bb4, %r9
nop
cmp %rdi, %rdi
vmovups (%r9), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %r15
dec %r11
lea addresses_WT_ht+0x171c4, %r9
nop
nop
nop
nop
add $47751, %r13
vmovups (%r9), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %r12
and $25121, %rdi
lea addresses_normal_ht+0x908d, %r12
nop
nop
nop
nop
nop
add $55656, %rcx
movb $0x61, (%r12)
nop
cmp %rdi, %rdi
lea addresses_A_ht+0x1a5f4, %r15
nop
nop
cmp $58362, %r9
mov $0x6162636465666768, %r11
movq %r11, %xmm3
vmovups %ymm3, (%r15)
nop
nop
nop
xor $53920, %r12
lea addresses_WT_ht+0x10eb4, %r9
and %rdi, %rdi
movl $0x61626364, (%r9)
nop
nop
nop
nop
nop
xor %rdi, %rdi
lea addresses_A_ht+0xd754, %r13
nop
nop
nop
nop
and %r15, %r15
mov $0x6162636465666768, %rcx
movq %rcx, %xmm5
movups %xmm5, (%r13)
xor %rdi, %rdi
lea addresses_UC_ht+0x333c, %rcx
nop
nop
nop
nop
add $55076, %rdi
mov $0x6162636465666768, %r11
movq %r11, (%rcx)
nop
nop
xor $13386, %r13
lea addresses_WC_ht+0x381d, %rsi
lea addresses_UC_ht+0xa484, %rdi
nop
nop
nop
sub $805, %r9
mov $34, %rcx
rep movsl
nop
xor $1081, %rsi
lea addresses_normal_ht+0x11d1a, %r11
clflush (%r11)
nop
nop
nop
nop
nop
and %rsi, %rsi
movl $0x61626364, (%r11)
nop
nop
nop
xor %rcx, %rcx
lea addresses_D_ht+0x1f5c, %rsi
lea addresses_WT_ht+0xb14, %rdi
nop
and %r12, %r12
mov $4, %rcx
rep movsw
nop
nop
nop
nop
inc %r9
lea addresses_normal_ht+0x43d4, %rsi
lea addresses_A_ht+0x7fd4, %rdi
nop
sub %r11, %r11
mov $44, %rcx
rep movsl
nop
add $12763, %r11
lea addresses_WT_ht+0x7d92, %rsi
lea addresses_WT_ht+0x105d4, %rdi
nop
nop
nop
nop
nop
mfence
mov $44, %rcx
rep movsw
inc %r11
lea addresses_D_ht+0x159d4, %rsi
lea addresses_WT_ht+0x19fd4, %rdi
clflush (%rdi)
nop
nop
nop
xor %r12, %r12
mov $65, %rcx
rep movsl
nop
nop
nop
nop
nop
sub %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r8
push %rbp
push %rcx
push %rdi
// Store
lea addresses_normal+0x1bad4, %r8
nop
nop
and %rdi, %rdi
mov $0x5152535455565758, %rcx
movq %rcx, (%r8)
nop
nop
nop
cmp $13915, %r8
// Load
lea addresses_US+0x1fcd4, %rcx
nop
nop
nop
add $8977, %r12
mov (%rcx), %bp
cmp %rcx, %rcx
// Store
mov $0x6666880000000c14, %r13
add $51418, %rcx
movb $0x51, (%r13)
xor $60378, %r13
// Faulty Load
lea addresses_normal+0x67d4, %rbp
nop
xor %rcx, %rcx
vmovups (%rbp), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rdi
lea oracles, %r14
and $0xff, %rdi
shlq $12, %rdi
mov (%r14,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_US', 'same': False, 'size': 2, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': True, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT_ht', 'same': True, 'size': 4, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
proofs/AKS/Nat/Divisibility.agda | mckeankylej/thesis | 1 | 14954 | <reponame>mckeankylej/thesis
open import Relation.Nullary.Decidable using (False)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; cong₂)
open import Relation.Binary.PropositionalEquality.WithK using (≡-erase)
module AKS.Nat.Divisibility where
open import Data.Nat.Divisibility using (_∣_) public
open import Agda.Builtin.Nat using () renaming (mod-helper to modₕ; div-helper to divₕ) public
open import Data.Nat.DivMod using (_/_; _%_; %-distribˡ-+) public
open import Data.Nat.DivMod.Core using (a≤n⇒a[modₕ]n≡a)
open import Data.Nat.DivMod using (/-congˡ; /-congʳ) renaming (m≡m%n+[m/n]*n to div-lemma)
open import AKS.Nat.Base using (ℕ; _+_; _*_; _∸_; _≟_; lte; _≤_; _<_)
open ℕ
open import AKS.Nat.Properties using (+-suc)
open import AKS.Nat.Properties using (m≤m+n; m≤n+m; suc-mono-≤; ∸-mono-≤ˡ; +-lower-≤; ≤-refl; ≢⇒¬≟; module ≤-Reasoning)
open import AKS.Nat.Properties using (*-comm; +-identityʳ)
open ≤-Reasoning
import Data.Nat.DivMod as Nat
import Data.Nat.Properties as Nat
open import Data.Nat.Properties using (*-zeroʳ)
open import Polynomial.Simple.AlmostCommutativeRing.Instances using (module Nat)
open import Polynomial.Simple.Reflection using (solve)
a[modₕ]n≤n : ∀ acc d n → modₕ acc (acc + n) d n ≤ acc + n
a[modₕ]n≤n acc zero n = m≤m+n
a[modₕ]n≤n acc (suc d) zero = a[modₕ]n≤n zero d (acc + 0)
a[modₕ]n≤n acc (suc d) (suc n) rewrite +-suc acc n = a[modₕ]n≤n (suc acc) d n
n%m<m : ∀ n m {≢0 : False (m ≟ 0)} → (n % m) {≢0} < m
n%m<m n (suc m) = suc-mono-≤ (a[modₕ]n≤n 0 n m)
a[modₕ]n≤a : ∀ acc a n → modₕ acc (acc + n) a n ≤ acc + a
a[modₕ]n≤a acc zero n rewrite +-identityʳ acc = ≤-refl
a[modₕ]n≤a acc (suc a) (suc n) = begin
modₕ acc (acc + suc n) (suc a) (suc n) ≡⟨ cong (λ v → modₕ acc v (suc a) (suc n)) (+-suc acc n) ⟩
modₕ acc (suc acc + n) (suc a) (suc n) ≤⟨ a[modₕ]n≤a (suc acc) a n ⟩
suc acc + a ≡⟨ sym (+-suc acc a) ⟩
acc + suc a ∎
a[modₕ]n≤a acc (suc a) zero = begin
modₕ acc (acc + 0) (suc a) 0 ≡⟨ cong (λ v → modₕ acc v (suc a) 0) (+-identityʳ acc) ⟩
modₕ acc acc (suc a) 0 ≤⟨ a[modₕ]n≤a 0 a acc ⟩
a ≤⟨ m≤n+m ⟩
suc a ≤⟨ m≤n+m ⟩
acc + suc a ∎
n%m≤n : ∀ n m {≢0} → (n % m) {≢0} ≤ n
n%m≤n n (suc m) = a[modₕ]n≤a 0 n m
n<m⇒n%m≡n : ∀ {n m} {≢0 : False (m ≟ 0)} → n < m → (n % m) {≢0} ≡ n
n<m⇒n%m≡n {n} {suc m} (lte k refl) = ≡-erase (a≤n⇒a[modₕ]n≡a 0 (n + k) n k)
0%m≡0 : ∀ m {≢0 : False (m ≟ 0)} → (0 % m) {≢0} ≡ 0
0%m≡0 (suc m) = refl
1%m≡1 : ∀ {m} {≢0} → 1 < m → (1 % m) {≢0} ≡ 1
1%m≡1 {suc (suc m)} 1<m = refl
record Euclidean (n : ℕ) (m : ℕ) : Set where
constructor Euclidean✓
field
q : ℕ
r : ℕ
division : n ≡ r + m * q
r<m : r < m
m≡m%n+[m/n]*n : ∀ m n {n≢0 : False (n ≟ 0)} → m ≡ (m % n) {n≢0} + (m / n) {n≢0} * n
m≡m%n+[m/n]*n m (suc n) = div-lemma m n
m%n≡m∸m/n*n : ∀ m n {n≢0 : False (n ≟ 0)} → (m % n) {n≢0} ≡ m ∸ (m / n) {n≢0} * n
m%n≡m∸m/n*n m (suc n) = Nat.m%n≡m∸m/n*n m n
m%n%n≡m%n : ∀ m n {n≢0 : False (n ≟ 0)} → ((m % n) {n≢0} % n) {n≢0} ≡ (m % n) {n≢0}
m%n%n≡m%n m (suc n) = Nat.m%n%n≡m%n m n
n%n≡0 : ∀ n {n≢0 : False (n ≟ 0)} → (n % n) {n≢0} ≡ 0
n%n≡0 (suc n) = Nat.n%n≡0 n
[m+kn]%n≡m%n : ∀ m k n {n≢0 : False (n ≟ 0)} → ((m + k * n) % n) {n≢0} ≡ (m % n) {n≢0}
[m+kn]%n≡m%n m k (suc n) = Nat.[m+kn]%n≡m%n m k n
%-distribˡ-* : ∀ m n d {≢0} → ((m * n) % d) {≢0} ≡ (((m % d) {≢0} * (n % d) {≢0}) % d) {≢0}
%-distribˡ-* m n (suc d) = begin-equality
(m * n) % suc d ≡⟨ cong (λ x → (x * n) % suc d) (m≡m%n+[m/n]*n m (suc d)) ⟩
((m % suc d + m / suc d * suc d) * n) % suc d ≡⟨ cong (λ x → x % suc d) (Nat.*-distribʳ-+ n (m % suc d) (m / suc d * suc d)) ⟩
((m % suc d) * n + (m / suc d * suc d) * n) % suc d ≡⟨ cong (λ x → ((m % suc d) * n + x) % suc d) (lemma (m / suc d) (suc d) n) ⟩
((m % suc d) * n + (m / suc d * n) * suc d) % suc d ≡⟨ Nat.[m+kn]%n≡m%n ((m % suc d) * n) (m / suc d * n) d ⟩
((m % suc d) * n) % suc d ≡⟨ cong (λ x → ((m % suc d) * x) % suc d) (m≡m%n+[m/n]*n n (suc d)) ⟩
((m % suc d) * (n % suc d + n / suc d * suc d)) % suc d ≡⟨ cong (λ x → x % suc d) (Nat.*-distribˡ-+ (m % suc d) (n % suc d) (n / suc d * suc d)) ⟩
((m % suc d) * (n % suc d) + (m % suc d) * (n / suc d * suc d)) % suc d ≡⟨ cong (λ x → ((m % suc d) * (n % suc d) + x) % suc d) (sym (Nat.*-assoc (m % suc d) (n / suc d) (suc d))) ⟩
((m % suc d) * (n % suc d) + ((m % suc d) * (n / suc d)) * suc d) % suc d ≡⟨ Nat.[m+kn]%n≡m%n ((m % suc d) * (n % suc d)) ((m % suc d) * (n / suc d)) d ⟩
((m % suc d) * (n % suc d)) % suc d ∎
where
lemma : ∀ x y z → (x * y) * z ≡ (x * z) * y
lemma = solve Nat.ring
[m∸n]%n≡m%n : ∀ m n {n≢0 : False (n ≟ 0)} → n ≤ m → ((m ∸ n) % n) {n≢0} ≡ (m % n) {n≢0}
[m∸n]%n≡m%n (suc .(n + k)) (suc n) (lte k refl) = begin-equality
((suc n + k) ∸ suc n) % suc n ≡⟨ cong (λ t → t % suc n) (Nat.m+n∸m≡n (suc n) k) ⟩
k % suc n ≡⟨ sym (Nat.[m+n]%n≡m%n k n) ⟩
(k + suc n) % suc n ≡⟨ cong (λ t → t % suc n) (Nat.+-comm k (suc n)) ⟩
(suc n + k) % suc n ∎
[m∸kn]%n≡m%n : ∀ m k n {n≢0 : False (n ≟ 0)} → k * n ≤ m → ((m ∸ k * n) % n) {n≢0} ≡ (m % n) {n≢0}
[m∸kn]%n≡m%n m zero (suc n) n≤m = refl
[m∸kn]%n≡m%n m (suc k) (suc n) k*n≤m = begin-equality
(m ∸ (suc n + k * suc n)) % suc n ≡⟨ cong (λ t → t % suc n) (sym (Nat.∸-+-assoc m (suc n) (k * suc n))) ⟩
((m ∸ suc n) ∸ k * suc n) % suc n ≡⟨ [m∸kn]%n≡m%n (m ∸ suc n) k (suc n) k*n≤m∸n ⟩
(m ∸ suc n) % suc n ≡⟨ [m∸n]%n≡m%n m (suc n) (+-lower-≤ (k * suc n) k*n≤m) ⟩
m % suc n ∎
where
k*n≤m∸n : k * suc n ≤ m ∸ suc n
k*n≤m∸n = begin
k * suc n ≡⟨ sym (Nat.m+n∸m≡n (suc n) (k * suc n)) ⟩
(suc n + k * suc n) ∸ suc n ≤⟨ ∸-mono-≤ˡ {suc n} m≤m+n k*n≤m ⟩
m ∸ suc n ∎
%-distribˡ-∸ : ∀ m n d {≢0} → n ≤ m → ((m ∸ n) % d) {≢0} ≡ ((m ∸ (n % d) {≢0}) % d) {≢0}
%-distribˡ-∸ m n (suc d) n≤m = begin-equality
(m ∸ n) % suc d ≡⟨ cong (λ t → (m ∸ t) % suc d) (m≡m%n+[m/n]*n n (suc d)) ⟩
(m ∸ (n % suc d + n / suc d * suc d)) % suc d ≡⟨ cong (λ t → t % suc d) (sym (Nat.∸-+-assoc m (n % suc d) (n / suc d * suc d))) ⟩
((m ∸ n % suc d) ∸ n / suc d * suc d) % suc d ≡⟨ [m∸kn]%n≡m%n (m ∸ n % suc d) (n / suc d) (suc d) n/d*d≤m∸n%d ⟩
(m ∸ n % suc d) % suc d ∎
where
n/d*d≤m∸n%d : n / suc d * suc d ≤ m ∸ n % suc d
n/d*d≤m∸n%d = begin
n / suc d * suc d ≡⟨ sym (Nat.m+n∸m≡n (n % suc d) (n / suc d * suc d)) ⟩
(n % suc d + n / suc d * suc d) ∸ n % suc d ≡⟨ cong (λ t → t ∸ n % suc d) (sym (m≡m%n+[m/n]*n n (suc d))) ⟩
n ∸ n % suc d ≤⟨ ∸-mono-≤ˡ {n % suc d} (n%m≤n n (suc d)) n≤m ⟩
m ∸ n % suc d ∎
open import AKS.Unsafe using (trustMe)
/-cancelˡ : ∀ c a b {b≢0} {b*c≢0} → ((c * a) / (c * b)) {b*c≢0} ≡ (a / b) {b≢0}
/-cancelˡ (suc c) a (suc b) {b≢0} {b*c≢0} = trustMe
/-cancelʳ : ∀ c a b {b≢0} {b*c≢0} → ((a * c) / (b * c)) {b*c≢0} ≡ (a / b) {b≢0}
/-cancelʳ c a b {b≢0} {b*c≢0} = begin-equality
(a * c) / (b * c) ≡⟨ /-congˡ {o≢0 = b*c≢0} (*-comm a c) ⟩
(c * a) / (b * c) ≡⟨ /-congʳ (*-comm b c) ⟩
(c * a) / (c * b) ≡⟨ /-cancelˡ c a b {b≢0} {c*b≢0} ⟩
a / b ∎
where
c*b≢0 : False (c * b ≟ 0)
c*b≢0 rewrite *-comm b c = b*c≢0
_div_ : ∀ n m {≢0 : False (m ≟ 0)} → Euclidean n m
n div suc m = Euclidean✓ (n / suc m) (n % suc m) (≡-erase div-proof) (n%m<m n (suc m))
where
div-proof : n ≡ n % suc m + suc m * (n / suc m)
div-proof rewrite *-comm (suc m) (n / suc m) = m≡m%n+[m/n]*n n (suc m)
|
EngineHacks/CoreHacks/ModularLevelUp/LevelUpScreen/MagChaMiscASM/MagCha.asm | MokhaLeee/FE16re-Proto | 5 | 175655 | .thumb
.include "_Definitions.h.s"
.global Get_New_Charm
.type Get_New_Charm, function
Get_New_Charm:
ldr r1, =gMapAnimData
lsl r0, r2, #2
add r0, r0, r2
lsl r0, r0, #2
add r1, #4
add r0, r1
ldr r0,[r0]
blh GetBu_ChangeChaAt
ldrb r0,[r0]
lsl r0, #0x18
lsr r0, #0x18
pop {r1}
bx r1
.ltorg
.align
.global Get_New_Magic
.type Get_New_Magic, function
Get_New_Magic:
ldr r1, =gMapAnimData
lsl r0, r2, #2
add r0, r0, r2
lsl r0, r0, #2
add r1, #4
add r0, r1
ldr r0,[r0]
blh GetBu_ChangeMagAt
ldrb r0,[r0]
lsl r0, #0x18
lsr r0, #0x18
pop {r1}
bx r1
.ltorg
.align
.global Get_Original_Charm
.type Get_Original_Charm, function
Get_Original_Charm:
mov r0, r2
_blh1 GetChaAt
ldrb r0,[r0]
lsl r0, #0x18
lsr r0, #0x18
pop {r4, r5} @Vanilla 7EDE4
pop {r1}
bx r1
.ltorg
.align
.global Get_Original_Magic
.type Get_Original_Magic, function
Get_Original_Magic:
mov r0, r2
_blh1 GetMagAt
ldrb r0,[r0]
lsl r0, #0x18
lsr r0, #0x18
pop {r4, r5} @Vanilla 7EDE4
pop {r1}
bx r1
|
pkgs/tools/yasm/src/modules/parsers/nasm/tests/uscore.asm | manggoguy/parsec-modified | 2,151 | 242369 | <filename>pkgs/tools/yasm/src/modules/parsers/nasm/tests/uscore.asm
dq 0000_1111_2222_3333h
dq 0000111122223333h
dd 0x01_23_45_67
dd 0x01234567
dw 1_2_3_4q
dw 1234q
db 00_11_00_11b
db 00110011b
_0:
dw _0
|
Task/Flow-control-structures/Ada/flow-control-structures-3.ada | LaudateCorpus1/RosettaCodeData | 1 | 5614 | select
delay 10.0;
Put_Line ("Cannot finish this in 10s");
then abort
-- do some lengthy calculation
...
end select;
|
source/amf/mof/cmof/amf-internals-cmof_namespaces.ads | svn2github/matreshka | 24 | 25112 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Constraints.Collections;
with AMF.CMOF.Element_Imports.Collections;
with AMF.CMOF.Named_Elements.Collections;
with AMF.CMOF.Namespaces;
with AMF.CMOF.Package_Imports.Collections;
with AMF.CMOF.Packageable_Elements.Collections;
with AMF.Internals.CMOF_Named_Elements;
generic
type Named_Element_Proxy is
abstract new AMF.Internals.CMOF_Named_Elements.CMOF_Named_Element_Proxy
with private;
package AMF.Internals.CMOF_Namespaces is
type CMOF_Namespace_Proxy is
abstract limited new Named_Element_Proxy
and AMF.CMOF.Namespaces.CMOF_Namespace with null record;
overriding function Get_Element_Import
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Element_Imports.Collections.Set_Of_CMOF_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Constraints.Collections.Set_Of_CMOF_Constraint;
-- Getter of Namespace::ownedRule.
overriding function Get_Package_Import
(Self : not null access constant CMOF_Namespace_Proxy)
return AMF.CMOF.Package_Imports.Collections.Set_Of_CMOF_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
end AMF.Internals.CMOF_Namespaces;
|
demo/agda/FRP/JS/Demo/Calculator/View.agda | agda/agda-frp-js | 63 | 13412 | open import FRP.JS.Behaviour using ( Beh ; [_] ; map )
open import FRP.JS.Event using ( Evt ; tag )
open import FRP.JS.DOM using
( DOM ; click ; element ; text ; _++_ ; element+ ; text+ ; listen+ ; _+++_ )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Product using ( _∧_ ; _,_ )
open import FRP.JS.Demo.Calculator.Model using
( Button ; State ; digit ; op ; clear ; eq ; plus ; minus ; times ; button$ ; state$ ; model )
module FRP.JS.Demo.Calculator.View where
button : ∀ {w} → Button → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
button b = listen+ click (λ _ → b) (element+ "button" (text+ [ button$ b ]))
keypad : ∀ {w} → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
keypad =
element+ "div" (button (digit 7) +++ button (digit 8) +++ button (digit 9) ) +++
element+ "div" (button (digit 4) +++ button (digit 5) +++ button (digit 6) ) +++
element+ "div" (button (digit 1) +++ button (digit 2) +++ button (digit 3) ) +++
element+ "div" (button (op eq) +++ button (digit 0) +++ button clear ) +++
element+ "div" (button (op plus) +++ button (op minus) +++ button (op times))
display : ∀ {w} → ⟦ Beh ⟨ State ⟩ ⇒ Beh (DOM w) ⟧
display σ = element "div" (text (map state$ σ))
view : ∀ {w} → ⟦ Beh (DOM w) ⟧
view with keypad
... | (dom , evt) = display (model evt) ++ dom |
2.0/cpm20_code/xsub0.asm | officialrafsan/CP-M | 0 | 80030 | version equ 20h
; xsub relocator program, included with the module
; to perform the move from 200h to the destination address
;
; copyright (c) 1979
; digital research
; box 579
; pacific grove, ca.
; 93950
;
org 100h
db (lxi or (b shl 3)) ;lxi b,module size
org $+2 ;skip address field
jmp start
db ' Extended Submit Vers '
db version/16+'0','.',version mod 16+'0'
db ', Copyright (c) 1979, Digital Research '
nogo: db 'Extended Submit Already Present$'
badver: db 'Requires CP/M Version 2.0 or later$'
;
bdos equ 0005h ;bdos entry point
print equ 9 ;bdos print function
vers equ 12 ;get version number
ccplen equ 0800h ;size of ccp
module equ 200h ;module address
;
start:
; ccp's stack used throughout
push b ;save the module's length
lda bdos+1 ;xsub already present?
cpi 06h ;low address must be 06h
jz continue
;
; bdos is not lowest module in memory, return to ccp
mvi c,print
lxi d,nogo ;already present message
call bdos ;to print the message
pop b ;recall length
ret ;to the ccp
;
continue:
mvi c,vers
call bdos ;version number?
cpi version ;2.0 or greater
jnc versok
;
; wrong version
mvi c,print
lxi d,badver
call bdos
pop b
ret ;to ccp
;
versok:
lxi h,bdos+2;address field of jump to bdos (top memory)
mov a,m ;a has high order address of memory top
dcr a ;page directly below bdos
sui (ccplen shr 8) ;-ccp pages
pop b ;recall length of module
push b ;and save it again
sub b ;a has high order address of reloc area
mov d,a
mvi e,0 ;d,e addresses base of reloc area
push d ;save for relocation below
;
lxi h,module;ready for the move
move: mov a,b ;bc=0?
ora c
jz reloc
dcx b ;count module size down to zero
mov a,m ;get next absolute location
stax d ;place it into the reloc area
inx d
inx h
jmp move
;
reloc: ;storage moved, ready for relocation
; hl addresses beginning of the bit map for relocation
pop d ;recall base of relocation area
pop b ;recall module length
push h ;save bit map base in stack
mov h,d ;relocation bias is in d
;
rel0: mov a,b ;bc=0?
ora c
jz endrel
;
; not end of the relocation, may be into next byte of bit map
dcx b ;count length down
mov a,e
ani 111b ;0 causes fetch of next byte
jnz rel1
; fetch bit map from stacked address
xthl
mov a,m ;next 8 bits of map
inx h
xthl ;base address goes back to stack
mov l,a ;l holds the map as we process 8 locations
rel1: mov a,l
ral ;cy set to 1 if relocation necessary
mov l,a ;back to l for next time around
jnc rel2 ;skip relocation if cy=0
;
; current address requires relocation
ldax d
add h ;apply bias in h
stax d
rel2: inx d ;to next address
jmp rel0 ;for another byte to relocate
;
endrel: ;end of relocation
pop d ;clear stacked address
; h has the high order 8-bits of relocated module address
mvi l,0
pchl ;go to relocated program
end
|
programs/oeis/100/A100119.asm | neoneye/loda | 22 | 103922 | <reponame>neoneye/loda<filename>programs/oeis/100/A100119.asm<gh_stars>10-100
; A100119: a(n) = n-th centered n-gonal number.
; 1,2,7,19,41,76,127,197,289,406,551,727,937,1184,1471,1801,2177,2602,3079,3611,4201,4852,5567,6349,7201,8126,9127,10207,11369,12616,13951,15377,16897,18514,20231,22051,23977,26012,28159,30421,32801,35302,37927,40679,43561,46576,49727,53017,56449,60026,63751,67627,71657,75844,80191,84701,89377,94222,99239,104431,109801,115352,121087,127009,133121,139426,145927,152627,159529,166636,173951,181477,189217,197174,205351,213751,222377,231232,240319,249641,259201,269002,279047,289339,299881,310676,321727,333037,344609,356446,368551,380927,393577,406504,419711,433201,446977,461042,475399,490051
sub $1,$0
bin $1,2
mul $1,$0
add $1,1
mov $0,$1
|
Driver/Video/Dumb/VidMem/Main/mainTables.asm | steakknife/pcgeos | 504 | 162546 | COMMENT @-----------------------------------------------------------------------
Copyright (c) Berkeley Softworks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Video memory driver
FILE: mainTables.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jim 8/89 Initial version
DESCRIPTION:
This file contains tables for the memory video driver
$Id: mainTables.asm,v 1.1 97/04/18 11:42:43 newdeal Exp $
------------------------------------------------------------------------------@
;----------------------------------------------------------------------------
; Driver jump table (used by DriverStrategy)
;----------------------------------------------------------------------------
driverJumpTable label word
word offset Main:VidInit ;intiialization
word offset Main:VideoNull ;last gasp
word offset Main:VideoNullCLCOnly ;suspend
word offset Main:VideoNullCLCOnly ;unsuspend
word offset Main:VideoNull ;test device existence
word offset Main:VideoNull ;set device enum
word offset Main:VidInfo ;get ptr to info block
word offset Main:VideoNull ;get exclusive
word offset Main:VideoNull ;start exclusive
word offset Main:VideoNull ;end exclusive
word offset Main:VidCallMod ; get a pixel color
word offset Main:VidCallMod ; get some bits
word offset Main:VideoNull ;set the ptr pic
word offset Main:VideoNull ;hide the cursor
word offset Main:VideoNull ;show the cursor
word offset Main:VideoNull ;move the cursor
word offset Main:VideoNullSet ;set save under area
word offset Main:VideoNullSet ;restore save under area
word offset Main:VideoNull ;nuke save under area
word offset Main:VideoNull ;request save under
word offset Main:VideoNull ;check save under
word offset Main:VideoNull ;get save under info
word offset Main:VideoNull ;get save under info
word offset Main:VideoNull ;dummy routine
word offset Main:VideoNull ;dummy routine
word offset Main:VidCallMod ; rectangle
word offset Main:VidCallMod ; char string
word offset Main:VidCallMod ; bitblt
word offset Main:VidCallMod ; putbits
word offset Main:VidCallMod ; drawline
word offset Main:VidCallMod ; drawregion
word offset Main:VidCallMod ; putline
word offset Main:VidCallMod ; polygon
word offset Main:VideoNull ; screen on
word offset Main:VideoNull ; screen off
word offset Main:VidCallMod ; polyline
word offset Main:VidCallMod ; dash line
word offset Main:VidCallMod ; dash fill
word offset Main:VidSetPalette ; SetPalette
word offset Main:VidGetPalette ; GetPalette
.assert ($-driverJumpTable) eq VidFunction
|
test_file/test_file_no_import.asm | drobotun/pefile_scripts | 0 | 3764 | <reponame>drobotun/pefile_scripts<gh_stars>0
format PE64 GUI
include 'win64ax.inc'
.data
test_data db 0x34
.code
start:
mov eax, test_data
.end start
|
src/asm_files/saveStateTests/saveState.asm | zedth2/sunyat-c | 0 | 85643 | <gh_stars>0
.constant TERM 0xFF
.constant CR 0xD
.constant LF 0xA
jmp !main
!crlf
.variable crlf0 CR
.variable crlf1 LF
.variable crlf2 0x00
!main
mov R0 'F'
mov R1 'U'
mov R2 'C'
mov R3 'K'
mov R4 ' '
mov R5 'Y'
mov R6 'O'
mov R7 'U'
aux 0
stor TERM R0
stor TERM R1
stor TERM R2
stor TERM R3
stor TERM R4
stor TERM R5
stor TERM R6
stor TERM R7
!wait
jmp !wait
!wait_end
ret
!main_end |
tests/vice-tests/VIC20/viavarious/via5a.asm | PhylumChordata/chips-test | 330 | 24086 | !to "via5a.prg", cbm
TESTID = 5
tmp=$fc
addr=$fd
add2=$f9
ERRBUF = $1f00
TMP = $2000 ; measured data on C64 side
DATA = $3000 ; reference data
TESTLEN = $20
NUMTESTS = 18 - 12
TESTSLOC = $1800
DTMP=screenmem
!src "common.asm"
* = TESTSLOC
;------------------------------------------
; before: --
; in the loop:
; [Timer B lo | Timer B hi] = loop counter
; start Timer B (set to count CLK)
; read [Timer B lo | Timer B hi | IRQ Flags]
!zone { ; M
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$8 ; Timer B lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; N
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$9 ; Timer B hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; O
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$8 ; Timer B lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; P
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$9 ; Timer B hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; Q
.test ldx #0
.l1 stx viabase+$8 ; Timer B lo
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; R
.test ldx #0
.l1 stx viabase+$9 ; Timer B hi
;lda #$11
;sta $dc0f ; start timer B continuous, force reload
lda #%00000000
sta viabase+$b
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
* = DATA
!bin "via5aref.bin", NUMTESTS * $0100, 2
|
Applications/Finder/reveal/reveal (path to me).applescript | looking-for-a-job/applescript-examples | 1 | 1898 | #!/usr/bin/osascript
tell application "Finder"
reveal (path to me)
end tell |
src/Categories/Theory/Lawvere.agda | bond15/agda-categories | 0 | 15800 | {-# OPTIONS --without-K --safe #-}
-- a categorical (i.e. non-skeletal) version of Lawvere Theory,
-- as per https://ncatlab.org/nlab/show/Lawvere+theory
module Categories.Theory.Lawvere where
open import Data.Nat using (ℕ)
open import Data.Product using (Σ; _,_)
open import Level
open import Categories.Category.Cartesian
open import Categories.Category using (Category; _[_,_])
open import Categories.Category.Instance.Setoids
open import Categories.Category.Monoidal.Instance.Setoids using (Setoids-Cartesian)
open import Categories.Category.Product
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.Functor.Cartesian
open import Categories.Functor.Cartesian.Properties
import Categories.Morphism as Mor
open import Categories.NaturalTransformation using (NaturalTransformation)
private
variable
o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level
record FiniteProduct (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
field
T : Category o ℓ e
open Mor T
field
cart : Cartesian T
generic : Category.Obj T
open Cartesian cart using (power)
field
obj-iso-to-generic-power : (x : Category.Obj T) → Σ ℕ (λ n → x ≅ power generic n)
record LT-Hom (T₁ : FiniteProduct o ℓ e) (T₂ : FiniteProduct o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
private
module T₁ = FiniteProduct T₁
module T₂ = FiniteProduct T₂
field
F : Functor T₁.T T₂.T
cartF : CartesianF T₁.cart T₂.cart F
LT-id : {A : FiniteProduct o ℓ e} → LT-Hom A A
LT-id = record { F = idF ; cartF = idF-Cartesian }
LT-∘ : {A : FiniteProduct o ℓ e} {B : FiniteProduct o′ ℓ′ e′} {C : FiniteProduct o″ ℓ″ e″} →
LT-Hom B C → LT-Hom A B → LT-Hom A C
LT-∘ G H = record { F = F G ∘F F H ; cartF = ∘-Cartesian (cartF G) (cartF H) }
where open LT-Hom
record T-Algebra (FP : FiniteProduct o ℓ e) : Set (o ⊔ ℓ ⊔ e ⊔ suc (ℓ′ ⊔ e′)) where
private
module FP = FiniteProduct FP
field
Mod : Functor FP.T (Setoids ℓ′ e′)
Cart : CartesianF FP.cart Setoids-Cartesian Mod
|
programs/oeis/095/A095098.asm | karttu/loda | 0 | 163031 | ; A095098: Fib001 numbers: those n for which the Zeckendorf expansion A014417(n) ends with two zeros and a final one.
; 6,9,14,19,22,27,30,35,40,43,48,53,56,61,64,69,74,77,82,85,90,95,98,103,108,111,116,119,124,129,132,137,142,145,150,153,158,163,166,171,174,179,184,187,192,197,200,205,208,213,218,221,226,229,234,239,242
mov $4,$0
add $4,1
mov $6,$0
lpb $4,1
mov $0,$6
sub $4,1
sub $0,$4
mov $8,2
mov $10,$0
lpb $8,1
mov $0,$10
sub $8,1
add $0,$8
mov $2,$0
mov $3,$0
add $0,1
pow $0,2
add $2,3
lpb $0,1
add $0,1
mov $5,$0
mov $0,0
add $2,2
add $5,2
trn $5,$2
add $0,$5
lpe
mov $5,$2
sub $5,4
add $5,$3
mov $7,$8
lpb $7,1
sub $7,1
mov $9,$5
lpe
lpe
lpb $10,1
sub $9,$5
mov $10,0
lpe
mov $5,$9
sub $5,1
mul $5,2
add $5,4
add $1,$5
lpe
sub $1,12
div $1,2
add $1,6
|
oeis/086/A086351.asm | neoneye/loda-programs | 11 | 244806 | ; A086351: T(n,3) of A086350.
; Submitted by <NAME>
; 1,4,17,74,325,1432,6317,27878,123049,543148,2397545,10583234,46716589,206216896,910285253,4018193246,17737162705,78295623508,345613602113,1525612248122,6734378273941,29726983906792,131221255523165
lpb $0
sub $0,1
mul $1,3
add $3,2
add $1,$3
add $2,$3
sub $2,1
mov $3,$1
add $3,$2
lpe
mov $0,$3
add $0,1
|
ada/src/main.ads | joshuawalcher/dockerfile-boilerplates | 229 | 2349 | with Text_IO,ada.Text_IO;
use Text_IO,ada.Text_IO;
procedure Adadocker is
begin
Put_line("******************************");
New_Line(2);
Put_line("Ada running inside docker.");
New_Line(2);
Put_line("******************************");
end Adadocker; |
experiments/test-suite/mutation-based/10/5/dll.als | kaiyuanw/AlloyFLCore | 1 | 3193 | <gh_stars>1-10
pred test3 {
some disj DLL0, DLL1: DLL {some disj Node0, Node1, Node2: Node {
DLL = DLL0 + DLL1
header = DLL1->Node2
Node = Node0 + Node1 + Node2
no pre
nxt = Node0->Node1 + Node2->Node0
elem = Node0->6 + Node1->5 + Node2->4
}}
}
run test3 for 3 expect 0
pred test43 {
some disj DLL0: DLL {some disj Node0, Node1, Node2: Node {
DLL = DLL0
header = DLL0->Node2
Node = Node0 + Node1 + Node2
pre = Node0->Node1 + Node1->Node2
nxt = Node1->Node0 + Node2->Node1
elem = Node0->-7 + Node1->-7 + Node2->-8
RepOk[]
}}
}
run test43 for 3 expect 0
pred test9 {
some disj DLL0: DLL {some disj Node0, Node1: Node {
DLL = DLL0
header = DLL0->Node1
Node = Node0 + Node1
no pre
nxt = Node1->Node0
elem = Node0->6 + Node1->5
}}
}
run test9 for 3 expect 1
pred test32 {
some disj DLL0: DLL {some disj Node0, Node1, Node2: Node {
DLL = DLL0
header = DLL0->Node2
Node = Node0 + Node1 + Node2
no pre
nxt = Node1->Node0 + Node2->Node1
elem = Node0->-7 + Node1->-8 + Node2->-7
Sorted[]
}}
}
run test32 for 3 expect 0
|
src/main/antlr4/org/codehaus/groovy/parser/antlr4/GroovyParser.g4 | danielsun1106/groovy-antlr4-grammar-optimized | 4 | 2009 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
parser grammar GroovyParser;
options { tokenVocab = GroovyLexer; }
@header {
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
}
@members {
private boolean ellipsisEnabled = false;
private boolean isEllipsisEnabled() {
return ellipsisEnabled;
}
private void enableEllipsis() {
ellipsisEnabled = true;
}
private void disableEllipsis() {
ellipsisEnabled = false;
}
private static String createErrorMessageForStrictCheck(Set<String> s, String keyword) {
if (VISIBILITY_MODIFIER_SET.contains(keyword)) {
StringBuilder sb = new StringBuilder();
for (String m : s) {
if (VISIBILITY_MODIFIER_SET.contains(m)) {
sb.append(m + ", ");
}
}
return sb.append(keyword) + " are not allowed to duplicate or define in the same time.";
} else {
return "duplicated " + keyword + " is not allowed.";
}
}
private static final Set<String> VISIBILITY_MODIFIER_SET = new HashSet<String>(Arrays.asList("public", "protected", "private"));
private static final String VISIBILITY_MODIFIER_STR = "VISIBILITY_MODIFIER";
private static void collectModifier(Set<String> s, String modifier) {
s.add(modifier);
}
private static boolean checkModifierDuplication(Set<String> s, String modifier) {
if (VISIBILITY_MODIFIER_SET.contains(modifier)) {
modifier = VISIBILITY_MODIFIER_STR;
for (String m : s) {
m = VISIBILITY_MODIFIER_SET.contains(m) ? VISIBILITY_MODIFIER_STR : m;
if (m.equals(modifier)) {
return true;
}
}
return false;
} else {
return s.contains(modifier);
}
}
}
compilationUnit: SHEBANG_COMMENT? (NL*)
packageDefinition? (NL | SEMICOLON)*
(importStatement (NL | SEMICOLON) | classDeclaration | scriptPart (NL | SEMICOLON) | (NL | SEMICOLON))* (NL | SEMICOLON)*
(scriptPart)? (NL | SEMICOLON)*
EOF;
scriptPart: { !GrammarPredicates.isInvalidMethodDeclaration(_input) }? methodDeclaration[null]
| statement
;
packageDefinition:
(annotationClause (NL | annotationClause)*)? KW_PACKAGE (IDENTIFIER (DOT IDENTIFIER)*);
importStatement:
(annotationClause (NL | annotationClause)*)? KW_IMPORT KW_STATIC? (IDENTIFIER (DOT IDENTIFIER)* (DOT MULT)?) (KW_AS IDENTIFIER)?;
classDeclaration
locals [Set<String> modifierSet = new HashSet<String>(), boolean isEnum = false, boolean isInterface = false, String className = null]
:
(
( annotationClause | classModifier {!checkModifierDuplication($modifierSet, $classModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierSet, $classModifier.text)}> {collectModifier($modifierSet, $classModifier.text);})
(NL | annotationClause | classModifier {!checkModifierDuplication($modifierSet, $classModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierSet, $classModifier.text)}> {collectModifier($modifierSet, $classModifier.text);})*
)? (AT KW_INTERFACE | KW_CLASS | KW_INTERFACE {$isInterface=true;} | KW_TRAIT | KW_ENUM {$isEnum=true;}) IDENTIFIER { $className = $IDENTIFIER.text; }
({!$isEnum}? genericDeclarationList? NL* (extendsClause[$isInterface])? NL*
|
)
implementsClause? NL*
classBody[$isEnum, $className];
classMember[String className]:
methodDeclaration[$className] | fieldDeclaration | objectInitializer | classInitializer | classDeclaration ;
enumConstant: IDENTIFIER (LPAREN argumentList RPAREN)?;
classBody[boolean isEnum, String className]
: LCURVE NL*
({$isEnum}? (enumConstant NL* COMMA NL*)* enumConstant NL* COMMA?
|
)
(classMember[$className] (NL | SEMICOLON) | NL | SEMICOLON)* (classMember[$className] (NL | SEMICOLON)*)?
RCURVE;
implementsClause: KW_IMPLEMENTS NL* genericClassNameExpression (COMMA NL* genericClassNameExpression)* ;
extendsClause[boolean isInterface]
: KW_EXTENDS NL* genericClassNameExpression (COMMA NL* {$isInterface}?<fail={"Only interface allows multi-inheritance"}> genericClassNameExpression)* ;
// Members
methodDeclaration[String classNameParam]
locals [Set<String> modifierAndDefSet = new HashSet<String>(), String className = null]
@init {
$className = $classNameParam;
}
:
(
(memberModifier {!checkModifierDuplication($modifierAndDefSet, $memberModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $memberModifier.text)}> {collectModifier($modifierAndDefSet, $memberModifier.text);} | annotationClause | KW_DEF {!$modifierAndDefSet.contains($KW_DEF.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $KW_DEF.text)}> {$modifierAndDefSet.add($KW_DEF.text);})
(memberModifier {!checkModifierDuplication($modifierAndDefSet, $memberModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $memberModifier.text)}> {collectModifier($modifierAndDefSet, $memberModifier.text);} | annotationClause | KW_DEF {!$modifierAndDefSet.contains($KW_DEF.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $KW_DEF.text)}> {$modifierAndDefSet.add($KW_DEF.text);} | NL)* (
(genericDeclarationList genericClassNameExpression) | typeDeclaration
)?
|
genericClassNameExpression
)?
(IDENTIFIER | STRING) LPAREN NL* argumentDeclarationList NL* RPAREN throwsClause? (KW_DEFAULT annotationParameter | blockStatementWithCurve)?
;
fieldDeclaration
locals [Set<String> modifierAndDefSet = new HashSet<String>()]
:
(
(memberModifier {!checkModifierDuplication($modifierAndDefSet, $memberModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $memberModifier.text)}> {collectModifier($modifierAndDefSet, $memberModifier.text);} | annotationClause | KW_DEF {!$modifierAndDefSet.contains($KW_DEF.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $KW_DEF.text)}> {$modifierAndDefSet.add($KW_DEF.text);})
(memberModifier {!checkModifierDuplication($modifierAndDefSet, $memberModifier.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $memberModifier.text)}> {collectModifier($modifierAndDefSet, $memberModifier.text);} | annotationClause | KW_DEF {!$modifierAndDefSet.contains($KW_DEF.text)}?<fail={createErrorMessageForStrictCheck($modifierAndDefSet, $KW_DEF.text)}> {$modifierAndDefSet.add($KW_DEF.text);} | NL)* genericClassNameExpression?
| genericClassNameExpression)
singleDeclaration ( COMMA NL* singleDeclaration)*
;
declarationRule: ( fieldDeclaration
| (annotationClause NL*)* KW_FINAL? KW_DEF tupleDeclaration
);
objectInitializer: blockStatementWithCurve ;
classInitializer: KW_STATIC blockStatementWithCurve ;
typeDeclaration:
(genericClassNameExpression | KW_DEF)
;
annotationClause:
AT genericClassNameExpression ( LPAREN ((annotationElementPair (COMMA annotationElementPair)*) | annotationElement)? RPAREN )?
;
annotationElementPair: IDENTIFIER ASSIGN NL* annotationElement ;
annotationElement: annotationParameter | annotationClause ;
genericDeclarationList:
LT genericsDeclarationElement (COMMA genericsDeclarationElement)* GT
;
genericsDeclarationElement: genericClassNameExpression (KW_EXTENDS genericClassNameExpression (BAND genericClassNameExpression)* )? ;
throwsClause: KW_THROWS classNameExpression (COMMA classNameExpression)*;
argumentDeclarationList:
(argumentDeclaration COMMA NL* )* { enableEllipsis(); } argumentDeclaration { disableEllipsis(); } | /* EMPTY ARGUMENT LIST */
;
argumentDeclaration:
annotationClause* KW_FINAL? typeDeclaration? IDENTIFIER (ASSIGN NL* expression)? ;
blockStatement:
(NL | SEMICOLON)+ (statement (NL | SEMICOLON)+)* statement? (NL | SEMICOLON)*
| statement ((NL | SEMICOLON)+ statement)* (NL | SEMICOLON)*;
singleDeclaration: IDENTIFIER (ASSIGN NL* expression)?;
tupleDeclaration: LPAREN tupleVariableDeclaration (COMMA tupleVariableDeclaration)* RPAREN (ASSIGN NL* expression)?;
tupleVariableDeclaration: genericClassNameExpression? IDENTIFIER;
newInstanceRule: KW_NEW (classNameExpression (LT GT)? | genericClassNameExpression) (LPAREN NL* argumentList? NL* RPAREN) (classBody[false, null])?;
newArrayRule: KW_NEW classNameExpression (LBRACK expression RBRACK)+ ;
statement:
declarationRule #declarationStatement
| newArrayRule #newArrayStatement
| newInstanceRule #newInstanceStatement
| KW_FOR LPAREN (declarationRule | expression)? SEMICOLON expression? SEMICOLON expression? RPAREN NL* statementBlock #classicForStatement
| KW_FOR LPAREN typeDeclaration? IDENTIFIER KW_IN expression RPAREN NL* statementBlock #forInStatement
| KW_FOR LPAREN typeDeclaration IDENTIFIER COLON expression RPAREN NL* statementBlock #forColonStatement
| KW_IF LPAREN expression RPAREN NL* statementBlock NL* (KW_ELSE NL* statementBlock)? #ifStatement
| KW_WHILE LPAREN expression RPAREN NL* statementBlock #whileStatement
| KW_SWITCH LPAREN expression RPAREN NL* LCURVE
(
(caseStatement | NL)*
(KW_DEFAULT COLON (statement (SEMICOLON | NL) | SEMICOLON | NL)+)?
)
RCURVE #switchStatement
| tryBlock ((catchBlock+ finallyBlock?) | finallyBlock) #tryCatchFinallyStatement
| (KW_CONTINUE | KW_BREAK) IDENTIFIER? #controlStatement
| KW_RETURN expression? #returnStatement
| KW_THROW expression #throwStatement
| KW_ASSERT expression ((COLON|COMMA) NL* expression)? #assertStatement
| KW_SYNCHRONIZED LPAREN expression RPAREN NL* statementBlock # synchronizedStatement
| IDENTIFIER COLON NL* statementBlock #labeledStatement
| expression #expressionStatement
;
blockStatementWithCurve : LCURVE blockStatement? RCURVE;
statementBlock:
blockStatementWithCurve
| statement ;
tryBlock: KW_TRY NL* blockStatementWithCurve NL*;
catchBlock: KW_CATCH NL* LPAREN ((classNameExpression (BOR classNameExpression)* IDENTIFIER) | IDENTIFIER) RPAREN NL* blockStatementWithCurve NL*;
finallyBlock: KW_FINALLY NL* blockStatementWithCurve;
caseStatement: (KW_CASE expression COLON (statement (SEMICOLON | NL) | SEMICOLON | NL)* );
pathExpression: (IDENTIFIER DOT)* IDENTIFIER;
gstringPathExpression: IDENTIFIER (GSTRING_PATH_PART)* ;
closureExpressionRule: LCURVE NL* (argumentDeclarationList NL* CLOSURE_ARG_SEPARATOR NL*)? blockStatement? RCURVE ;
gstringExpressionBody:( gstringPathExpression
| LCURVE expression? RCURVE
| closureExpressionRule
);
gstring: GSTRING_START gstringExpressionBody (GSTRING_PART gstringExpressionBody)* GSTRING_END ;
// Special cases.
// 1. Command expression(parenthesis-less expressions)
// 2. Annotation paramenthers.. (inline constant)
// 3. Constant expressions.
// 4. class ones, for instanceof and as (type specifier)
annotationParameter:
LBRACK (annotationParameter (COMMA annotationParameter)*)? RBRACK #annotationParamArrayExpression
| classConstantRule #annotationParamClassConstantExpression //class constant
| pathExpression #annotationParamPathExpression //constant field
| genericClassNameExpression #annotationParamClassExpression //class
| STRING #annotationParamStringExpression //primitive
| DECIMAL #annotationParamDecimalExpression //primitive
| INTEGER #annotationParamIntegerExpression //primitive
| KW_NULL #annotationParamNullExpression //primitive
| (KW_TRUE | KW_FALSE) #annotationParamBoolExpression //primitive
| closureExpressionRule # annotationParamClosureExpression
;
// (!!! OUTDATED !!!)Reference: https://github.com/apache/groovy/blob/master/src/main/org/codehaus/groovy/antlr/groovy.g#L2276
// The operators have the following precedences:
// lowest ( 15) = **= *= /= %= += -= <<= >>= >>>= &= ^= |= (assignments)
// ( 14) ?: (conditional expression and elvis)
// ( 13) || (logical or)
// ( 12) && (logical and)
// ( 11) | ()binary or
// ( 10) ^ (binary xor)
// ( 9) & (binary and)
// (8.5) =~ ==~ (regex find/match)
// ( 8) == != <=> === !== (equals, not equals, compareTo)
// ( 7) < <= > >= instanceof as in (relational, in, instanceof, type coercion)
// ( 6) << >> >>> .. ..< (shift, range)
// ( 5) + - (addition, subtraction)
// ( 4) * / % (multiply div modulo)
// ( 3) ++ -- + - (pre dec/increment, unary signs)
// ( 2) ** (power)
// ( 1) ~ ! $ (type) (negate, not, typecast)
// ?. * *. *: (safe dereference, spread, spread-dot, spread-map)
// . .& .@ (member access, method closure, field/attribute access)
// [] ++ -- (list/map/array index, post inc/decrement)
// () {} [] (method call, closableBlock, list/map literal)
// new () (object creation, explicit parenthesis)
expression:
atomExpressionRule #atomExpression
| KW_THIS #thisExpression
| KW_SUPER #superExpression
| (KW_THIS | KW_SUPER) LPAREN argumentList? RPAREN #constructorCallExpression
| e=expression NL* op=(DOT | SAFE_DOT | STAR_DOT | ATTR_DOT | MEMBER_POINTER) (selectorName | STRING | gstring | LPAREN mne=expression RPAREN) #fieldAccessExpression
| MULT expression #spreadExpression
| expression (DECREMENT | INCREMENT) #postfixExpression
| expression LBRACK (expression (COMMA expression)*)? RBRACK #indexExpression
| expression NL* op=(DOT | SAFE_DOT | STAR_DOT) NL* genericDeclarationList? c=callExpressionRule (nonKwCallExpressionRule)* (IDENTIFIER | STRING | gstring)? # cmdExpression
| n=nonKwCallExpressionRule (nonKwCallExpressionRule)* (IDENTIFIER | STRING | gstring)? # cmdExpression
| callRule #callExpression
| LPAREN genericClassNameExpression RPAREN expression #castExpression
| LPAREN expression RPAREN #parenthesisExpression
| (NOT | BNOT) expression #unaryExpression
| expression POWER NL* expression #binaryExpression
| (PLUS | MINUS) expression #unaryExpression
| (DECREMENT | INCREMENT) expression #prefixExpression
| expression (MULT | DIV | MOD) NL* expression #binaryExpression
| expression (PLUS | MINUS) NL* expression #binaryExpression
| expression (RANGE | ORANGE) NL* expression #binaryExpression
| expression (LSHIFT | GT GT | GT GT GT) NL* expression #binaryExpression
| expression KW_IN NL* expression #binaryExpression
| expression (KW_AS | KW_INSTANCEOF) NL* genericClassNameExpression #binaryExpression
| expression (LT | LTE | GT | GTE) NL* expression #binaryExpression
| expression (EQUAL | UNEQUAL | SPACESHIP) NL* expression #binaryExpression
| expression (FIND | MATCH) NL* expression #binaryExpression
| expression BAND NL* expression #binaryExpression
| expression XOR NL* expression #binaryExpression
| expression BOR NL* expression #binaryExpression
| expression NL* AND NL* expression #binaryExpression
| expression NL* OR NL* expression #binaryExpression
|<assoc=right> expression NL* (QUESTION NL* expression NL* COLON | ELVIS) NL* expression #ternaryExpression
|<assoc=right> expression (ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN | MULT_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | BAND_ASSIGN | XOR_ASSIGN | BOR_ASSIGN | LSHIFT_ASSIGN | RSHIFT_ASSIGN | RUSHIFT_ASSIGN) NL* expression #assignmentExpression
|<assoc=right> LPAREN IDENTIFIER (COMMA IDENTIFIER)* RPAREN ASSIGN NL* expression #assignmentExpression
;
atomExpressionRule:
STRING #constantExpression
| gstring #gstringExpression
| DECIMAL #constantDecimalExpression
| INTEGER #constantIntegerExpression
| KW_NULL #nullExpression
| (KW_TRUE | KW_FALSE) #boolExpression
| IDENTIFIER #variableExpression
| classConstantRule #classConstantExpression
| closureExpressionRule #closureExpression
| LBRACK NL* (expression (NL* COMMA NL* expression NL*)* COMMA?)? NL* RBRACK #listConstructor
| LBRACK NL* (COLON NL*| (mapEntry (NL* COMMA NL* mapEntry NL*)*) COMMA?) NL* RBRACK #mapConstructor
| newArrayRule #newArrayExpression
| newInstanceRule #newInstanceExpression
;
classConstantRule: classNameExpression (DOT KW_CLASS)?;
argumentListRule:
LPAREN NL* argumentList? NL* RPAREN closureExpressionRule*;
callExpressionRule:
(selectorName | STRING | gstring | LPAREN mne=expression RPAREN) argumentListRule+
| { !GrammarPredicates.isFollowedByLPAREN(_input) }? (selectorName | STRING | gstring | LPAREN mne=expression RPAREN) argumentList
;
nonKwCallExpressionRule:
// @baseContext{callExpressionRule} does not work in antlr4.5.3
(IDENTIFIER | STRING | gstring) argumentListRule+
| { !GrammarPredicates.isFollowedByLPAREN(_input) }? (IDENTIFIER | STRING | gstring) argumentList
;
callRule
: a=atomExpressionRule argumentListRule+
| { !GrammarPredicates.isFollowedByLPAREN(_input) }? (c=closureExpressionRule ) argumentList
| { !GrammarPredicates.isClassName(_input, 2) }? LPAREN mne=expression RPAREN argumentListRule+
;
classNameExpression: { GrammarPredicates.isClassName(_input) }? (BUILT_IN_TYPE | pathExpression);
genericClassNameExpression: classNameExpression genericList? (LBRACK RBRACK)* (ELLIPSIS { isEllipsisEnabled() }?<fail={ "The var-arg only be allowed to appear as the last parameter" }>)?;
genericList:
LT genericListElement (COMMA genericListElement)* GT
;
genericListElement:
genericClassNameExpression #genericsConcreteElement
| QUESTION (KW_EXTENDS genericClassNameExpression | KW_SUPER genericClassNameExpression)? #genericsWildcardElement
;
mapEntry:
STRING COLON expression
| gstring COLON expression
| selectorName COLON expression
| LPAREN expression RPAREN COLON expression
| MULT COLON expression
| DECIMAL COLON expression
| INTEGER COLON expression
;
classModifier:
VISIBILITY_MODIFIER | KW_STATIC | (KW_ABSTRACT | KW_FINAL) | KW_STRICTFP ;
memberModifier:
VISIBILITY_MODIFIER | KW_STATIC | (KW_ABSTRACT | KW_FINAL) | KW_NATIVE | KW_SYNCHRONIZED | KW_TRANSIENT | KW_VOLATILE ;
argumentList: ( (closureExpressionRule)+ | argument (NL* COMMA NL* argument)*) ;
argument
: mapEntry
| expression
;
selectorName
: IDENTIFIER
| kwSelectorName
;
kwSelectorName: KW_ABSTRACT | KW_AS | KW_ASSERT | KW_BREAK | KW_CASE | KW_CATCH | KW_CLASS | KW_CONST | KW_CONTINUE
| KW_DEF | KW_DEFAULT | KW_DO | KW_ELSE | KW_ENUM | KW_EXTENDS | KW_FALSE | KW_FINAL | KW_FINALLY
| KW_FOR | KW_GOTO | KW_IF | KW_IMPLEMENTS | KW_IMPORT | KW_IN | KW_INSTANCEOF | KW_INTERFACE
| KW_NATIVE | KW_NEW | KW_NULL | KW_PACKAGE
| KW_RETURN | KW_STATIC | KW_STRICTFP | KW_SUPER | KW_SWITCH | KW_SYNCHRONIZED | KW_THIS | KW_THREADSAFE | KW_THROW
| KW_THROWS | KW_TRANSIENT | KW_TRAIT | KW_TRUE | KW_TRY | KW_VOLATILE | KW_WHILE
| BUILT_IN_TYPE | VISIBILITY_MODIFIER /* in place of KW_PRIVATE | KW_PROTECTED | KW_PUBLIC */
; |
RefactorAgdaEngine/Test/Tests/input/ExtractDependent.agda | omega12345/RefactorAgda | 5 | 1960 | {-# OPTIONS --allow-unsolved-metas #-}
module ExtractDependent where
open import Agda.Builtin.Nat
open import Agda.Builtin.Bool
open import Agda.Builtin.String
apply : (A : Set) -> (B : A -> Set) ->
((x : A) -> B x) -> (a : A) -> B a
apply A B f a = f a
applySameName : (A : Set) -> (A : Set) -> (B : A -> Set) ->
(h : Set) -> (h : (x : A) -> B x) -> (a : A) -> B a
applySameName C A B g f a = f a
-- TODO : Try same test with {A} {B} once the parser can handle that.
applyImp : {A : Set} -> {B : A -> Set} ->
((x : A) -> B x) -> (y : A) -> B y
applyImp f a = f a
applyImpSameName : {A : Set} -> {A : Set} -> {B : A -> Set} ->
(h : Set) -> (h : (x : A) -> B x) -> (a : A) -> B a
applyImpSameName A B h = B h
|
legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalLexerGrammar.g4 | ivan-kyosev-gs/legend-engine | 0 | 3679 | <reponame>ivan-kyosev-gs/legend-engine
lexer grammar RelationalLexerGrammar;
import CoreLexerGrammar;
// -------------------------------------- KEYWORD --------------------------------------
DATABASE: 'Database';
INCLUDE: 'include';
TABLE: 'Table';
SCHEMA: 'Schema';
VIEW: 'View';
FILTER: 'Filter';
MULTIGRAIN_FILTER: 'MultiGrainFilter';
JOIN: 'Join';
FILTER_CMD: '~filter';
DISTINCT_CMD: '~distinct';
GROUP_BY_CMD: '~groupBy';
MAIN_TABLE_CMD: '~mainTable';
PRIMARY_KEY_CMD: '~primaryKey';
TARGET: '{target}';
PRIMARY_KEY: 'PRIMARY KEY';
NOT_NULL: 'NOT NULL';
IS_NULL: 'is null';
IS_NOT_NULL: 'is not null';
AND: 'and';
OR: 'or';
// Milestoning
MILESTONING: 'milestoning';
BUSINESS_MILESTONING: 'business';
BUSINESS_MILESTONING_FROM: 'BUS_FROM';
BUSINESS_MILESTONING_THRU: 'BUS_THRU';
THRU_IS_INCLUSIVE: 'THRU_IS_INCLUSIVE';
BUS_SNAPSHOT_DATE: 'BUS_SNAPSHOT_DATE';
PROCESSING_MILESTONING: 'processing';
PROCESSING_MILESTONING_IN: 'PROCESSING_IN';
PROCESSING_MILESTONING_OUT: 'PROCESSING_OUT';
OUT_IS_INCLUSIVE: 'OUT_IS_INCLUSIVE';
INFINITY_DATE: 'INFINITY_DATE';
// Mapping
ASSOCIATION_MAPPING: 'AssociationMapping';
ENUMERATION_MAPPING: 'EnumerationMapping';
OTHERWISE: 'Otherwise';
INLINE: 'Inline';
BINDING: 'Binding';
SCOPE: 'scope';
// ----------------------------------- BUILDING BLOCK -----------------------------------
NOT_EQUAL: '<>';
FLOAT: ('+' | '-')? Float;
INTEGER: ('+' | '-')? Integer;
QUOTED_STRING: ('"' ( EscSeq | ~["\r\n] )* '"');
|
src/main/ada/2019/aoc-aoc_2019-day05.ads | wooky/aoc.kt | 0 | 6886 | <gh_stars>0
with Intcode;
package AOC.AOC_2019.Day05 is
type Day_05 is new Day.Day with private;
overriding procedure Init (D : in out Day_05; Root : String);
overriding function Part_1 (D : Day_05) return String;
overriding function Part_2 (D : Day_05) return String;
private
type Day_05 is new Day.Day with record
Compiler : Intcode.Compilers.Compiler;
end record;
end AOC.AOC_2019.Day05;
|
programs/oeis/207/A207451.asm | jmorken/loda | 1 | 18422 | <gh_stars>1-10
; A207451: Number of n X 6 0..1 arrays avoiding 0 0 0 and 0 0 1 horizontally and 0 0 1 and 1 0 1 vertically.
; 26,676,3354,10088,23530,46956,84266,139984,219258,327860,472186,659256,896714,1192828,1556490,1997216,2525146,3151044,3886298,4742920,5733546,6871436,8170474,9645168,11310650,13182676,15277626,17612504,20204938
mov $2,$0
add $2,1
pow $2,2
mov $3,5
add $3,$0
mul $3,$0
mul $3,$2
add $0,$3
mov $1,$0
mul $1,26
add $1,26
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.