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/107/A107660.asm
neoneye/loda
22
18443
; A107660: Sum 3^max(k,n-k),k=0..n. ; 1,6,21,72,225,702,2133,6480,19521,58806,176661,530712,1592865,4780782,14344533,43040160,129127041,387400806,1162222101,3486725352,10460235105,31380882462,94142824533,282429005040,847287546561,2541864234006,7625594296341,22876787671992,68630367798945,205891117745742,617673367586133,1853020145805120,5559060480462081,16677181570526406,50031544840719381,150094634909578632,450283905116156385,1350851716510730622,4052555150694453333,12157665455570144400,36472996370197217601,109418989121052006006,328256967373616371221,984770902152230173272,2954312706488071579425,8862938119558357917102,26588814358769216930133,79766443076590080326880,239299329230052670517121,717897987691005300160806,2153693963073863189091861,6461081889224131433103912,19383245667674936165140065,58149737003032434092905182,174449211009104927876200533,523347633027337660421056560,1570042899082035858055624641,4710128697246176204544238806,14130386091738597244010081301,42391158275215997623162338552,127173474825648198760619110305,381520424476945213955253614862,1144561273430836259539157128533,3433683820292510631637660237440,10301051460877533747933169564161,30903154382632606802860075248006,92709463147897825967640792299541,278128389443693494580104076565192,834385168331080500417493929362145,2503155504993241551284026887086142,7509466514979724703883625760258133,22528399544939174261745512577773520,67585198634817522935331173030319681,202755595904452569256277424981956406,608266787713357708219116180836866581 add $0,1 seq $0,32096 ; "BHK" (reversible, identity, unlabeled) transform of 2,2,2,2,... sub $0,2
source/network-addresses.ads
reznikmm/network
1
1267
<reponame>reznikmm/network<filename>source/network-addresses.ads -- SPDX-FileCopyrightText: 2021 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Streams; with League.Strings; package Network.Addresses is pragma Preelaborate; type Address is private; -- Composable and future-proof network addresses function To_String (Self : Address) return League.Strings.Universal_String; -- Return textual representation of the multiaddr. Example: -- "/ip4/127.0.0.1/tcp/8080". See Multiaddr for details. function To_Stream_Element_Array (Self : Address) return Ada.Streams.Stream_Element_Array; -- Return binary representation of the multiaddr function To_Address (Value : League.Strings.Universal_String) return Address with Pre => Is_Valid (Value); -- Construct multiaddr from the string function To_Address (Value : Ada.Streams.Stream_Element_Array) return Address with Pre => Is_Valid (Value); -- Construct multiaddr from bytes function Is_Valid (Value : League.Strings.Universal_String) return Boolean; -- Check is given string represents a multiaddr function Is_Valid (Ignore : Ada.Streams.Stream_Element_Array) return Boolean is (True); -- TBD type Address_Array is array (Positive range <>) of Address; private type Address is record Value : League.Strings.Universal_String; end record; type Simple_Stream (Size : Ada.Streams.Stream_Element_Count) is new Ada.Streams.Root_Stream_Type with record Last : Ada.Streams.Stream_Element_Count := 0; Data : Ada.Streams.Stream_Element_Array (1 .. Size); end record; overriding procedure Read (Self : in out Simple_Stream; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); overriding procedure Write (Self : in out Simple_Stream; Item : Ada.Streams.Stream_Element_Array); procedure Write (Self : access Ada.Streams.Root_Stream_Type'Class; Value : Ada.Streams.Stream_Element_Count); procedure Read (Self : access Ada.Streams.Root_Stream_Type'Class; Value : out Ada.Streams.Stream_Element_Count); end Network.Addresses;
TotalRecognisers/LeftRecursion/KleeneAlgebra.agda
nad/parser-combinators
1
15363
------------------------------------------------------------------------ -- Recognisers form a Kleene algebra ------------------------------------------------------------------------ module TotalRecognisers.LeftRecursion.KleeneAlgebra (Tok : Set) where open import Algebra import Algebra.Properties.BooleanAlgebra open import Codata.Musical.Notation open import Data.Bool hiding (_∧_; _≤_) import Data.Bool.Properties as Bool private module BoolCS = CommutativeSemiring Bool.∨-∧-commutativeSemiring module BoolBA = Algebra.Properties.BooleanAlgebra Bool.∨-∧-booleanAlgebra open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence as Eq using (_⇔_; equivalence) open import Data.List open import Data.List.Properties private module ListMonoid {A : Set} = Monoid (++-monoid A) open import Data.Nat using (ℕ; zero; suc) open import Data.Product as Prod open import Relation.Binary.HeterogeneousEquality using (_≅_; refl) open import Relation.Binary.PropositionalEquality as P using (_≡_; refl; _≗_) open import Relation.Nullary import TotalRecognisers.LeftRecursion open TotalRecognisers.LeftRecursion Tok hiding (left-zero) import TotalRecognisers.LeftRecursion.Lib open TotalRecognisers.LeftRecursion.Lib Tok open ⊙ using (_⊙′_) open KleeneStar₂ ------------------------------------------------------------------------ -- The relation _≤_ is a partial order with respect to _≈_ module PartialOrder where reflexive : ∀ {n} {p : P n} → p ≤ p reflexive = id trans : ∀ {n₁ n₂ n₃} {p₁ : P n₁} {p₂ : P n₂} {p₃ : P n₃} → p₁ ≤ p₂ → p₂ ≤ p₃ → p₁ ≤ p₃ trans p₁≤p₂ p₂≤p₃ = p₂≤p₃ ∘ p₁≤p₂ antisym : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≤ p₂ → p₂ ≤ p₁ → p₁ ≈ p₂ antisym p₁≤p₂ p₂≤p₁ = equivalence p₁≤p₂ p₂≤p₁ ------------------------------------------------------------------------ -- The relation _≈_ is an equality, i.e. a congruential equivalence -- relation module Equivalence where reflexive : ∀ {n} {p : P n} → p ≈ p reflexive = Eq.id sym : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → p₂ ≈ p₁ sym p₁≈p₂ = Eq.sym p₁≈p₂ trans : ∀ {n₁ n₂ n₃} {p₁ : P n₁} {p₂ : P n₂} {p₃ : P n₃} → p₁ ≈ p₂ → p₂ ≈ p₃ → p₁ ≈ p₃ trans p₁≈p₂ p₂≈p₃ = Eq._∘_ p₂≈p₃ p₁≈p₂ ♭♯-cong : ∀ {n₁ n₂} b₁ b₂ {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → ♭? (♯? {b₁} p₁) ≈ ♭? (♯? {b₂} p₂) ♭♯-cong b₁ b₂ {p₁} {p₂} rewrite ♭?♯? b₁ {p = p₁} | ♭?♯? b₂ {p = p₂} = id fail-cong : fail ≈ fail fail-cong = Equivalence.reflexive empty-cong : empty ≈ empty empty-cong = Equivalence.reflexive sat-cong : {f₁ f₂ : Tok → Bool} → f₁ ≗ f₂ → sat f₁ ≈ sat f₂ sat-cong f₁≗f₂ = equivalence (helper f₁≗f₂) (helper (P.sym ∘ f₁≗f₂)) where helper : {f₁ f₂ : Tok → Bool} → f₁ ≗ f₂ → sat f₁ ≤ sat f₂ helper f₁≗f₂ (sat ok) = sat (P.subst T (f₁≗f₂ _) ok) ∣-cong : ∀ {n₁ n₂ n₃ n₄} {p₁ : P n₁} {p₂ : P n₂} {p₃ : P n₃} {p₄ : P n₄} → p₁ ≈′ p₃ → p₂ ≈′ p₄ → p₁ ∣ p₂ ≈′ p₃ ∣ p₄ ∣-cong (refl ∷ rest₁) (refl ∷ rest₂) = refl ∷ λ t → ♯ ∣-cong (♭ (rest₁ t)) (♭ (rest₂ t)) ·-cong : ∀ {n₁ n₂ n₃ n₄} {p₁ : ∞⟨ n₂ ⟩P n₁} {p₂ : ∞⟨ n₁ ⟩P n₂} {p₃ : ∞⟨ n₄ ⟩P n₃} {p₄ : ∞⟨ n₃ ⟩P n₄} → ♭? p₁ ≈ ♭? p₃ → ♭? p₂ ≈ ♭? p₄ → p₁ · p₂ ≈ p₃ · p₄ ·-cong p₁≈p₃ p₂≈p₄ = Eq.Equivalence.from ≈⇔≤≥ ⟨$⟩ Prod.zip helper helper (Eq.Equivalence.to ≈⇔≤≥ ⟨$⟩ p₁≈p₃) (Eq.Equivalence.to ≈⇔≤≥ ⟨$⟩ p₂≈p₄) where helper : ∀ {n₁ n₂ n₃ n₄} {p₁ : ∞⟨ n₂ ⟩P n₁} {p₂ : ∞⟨ n₁ ⟩P n₂} {p₃ : ∞⟨ n₄ ⟩P n₃} {p₄ : ∞⟨ n₃ ⟩P n₄} → ♭? p₁ ≤ ♭? p₃ → ♭? p₂ ≤ ♭? p₄ → p₁ · p₂ ≤ p₃ · p₄ helper ₁≤₃ ₂≤₄ (∈p₁ · ∈p₂) = ₁≤₃ ∈p₁ · ₂≤₄ ∈p₂ ⊙-cong : ∀ {n₁ n₂ n₃ n₄} {p₁ : P n₁} {p₂ : P n₂} {p₃ : P n₃} {p₄ : P n₄} → p₁ ≈ p₃ → p₂ ≈ p₄ → p₁ ⊙ p₂ ≈ p₃ ⊙ p₄ ⊙-cong {n₁} {n₂} {n₃} {n₄} ₁≈₃ ₂≈₄ = ·-cong (♭♯-cong n₂ n₄ ₁≈₃) (♭♯-cong n₁ n₃ ₂≈₄) nonempty-cong : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈′ p₂ → nonempty p₁ ≈′ nonempty p₂ nonempty-cong (_ ∷ rest) = refl ∷ rest cast-cong : ∀ {n₁ n₂ n₁′ n₂′} {p₁ : P n₁} {p₂ : P n₂} {eq₁ : n₁ ≡ n₁′} {eq₂ : n₂ ≡ n₂′} → p₁ ≈′ p₂ → cast eq₁ p₁ ≈′ cast eq₂ p₂ cast-cong {eq₁ = refl} {refl} (init ∷ rest) = init ∷ rest ⋆-cong : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → p₁ ⋆ ≈ p₂ ⋆ ⋆-cong p₁≈p₂ = Eq.Equivalence.from ≈⇔≤≥ ⟨$⟩ Prod.map helper helper (Eq.Equivalence.to ≈⇔≤≥ ⟨$⟩ p₁≈p₂) where helper : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≤ p₂ → p₁ ⋆ ≤ p₂ ⋆ helper p₁≤p₂ (∣-left empty) = ∣-left empty helper p₁≤p₂ (∣-right (nonempty ∈p₁ · ∈p₁⋆)) = ∣-right {p₁ = empty} (nonempty (p₁≤p₂ ∈p₁) · helper p₁≤p₂ ∈p₁⋆) ^-cong : ∀ {n₁ n₂ i₁ i₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → i₁ ≡ i₂ → p₁ ^ i₁ ≈ p₂ ^ i₂ ^-cong {i₁ = i} p₁≈p₂ refl = Eq.Equivalence.from ≈⇔≤≥ ⟨$⟩ Prod.map (helper i) (helper i) (Eq.Equivalence.to ≈⇔≤≥ ⟨$⟩ p₁≈p₂) where helper : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} i → p₁ ≤ p₂ → p₁ ^ i ≤ p₂ ^ i helper zero p₁≤p₂ empty = empty helper {n₁} {n₂} (suc i) p₁≤p₂ ∈p₁⊙p₁ⁱ with ⊙.sound ⟨ n₁ ^ i ⟩-nullable ∈p₁⊙p₁ⁱ ... | ∈p₁ ⊙′ ∈p₁ⁱ = ⊙.complete (p₁≤p₂ ∈p₁) (helper i p₁≤p₂ ∈p₁ⁱ) ------------------------------------------------------------------------ -- A variant of _≤_ infix 4 _≲_ -- If _∣_ is viewed as the join operation of a join-semilattice, then -- the following definition of order is natural. _≲_ : ∀ {n₁ n₂} → P n₁ → P n₂ → Set p₁ ≲ p₂ = p₁ ∣ p₂ ≈ p₂ -- The order above coincides with _≤_. ≤⇔≲ : ∀ {n₁ n₂} (p₁ : P n₁) (p₂ : P n₂) → p₁ ≤ p₂ ⇔ p₁ ≲ p₂ ≤⇔≲ {n₁} p₁ p₂ = equivalence (λ (p₁≤p₂ : p₁ ≤ p₂) {_} → equivalence (helper p₁≤p₂) (∣-right {n₁ = n₁})) (λ (p₁≲p₂ : p₁ ≲ p₂) s∈p₁ → Eq.Equivalence.to p₁≲p₂ ⟨$⟩ ∣-left s∈p₁) where helper : p₁ ≤ p₂ → p₁ ∣ p₂ ≤ p₂ helper p₁≤p₂ (∣-left s∈p₁) = p₁≤p₂ s∈p₁ helper p₁≤p₂ (∣-right s∈p₂) = s∈p₂ ------------------------------------------------------------------------ -- Recognisers form a *-continuous Kleene algebra -- The definition of *-continuous Kleene algebras used here is the one -- given by Kozen in "On Kleene Algebras and Closed Semirings", except -- for the presence of the recogniser indices. Kozen used the order -- _≲_ in his definition, but as shown above this order is equivalent -- to _≤_. -- Additive idempotent commutative monoid. (One of the identity lemmas -- could be omitted.) ∣-commutative : ∀ {n₁ n₂} (p₁ : P n₁) (p₂ : P n₂) → p₁ ∣ p₂ ≈′ p₂ ∣ p₁ ∣-commutative {n₁} {n₂} p₁ p₂ = BoolCS.+-comm n₁ n₂ ∷ λ t → ♯ ∣-commutative (D t p₁) (D t p₂) fail-left-identity : ∀ {n} (p : P n) → fail ∣ p ≈′ p fail-left-identity p = refl ∷ λ t → ♯ fail-left-identity (D t p) fail-right-identity : ∀ {n} (p : P n) → p ∣ fail ≈′ p fail-right-identity {n} p = proj₂ BoolCS.+-identity n ∷ λ t → ♯ fail-right-identity (D t p) ∣-associative : ∀ {n₁ n₂ n₃} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) → p₁ ∣ (p₂ ∣ p₃) ≈′ (p₁ ∣ p₂) ∣ p₃ ∣-associative {n₁} {n₂} {n₃} p₁ p₂ p₃ = P.sym (BoolCS.+-assoc n₁ n₂ n₃) ∷ λ t → ♯ ∣-associative (D t p₁) (D t p₂) (D t p₃) ∣-idempotent : ∀ {n} (p : P n) → p ∣ p ≈′ p ∣-idempotent {n} p = BoolBA.∨-idempotent n ∷ λ t → ♯ ∣-idempotent (D t p) -- Multiplicative monoid. empty-left-identity : ∀ {n} (p : P n) → empty ⊙ p ≈ p empty-left-identity {n} p = equivalence helper (λ s∈p → ⊙.complete empty s∈p) where helper : empty ⊙ p ≤ p helper ∈empty⊙p with ⊙.sound n ∈empty⊙p ... | empty ⊙′ s∈p = s∈p empty-right-identity : ∀ {n} (p : P n) → p ⊙ empty ≈ p empty-right-identity {n} p = equivalence helper (λ s∈p → cast∈ (proj₂ ListMonoid.identity _) refl (⊙.complete s∈p empty)) where helper : ∀ {s} → s ∈ p ⊙ empty → s ∈ p helper ∈p⊙empty with ⊙.sound true ∈p⊙empty helper ∈p⊙empty | ∈p ⊙′ empty = cast∈ (P.sym (proj₂ ListMonoid.identity _)) refl ∈p ·-associative : ∀ {n₁ n₂ n₃} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) → p₁ ⊙ (p₂ ⊙ p₃) ≈ (p₁ ⊙ p₂) ⊙ p₃ ·-associative {n₁} {n₂} {n₃} p₁ p₂ p₃ = equivalence helper₁ helper₂ where helper₁ : p₁ ⊙ (p₂ ⊙ p₃) ≤ (p₁ ⊙ p₂) ⊙ p₃ helper₁ ∈⊙⊙ with ⊙.sound (n₂ ∧ n₃) ∈⊙⊙ ... | _⊙′_ {s₁ = s₁} ∈p₁ ∈⊙ with ⊙.sound n₃ ∈⊙ ... | ∈p₂ ⊙′ ∈p₃ = cast∈ (ListMonoid.assoc s₁ _ _) refl $ ⊙.complete (⊙.complete ∈p₁ ∈p₂) ∈p₃ helper₂ : (p₁ ⊙ p₂) ⊙ p₃ ≤ p₁ ⊙ (p₂ ⊙ p₃) helper₂ ∈⊙⊙ with ⊙.sound n₃ ∈⊙⊙ ... | ∈⊙ ⊙′ ∈p₃ with ⊙.sound n₂ ∈⊙ ... | _⊙′_ {s₁ = s₁} ∈p₁ ∈p₂ = cast∈ (P.sym $ ListMonoid.assoc s₁ _ _) refl $ ⊙.complete ∈p₁ (⊙.complete ∈p₂ ∈p₃) -- Distributivity. left-distributive : ∀ {n₁ n₂ n₃} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) → p₁ ⊙ (p₂ ∣ p₃) ≈ p₁ ⊙ p₂ ∣ p₁ ⊙ p₃ left-distributive {n₁} {n₂} {n₃} p₁ p₂ p₃ = equivalence helper₁ helper₂ where helper₁ : p₁ ⊙ (p₂ ∣ p₃) ≤ p₁ ⊙ p₂ ∣ p₁ ⊙ p₃ helper₁ ∈⊙∣ with ⊙.sound (n₂ ∨ n₃) ∈⊙∣ ... | ∈p₁ ⊙′ ∣-left ∈p₂ = ∣-left $ ⊙.complete ∈p₁ ∈p₂ ... | ∈p₁ ⊙′ ∣-right ∈p₃ = ∣-right {n₁ = n₁ ∧ n₂} $ ⊙.complete ∈p₁ ∈p₃ helper₂ : p₁ ⊙ p₂ ∣ p₁ ⊙ p₃ ≤ p₁ ⊙ (p₂ ∣ p₃) helper₂ (∣-left ∈⊙) with ⊙.sound n₂ ∈⊙ ... | ∈p₁ ⊙′ ∈p₂ = ⊙.complete ∈p₁ (∣-left ∈p₂) helper₂ (∣-right ∈⊙) with ⊙.sound n₃ ∈⊙ ... | ∈p₁ ⊙′ ∈p₃ = ⊙.complete ∈p₁ (∣-right {n₁ = n₂} ∈p₃) right-distributive : ∀ {n₁ n₂ n₃} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) → (p₁ ∣ p₂) ⊙ p₃ ≈ p₁ ⊙ p₃ ∣ p₂ ⊙ p₃ right-distributive {n₁} {n₂} {n₃} p₁ p₂ p₃ = equivalence helper₁ helper₂ where helper₁ : (p₁ ∣ p₂) ⊙ p₃ ≤ p₁ ⊙ p₃ ∣ p₂ ⊙ p₃ helper₁ ∈∣⊙ with ⊙.sound n₃ ∈∣⊙ ... | ∣-left ∈p₁ ⊙′ ∈p₃ = ∣-left $ ⊙.complete ∈p₁ ∈p₃ ... | ∣-right ∈p₂ ⊙′ ∈p₃ = ∣-right {n₁ = n₁ ∧ n₃} $ ⊙.complete ∈p₂ ∈p₃ helper₂ : p₁ ⊙ p₃ ∣ p₂ ⊙ p₃ ≤ (p₁ ∣ p₂) ⊙ p₃ helper₂ (∣-left ∈⊙) with ⊙.sound n₃ ∈⊙ ... | ∈p₁ ⊙′ ∈p₃ = ⊙.complete (∣-left ∈p₁) ∈p₃ helper₂ (∣-right ∈⊙) with ⊙.sound n₃ ∈⊙ ... | ∈p₂ ⊙′ ∈p₃ = ⊙.complete (∣-right {n₁ = n₁} ∈p₂) ∈p₃ -- Zero. left-zero : ∀ {n} (p : P n) → fail ⊙ p ≈ fail left-zero {n} p = equivalence helper (λ ()) where helper : fail ⊙ p ≤ fail helper ∈fail⊙ with ⊙.sound n ∈fail⊙ ... | () ⊙′ _ right-zero : ∀ {n} (p : P n) → p ⊙ fail ≈ fail right-zero {n} p = equivalence helper (λ ()) where helper : p ⊙ fail ≤ fail helper ∈⊙fail with ⊙.sound false ∈⊙fail ... | _ ⊙′ () -- *-continuity. *-continuity-upper-bound : ∀ {n₁ n₂ n₃} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) → ∀ i → p₁ ⊙ p₂ ^ i ⊙ p₃ ≤ p₁ ⊙ p₂ ⋆ ⊙ p₃ *-continuity-upper-bound {n₁} {n₂} {n₃} _ _ _ i ∈⊙ⁱ⊙ with ⊙.sound n₃ ∈⊙ⁱ⊙ ... | ∈⊙ⁱ ⊙′ ∈p₃ with ⊙.sound ⟨ n₂ ^ i ⟩-nullable ∈⊙ⁱ ... | ∈p₁ ⊙′ ∈p₂ⁱ = ⊙.complete (⊙.complete ∈p₁ (^≤⋆ i ∈p₂ⁱ)) ∈p₃ *-continuity-least-upper-bound : ∀ {n₁ n₂ n₃ n} (p₁ : P n₁) (p₂ : P n₂) (p₃ : P n₃) (p : P n) → (∀ i → p₁ ⊙ p₂ ^ i ⊙ p₃ ≤ p) → p₁ ⊙ p₂ ⋆ ⊙ p₃ ≤ p *-continuity-least-upper-bound {n₁} {n₂} {n₃} {n} p₁ p₂ p₃ p ub = helper ∘ _⟨$⟩_ (Eq.Equivalence.from $ ·-associative p₁ (p₂ ⋆) p₃) where helper : p₁ ⊙ (p₂ ⋆ ⊙ p₃) ≤ p helper ∈⊙⋆⊙ with ⊙.sound (true ∧ n₃) ∈⊙⋆⊙ ... | _⊙′_ {s₁ = s₁} ∈p₁ ∈⋆⊙ with ⊙.sound n₃ ∈⋆⊙ ... | ∈p₂⋆ ⊙′ ∈p₃ with ⋆≤^ ∈p₂⋆ ... | (i , ∈p₂ⁱ) = cast∈ (ListMonoid.assoc s₁ _ _) refl $ ub i $ ⊙.complete (⊙.complete ∈p₁ ∈p₂ⁱ) ∈p₃
oeis/176/A176627.asm
neoneye/loda-programs
11
242159
<reponame>neoneye/loda-programs ; A176627: Triangle T(n, k) = 12^(k*(n-k)), read by rows. ; Submitted by <NAME> ; 1,1,1,1,12,1,1,144,144,1,1,1728,20736,1728,1,1,20736,2985984,2985984,20736,1,1,248832,429981696,5159780352,429981696,248832,1,1,2985984,61917364224,8916100448256,8916100448256,61917364224,2985984,1,1 lpb $0 add $1,1 sub $0,$1 lpe sub $1,$0 mul $1,$0 mov $0,12 pow $0,$1
parser/src/main/grammars/ECL.g4
endeavourhealth-discovery/IMAPI
0
1740
grammar ECL; expressionconstraint : ws ( refinedexpressionconstraint | compoundexpressionconstraint | dottedexpressionconstraint | subexpressionconstraint ) ws; refinedexpressionconstraint : subexpressionconstraint ws COLON ws eclrefinement; compoundexpressionconstraint : conjunctionexpressionconstraint | disjunctionexpressionconstraint | exclusionexpressionconstraint; conjunctionexpressionconstraint : subexpressionconstraint (ws conjunction ws subexpressionconstraint)+; disjunctionexpressionconstraint : subexpressionconstraint (ws disjunction ws subexpressionconstraint)+; exclusionexpressionconstraint : subexpressionconstraint ws exclusion ws subexpressionconstraint; dottedexpressionconstraint : subexpressionconstraint (ws dottedexpressionattribute)+; dottedexpressionattribute : dot ws eclattributename; subexpressionconstraint : (constraintoperator ws)? (memberof ws)? (eclfocusconcept | (LEFT_PAREN ws expressionconstraint ws RIGHT_PAREN)); eclfocusconcept : eclconceptreference | wildcard; dot : PERIOD; memberof : CARAT; eclconceptreference : conceptid (ws PIPE ws term ws PIPE)?; conceptid : sctid ; term : nonwsnonpipe+ ( sp+ nonwsnonpipe+ )*; wildcard : ASTERISK; constraintoperator : childof | descendantorselfof | descendantof | parentof | ancestororselfof | ancestorof; descendantof : LESS_THAN; descendantorselfof : (LESS_THAN LESS_THAN); childof : (LESS_THAN EXCLAMATION); ancestorof : GREATER_THAN; ancestororselfof : (GREATER_THAN GREATER_THAN); parentof : (GREATER_THAN EXCLAMATION); conjunction : ((A|CAP_A) (N|CAP_N) (D|CAP_D) mws) | COMMA; disjunction : (O|CAP_O) (R|CAP_R) mws; exclusion : (M|CAP_M) (I|CAP_I) (N|CAP_N) (U|CAP_U) (S|CAP_S) mws; eclrefinement : subrefinement ws (conjunctionrefinementset | disjunctionrefinementset)?; conjunctionrefinementset : (ws conjunction ws subrefinement)+; disjunctionrefinementset : (ws disjunction ws subrefinement)+; subrefinement : eclattributeset | eclattributegroup | (LEFT_PAREN ws eclrefinement ws RIGHT_PAREN); eclattributeset : subattributeset ws (conjunctionattributeset | disjunctionattributeset)?; conjunctionattributeset : (ws conjunction ws subattributeset)+; disjunctionattributeset : (ws disjunction ws subattributeset)+; subattributeset : eclattribute | (LEFT_PAREN ws eclattributeset ws RIGHT_PAREN); eclattributegroup : (LEFT_BRACE cardinality RIGHT_BRACE ws)? LEFT_CURLY_BRACE ws eclattributeset ws RIGHT_CURLY_BRACE; eclattribute : (LEFT_BRACE cardinality RIGHT_BRACE ws)? (reverseflag ws)? eclattributename ws ((expressioncomparisonoperator ws subexpressionconstraint) | (numericcomparisonoperator ws POUND numericvalue) | (stringcomparisonoperator ws qm stringvalue qm)); cardinality : minvalue to maxvalue; minvalue : nonnegativeintegervalue; to : (PERIOD PERIOD); maxvalue : nonnegativeintegervalue | many; many : ASTERISK; reverseflag : CAP_R; eclattributename : subexpressionconstraint; expressioncomparisonoperator : EQUALS | (EXCLAMATION EQUALS); numericcomparisonoperator : EQUALS | (EXCLAMATION EQUALS) | (LESS_THAN EQUALS) | LESS_THAN | (GREATER_THAN EQUALS) | GREATER_THAN; stringcomparisonoperator : EQUALS | (EXCLAMATION EQUALS); numericvalue : ('-'|'+')? (decimalvalue | integervalue); stringvalue : (anynonescapedchar | escapedchar)+; integervalue : (digitnonzero digit*) | zero; decimalvalue : integervalue PERIOD digit+; nonnegativeintegervalue : (digitnonzero digit* ) | zero; sctid : (H T T P nonspacechar+) |(digitnonzero ( digit ) (digit) (digit) (digit) (digit) ((digit)? | ((digit) (digit)) | ((digit) (digit) (digit)) | ((digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit)) | ((digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit) (digit)))); ws : ( sp | htab | cr | lf | comment )*; // optional white space mws : ( sp | htab | cr | lf | comment )+; // mandatory white space comment : (SLASH ASTERISK) (nonstarchar | starwithnonfslash)* (ASTERISK SLASH); nonstarchar : sp | htab | cr | lf | (EXCLAMATION | QUOTE | POUND | DOLLAR | PERCENT | AMPERSAND | APOSTROPHE | LEFT_PAREN | RIGHT_PAREN) | (PLUS | COMMA | DASH | PERIOD | SLASH | ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | COLON | SEMICOLON | LESS_THAN | EQUALS | GREATER_THAN | QUESTION | AT | CAP_A | CAP_B | CAP_C | CAP_D | CAP_E | CAP_F | CAP_G | CAP_H | CAP_I | CAP_J | CAP_K | CAP_L | CAP_M | CAP_N | CAP_O | CAP_P | CAP_Q | CAP_R | CAP_S | CAP_T | CAP_U | CAP_V | CAP_W | CAP_X | CAP_Y | CAP_Z | LEFT_BRACE | BACKSLASH | RIGHT_BRACE | CARAT | UNDERSCORE | ACCENT | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | LEFT_CURLY_BRACE | PIPE | RIGHT_CURLY_BRACE | TILDE) | UTF8_LETTER; nonspacechar : ('#'| POUND | DOLLAR | PERCENT | AMPERSAND | APOSTROPHE | LEFT_PAREN | RIGHT_PAREN) | (PLUS| COMMA | DASH | PERIOD | SLASH | ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | COLON | SEMICOLON | LESS_THAN | EQUALS | GREATER_THAN | QUESTION | AT | CAP_A | CAP_B | CAP_C | CAP_D | CAP_E | CAP_F | CAP_G | CAP_H | CAP_I | CAP_J | CAP_K | CAP_L | CAP_M | CAP_N | CAP_O | CAP_P | CAP_Q | CAP_R | CAP_S | CAP_T | CAP_U | CAP_V | CAP_W | CAP_X | CAP_Y | CAP_Z | LEFT_BRACE | BACKSLASH | RIGHT_BRACE | CARAT | UNDERSCORE | ACCENT | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | LEFT_CURLY_BRACE | PIPE | RIGHT_CURLY_BRACE | TILDE) | UTF8_LETTER; starwithnonfslash : ASTERISK nonfslash; nonfslash : sp | htab | cr | lf | (EXCLAMATION | QUOTE | POUND | DOLLAR | PERCENT | AMPERSAND | APOSTROPHE | LEFT_PAREN | RIGHT_PAREN | ASTERISK | PLUS | COMMA | DASH | PERIOD) | (ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | COLON | SEMICOLON | LESS_THAN | EQUALS | GREATER_THAN | QUESTION | AT | CAP_A | CAP_B | CAP_C | CAP_D | CAP_E | CAP_F | CAP_G | CAP_H | CAP_I | CAP_J | CAP_K | CAP_L | CAP_M | CAP_N | CAP_O | CAP_P | CAP_Q | CAP_R | CAP_S | CAP_T | CAP_U | CAP_V | CAP_W | CAP_X | CAP_Y | CAP_Z | LEFT_BRACE | BACKSLASH | RIGHT_BRACE | CARAT | UNDERSCORE | ACCENT | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | LEFT_CURLY_BRACE | PIPE | RIGHT_CURLY_BRACE | TILDE) | UTF8_LETTER; sp : SPACE; // space htab : TAB; // tab cr : CR; // carriage return lf : LF; // line feed qm : QUOTE; // quotation mark bs : BACKSLASH; // back slash digit : (ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE); zero : ZERO; digitnonzero : (ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE); nonwsnonpipe : (EXCLAMATION | QUOTE | POUND | DOLLAR | PERCENT | AMPERSAND | APOSTROPHE | LEFT_PAREN | RIGHT_PAREN | ASTERISK | PLUS | COMMA | DASH | PERIOD | SLASH | ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | COLON | SEMICOLON | LESS_THAN | EQUALS | GREATER_THAN | QUESTION | AT | CAP_A | CAP_B | CAP_C | CAP_D | CAP_E | CAP_F | CAP_G | CAP_H | CAP_I | CAP_J | CAP_K | CAP_L | CAP_M | CAP_N | CAP_O | CAP_P | CAP_Q | CAP_R | CAP_S | CAP_T | CAP_U | CAP_V | CAP_W | CAP_X | CAP_Y | CAP_Z | LEFT_BRACE | BACKSLASH | RIGHT_BRACE | CARAT | UNDERSCORE | ACCENT | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | LEFT_CURLY_BRACE) | (RIGHT_CURLY_BRACE | TILDE) | UTF8_LETTER; anynonescapedchar : sp | htab | cr | lf | (SPACE | EXCLAMATION) | (POUND | DOLLAR | PERCENT | AMPERSAND | APOSTROPHE | LEFT_PAREN | RIGHT_PAREN | ASTERISK | PLUS | COMMA | DASH | PERIOD | SLASH | ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | COLON | SEMICOLON | LESS_THAN | EQUALS | GREATER_THAN | QUESTION | AT | CAP_A | CAP_B | CAP_C | CAP_D | CAP_E | CAP_F | CAP_G | CAP_H | CAP_I | CAP_J | CAP_K | CAP_L | CAP_M | CAP_N | CAP_O | CAP_P | CAP_Q | CAP_R | CAP_S | CAP_T | CAP_U | CAP_V | CAP_W | CAP_X | CAP_Y | CAP_Z | LEFT_BRACE) | (RIGHT_BRACE | CARAT | UNDERSCORE | ACCENT | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | LEFT_CURLY_BRACE | PIPE | RIGHT_CURLY_BRACE | TILDE) | UTF8_LETTER; escapedchar : (bs qm) | (bs bs); ////////////////////////////////////////////////////////////////////////// // Lexer rules generated for each distinct character in original grammar // per http://www.unicode.org/charts/PDF/U0000.pdf ////////////////////////////////////////////////////////////////////////// UTF8_LETTER : '\u00C0' .. '\u02FF' | '\u0370' .. '\u037D' | '\u037F' .. '\u1FFF' | '\u200C' .. '\u200D' | '\u2070' .. '\u218F' | '\u2C00' .. '\u2FEF' | '\u3001' .. '\uD7FF' | '\uF900' .. '\uFDCF' | '\uFDF0' .. '\uFFFD' ; TAB : '\t'; LF : '\n'; CR : '\r'; SPACE : ' '; EXCLAMATION : '!'; QUOTE : '"'; POUND : '#'; DOLLAR : '$'; PERCENT : '%'; AMPERSAND : '&'; APOSTROPHE : '\''; LEFT_PAREN : '('; RIGHT_PAREN : ')'; ASTERISK : '*'; PLUS : '+'; COMMA : ','; DASH : '-'; PERIOD : '.'; SLASH : '/'; ZERO : '0'; ONE : '1'; TWO : '2'; THREE : '3'; FOUR : '4'; FIVE : '5'; SIX : '6'; SEVEN : '7'; EIGHT : '8'; NINE : '9'; COLON : ':'; SEMICOLON : ';'; LESS_THAN : '<'; EQUALS : '='; GREATER_THAN : '>'; QUESTION : '?'; AT : '@'; CAP_A : 'A'; CAP_B : 'B'; CAP_C : 'C'; CAP_D : 'D'; CAP_E : 'E'; CAP_F : 'F'; CAP_G : 'G'; CAP_H : 'H'; CAP_I : 'I'; CAP_J : 'J'; CAP_K : 'K'; CAP_L : 'L'; CAP_M : 'M'; CAP_N : 'N'; CAP_O : 'O'; CAP_P : 'P'; CAP_Q : 'Q'; CAP_R : 'R'; CAP_S : 'S'; CAP_T : 'T'; CAP_U : 'U'; CAP_V : 'V'; CAP_W : 'W'; CAP_X : 'X'; CAP_Y : 'Y'; CAP_Z : 'Z'; LEFT_BRACE : '['; BACKSLASH : '\\'; RIGHT_BRACE : ']'; CARAT : '^'; UNDERSCORE : '_'; ACCENT : '`'; A : 'a'; B : 'b'; C : 'c'; D : 'd'; E : 'e'; F : 'f'; G : 'g'; H : 'h'; I : 'i'; J : 'j'; K : 'k'; L : 'l'; M : 'm'; N : 'n'; O : 'o'; P : 'p'; Q : 'q'; R : 'r'; S : 's'; T : 't'; U : 'u'; V : 'v'; W : 'w'; X : 'x'; Y : 'y'; Z : 'z'; LEFT_CURLY_BRACE : '{'; PIPE : '|'; RIGHT_CURLY_BRACE : '}'; TILDE : '~';
grammars/AssignmentStatement2.g4
SadraGoudarzdashti/IUSTCompiler
3
3615
<filename>grammars/AssignmentStatement2.g4 /* grammer AssignmentStatement2 (version 2) @author: <NAME>, (http://webpages.iust.ac.ir/morteza_zakeri/) @date: 20201029 - Compiler generator: ANTRL4.x - Target language(s): Python3.x, -Changelog: -- v2.0 --- add attribute for holding rule type and rule intermediate representations (AST and Three-addresses codes) --- - Reference: Compiler book by Dr. Saeed Parsa (http://parsa.iust.ac.ir/) - Course website: http://parsa.iust.ac.ir/courses/compilers/ - Laboratory website: http://reverse.iust.ac.ir/ */ grammar AssignmentStatement2; start returns [value_attr = str(), type_attr = str()]: prog EOF ; prog returns [value_attr = str(), type_attr = str()]: prog assign | assign ; assign returns [value_attr = str(), type_attr = str()]: ID ':=' expr (NEWLINE | EOF) ; expr returns [value_attr = str(), type_attr = str()]: expr '+' term #expr_term_plus | expr '-' term #expr_term_minus | expr RELOP term #expr_term_relop | term #term4 ; term returns [value_attr = str(), type_attr = str()]: term '*' factor #term_fact_mutiply | term '/' factor #term_fact_divide | factor #factor3 ; factor returns [value_attr = str(), type_attr = str()]: '(' expr ')' #fact_expr | ID #fact_id | number #fact_number ; number returns [value_attr = str(), type_attr = str()]: FLOAT #number_float | INT #number_int ; /* Lexical Rules */ INT : DIGIT+ ; FLOAT: DIGIT+ '.' DIGIT* | '.' DIGIT+ ; String: '"' (ESC|.)*? '"' ; ID: LETTER(LETTER|DIGIT)* ; fragment DIGIT: [0-9] ; fragment LETTER: [a-zA-Z] ; fragment ESC: '\\"' | '\\\\' ; WS: [ \t\r]+ -> skip ; NEWLINE: '\n'; RELOP: '<=' | '<' ;
libsrc/_DEVELOPMENT/adt/b_array/c/sdcc_iy/b_array_resize.asm
jpoikela/z88dk
640
16415
<reponame>jpoikela/z88dk<gh_stars>100-1000 ; int b_array_resize(b_array_t *a, size_t n) SECTION code_clib SECTION code_adt_b_array PUBLIC _b_array_resize EXTERN asm_b_array_resize _b_array_resize: pop af pop hl pop de push de push hl push af jp asm_b_array_resize
iod/qsound/main.asm
olifink/smsqe
0
1964
<filename>iod/qsound/main.asm ; AY-sound chip API and BASIC commands 3.00  2020 <NAME> and <NAME> ; ; Mostly QSOUND compatible where possible, but supports multiple chips. ; Actual hardware access is implemented in separate file. section qsound include 'dev8_keys_qdos_sms' include 'dev8_keys_sys' include 'dev8_keys_err' include 'dev8_keys_qlv' include 'dev8_keys_sbasic' include 'dev8_mac_proc' include 'dev8_iod_qsound_keys' xdef qsound_base xdef qsound.vers xref qsound_drv_init xref ay_hw_setup xref ay_hw_wrreg xref ay_hw_wrall xref ay_hw_type xref ay_hw_freq xref ay_hw_stereo xref ay_hw_volume cmd.count equ 15 qsound.vers equ '3.00' qsound_base lea proc_def,a1 move.w sb.inipr,a2 jsr (a2) bsr.s start jsr qsound_drv_init moveq #0,d0 rts start movem.l a0/a3,-(sp) moveq #sms.info,d0 trap #1 move.l a0,a4 ; Allocate data block move.l #qs_size,d1 moveq #-1,d2 moveq #sms.achp,d0 trap #1 tst.l d0 bne.s start_end move.l a0,sys_qsound(a4) move.l a0,a3 ; QSound data block ; Originally there were sv_aybas and sv_ayjmp, with aybas being the data ; block and ayjmp the code entry. sv_ayjmp has been reserved as sys_qsound ; for a long time, but sv_aybas is apparently also used by Turbo! So the ; new way is to have the data block under sv_ayjmp/sys_qsound and have it start ; with a JMP to the real entry lea mc_entry,a1 ; Construct JMP to real mc_entry move.w #$4ef9,(a3) move.l a1,2(a3) bsr ay_hw_setup bsr ay_reset move.l sys_qsound(a4),a0 ; Link in poll lea int_serve,a1 move.l a1,qs_plad(a0) lea qs_pllk(a0),a0 moveq #sms.lpol,d0 trap #1 ;;; lea gong_tab,a1 ;;; bsr ay_wrall start_end movem.l (sp)+,a0/a3 rts error_ok moveq #0,d0 rts error_bp moveq #err.ipar,d0 rts error_nc moveq #err.nc,d0 rts error_or moveq #err.orng,d0 rts error_om moveq #err.imem,d0 rts error_nimp moveq #err.nimp,d0 rts error_no moveq #err.ichn,d0 rts ; Write d1.b into register d2.b (MC entry) ay_wrreg lea qs_regs_0(a3),a5 ; Chip 0 move.b d2,d0 andi.b #$f,d2 lsr.b #4,d0 beq.s ay_wrreg0 cmp.b qs_chip_count(a3),d0 bcc.s error_or lea qs_regs_1(a3),a5 ; Chip 1 bra.s ay_wrregx ay_wrreg0 cmpi.b #7,d2 bne.s ay_wrregx ; For QSound we need to make sure the I/O ori.b #$c0,d1 ; port of chip 0 is always output (for PAR port) ay_wrregx cmpi.w #13,d2 bhi.s error_or ; Write d1.b into register d2.b, a5 = ptr to chip registers write_reg move.b d1,(a5,d2.w) ; Save in register cache bra ay_hw_wrreg ; Write to h/w ay_rdreg lea qs_regs_0(a3),a5 ; Chip 0 move.b d2,d0 andi.b #$f,d2 lsr.b #4,d0 beq.s ay_rdreg0 cmp.b qs_chip_count(a3),d0 bcc.s error_or lea qs_regs_1(a3),a5 ; Chip 1 ay_rdreg0 cmpi.w #13,d2 bhi.s error_or ; Read the value from register d2.b to d1.b (actually just read cache) ; a5 = ptr to chip registers read_reg moveq #0,d1 move.b (a5,d2.w),d1 moveq #0,d0 rts ; MC entry point mc_entry cmpi.l #cmd.count,d0 bhi error_nc movem.l a3-a4,-(sp) lsl.w #1,d0 lea mc_table,a5 adda.w d0,a5 move.w (a5),a5 lea qsound_base,a4 adda.l a4,a5 bsr.s get_aybas ; Get data block in a3 jsr (a5) movem.l (sp)+,a3-a4 rts ; Get QSound data block in a3 get_aybas movem.l d0-d2/a0,-(sp) moveq #sms.info,d0 trap #1 move.l sys_qsound(a0),a3 movem.l (sp)+,d0-d2/a0 rts ; Free all sound queues free_sound_queues movem.l d5-d7,-(sp) moveq #0,d5 moveq #0,d6 move.b qs_chan_count(a3),d7 free_queue_loop move.l qs_mem(a3,d6.w),d0 beq.s free_next_queue move.l d0,a0 sf qs_act(a3,d5.w) clr.l qs_mem(a3,d6.w) move.l a3,-(sp) moveq #sms.rchp,d0 trap #1 move.l (sp)+,a3 free_next_queue addq.w #4,d6 addq.b #1,d5 cmp.b d5,d7 bne.s free_queue_loop movem.l (sp)+,d5-d7 rts ; Reset AY chip ay_reset move.l d1,-(sp) bsr.s get_aybas bsr.s free_sound_queues lea quiet_tab,a1 moveq #0,d2 ; Chip 0 bsr.s ay_wrall cmp.b #1,qs_chip_count(a3) bne.s ay_reset_end lea quiet_tab,a1 moveq #1,d2 ; Chip 1 bsr.s ay_wrall ay_reset_end move.l (sp)+,d1 moveq #0,d0 rts ; Write 14 bytes block pointed to by a1 into registers 0..13 of AY ; Chip number in d2 ay_wrall cmp.b qs_chip_count(a3),d2 bcc error_bp lea qs_regs_0(a3),a5 tst.b d2 beq.s write_it_all lea qs_regs_1(a3),a5 ; d2 = chip (0/1), a5 = ptr to chip registers write_it_all move.l (a1)+,(a5) move.l (a1)+,4(a5) move.l (a1)+,8(a5) move.w (a1)+,12(a5) tst.b d2 bne.s write_all_1 or.b #$c0,7(a5) ; Keep I/O ports as output (chip 0 only) write_all_1 bra ay_hw_wrall ; Read all 14 registers (in reality gets them from cache) ay_rdall cmp.b qs_chip_count(a3),d2 bcc error_bp lea qs_regs_0(a3),a5 tst.b d2 beq.s read_it_all lea qs_regs_1(a3),a5 read_it_all move.l (a5)+,(a1)+ move.l (a5)+,(a1)+ move.l (a5)+,(a1)+ move.w (a5)+,(a1)+ moveq #0,d0 rts ; Make some noise ay_noise lea explode_tab,a1 andi.w #$ff,d1 cmpi.w #2,d1 bhi error_bp mulu #14,d1 adda.w d1,a1 bra ay_wrall ****************** * Poll interrupt * ****************** int_serve movem.l d0-d7/a0-a6,-(sp) bsr out_sound_queue movem.l (sp)+,d0-d7/a0-a6 rts ********************** * Basic - extensions * ********************** ; POKE_AY (chip),r,v ; ; Set register r (0..13) to v (0..255) of chip (0..1) poke_ay move.w sb.gtint,a2 jsr (a2) bsr get_aybas moveq #0,d2 ; Default to chip 0 subq.w #2,d3 beq.s poke_it subq.w #1,d3 bne error_bp move.w 0(a6,a1.l),d2 ; Chip number addq.l #2,a1 lsl.b #4,d2 poke_it or.w 0(a6,a1.l),d2 ; Add register number move.w 2(a6,a1.l),d1 bra ay_wrreg ; LIST_AY (chip),r0,r1,r2,r3..,r13 ; ; Set all registers at once list_ay move.w sb.gtint,a2 jsr (a2) bsr get_aybas moveq #0,d2 ; Default to chip 0 sub.w #14,d3 beq.s list_it subq.w #1,d3 bne error_bp move.w 0(a6,a1.l),d2 ; Chip number list_it move.l sp,a2 suba.w #14,sp move.l sp,a0 list_ay_loop move.w (a6,a1.l),d0 ; Word array to byte array move.b d0,(a0)+ addq.w #2,a1 cmpa.l a0,a2 bne.s list_ay_loop move.l sp,a1 bsr ay_wrall ; Now write all registers adda.w #14,sp rts ; v = PEEK_AY((chip), r) ; ; Return contents of register r (0..13) peek_ay move.w sb.gtint,a2 jsr (a2) bsr get_aybas moveq #0,d2 ; Default to chip 0 subq.w #1,d3 beq.s peek_it subq.w #1,d3 bne error_bp move.w 0(a6,a1.l),d2 ; Chip number lsl.b #4,d2 addq.l #2,a1 peek_it or.w (a6,a1.l),d2 bsr ay_rdreg tst.l d0 bne.s peek_rts move.w d1,(a6,a1.l) moveq #3,d4 moveq #0,d0 peek_rts rts ; BELL bell lea bell_tab,a1 bsr get_aybas bra ay_wrall ; EXPLODE explode lea explode_tab,a1 bsr get_aybas bra ay_wrall ; SHOOT shoot lea shoot_tab,a1 bsr get_aybas bra ay_wrall *********************************** * Indexes into int_tab jump table * *********************************** set_period equ 0 set_volume equ 1 set_noise equ 2 set_len equ 3 set_susp equ 4 set_rel equ 5 set_n_per equ 6 set_wave equ 7 set_w_len equ 8 ; mc_play ; ; d1.b = channel number 1..6 ; a0 = pointer to string ay_play move.l a0,a1 suba.l a6,a1 move.w d1,d7 bra.s play_all ; PLAY channel, string play suba.l a3,a5 cmpa.l #16,a5 ; Must be two parametrs bne error_bp lea 8(a3),a5 movem.l a3/a5,-(sp) move.w sb.gtint,a2 ; Get channel number jsr (a2) movem.l (sp)+,a3/a5 tst.l d0 bne error_bp moveq #0,d7 move.w 0(a6,a1.l),d7 lea 8(a3),a3 lea 8(a3),a5 move.w sb.gtstr,a2 ; Play string jsr (a2) tst.w d0 bne error_bp ; d7 = channel 1..3 play_all bsr get_aybas tst.w d7 beq error_bp andi.w #$ff,d7 cmp.b qs_chan_count(a3),d7 bhi error_bp subq.w #1,d7 ; d7 = channel 0..5 moveq #0,d6 move.w (a6,a1.l),d6 ; String length tst.w d6 beq error_bp lea qs_act(a3),a2 sf (a2,d7.w) ; Disable channel move.l a1,a4 ; Pointer to string ; a4 = pointer to string lea qs_mem(a3),a2 moveq #0,d1 move.b d7,d1 lsl.w #2,d1 move.l (a2,d1.w),a0 move.l a0,d0 bne play_start_loop ; already a queue? -> append ; Setup a new queue move.l a3,-(sp) move.l #4096,d1 moveq #-1,d2 moveq #sms.achp,d0 trap #1 move.l (sp)+,a3 tst.l d0 bne error_om move.l a0,a1 move.w #1023,d1 play_new_loop clr.l (a1)+ dbra d1,play_new_loop ; clear move.l a3,-(sp) move.l a0,a2 move.l #4096,d1 move.w ioq.setq,a1 ; setup queue jsr (a1) ; Put in commands to set default values move.w ioq.pbyt,a1 moveq #set_volume,d1 jsr (a1) moveq #0,d1 ; volume = 0 jsr (a1) moveq #set_noise,d1 jsr (a1) moveq #0,d1 ; noise = 0 jsr (a1) moveq #set_n_per,d1 jsr (a1) moveq #0,d1 ; noise period = 0 jsr (a1) moveq #set_wave,d1 jsr (a1) moveq #0,d1 ; wave = 0 jsr (a1) moveq #set_w_len,d1 jsr (a1) moveq #0,d1 ; wave_length = 0 jsr (a1) moveq #0,d1 jsr (a1) move.l (sp)+,a3 move.b #4,qs_okt(a3,d7.w) ; octave = 4 move.b #5,qs_len(a3,d7.w) ; len = 5 lea qs_mem(a3),a2 moveq #0,d1 move.b d7,d1 lsl.w #2,d1 move.l a0,(a2,d1.w) ; play queue for this channel ; d6 = string size ; a0 = play queue ; a4 = pointer to string (rel a6) play_start_loop lea play_end,a2 ; Jump to here on exit move.l a2,-(sp) move.l a0,qs_work_queue(a3) addq.w #1,d6 ; just so we can subtract it again adda.l #2,a4 ; skip size play_loop moveq #0,d0 subq.w #1,d6 beq play_rts moveq #0,d1 move.b (a6,a4.l),d1 ; get next char addq.l #1,a4 move.w d1,d2 sub.w #32,d1 ; table is based on ' ' char bcs error_bp cmp.w #96,d1 ; 96 table entries bhi error_bp lea cmd_table,a0 move.b (a0,d1.w),d1 andi.w #$0f,d1 lsl.w #1,d1 lea jump_table,a0 adda.w d1,a0 adda.w (a0),a0 jsr (a0) ; jump to handler tst.w d0 bne.s play_rts bra.s play_loop ; Error in handler, skip returning to play_loop play_error adda.l #4,sp bra error_bp ; Lower case note play_note_kl sub.b #32,d2 ; 'a' -> 'A' ; Upper case note play_note sub.b #'A',d2 lea note_tab,a1 andi.w #$f,d2 lsl.w #1,d2 ; note offsets move.w (a1,d2.w),d1 lea oktave_0,a1 moveq #0,d2 lea qs_okt(a3),a2 move.b (a2,d7.w),d2 mulu #24,d2 ; multiply adda.w d2,a1 moveq #0,d2 lea qs_dif(a3),a2 move.b (a2,d7.w),d2 ; get sharp/flat offset ext.w d2 clr.b (a2,d7.w) ; ... and clear it for next note add.w d2,d1 ; add to note and.l #$fff,d1 move.w (a1,d1.w),d1 play_p_1 moveq #set_period,d2 ; load bra play_word ; Play command finished, enable playing play_end lea qs_act(a3),a2 ; Enable playing st (a2,d7.w) play_rts rts ; 'b': Next note is flat play_lower lea qs_dif(a3),a2 move.b #-2,(a2,d7.w) ; flats rts ; '#': Next note is sharp play_higher lea qs_dif(a3),a2 move.b #2,(a2,d7.w) ; sharps rts ; 'p': Pause playing (one note) play_pause moveq #0,d1 ; set bra.s play_p_1 ; 'v': Set volume play_volume bsr get_num cmpi.w #16,d1 bhi error_or moveq #set_volume,d2 bra play_sub ; 'S': Synchronised wait play_wait moveq #set_susp,d1 ; load bra write_byte ; 'r': Activate channel play_start bsr get_num tst.w d1 beq error_or andi.w #$ff,d1 cmp.b qs_chan_count(a3),d1 bhi error_or subq.w #1,d1 moveq #set_rel,d2 ; load bra.s play_sub ; 'o': Set octave play_oktave bsr get_num cmpi.w #9,d1 bhi error_or lea qs_okt(a3),a2 move.b d1,0(a2,d7.w) rts ; 'n': Noise frequency play_noise bsr.s get_num tst.w d1 beq.s play_n_off andi.w #$ff,d1 moveq #set_n_per,d2 bsr.s play_sub st d1 play_n_off moveq #set_noise,d2 bra.s play_sub ; 'l': Set note length play_length bsr.s get_num moveq #set_len,d2 bra.s play_sub ; 'w': Set wrap curve play_wave bsr.s get_num cmpi.w #15,d1 bhi error_bp moveq #set_wave,d2 bra.s play_sub ; 'x': Set wrap length play_w_length bsr.s get_num moveq #set_w_len,d2 ; Write command and data word play_word move.l d1,-(sp) move.w d2,d1 bsr.s write_byte move.l (sp)+,d1 tst.w d0 bne.s play_rts2 move.l d1,-(sp) and.w #$ff,d1 bsr.s write_byte move.l (sp)+,d1 tst.w d0 bne.s play_rts2 lsr.w #8,d1 and.w #$ff,d1 bsr.s write_byte play_rts2 rts ; Write command and data byte play_sub move.l d1,-(sp) move.w d2,d1 bsr.s write_byte move.l (sp)+,d1 tst.w d0 bne.s play_rts2 ;;; bra.s write_byte ; Put byte d1 into queue write_byte move.l qs_work_queue(a3),a2 write_byte_1 move.l a3,-(sp) move.w ioq.pbyt,a1 jsr (a1) move.l (sp)+,a3 rts ; Translate ASCII number to integer get_num lea qs_work_num(a3),a5 moveq #0,d1 get_loop move.b (a6,a4.l),d2 cmpi.b #47,d2 bls.s get_end cmpi.b #'9',d2 bhi.s get_end adda.l #1,a4 addq.w #1,d1 subq.w #1,d6 move.b d2,(a5)+ cmpi.b #4,d1 bne.s get_loop get_end tst.b d1 beq.s get_end_all moveq #0,d2 moveq #1,d3 get_e_1 tst.b d1 beq.s get_e_2 moveq #0,d4 move.b -(a5),d4 sub.b #'0',d4 mulu d3,d4 add.w d4,d2 mulu #10,d3 subq.w #1,d1 bra.s get_e_1 get_e_2 move.l d2,d1 get_end_all rts ; RELEASE <ch> ; ; Release all (no parameter) or a specific channel release move.w sb.gtint,a2 jsr (a2) tst.w d3 beq.s ay_relse_all subq.w #1,d3 bne error_bp move.w (a6,a1.l),d1 ay_relse tst.b d1 beq.s ay_relse_all bsr get_aybas subq.w #1,d1 cmp.w qs_chan_count(a3),d1 bcc error_or lea qs_mem(a3),a1 move.w d1,d2 lsl.w #2,d2 tst.l (a1,d2.w) beq error_no lea qs_act(a3),a1 st (a1,d1.w) ; Enable playing moveq #0,d0 rts ay_relse_all bsr get_aybas lea qs_act(a3),a1 move.b qs_chan_count(a3),d0 ay_relse_all_loop st (a1)+ ; Enable all channels subq.b #1,d0 bne.s ay_relse_all_loop moveq #0,d0 rts ; val = PLAYING(ch) ; ; Check if queue of channel is currently playing playing move.w sb.gtint,a2 jsr (a2) tst.w d0 bne.s playing_rts cmpi.w #1,d3 bne error_bp move.w (a6,a1.l),d1 bsr.s ay_tstpl tst.w d0 bne.s playing_rts move.w d1,0(a6,a1.l) move.l a1,sb_arthp(a6) moveq #0,d0 moveq #3,d4 playing_rts rts ay_tstpl bsr get_aybas andi.w #$ff,d1 subq.w #1,d1 cmp.b qs_chan_count(a3),d1 bcc error_or move.w d1,d2 lea qs_mem(a3),a2 lsl.w #2,d2 tst.l (a2,d2.w) beq error_no lea qs_act(a3),a2 move.b (a2,d1.w),d1 andi.w #1,d1 moveq #0,d0 rts ; HOLD n ; ; Stop all (no parameter) or a specific interrupt list hold move.w sb.gtint,a2 jsr (a2) tst.w d3 beq.s ay_hold_all ; No param -> hold all cmpi.w #1,d3 bne error_bp move.w (a6,a1.l),d1 ; List to hold ay_hold tst.b d1 beq.s ay_hold_all ; List 0 -> hold all bsr get_aybas andi.w #$ff,d1 subq.w #1,d1 cmp.b qs_chan_count(a3),d1 bcc error_bp move.w d1,d2 lsl.w #2,d2 lea qs_mem(a3),a1 tst.l (a1,d2.w) beq error_no lea qs_act(a3),a1 sf (a1,d1.w) moveq #0,d0 rts ay_hold_all bsr get_aybas lea qs_act(a3),a1 moveq #0,d0 move.l d0,(a1)+ ; Stop all 6 (possible) channels move.w d0,(a1)+ rts ; ENVELOPE shape, period envelope move.w sb.gtint,a2 jsr (a2) tst.w d0 bne.s env_rts cmpi.w #2,d3 bne error_bp move.w 0(a6,a1.l),d6 ; Envelope shape cmpi.w #$f,d6 bhi error_or move.w 2(a6,a1.l),d7 ; Envelope period cmpi.w #4095,d7 bhi error_or bsr get_aybas move.w d6,d1 moveq #ay_env_shape,d2 bsr ay_wrreg move.w d7,d1 andi.w #$FF,d1 moveq #ay_env_period_l,d2 bsr ay_wrreg move.w d7,d1 lsr.w #8,d1 moveq #ay_env_period_h,d2 bsr ay_wrreg moveq #0,d0 env_rts rts ; Polled interrupt sound handler out_sound_queue bsr get_aybas moveq #0,d6 ; Channel within chip moveq #0,d7 ; Total channel lea qs_regs_0(a3),a5 out_sound_loop cmp.b #3,d7 bne.s out_no_chip_change lea qs_regs_1(a3),a5 moveq #0,d6 ; Start from channel 0 again out_no_chip_change bsr.s out_queue addq.w #1,d6 addq.w #1,d7 cmp.b qs_chan_count(a3),d7 bne.s out_sound_loop rts out_queue lea qs_mem(a3),a2 move.l d7,d3 lsl.w #2,d3 tst.l (a2,d3.w) ; Any output queue? beq.s out_rts ; ... no, next channel lea qs_act(a3),a2 tst.b (a2,d7.w) ; Queue enabled? beq.s out_rts ; ... no, next channel moveq #0,d1 lea qs_count(a3),a2 ; Remaining note length move.b (a2,d7.w),d1 tst.b d1 beq.s out_q_1 ; Get next queue command subq.w #1,d1 ; Note remains a bit longer move.b d1,(a2,d7.w) out_rts rts out_q_1 bsr get_byte ; Next byte out of queue tst.w d0 bne.s out_susp ; ... done, suspend output cmpi.b #set_w_len,d1 ; Command valdi? bhi.s out_susp ; ... no, suspend output andi.l #$0f,d1 lea int_tab,a0 lsl.w #1,d1 adda.w d1,a0 adda.w (a0),a0 jmp (a0) ; Jump to next command out_q_end lea qs_len(a3),a2 lea qs_count(a3),a4 move.b (a2,d7.w),(a4,d7.w) ; count = len rts out_q_e_0 lea qs_count(a3),a2 clr.b (a2,d7.w) ; count = 0 rts out_period bsr get_byte tst.w d0 bne.s out_susp move.w d1,d4 bsr get_byte tst.w d0 bne.s out_susp move.w d1,d5 moveq #0,d3 move.b d6,d3 lsl.w #1,d3 ; Tune register low for ch <d6> move.w d3,d2 move.w d4,d1 bsr write_reg addq.w #1,d3 ; Tune register high move.w d3,d2 move.w d5,d1 bsr write_reg bra out_q_end out_len bsr get_byte tst.w d0 bne.s out_susp lea qs_len(a3),a2 move.b d1,(a2,d7.w) bra out_q_1 out_susp lea qs_act(a3),a2 sf (a2,d7.w) ; Not playing anymore bra out_q_end out_rel bsr get_byte tst.w d0 bne.s out_susp andi.w #$ff,d1 lea qs_act(a3),a2 st (a2,d1.w) ; Now playing bra out_q_e_0 out_n_per bsr get_byte tst.w d0 bne.s out_susp moveq #ay_noise_period,d2 bsr write_reg bra out_q_e_0 out_volume bsr get_byte tst.w d0 bne.s out_susp tst.b d1 beq.s out_vol_0 moveq #ay_amplitude_a,d2 add.b d6,d2 ; ay_amplitude_<d6> bsr write_reg moveq #ay_enable,d2 bsr read_reg bclr d6,d1 ; Enable tone <d6> bsr write_reg bra out_q_1 out_vol_0 moveq #ay_amplitude_a,d2 add.b d6,d2 ; ay_amplitude_<d6> bsr write_reg moveq #ay_enable,d2 bsr read_reg bset d6,d1 ; Disable tone <d6> bsr write_reg bra out_q_1 out_noise bsr.s get_byte tst.w d0 bne.s out_susp tst.b d1 beq.s out_n_reset move.w d6,d3 ; 0..2 addq.w #3,d3 ; 3..5 moveq #ay_enable,d2 bsr read_reg bclr d3,d1 ; Enable noise <d6> bsr write_reg bra out_q_1 out_n_reset move.w d6,d3 addq.w #3,d3 moveq #ay_enable,d2 bsr read_reg bset d3,d1 ; Disable noise <d6> bsr write_reg bra out_q_1 out_wave bsr.s get_byte tst.w d0 bne out_susp moveq #ay_env_shape,d2 bsr write_reg bra out_q_1 out_w_len bsr.s get_byte tst.w d0 bne out_susp move.w d1,d4 bsr.s get_byte tst.w d0 bne out_susp move.w d1,d5 move.w d4,d1 moveq #ay_env_period_l,d2 bsr write_reg move.w d5,d1 moveq #ay_env_period_h,d2 bsr write_reg bra out_q_1 get_byte move.l a3,-(sp) lea qs_mem(a3),a2 moveq #0,d5 move.b d7,d5 lsl.w #2,d5 move.l (a2,d5.w),a2 move.w ioq.gbyt,a1 jsr (a1) move.l (sp)+,a3 andi.l #$ff,d1 rts ; Machine code entry point for SOUND ; ; d1 = Channel number ; d2 = Frequency ; d3 = Volume sound_mc tst.w d1 beq ay_reset ; Stop all sounds bsr get_aybas move.w d2,d0 or.w d3,d0 beq sound_v0_mc ; Stop sound for this channel movem.l a0-a2/a4/d4-d7,-(sp) andi.l #$fff,d2 move.l #93750,d4 divu d2,d4 move.l d1,d5 move.l d1,d2 add.w d2,d2 ; ay_tune_a_<d5>_l move.b d4,d1 bsr ay_wrreg move.w d4,d1 lsr.w #8,d1 addq.w #1,d2 ; ay_tune_a_<d5>_h bsr ay_wrreg moveq #ay_amplitude_a,d2 add.w d5,d2 ; ay_amplitude_<d5> move.b d3,d1 bsr ay_wrreg moveq #ay_enable,d2 bsr ay_rdreg bclr d5,d1 ; Enable tone <d5> addq.w #3,d5 bset d5,d1 ; Disable noise <d5> bsr ay_wrreg movem.l (sp)+,a0-a2/a4/d4-d7 rts ; SOUND n, f, v ; ; Set sound output of channel n to frequency f with volume v sound move.w sb.gtfp,a2 jsr (a2) bsr get_aybas tst.w d3 beq ay_reset ; No parameter -> stop all sounds cmpi.w #1,d3 beq sound_v0 ; One parameter -> stop channel cmpi.w #3,d3 bne error_bp sound_all move.w qa.op,a2 moveq #qa.int,d0 jsr (a2) tst.w d0 bne sound_rts move.w 0(a6,a1.l),d4 tst.w d4 beq error_or cmpi.w #3,d4 bhi error_or lea qs_data(a3),a0 subq.w #1,d4 move.w d4,(a0) ; Channel number subq.l #4,a1 move.l #$8115B8D,0(a6,a1.l) ; 93750 move.w #$8000,4(a6,a1.l) tst.l 6(a6,a1.l) bne.s sound_1 tst.w 10(a6,a1.l) bne.s sound_1 adda.l #12,a1 lea qs_data(a3),a0 clr.w 2(a0) ; 2(a0) Frequency bra.s sound_2 sound_1 lea qs_data(a3),a0 ; Only temporary memory in this case move.l 0(a6,a1.l),2(a0) ; Swap TOS and NOS move.w 4(a6,a1.l),6(a0) move.l 6(a6,a1.l),0(a6,a1.l) move.w 10(a6,a1.l),4(a6,a1.l) move.l 2(a0),6(a6,a1.l) move.w 6(a0),10(a6,a1.l) move.l (a3),-(sp) move.w qa.mop,a2 lea operation1,a3 jsr (a2) move.l (sp)+,a3 tst.l d0 bne sound_rts lea qs_data(a3),a0 move.w 0(a6,a1.l),2(a0) ; 2 (a0) frequency adda.l #2,a1 sound_2 move.w qa.op,a2 moveq #qa.int,d0 jsr (a2) tst.l d0 bne.s sound_rts lea qs_data(a3),a0 move.w 0(a6,a1.l),4(a0) ; 4(a0) volume cmpi.w #4095,2(a0) bhi error_or cmpi.w #16,4(a0) bhi error_or moveq #0,d2 move.w (a0),d2 ; channel add.w d2,d2 ; ay_tune_<ch>_l moveq #0,d1 move.w 2(a0),d1 ; frequency andi.w #$ff,d1 bsr ay_wrreg move.w 2(a0),d1 ; frequency lsr.w #8,d1 andi.w #$F,d1 addq.w #1,d2 ; ay_tune_<ch>_h bsr ay_wrreg moveq #ay_amplitude_a,d2 add.w (a0),d2 ; ay_amplitude_<ch> move.w 4(a0),d1 ; volume bsr ay_wrreg moveq #ay_enable,d2 bsr ay_rdreg move.w (a0),d3 ; channel bclr d3,d1 ; enable addq.w #3,d3 bset d3,d1 ; disable noise bsr ay_wrreg moveq #0,d0 sound_rts rts ; Stop sound for channel d1 sound_v0_mc move.w d1,d4 bra.s sound_v0_all sound_v0 moveq #qa.int,d0 move.w qa.op,a2 jsr (a2) tst.w d0 bne.s sound_rts move.w 0(a6,a1.l),d4 sound_v0_all tst.w d4 beq error_or cmpi.w #3,d4 bhi error_or subq.w #1,d4 move.w d4,d2 moveq #0,d3 move.b d4,d3 add.w d2,d2 ; ay_tune_<ch>_l moveq #0,d1 bsr ay_wrreg addq.w #1,d2 ; ay_tune_<ch>_h bsr ay_wrreg move.w d4,d2 addq.w #ay_amplitude_a,d2 ; ay_amplitude_<ch> bsr ay_wrreg moveq #ay_enable,d2 bsr ay_rdreg bset d3,d1 ; silence tone bsr ay_wrreg andi.l #$f,d4 sf qs_act(a3,d4.w) move.w #$4000,d1 swait dbra d1,swait lea qs_mem(a3),a1 lsl.w #2,d4 tst.l (a1,d4.w) beq sound_rts move.l (a1,d4.w),a0 clr.l (a1,d4.w) moveq #sms.rchp,d0 trap #1 moveq #0,d0 rts qa_resri moveq #6,d1 move.w qa.resri,a1 jmp (a1) ; version = AY_VER$ ay_ver$ bsr.s qa_resri move.l sb_arthp(a6),a1 subq.l #6,a1 move.w #4,(a6,a1.l) move.l #qsound.vers,2(a6,a1.l) move.l a1,sb_arthp(a6) moveq #1,d4 moveq #0,d0 rts ; count = AY_CHIPS ay_chips moveq #qs_chip_count,d5 bra.s ay_ret_byte ; type = AY_TYPE ay_type move.w #qs_chip_type,d5 ; Fall-through ; Byte index in d5 ay_ret_byte bsr.s qa_resri bsr get_aybas moveq #0,d1 move.w (a3,d5.w),d1 move.l sb_arthp(a6),a1 subq.l #2,a1 move.w d1,(a6,a1.l) move.l a1,sb_arthp(a6) moveq #3,d4 moveq #0,d0 rts ; Get version in d1, chip count in d2 ay_info_mc move.l #qsound.vers,d1 moveq #0,d2 move.b qs_chip_count(a3),d2 rts ; Get/set chip type ay_type_mc tst.l d1 bmi.s ay_type_get bsr ay_hw_type bmi.s ay_type_rts move.b d1,qs_chip_type(a3) ay_type_get moveq #0,d1 move.b qs_chip_type(a3),d1 moveq #0,d0 ay_type_rts rts ; Get/set chip frequency ay_freq_mc tst.l d1 bmi.s ay_freq_get bsr ay_hw_freq bmi.s ay_freq_rts move.l d1,qs_chip_freq(a3) ay_freq_get move.l qs_chip_freq(a3),d1 moveq #0,d0 ay_freq_rts rts ; Get/set stereo mode ay_stereo_mc tst.l d1 bmi.s ay_stereo_get bsr ay_hw_stereo bmi.s ay_stereo_rts move.b d1,qs_stereo(a3) ay_stereo_get moveq #0,d1 move.b qs_stereo(a3),d1 moveq #0,d0 ay_stereo_rts rts ; Get/set volume ay_volume_mc tst.l d1 bmi.s ay_volume_get bsr ay_hw_volume bmi.s ay_volume_rts move.b d1,qs_volume(a3) ay_volume_get moveq #0,d1 move.b qs_volume(a3),d1 moveq #0,d0 ay_volume_rts rts ; Basic definitions proc_def proc_stt proc_ref BELL proc_ref EXPLODE proc_ref SHOOT proc_ref POKE_AY proc_ref LIST_AY proc_ref PLAY proc_ref HOLD proc_ref RELEASE proc_ref ENVELOPE proc_ref SOUND proc_end proc_stt proc_ref PEEK_AY proc_ref PLAYING proc_ref AY_CHIPS proc_ref AY_TYPE proc_end quiet_tab dc.b 0,0,0,0,0,0,0,$ff,0,0,0,0,0,0 explode_tab dc.b 0,0,0,0,0,0,$1f,7,16,16,16,0,16,0 shoot_tab dc.b 0,0,0,0,0,0,$10,7,16,16,16,0,3,0 bell_tab dc.b 100,0,101,0,0,0,0,248,16,16,0,0,4,0 gong_tab dc.b 60,0,61,0,63,0,0,248,16,16,16,0,9,0 ; Update cmd.count when extending the table mc_table dc.w ay_reset-qsound_base ; 0 dc.w ay_wrreg-qsound_base ; 1 dc.w ay_rdreg-qsound_base ; 2 dc.w ay_wrall-qsound_base ; 3 dc.w ay_rdall-qsound_base ; 4 dc.w ay_play-qsound_base ; 5 dc.w ay_tstpl-qsound_base ; 6 dc.w ay_hold-qsound_base ; 7 dc.w ay_relse-qsound_base ; 8 dc.w ay_noise-qsound_base ; 9 dc.w sound_mc-qsound_base ; 10 dc.w ay_info_mc-qsound_base ; 11 dc.w ay_type_mc-qsound_base ; 12 dc.w ay_freq_mc-qsound_base ; 13 dc.w ay_stereo_mc-qsound_base ; 14 dc.w ay_volume_mc-qsound_base ; 15 operation1 dc.b qa.div,qa.int,0,0 int_tab dc.w out_period-* dc.w out_volume-* dc.w out_noise-* dc.w out_len-* dc.w out_susp-* dc.w out_rel-* dc.w out_n_per-* dc.w out_wave-* dc.w out_w_len-* cmd_table dc.b 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dc.b 0,12,2,12,12,12,12,12,12,0,0,0,3,0,7,8 dc.b 9,0,6,5,0,0,4,10,11,0,0,0,0,0,0,0 dc.b 0,13,2,13,13,13,13,13,13,0,0,0,3,0,7,8 dc.b 9,0,6,5,0,0,4,10,11,0,0,0,0,0,0,0 jump_table dc.w play_error-* dc.w play_higher-* dc.w play_lower-* dc.w play_length-* dc.w play_volume-* dc.w play_wait-* dc.w play_start-* dc.w play_noise-* dc.w play_oktave-* dc.w play_pause-* dc.w play_wave-* dc.w play_w_length-* dc.w play_note-* dc.w play_note_kl-* note_tab dc.w 18,255,0,4,8,10,14,22 okt_tab dc.w 4000 oktave_0 dc.w 3822,3608,3405,3214,3034,2863,2703,2551,2408,2273,2145,2025 oktave_1 dc.w 1911,1804,1703,1607,1517,1432,1351,1276,1204,1136,1073,1012 oktave_2 dc.w 956,902,851,804,758,716,676,638,602,568,536,506 oktave_3 dc.w 478,451,426,402,379,358,338,319,301,284,268,253 oktave_4 dc.w 239,225,213,201,190,179,169,159,150,142,134,127 oktave_5 dc.w 119,113,106,100,95,89,84,80,75,71,67,63 oktave_6 dc.w 60,56,53,50,47,45,42,40,38,36,34,32 oktave_7 dc.w 30,28,27,25,24,22,21,20,19,18,17,16 oktave_8 dc.w 15,14,13,12,12,11,10,10,9,9,8,8 oktave_9 dc.w 7,7,6,6,6,5,5,5,4,4,4,4 dc.w 3 end
oeis/276/A276602.asm
neoneye/loda-programs
11
19200
<reponame>neoneye/loda-programs<filename>oeis/276/A276602.asm ; A276602: Values of k such that k^2 + 10 is a triangular number (A000217). ; Submitted by <NAME>(s1.) ; 0,9,54,315,1836,10701,62370,363519,2118744,12348945,71974926,419500611,2445028740,14250671829,83059002234,484103341575,2821561047216,16445262941721,95850016603110,558654836676939,3256079003458524,18977819184074205,110610836100986706,644687197421846031,3757512348430089480,21900386893158690849,127644809010522055614,743968467169973642835,4336165994009319801396,25273027496885945165541,147301998987306351191850,858538966426952161985559,5003931799574406620721504,29165051831019487562343465 lpb $0 sub $0,1 add $2,$1 add $1,$2 add $1,$2 add $1,1 add $2,$1 lpe mov $0,$1 mul $0,9
_build/dispatcher/jmp_ippsPRNGGetSeed_3f32a76b.asm
zyktrcn/ippcp
1
84224
<filename>_build/dispatcher/jmp_ippsPRNGGetSeed_3f32a76b.asm extern m7_ippsPRNGGetSeed:function extern n8_ippsPRNGGetSeed:function extern y8_ippsPRNGGetSeed:function extern e9_ippsPRNGGetSeed:function extern l9_ippsPRNGGetSeed:function extern n0_ippsPRNGGetSeed:function extern k0_ippsPRNGGetSeed:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsPRNGGetSeed .Larraddr_ippsPRNGGetSeed: dq m7_ippsPRNGGetSeed dq n8_ippsPRNGGetSeed dq y8_ippsPRNGGetSeed dq e9_ippsPRNGGetSeed dq l9_ippsPRNGGetSeed dq n0_ippsPRNGGetSeed dq k0_ippsPRNGGetSeed segment .text global ippsPRNGGetSeed:function (ippsPRNGGetSeed.LEndippsPRNGGetSeed - ippsPRNGGetSeed) .Lin_ippsPRNGGetSeed: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsPRNGGetSeed: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsPRNGGetSeed] mov r11, qword [r11+rax*8] jmp r11 .LEndippsPRNGGetSeed:
8088/bus_test/crtc_ma.asm
reenigne/reenigne
92
83124
<filename>8088/bus_test/crtc_ma.asm<gh_stars>10-100 %include "../defaults_bin.asm" mov dx,0x3d4 mov ax,0x000c out dx,ax inc ax out dx,ax mov ax,0x0004 out dx,ax mov ax,0x0005 out dx,ax mov ax,0x0009 out dx,ax mov ax,0x0308 out dx,ax mov al,16 out dx,al mov ax,cs mov es,ax mov ds,ax mov di,end mov si,di mov cx,0x4000 mov dl,0xdc looptop: in al,dx ; 0x3dc: Activate light pen dec dx in al,dx ; 0x3db: Clean light pen strobe ; mov dl,0xd4 ; mov al,17 ; out dx,al ; 0x3d4<-17: light pen low ; inc dx ; in al,dx ; 0x3d5: register value ; stosb ; dec dx ; mov al,16 ; out dx,al ; 0x3d4<-16: light pen high ; inc dx ; in al,dx ; 0x3d5: register value ; stosb mov dl,0xd5 in al,dx stosb stosb mov dl,0xdc loop looptop mov cx,0x4000 looptop2: lodsw printHex printCharacter ' ' dec cx lodsw printHex printCharacter ' ' dec cx lodsw printHex printCharacter ' ' dec cx lodsw printHex printNewLine loop looptop2 complete end:
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_850.asm
ljhsiun2/medusa
9
92269
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0xa63f, %rbp nop nop and $52087, %r11 mov $0x6162636465666768, %rdi movq %rdi, (%rbp) sub %rbp, %rbp lea addresses_WT_ht+0xcd5, %r8 nop nop nop nop sub $17060, %rbx and $0xffffffffffffffc0, %r8 vmovaps (%r8), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %r9 nop nop nop xor $51640, %r9 lea addresses_D_ht+0x1d315, %r11 nop nop nop nop nop and %r9, %r9 vmovups (%r11), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rbp nop nop nop sub %rbx, %rbx lea addresses_A_ht+0x13185, %rsi lea addresses_WT_ht+0x3d5, %rdi nop add %r11, %r11 mov $126, %rcx rep movsw nop nop nop nop nop and %r9, %r9 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r14 push %rbp push %rbx push %rdi // Load lea addresses_PSE+0x18ed5, %r12 sub $41260, %r13 mov (%r12), %rbp nop nop nop nop sub %r13, %r13 // Load lea addresses_A+0x19bb2, %r12 nop nop nop nop xor $7181, %rdi mov (%r12), %r11w nop nop add %rbp, %rbp // Store lea addresses_WC+0xbfaf, %rbp nop nop nop cmp %r13, %r13 movw $0x5152, (%rbp) and $39157, %rbx // Store lea addresses_normal+0xa4d5, %rdi nop nop inc %r14 movw $0x5152, (%rdi) nop nop nop and $20061, %r11 // Faulty Load lea addresses_RW+0xe8d5, %r11 nop nop nop and %r14, %r14 movb (%r11), %r12b lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rdi pop %rbx pop %rbp pop %r14 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_RW', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_RW', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
libsrc/_DEVELOPMENT/l/z80/ascii/txt_to_num/small/l_small_atoul.asm
Toysoft/z88dk
8
96841
SECTION code_clib SECTION code_l PUBLIC l_small_atoul l_small_atoul: ; ascii buffer to unsigned long conversion ; whitespace is not skipped ; char consumption stops on overflow ; ; enter : de = char * ; ; exit : bc = & next char to interpret in buffer ; dehl = unsigned result (0 on invalid input) ; carry set on unsigned overflow ; ; uses : af, bc, de, hl ld c,e ld b,d ld de,0 ld l,e ld h,d dec bc push de push hl loop: pop af pop af inc bc ld a,(bc) sub '0' ccf ret nc cp 10 ret nc push de push hl add hl,hl rl e rl d jr c, overflow_0 push de push hl add hl,hl rl e rl d jr c, overflow_0 add hl,hl rl e rl d jr c, overflow_0 ex de,hl ex (sp),hl add hl,de pop de ex (sp),hl adc hl,de ex de,hl pop hl jr c, overflow_1 add a,l ld l,a jr nc, loop inc h jr nz, loop inc e jr nz, loop inc d jr nz, loop overflow_1: pop hl pop de scf ret overflow_0: pop af pop af jr overflow_1
source/expression/evaluate.asm
paulscottrobson/x16-basic
1
165006
<reponame>paulscottrobson/x16-basic<filename>source/expression/evaluate.asm ; ***************************************************************************** ; ***************************************************************************** ; ; Name : evaluate.asm ; Purpose : Basic Expression Evaluation ; Author : <NAME> (<EMAIL>) ; Date : 7th February 2020 ; ; ***************************************************************************** ; ***************************************************************************** ; ***************************************************************************** ; ; Evaluate an expression starting from empty stack with lowest precedence ; ; ***************************************************************************** EvaluateExpression: ldx #0 ; reset the evaluation stack pointer in X ; ***************************************************************************** ; ; Evaluate lowest precedence, current stack level ; ; ***************************************************************************** EvaluateExpressionAtX: lda #$10 ; this is the lowest precedence. ; ***************************************************************************** ; ; Evaluate at precedence A, current stack level ; ; ***************************************************************************** EvaluateExpressionAtXPrecA: pha ; save lowest stack level. lda (codePtr),y ; get the first term. bmi _EXAKeywordData ; is it keyword, or data. cmp #$40 ; is it a variable (0-3F) bcc _EXAVariable ; iny ; skip over the short constant and #$3F ; short constant $00-$3F sta xsIntLow,x ; and put as an integer stz xsIntHigh,x stz xsStatus,x ; integer, number, not a reference. ; ; Come here when we have a term. Current precedence on stack ; _EXAHaveTerm: pla ; restore current precedence and save in zTemp1 sta zTemp1 lda (codePtr),y ; is it followed by a binary operation. phx tax lda TokenControlByteTable-$80,x ; get the control byte. plx cmp #$20 ; must be $10-$17 (or possibly $00, will be < precedence) bcs _EXAExit cmp zTemp1 ; check against current precedence. beq _EXAExit bcs _EXABinaryOp ; if >, do a binary operation. _EXAExit: rts ; exit expression evaluation. ; ; Handle a binary operation. ; _EXABinaryOp: sta zTemp1+1 ; save operator. lda zTemp1 ; get and save current precedence pha ; lda (codePtr),y ; push binary operator on stack pha iny ; and skip over it. ; inx ; calculate the RHS in the next slot up. lda zTemp1+1 ; at operator precedence level. jsr EvaluateExpressionAtXPrecA dex ; pla ; get binary operator. phx ; save stack depth. asl a ; double binary operator and put into X, loses MSB tax lda TokenVectors,x ; get address => zTemp2 sta zTemp2 lda TokenVectors+1,x sta zTemp2+1 plx ; restore stack depth. jsr _EXACallZTemp2 ; call the routine bra _EXAHaveTerm ; and loop round again. ; ; Variable reference comes here. ; _EXAVariable: jsr VariableLookup ; look up the variable value perhaps creating it. bra _EXAHaveTerm ; and carry on with the expression ; ; Token / Reference where term is expected here. ; _EXAKeywordData: cmp #TOK_MINUS ; special case as - is unary and binary operator. bne _EXANotNegate iny jsr EvaluateTermAtX ; the term jsr IntegerNegate ; negate it bra _EXAHaveTerm ; and loop back. ; _EXANotNegate: cmp #$F8 ; $80-$F8 are unary functions bcc _EXAUnaryFunction cmp #TOK_STRING_OBJ ; $FB is a string. beq _EXAString ; ; Now handle $FE (byte constant) $FF (int constant) ; stz xsStatus,x ; it is now either $FE (short int) or $FF (long int) stz xsIntHigh,x pha ; save identifier iny ; do the low byte lda (codePtr),y sta xsIntLow,x iny pla ; get identifier cmp #TOK_BYTE_OBJ ; if short then done. beq _EXAHaveTerm cmp #TOK_WORD_OBJ ; should be $FF bne _EXACrash lda (codePtr),y ; copy high byte sta xsIntHigh,x iny bra _EXAHaveTerm _EXACrash: ; internal error should not happen. berror "#X" ; ; String ; _EXAString: iny ; point to string length, which is the string start. tya ; work out the physical address of the string clc adc codePtr sta xsAddrLow,x lda codePtr+1 adc #0 sta xsAddrHigh,x lda #$40 ; set the type to string sta xsStatus,x ; tya ; add the length to the current position sec ; +1 for the length byte itself. adc (codePtr),y tay jmp _EXAHaveTerm ; ; Unary Function. A contains its token. ; _EXAUnaryFunction: phx ; get the table entry to check it is a unary function tax bit TokenControlByteTable-$80,x ; if bit 6 is not set, it's not a unary function. bvc _EXANotUnaryFunction txa ; now copy the routine address, put token x 2 in. asl a tax lda TokenVectors,x ; get address => zTemp2 sta zTemp2 lda TokenVectors+1,x sta zTemp2+1 plx ; restore stack depth. iny ; skip unary function token. jsr _EXACallZTemp2 ; call the routine jmp _EXAHaveTerm ; and loop round again. ; _EXANotUnaryFunction: jmp SyntaxError _EXACallZTemp2: ; so we can jsr (zTemp2) jmp (zTemp2)
solutions/07 - Collation Station/size-21_speed-4.asm
michaelgundlach/7billionhumans
45
94751
-- 7 Billion Humans (2087) -- -- 7: Collation Station -- -- Author: landfillbaby -- Size: 21 -- Speed: 4 step s step s step s if n == datacube: pickup n jump a endif step s if n == datacube: pickup n jump b endif step s if n == datacube: pickup n jump c endif step s pickup n jump d a: step s b: step s c: step s d: drop
libsrc/msx/set_vdp_reg.asm
grancier/z180
0
3790
<gh_stars>0 ; ; MSX specific routines ; ; GFX - a small graphics library ; Copyright (C) 2004 <NAME> ; ; void set_vdp_reg(int reg, int value); ; ; Write data to a VDP register ; ; $Id: set_vdp_reg.asm,v 1.5 2016/06/16 19:30:25 dom Exp $ ; SECTION code_clib PUBLIC set_vdp_reg PUBLIC _set_vdp_reg EXTERN msxbios INCLUDE "msxbios.def" set_vdp_reg: _set_vdp_reg: pop hl pop de pop bc push bc ; register push de ; value push hl ; RET address push ix ld b,e ld ix,WRTVDP call msxbios pop ix ret
programs/oeis/111/A111982.asm
karttu/loda
0
86712
; A111982: Row sums of abs(A111967). ; 1,1,2,3,2,4,2,5,2,4,2,6,2,4,2,7,2,4,2,6,2,4,2,8,2,4,2,6,2,4,2,9,2,4,2,6,2,4,2,8,2,4,2,6,2,4,2,10,2,4,2,6,2,4,2,8,2,4,2,6,2,4,2,11,2,4,2,6,2,4,2,8,2,4,2,6,2,4,2,10,2,4,2,6,2,4,2,8,2,4,2,6,2,4,2,12,2,4,2,6,2 mov $7,$0 mov $9,2 lpb $9,1 mov $0,$7 sub $9,1 add $0,$9 sub $0,1 mov $3,1 mov $5,1 lpb $0,1 add $3,$0 sub $0,1 add $3,$0 div $0,2 lpe mul $5,$3 mov $6,$4 add $6,$5 mov $2,$6 mov $8,$9 lpb $8,1 mov $1,$2 sub $8,1 lpe lpe lpb $7,1 sub $1,$2 mov $7,0 lpe
programs/oeis/302/A302777.asm
karttu/loda
0
94954
<filename>programs/oeis/302/A302777.asm ; A302777: a(n) = 1 if n is of the form p^(2^k) where p is prime and k >= 0, otherwise 0. ; 0,1,1,1,1,0,1,0,1,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0 cal $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. mov $2,$0 div $2,2 mul $2,3 sub $2,1 log $0,$2 add $0,2 mov $1,$0 sub $1,2
TotalParserCombinators/Derivative.agda
yurrriq/parser-combinators
7
11711
------------------------------------------------------------------------ -- A derivative operator for parsers ------------------------------------------------------------------------ -- Similar to the derivative operator in Brzozowski's "Derivatives of -- Regular Expressions". module TotalParserCombinators.Derivative where -- Definition of the derivative. open import TotalParserCombinators.Derivative.Definition public -- The derivative operator is sound and complete with respect to the -- semantics. open import TotalParserCombinators.Derivative.SoundComplete public hiding (complete′) -- A proof showing that the derivative operator does not introduce any -- unneeded ambiguity. open import TotalParserCombinators.Derivative.LeftInverse public -- A proof showing that the derivative operator does not remove any -- ambiguity. open import TotalParserCombinators.Derivative.RightInverse public hiding (sound∘complete′) -- Some corollaries. open import TotalParserCombinators.Derivative.Corollaries public
src/Category/Monad/Monotone/Reader.agda
metaborg/mj.agda
10
13862
<gh_stars>1-10 open import Relation.Binary using (Preorder) open import Relation.Binary.PropositionalEquality open import Relation.Unary module Category.Monad.Monotone.Reader {ℓ}(pre : Preorder ℓ ℓ ℓ) where open Preorder pre renaming (Carrier to I; _∼_ to _≤_; refl to ≤-refl) open import Relation.Unary.Monotone pre open import Relation.Unary.PredicateTransformer using (Pt) open import Data.Product open import Function open import Level hiding (lift) open import Category.Monad open import Category.Monad.Monotone.Identity pre open import Category.Monad.Monotone pre ReaderT : Pred I ℓ → Pt I ℓ → Pt I ℓ ReaderT E M P = λ i → E i → M P i Reader : (Pred I ℓ) → Pt I ℓ Reader E = ReaderT E Identity record ReaderMonad E (M : Pred I ℓ → Pt I ℓ) : Set (suc ℓ) where field ask : ∀ {i} → M E E i reader : ∀ {P} → (E ⇒ P) ⊆ M E P local : ∀ {P E'} → (E ⇒ E') ⊆ (M E' P ⇒ M E P) asks : ∀ {A} → (E ⇒ A) ⊆ M E A asks = reader module _ {M : Pt I ℓ}⦃ Mon : RawMPMonad M ⦄ where private module M = RawMPMonad Mon module _ {E}⦃ mono : Monotone E ⦄ where instance open RawMPMonad reader-monad : RawMPMonad (ReaderT E M) return reader-monad x e = M.return x _≥=_ reader-monad m f e = m e M.≥= λ i≤j px → f i≤j px (wk i≤j e) open ReaderMonad reader-monad-ops : ReaderMonad E (λ E → ReaderT E M) ask reader-monad-ops e = M.return e reader reader-monad-ops f e = M.return (f e) local reader-monad-ops f c e = c (f e) lift-reader : ∀ {P} E → M P ⊆ ReaderT E M P lift-reader _ z _ = z
Framework/trackmo/framework/driver_packed3.asm
kosmonautdnb/TheLandsOfZador
0
101348
processor 6502 ORG $1001 DC.W $100B,0 DC.B $9E,"4109",0,0,0 ; SYS4107 JMP main org $1800,$00 include "fw_interface.asm" include "fw_bootstrap.asm" main SUBROUTINE lda #$00 jsr fw_init sei sta $ff3f lda #$00 sta $ff0a ldy #$10 lda #$00 .0 sta $0000,y iny bne .0 jsr fw_run cli ldy #$00 .loop iny sty $ff19 bne .loop jmp launch demopart_begin = . incbin "demopart.exo" demopart_end = . demopart_len = [demopart_end - demopart_begin] ECHO demopart_begin, " " , demopart_end, " ", demopart_len align 256 launch SUBROUTINE lda #<demopart_begin sta .src lda #>demopart_begin sta .src+1 lda #$f0 sta .dst lda #$17 sta .dst+1 .loop .src = .+1 lda $1234 .dst = .+1 sta $5678 inc .src bne .srcok inc .src+1 .srcok inc .dst bne .dstok inc .dst+1 .dstok lda .src cmp #<demopart_end bne .loop lda .src+1 cmp #>demopart_end bne .loop ldx .dst ldy .dst+1 jsr fw_decrunch jmp $a7fd
src/ui/utils-ui.adb
thindil/steamsky
80
14275
<gh_stars>10-100 -- Copyright (c) 2020-2021 <NAME> <<EMAIL>> -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT 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 -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Directories; use Ada.Directories; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Interfaces.C.Strings; use Interfaces.C.Strings; with GNAT.String_Split; use GNAT.String_Split; with Tcl; use Tcl; with Tcl.Ada; use Tcl.Ada; with Tcl.Tk.Ada; use Tcl.Tk.Ada; with Tcl.Tk.Ada.Grid; with Tcl.Tk.Ada.Widgets.Text; use Tcl.Tk.Ada.Widgets.Text; with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu; with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton; with Tcl.Tk.Ada.Widgets.TtkEntry; use Tcl.Tk.Ada.Widgets.TtkEntry; with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; with Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox; use Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox; with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame; with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel; with Tcl.Tk.Ada.Widgets.TtkPanedWindow; use Tcl.Tk.Ada.Widgets.TtkPanedWindow; with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar; with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo; with Bases; use Bases; with Combat.UI; use Combat.UI; with Config; use Config; with CoreUI; use CoreUI; with Crew; use Crew; with Dialogs; use Dialogs; with Events; use Events; with Factions; use Factions; with Maps; use Maps; with Maps.UI; use Maps.UI; with MainMenu; use MainMenu; with Messages; use Messages; with Missions; use Missions; with Ships.Cargo; use Ships.Cargo; with Ships.Crew; use Ships.Crew; with Ships.Movement; use Ships.Movement; with Ships.UI.Crew; use Ships.UI.Crew; with Ships.UI.Modules; use Ships.UI.Modules; with Statistics.UI; use Statistics.UI; package body Utils.UI is procedure Add_Command (Name: String; Ada_Command: not null CreateCommands.Tcl_CmdProc) is Command: Tcl.Tcl_Command; Steam_Sky_Add_Command_Error: exception; begin Tcl_Eval(interp => Get_Context, strng => "info commands " & Name); if Tcl_GetResult(interp => Get_Context) /= "" then raise Steam_Sky_Add_Command_Error with "Command with name " & Name & " exists"; end if; Command := CreateCommands.Tcl_CreateCommand (interp => Get_Context, cmdName => Name, proc => Ada_Command, data => 0, deleteProc => null); if Command = null then raise Steam_Sky_Add_Command_Error with "Can't add command " & Name; end if; end Add_Command; -- ****o* UUI/UUI.Resize_Canvas_Command -- PARAMETERS -- Resize the selected canvas -- Client_Data - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- ResizeCanvas name width height -- Name is the name of the canvas to resize, width it a new width, height -- is a new height -- SOURCE function Resize_Canvas_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Resize_Canvas_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); Canvas: constant Ttk_Frame := Get_Widget (pathName => CArgv.Arg(Argv => Argv, N => 1), Interp => Interp); Parent_Frame: Ttk_Frame; begin if Winfo_Get(Widgt => Canvas, Info => "exists") = "0" then return TCL_OK; end if; Parent_Frame := Get_Widget (pathName => Winfo_Get(Widgt => Canvas, Info => "parent"), Interp => Interp); Unbind(Widgt => Parent_Frame, Sequence => "<Configure>"); Widgets.configure (Widgt => Canvas, options => "-width " & CArgv.Arg(Argv => Argv, N => 2) & " -height [expr " & CArgv.Arg(Argv => Argv, N => 3) & " - 20]"); Bind (Widgt => Parent_Frame, Sequence => "<Configure>", Script => "{ResizeCanvas %W.canvas %w %h}"); return TCL_OK; end Resize_Canvas_Command; -- ****o* UUI/UUI.Check_Amount_Command -- PARAMETERS -- Check amount of the item, if it is not below low level warning or if -- entered amount is a proper number -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- CheckAmount name cargoindex value -- Name is the name of spinbox which value will be checked, cargoindex is -- the index of the item in the cargo -- SOURCE function Check_Amount_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Check_Amount_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data); Cargo_Index: constant Natural := Natural'Value(CArgv.Arg(Argv => Argv, N => 2)); Warning_Text: Unbounded_String := Null_Unbounded_String; Amount: Integer := 0; Label: Ttk_Label := Get_Widget(pathName => ".itemdialog.errorlbl", Interp => Interp); Value: Integer := 0; Spin_Box: constant Ttk_SpinBox := Get_Widget (pathName => CArgv.Arg(Argv => Argv, N => 1), Interp => Interp); Max_Value: constant Positive := Positive'Value(Widgets.cget(Widgt => Spin_Box, option => "-to")); begin if CArgv.Arg(Argv => Argv, N => 3)'Length > 0 then Check_Argument_Loop : for Char of CArgv.Arg(Argv => Argv, N => 3) loop if not Is_Decimal_Digit(Item => Char) then Tcl_SetResult(interp => Interp, str => "0"); return TCL_OK; end if; end loop Check_Argument_Loop; Value := Integer'Value(CArgv.Arg(Argv => Argv, N => 3)); end if; if CArgv.Arg(Argv => Argv, N => 1) = ".itemdialog.giveamount" then Warning_Text := To_Unbounded_String (Source => "You will give amount below low level of "); else Warning_Text := To_Unbounded_String (Source => "You will " & CArgv.Arg(Argv => Argv, N => 4) & " amount below low level of "); end if; if Value < 1 then Set(SpinBox => Spin_Box, Value => "1"); Value := 1; elsif Value > Max_Value then Set(SpinBox => Spin_Box, Value => Positive'Image(Max_Value)); Value := Max_Value; end if; if Argc > 4 then if CArgv.Arg(Argv => Argv, N => 4) = "take" then Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; elsif CArgv.Arg(Argv => Argv, N => 4) in "buy" | "sell" then Set_Price_Info_Block : declare Cost: Natural := Value * Positive'Value(CArgv.Arg(Argv => Argv, N => 5)); begin Label := Get_Widget (pathName => ".itemdialog.costlbl", Interp => Interp); Count_Price (Price => Cost, Trader_Index => FindMember(Order => Talk), Reduce => (if CArgv.Arg(Argv => Argv, N => 4) = "buy" then True else False)); configure (Widgt => Label, options => "-text {" & (if CArgv.Arg(Argv => Argv, N => 4) = "buy" then "Cost:" else "Gain:") & Natural'Image(Cost) & " " & To_String(Source => Money_Name) & "}"); if CArgv.Arg(Argv => Argv, N => 4) = "buy" then Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; end if; end Set_Price_Info_Block; end if; end if; Label := Get_Widget(pathName => ".itemdialog.errorlbl", Interp => Interp); if Items_List(Player_Ship.Cargo(Cargo_Index).ProtoIndex).IType = Fuel_Type then Amount := GetItemAmount(ItemType => Fuel_Type) - Value; if Amount <= Game_Settings.Low_Fuel then Widgets.configure (Widgt => Label, options => "-text {" & To_String(Source => Warning_Text) & "fuel.}"); Tcl.Tk.Ada.Grid.Grid(Slave => Label); Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; end if; end if; Check_Food_And_Drinks_Loop : for Member of Player_Ship.Crew loop if Factions_List(Member.Faction).DrinksTypes.Contains (Item => Items_List(Player_Ship.Cargo(Cargo_Index).ProtoIndex) .IType) then Amount := GetItemsAmount(IType => "Drinks") - Value; if Amount <= Game_Settings.Low_Drinks then Widgets.configure (Widgt => Label, options => "-text {" & To_String(Source => Warning_Text) & "drinks.}"); Tcl.Tk.Ada.Grid.Grid(Slave => Label); Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; end if; exit Check_Food_And_Drinks_Loop; elsif Factions_List(Member.Faction).FoodTypes.Contains (Item => Items_List(Player_Ship.Cargo(Cargo_Index).ProtoIndex) .IType) then Amount := GetItemsAmount(IType => "Food") - Value; if Amount <= Game_Settings.Low_Food then Widgets.configure (Widgt => Label, options => "-text {" & To_String(Source => Warning_Text) & "food.}"); Tcl.Tk.Ada.Grid.Grid(Slave => Label); Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; end if; exit Check_Food_And_Drinks_Loop; end if; end loop Check_Food_And_Drinks_Loop; Tcl.Tk.Ada.Grid.Grid_Remove(Slave => Label); Tcl_SetResult(interp => Interp, str => "1"); return TCL_OK; exception when Constraint_Error => Tcl_SetResult(interp => Interp, str => "0"); return TCL_OK; end Check_Amount_Command; -- ****o* UUI/UUI.Validate_Amount_Command -- PARAMETERS -- Validate amount of the item when button to increase or decrease the -- amount was pressed -- ClientData - Custom data send to the command. -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- ValidateAmount name -- Name is the name of spinbox which value will be validated -- SOURCE function Validate_Amount_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Validate_Amount_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is Spin_Box: constant Ttk_SpinBox := Get_Widget (pathName => CArgv.Arg(Argv => Argv, N => 1), Interp => Interp); New_Argv: constant CArgv.Chars_Ptr_Ptr := (if Argc < 4 then Argv & Get(Widgt => Spin_Box) elsif Argc = 4 then CArgv.Empty & CArgv.Arg(Argv => Argv, N => 0) & CArgv.Arg(Argv => Argv, N => 1) & CArgv.Arg(Argv => Argv, N => 2) & Get(Widgt => Spin_Box) & CArgv.Arg(Argv => Argv, N => 3) else CArgv.Empty & CArgv.Arg(Argv => Argv, N => 0) & CArgv.Arg(Argv => Argv, N => 1) & CArgv.Arg(Argv => Argv, N => 2) & Get(Widgt => Spin_Box) & CArgv.Arg(Argv => Argv, N => 3) & CArgv.Arg(Argv => Argv, N => 4)); begin return Check_Amount_Command (Client_Data => Client_Data, Interp => Interp, Argc => CArgv.Argc(Argv => New_Argv), Argv => New_Argv); end Validate_Amount_Command; -- ****o* UUI/UUI.Set_Text_Variable_Command -- FUNCTION -- Set the selected Tcl text variable and the proper the Ada its equivalent -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SetTextVariable variablename -- Variablename is the name of variable to set -- SOURCE function Set_Text_Variable_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Set_Text_Variable_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); T_Entry: constant Ttk_Entry := Get_Widget(pathName => ".getstring.entry", Interp => Interp); Value: constant String := Get(Widgt => T_Entry); Var_Name: constant String := CArgv.Arg(Argv => Argv, N => 1); begin Tcl_SetVar(interp => Interp, varName => Var_Name, newValue => Value); if Var_Name = "shipname" then Player_Ship.Name := To_Unbounded_String(Source => Value); elsif Var_Name'Length > 10 and then Var_Name(1 .. 10) = "modulename" then Rename_Module_Block : declare Module_Index: constant Positive := Positive'Value(Var_Name(11 .. Var_Name'Last)); begin Player_Ship.Modules(Module_Index).Name := To_Unbounded_String(Source => Value); Tcl_UnsetVar(interp => Interp, varName => Var_Name); UpdateModulesInfo; end Rename_Module_Block; elsif Var_Name'Length > 8 and then Var_Name(1 .. 8) = "crewname" then Rename_Crew_Member_Block : declare Crew_Index: constant Positive := Positive'Value(Var_Name(9 .. Var_Name'Last)); begin Player_Ship.Crew(Crew_Index).Name := To_Unbounded_String(Source => Value); Tcl_UnsetVar(interp => Interp, varName => Var_Name); UpdateCrewInfo; end Rename_Crew_Member_Block; end if; return TCL_OK; end Set_Text_Variable_Command; -- ****o* UUI/UUI.Process_Question_Command -- FUNCTION -- Process question from dialog when the player answer Yes there -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- ProcessQuestion answer -- Answer is the answer set for the selected question -- SOURCE function Process_Question_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Process_Question_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); Result: constant String := CArgv.Arg(Argv => Argv, N => 1); begin if Result = "deletesave" then Delete_File (Name => To_String (Source => Save_Directory & Tcl_GetVar(interp => Interp, varName => "deletesave"))); Tcl_UnsetVar(interp => Interp, varName => "deletesave"); Tcl_Eval(interp => Interp, strng => "ShowLoadGame"); elsif Result = "sethomebase" then Set_Home_Base_Block : declare Trader_Index: constant Natural := FindMember(Order => Talk); Price: Positive := 1_000; Money_Index2: constant Natural := FindItem (Inventory => Player_Ship.Cargo, ProtoIndex => Money_Index); begin if Money_Index2 = 0 then ShowMessage (Text => "You don't have any " & To_String(Source => Money_Name) & " for change ship home base.", Title => "No money"); return TCL_OK; end if; Count_Price(Price => Price, Trader_Index => Trader_Index); if Player_Ship.Cargo(Money_Index2).Amount < Price then ShowMessage (Text => "You don't have enough " & To_String(Source => Money_Name) & " for change ship home base.", Title => "No money"); return TCL_OK; end if; Player_Ship.Home_Base := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; UpdateCargo (Ship => Player_Ship, CargoIndex => Money_Index2, Amount => -Price); AddMessage (Message => "You changed your ship home base to: " & To_String(Source => Sky_Bases(Player_Ship.Home_Base).Name), MType => OtherMessage); GainExp (Amount => 1, SkillNumber => Talking_Skill, CrewIndex => Trader_Index); Update_Game(Minutes => 10); ShowSkyMap; end Set_Home_Base_Block; elsif Result = "nopilot" then WaitForRest; Check_For_Combat_Block : declare Starts_Combat: constant Boolean := CheckForEvent; Message: Unbounded_String := Null_Unbounded_String; begin if not Starts_Combat and Game_Settings.Auto_Finish then Message := To_Unbounded_String(Source => AutoFinishMissions); end if; if Message /= Null_Unbounded_String then ShowMessage (Text => To_String(Source => Message), Title => "Error"); end if; CenterX := Player_Ship.Sky_X; CenterY := Player_Ship.Sky_Y; if Starts_Combat then ShowCombatUI; else ShowSkyMap; end if; end Check_For_Combat_Block; elsif Result = "quit" then Game_Settings.Messages_Position := Game_Settings.Window_Height - Natural'Value(SashPos(Paned => Main_Paned, Index => "0")); End_Game(Save => True); Show_Main_Menu; elsif Result = "resign" then Death (MemberIndex => 1, Reason => To_Unbounded_String(Source => "resignation"), Ship => Player_Ship); ShowQuestion (Question => "You are dead. Would you like to see your game statistics?", Result => "showstats"); elsif Result = "showstats" then Show_Game_Stats_Block : declare Button: constant Ttk_Button := Get_Widget(pathName => Game_Header & ".menubutton"); begin Tcl.Tk.Ada.Grid.Grid(Slave => Button); Widgets.configure (Widgt => Close_Button, options => "-command ShowMainMenu"); Tcl.Tk.Ada.Grid.Grid (Slave => Close_Button, Options => "-row 0 -column 1"); Delete(MenuWidget => GameMenu, StartIndex => "3", EndIndex => "4"); Delete (MenuWidget => GameMenu, StartIndex => "6", EndIndex => "14"); ShowStatistics; end Show_Game_Stats_Block; elsif Result = "mainmenu" then Game_Settings.Messages_Position := Game_Settings.Window_Height - Natural'Value(SashPos(Paned => Main_Paned, Index => "0")); End_Game(Save => False); Show_Main_Menu; elsif Result = "messages" then Show_Last_Messages_Block : declare Type_Box: constant Ttk_ComboBox := Get_Widget (pathName => Main_Paned & ".messagesframe.canvas.messages.options.types", Interp => Get_Context); begin ClearMessages; Current(ComboBox => Type_Box, NewIndex => "0"); Tcl_Eval(interp => Get_Context, strng => "ShowLastMessages"); end Show_Last_Messages_Block; elsif Result = "retire" then Death (MemberIndex => 1, Reason => To_Unbounded_String(Source => "retired after finished the game"), Ship => Player_Ship); ShowQuestion (Question => "You are dead. Would you like to see your game statistics?", Result => "showstats"); else Dismiss_Member_Block : declare Base_Index: constant Positive := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; Member_Index: constant Positive := Positive'Value(CArgv.Arg(Argv => Argv, N => 1)); begin AddMessage (Message => "You dismissed " & To_String(Source => Player_Ship.Crew(Member_Index).Name) & ".", MType => OrderMessage); DeleteMember(MemberIndex => Member_Index, Ship => Player_Ship); Sky_Bases(Base_Index).Population := Sky_Bases(Base_Index).Population + 1; Update_Morale_Loop : for I in Player_Ship.Crew.Iterate loop UpdateMorale (Ship => Player_Ship, MemberIndex => Crew_Container.To_Index(Position => I), Value => Get_Random(Min => -5, Max => -1)); end loop Update_Morale_Loop; UpdateCrewInfo; UpdateHeader; Update_Messages; end Dismiss_Member_Block; end if; return TCL_OK; end Process_Question_Command; -- ****o* UUI/UUI.Set_Scrollbar_Bindings_Command -- FUNCTION -- Assign scrolling events with mouse wheel to the selected vertical -- scrollbar from the selected widget -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SetScrollbarBindings widget scrollbar -- Widget is the widget from which events will be fired, scrollbar is -- Ttk::scrollbar which to which bindings will be added -- SOURCE function Set_Scrollbar_Bindings_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Set_Scrollbar_Bindings_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); Widget: constant Ttk_Frame := Get_Widget (pathName => CArgv.Arg(Argv => Argv, N => 1), Interp => Interp); Scrollbar: constant Ttk_Scrollbar := Get_Widget (pathName => CArgv.Arg(Argv => Argv, N => 2), Interp => Interp); begin Bind (Widgt => Widget, Sequence => "<Button-4>", Script => "{if {[winfo ismapped " & Scrollbar & "]} {event generate " & Scrollbar & " <Button-4>}}"); Bind (Widgt => Widget, Sequence => "<Key-Prior>", Script => "{if {[winfo ismapped " & Scrollbar & "]} {event generate " & Scrollbar & " <Button-4>}}"); Bind (Widgt => Widget, Sequence => "<Button-5>", Script => "{if {[winfo ismapped " & Scrollbar & "]} {event generate " & Scrollbar & " <Button-5>}}"); Bind (Widgt => Widget, Sequence => "<Key-Next>", Script => "{if {[winfo ismapped " & Scrollbar & "]} {event generate " & Scrollbar & " <Button-5>}}"); Bind (Widgt => Widget, Sequence => "<MouseWheel>", Script => "{if {[winfo ismapped " & Scrollbar & "]} {event generate " & Scrollbar & " <MouseWheel>}}"); return TCL_OK; end Set_Scrollbar_Bindings_Command; function Show_On_Map_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); begin CenterX := Positive'Value(CArgv.Arg(Argv => Argv, N => 1)); CenterY := Positive'Value(CArgv.Arg(Argv => Argv, N => 2)); Entry_Configure (MenuWidget => GameMenu, Index => "Help", Options => "-command {ShowHelp general}"); Tcl_Eval(interp => Interp, strng => "InvokeButton " & Close_Button); Tcl.Tk.Ada.Grid.Grid_Remove(Slave => Close_Button); return TCL_OK; end Show_On_Map_Command; function Set_Destination_Command (Client_Data: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Client_Data, Argc); begin if Positive'Value(CArgv.Arg(Argv => Argv, N => 1)) = Player_Ship.Sky_X and Positive'Value(CArgv.Arg(Argv => Argv, N => 2)) = Player_Ship.Sky_Y then ShowMessage (Text => "You are at this location now.", Title => "Can't set destination"); return TCL_OK; end if; Player_Ship.Destination_X := Positive'Value(CArgv.Arg(Argv => Argv, N => 1)); Player_Ship.Destination_Y := Positive'Value(CArgv.Arg(Argv => Argv, N => 2)); AddMessage (Message => "You set the travel destination for your ship.", MType => OrderMessage); Entry_Configure (MenuWidget => GameMenu, Index => "Help", Options => "-command {ShowHelp general}"); Tcl_Eval(interp => Interp, strng => "InvokeButton " & Close_Button); Tcl.Tk.Ada.Grid.Grid_Remove(Slave => Close_Button); return TCL_OK; end Set_Destination_Command; procedure Add_Commands is begin Add_Command (Name => "ResizeCanvas", Ada_Command => Resize_Canvas_Command'Access); Add_Command (Name => "CheckAmount", Ada_Command => Check_Amount_Command'Access); Add_Command (Name => "ValidateAmount", Ada_Command => Validate_Amount_Command'Access); Add_Command (Name => "SetTextVariable", Ada_Command => Set_Text_Variable_Command'Access); Add_Command (Name => "ProcessQuestion", Ada_Command => Process_Question_Command'Access); Add_Command (Name => "SetScrollbarBindings", Ada_Command => Set_Scrollbar_Bindings_Command'Access); Add_Command (Name => "ShowOnMap", Ada_Command => Show_On_Map_Command'Access); Add_Command (Name => "SetDestination2", Ada_Command => Set_Destination_Command'Access); end Add_Commands; procedure Minutes_To_Date (Minutes: Natural; Info_Text: in out Unbounded_String) with SPARK_Mode is Travel_Time: Date_Record := (others => 0); Minutes_Diff: Integer := Minutes; begin Count_Time_Loop : while Minutes_Diff > 0 loop pragma Loop_Invariant (Travel_Time.Year < 4_000_000 and Travel_Time.Month < 13 and Travel_Time.Day < 32 and Travel_Time.Hour < 24); case Minutes_Diff is when 518_401 .. Integer'Last => Travel_Time.Year := Travel_Time.Year + 1; Minutes_Diff := Minutes_Diff - 518_400; when 43_201 .. 518_400 => Travel_Time.Month := Travel_Time.Month + 1; if Travel_Time.Month > 12 then Travel_Time.Month := 1; Travel_Time.Year := Travel_Time.Year + 1; end if; Minutes_Diff := Minutes_Diff - 43_200; when 1_441 .. 43_200 => Travel_Time.Day := Travel_Time.Day + 1; if Travel_Time.Day > 31 then Travel_Time.Day := 1; Travel_Time.Month := Travel_Time.Month + 1; if Travel_Time.Month > 12 then Travel_Time.Month := 1; Travel_Time.Year := Travel_Time.Year + 1; end if; end if; Minutes_Diff := Minutes_Diff - 1_440; when 61 .. 1_440 => Travel_Time.Hour := Travel_Time.Hour + 1; if Travel_Time.Hour > 23 then Travel_Time.Hour := 0; Travel_Time.Day := Travel_Time.Day + 1; if Travel_Time.Day > 31 then Travel_Time.Day := 1; Travel_Time.Month := Travel_Time.Month + 1; if Travel_Time.Month > 12 then Travel_Time.Month := 1; Travel_Time.Year := Travel_Time.Year + 1; end if; end if; end if; Minutes_Diff := Minutes_Diff - 60; when others => Travel_Time.Minutes := Minutes_Diff; Minutes_Diff := 0; end case; exit Count_Time_Loop when Travel_Time.Year = 4_000_000; end loop Count_Time_Loop; if Travel_Time.Year > 0 and then Length(Source => Info_Text) < Natural'Last - (Positive'Image(Travel_Time.Year)'Length + 1) then Append (Source => Info_Text, New_Item => Positive'Image(Travel_Time.Year) & "y"); end if; if Travel_Time.Month > 0 and then Length(Source => Info_Text) < Natural'Last - (Positive'Image(Travel_Time.Month)'Length + 1) then Append (Source => Info_Text, New_Item => Positive'Image(Travel_Time.Month) & "m"); end if; if Travel_Time.Day > 0 and then Length(Source => Info_Text) < Natural'Last - (Positive'Image(Travel_Time.Day)'Length + 1) then Append (Source => Info_Text, New_Item => Positive'Image(Travel_Time.Day) & "d"); end if; if Travel_Time.Hour > 0 and then Length(Source => Info_Text) < Natural'Last - (Positive'Image(Travel_Time.Hour)'Length + 1) then Append (Source => Info_Text, New_Item => Positive'Image(Travel_Time.Hour) & "h"); end if; if Travel_Time.Minutes > 0 and then Length(Source => Info_Text) < Natural'Last - (Positive'Image(Travel_Time.Minutes)'Length + 4) then Append (Source => Info_Text, New_Item => Positive'Image(Travel_Time.Minutes) & "mins"); end if; end Minutes_To_Date; procedure Travel_Info (Info_Text: in out Unbounded_String; Distance: Positive; Show_Fuel_Name: Boolean := False) is type Speed_Type is digits 2; Speed: constant Speed_Type := Speed_Type(RealSpeed(Ship => Player_Ship, InfoOnly => True)) / 1_000.0; Minutes_Diff: Integer; Rests, Cabin_Index, Rest_Time, Tired, Cabin_Bonus, Temp_Time: Natural := 0; Damage: Damage_Factor := 0.0; begin if Speed = 0.0 then Append(Source => Info_Text, New_Item => LF & "ETA: Never"); return; end if; Minutes_Diff := Integer(100.0 / Speed); case Player_Ship.Speed is when QUARTER_SPEED => if Minutes_Diff < 60 then Minutes_Diff := 60; end if; when HALF_SPEED => if Minutes_Diff < 30 then Minutes_Diff := 30; end if; when FULL_SPEED => if Minutes_Diff < 15 then Minutes_Diff := 15; end if; when others => null; end case; Append(Source => Info_Text, New_Item => LF & "ETA:"); Minutes_Diff := Minutes_Diff * Distance; Count_Rest_Time_Loop : for I in Player_Ship.Crew.Iterate loop if Player_Ship.Crew(I).Order not in Pilot | Engineer then goto End_Of_Count_Loop; end if; Tired := (Minutes_Diff / 15) + Player_Ship.Crew(I).Tired; if (Tired / (80 + Player_Ship.Crew(I).Attributes(Integer(Condition_Index)).Level)) > Rests then Rests := (Tired / (80 + Player_Ship.Crew(I).Attributes(Integer(Condition_Index)) .Level)); end if; if Rests > 0 then Cabin_Index := FindCabin(MemberIndex => Crew_Container.To_Index(Position => I)); if Cabin_Index > 0 then Damage := 1.0 - Damage_Factor (Float(Player_Ship.Modules(Cabin_Index).Durability) / Float(Player_Ship.Modules(Cabin_Index).Max_Durability)); Cabin_Bonus := Player_Ship.Modules(Cabin_Index).Cleanliness - Natural (Float(Player_Ship.Modules(Cabin_Index).Cleanliness) * Float(Damage)); if Cabin_Bonus = 0 then Cabin_Bonus := 1; end if; Temp_Time := ((80 + Player_Ship.Crew(I).Attributes(Integer(Condition_Index)) .Level) / Cabin_Bonus) * 15; if Temp_Time = 0 then Temp_Time := 15; end if; else Temp_Time := (80 + Player_Ship.Crew(I).Attributes(Integer(Condition_Index)) .Level) * 15; end if; Temp_Time := Temp_Time + 15; if Temp_Time > Rest_Time then Rest_Time := Temp_Time; end if; end if; <<End_Of_Count_Loop>> end loop Count_Rest_Time_Loop; Minutes_Diff := Minutes_Diff + (Rests * Rest_Time); Minutes_To_Date(Minutes => Minutes_Diff, Info_Text => Info_Text); Append (Source => Info_Text, New_Item => LF & "Approx fuel usage:" & Natural'Image (abs (Distance * CountFuelNeeded) + (Rests * (Rest_Time / 10))) & " "); if Show_Fuel_Name then Append (Source => Info_Text, New_Item => Items_List(FindProtoItem(ItemType => Fuel_Type)).Name); end if; end Travel_Info; procedure Update_Messages with SPARK_Mode is Loop_Start: Integer := 0 - MessagesAmount; Message: Message_Data; Tag_Names: constant array(1 .. 5) of Unbounded_String := (1 => To_Unbounded_String(Source => "yellow"), 2 => To_Unbounded_String(Source => "green"), 3 => To_Unbounded_String(Source => "red"), 4 => To_Unbounded_String(Source => "blue"), 5 => To_Unbounded_String(Source => "cyan")); Messages_View: constant Tk_Text := Get_Widget(pathName => ".gameframe.paned.controls.messages.view"); procedure Show_Message is begin if Message.Color = WHITE then Insert (TextWidget => Messages_View, Index => "end", Text => "{" & To_String(Source => Message.Message) & "}"); else Insert (TextWidget => Messages_View, Index => "end", Text => "{" & To_String(Source => Message.Message) & "} [list " & To_String (Source => Tag_Names(Message_Color'Pos(Message.Color))) & "]"); end if; end Show_Message; begin Tcl.Tk.Ada.Widgets.configure (Widgt => Messages_View, options => "-state normal"); Delete (TextWidget => Messages_View, StartIndex => "1.0", Indexes => "end"); if Loop_Start = 0 then return; end if; if Loop_Start < -10 then Loop_Start := -10; end if; if Game_Settings.Messages_Order = OLDER_FIRST then Show_Older_First_Loop : for I in Loop_Start .. -1 loop Message := GetMessage(MessageIndex => I + 1); Show_Message; if I < -1 then Insert (TextWidget => Messages_View, Index => "end", Text => "{" & LF & "}"); end if; end loop Show_Older_First_Loop; Tcl_Eval(interp => Get_Context, strng => "update"); See(TextWidget => Messages_View, Index => "end"); else Show_Newer_First_Loop : for I in reverse Loop_Start .. -1 loop Message := GetMessage(MessageIndex => I + 1); Show_Message; if I > Loop_Start then Insert (TextWidget => Messages_View, Index => "end", Text => "{" & LF & "}"); end if; end loop Show_Newer_First_Loop; end if; Tcl.Tk.Ada.Widgets.configure (Widgt => Messages_View, options => "-state disable"); end Update_Messages; procedure Show_Screen(New_Screen_Name: String) with SPARK_Mode is Sub_Window, Old_Sub_Window: Ttk_Frame; Sub_Windows: Unbounded_String; Messages_Frame: constant Ttk_Frame := Get_Widget(pathName => Main_Paned & ".controls.messages"); Paned: constant Ttk_PanedWindow := Get_Widget(pathName => Main_Paned & ".controls.buttons"); begin Sub_Windows := To_Unbounded_String(Source => Panes(Paned => Main_Paned)); Old_Sub_Window := (if Index(Source => Sub_Windows, Pattern => " ") = 0 then Get_Widget(pathName => To_String(Source => Sub_Windows)) else Get_Widget (pathName => Slice (Source => Sub_Windows, Low => 1, High => Index(Source => Sub_Windows, Pattern => " ")))); Forget(Paned => Main_Paned, SubWindow => Old_Sub_Window); Sub_Window.Name := New_String(Str => ".gameframe.paned." & New_Screen_Name); Insert (Paned => Main_Paned, Position => "0", SubWindow => Sub_Window, Options => "-weight 1"); if New_Screen_Name in "optionsframe" | "messagesframe" or not Game_Settings.Show_Last_Messages then Tcl.Tk.Ada.Grid.Grid_Remove(Slave => Messages_Frame); if New_Screen_Name /= "mapframe" then SashPos (Paned => Main_Paned, Index => "0", NewPos => Winfo_Get(Widgt => Main_Paned, Info => "height")); end if; else if Trim (Source => Widget_Image(Win => Old_Sub_Window), Side => Both) in Main_Paned & ".messagesframe" | Main_Paned & ".optionsframe" then SashPos (Paned => Main_Paned, Index => "0", NewPos => Natural'Image (Game_Settings.Window_Height - Game_Settings.Messages_Position)); end if; Tcl.Tk.Ada.Grid.Grid(Slave => Messages_Frame); end if; if New_Screen_Name = "mapframe" then Tcl.Tk.Ada.Grid.Grid(Slave => Paned); else Tcl.Tk.Ada.Grid.Grid_Remove(Slave => Paned); end if; end Show_Screen; procedure Show_Inventory_Item_Info (Parent: String; Item_Index: Positive; Member_Index: Natural) is Proto_Index, Item_Info: Unbounded_String; Item_Types: constant array(1 .. 6) of Unbounded_String := (1 => Weapon_Type, 2 => Chest_Armor, 3 => Head_Armor, 4 => Arms_Armor, 5 => Legs_Armor, 6 => Shield_Type); use Tiny_String; begin if Member_Index > 0 then Proto_Index := Player_Ship.Crew(Member_Index).Inventory(Item_Index).ProtoIndex; if Player_Ship.Crew(Member_Index).Inventory(Item_Index).Durability < Default_Item_Durability then Append (Source => Item_Info, New_Item => GetItemDamage (ItemDurability => Player_Ship.Crew(Member_Index).Inventory(Item_Index) .Durability) & LF); end if; else Proto_Index := Player_Ship.Cargo(Item_Index).ProtoIndex; if Player_Ship.Cargo(Item_Index).Durability < Default_Item_Durability then Append (Source => Item_Info, New_Item => GetItemDamage (ItemDurability => Player_Ship.Cargo(Item_Index).Durability) & LF); end if; end if; Append (Source => Item_Info, New_Item => "Weight:" & Positive'Image(Items_List(Proto_Index).Weight) & " kg"); if Items_List(Proto_Index).IType = Weapon_Type then Append (Source => Item_Info, New_Item => LF & "Skill: " & To_String (Source => SkillsData_Container.Element (Container => Skills_List, Index => Items_List(Proto_Index).Value(3)) .Name) & "/" & To_String (Source => AttributesData_Container.Element (Container => Attributes_List, Index => (SkillsData_Container.Element (Container => Skills_List, Index => Items_List(Proto_Index).Value(3)) .Attribute)) .Name)); if Items_List(Proto_Index).Value(4) = 1 then Append (Source => Item_Info, New_Item => LF & "Can be used with shield."); else Append (Source => Item_Info, New_Item => LF & "Can't be used with shield (two-handed weapon)."); end if; Append (Source => Item_Info, New_Item => LF & "Damage type: " & (case Items_List(Proto_Index).Value(5) is when 1 => "cutting", when 2 => "impaling", when 3 => "blunt", when others => "")); end if; Show_More_Item_Info_Loop : for ItemType of Item_Types loop if Items_List(Proto_Index).IType = ItemType then Append (Source => Item_Info, New_Item => LF & "Damage chance: " & LF & "Strength:" & Integer'Image(Items_List(Proto_Index).Value(2))); exit Show_More_Item_Info_Loop; end if; end loop Show_More_Item_Info_Loop; if Tools_List.Contains(Item => Items_List(Proto_Index).IType) then Append (Source => Item_Info, New_Item => LF & "Damage chance: " & GetItemChanceToDamage (ItemData => Items_List(Proto_Index).Value(1))); end if; if Length(Source => Items_List(Proto_Index).IType) > 4 and then (Slice(Source => Items_List(Proto_Index).IType, Low => 1, High => 4) = "Ammo" or Items_List(Proto_Index).IType = To_Unbounded_String(Source => "Harpoon")) then Append (Source => Item_Info, New_Item => LF & "Strength:" & Integer'Image(Items_List(Proto_Index).Value(1))); end if; if Items_List(Proto_Index).Description /= Null_Unbounded_String then Append (Source => Item_Info, New_Item => LF & LF & To_String(Source => Items_List(Proto_Index).Description)); end if; if Parent = "." then ShowInfo (Text => To_String(Source => Item_Info), Title => (if Member_Index > 0 then GetItemName (Item => Player_Ship.Crew(Member_Index).Inventory(Item_Index), DamageInfo => False, ToLower => False) else GetItemName (Item => Player_Ship.Cargo(Item_Index), DamageInfo => False, ToLower => False))); else ShowInfo (Text => To_String(Source => Item_Info), ParentName => Parent, Title => (if Member_Index > 0 then GetItemName (Item => Player_Ship.Crew(Member_Index).Inventory(Item_Index), DamageInfo => False, ToLower => False) else GetItemName (Item => Player_Ship.Cargo(Item_Index), DamageInfo => False, ToLower => False))); end if; end Show_Inventory_Item_Info; procedure Delete_Widgets (Start_Index, End_Index: Integer; Frame: Tk_Widget'Class) with SPARK_Mode is Tokens: Slice_Set; Item: Ttk_Frame; begin if End_Index < Start_Index then return; end if; Delete_Widgets_Loop : for I in Start_Index .. End_Index loop Create (S => Tokens, From => Tcl.Tk.Ada.Grid.Grid_Slaves (Master => Frame, Option => "-row" & Positive'Image(I)), Separators => " "); Delete_Row_Loop : for J in 1 .. Slice_Count(S => Tokens) loop Item := Get_Widget(pathName => Slice(S => Tokens, Index => J)); Destroy(Widgt => Item); end loop Delete_Row_Loop; end loop Delete_Widgets_Loop; end Delete_Widgets; function Get_Skill_Marks (Skill_Index: Skills_Amount_Range; Member_Index: Positive) return String is Skill_Value, Crew_Index: Natural := 0; Skill_String: Unbounded_String := Null_Unbounded_String; begin Get_Highest_Skills_Loop : for I in Player_Ship.Crew.First_Index .. Player_Ship.Crew.Last_Index loop if GetSkillLevel (Member => Player_Ship.Crew(I), SkillIndex => Skill_Index) > Skill_Value then Crew_Index := I; Skill_Value := GetSkillLevel (Member => Player_Ship.Crew(I), SkillIndex => Skill_Index); end if; end loop Get_Highest_Skills_Loop; if GetSkillLevel (Member => Player_Ship.Crew(Member_Index), SkillIndex => Skill_Index) > 0 then Skill_String := To_Unbounded_String(Source => " +"); end if; if Member_Index = Crew_Index then Skill_String := Skill_String & To_Unbounded_String(Source => "+"); end if; return To_String(Source => Skill_String); end Get_Skill_Marks; end Utils.UI;
Categories/Morphism/Reasoning/Core.agda
Taneb/agda-categories
0
10848
{-# OPTIONS --without-K --safe #-} open import Categories.Category {- Helper routines most often used in reasoning with commutative squares, at the level of arrows in categories. Basic : reasoning about identity Pulls : use a ∘ b ≈ c as left-to-right rewrite Pushes : use c ≈ a ∘ b as a left-to-right rewrite IntroElim : introduce/eliminate an equivalent-to-id arrow Extend : 'extends' a commutative square with an equality on left/right/both -} module Categories.Morphism.Reasoning.Core {o ℓ e} (C : Category o ℓ e) where open import Level open import Function renaming (id to idᶠ; _∘_ to _∙_) open import Relation.Binary hiding (_⇒_) open Category C private variable X Y : Obj a a′ a″ b b′ b″ c c′ c″ : X ⇒ Y f g h i : X ⇒ Y open HomReasoning module Basic where id-unique : ∀ {o} {f : o ⇒ o} → (∀ g → g ∘ f ≈ g) → f ≈ id id-unique g∘f≈g = trans (sym identityˡ) (g∘f≈g id) id-comm : ∀ {a b} {f : a ⇒ b} → f ∘ id ≈ id ∘ f id-comm = trans identityʳ (sym identityˡ) id-comm-sym : ∀ {a b} {f : a ⇒ b} → id ∘ f ≈ f ∘ id id-comm-sym = trans identityˡ (sym identityʳ) open Basic public module Utils where assoc² : ((i ∘ h) ∘ g) ∘ f ≈ i ∘ (h ∘ (g ∘ f)) assoc² = trans assoc assoc assoc²' : (i ∘ (h ∘ g)) ∘ f ≈ i ∘ (h ∘ (g ∘ f)) assoc²' = trans assoc (∘-resp-≈ʳ assoc) open Utils public module Pulls (ab≡c : a ∘ b ≈ c) where pullʳ : (f ∘ a) ∘ b ≈ f ∘ c pullʳ {f = f} = begin (f ∘ a) ∘ b ≈⟨ assoc ⟩ f ∘ (a ∘ b) ≈⟨ refl⟩∘⟨ ab≡c ⟩ f ∘ c ∎ pullˡ : a ∘ b ∘ f ≈ c ∘ f pullˡ {f = f} = begin a ∘ b ∘ f ≈⟨ sym assoc ⟩ (a ∘ b) ∘ f ≈⟨ ab≡c ⟩∘⟨refl ⟩ c ∘ f ∎ open Pulls public module Pushes (c≡ab : c ≈ a ∘ b) where pushʳ : f ∘ c ≈ (f ∘ a) ∘ b pushʳ {f = f} = begin f ∘ c ≈⟨ refl⟩∘⟨ c≡ab ⟩ f ∘ (a ∘ b) ≈˘⟨ assoc ⟩ (f ∘ a) ∘ b ∎ pushˡ : c ∘ f ≈ a ∘ (b ∘ f) pushˡ {f = f} = begin c ∘ f ≈⟨ c≡ab ⟩∘⟨refl ⟩ (a ∘ b) ∘ f ≈⟨ assoc ⟩ a ∘ (b ∘ f) ∎ open Pushes public module IntroElim (a≡id : a ≈ id) where elimʳ : f ∘ a ≈ f elimʳ {f = f} = begin f ∘ a ≈⟨ refl⟩∘⟨ a≡id ⟩ f ∘ id ≈⟨ identityʳ ⟩ f ∎ introʳ : f ≈ f ∘ a introʳ = Equiv.sym elimʳ elimˡ : (a ∘ f) ≈ f elimˡ {f = f} = begin a ∘ f ≈⟨ a≡id ⟩∘⟨refl ⟩ id ∘ f ≈⟨ identityˡ ⟩ f ∎ introˡ : f ≈ a ∘ f introˡ = Equiv.sym elimˡ open IntroElim public module Extends (s : CommutativeSquare f g h i) where extendˡ : CommutativeSquare f g (a ∘ h) (a ∘ i) extendˡ {a = a} = begin (a ∘ h) ∘ f ≈⟨ pullʳ s ⟩ a ∘ i ∘ g ≈˘⟨ assoc ⟩ (a ∘ i) ∘ g ∎ extendʳ : CommutativeSquare (f ∘ a) (g ∘ a) h i extendʳ {a = a} = begin h ∘ (f ∘ a) ≈⟨ pullˡ s ⟩ (i ∘ g) ∘ a ≈⟨ assoc ⟩ i ∘ (g ∘ a) ∎ extend² : CommutativeSquare (f ∘ b) (g ∘ b) (a ∘ h) (a ∘ i) extend² {b = b} {a = a } = begin (a ∘ h) ∘ (f ∘ b) ≈⟨ pullʳ extendʳ ⟩ a ∘ (i ∘ (g ∘ b)) ≈˘⟨ assoc ⟩ (a ∘ i) ∘ (g ∘ b) ∎ open Extends public -- essentially composition in the arrow category {- A₁ -- c --> B₁ | | b′ comm b | | V V A₂ -- c′ -> B₂ | | a′ comm a | | V V A₃ -- c″ -> B₃ then the whole diagram commutes -} glue : CommutativeSquare c′ a′ a c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c (a′ ∘ b′) (a ∘ b) c″ glue {c′ = c′} {a′ = a′} {a = a} {c″ = c″} {c = c} {b′ = b′} {b = b} sq-a sq-b = begin (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ≈⟨ pullˡ sq-a ⟩ (c″ ∘ a′) ∘ b′ ≈⟨ assoc ⟩ c″ ∘ (a′ ∘ b′) ∎ glue◃◽ : a ∘ c′ ≈ c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c b′ (a ∘ b) c″ glue◃◽ {a = a} {c′ = c′} {c″ = c″} {c = c} {b′ = b′} {b = b} tri-a sq-b = begin (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ≈⟨ pullˡ tri-a ⟩ c″ ∘ b′ ∎ glue◃◽′ : c ∘ c′ ≈ a′ → CommutativeSquare a b a′ b′ → CommutativeSquare (c′ ∘ a) b c b′ glue◃◽′ {c = c} {c′ = c′} {a′ = a′} {a = a} {b = b} {b′ = b′} tri sq = begin c ∘ c′ ∘ a ≈⟨ pullˡ tri ⟩ a′ ∘ a ≈⟨ sq ⟩ b′ ∘ b ∎ glue◽◃ : CommutativeSquare a b a′ b′ → b ∘ c ≈ c′ → CommutativeSquare (a ∘ c) c′ a′ b′ glue◽◃ {a = a} {b = b} {a′ = a′} {b′ = b′} {c = c} {c′ = c′} sq tri = begin a′ ∘ a ∘ c ≈⟨ pullˡ sq ⟩ (b′ ∘ b) ∘ c ≈⟨ pullʳ tri ⟩ b′ ∘ c′ ∎ glue▹◽ : b ∘ a″ ≈ c → CommutativeSquare a b a′ b′ → CommutativeSquare (a ∘ a″) c a′ b′ glue▹◽ {b = b} {a″ = a″} {c = c} {a = a} {a′ = a′} {b′ = b′} tri sq = begin a′ ∘ a ∘ a″ ≈⟨ pullˡ sq ⟩ (b′ ∘ b) ∘ a″ ≈⟨ pullʳ tri ⟩ b′ ∘ c ∎ -- essentially composition in the over category glueTrianglesʳ : a ∘ b ≈ a′ → a′ ∘ b′ ≈ a″ → a ∘ (b ∘ b′) ≈ a″ glueTrianglesʳ {a = a} {b = b} {a′ = a′} {b′ = b′} {a″ = a″} a∘b≡a′ a′∘b′≡a″ = begin a ∘ (b ∘ b′) ≈⟨ pullˡ a∘b≡a′ ⟩ a′ ∘ b′ ≈⟨ a′∘b′≡a″ ⟩ a″ ∎ -- essentially composition in the under category glueTrianglesˡ : a′ ∘ b′ ≈ b″ → a ∘ b ≈ b′ → (a′ ∘ a) ∘ b ≈ b″ glueTrianglesˡ {a′ = a′} {b′ = b′} {b″ = b″} {a = a} {b = b} a′∘b′≡b″ a∘b≡b′ = begin (a′ ∘ a) ∘ b ≈⟨ pullʳ a∘b≡b′ ⟩ a′ ∘ b′ ≈⟨ a′∘b′≡b″ ⟩ b″ ∎ module Cancellers (inv : h ∘ i ≈ id) where cancelʳ : (f ∘ h) ∘ i ≈ f cancelʳ {f = f} = begin (f ∘ h) ∘ i ≈⟨ pullʳ inv ⟩ f ∘ id ≈⟨ identityʳ ⟩ f ∎ cancelˡ : h ∘ (i ∘ f) ≈ f cancelˡ {f = f} = begin h ∘ (i ∘ f) ≈⟨ pullˡ inv ⟩ id ∘ f ≈⟨ identityˡ ⟩ f ∎ cancelInner : (f ∘ h) ∘ (i ∘ g) ≈ f ∘ g cancelInner {f = f} {g = g} = begin (f ∘ h) ∘ (i ∘ g) ≈⟨ pullˡ cancelʳ ⟩ f ∘ g ∎ open Cancellers public center : g ∘ h ≈ a → (f ∘ g) ∘ h ∘ i ≈ f ∘ a ∘ i center {g = g} {h = h} {a = a} {f = f} {i = i} eq = begin (f ∘ g) ∘ h ∘ i ≈⟨ assoc ⟩ f ∘ g ∘ h ∘ i ≈⟨ refl⟩∘⟨ pullˡ eq ⟩ f ∘ a ∘ i ∎ center⁻¹ : f ∘ g ≈ a → h ∘ i ≈ b → f ∘ (g ∘ h) ∘ i ≈ a ∘ b center⁻¹ {f = f} {g = g} {a = a} {h = h} {i = i} {b = b} eq eq′ = begin f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq′ ⟩ f ∘ g ∘ b ≈⟨ pullˡ eq ⟩ a ∘ b ∎ pull-last : h ∘ i ≈ a → (f ∘ g ∘ h) ∘ i ≈ f ∘ g ∘ a pull-last {h = h} {i = i} {a = a} {f = f} {g = g} eq = begin (f ∘ g ∘ h) ∘ i ≈⟨ assoc ⟩ f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq ⟩ f ∘ g ∘ a ∎ pull-first : f ∘ g ≈ a → f ∘ (g ∘ h) ∘ i ≈ a ∘ h ∘ i pull-first {f = f} {g = g} {a = a} {h = h} {i = i} eq = begin f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ assoc ⟩ f ∘ g ∘ h ∘ i ≈⟨ pullˡ eq ⟩ a ∘ h ∘ i ∎
kernel/support/debug.asm
paulscottrobson/color-forth-old-next
1
101856
<reponame>paulscottrobson/color-forth-old-next<gh_stars>1-10 ; ********************************************************************************* ; ********************************************************************************* ; ; File: debug.asm ; Purpose: Show stack on the screen. ; Date : 8th December 2018 ; Author: <EMAIL> ; ; ********************************************************************************* ; ********************************************************************************* DEBUGShow: pop bc ; return address push de ; stack is now decached push bc ; the stack is now [data stack] [return address] push ix ; now [data stack] [return address] [ix] ld hl,$0000 ; get SP value add hl,sp ld de,StackTop ex de,hl ; calculate Stack Top - SP xor a sbc hl,de rr l ; divide by 2 as 2 bytes per stack element. dec l ; subtract two for the return address and IX dec l dec l ; one for the initial PUSH DE ; means ld sp,top == empty ld b,l ; put count in B ld ix,StackTop-2 ; TOS in IX push bc ; clear the bottom 32 characters ld hl,(__DIScreenSize) ld de,-32 add hl,de push hl ld b,32 __DEBUGShowClear: ld de,$0620 call GFXWriteCharacter inc hl djnz __DEBUGShowClear pop hl ; HL points to bottom line pop bc ; B is the count to print ld c,32 ; C is the ramining characters ; IX points to the bottom stack element. ld a,b ; exit on underflow or empty or a jr z,__DEBUGShowExit jp m,__DEBUGShowExit __DEBUGShowLoop: dec ix ; read next value dec ix ld e,(ix+0) ld d,(ix+1) call __DEBUGPrintDecimalInteger ; print DE at position HL, C Chars remaining. inc hl ; space right dec c ; one fewer character bit 7,c ; if -ve exit anyway jr nz,__DEBUGShowExit djnz __DEBUGShowLoop ; do however many. __DEBUGShowExit: pop ix ; restore IX pop hl ; pop return address pop de ; decache stack jp (hl) ; and exit. __DEBUGPrintDecimalInteger: push de bit 7,d ; is it negative. jr z,__DEBUGPrintDecNotNegative ld a,d ; if so, negate the value. cpl ld d,a ld a,e cpl ld e,a inc de __DEBUGPrintDecNotNegative: call __DEBUGPrintDERecursively pop de bit 7,d ; was it -VE ret z ld de,$0600+'-' ; print a -ve sign call GFXWriteCharacter inc hl dec c ret __DEBUGPrintDERecursively: push hl ; save screen position ld hl,10 ; divide by 10, DE is division, HL is remainder. call DIVDivideMod16 ex (sp),hl ; remainder on TOS, HL contains screen position ld a,d ; if DE is non zero call Recursively or e call nz,__DEBUGPrintDERecursively pop de ; DE = remainder ld a,e ; convert E to a character or '0' ld e,a ld d,6 ; yellow call GFXWriteCharacter ; write digit. inc hl dec c ret ret
Transynther/x86/_processed/NONE/_zr_/i3-7100_9_0x84_notsx.log_21829_2095.asm
ljhsiun2/medusa
9
22356
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1e33d, %rbx nop nop add $19344, %r12 mov (%rbx), %edi nop nop nop nop nop xor $54299, %rsi lea addresses_D_ht+0x1835, %rdx nop nop nop nop nop inc %r10 movb (%rdx), %r14b nop nop cmp %rdi, %rdi lea addresses_UC_ht+0x8545, %rsi nop nop xor $51672, %rdi mov $0x6162636465666768, %rbx movq %rbx, %xmm0 movups %xmm0, (%rsi) nop nop nop nop cmp %r14, %r14 lea addresses_UC_ht+0x5329, %rsi lea addresses_WC_ht+0xbc35, %rdi clflush (%rdi) nop nop xor %r14, %r14 mov $45, %rcx rep movsb nop dec %rcx lea addresses_UC_ht+0x5979, %rcx nop nop nop xor $14561, %rdi movb (%rcx), %dl nop nop nop xor $7515, %rbx lea addresses_D_ht+0x15035, %rbx nop nop nop nop inc %r12 mov (%rbx), %dx cmp $25086, %rdx lea addresses_normal_ht+0x6435, %r14 nop nop nop and $45096, %r10 movb $0x61, (%r14) nop nop add %r12, %r12 lea addresses_UC_ht+0x1841, %r14 add $47416, %rsi mov (%r14), %rbx nop nop add $5570, %r12 lea addresses_UC_ht+0x19035, %rsi lea addresses_UC_ht+0x17746, %rdi nop sub %rbx, %rbx mov $81, %rcx rep movsb nop nop nop nop cmp $27020, %rbx lea addresses_WC_ht+0xedc5, %rdi nop add $8018, %rsi movups (%rdi), %xmm2 vpextrq $1, %xmm2, %rcx nop nop and $19921, %rbx lea addresses_normal_ht+0x4135, %rsi clflush (%rsi) nop add %rdx, %rdx mov $0x6162636465666768, %r10 movq %r10, %xmm5 movups %xmm5, (%rsi) nop nop and %rsi, %rsi lea addresses_A_ht+0xb66f, %rsi lea addresses_WC_ht+0x14f5, %rdi nop nop and %r14, %r14 mov $89, %rcx rep movsq nop nop nop nop add $12687, %r14 lea addresses_A_ht+0x19633, %rbx nop nop nop xor %rdi, %rdi mov (%rbx), %edx nop nop and $62510, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r15 push %r9 push %rbp push %rdx // Store lea addresses_WC+0xacf7, %r15 nop add $38397, %rbp movw $0x5152, (%r15) nop nop nop nop and %rdx, %rdx // Store lea addresses_A+0xa035, %r10 nop nop cmp $61065, %r9 mov $0x5152535455565758, %r15 movq %r15, %xmm6 vmovups %ymm6, (%r10) nop and %rbp, %rbp // Store mov $0xd15, %r13 nop xor $22753, %rbp mov $0x5152535455565758, %rdx movq %rdx, %xmm3 movups %xmm3, (%r13) nop nop nop and %r9, %r9 // Store lea addresses_D+0x11ced, %rdx clflush (%rdx) nop nop and $48674, %r14 movb $0x51, (%rdx) cmp %r10, %r10 // Store lea addresses_UC+0x170ab, %r9 nop nop sub %r13, %r13 mov $0x5152535455565758, %rbp movq %rbp, %xmm1 movups %xmm1, (%r9) nop nop nop nop nop add $30844, %r13 // Store lea addresses_PSE+0x1eb35, %r9 nop nop sub %rbp, %rbp mov $0x5152535455565758, %r14 movq %r14, (%r9) nop nop nop nop nop sub %r13, %r13 // Faulty Load lea addresses_A+0xa035, %r15 nop nop and %r13, %r13 vmovups (%r15), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rdx lea oracles, %r13 and $0xff, %rdx shlq $12, %rdx mov (%r13,%rdx,1), %rdx pop %rdx pop %rbp pop %r9 pop %r15 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'same': True, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'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 */
Cubical/ZCohomology/MayerVietorisUnreduced.agda
ayberkt/cubical
0
14241
<reponame>ayberkt/cubical<gh_stars>0 {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.MayerVietorisUnreduced where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.KcompPrelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.HITs.Pushout open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) open import Cubical.Data.Nat open import Cubical.Data.Prod hiding (_×_) open import Cubical.Algebra.Group open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3) open GroupHom module MV {ℓ ℓ' ℓ''} (A : Type ℓ) (B : Type ℓ') (C : Type ℓ'') (f : C → A) (g : C → B) where -- Proof from Brunerie 2016. -- We first define the three morphisms involved: i, Δ and d. private i* : (n : ℕ) → coHom n (Pushout f g) → coHom n A × coHom n B i* _ = sRec (isSet× setTruncIsSet setTruncIsSet) λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂ iIsHom : (n : ℕ) → isGroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B) (i* n) iIsHom _ = sElim2 (λ _ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ _ _ → refl i : (n : ℕ) → GroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B) GroupHom.fun (i n) = i* n GroupHom.isHom (i n) = iIsHom n private distrLem : (n : ℕ) (x y z w : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ (z +[ n ]ₖ w) ≡ (x -[ n ]ₖ z) +[ n ]ₖ (y -[ n ]ₖ w) distrLem n x y z w = cong (ΩKn+1→Kn n) (cong₂ (λ q p → q ∙ sym p) (+ₖ→∙ n x y) (+ₖ→∙ n z w) ∙∙ cong ((Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) ∙_) (symDistr (Kn→ΩKn+1 n z) (Kn→ΩKn+1 n w)) ∙∙ ((sym (assoc (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) _)) ∙∙ cong (Kn→ΩKn+1 n x ∙_) (assoc (Kn→ΩKn+1 n y) (sym (Kn→ΩKn+1 n w)) (sym (Kn→ΩKn+1 n z))) ∙∙ (cong (Kn→ΩKn+1 n x ∙_) (isCommΩK (suc n) _ _) ∙∙ assoc _ _ _ ∙∙ cong₂ _∙_ (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n z)))) (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n y ∙ sym (Kn→ΩKn+1 n w))))))) Δ' : (n : ℕ) → ⟨ ×coHomGr n A B ⟩ → ⟨ coHomGr n C ⟩ Δ' n (α , β) = coHomFun n f α -[ n ]ₕ coHomFun n g β Δ'-isMorph : (n : ℕ) → isGroupHom (×coHomGr n A B) (coHomGr n C) (Δ' n) Δ'-isMorph n = prodElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _ ) λ f' x1 g' x2 i → ∣ (λ x → distrLem n (f' (f x)) (g' (f x)) (x1 (g x)) (x2 (g x)) i) ∣₂ Δ : (n : ℕ) → GroupHom (×coHomGr n A B) (coHomGr n C) GroupHom.fun (Δ n) = Δ' n GroupHom.isHom (Δ n) = Δ'-isMorph n d-pre : (n : ℕ) → (C → coHomK n) → Pushout f g → coHomK (suc n) d-pre n γ (inl x) = 0ₖ (suc n) d-pre n γ (inr x) = 0ₖ (suc n) d-pre zero γ (push a i) = Kn→ΩKn+1 zero (γ a) i d-pre (suc n) γ (push a i) = Kn→ΩKn+1 (suc n) (γ a) i dHomHelperPath : (n : ℕ) (h l : C → coHomK n) (a : C) → I → I → coHomK (suc n) dHomHelperPath zero h l a i j = hcomp (λ k → λ { (i = i0) → lUnitₖ 1 (0ₖ 1) (~ j) ; (i = i1) → lUnitₖ 1 (0ₖ 1) (~ j) ; (j = i0) → +ₖ→∙ 0 (h a) (l a) (~ k) i ; (j = i1) → cong₂Funct (λ x y → x +[ 1 ]ₖ y) (Kn→ΩKn+1 0 (h a)) (Kn→ΩKn+1 0 (l a)) (~ k) i}) (bottom i j) where bottom : I → I → coHomK 1 bottom i j = hcomp (λ k → λ { (i = i0) → lUnitₖ 1 (0ₖ 1) (~ j) ; (i = i1) → lUnitₖ 1 (Kn→ΩKn+1 0 (l a) k) (~ j) }) (anotherbottom i j) where anotherbottom : I → I → coHomK 1 anotherbottom i j = hcomp (λ k → λ { (i = i0) → rUnitlUnit0 1 k (~ j) ; (i = i1) → rUnitlUnit0 1 k (~ j) ; (j = i0) → Kn→ΩKn+1 0 (h a) i ; (j = i1) → Kn→ΩKn+1 0 (h a) i +[ 1 ]ₖ 0ₖ 1 }) (rUnitₖ 1 (Kn→ΩKn+1 0 (h a) i) (~ j)) dHomHelperPath (suc n) h l a i j = hcomp (λ k → λ { (i = i0) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (i = i1) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (j = i0) → +ₖ→∙ (suc n) (h a) (l a) (~ k) i ; (j = i1) → cong₂Funct (λ x y → x +[ 2 + n ]ₖ y) (Kn→ΩKn+1 (suc n) (h a)) (Kn→ΩKn+1 (suc n) (l a)) (~ k) i}) (bottom i j) where bottom : I → I → coHomK (2 + n) bottom i j = hcomp (λ k → λ { (i = i0) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (i = i1) → lUnitₖ (2 + n) (Kn→ΩKn+1 (suc n) (l a) k) (~ j) }) (anotherbottom i j) where anotherbottom : I → I → coHomK (2 + n) anotherbottom i j = hcomp (λ k → λ { (i = i0) → rUnitlUnit0 (2 + n) k (~ j) ; (i = i1) → rUnitlUnit0 (2 + n) k (~ j) ; (j = i0) → Kn→ΩKn+1 (suc n) (h a) i ; (j = i1) → Kn→ΩKn+1 (suc n) (h a) i +[ 2 + n ]ₖ (0ₖ (2 + n)) }) (rUnitₖ (2 + n) (Kn→ΩKn+1 (suc n) (h a) i) (~ j)) dHomHelper : (n : ℕ) (h l : C → coHomK n) (x : Pushout f g) → d-pre n (λ x → h x +[ n ]ₖ l x) x ≡ d-pre n h x +[ suc n ]ₖ d-pre n l x dHomHelper n h l (inl x) = sym (lUnitₖ (suc n) (0ₖ (suc n))) dHomHelper n h l (inr x) = sym (lUnitₖ (suc n) (0ₖ (suc n))) dHomHelper zero h l (push a i) j = dHomHelperPath zero h l a i j dHomHelper (suc n) h l (push a i) j = dHomHelperPath (suc n) h l a i j dIsHom : (n : ℕ) → isGroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂) dIsHom zero = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ funExt (λ x → dHomHelper zero f g x) i ∣₂ dIsHom (suc n) = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ funExt (λ x → dHomHelper (suc n) f g x) i ∣₂ d : (n : ℕ) → GroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g)) GroupHom.fun (d n) = sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂ GroupHom.isHom (d n) = dIsHom n -- The long exact sequence Im-d⊂Ker-i : (n : ℕ) (x : ⟨ (coHomGr (suc n) (Pushout f g)) ⟩) → isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x → isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x Im-d⊂Ker-i n = sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ a → pRec (isOfHLevelPath' 1 (isSet× setTruncIsSet setTruncIsSet) _ _) (sigmaElim (λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ δ b i → sRec (isSet× setTruncIsSet setTruncIsSet) (λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂ ) (b (~ i))) Ker-i⊂Im-d : (n : ℕ) (x : ⟨ coHomGr (suc n) (Pushout f g) ⟩) → isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x → isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x Ker-i⊂Im-d zero = sElim (λ _ → isSetΠ λ _ → isProp→isSet propTruncIsProp) λ a p → pRec {A = (λ x → a (inl x)) ≡ λ _ → 0ₖ 1} (isProp→ propTruncIsProp) (λ p1 → pRec propTruncIsProp λ p2 → ∣ ∣ (λ c → ΩKn+1→Kn 0 (sym (cong (λ F → F (f c)) p1) ∙∙ cong a (push c) ∙∙ cong (λ F → F (g c)) p2)) ∣₂ , cong ∣_∣₂ (funExt (λ δ → helper a p1 p2 δ)) ∣₁) (Iso.fun PathIdTrunc₀Iso (cong fst p)) (Iso.fun PathIdTrunc₀Iso (cong snd p)) where helper : (F : (Pushout f g) → hLevelTrunc 3 (S₊ 1)) (p1 : Path (_ → hLevelTrunc 3 (S₊ 1)) (λ a₁ → F (inl a₁)) (λ _ → ∣ base ∣)) (p2 : Path (_ → hLevelTrunc 3 (S₊ 1)) (λ a₁ → F (inr a₁)) (λ _ → ∣ base ∣)) → (δ : Pushout f g) → d-pre 0 (λ c → ΩKn+1→Kn 0 ((λ i₁ → p1 (~ i₁) (f c)) ∙∙ cong F (push c) ∙∙ cong (λ F → F (g c)) p2)) δ ≡ F δ helper F p1 p2 (inl x) = sym (cong (λ f → f x) p1) helper F p1 p2 (inr x) = sym (cong (λ f → f x) p2) helper F p1 p2 (push a i) j = hcomp (λ k → λ { (i = i0) → p1 (~ j) (f a) ; (i = i1) → p2 (~ j) (g a) ; (j = i0) → Iso.rightInv (Iso-Kn-ΩKn+1 0) ((λ i₁ → p1 (~ i₁) (f a)) ∙∙ cong F (push a) ∙∙ cong (λ F₁ → F₁ (g a)) p2) (~ k) i ; (j = i1) → F (push a i)}) (doubleCompPath-filler (sym (cong (λ F → F (f a)) p1)) (cong F (push a)) (cong (λ F → F (g a)) p2) (~ j) i) Ker-i⊂Im-d (suc n) = sElim (λ _ → isSetΠ λ _ → isProp→isSet propTruncIsProp) λ a p → pRec {A = (λ x → a (inl x)) ≡ λ _ → 0ₖ (2 + n)} (isProp→ propTruncIsProp) (λ p1 → pRec propTruncIsProp λ p2 → ∣ ∣ (λ c → ΩKn+1→Kn (suc n) (sym (cong (λ F → F (f c)) p1) ∙∙ cong a (push c) ∙∙ cong (λ F → F (g c)) p2)) ∣₂ , cong ∣_∣₂ (funExt (λ δ → helper a p1 p2 δ)) ∣₁) (Iso.fun PathIdTrunc₀Iso (cong fst p)) (Iso.fun PathIdTrunc₀Iso (cong snd p)) where helper : (F : (Pushout f g) → hLevelTrunc (4 + n) (S₊ (2 + n))) (p1 : Path (_ → hLevelTrunc (4 + n) (S₊ (2 + n))) (λ a₁ → F (inl a₁)) (λ _ → ∣ north ∣)) (p2 : Path (_ → hLevelTrunc (4 + n) (S₊ (2 + n))) (λ a₁ → F (inr a₁)) (λ _ → ∣ north ∣)) → (δ : (Pushout f g)) → d-pre (suc n) (λ c → ΩKn+1→Kn (suc n) ((λ i₁ → p1 (~ i₁) (f c)) ∙∙ cong F (push c) ∙∙ cong (λ F → F (g c)) p2)) δ ≡ F δ helper F p1 p2 (inl x) = sym (cong (λ f → f x) p1) helper F p1 p2 (inr x) = sym (cong (λ f → f x) p2) helper F p1 p2 (push a i) j = hcomp (λ k → λ { (i = i0) → p1 (~ j) (f a) ; (i = i1) → p2 (~ j) (g a) ; (j = i0) → Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) ((λ i₁ → p1 (~ i₁) (f a)) ∙∙ cong F (push a) ∙∙ cong (λ F₁ → F₁ (g a)) p2) (~ k) i ; (j = i1) → F (push a i)}) (doubleCompPath-filler (sym (cong (λ F → F (f a)) p1)) (cong F (push a)) (cong (λ F → F (g a)) p2) (~ j) i) open GroupHom Im-i⊂Ker-Δ : (n : ℕ) (x : ⟨ ×coHomGr n A B ⟩) → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) x → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) x Im-i⊂Ker-Δ n (Fa , Fb) = sElim {B = λ Fa → (Fb : _) → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) (Fa , Fb) → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) (Fa , Fb)} (λ _ → isSetΠ2 λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) (λ Fa → sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fb → pRec (setTruncIsSet _ _) (sigmaElim (λ x → isProp→isSet (setTruncIsSet _ _)) λ Fd p → helper n Fa Fb Fd p)) Fa Fb where helper : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n) (Fd : (Pushout f g) → coHomK n) → (fun (i n) ∣ Fd ∣₂ ≡ (∣ Fa ∣₂ , ∣ Fb ∣₂)) → (fun (Δ n)) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n helper zero Fa Fb Fd p = cong (fun (Δ zero)) (sym p) ∙∙ (λ i → ∣ (λ x → Fd (inl (f x))) ∣₂ -[ 0 ]ₕ ∣ (λ x → Fd (push x (~ i))) ∣₂ ) ∙∙ cancelₕ 0 ∣ (λ x → Fd (inl (f x))) ∣₂ helper (suc n) Fa Fb Fd p = cong (fun (Δ (suc n))) (sym p) ∙∙ (λ i → ∣ (λ x → Fd (inl (f x))) ∣₂ -[ (suc n) ]ₕ ∣ (λ x → Fd (push x (~ i))) ∣₂) ∙∙ cancelₕ (suc n) ∣ (λ x → Fd (inl (f x))) ∣₂ Ker-Δ⊂Im-i : (n : ℕ) (a : ⟨ ×coHomGr n A B ⟩) → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) a → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) a Ker-Δ⊂Im-i n = prodElim (λ _ → isSetΠ (λ _ → isProp→isSet propTruncIsProp)) (λ Fa Fb p → pRec propTruncIsProp (λ q → ∣ ∣ helpFun Fa Fb q ∣₂ , refl ∣₁) (helper Fa Fb p)) where helper : (Fa : A → coHomK n) (Fb : B → coHomK n) → fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n → ∥ Path (_ → _) (λ c → Fa (f c)) (λ c → Fb (g c)) ∥₁ helper Fa Fb p = Iso.fun PathIdTrunc₀Iso (sym (-+cancelₕ n ∣ (λ c → Fa (f c)) ∣₂ ∣ (λ c → Fb (g c)) ∣₂) ∙∙ cong (λ x → x +[ n ]ₕ ∣ (λ c → Fb (g c)) ∣₂) p ∙∙ lUnitₕ n _) helpFun : (Fa : A → coHomK n) (Fb : B → coHomK n) → ((λ c → Fa (f c)) ≡ (λ c → Fb (g c))) → Pushout f g → coHomK n helpFun Fa Fb p (inl x) = Fa x helpFun Fa Fb p (inr x) = Fb x helpFun Fa Fb p (push a i) = p i a private distrHelper : (n : ℕ) (p q : _) → ΩKn+1→Kn n p +[ n ]ₖ (-[ n ]ₖ ΩKn+1→Kn n q) ≡ ΩKn+1→Kn n (p ∙ sym q) distrHelper n p q i = ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) p i ∙ Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) q i)) i) Ker-d⊂Im-Δ : (n : ℕ) (a : coHom n C) → isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a → isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a Ker-d⊂Im-Δ zero = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp) λ Fc p → pRec propTruncIsProp (λ p → ∣ (∣ (λ a → ΩKn+1→Kn 0 (cong (λ f → f (inl a)) p)) ∣₂ , ∣ (λ b → ΩKn+1→Kn 0 (cong (λ f → f (inr b)) p)) ∣₂) , Iso.inv (PathIdTrunc₀Iso) ∣ funExt (λ c → helper2 Fc p c) ∣₁ ∣₁) (Iso.fun (PathIdTrunc₀Iso) p) where helper2 : (Fc : C → coHomK 0) (p : d-pre 0 Fc ≡ (λ _ → ∣ base ∣)) (c : C) → ΩKn+1→Kn 0 (λ i₁ → p i₁ (inl (f c))) -[ 0 ]ₖ (ΩKn+1→Kn 0 (λ i₁ → p i₁ (inr (g c)))) ≡ Fc c helper2 Fc p c = cong₂ (λ x y → ΩKn+1→Kn 0 (x ∙ sym y)) (Iso.rightInv (Iso-Kn-ΩKn+1 0) (λ i₁ → p i₁ (inl (f c)))) (Iso.rightInv (Iso-Kn-ΩKn+1 0) (λ i₁ → p i₁ (inr (g c)))) ∙∙ cong (ΩKn+1→Kn 0) (sym ((PathP→compPathR (cong (λ f → cong f (push c)) p)) ∙ (λ i → (λ i₁ → p i₁ (inl (f c))) ∙ (lUnit (sym (λ i₁ → p i₁ (inr (g c)))) (~ i))))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 zero) (Fc c) Ker-d⊂Im-Δ (suc n) = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp) λ Fc p → pRec propTruncIsProp (λ p → ∣ (∣ (λ a → ΩKn+1→Kn (suc n) (cong (λ f → f (inl a)) p)) ∣₂ , ∣ (λ b → ΩKn+1→Kn (suc n) (cong (λ f → f (inr b)) p)) ∣₂) , Iso.inv (PathIdTrunc₀Iso) ∣ funExt (λ c → helper2 Fc p c) ∣₁ ∣₁) (Iso.fun (PathIdTrunc₀Iso) p) where helper2 : (Fc : C → coHomK (suc n)) (p : d-pre (suc n) Fc ≡ (λ _ → ∣ north ∣)) (c : C) → ΩKn+1→Kn (suc n) (λ i₁ → p i₁ (inl (f c))) -[ (suc n) ]ₖ (ΩKn+1→Kn (suc n) (λ i₁ → p i₁ (inr (g c)))) ≡ Fc c helper2 Fc p c = cong₂ (λ x y → ΩKn+1→Kn (suc n) (x ∙ sym y)) (Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) (λ i₁ → p i₁ (inl (f c)))) (Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) (λ i₁ → p i₁ (inr (g c)))) ∙∙ cong (ΩKn+1→Kn (suc n)) (sym ((PathP→compPathR (cong (λ f → cong f (push c)) p)) ∙ (λ i → (λ i₁ → p i₁ (inl (f c))) ∙ (lUnit (sym (λ i₁ → p i₁ (inr (g c)))) (~ i))))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (Fc c) Im-Δ⊂Ker-d : (n : ℕ) (a : coHom n C) → isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a → isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a Im-Δ⊂Ker-d n = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fc → pRec (isOfHLevelPath' 1 setTruncIsSet _ _) (sigmaProdElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fa Fb p → pRec (isOfHLevelPath' 1 setTruncIsSet _ _) (λ q → ((λ i → fun (d n) ∣ (q (~ i)) ∣₂) ∙ dΔ-Id n Fa Fb)) (Iso.fun (PathIdTrunc₀Iso) p)) where d-preLeftId : (n : ℕ) (Fa : A → coHomK n)(d : (Pushout f g)) → d-pre n (Fa ∘ f) d ≡ 0ₖ (suc n) d-preLeftId zero Fa (inl x) = Kn→ΩKn+1 0 (Fa x) d-preLeftId (suc n) Fa (inl x) = Kn→ΩKn+1 (suc n) (Fa x) d-preLeftId zero Fa (inr x) = refl d-preLeftId (suc n) Fa (inr x) = refl d-preLeftId zero Fa (push a i) j = Kn→ΩKn+1 zero (Fa (f a)) (j ∨ i) d-preLeftId (suc n) Fa (push a i) j = Kn→ΩKn+1 (suc n) (Fa (f a)) (j ∨ i) d-preRightId : (n : ℕ) (Fb : B → coHomK n) (d : (Pushout f g)) → d-pre n (Fb ∘ g) d ≡ 0ₖ (suc n) d-preRightId n Fb (inl x) = refl d-preRightId zero Fb (inr x) = sym (Kn→ΩKn+1 0 (Fb x)) d-preRightId (suc n) Fb (inr x) = sym (Kn→ΩKn+1 (suc n) (Fb x)) d-preRightId zero Fb (push a i) j = Kn→ΩKn+1 zero (Fb (g a)) (~ j ∧ i) d-preRightId (suc n) Fb (push a i) j = Kn→ΩKn+1 (suc n) (Fb (g a)) (~ j ∧ i) dΔ-Id : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n) → fun (d n) (fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂)) ≡ 0ₕ (suc n) dΔ-Id zero Fa Fb = -distrLemma 0 1 (d zero) ∣ Fa ∘ f ∣₂ ∣ Fb ∘ g ∣₂ ∙∙ (λ i → ∣ (λ x → d-preLeftId zero Fa x i) ∣₂ -[ 1 ]ₕ ∣ (λ x → d-preRightId zero Fb x i) ∣₂) ∙∙ cancelₕ 1 (0ₕ 1) dΔ-Id (suc n) Fa Fb = -distrLemma (suc n) (2 + n) (d (suc n)) ∣ Fa ∘ f ∣₂ ∣ Fb ∘ g ∣₂ ∙∙ (λ i → ∣ (λ x → d-preLeftId (suc n) Fa x i) ∣₂ -[ (2 + n) ]ₕ ∣ (λ x → d-preRightId (suc n) Fb x i) ∣₂) ∙∙ cancelₕ (2 + n) (0ₕ (2 + n))
Agda/21-image.agda
tadejpetric/HoTT-Intro
0
13636
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-} module 21-image where import 20-sequences open 20-sequences public {- We give the formal specification of propositional truncation. -} precomp-Prop : { l1 l2 l3 : Level} {A : UU l1} (P : hProp l2) → (A → type-Prop P) → (Q : hProp l3) → (type-Prop P → type-Prop Q) → A → type-Prop Q precomp-Prop P f Q g = g ∘ f universal-property-propositional-truncation : ( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) → ( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2) universal-property-propositional-truncation l P f = (Q : hProp l) → is-equiv (precomp-Prop P f Q) universal-property-propositional-truncation' : ( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) → ( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2) universal-property-propositional-truncation' l {A = A} P f = (Q : hProp l) → (A → type-Prop Q) → (type-Prop P → type-Prop Q) universal-property-propositional-truncation-simplify : { l1 l2 : Level} {A : UU l1} (P : hProp l2) ( f : A → type-Prop P) → ( (l : Level) → universal-property-propositional-truncation' l P f) → ( (l : Level) → universal-property-propositional-truncation l P f) universal-property-propositional-truncation-simplify P f up-P l Q = is-equiv-is-prop ( is-prop-Π (λ x → is-prop-type-Prop Q)) ( is-prop-Π (λ x → is-prop-type-Prop Q)) ( up-P l Q) precomp-Π-Prop : { l1 l2 l3 : Level} {A : UU l1} (P : hProp l2) → ( f : A → type-Prop P) (Q : type-Prop P → hProp l3) → ( g : (p : type-Prop P) → type-Prop (Q p)) → (x : A) → type-Prop (Q (f x)) precomp-Π-Prop P f Q g x = g (f x) dependent-universal-property-propositional-truncation : ( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) → ( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2) dependent-universal-property-propositional-truncation l P f = (Q : type-Prop P → hProp l) → is-equiv (precomp-Π-Prop P f Q) {- We introduce the image inclusion of a map. -} precomp-emb : { l1 l2 l3 l4 : Level} {X : UU l1} {A : UU l2} (f : A → X) {B : UU l3} ( i : B ↪ X) (q : hom-slice f (map-emb i)) → {C : UU l4} ( j : C ↪ X) (r : hom-slice (map-emb i) (map-emb j)) → hom-slice f (map-emb j) precomp-emb f i q j r = pair ( ( map-hom-slice (map-emb i) (map-emb j) r) ∘ ( map-hom-slice f (map-emb i) q)) ( ( triangle-hom-slice f (map-emb i) q) ∙h ( ( triangle-hom-slice (map-emb i) (map-emb j) r) ·r ( map-hom-slice f (map-emb i) q))) is-prop-hom-slice : { l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) → { B : UU l3} (i : B ↪ X) → is-prop (hom-slice f (map-emb i)) is-prop-hom-slice {X = X} f i = is-prop-is-equiv ( (x : X) → fib f x → fib (map-emb i) x) ( fiberwise-hom-hom-slice f (map-emb i)) ( is-equiv-fiberwise-hom-hom-slice f (map-emb i)) ( is-prop-Π ( λ x → is-prop-Π ( λ p → is-prop-map-is-emb (map-emb i) (is-emb-map-emb i) x))) universal-property-image : ( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) → { B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3) universal-property-image l {X = X} f i q = ( C : UU l) (j : C ↪ X) → is-equiv (precomp-emb f i q j) universal-property-image' : ( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) → { B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3) universal-property-image' l {X = X} f i q = ( C : UU l) (j : C ↪ X) → hom-slice f (map-emb j) → hom-slice (map-emb i) (map-emb j) universal-property-image-universal-property-image' : ( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) → { B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) → universal-property-image' l f i q → universal-property-image l f i q universal-property-image-universal-property-image' l f i q up' C j = is-equiv-is-prop ( is-prop-hom-slice (map-emb i) j) ( is-prop-hom-slice f j) ( up' C j)
random.asm
olebabale/shellmark
0
14146
<gh_stars>0 ;RANDOM NUMBER GENERATOR ;USING TIME STAMP COUNTER INSTRUCTION global _start section .text _start: rdtsc ;read time stamp counter shr eax,2 ret ;handshaking with C variable.(ret eax)!
oeis/024/A024537.asm
neoneye/loda-programs
11
94373
; A024537: a(n) = floor( a(n-1)/(sqrt(2) - 1) ), with a(0) = 1. ; Submitted by <NAME>(s3) ; 1,2,4,9,21,50,120,289,697,1682,4060,9801,23661,57122,137904,332929,803761,1940450,4684660,11309769,27304197,65918162,159140520,384199201,927538921,2239277042,5406093004,13051463049,31509019101,76069501250,183648021600,443365544449,1070379110497,2584123765442,6238626641380,15061377048201,36361380737781,87784138523762,211929657785304,511643454094369,1235216565974041,2982076586042450,7199369738058940,17380816062160329,41961001862379597,101302819786919522,244566641436218640,590436102659356801 lpb $0 sub $0,1 add $1,1 add $1,$3 mov $2,$3 add $3,$1 mov $1,$2 lpe mov $0,$3 add $0,1
src/firmware-tests/Platform/Lcd/States/EnableTrySetByteMode1/ShiftOutTest.asm
pete-restall/Cluck2Sesame-Prototype
1
161162
#include "Platform.inc" #include "FarCalls.inc" #include "Lcd.inc" #include "../../LcdStates.inc" #include "../../../ShiftRegister/ShiftOutMock.inc" #include "TestFixture.inc" radix decimal udata global initialShiftRegisterBuffer global expectedShiftOut1 global expectedShiftOut2 global expectedShiftOut3 initialShiftRegisterBuffer res 1 expectedShiftOut1 res 1 expectedShiftOut2 res 1 expectedShiftOut3 res 1 ShiftOutTest code global testArrange testArrange: fcall initialiseShiftOutMock fcall initialiseLcd banksel initialShiftRegisterBuffer movf initialShiftRegisterBuffer, W banksel shiftRegisterBuffer movwf shiftRegisterBuffer testAct: setLcdState LCD_STATE_ENABLE_TRYSETBYTEMODE1 fcall pollLcd testAssert: banksel calledShiftOutCount .assert "calledShiftOutCount == 3, 'Expected three calls to shiftOut().'" .assertShiftOut 1, expectedShiftOut1 .assertShiftOut 2, expectedShiftOut2 .assertShiftOut 3, expectedShiftOut3 return end
tools/scitools/conf/understand/ada/ada95/s-tasabo.ads
brucegua/moocos
1
25801
<reponame>brucegua/moocos ------------------------------------------------------------------------------ -- -- -- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . A B O R T I O N -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU Library General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. GNARL is distributed in the hope that it will be use- -- -- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- -- -- eral Library Public License for more details. You should have received -- -- a copy of the GNU Library General Public License along with GNARL; see -- -- file COPYING.LIB. If not, write to the Free Software Foundation, 675 -- -- Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives; -- Used for, Task_Primitives.Pre_Call_State with System.Tasking.Utilities; -- Used for, Utilities.ATCB_Ptr package System.Tasking.Abortion is procedure Abort_Tasks (Tasks : Task_List); -- Abort_Tasks is called to initiate abortion, however, the actual -- abortion is done by abortee by means of Abort_Handler procedure Change_Base_Priority (T : System.Tasking.Utilities.ATCB_Ptr); -- Change the base priority of T. -- Has to be called with T.Lock write locked. procedure Defer_Abortion; -- pragma Inline (Defer_Abortion); -- To allow breakpoints to be set. ??? procedure Undefer_Abortion; -- pragma Inline (Undefer_Abortion); -- To allow breakpoints to be set. end System.Tasking.Abortion;
libsrc/stdio/ansi/px4/f_ansi_dline.asm
teknoplop/z88dk
0
169434
; ; ANSI Video handling for the Epson PX4 ; By <NAME> - Nov 2014 ; ; Clean a text line ; ; in: A = text row number ; ; ; $Id: f_ansi_dline.asm,v 1.1 2015/11/05 16:08:04 stefano Exp $ ; PUBLIC ansi_del_line EXTERN base_graphics .ansi_del_line ld de,32*8 ld b,a ld hl,$e000 and a jr z,zline .lloop add hl,de djnz lloop .zline ld d,h ld e,l inc de ld (hl),0 ld bc,32*8 ldir ret
oeis/256/A256462.asm
neoneye/loda-programs
11
244092
; A256462: Double sum of the product of two binomials with even arguments. ; Submitted by <NAME> ; 1,14,238,4092,70070,1192516,20177164,339653880,5692584870,95050101300,1581953021220,26255495764680,434697697648188,7181635051211432,118422830335911640,1949458102569167344,32043155434056810246,525974795270875804308 mul $0,2 mov $1,$0 mul $0,2 bin $0,$1 add $1,1 mov $2,$0 div $2,$1 add $1,2 mul $0,$1 sub $2,2 sub $0,$2 div $0,2 sub $0,1
example/testForFail.asm
LayerXcom/gram
15
13224
<reponame>LayerXcom/gram STORE 0 r0 MOV r0 1 READ r1 0 ADD r0 r0 1 STORE r0 r1 CMPA r0 3 XOR r1 r2 5 STORE 1 r0 LOAD r2 0 MOV r3 5
Transynther/x86/_processed/AVXALIGN/_ht_zr_un_/i7-7700_9_0x48.log_21829_1597.asm
ljhsiun2/medusa
9
23354
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_normal_ht+0xe2d3, %rsi lea addresses_UC_ht+0x1a63, %rdi nop nop nop nop nop cmp %r15, %r15 mov $127, %rcx rep movsw dec %r15 lea addresses_normal_ht+0x17c43, %r13 nop nop dec %rdi mov (%r13), %r15d nop nop nop nop nop sub %r13, %r13 lea addresses_WC_ht+0xed03, %r14 nop inc %rdi movl $0x61626364, (%r14) nop nop nop xor %r13, %r13 lea addresses_WC_ht+0x1d643, %rsi lea addresses_normal_ht+0x1a043, %rdi and %r14, %r14 mov $18, %rcx rep movsb nop nop sub %r15, %r15 lea addresses_WT_ht+0x32c3, %r14 nop nop nop nop nop and $58813, %rsi movups (%r14), %xmm3 vpextrq $1, %xmm3, %r15 nop add %r15, %r15 lea addresses_WT_ht+0x16c03, %rdi nop nop nop nop inc %rsi mov (%rdi), %r14d nop nop and $50637, %rsi lea addresses_UC_ht+0xd043, %r13 nop nop sub %rsi, %rsi mov (%r13), %di nop nop nop lfence lea addresses_D_ht+0x92c3, %rsi lea addresses_UC_ht+0x19543, %rdi nop nop nop nop nop inc %r9 mov $48, %rcx rep movsq nop cmp %r15, %r15 lea addresses_WT_ht+0x8ce1, %r14 nop nop cmp %rdi, %rdi movw $0x6162, (%r14) nop nop nop nop and %r14, %r14 lea addresses_UC_ht+0xbe45, %r13 nop nop nop nop cmp $12068, %rcx mov (%r13), %esi nop cmp $28777, %r13 lea addresses_D_ht+0x160d3, %rsi nop nop nop nop add $24129, %r9 mov $0x6162636465666768, %rdi movq %rdi, %xmm6 and $0xffffffffffffffc0, %rsi vmovaps %ymm6, (%rsi) cmp $28591, %r15 lea addresses_UC_ht+0x1e702, %r9 nop nop nop nop nop and $28627, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm0 vmovups %ymm0, (%r9) nop nop nop dec %r9 pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r15 push %rax push %rbp push %rbx // Faulty Load lea addresses_RW+0x1a843, %rbp add %r15, %r15 movntdqa (%rbp), %xmm4 vpextrq $1, %xmm4, %rax lea oracles, %rbx and $0xff, %rax shlq $12, %rax mov (%rbx,%rax,1), %rax pop %rbx pop %rbp pop %rax pop %r15 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': True, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 3, 'size': 32, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} {'08': 2, '44': 11872, '00': 913, '49': 1433, '48': 564, '46': 7045} 49 44 46 44 46 44 46 44 46 44 44 44 46 00 44 48 44 46 44 46 44 44 44 46 49 44 00 44 48 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 00 44 49 44 00 44 00 44 48 44 46 44 46 44 46 44 44 44 46 49 44 49 44 46 44 46 49 44 48 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 46 00 44 49 44 48 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 44 49 44 48 44 46 44 46 44 46 00 44 49 44 00 44 46 44 46 44 46 44 46 44 44 49 44 48 44 46 44 44 46 44 46 00 44 49 44 46 44 46 44 46 00 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 46 00 44 49 44 46 44 46 44 46 44 46 44 44 44 44 49 44 48 44 46 44 46 44 46 44 44 44 46 49 44 48 44 46 44 44 44 44 49 44 46 44 46 44 44 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 49 44 00 44 46 44 46 44 46 44 44 44 44 49 44 00 44 46 44 46 44 46 44 44 44 44 49 44 49 44 46 44 46 44 46 44 44 44 44 44 46 44 44 49 44 48 44 46 44 46 44 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 46 44 44 49 44 48 44 46 44 46 44 44 44 46 49 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 44 46 44 44 49 44 48 44 46 44 46 44 46 44 46 44 44 44 44 49 44 48 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 44 49 44 46 44 46 44 44 44 44 44 44 46 44 46 44 46 44 46 44 46 44 44 49 44 48 44 46 44 46 44 46 00 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 44 49 44 46 44 46 44 46 44 44 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 00 44 49 44 46 44 46 44 46 44 44 46 44 46 44 44 44 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 44 49 44 48 44 46 44 46 44 46 44 44 49 44 00 49 44 48 44 46 44 46 44 46 44 46 00 44 49 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 46 44 46 44 44 44 44 44 44 49 44 49 44 48 44 46 44 46 48 44 46 44 46 44 44 44 44 49 44 49 44 46 44 44 44 44 44 46 44 44 49 44 48 44 46 44 46 44 46 44 46 49 44 48 44 46 44 46 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 49 44 00 44 46 44 46 00 44 46 44 46 44 46 44 44 44 44 00 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 44 44 44 44 44 49 44 48 44 46 44 46 44 46 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 44 46 49 44 00 44 46 44 46 44 46 44 46 44 46 44 44 49 44 00 44 46 44 46 44 46 44 44 49 44 48 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 44 49 44 46 44 46 44 46 44 46 44 46 44 44 00 44 46 44 46 44 46 44 46 44 46 00 44 49 44 46 00 44 49 44 46 44 46 44 44 44 44 49 44 48 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 46 44 44 44 44 49 44 48 44 46 44 46 44 46 44 46 44 46 44 */
oeis/008/A008415.asm
neoneye/loda-programs
11
99295
<filename>oeis/008/A008415.asm ; A008415: Coordination sequence for 7-dimensional cubic lattice. ; Submitted by <NAME> ; 1,14,98,462,1666,4942,12642,28814,59906,115598,209762,361550,596610,948430,1459810,2184462,3188738,4553486,6376034,8772302,11879042,15856206,20889442,27192718,35011074,44623502,56345954,70534478,87588482,107954126,132127842,160659982,194158594,233293326,278799458,331482062,392220290,461971790,541777250,632765070,736156162,853268878,985524066,1134450254,1301688962,1489000142,1698267746,1931505422,2190862338,2478629134,2797244002,3149298894,3537545858,3964903502,4434463586,4949497742,5513464322 mov $1,$0 bin $1,$0 add $0,1 lpb $0 sub $0,$1 add $1,$3 mov $2,$0 max $2,0 seq $2,1848 ; Crystal ball sequence for 6-dimensional cubic lattice. add $3,$2 lpe mov $0,$3
src/FLA/Data/Vec+/Base.agda
turion/functional-linear-algebra
21
2680
<filename>src/FLA/Data/Vec+/Base.agda {-# OPTIONS --without-K --safe #-} open import Level using (Level) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_) open import Data.Nat using (ℕ; suc; zero) open import Data.Empty using (⊥) open import Data.Vec using (Vec) renaming ([] to []ⱽ; _∷_ to _∷ⱽ_) module FLA.Data.Vec+.Base where private variable ℓ : Level A : Set ℓ n : ℕ -- TODO: Can this be replaced with something like the List⁺ definition so that -- the proofs from Vec can be transferred? This definition is convenient because -- the size is correct (it is not n - 1). data Vec⁺ (A : Set ℓ) : ℕ → Set ℓ where [_] : A → Vec⁺ A 1 _∷_ : ∀ {n} (x : A) (xs : Vec⁺ A n) → Vec⁺ A (suc n) infixr 5 _∷_ -- Want to prove that is it not possible to construct an empty vector emptyVecImpossible : Vec⁺ A 0 → ⊥ emptyVecImpossible = λ () Vec⁺→Vec : Vec⁺ A n → Vec A n Vec⁺→Vec [ v ] = v ∷ⱽ []ⱽ Vec⁺→Vec (v ∷ vs⁺) = v ∷ⱽ Vec⁺→Vec vs⁺ Vec⁺→n≢0 : Vec⁺ A n → n ≢ 0 Vec⁺→n≢0 {ℓ} {A} {suc n} v = suc≢0 where suc≢0 : {n : ℕ} → suc n ≢ 0 suc≢0 {zero} () suc≢0 {suc n} = λ () -- Closer maybe but still buggered -- Vec→Vec⁺ : ∀ {ℓ} → {A : Set ℓ} {n : ℕ} → (n ≢ 0) → Vec A n → Vec⁺ A n -- Vec→Vec⁺ {ℓ} {A} {0} p []ⱽ = ⊥-elim (p refl) -- Vec→Vec⁺ {ℓ} {A} {1} p (x ∷ⱽ []ⱽ) = [ x ] -- Vec→Vec⁺ {ℓ} {A} {suc n} p (x ∷ⱽ xs) = x ∷ (Vec→Vec⁺ {!!} xs)
libsrc/_DEVELOPMENT/target/yaz180/device/asci/z180/__asci1_data_Tx.asm
jpoikela/z88dk
640
92309
INCLUDE "config_private.inc" SECTION data_driver PUBLIC asci1TxCount, asci1TxIn, asci1TxOut, asci1TxLock asci1TxCount: defb 0 ; Space for Tx Buffer Management asci1TxIn: defw asci1TxBuffer ; non-zero item in bss since it's initialized anyway asci1TxOut: defw asci1TxBuffer ; non-zero item in bss since it's initialized anyway asci1TxLock: defb $FE ; lock flag for Tx exclusion IF __ASCI1_TX_SIZE = 256 SECTION data_align_256 ENDIF IF __ASCI1_TX_SIZE = 128 SECTION data_align_128 ENDIF IF __ASCI1_TX_SIZE = 64 SECTION data_align_64 ENDIF IF __ASCI1_TX_SIZE = 32 SECTION data_align_32 ENDIF IF __ASCI1_TX_SIZE = 16 SECTION data_align_16 ENDIF IF __ASCI1_TX_SIZE = 8 SECTION data_align_8 ENDIF IF __ASCI1_TX_SIZE%8 != 0 ERROR "__ASCI1_TX_SIZE not 2^n" ENDIF PUBLIC asci1TxBuffer asci1TxBuffer: defs __ASCI1_TX_SIZE ; Space for the Tx Buffer ; pad to next boundary IF __ASCI1_TX_SIZE = 256 ALIGN 256 ENDIF IF __ASCI1_TX_SIZE = 128 ALIGN 128 ENDIF IF __ASCI1_TX_SIZE = 64 ALIGN 64 ENDIF IF __ASCI1_TX_SIZE = 32 ALIGN 32 ENDIF IF __ASCI1_TX_SIZE = 16 ALIGN 16 ENDIF IF __ASCI1_TX_SIZE = 8 ALIGN 8 ENDIF
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_251.asm
ljhsiun2/medusa
9
9454
<filename>Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_251.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x58fa, %r14 nop nop nop xor %rdi, %rdi movb (%r14), %r12b nop nop nop inc %r10 lea addresses_WC_ht+0x7ec6, %rbx nop and $33842, %rcx movw $0x6162, (%rbx) nop nop nop nop xor %r10, %r10 lea addresses_WT_ht+0x134c6, %r14 nop nop nop sub $58896, %rbx mov $0x6162636465666768, %r12 movq %r12, %xmm7 movups %xmm7, (%r14) nop nop nop nop nop xor %r14, %r14 lea addresses_WC_ht+0x946, %rcx nop xor %r12, %r12 mov (%rcx), %r10d nop nop nop nop and $30393, %rdi lea addresses_A_ht+0x1792, %r12 nop nop add %rcx, %rcx mov (%r12), %r10d nop nop nop cmp %r14, %r14 lea addresses_WT_ht+0x173f6, %rsi lea addresses_WT_ht+0x1ca46, %rdi nop nop nop dec %r12 mov $101, %rcx rep movsb nop nop nop nop xor %rax, %rax lea addresses_normal_ht+0xe48d, %rbx nop nop xor %rdi, %rdi movb $0x61, (%rbx) nop nop nop nop and $25864, %r10 lea addresses_WC_ht+0x12646, %rsi lea addresses_WT_ht+0x8a6, %rdi clflush (%rdi) xor $54120, %rbx mov $95, %rcx rep movsb nop nop nop nop dec %rbx lea addresses_WT_ht+0xbc86, %rax nop nop nop nop nop inc %rdi movl $0x61626364, (%rax) nop nop cmp %r14, %r14 lea addresses_D_ht+0xc146, %rsi lea addresses_D_ht+0xf946, %rdi sub %rbx, %rbx mov $17, %rcx rep movsl nop cmp $64389, %rcx lea addresses_WT_ht+0xd77a, %rdi nop nop nop add %r12, %r12 movups (%rdi), %xmm2 vpextrq $0, %xmm2, %r10 cmp %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %r15 push %rcx push %rdx // Load lea addresses_UC+0x1df39, %r10 nop nop nop nop nop add $53140, %r13 movb (%r10), %r11b nop add %r11, %r11 // Store lea addresses_WC+0x16d46, %r10 clflush (%r10) and $39539, %r14 mov $0x5152535455565758, %r15 movq %r15, (%r10) nop nop and %r15, %r15 // Faulty Load lea addresses_WC+0x17546, %r11 nop inc %rcx movups (%r11), %xmm4 vpextrq $1, %xmm4, %r14 lea oracles, %rcx and $0xff, %r14 shlq $12, %r14 mov (%rcx,%r14,1), %r14 pop %rdx pop %rcx pop %r15 pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'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 */
src/CheckROMs.asm
SerErris/amstrad-diagnostics
60
102568
<reponame>SerErris/amstrad-diagnostics MODULE ROMTEST @CheckROMs: call ROMSetUpScreen @CheckROMsWithoutTitle: ld a, TESTRESULT_UNTESTED ld (TestResultTableLowerROM), a ld (TestResultTableUpperROM), a call CheckLowerROM call NewLine call CheckUpperROMs call NewLine call SetDefaultColors ld hl,TxtAnyKeyMainMenu call PrintString ret ROMSetUpScreen: ld d, 0 call ClearScreen ld a, 4 call SetBorderColor ld hl,TxtROMTitle ld d,(ScreenCharsWidth - TxtTitleLen - TxtROMTitleLen)/2 call PrintTitleBanner ld hl,#0002 ld (TxtCoords),hl call SetDefaultColors ret TxtROMTitle: db ' - ROM TEST',0 TxtROMTitleLen EQU $-TxtROMTitle-1 TxtCheckingLowerROM: db 'CHECKING LOWER ROM...',0 TxtLowerROM: db 'LOWER ROM: ',0 TxtDetectingUpperROMs: db 'DETECTING UPPER ROMS...',0 TxtColon: db ': ',0 TxtDashes: db '----',0 TxtUnknownROM: db 'UNKNOWN: ',0 TxtAmsDiagROM: db 'AMSTRAD DIAG (THIS ROM)',0 TxtCantAccessLowerROM: db "CAN'T ACCESS SYSTEM LOWER ROM",0 ////////////////////////////////////// CheckLowerROM: IFDEF TRY_UNPAGING_LOW_ROM call CanAccessLowROM jr nz, .continueLowerROM ;; Remember failure ld a, TESTRESULT_NOTAVAILABLE ld (TestResultTableLowerROM), a ld hl,TxtCantAccessLowerROM call PrintString call NewLine ret ENDIF .continueLowerROM: ld hl,TxtCheckingLowerROM call PrintString call NewLine ld hl,TxtLowerROM call PrintString call CRCLowerRom push hl call GetROMAddrFromCRC or a jr z, .unknownROM call PrintROMName ;; Remember success ld a, TESTRESULT_PASSED ld (TestResultTableLowerROM), a .finishROM: ld hl, txt_x inc (hl) pop hl call PrintCRC call NewLine ret .unknownROM: ;; Remember failure ld a, TESTRESULT_FAILED ld (TestResultTableLowerROM), a call SetErrorColors ld hl,TxtUnknownROM call PrintString jr .finishROM ////////////////////////////////////// CheckUpperROMs: ld a, TESTRESULT_PASSED ld (TestResultTableUpperROM), a call SetDefaultColors ld hl, TxtDetectingUpperROMs call PrintString call NewLine ld d, 0 ;; D = ROM number .romLoop: call SetDefaultColors push de IFDEF UpperROMBuild ld a, (UpperROMConfig) cp d jr z, .thisROM ENDIF call CheckUpperROM or a ;; A = result jr nz, .nextROM ;; Failed, but only fail the test if ROM 0 fails, the others we can ignore pop de ;; D = ROM number push de ld a, d or a jr nz, .nextROM ;; It was ROM 0 and it failed, so mark it as failed ld a, TESTRESULT_FAILED ld (TestResultTableUpperROM), a .nextROM: pop de inc d ld a,d cp #10 jr nz, .romLoop ret IFDEF UpperROMBuild .thisROM: ld hl,TxtROM call PrintString ld a,d call PrintAHex ld hl,TxtColon call PrintString ld hl,TxtAmsDiagROM call PrintString call NewLine jr .nextROM ENDIF ;; IN D = ROM to check ;; OUT A = 1 known, 0 unknown CheckUpperROM: push de ld hl,TxtROM call PrintString ld a,d call PrintAHex ld hl,TxtColon call PrintString pop de ld a,d ; Always do the 0 ROM or a jr z,.doIt call GetUpperROMType ; Skip any roms of type #80 (because that's the BASIC ROM repeated in other places) cp #80 jr nz, .doIt ld hl, TxtDashes call PrintString call NewLine ld a, 1 ret .doIt: push de ; Save ROM index for later ld a, d call CRCUpperRom pop de push hl ; Save CRC push de ; Save ROM index call GetROMAddrFromCRC or a jr z, .unknownROM call PrintROMName ld a, 1 pop de .finishROM: ld hl, txt_x inc (hl) pop hl push af ;; Preserve A, which is the return value call PrintCRC call NewLine pop af ret .unknownROM: call SetErrorColors ld hl,TxtUnknownROM call PrintString pop de ld a,d ld de, ROMStringBuffer call GetROMString ld hl, ROMStringBuffer call ConvertToUpperCase7BitEnding ld hl, ROMStringBuffer call PrintString7BitEnding ld a,0 ;;push af jr .finishROM ; IN HL = CRC PrintCRC: ld a,'(' call PrintChar ld a,h call PrintAHex ld a,l call PrintAHex ld a,')' call PrintChar ret ; IN HL = CRC ; OUT DE = ROM index and A = 1 or A = 0 if unknown GetROMAddrFromCRC: ld b, 0 ld ix, ROMInfoTable .loop: ld e, (ix) ld d, (ix+1) ld a, l cp e jr nz, .next ld a, h cp d jr nz, .next ld de, ix ld a, 1 ret .next: inc ix inc ix inc ix inc ix inc b ld a, b cp ROMCount jr nz, .loop ld a, 0 ret ; IN DE = ROM address in table PrintROMName: ld ix, de ld l, (ix+2) ld h, (ix+3) call PrintString ret ; IN HL = String ConvertToUpperCase7BitEnding: ld a, (hl) and %01111111 cp #61 jr c, .skipChar ld a, (hl) sub #20 ld (hl), a .skipChar: ld a, (hl) inc hl bit 7, a jr z, ConvertToUpperCase7BitEnding ret INCLUDE "ROMTable.asm" ENDMODULE
Numbers/BinaryNaturals/Definition.agda
Smaug123/agdaproofs
4
13866
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Lists.Lists open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Semirings.Definition open import Orders.Total.Definition module Numbers.BinaryNaturals.Definition where data Bit : Set where zero : Bit one : Bit BinNat : Set BinNat = List Bit ::Inj : {xs ys : BinNat} {i : Bit} → i :: xs ≡ i :: ys → xs ≡ ys ::Inj {i = zero} refl = refl ::Inj {i = one} refl = refl nonEmptyNotEmpty : {a : _} {A : Set a} {l1 : List A} {i : A} → i :: l1 ≡ [] → False nonEmptyNotEmpty {l1 = l1} {i} () -- TODO - maybe we should do the floating-point style of assuming there's a leading bit and not storing it. -- That way, everything is already canonical. canonical : BinNat → BinNat canonical [] = [] canonical (zero :: n) with canonical n canonical (zero :: n) | [] = [] canonical (zero :: n) | x :: bl = zero :: x :: bl canonical (one :: n) = one :: canonical n Canonicalised : Set Canonicalised = Sg BinNat (λ i → canonical i ≡ i) binNatToN : BinNat → ℕ binNatToN [] = 0 binNatToN (zero :: b) = 2 *N binNatToN b binNatToN (one :: b) = 1 +N (2 *N binNatToN b) incr : BinNat → BinNat incr [] = one :: [] incr (zero :: n) = one :: n incr (one :: n) = zero :: (incr n) incrNonzero : (x : BinNat) → canonical (incr x) ≡ [] → False incrPreservesCanonical : (x : BinNat) → (canonical x ≡ x) → canonical (incr x) ≡ incr x incrPreservesCanonical [] pr = refl incrPreservesCanonical (zero :: xs) pr with canonical xs incrPreservesCanonical (zero :: xs) pr | x :: t = applyEquality (one ::_) (::Inj pr) incrPreservesCanonical (one :: xs) pr with inspect (canonical (incr xs)) incrPreservesCanonical (one :: xs) pr | [] with≡ x = exFalso (incrNonzero xs x) incrPreservesCanonical (one :: xs) pr | (x₁ :: y) with≡ x rewrite x = applyEquality (zero ::_) (transitivity (equalityCommutative x) (incrPreservesCanonical xs (::Inj pr))) incrPreservesCanonical' : (x : BinNat) → canonical (incr x) ≡ incr (canonical x) incrC : Canonicalised → Canonicalised incrC (a , b) = incr a , incrPreservesCanonical a b NToBinNat : ℕ → BinNat NToBinNat zero = [] NToBinNat (succ n) with NToBinNat n NToBinNat (succ n) | t = incr t NToBinNatC : ℕ → Canonicalised NToBinNatC zero = [] , refl NToBinNatC (succ n) = incrC (NToBinNatC n) incrInj : {x y : BinNat} → incr x ≡ incr y → canonical x ≡ canonical y incrNonzero' : (x : BinNat) → (incr x) ≡ [] → False incrNonzero' (zero :: xs) () incrNonzero' (one :: xs) () canonicalRespectsIncr' : {x y : BinNat} → canonical (incr x) ≡ canonical (incr y) → canonical x ≡ canonical y binNatToNSucc : (n : BinNat) → binNatToN (incr n) ≡ succ (binNatToN n) NToBinNatSucc : (n : ℕ) → incr (NToBinNat n) ≡ NToBinNat (succ n) binNatToNZero : (x : BinNat) → binNatToN x ≡ 0 → canonical x ≡ [] binNatToNZero' : (x : BinNat) → canonical x ≡ [] → binNatToN x ≡ 0 NToBinNatZero : (n : ℕ) → NToBinNat n ≡ [] → n ≡ 0 NToBinNatZero zero pr = refl NToBinNatZero (succ n) pr with NToBinNat n NToBinNatZero (succ n) pr | zero :: bl = exFalso (nonEmptyNotEmpty pr) NToBinNatZero (succ n) pr | one :: bl = exFalso (nonEmptyNotEmpty pr) canonicalAscends : {i : Bit} → (a : BinNat) → 0 <N binNatToN a → i :: canonical a ≡ canonical (i :: a) canonicalAscends' : {i : Bit} → (a : BinNat) → (canonical a ≡ [] → False) → i :: canonical a ≡ canonical (i :: a) canonicalAscends' {i} a pr = canonicalAscends {i} a (t a pr) where t : (a : BinNat) → (canonical a ≡ [] → False) → 0 <N binNatToN a t a pr with TotalOrder.totality ℕTotalOrder 0 (binNatToN a) t a pr | inl (inl x) = x t a pr | inr x = exFalso (pr (binNatToNZero a (equalityCommutative x))) canonicalIdempotent : (a : BinNat) → canonical a ≡ canonical (canonical a) canonicalIdempotent [] = refl canonicalIdempotent (zero :: a) with inspect (canonical a) canonicalIdempotent (zero :: a) | [] with≡ y rewrite y = refl canonicalIdempotent (zero :: a) | (x :: bl) with≡ y = transitivity (equalityCommutative (canonicalAscends' {zero} a λ p → contr p y)) (transitivity (applyEquality (zero ::_) (canonicalIdempotent a)) (equalityCommutative v)) where contr : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False contr {l1 = []} p1 () contr {l1 = x :: l1} () p2 u : canonical (canonical (zero :: a)) ≡ canonical (zero :: canonical a) u = applyEquality canonical (equalityCommutative (canonicalAscends' {zero} a λ p → contr p y)) v : canonical (canonical (zero :: a)) ≡ zero :: canonical (canonical a) v = transitivity u (equalityCommutative (canonicalAscends' {zero} (canonical a) λ p → contr (transitivity (canonicalIdempotent a) p) y)) canonicalIdempotent (one :: a) rewrite equalityCommutative (canonicalIdempotent a) = refl canonicalAscends'' : {i : Bit} → (a : BinNat) → canonical (i :: canonical a) ≡ canonical (i :: a) binNatToNInj : (x y : BinNat) → binNatToN x ≡ binNatToN y → canonical x ≡ canonical y NToBinNatInj : (x y : ℕ) → canonical (NToBinNat x) ≡ canonical (NToBinNat y) → x ≡ y NToBinNatIsCanonical : (x : ℕ) → NToBinNat x ≡ canonical (NToBinNat x) NToBinNatIsCanonical zero = refl NToBinNatIsCanonical (succ x) with NToBinNatC x NToBinNatIsCanonical (succ x) | a , b = equalityCommutative (incrPreservesCanonical (NToBinNat x) (equalityCommutative (NToBinNatIsCanonical x))) contr' : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False contr' {l1 = []} p1 () contr' {l1 = x :: l1} () p2 binNatToNIsCanonical : (x : BinNat) → binNatToN (canonical x) ≡ binNatToN x binNatToNIsCanonical [] = refl binNatToNIsCanonical (zero :: x) with inspect (canonical x) binNatToNIsCanonical (zero :: x) | [] with≡ t rewrite t | binNatToNZero' x t = refl binNatToNIsCanonical (zero :: x) | (x₁ :: bl) with≡ t rewrite (equalityCommutative (canonicalAscends' {zero} x λ p → contr' p t)) | binNatToNIsCanonical x = refl binNatToNIsCanonical (one :: x) rewrite binNatToNIsCanonical x = refl -- The following two theorems demonstrate that Canonicalised is isomorphic to ℕ nToN : (x : ℕ) → binNatToN (NToBinNat x) ≡ x binToBin : (x : BinNat) → NToBinNat (binNatToN x) ≡ canonical x binToBin x = transitivity (NToBinNatIsCanonical (binNatToN x)) (binNatToNInj (NToBinNat (binNatToN x)) x (nToN (binNatToN x))) doubleIsBitShift' : (a : ℕ) → NToBinNat (2 *N succ a) ≡ zero :: NToBinNat (succ a) doubleIsBitShift' zero = refl doubleIsBitShift' (succ a) with doubleIsBitShift' a ... | bl rewrite Semiring.commutative ℕSemiring a (succ (succ (a +N 0))) | Semiring.commutative ℕSemiring (succ (a +N 0)) a | Semiring.commutative ℕSemiring a (succ (a +N 0)) | Semiring.commutative ℕSemiring (a +N 0) a | bl = refl doubleIsBitShift : (a : ℕ) → (0 <N a) → NToBinNat (2 *N a) ≡ zero :: NToBinNat a doubleIsBitShift zero () doubleIsBitShift (succ a) _ = doubleIsBitShift' a canonicalDescends : {a : Bit} (as : BinNat) → (prA : a :: as ≡ canonical (a :: as)) → as ≡ canonical as canonicalDescends {zero} as pr with canonical as canonicalDescends {zero} as pr | x :: bl = ::Inj pr canonicalDescends {one} as pr = ::Inj pr --- Proofs parity : (a b : ℕ) → succ (2 *N a) ≡ 2 *N b → False doubleInj : (a b : ℕ) → (2 *N a) ≡ (2 *N b) → a ≡ b incrNonzeroTwice : (x : BinNat) → canonical (incr (incr x)) ≡ one :: [] → False incrNonzeroTwice (zero :: xs) pr with canonical (incr xs) incrNonzeroTwice (zero :: xs) () | [] incrNonzeroTwice (zero :: xs) () | x :: bl incrNonzeroTwice (one :: xs) pr = exFalso (incrNonzero xs (::Inj pr)) canonicalRespectsIncr' {[]} {[]} pr = refl canonicalRespectsIncr' {[]} {zero :: y} pr with canonical y canonicalRespectsIncr' {[]} {zero :: y} pr | [] = refl canonicalRespectsIncr' {[]} {one :: y} pr with canonical (incr y) canonicalRespectsIncr' {[]} {one :: y} () | [] canonicalRespectsIncr' {[]} {one :: y} () | x :: bl canonicalRespectsIncr' {zero :: xs} {y} pr with canonical xs canonicalRespectsIncr' {zero :: xs} {[]} pr | [] = refl canonicalRespectsIncr' {zero :: xs} {zero :: y} pr | [] with canonical y canonicalRespectsIncr' {zero :: xs} {zero :: y} pr | [] | [] = refl canonicalRespectsIncr' {zero :: xs} {one :: y} pr | [] with canonical (incr y) canonicalRespectsIncr' {zero :: xs} {one :: y} () | [] | [] canonicalRespectsIncr' {zero :: xs} {one :: y} () | [] | x :: bl canonicalRespectsIncr' {zero :: xs} {zero :: ys} pr | x :: bl with canonical ys canonicalRespectsIncr' {zero :: xs} {zero :: ys} pr | x :: bl | x₁ :: th = applyEquality (zero ::_) (::Inj pr) canonicalRespectsIncr' {zero :: xs} {one :: ys} pr | x :: bl with canonical (incr ys) canonicalRespectsIncr' {zero :: xs} {one :: ys} () | x :: bl | [] canonicalRespectsIncr' {zero :: xs} {one :: ys} () | x :: bl | x₁ :: th canonicalRespectsIncr' {one :: xs} {[]} pr with canonical (incr xs) canonicalRespectsIncr' {one :: xs} {[]} () | [] canonicalRespectsIncr' {one :: xs} {[]} () | x :: bl canonicalRespectsIncr' {one :: xs} {zero :: ys} pr with canonical ys canonicalRespectsIncr' {one :: xs} {zero :: ys} pr | [] with canonical (incr xs) canonicalRespectsIncr' {one :: xs} {zero :: ys} () | [] | [] canonicalRespectsIncr' {one :: xs} {zero :: ys} () | [] | x :: t canonicalRespectsIncr' {one :: xs} {zero :: ys} pr | x :: bl with canonical (incr xs) canonicalRespectsIncr' {one :: xs} {zero :: ys} () | x :: bl | [] canonicalRespectsIncr' {one :: xs} {zero :: ys} () | x :: bl | x₁ :: t canonicalRespectsIncr' {one :: xs} {one :: ys} pr with inspect (canonical (incr xs)) canonicalRespectsIncr' {one :: xs} {one :: ys} pr | [] with≡ x = exFalso (incrNonzero xs x) canonicalRespectsIncr' {one :: xs} {one :: ys} pr | (x+1 :: x+1s) with≡ bad rewrite bad = applyEquality (one ::_) ans where ans : canonical xs ≡ canonical ys ans with inspect (canonical (incr ys)) ans | [] with≡ x = exFalso (incrNonzero ys x) ans | (x₁ :: y) with≡ x rewrite x = canonicalRespectsIncr' {xs} {ys} (transitivity bad (transitivity (::Inj pr) (equalityCommutative x))) binNatToNInj[] : (y : BinNat) → 0 ≡ binNatToN y → [] ≡ canonical y binNatToNInj[] [] pr = refl binNatToNInj[] (zero :: y) pr with productZeroImpliesOperandZero {2} {binNatToN y} (equalityCommutative pr) binNatToNInj[] (zero :: y) pr | inr x with inspect (canonical y) binNatToNInj[] (zero :: y) pr | inr x | [] with≡ canYPr rewrite canYPr = refl binNatToNInj[] (zero :: ys) pr | inr x | (y :: canY) with≡ canYPr with binNatToNZero ys x ... | r with canonical ys binNatToNInj[] (zero :: ys) pr | inr x | (y :: canY) with≡ canYPr | r | [] = refl binNatToNInj[] (zero :: ys) pr | inr x | (y :: canY) with≡ canYPr | () | x₁ :: t binNatToNInj [] y pr = binNatToNInj[] y pr binNatToNInj (zero :: xs) [] pr = equalityCommutative (binNatToNInj[] (zero :: xs) (equalityCommutative pr)) binNatToNInj (zero :: xs) (zero :: ys) pr with doubleInj (binNatToN xs) (binNatToN ys) pr ... | x=y with binNatToNInj xs ys x=y ... | t with canonical xs binNatToNInj (zero :: xs) (zero :: ys) pr | x=y | t | [] with canonical ys binNatToNInj (zero :: xs) (zero :: ys) pr | x=y | t | [] | [] = refl binNatToNInj (zero :: xs) (zero :: ys) pr | x=y | t | x :: cxs with canonical ys binNatToNInj (zero :: xs) (zero :: ys) pr | x=y | t | x :: cxs | x₁ :: cys = applyEquality (zero ::_) t binNatToNInj (zero :: xs) (one :: ys) pr = exFalso (parity (binNatToN ys) (binNatToN xs) (equalityCommutative pr)) binNatToNInj (one :: xs) (zero :: ys) pr = exFalso (parity (binNatToN xs) (binNatToN ys) pr) binNatToNInj (one :: xs) (one :: ys) pr = applyEquality (one ::_) (binNatToNInj xs ys (doubleInj (binNatToN xs) (binNatToN ys) (succInjective pr))) NToBinNatInj zero zero pr = refl NToBinNatInj zero (succ y) pr with NToBinNat y NToBinNatInj zero (succ y) pr | bl = exFalso (incrNonzero bl (equalityCommutative pr)) NToBinNatInj (succ x) zero pr with NToBinNat x ... | bl = exFalso (incrNonzero bl pr) NToBinNatInj (succ x) (succ y) pr with inspect (NToBinNat x) NToBinNatInj (succ zero) (succ zero) pr | [] with≡ nToBinXPr = refl NToBinNatInj (succ zero) (succ (succ y)) pr | [] with≡ nToBinXPr with NToBinNat y NToBinNatInj (succ zero) (succ (succ y)) pr | [] with≡ nToBinXPr | y' = exFalso (incrNonzeroTwice y' (equalityCommutative pr)) NToBinNatInj (succ (succ x)) (succ y) pr | [] with≡ nToBinXPr with NToBinNat x NToBinNatInj (succ (succ x)) (succ y) pr | [] with≡ nToBinXPr | t = exFalso (incrNonzero' t nToBinXPr) NToBinNatInj (succ x) (succ y) pr | (x₁ :: nToBinX) with≡ nToBinXPr with NToBinNatInj x y (canonicalRespectsIncr' {NToBinNat x} {NToBinNat y} pr) NToBinNatInj (succ x) (succ .x) pr | (x₁ :: nToBinX) with≡ nToBinXPr | refl = refl incrInj {[]} {[]} pr = refl incrInj {[]} {zero :: ys} pr rewrite equalityCommutative (::Inj pr) = refl incrInj {zero :: xs} {[]} pr rewrite ::Inj pr = refl incrInj {zero :: xs} {zero :: .xs} refl = refl incrInj {one :: xs} {one :: ys} pr = applyEquality (one ::_) (incrInj {xs} {ys} (l (incr xs) (incr ys) pr)) where l : (a : BinNat) → (b : BinNat) → zero :: a ≡ zero :: b → a ≡ b l a .a refl = refl doubleInj zero zero pr = refl doubleInj (succ a) (succ b) pr = applyEquality succ (doubleInj a b u) where t : a +N a ≡ b +N b t rewrite Semiring.commutative ℕSemiring (succ a) 0 | Semiring.commutative ℕSemiring (succ b) 0 | Semiring.commutative ℕSemiring a (succ a) | Semiring.commutative ℕSemiring b (succ b) = succInjective (succInjective pr) u : a +N (a +N zero) ≡ b +N (b +N zero) u rewrite Semiring.commutative ℕSemiring a 0 | Semiring.commutative ℕSemiring b 0 = t binNatToNZero [] pr = refl binNatToNZero (zero :: xs) pr with inspect (canonical xs) binNatToNZero (zero :: xs) pr | [] with≡ x rewrite x = refl binNatToNZero (zero :: xs) pr | (x₁ :: y) with≡ x with productZeroImpliesOperandZero {2} {binNatToN xs} pr binNatToNZero (zero :: xs) pr | (x₁ :: y) with≡ x | inr pr' with binNatToNZero xs pr' ... | bl with canonical xs binNatToNZero (zero :: xs) pr | (x₁ :: y) with≡ x | inr pr' | bl | [] = refl binNatToNZero (zero :: xs) pr | (x₁ :: y) with≡ x | inr pr' | () | x₂ :: t binNatToNSucc [] = refl binNatToNSucc (zero :: n) = refl binNatToNSucc (one :: n) rewrite Semiring.commutative ℕSemiring (binNatToN n) zero | Semiring.commutative ℕSemiring (binNatToN (incr n)) 0 | binNatToNSucc n = applyEquality succ (Semiring.commutative ℕSemiring (binNatToN n) (succ (binNatToN n))) incrNonzero (one :: xs) pr with inspect (canonical (incr xs)) incrNonzero (one :: xs) pr | [] with≡ x = incrNonzero xs x incrNonzero (one :: xs) pr | (y :: ys) with≡ x with canonical (incr xs) incrNonzero (one :: xs) pr | (y :: ys) with≡ () | [] incrNonzero (one :: xs) () | (.x₁ :: .th) with≡ refl | x₁ :: th nToN zero = refl nToN (succ x) with inspect (NToBinNat x) nToN (succ x) | [] with≡ pr = ans where t : x ≡ zero t = NToBinNatInj x 0 (applyEquality canonical pr) ans : binNatToN (incr (NToBinNat x)) ≡ succ x ans rewrite t | pr = refl nToN (succ x) | (bit :: xs) with≡ pr = transitivity (binNatToNSucc (NToBinNat x)) (applyEquality succ (nToN x)) parity zero (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) = bad pr where bad : (1 ≡ succ (succ ((b +N 0) +N b))) → False bad () parity (succ a) (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) | Semiring.commutative ℕSemiring a (succ (a +N 0)) | Semiring.commutative ℕSemiring (a +N 0) a | Semiring.commutative ℕSemiring (b +N 0) b = parity a b (succInjective (succInjective pr)) binNatToNZero' [] pr = refl binNatToNZero' (zero :: xs) pr with inspect (canonical xs) binNatToNZero' (zero :: xs) pr | [] with≡ p2 = ans where t : binNatToN xs ≡ 0 t = binNatToNZero' xs p2 ans : 2 *N binNatToN xs ≡ 0 ans rewrite t = refl binNatToNZero' (zero :: xs) pr | (y :: ys) with≡ p rewrite p = exFalso (bad pr) where bad : zero :: y :: ys ≡ [] → False bad () binNatToNZero' (one :: xs) () canonicalAscends {zero} a 0<a with inspect (canonical a) canonicalAscends {zero} (zero :: a) 0<a | [] with≡ x = exFalso (contr'' (binNatToN a) t v) where u : binNatToN (zero :: a) ≡ 0 u = binNatToNZero' (zero :: a) x v : binNatToN a ≡ 0 v with inspect (binNatToN a) v | zero with≡ x = x v | succ a' with≡ x with inspect (binNatToN (zero :: a)) v | succ a' with≡ x | zero with≡ pr2 rewrite pr2 = exFalso (TotalOrder.irreflexive ℕTotalOrder 0<a) v | succ a' with≡ x | succ y with≡ pr2 rewrite u = exFalso (TotalOrder.irreflexive ℕTotalOrder 0<a) t : 0 <N binNatToN a t with binNatToN a t | succ bl rewrite Semiring.commutative ℕSemiring (succ bl) 0 = succIsPositive bl contr'' : (x : ℕ) → (0 <N x) → (x ≡ 0) → False contr'' x 0<x x=0 rewrite x=0 = TotalOrder.irreflexive ℕTotalOrder 0<x canonicalAscends {zero} a 0<a | (x₁ :: y) with≡ x rewrite x = refl canonicalAscends {one} a 0<a = refl canonicalAscends'' {i} a with inspect (canonical a) canonicalAscends'' {zero} a | [] with≡ x rewrite x = refl canonicalAscends'' {one} a | [] with≡ x rewrite x = refl canonicalAscends'' {i} a | (x₁ :: y) with≡ x = transitivity (applyEquality canonical (canonicalAscends' {i} a λ p → contr p x)) (equalityCommutative (canonicalIdempotent (i :: a))) where contr : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False contr {l1 = []} p1 () contr {l1 = x :: l1} () p2 incrPreservesCanonical' [] = refl incrPreservesCanonical' (zero :: xs) with inspect (canonical xs) incrPreservesCanonical' (zero :: xs) | [] with≡ x rewrite x = refl incrPreservesCanonical' (zero :: xs) | (x₁ :: y) with≡ x rewrite x = refl incrPreservesCanonical' (one :: xs) with inspect (canonical (incr xs)) ... | [] with≡ pr = exFalso (incrNonzero xs pr) ... | (_ :: _) with≡ pr rewrite pr = applyEquality (zero ::_) (transitivity (equalityCommutative pr) (incrPreservesCanonical' xs)) NToBinNatSucc zero = refl NToBinNatSucc (succ n) with NToBinNat n ... | [] = refl ... | a :: as = refl
src/Ordinal/Shulman.agda
JLimperg/msc-thesis-code
5
11967
-- Plump ordinals as presented by Shulman -- https://homotopytypetheory.org/2014/02/22/surreals-plump-ordinals/ -- -- Implementation based on an implementation of Aczel sets by <NAME>. module Ordinal.Shulman where open import Data.Sum using ([_,_]′) open import Induction.WellFounded as WfRec using (Acc ; acc ; WellFounded) open import Level using (Lift ; lift ; lower) open import Relation.Binary using (IsEquivalence) open import Relation.Nullary using (¬_) open import Ordinal.HoTT using (IsOrdinal ; IsExtensional ; _↔_ ; forth ; back) open import Util.Prelude -- Definition of ordinals, equality, orders ------------------------------------------------------------------------ -- Ordinals are infinitely branching well-founded trees. -- The branching type is given at each node. data Ord ℓ : Set (lsuc ℓ) where limSuc : (I : Set ℓ) (els : I → Ord ℓ) → Ord ℓ -- Branching type Br : ∀ {ℓ} (a : Ord ℓ) → Set ℓ Br (limSuc I _) = I -- Elements els : ∀ {ℓ} (a : Ord ℓ) (i : Br a) → Ord ℓ els (limSuc _ f) = f syntax els a i = a ` i lift-Ord : ∀ {a ℓ} → Ord ℓ → Ord (a ⊔ℓ ℓ) lift-Ord {a} (limSuc I f) = limSuc (Lift a I) λ i → lift-Ord {a} (f (lower i)) -- Equality and orders mutual _<_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a < limSuc _ f = ∃[ i ] (a ≤ f i) _≤_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ limSuc _ f ≤ b = ∀ i → f i < b _≅_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≅ b = (a ≤ b) × (b ≤ a) _≮_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≮ b = ¬ (a < b) _≇_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≇ b = ¬ (a ≅ b) -- Intro/Elim rules for </≤ (for nicer proofs below) <-intro : ∀ {ℓ} {a b : Ord ℓ} → ∃[ i ] (a ≤ (b ` i)) → a < b <-intro {b = limSuc I f} p = p <-elim : ∀ {ℓ} {a b : Ord ℓ} → a < b → ∃[ i ] (a ≤ (b ` i)) <-elim {b = limSuc I f} p = p ≤-intro : ∀ {ℓ} {a b : Ord ℓ} → (∀ i → (a ` i) < b) → a ≤ b ≤-intro {a = limSuc I f} p = p ≤-elim : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → (∀ i → (a ` i) < b) ≤-elim {a = limSuc I f} p = p -- Reflexivity ≤-refl : ∀ {ℓ} {a : Ord ℓ} → a ≤ a ≤-refl {a = limSuc _ f} i = i , ≤-refl ≅-refl : ∀ {ℓ} {a : Ord ℓ} → a ≅ a ≅-refl = ≤-refl , ≤-refl -- < implies ≤ <→≤ : ∀ {ℓ} {a b : Ord ℓ} → a < b → a ≤ b <→≤ {ℓ} {limSuc A fa} {limSuc B fb} (i , fa<fb) j = i , <→≤ (fa<fb j) -- Transitivity mutual <-trans-≤ : ∀ {ℓ} {a b c : Ord ℓ} → a < b → b ≤ c → a < c <-trans-≤ {b = limSuc _ f} (i , p) h = ≤-trans-< p (h i) ≤-trans-< : ∀ {ℓ} {a b c : Ord ℓ} → a ≤ b → b < c → a < c ≤-trans-< {c = limSuc _ f} p (i , q) = i , ≤-trans p q ≤-trans : ∀ {ℓ} {a b c : Ord ℓ} → a ≤ b → b ≤ c → a ≤ c ≤-trans {a = limSuc _ f} h q i = <-trans-≤ (h i) q <-trans : ∀ {ℓ} {a b c : Ord ℓ} → a < b → b < c → a < c <-trans {ℓ} {a} {b} {limSuc C fc} a<b (i , b≤fci) = i , <→≤ (<-trans-≤ a<b b≤fci) ≅-trans : ∀ {ℓ} {a b c : Ord ℓ} (d : a ≅ b) (e : b ≅ c) → a ≅ c ≅-trans (p , p′) (q , q′) = ≤-trans p q , ≤-trans q′ p′ -- Symmetry ≅-sym : ∀ {ℓ} {a b : Ord ℓ} (p : a ≅ b) → b ≅ a ≅-sym (p , p′) = p′ , p -- ≅ is an equivalence relation. ≅-equiv : ∀ {ℓ} → IsEquivalence (_≅_ {ℓ}) ≅-equiv = record { refl = ≅-refl ; sym = ≅-sym ; trans = ≅-trans } -- < is 'extensional'. <-ext-≤ : ∀ {ℓ} {a b : Ord ℓ} → (∀ c → c < a → c < b) → a ≤ b <-ext-≤ {a = limSuc I els} p i = p (els i) (i , ≤-refl) <-ext : ∀ {ℓ} → IsExtensional {ℓ} _≅_ _<_ <-ext p = <-ext-≤ (λ c → forth (p c)) , <-ext-≤ (λ c → back (p c)) -- Alternative interpretation of ≤ in terms of < ≤-intro′ : ∀ {ℓ} {b c : Ord ℓ} → (∀ {a} → a < b → a < c) → b ≤ c ≤-intro′ {b = limSuc _ f} cast i = cast (i , ≤-refl) ≤-elim′ : ∀ {ℓ} {b c : Ord ℓ} → b ≤ c → ∀ {a} → a < b → a < c ≤-elim′ b≤c a<b = <-trans-≤ a<b b≤c -- Compatibility of ≤ with ≅ ≤-congˡ : ∀ {ℓ} {a b c : Ord ℓ} → a ≅ b → a ≤ c → b ≤ c ≤-congˡ {ℓ} (a≤b , b≤a) a≤c = ≤-trans b≤a a≤c ≤-congʳ : ∀ {ℓ} {a b c : Ord ℓ} → b ≅ c → a ≤ b → a ≤ c ≤-congʳ (b≤c , c≤b) a≤b = ≤-trans a≤b b≤c -- Compatibility of < with ≅ <-congʳ : ∀ {ℓ} {a b c : Ord ℓ} → b ≅ c → a < b → a < c <-congʳ (b≤c , c≤b) a<b = <-trans-≤ a<b b≤c <-congˡ : ∀ {ℓ} {a b c : Ord ℓ} → a ≅ b → a < c → b < c <-congˡ (a≤b , b≤a) a<c = ≤-trans-< b≤a a<c -- Foundation: a ≤ b implies b ≮ a ≤-found : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → b ≮ a ≤-found {ℓ} {limSuc A fa} {b} a≤b (i , b≤fai) = ≤-found b≤fai (a≤b i) -- Thus, a ≮ a. <-irr : ∀ {ℓ} {a : Ord ℓ} → a ≮ a <-irr = ≤-found ≤-refl -- Predicates over ordinals (need to respect equality) IsPred : ∀ {ℓ} (P : Ord ℓ → Set ℓ) → Set (lsuc ℓ) IsPred {ℓ} P = {a b : Ord ℓ} → a ≅ b → P a → P b record Pred ℓ : Set (lsuc ℓ) where constructor pred field _!_ : Ord ℓ → Set ℓ resp : IsPred _!_ open Pred -- <-induction. <-acc-≤ : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → Acc _<_ b → Acc _<_ a <-acc-≤ {ℓ} {limSuc A fa} {b} fai<b (acc rs) = acc λ where x (i , x≤fai) → rs x (≤-trans-< x≤fai (fai<b i)) <-wf : ∀ {ℓ} → WellFounded (_<_ {ℓ}) <-wf (limSuc I f) = acc λ { x (i , x≤fi) → <-acc-≤ x≤fi (<-wf (f i)) } <-ind : ∀ {ℓ ℓ′} (P : Ord ℓ → Set ℓ′) → (∀ a → (∀ b → b < a → P b) → P a) → ∀ a → P a <-ind = WfRec.All.wfRec <-wf _ -- Ordinals are ordinals (in the sense of the HoTT book). isOrdinal : ∀ {ℓ} → IsOrdinal (Ord ℓ) ℓ ℓ isOrdinal = record { _≈_ = _≅_ ; ≈-equiv = ≅-equiv ; _<_ = _<_ ; <-wf = <-wf ; <-ext = <-ext ; <-trans = <-trans } -- Constructions on ordinals ------------------------------------------------------------------------ -- Zero ozero : ∀ {ℓ} → Ord ℓ ozero {ℓ} = limSuc (Lift ℓ ⊥) λ() -- Successor? osuc : ∀ {ℓ} → Ord ℓ → Ord ℓ osuc {ℓ} a = limSuc (Lift ℓ ⊤) λ _ → a -- Lo and behold! osuc-mon-< : ∀ {ℓ} {a b : Ord ℓ} → a < b → osuc a < osuc b osuc-mon-< a<b = _ , λ _ → a<b osuc-mon-≤ : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → osuc a ≤ osuc b osuc-mon-≤ a≤b _ = _ , a≤b osuc-cong : ∀ {ℓ} {a b : Ord ℓ} → a ≅ b → osuc a ≅ osuc b osuc-cong (a≤b , b≤a) = osuc-mon-≤ a≤b , osuc-mon-≤ b≤a -- Maximum/Supremum _⊔_ : ∀ {ℓ} (a b : Ord ℓ) → Ord ℓ a ⊔ b = limSuc (_ ⊎ _) λ where (inj₁ i) → a ` i (inj₂ j) → b ` j ⊔-introˡ : ∀ {ℓ} a {b c : Ord ℓ} → a < b → a < (b ⊔ c) ⊔-introˡ a {limSuc _ f} (i , e) = inj₁ i , e ⊔-introʳ : ∀ {ℓ} a {b c : Ord ℓ} → a < c → a < (b ⊔ c) ⊔-introʳ a {c = limSuc _ g} (i , e) = inj₂ i , e ⊔-≤-introˡ : ∀ {ℓ} a {b c : Ord ℓ} → a ≤ b → a ≤ (b ⊔ c) ⊔-≤-introˡ a a≤b = ≤-intro λ i → ⊔-introˡ _ (≤-elim a≤b i) ⊔-≤-introˡ′ : ∀ {ℓ} {a : Ord ℓ} b → a ≤ (a ⊔ b) ⊔-≤-introˡ′ b = ⊔-≤-introˡ _ ≤-refl ⊔-≤-introʳ : ∀ {ℓ} a {b c : Ord ℓ} → a ≤ c → a ≤ (b ⊔ c) ⊔-≤-introʳ a a≤c = ≤-intro λ i → ⊔-introʳ _ (≤-elim a≤c i) ⊔-≤-introʳ′ : ∀ {ℓ} a {b : Ord ℓ} → b ≤ (a ⊔ b) ⊔-≤-introʳ′ a = ⊔-≤-introʳ _ ≤-refl ⊔-elim : ∀ {ℓ} {a b c : Ord ℓ} → c < (a ⊔ b) → (c < a) ⊎ (c < b) ⊔-elim {a = limSuc _ f} (inj₁ i , e) = inj₁ (i , e) ⊔-elim {a = limSuc _ _} {b = limSuc _ g} (inj₂ i , e) = inj₂ (i , e) ⊔-case : ∀ {ℓ} {a b c : Ord ℓ} → c < (a ⊔ b) → ∀ {q} {Q : Set q} → (c < a → Q) → (c < b → Q) → Q ⊔-case p left right = [ left , right ]′ (⊔-elim p) ⊔-split : ∀ {ℓ q} {Q : Set q} {a b c : Ord ℓ} → (c < a → Q) → (c < b → Q) → c < (a ⊔ b) → Q ⊔-split left right p = ⊔-case p left right ⊔-mon : ∀ {ℓ} {a a′ b b′ : Ord ℓ} → a ≤ a′ → b ≤ b′ → (a ⊔ b) ≤ (a′ ⊔ b′) ⊔-mon a≤a′ b≤b′ = ≤-intro′ (⊔-split (λ c<a → ⊔-introˡ _ (≤-elim′ a≤a′ c<a)) (λ c<b → ⊔-introʳ _ (≤-elim′ b≤b′ c<b))) ⊔-cong : ∀ {ℓ} {a a′ b b′ : Ord ℓ} → a ≅ a′ → b ≅ b′ → (a ⊔ b) ≅ (a′ ⊔ b′) ⊔-cong (a≤a′ , a′≤a) (b≤b′ , b′≤b) = ⊔-mon a≤a′ b≤b′ , ⊔-mon a′≤a b′≤b ⊔-<→LEM : ∀ {ℓ} → ({α α′ β : Ord ℓ} → α < β → α′ < β → (α ⊔ α′) < β) → (A : Set ℓ) → A ⊎ ¬ A ⊔-<→LEM {ℓ} p A = let α<β : α < β α<β = lift true , ≤-refl α′<β : α′ < β α′<β = lift false , ≤-refl in go (p α<β α′<β) where oone = osuc ozero α = limSuc A λ _ → oone α′ = oone β = limSuc (Lift ℓ Bool) λ { (lift true) → α ; (lift false) → α′ } go : (α ⊔ α′) < β → A ⊎ ¬ A go (lift true , α⊔α′≤α) = inj₁ (proj₁ (α⊔α′≤α (inj₂ _))) go (lift false , α⊔α′≤α′) = inj₂ λ a → lower (proj₁ (proj₂ (α⊔α′≤α′ (inj₁ a)) _)) -- Supremum of a family of ordinals ⨆ᶠ : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) → Ord ℓ ⨆ᶠ {ℓ} {I} f = limSuc (∃[ i ] Br (f i)) λ { (i , j) → f i ` j } ⨆ᶠ-intro : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) {c : Ord ℓ} {i : I} → c < f i → c < ⨆ᶠ f ⨆ᶠ-intro f {c} {i} c<fi = let j , c≤ = <-elim c<fi in (i , j) , c≤ ⨆ᶠ-elim : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) {c : Ord ℓ} → c < ⨆ᶠ f → ∃[ i ] (c < f i) ⨆ᶠ-elim _ ((i , j) , e) = i , <-intro (j , e) ⨆ᶠ-mon : ∀ {ℓ} {I : Set ℓ} {f f′ : I → Ord ℓ} → (∀ i → f i ≤ f′ i) → ⨆ᶠ f ≤ ⨆ᶠ f′ ⨆ᶠ-mon {f = f} {f′} p = ≤-intro′ λ c<⨆ᶠf → let i , q = ⨆ᶠ-elim f c<⨆ᶠf in ⨆ᶠ-intro f′ (≤-elim′ (p i) q) ⨆ᶠ-cong : ∀ {ℓ} {I : Set ℓ} {f f′ : I → Ord ℓ} → (∀ i → f i ≅ f′ i) → ⨆ᶠ f ≅ ⨆ᶠ f′ ⨆ᶠ-cong p = ⨆ᶠ-mon (λ i → proj₁ (p i)) , ⨆ᶠ-mon (λ i → proj₂ (p i)) -- Supremum of all ordinals smaller than some given ordinal ⨆ : ∀ {ℓ} (a : Ord ℓ) → Ord ℓ ⨆ (limSuc _ f) = ⨆ᶠ f ⨆-intro : ∀ {ℓ} {a b : Ord ℓ} → b < a → b ≤ ⨆ a ⨆-intro {a = limSuc A fa} {b = limSuc B fb} (i , b≤fi) = ≤-intro λ j → let k , p = <-elim (b≤fi j) in _ , p ⨆-elim : ∀ {ℓ} {a c : Ord ℓ} → c < ⨆ a → ∃[ b ] ((b < a) × (c < b)) ⨆-elim {a = limSuc _ f} ((i , j) , c≤) = f i , (i , ≤-refl) , <-intro (_ , c≤)
constants/status_constants.asm
etdv-thevoid/pokemon-rgb-enhanced
1
84635
; non-volatile statuses SLP EQU %111 ; sleep counter PSN EQU 3 BRN EQU 4 FRZ EQU 5 PAR EQU 6 ; volatile statuses 1 StoringEnergy EQU 0 ; Bide ThrashingAbout EQU 1 ; e.g. Thrash AttackingMultipleTimes EQU 2 ; e.g. Double Kick, Fury Attack Flinched EQU 3 ChargingUp EQU 4 ; e.g. Solar Beam, Fly UsingTrappingMove EQU 5 ; e.g. Wrap Invulnerable EQU 6 ; charging up Fly/Dig Confused EQU 7 ; volatile statuses 2 UsingXAccuracy EQU 0 ProtectedByMist EQU 1 GettingPumped EQU 2 ; Focus Energy ; EQU 3 ; unused? HasSubstituteUp EQU 4 NeedsToRecharge EQU 5 ; Hyper Beam UsingRage EQU 6 Seeded EQU 7 ; volatile statuses 3 BadlyPoisoned EQU 0 HasLightScreenUp EQU 1 HasReflectUp EQU 2 Transformed EQU 3
draw_horizontal_line.asm
Dove6/bmp-rgb-triangle-x86-64
1
177211
<gh_stars>1-10 ; description: Contains the function for drawing interpolated horizontal lines on R8G8B8 bitmap. ; author: <NAME> ; last modified: 2020-06-12 section .text global draw_horizontal_line %macro clamp_0_255 2 ; parameters: ; %1 source and destination register (to be clamped) ; %2 temporary helper register mov %2, 255 cmp %1, %2 cmovg %1, %2 ; replace %1 with 255 if %1 > 255 xor %2, %2 test %1, %1 cmovs %1, %2 ; replace %1 with 0 if %1 < 0 %endmacro draw_horizontal_line: ; function arguments ; [rdi] BYTE *image_data ; [rsi] struct BITMAPINFOHEADER *info_header ; [rdx] DWORD line_y ; [xmm0] double left_x ; [xmm1] double left_r ; [xmm2] double left_g ; [xmm3] double left_b ; [xmm4] double right_x ; [xmm5] double right_r ; [xmm6] double right_g ; [xmm7] double right_b ; function prologue sub rsp, 8 ; align the stack ; move left_x and right_x to general purpose registers mov r11, rdx ; line_y cvtpd2dq xmm8, xmm0 ; left_x movd ecx, xmm8 cvtpd2dq xmm8, xmm4 ; right_x movd edx, xmm8 ; if right_x < 0, skip drawing xor rax, rax cmp edx, eax jl draw_end ; if left_x >= image width, skip drawing mov r10d, [rsi+0x4] ; info_header->biWidth mov r8d, r10d ; sar r8d, 31 ; xor r10d, r8d ; sub r10d, r8d ; get absolute value of width cmp r10d, ecx jl draw_end ; [r10d] abs(width) ; prepare vector registers for looping unpcklpd xmm0, xmm1 unpcklpd xmm2, xmm3 unpcklpd xmm4, xmm5 unpcklpd xmm6, xmm7 movapd xmm1, xmm2 movapd xmm2, xmm4 movapd xmm3, xmm6 movapd xmm4, xmm0 movapd xmm5, xmm1 ; vector registers layout (high double, low double) ; [xmm0] left_r, left_x ; [xmm1] left_b, left_g ; [xmm2] right_r, right_x ; [xmm3] right_b, right_g ; [xmm4] left_r, left_x ; [xmm5] left_b, left_g subpd xmm4, xmm2 subpd xmm5, xmm3 ; [xmm4] left_r - right_r, left_x - right_x ; [xmm5] left_b - right_b, left_g - right_g movsd xmm6, xmm0 cmpeqpd xmm6, xmm2 punpcklqdq xmm6, xmm6 pcmpeqd xmm7, xmm7 pxor xmm7, xmm6 ; [xmm6] left_x == right_x, left_x == right_x ; [xmm7] left_x != right_x, left_x != right_x movsd xmm2, xmm4 unpcklpd xmm2, xmm4 movdqa xmm3, xmm6 ; [xmm2] left_x - right_x, left_x - right_x ; [xmm3] left_x == right_x, left_x == right_x pand xmm4, xmm7 pand xmm5, xmm7 cvtdq2pd xmm3, xmm3 addpd xmm2, xmm3 ; if left_x == right_x ; [xmm2] -1.0, -1.0 } ; [xmm3] -1.0, -1.0 } to avoid dividing by zero ; [xmm4] 0.0, 0.0 ; [xmm5] 0.0, 0.0 ; else (left_x != right_x) ; [xmm2] left_x - right_x, left_x - right_x ; [xmm3] 0.0, 0.0 ; [xmm4] left_r - right_r, left_x - right_x ; [xmm5] left_b - right_b, left_g - right_g divpd xmm4, xmm2 divpd xmm5, xmm2 ; [xmm4] step_r, step_x ; [xmm5] step_b, step_g ; (zeroed if left_x == right_x) movapd xmm2, xmm4 movapd xmm3, xmm5 ; [xmm2] step_r, step_x ; [xmm3] step_b, step_g ; prepare general purpose registers for looping xor r8d, r8d mov r9d, r8d sub r9d, ecx cmovg ecx, r8d ; ecx = max(0, left_x) cmovl r9d, r8d movd xmm4, r9d ; send max(0, 0 - left_x) to a vector register mov r9d, r10d ; abs(width) mov r8d, r9d sub r8d, 1 cmp edx, r8d cmovg edx, r8d ; edx = min(width - 1, right_x) ; if left_x > right_x, skip drawing cmp ecx, edx jg draw_end ; calculate stride mov r8d, r9d ; shl r9d, 1 ; add r9d, r8d ; multiply r9d by 3 add r9d, 3 and r9d, 0xfffffffc ; discard 3 least-significant bits ; calculate initial value of current_x, current_r, current_g, current_b ; by adding appropriate step values multiplied by max(0, 0 - left_x) ; to left_x, left_r, left_g, left_b cvtdq2pd xmm4, xmm4 unpcklpd xmm4, xmm4 movapd xmm5, xmm4 mulpd xmm4, xmm2 mulpd xmm5, xmm3 addpd xmm0, xmm4 addpd xmm1, xmm5 ; [xmm0] current_r, current_x ; [xmm1] current_b, current_g ; calculate memory address mov eax, r9d ; stride mov r9d, edx ; move min(width - 1, right_x), as edx content is destroyed after multiplication mul r11d ; edx:eax <- stride * line_y shl rdx, 32 or rax, rdx mov edx, ecx ; shl rdx, 1 ; add rdx, rcx ; multiply left_x by 3 (bytes per pixel) add rax, rdx add rdi, rax mov edx, r9d horizontal_loop: ; general purpose registers layout ; [rdi] current image data pointer ; [rsi] info_header ; [rcx] loop counter ; [rdx] loop counter limit ; vector registers layout ; [xmm0] current_r, current_x ; [xmm1] current_b, current_g ; [xmm2] step_r, step_x ; [xmm3] step_b, step_g ; fetch current color values cvtpd2dq xmm4, xmm0 cvtpd2dq xmm5, xmm1 movq r9, xmm5 mov rax, r9 shr rax, 32 clamp_0_255 eax, r8d mov [rdi], al ; store blue mov eax, r9d clamp_0_255 eax, r8d mov [rdi+1], al ; store green movq rax, xmm4 shr rax, 32 clamp_0_255 eax, r8d mov [rdi+2], al ; store red ; perform a linear interpolation step addpd xmm0, xmm2 addpd xmm1, xmm3 add rdi, 3 ; increment memory destination pointer add ecx, 1 cmp ecx, edx jle horizontal_loop draw_end: xor rax, rax ; function epilogue add rsp, 8 ; undo stack alignment ret
test/Fail/Issue1441.agda
shlevy/agda
1,989
17020
<reponame>shlevy/agda<gh_stars>1000+ -- 2015-02-24 <NAME> -- Since type constructors are considered injective by the forcing analysis we are able to define the type for the "russel" paradox: open import Common.Product Type = Set₁ data Box : Type -> Set where -- The following type should be rejected, as A is not forced. data Tree' : Set -> Type where sup' : ∀ (A : Type) -> (A → ∃ Tree') → Tree' (Box A) Tree = ∃ Tree' sup : (a : Type) -> (f : a -> Tree) -> Tree sup a f = _ , sup' a f a : Tree -> Type a (._ , sup' a _) = a f : (t : Tree) -> a t -> Tree f (._ , sup' a f) = f -- The rest is the standard paradox open import Common.Equality open import Common.Prelude normal : Tree -> Type normal t = Σ (a t) (λ (y : a t) → (f t y ≡ sup (a t) (f t))) -> ⊥ nt : Type nt = Σ Tree \ (t : Tree) -> normal t p : nt -> Tree p (x , _) = x q : (y : nt) -> normal (p y) q (x , y) = y r : Tree r = sup nt p lemma : normal r lemma ((y1 , y2) , z) = y2 (subst (\ y3 -> Σ _ \ (y : a y3) -> f y3 y ≡ sup (a y3) (f y3)) (sym z) ((y1 , y2) , z)) russel : ⊥ russel = lemma ((r , lemma) , refl)
programs/oeis/014/A014797.asm
neoneye/loda
22
5983
; A014797: Squares of odd square pyramidal numbers. ; 1,25,3025,8281,81225,148225,670761,1030225,3186225,4447881,10962721,14402025,30525625,38452401,73188025,89397025,156975841,187279225,308880625,361722361,567440041,654592225,985646025,1122987121,1634180625,1842555625,2604979521,2911142025,4015123225,4452759441,6011055961,6621890625,8773132225,9608116441,12520491025,13641072025,17516257801,18995730625,24073074025,25998015121,32558954481,35030737225,43403472225,46539864361,57104271225,61041114225,74233906681,79126877025,95447013025,101473465401,121487799601,128848692025,153197874025,162119774881,191524393225,202261570225,237528542161,250365133225,292394340225,307646606281,357437775321,375456435025,434116265625,455288912001,524038449025,548792048025,628974300241,657777771225,750865575625,784232453761,891836585641,930327766225,1054205295025,1098431859721,1240494750625,1291120875625,1453444836921,1511190783025,1696024359225,1761669543841,1971443454561,2045829605625,2283166330225,2367200722041,2634924330025,2729583101025,3030729328201,3137060880625,3474887451025,3594015932521,3972013126081,4105141993225,4527043459225,4675459122961,5145252939225,5310328492225,5832268470081,6015467496025,6594084731025,6796965195801 seq $0,15221 ; Odd square pyramidal numbers. pow $0,2
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_pbutils_encoding_target_h.ads
persan/A-gst
1
14825
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h; with glib; with glib; with glib.Values; with System; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h; with System; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_pbutils_encoding_target_h is GST_ENCODING_CATEGORY_DEVICE : aliased constant String := "device" & ASCII.NUL; -- gst/pbutils/encoding-target.h:42 GST_ENCODING_CATEGORY_ONLINE_SERVICE : aliased constant String := "online-service" & ASCII.NUL; -- gst/pbutils/encoding-target.h:53 GST_ENCODING_CATEGORY_STORAGE_EDITING : aliased constant String := "storage-editing" & ASCII.NUL; -- gst/pbutils/encoding-target.h:64 GST_ENCODING_CATEGORY_CAPTURE : aliased constant String := "capture" & ASCII.NUL; -- gst/pbutils/encoding-target.h:72 -- unsupported macro: GST_TYPE_ENCODING_TARGET (gst_encoding_target_get_type ()) -- arg-macro: function GST_ENCODING_TARGET (obj) -- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ENCODING_TARGET, GstEncodingTarget); -- arg-macro: function GST_IS_ENCODING_TARGET (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ENCODING_TARGET); -- arg-macro: function gst_encoding_target_unref (target) -- return gst_mini_object_unref ((GstMiniObject*) target); -- arg-macro: function gst_encoding_target_ref (target) -- return gst_mini_object_ref ((GstMiniObject*) target); -- GStreamer encoding profile registry -- * Copyright (C) 2010 <NAME> <<EMAIL>> -- * (C) 2010 Nokia Corporation -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- -- FIXME/UNKNOWNS -- * -- * Should encoding categories be well-known strings/quarks ? -- * -- --* -- * GST_ENCODING_CATEGORY_DEVICE: -- * -- * #GstEncodingTarget category for device-specific targets. -- * The name of the target will usually be the constructor and model of the device, -- * and that target will contain #GstEncodingProfiles suitable for that device. -- --* -- * GST_ENCODING_CATEGORY_ONLINE_SERVICE: -- * -- * #GstEncodingTarget category for online-services. -- * The name of the target will usually be the name of the online service -- * and that target will contain #GstEncodingProfiles suitable for that online -- * service. -- --* -- * GST_ENCODING_CATEGORY_STORAGE_EDITING: -- * -- * #GstEncodingTarget category for storage, archiving and editing targets. -- * Those targets can be lossless and/or provide very fast random access content. -- * The name of the target will usually be the container type or editing target, -- * and that target will contain #GstEncodingProfiles suitable for editing or -- * storage. -- --* -- * GST_ENCODING_CATEGORY_CAPTURE: -- * -- * #GstEncodingTarget category for recording and capture. -- * Targets within this category are optimized for low latency encoding. -- --* -- * GstEncodingTarget: -- * -- * Collection of #GstEncodingProfile for a specific target or use-case. -- * -- * When being stored/loaded, targets come from a specific category, like -- * #GST_ENCODING_CATEGORY_DEVICE. -- * -- * Since: 0.10.32 -- -- skipped empty struct u_GstEncodingTarget -- skipped empty struct GstEncodingTarget type GstEncodingTargetClass is new GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObjectClass; -- gst/pbutils/encoding-target.h:92 function gst_encoding_target_get_type return GLIB.GType; -- gst/pbutils/encoding-target.h:94 pragma Import (C, gst_encoding_target_get_type, "gst_encoding_target_get_type"); --* -- * gst_encoding_target_unref: -- * @target: a #GstEncodingTarget -- * -- * Decreases the reference count of the @target, possibly freeing it. -- * -- * Since: 0.10.32 -- --* -- * gst_encoding_target_ref: -- * @target: a #GstEncodingTarget -- * -- * Increases the reference count of the @target. -- * -- * Since: 0.10.32 -- function gst_encoding_target_new (name : access GLIB.gchar; category : access GLIB.gchar; description : access GLIB.gchar; profiles : access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList) return System.Address; -- gst/pbutils/encoding-target.h:119 pragma Import (C, gst_encoding_target_new, "gst_encoding_target_new"); function gst_encoding_target_get_name (target : System.Address) return access GLIB.gchar; -- gst/pbutils/encoding-target.h:121 pragma Import (C, gst_encoding_target_get_name, "gst_encoding_target_get_name"); function gst_encoding_target_get_category (target : System.Address) return access GLIB.gchar; -- gst/pbutils/encoding-target.h:122 pragma Import (C, gst_encoding_target_get_category, "gst_encoding_target_get_category"); function gst_encoding_target_get_description (target : System.Address) return access GLIB.gchar; -- gst/pbutils/encoding-target.h:123 pragma Import (C, gst_encoding_target_get_description, "gst_encoding_target_get_description"); function gst_encoding_target_get_profiles (target : System.Address) return access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/pbutils/encoding-target.h:124 pragma Import (C, gst_encoding_target_get_profiles, "gst_encoding_target_get_profiles"); function gst_encoding_target_get_profile (target : System.Address; name : access GLIB.gchar) return System.Address; -- gst/pbutils/encoding-target.h:125 pragma Import (C, gst_encoding_target_get_profile, "gst_encoding_target_get_profile"); function gst_encoding_target_add_profile (target : System.Address; profile : System.Address) return GLIB.gboolean; -- gst/pbutils/encoding-target.h:129 pragma Import (C, gst_encoding_target_add_profile, "gst_encoding_target_add_profile"); function gst_encoding_target_save (target : System.Address; error : System.Address) return GLIB.gboolean; -- gst/pbutils/encoding-target.h:131 pragma Import (C, gst_encoding_target_save, "gst_encoding_target_save"); function gst_encoding_target_save_to_file (target : System.Address; filepath : access GLIB.gchar; error : System.Address) return GLIB.gboolean; -- gst/pbutils/encoding-target.h:133 pragma Import (C, gst_encoding_target_save_to_file, "gst_encoding_target_save_to_file"); function gst_encoding_target_load (name : access GLIB.gchar; category : access GLIB.gchar; error : System.Address) return System.Address; -- gst/pbutils/encoding-target.h:136 pragma Import (C, gst_encoding_target_load, "gst_encoding_target_load"); function gst_encoding_target_load_from_file (filepath : access GLIB.gchar; error : System.Address) return System.Address; -- gst/pbutils/encoding-target.h:139 pragma Import (C, gst_encoding_target_load_from_file, "gst_encoding_target_load_from_file"); function gst_encoding_list_available_categories return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/pbutils/encoding-target.h:142 pragma Import (C, gst_encoding_list_available_categories, "gst_encoding_list_available_categories"); function gst_encoding_list_all_targets (categoryname : access GLIB.gchar) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/pbutils/encoding-target.h:143 pragma Import (C, gst_encoding_list_all_targets, "gst_encoding_list_all_targets"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_pbutils_encoding_target_h;
src/dir_to_graphviz.adb
pyjarrett/dirs_to_graphviz
0
17940
-- Prints a graphviz version of a directory tree. with Ada.Command_Line; with Ada.Text_IO; with DTG; procedure Dir_To_Graphviz is package ACL renames Ada.Command_Line; package AIO renames Ada.Text_IO; begin if ACL.Argument_Count = 0 then AIO.Put_Line ("No arguments provided."); AIO.Put_Line ("Usage: " & ACL.Command_Name & "DIR..."); return; end if; declare Result : DTG.Report := DTG.Create ("example.dot"); begin Result.Include_Dot_Files := False; for Index in 1 .. ACL.Argument_Count loop DTG.Evaluate (Result, ACL.Argument (Index)); end loop; end; end Dir_To_Graphviz;
tools-src/gnu/gcc/gcc/ada/bindusg.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
18144
------------------------------------------------------------------------------ -- -- -- GBIND BINDER COMPONENTS -- -- -- -- B I N D U S G -- -- -- -- B o d y -- -- -- -- $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. -- -- -- ------------------------------------------------------------------------------ with Osint; use Osint; with Output; use Output; procedure Bindusg is procedure Write_Switch_Char; -- Write two spaces followed by appropriate switch character procedure Write_Switch_Char is begin Write_Str (" "); Write_Char (Switch_Character); end Write_Switch_Char; -- Start of processing for Bindusg begin -- Usage line Write_Str ("Usage: "); Write_Program_Name; Write_Char (' '); Write_Str ("switches lfile"); Write_Eol; Write_Eol; -- Line for -aO switch Write_Switch_Char; Write_Str ("aOdir Specify library files search path"); Write_Eol; -- Line for -aI switch Write_Switch_Char; Write_Str ("aIdir Specify source files search path"); Write_Eol; -- Line for A switch Write_Switch_Char; Write_Str ("A Generate binder program in Ada (default)"); Write_Eol; -- Line for -b switch Write_Switch_Char; Write_Str ("b Generate brief messages to std"); Write_Str ("err even if verbose mode set"); Write_Eol; -- Line for -c switch Write_Switch_Char; Write_Str ("c Check only, no generation of b"); Write_Str ("inder output file"); Write_Eol; -- Line for C switch Write_Switch_Char; Write_Str ("C Generate binder program in C"); Write_Eol; -- Line for -e switch Write_Switch_Char; Write_Str ("e Output complete list of elabor"); Write_Str ("ation order dependencies"); Write_Eol; -- Line for -E switch Write_Switch_Char; Write_Str ("E Store tracebacks in Exception occurrences"); Write_Eol; -- Line for -h switch Write_Switch_Char; Write_Str ("h Output this usage (help) infor"); Write_Str ("mation"); Write_Eol; -- Lines for -I switch Write_Switch_Char; Write_Str ("Idir Specify library and source files search path"); Write_Eol; Write_Switch_Char; Write_Str ("I- Don't look for sources & library files"); Write_Str (" in default directory"); Write_Eol; -- Line for -K switch Write_Switch_Char; Write_Str ("K Give list of linker options specified for link"); Write_Eol; -- Line for -l switch Write_Switch_Char; Write_Str ("l Output chosen elaboration order"); Write_Eol; -- Line of -L switch Write_Switch_Char; Write_Str ("Lxyz Library build: adainit/final "); Write_Str ("renamed to xyzinit/final, implies -n"); Write_Eol; -- Line for -M switch Write_Switch_Char; Write_Str ("Mxyz Rename generated main program from main to xyz"); Write_Eol; -- Line for -m switch Write_Switch_Char; Write_Str ("mnnn Limit number of detected error"); Write_Str ("s to nnn (1-999)"); Write_Eol; -- Line for -n switch Write_Switch_Char; Write_Str ("n No Ada main program (foreign main routine)"); Write_Eol; -- Line for -nostdinc Write_Switch_Char; Write_Str ("nostdinc Don't look for source files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib Write_Switch_Char; Write_Str ("nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -o switch Write_Switch_Char; Write_Str ("o file Give the output file name (default is b~xxx.adb) "); Write_Eol; -- Line for -O switch Write_Switch_Char; Write_Str ("O Give list of objects required for link"); Write_Eol; -- Line for -p switch Write_Switch_Char; Write_Str ("p Pessimistic (worst-case) elaborat"); Write_Str ("ion order"); Write_Eol; -- Line for -s switch Write_Switch_Char; Write_Str ("s Require all source files to be"); Write_Str (" present"); Write_Eol; -- Line for -Sxx switch Write_Switch_Char; Write_Str ("S?? Sin/lo/hi/xx for Initialize_Scalars"); Write_Str (" invalid/low/high/hex"); Write_Eol; -- Line for -static Write_Switch_Char; Write_Str ("static Link against a static GNAT run time"); Write_Eol; -- Line for -shared Write_Switch_Char; Write_Str ("shared Link against a shared GNAT run time"); Write_Eol; -- Line for -t switch Write_Switch_Char; Write_Str ("t Tolerate time stamp and other consistency errors"); Write_Eol; -- Line for -T switch Write_Switch_Char; Write_Str ("Tn Set time slice value to n microseconds (n >= 0)"); Write_Eol; -- Line for -v switch Write_Switch_Char; Write_Str ("v Verbose mode. Error messages, "); Write_Str ("header, summary output to stdout"); Write_Eol; -- Lines for -w switch Write_Switch_Char; Write_Str ("wx Warning mode. (x=s/e for supp"); Write_Str ("ress/treat as error)"); Write_Eol; -- Line for -x switch Write_Switch_Char; Write_Str ("x Exclude source files (check ob"); Write_Str ("ject consistency only)"); Write_Eol; -- Line for -z switch Write_Switch_Char; Write_Str ("z No main subprogram (zero main)"); Write_Eol; -- Line for sfile Write_Str (" lfile Library file names"); Write_Eol; end Bindusg;
tmp/src/main.adb
acornagl/Control_flow_graph-wcet
0
4615
<gh_stars>0 with Ada.Text_IO; use Ada.Text_IO; with Extract_List_Files; use Extract_List_Files; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Parser_Xml; use Parser_Xml; procedure Main is Return_From_Call_String : Unbounded_String; Return_From_Call_Vector : Parser_Xml.String_Vector.Vector; begin -- Print the list of xml files -- Put_Line(Extract_List_Files.Print_List("obj/xml")); -- Return_From_Call_Vector := Get_List("obj/xml"); -- Put_Line(Integer'Image(Integer(Return_From_Call_Vector.Length))); -- --Return_From_Call_String := -- Extract_Nodes(File_Name => "obj/xml/xml_test.xml", -- Parent_Name => "lillo"); Return_From_Call_Vector := Get_Nodes_Value_From_Xml_Tree(Xml_Tree => Get_Xml_Tree_From_File( File_Name => "obj/xml/xml_test.xml", Description => "Addresses list"), Value_Description => "addr"); for Index in 0 .. (Integer(Return_From_Call_Vector.Length) - 1) loop Put_Line(Return_From_Call_Vector.Element(Integer(Index))); end loop; end Main;
antlr/arms.g4
ARMS/arms.github.io
1
1484
grammar arms; program : model statement+; model : NAME '=' MODEL attributeBlock; attributeBlock : '{' attribute* '}'; attribute : NAME '=' ( math | STRING | UNITS | COLOR); statement : block | variable | template | invocation; block : '{' statement+ '}'; variable : (NAME | INTERP_NAME) '=' expression; template : TEMPLATE NAME '(' (NAME (',' NAME)*)? ')' block; invocation : NAME '(' (math (',' math)*)? ')'; expression : ternary | primitive | math; ternary : cond = math '?' tbranch = math ':' fbranch = math; primitive : PRIMITIVE attributeBlock; math: NUMBER # Number | '-'? NAME # Name | STRING # String | '[' math ',' math ',' math ']' # Vector3 | '[' math ',' math ',' math ',' math ']' # Vector4 | '(' inner = expression ')' # Parentheses | left = math operator = '^' right = math # Power | left = math operator = '*' right = math # Multiplication | left = math operator = '/' right = math # Division | left = math operator = '+' right = math # Addition | left = math operator = '-' right = math # Subtraction; // Keywords TEMPLATE : 'template'; FOR : 'for'; IF : 'if'; ELSE : 'else'; // Literals PRIMITIVE: 'Cuboid' | 'Ellipsoid' | 'Cylinder' | 'Mesh' | 'Revolute'; MODEL : 'Model'; UNITS : 'mm' | 'cm' | 'm' | 'in' | 'ft'; INTERP_NAME : '`' [a-zA-Z{]+ [a-zA-Z0-9_{}]* '`'; NAME : [a-zA-Z] [a-zA-Z0-9_]*; STRING : '"' (~'"' | '\\"')* '"'; COLOR : '#' HEX HEX HEX HEX HEX HEX; fragment HEX : [0-9A-F]; NUMBER : '-'? DIGITS ('.' ZERO* DIGITS EXP? | EXP)?; fragment EXP : [Ee] [+\-]? DIGITS; fragment DIGITS : ZERO | [1-9] [0-9]*; fragment ZERO : '0'; BLOCK_COMMENT : '[-' .*? '-]' -> skip; LINE_COMMENT : '--' ~[\r\n]* -> skip; WHITESPACE : [ \tr\n]+ -> skip;
libsrc/_DEVELOPMENT/target/yaz180/device/asci/c/asci0_flush_Tx.asm
jpoikela/z88dk
640
175460
<reponame>jpoikela/z88dk<gh_stars>100-1000 SECTION code_driver PUBLIC _asci0_flush_Tx EXTERN asm_asci0_flush_Tx_di defc _asci0_flush_Tx = asm_asci0_flush_Tx_di EXTERN asm_asci0_need defc NEED = asm_asci0_need
08/SimpleFunction.asm
tthero/tthero-nand2tetris
0
9387
<filename>08/SimpleFunction.asm<gh_stars>0 // function SimpleFunction.test#$ 0 (SimpleFunction.test#$) // push local 0 @LCL D=M @0 A=A+D D=M @SP A=M M=D @SP M=M+1 // push local 1 @LCL D=M @1 A=A+D D=M @SP A=M M=D @SP M=M+1 // add @SP AM=M-1 D=M A=A-1 M=M+D // neg @SP A=M-1 M=!M M=M+1 // push argument 0 @ARG D=M @0 A=A+D D=M @SP A=M M=D @SP M=M+1 // add @SP AM=M-1 D=M A=A-1 M=M+D // push argument 1 @ARG D=M @1 A=A+D D=M @SP A=M M=D @SP M=M+1 // sub @SP AM=M-1 D=M A=A-1 M=M-D // call test.test 2 @SimpleFunction.test#$$RET$0 D=A @SP A=M M=D @SP M=M+1 @LCL D=M @SP A=M M=D @SP M=M+1 @ARG D=M @SP A=M M=D @SP M=M+1 @THIS D=M @SP A=M M=D @SP M=M+1 @THAT D=M @SP A=M M=D @SP M=M+1 @5 D=A @2 D=A+D @SP D=M-D @ARG M=D @SP D=M @LCL M=D @test.test 0;JMP (SimpleFunction.test#$$RET$0) // goto END @SimpleFunction.test#$$END 0;JMP // label END (SimpleFunction.test#$$END) // return @LCL D=M @R13 M=D @R14 D=A @SP A=M M=D @SP AM=M-1 D=M @SP A=M+1 A=M M=D @ARG D=M @SP M=D @R13 D=M @1 A=D-A D=M @THAT M=D @R13 D=M @2 A=D-A D=M @THIS M=D @R13 D=M @3 A=D-A D=M @ARG M=D @R13 D=M @4 A=D-A D=M @LCL M=D @R13 D=M @5 A=D-A D=M @R13 M=D @R14 D=M @SP A=M M=D @SP M=M+1 @R13 A=M 0;JMP // function test.test 2 (test.test) @0 D=A @SP A=M M=D @SP M=M+1 @0 D=A @SP A=M M=D @SP M=M+1 // push local 0 @LCL D=M @0 A=A+D D=M @SP A=M M=D @SP M=M+1 // push local 1 @LCL D=M @1 A=A+D D=M @SP A=M M=D @SP M=M+1 // add @SP AM=M-1 D=M A=A-1 M=M+D // not @SP A=M-1 M=!M // push argument 0 @ARG D=M @0 A=A+D D=M @SP A=M M=D @SP M=M+1 // add @SP AM=M-1 D=M A=A-1 M=M+D // push argument 1 @ARG D=M @1 A=A+D D=M @SP A=M M=D @SP M=M+1 // sub @SP AM=M-1 D=M A=A-1 M=M-D // return @LCL D=M @R13 M=D @R14 D=A @SP A=M M=D @SP AM=M-1 D=M @SP A=M+1 A=M M=D @ARG D=M @SP M=D @R13 D=M @1 A=D-A D=M @THAT M=D @R13 D=M @2 A=D-A D=M @THIS M=D @R13 D=M @3 A=D-A D=M @ARG M=D @R13 D=M @4 A=D-A D=M @LCL M=D @R13 D=M @5 A=D-A D=M @R13 M=D @R14 D=M @SP A=M M=D @SP M=M+1 @R13 A=M 0;JMP
src/presets/cm_presets_defeatkholdstare.asm
spannerisms/lttphack
6
22483
;=================================================================================================== ; PRESET DATA HEADER ;=================================================================================================== presetheader_defeatkholdstare: dw presetSRAM_defeatkholdstare ; location of SRAM dw presetpersistent_defeatkholdstare ; location of persistent data ;=================================================================================================== %menu_header("Defeat Kholdstare", 24) ;=================================================================================================== ;--------------------------------------------------------------------------------------------------- ; KHOLDSTARE ;--------------------------------------------------------------------------------------------------- ;=================================================================================================== ;--------------------------------------------------------------------------------------------------- %preset_UW("Link's Bed", "defeatkholdstare", "kholdstare", "links_bed") dw $0104 ; Screen ID dw $0940, $215A ; Link Coords dw $0900, $2110 ; Camera HV db $00 ; Item db $02 ; Direction ;----------------------------- db $00 ; Entrance db $20 ; Room layout db $00 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Uncle Lamp", "defeatkholdstare", "kholdstare", "uncle_lamp") dw $0055 ; Screen ID dw $0A78, $0AE1 ; Link Coords dw $0A00, $0A10 ; Camera HV db $00 ; Item db $02 ; Direction ;----------------------------- db $7D ; Entrance db $8F ; Room layout db $09 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_OW("Castle", "defeatkholdstare", "kholdstare", "castle") dw $001B ; Screen ID dw $07F8, $06F9 ; Link Coords dw $0784, $069B ; Camera HV db $09 ; Item db $00 ; Direction ;----------------------------- dw $0803, $0708 ; Scroll X,Y dw $0530 ; Tilemap position ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Stair Clip", "defeatkholdstare", "kholdstare", "stair_clip") dw $0061 ; Screen ID dw $03E8, $0CF8 ; Link Coords dw $0300, $0C8C ; Camera HV db $09 ; Item db $06 ; Direction ;----------------------------- db $04 ; Entrance db $D0 ; Room layout db $0A ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Re-arm EG", "defeatkholdstare", "kholdstare", "re_arm_eg") dw $0062 ; Screen ID dw $053F, $0D2F ; Link Coords dw $04C7, $0CC3 ; Camera HV db $09 ; Item db $02 ; Direction ;----------------------------- db $04 ; Entrance db $F0 ; Room layout db $00 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Ball 'n Chains", "defeatkholdstare", "kholdstare", "ball_n_chains") dw $0070 ; Screen ID dw $0050, $0E20 ; Link Coords dw $004E, $0E00 ; Camera HV db $09 ; Item db $00 ; Direction ;----------------------------- db $04 ; Entrance db $0F ; Room layout db $00 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Trudge to Mire", "defeatkholdstare", "kholdstare", "trudge_to_mire") dw $0080 ; Screen ID dw $01E8, $108F ; Link Coords dw $0100, $1010 ; Camera HV db $09 ; Item db $06 ; Direction ;----------------------------- db $04 ; Entrance db $9E ; Room layout db $0C ; Door / Peg state / Layer dw $0004 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Spark Avoidance", "defeatkholdstare", "kholdstare", "spark_avoidance") dw $00B2 ; Screen ID dw $0478, $17DB ; Link Coords dw $0402, $16F0 ; Camera HV db $09 ; Item db $02 ; Direction ;----------------------------- db $04 ; Entrance db $AE ; Room layout db $8C ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Somaria Bridge", "defeatkholdstare", "kholdstare", "somaria_bridge") dw $00C3 ; Screen ID dw $06E8, $1978 ; Link Coords dw $0600, $190B ; Camera HV db $09 ; Item db $06 ; Direction ;----------------------------- db $04 ; Entrance db $6E ; Room layout db $02 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Trudge to Cannonballs", "defeatkholdstare", "kholdstare", "trudge_to_cannonballs") dw $00C3 ; Screen ID dw $070A, $1878 ; Link Coords dw $0700, $180B ; Camera HV db $09 ; Item db $04 ; Direction ;----------------------------- db $04 ; Entrance db $5E ; Room layout db $02 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Cannonballs", "defeatkholdstare", "kholdstare", "cannonballs") dw $00B8 ; Screen ID dw $11E8, $170B ; Link Coords dw $1100, $169E ; Camera HV db $09 ; Item db $06 ; Direction ;----------------------------- db $04 ; Entrance db $7E ; Room layout db $0C ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Acquire Bow", "defeatkholdstare", "kholdstare", "acquire_bow") dw $00B9 ; Screen ID dw $1239, $1604 ; Link Coords dw $1200, $1600 ; Camera HV db $12 ; Item db $00 ; Direction ;----------------------------- db $04 ; Entrance db $CE ; Room layout db $0C ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Mire to Skull Woods", "defeatkholdstare", "kholdstare", "mire_to_skull_woods") dw $00D1 ; Screen ID dw $02A8, $1A20 ; Link Coords dw $0200, $1A00 ; Camera HV db $12 ; Item db $00 ; Direction ;----------------------------- db $04 ; Entrance db $0D ; Room layout db $00 ; Door / Peg state / Layer dw $0040 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Fire Rod STC", "defeatkholdstare", "kholdstare", "fire_rod_stc") dw $0057 ; Screen ID dw $0E78, $06E2 ; Link Coords dw $0E00, $0510 ; Camera HV db $12 ; Item db $02 ; Direction ;----------------------------- db $04 ; Entrance db $2E ; Room layout db $01 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write16_enable() %write16($7E0600, $FF00) ; Camera boundaries %write16($7E0602, $FE00) ; Camera boundaries %write16($7E0604, $FF10) ; Camera boundaries %write16($7E0606, $FF10) ; Camera boundaries %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Supply Run", "defeatkholdstare", "kholdstare", "supply_run") dw $0058 ; Screen ID dw $1078, $03E1 ; Link Coords dw $1000, $0376 ; Camera HV db $05 ; Item db $02 ; Direction ;----------------------------- db $04 ; Entrance db $2E ; Room layout db $01 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write16_enable() %write16($7E0600, $FB00) ; Camera boundaries %write16($7E0602, $FC00) ; Camera boundaries %write16($7E0604, $FB10) ; Camera boundaries %write16($7E0606, $FD10) ; Camera boundaries %write_end() ;--------------------------------------------------------------------------------------------------- %preset_OW("Well Stair Clip", "defeatkholdstare", "kholdstare", "well_stair_clip") dw $0018 ; Screen ID dw $00B8, $06C9 ; Link Coords dw $0032, $0667 ; Camera HV db $12 ; Item db $00 ; Direction ;----------------------------- dw $00BF, $06D4 ; Scroll X,Y dw $0388 ; Tilemap position ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Ice Backdoor", "defeatkholdstare", "kholdstare", "ice_backdoor") dw $004F ; Screen ID dw $1E0A, $0830 ; Link Coords dw $1E00, $0802 ; Camera HV db $12 ; Item db $02 ; Direction ;----------------------------- db $39 ; Entrance db $0F ; Room layout db $0C ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_OW("Ice Entrance", "defeatkholdstare", "kholdstare", "ice_entrance") dw $0075 ; Screen ID dw $0CB8, $0DC9 ; Link Coords dw $0C3E, $0D6B ; Camera HV db $12 ; Item db $00 ; Direction ;----------------------------- dw $0CC3, $0DD8 ; Scroll X,Y dw $0BC6 ; Tilemap position ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Penguin Switch Room", "defeatkholdstare", "kholdstare", "penguin_switch_room") dw $001E ; Screen ID dw $1DE8, $0378 ; Link Coords dw $1D00, $030B ; Camera HV db $01 ; Item db $06 ; Direction ;----------------------------- db $2D ; Entrance db $30 ; Room layout db $C2 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Break the Ice", "defeatkholdstare", "kholdstare", "break_the_ice") dw $001F ; Screen ID dw $1EE8, $0378 ; Link Coords dw $1E00, $030B ; Camera HV db $01 ; Item db $06 ; Direction ;----------------------------- db $2D ; Entrance db $20 ; Room layout db $C2 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Spike Key", "defeatkholdstare", "kholdstare", "spike_key") dw $003F ; Screen ID dw $1EB0, $0720 ; Link Coords dw $1E00, $0700 ; Camera HV db $12 ; Item db $00 ; Direction ;----------------------------- db $2D ; Entrance db $2F ; Room layout db $40 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Lonely Firebar", "defeatkholdstare", "kholdstare", "lonely_firebar") dw $005E ; Screen ID dw $1D0A, $0B78 ; Link Coords dw $1D00, $0B0B ; Camera HV db $12 ; Item db $04 ; Direction ;----------------------------- db $2D ; Entrance db $3E ; Room layout db $42 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Last Two Screens", "defeatkholdstare", "kholdstare", "last_two_screens") dw $009E ; Screen ID dw $1CE8, $1378 ; Link Coords dw $1C00, $130B ; Camera HV db $12 ; Item db $06 ; Direction ;----------------------------- db $2D ; Entrance db $2C ; Room layout db $42 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;--------------------------------------------------------------------------------------------------- %preset_UW("Kholdstare", "defeatkholdstare", "kholdstare", "kholdstare") dw $00BE ; Screen ID dw $1D78, $17E1 ; Link Coords dw $1D00, $1710 ; Camera HV db $12 ; Item db $02 ; Direction ;----------------------------- db $2D ; Entrance db $3B ; Room layout db $C1 ; Door / Peg state / Layer dw $0000 ; Dead sprites ;----------------------------- %write_end() ;=================================================================================================== presetpersistent_defeatkholdstare: ;=================================================================================================== presetpersistent_defeatkholdstare_kholdstare: ;----------------------------- .links_bed %write_sq() %write8($7E044A, $00) ; EG strength %write8($7E047A, $00) ; Armed EG ..end ;----------------------------- .uncle_lamp %write8($7E044A, $02) ; EG strength ..end ;----------------------------- .castle ..end ;----------------------------- .stair_clip ..end ;----------------------------- .re_arm_eg %write8($7E044A, $01) ; EG strength ..end ;----------------------------- .ball_n_chains %write8($7E047A, $01) ; Armed EG ..end ;----------------------------- .trudge_to_mire %write8($7E047A, $00) ; Armed EG ..end ;----------------------------- .spark_avoidance %write8($7E047A, $01) ; Armed EG ..end ;----------------------------- .somaria_bridge ..end ;----------------------------- .trudge_to_cannonballs ..end ;----------------------------- .cannonballs %write8($7E047A, $00) ; Armed EG ..end ;----------------------------- .acquire_bow ..end ;----------------------------- .mire_to_skull_woods ..end ;----------------------------- .fire_rod_stc %write8($7E02A2, $02) ; Slot 4 Altitude ..end ;----------------------------- .supply_run %write_mirror($48, $08, $09, $01) %write8($7E02A2, $17) ; Slot 4 Altitude ..end ;----------------------------- .well_stair_clip ..end ;----------------------------- .ice_backdoor ..end ;----------------------------- .ice_entrance %write8($7E02A2, $00) ; Slot 4 Altitude ..end ;----------------------------- .penguin_switch_room ..end ;----------------------------- .break_the_ice ..end ;----------------------------- .spike_key ..end ;----------------------------- .lonely_firebar ..end ;----------------------------- .last_two_screens ..end ;----------------------------- .kholdstare ..end ;=================================================================================================== presetSRAM_defeatkholdstare: ;----------------------------- .kholdstare ;----------------------------- ..links_bed %write8($7EF36F, $FF) ; Keys %writeroom($104, $0002) ...end ;----------------------------- ..uncle_lamp %write8($7EF359, $01) ; Sword %write8($7EF35A, $01) ; Shield %write8($7EF3C5, $01) ; Game state %write8($7EF3C6, $11) ; Game flags A %write8($7EF3C8, $03) ; Spawn point %writeroom($055, $000C) ...end ;----------------------------- ..castle %write8($7EF34A, $01) ; Lamp %write8($7EF36E, $10) ; Magic %writeroom($055, $001F) ...end ;----------------------------- ..stair_clip %write8($7EF36F, $00) ; Keys %writeroom($061, $000F) ...end ;----------------------------- ..re_arm_eg %writeroom($062, $000F) ...end ;----------------------------- ..ball_n_chains %write8($7EF36D, $10) ; Health %writeroom($070, $0008) %writeroom($071, $000C) %writeroom($072, $000C) ...end ;----------------------------- ..trudge_to_mire %write8($7EF36D, $14) ; Health %write16sram($7EF366, $4000) ; Big keys %writeroom($080, $040C) ...end ;----------------------------- ..spark_avoidance %write8($7EF36D, $0C) ; Health %writeroom($081, $000F) %writeroom($091, $000F) %writeroom($0A1, $000F) %writeroom($0A2, $000F) %writeroom($0B2, $000F) ...end ;----------------------------- ..somaria_bridge %write16sram($7EF360, $0001) ; Rupees %writeroom($0C2, $000F) %writeroom($0C3, $000A) ...end ;----------------------------- ..trudge_to_cannonballs %write8($7EF350, $01) ; Somaria %writeroom($0C3, $001F) ...end ;----------------------------- ..cannonballs %write8($7EF36D, $04) ; Health %writeroom($0B6, $0003) %writeroom($0B7, $000F) %writeroom($0B8, $000F) %writeroom($0C4, $000F) %writeroom($0C5, $000F) %writeroom($0C6, $000F) ...end ;----------------------------- ..acquire_bow %write8($7EF36E, $08) ; Magic %write16sram($7EF360, $006A) ; Rupees %writeroom($0B9, $001F) ...end ;----------------------------- ..mire_to_skull_woods %write8($7EF340, $02) ; Bow %write8($7EF343, $01) ; Bombs %write8($7EF36E, $5F) ; Magic %write8($7EF377, $0A) ; Arrows %write16sram($7EF360, $006B) ; Rupees %writeroom($097, $000A) %writeroom($0A7, $000C) %writeroom($0A8, $000F) %writeroom($0A9, $001F) %writeroom($0D1, $0008) ...end ;----------------------------- ..fire_rod_stc %write8($7EF36E, $68) ; Magic %writeroom($057, $0002) %writeroom($067, $000A) %writeroom($077, $000A) %writeroom($087, $000A) ...end ;----------------------------- ..supply_run %write8($7EF343, $00) ; Bombs %write8($7EF345, $01) ; Fire Rod %write8($7EF36E, $70) ; Magic %writeroom($057, $000F) %writeroom($058, $001A) %writeroom($067, $000F) ...end ;----------------------------- ..well_stair_clip %write8($7EF343, $03) ; Bombs %write8($7EF35C, $03) ; Bottle 1 %write8($7EF36D, $14) ; Health %write8($7EF36F, $FF) ; Keys %write16sram($7EF360, $0002) ; Rupees %writeroom($02F, $0163) %writeroom($103, $001A) %writeroom($11F, $0001) ...end ;----------------------------- ..ice_backdoor %writeroom($03F, $000F) %writeroom($04F, $0008) ...end ;----------------------------- ..ice_entrance %write8($7EF36E, $68) ; Magic %writeroom($00E, $0003) %writeroom($01E, $0002) %writeroom($02E, $400C) %writeroom($03E, $400C) %writeroom($04E, $400C) ...end ;----------------------------- ..penguin_switch_room %write8($7EF34F, $01) ; Bottles %write8($7EF36F, $00) ; Keys %writeroom($01E, $0007) ...end ;----------------------------- ..break_the_ice %writeroom($01F, $0002) ...end ;----------------------------- ..spike_key %write8($7EF36E, $60) ; Magic %writeroom($01F, $0003) ...end ;----------------------------- ..lonely_firebar %write8($7EF36D, $0C) ; Health %writeroom($05E, $8001) %writeroom($05F, $8012) ...end ;----------------------------- ..last_two_screens %writeroom($05E, $8003) %writeroom($07E, $0002) %writeroom($09E, $0002) ...end ;----------------------------- ..kholdstare %writeroom($09E, $0003) %writeroom($0BE, $0001) ...end ;=================================================================================================== presetend_defeatkholdstare: print "defeatkholdstare size: $", hex(presetend_defeatkholdstare-presetheader_defeatkholdstare)
GrammarSquaredLexer.g4
vgautam/grammar-squared
0
1555
lexer grammar GrammarSquaredLexer; Nonterminal : CapitalAlpha AlphaNum* ; Terminal : QuoteChar Char* QuoteChar ; Produces : '->' ; Or : '|' ; Newline : '\n' ; fragment CapitalAlpha : [A-Z] ; fragment AlphaNum : Alpha | Digit ; fragment Alpha : [a-zA-Z] ; fragment Digit : [0-9] ; fragment Char : ~('"') ; fragment QuoteChar : '"' ; // skip spaces and tabs WS : [ \t\r]+ -> skip ;
oeis/087/A087912.asm
neoneye/loda-programs
11
103104
<reponame>neoneye/loda-programs<filename>oeis/087/A087912.asm ; A087912: Exponential generating function is exp(2*x/(1-x))/(1-x). ; Submitted by <NAME> ; 1,3,14,86,648,5752,58576,671568,8546432,119401856,1815177984,29808908032,525586164736,9898343691264,198227905206272,4204989697906688,94163381359509504,2219240984918720512,54898699229094412288,1422015190821016633344,38484192401958599131136,1086014196955813109301248,31899110013747847701725184,973627299319535297079279616,30833108469384618122672078848,1011679207530563193138610962432,34348305205754462909676331728896,1205261642025834741470497234485248,43659999100477576802664296535293952 mov $1,1 mov $2,1 add $2,$0 lpb $0 sub $0,1 add $2,$1 mul $1,$0 add $1,$2 mul $2,$0 add $2,$1 lpe mov $0,$1
smsq/java/ip/cnam.asm
olifink/smsqe
0
247580
; Setup name of IP channel V1.02  2004 <NAME> ; 1.02 check for UDP channel 2020 <NAME> ; v.1.01 adapted for SMSQmulator section ip xdef ip_cnam xref udp_name xref udd_name include 'dev8_keys_java' include 'dev8_smsq_java_ip_data' ip_cnam move.l d3,-(a7) moveq #-jt9.cnm,d0 ; presume UDP move.l udp_name,d3 cmp.l chn_typ(a0),d3 beq.s cont move.l udd_name,d3 cmp.l chn_typ(a0),d3 ; checfor UDD beq.s cont moveq #jt9.cnm,d0 ; but it isn't, so it's tcp cont move.l (sp),d3 move.l a0,(sp) move.l chn_data(a0),a0 ; internal data dc.w jva.trp9 move.l (sp)+,a0 rts end
src/main/antlr/com/yahoo/elide/IdList.g4
aklish/elide-testing-framework
1
2028
/* * Copyright 2016 Yahoo Inc. * Licensed under the terms of the Apache License, Version 2. Please see LICENSE.txt in the project root for terms. */ grammar IdList; @header { package com.yahoo.elide; } start : EOF #EOF | LBRACKET ALL RBRACKET EOF #ALL | entityIds EOF #IDList ; entityIds : entityId #ID | entityId COMMA entityIds #ListWithID | LBRACKET type=NAME DOT collection=NAME RBRACKET #Subcollection | LBRACKET type=NAME DOT collection=NAME RBRACKET COMMA entityIds #SubcollectionWithList ; entityId : (TERM|NAME); ALL: [Aa][Ll][Ll]; DOT: '.'; COMMA: ','; LBRACKET: '['; RBRACKET: ']'; WS: (' ' | '\t') -> channel(HIDDEN); NAME: ALPHA ALPHANUMERIC; TERM: ALPHANUMERIC; ALPHA: [a-zA-Z]; DIGIT: [0-9]; ALPHANUMERIC: (DIGIT|ALPHA)+;
programs/oeis/225/A225232.asm
jmorken/loda
1
88226
<gh_stars>1-10 ; A225232: The number of FO3C2 moves required to restore a packet of n playing cards to its original state (order and orientation). ; 2,4,4,12,6,24,8,40,10,60,12,84,14,112,16,144,18,180,20,220,22,264,24,312,26,364,28,420,30,480,32,544,34,612,36,684,38,760,40,840,42,924,44,1012,46,1104,48,1200,50,1300,52,1404,54,1512,56,1624,58,1740,60,1860,62,1984,64,2112,66,2244,68,2380,70,2520,72,2664,74,2812,76,2964,78,3120,80,3280,82,3444,84,3612,86,3784,88,3960,90,4140,92,4324,94,4512,96,4704,98,4900,100,5100,102,5304,104,5512,106,5724,108,5940,110,6160,112,6384,114,6612,116,6844,118,7080,120,7320,122,7564,124,7812,126,8064,128,8320,130,8580,132,8844,134,9112,136,9384,138,9660,140,9940,142,10224,144,10512,146,10804,148,11100,150,11400,152,11704,154,12012,156,12324,158,12640,160,12960,162,13284,164,13612,166,13944,168,14280,170,14620,172,14964,174,15312,176,15664,178,16020,180,16380,182,16744,184,17112,186,17484,188,17860,190,18240,192,18624,194,19012,196,19404,198,19800,200,20200,202,20604,204,21012,206,21424,208,21840,210,22260,212,22684,214,23112,216,23544,218,23980,220,24420,222,24864,224,25312,226,25764,228,26220,230,26680,232,27144,234,27612,236,28084,238,28560,240,29040,242,29524,244,30012,246,30504,248,31000,250,31500 mov $2,$0 mov $3,4 lpb $3 mul $0,2 lpb $0 add $1,$0 mov $3,$0 trn $0,4 lpe sub $1,1 lpe lpb $2 add $1,1 sub $2,1 lpe add $1,2
programs/oeis/230/A230462.asm
neoneye/loda
22
241042
; A230462: Numbers congruent to {1, 11, 13, 17, 19, or 29} mod 30. ; 1,11,13,17,19,29,31,41,43,47,49,59,61,71,73,77,79,89,91,101,103,107,109,119,121,131,133,137,139,149,151,161,163,167,169,179,181,191,193,197,199,209,211,221,223,227,229,239,241,251,253,257,259,269,271,281,283,287,289,299,301,311,313,317,319,329,331,341,343,347,349,359,361,371,373,377,379,389,391,401,403,407,409,419,421,431,433,437,439,449,451,461,463,467,469,479,481,491,493,497 mov $1,$0 add $0,2 mov $2,3 mov $3,2 mov $5,$1 lpb $2 mov $4,$0 lpb $4 add $0,$3 trn $4,$3 lpe sub $2,1 trn $2,1 add $3,4 lpe lpb $5 add $0,1 sub $5,1 lpe sub $0,9
programs/oeis/089/A089348.asm
neoneye/loda
22
161891
; A089348: Primes of the form smallest multiple of n followed by a 1. ; 11,41,31,41,101,61,71,241,181,101,331,241,131,281,151,641,1021,181,191,401,211,661,461,241,251,521,271,281,1451,601,311,641,331,1021,701,1801,1481,761,1171,401,821,421,431,881,1801,461,941,3361,491,3001,1021,521 add $0,1 mul $0,10 sub $0,1 seq $0,34694 ; Smallest prime == 1 (mod n).
src/features/sysenter.asm
FranchuFranchu/fran-os
1
99409
%include "features/system_calls.asm" %include "features/sysenter_vectors_list.asm" KERNEL_MSR_IA32_SYSENTER_CS equ 0x174 KERNEL_MSR_IA32_SYSENTER_ESP equ 0x175 KERNEL_MSR_IA32_SYSENTER_EIP equ 0x176 kernel_sysenter_setup: mov eax, 0 mov edx, 0 mov ax, 8h mov ecx, KERNEL_MSR_IA32_SYSENTER_CS wrmsr mov eax, esp mov edx, 0 mov ecx, KERNEL_MSR_IA32_SYSENTER_ESP wrmsr mov eax, kernel_sysenter_entry_point mov edx, 0 mov ecx, KERNEL_MSR_IA32_SYSENTER_EIP wrmsr ; Allocate some things mov eax, 10 mov ebx, fd_list call kernel_data_structure_vec_initialize ret ; IN = EBX: System call number, EDX: Return address, ECX: Return stack kernel_sysenter_entry_point: ; Make sure system call in range cmp ebx, (kernel_system_calls_end - kernel_system_calls) / 4 jge .out_of_range call [kernel_system_calls+ebx*4] sysexit .out_of_range: stc sysexit .teststr dd "Sysenter executed correctly!", 0
Driver/Task/NonTS/nontsStart.asm
steakknife/pcgeos
504
92561
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: FILE: nontsStart.asm AUTHOR: <NAME>, May 9, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 5/ 9/92 Initial revision DESCRIPTION: Code to handle a DR_TASK_START call. $Id: nontsStart.asm,v 1.1 97/04/18 11:58:16 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NTSMovableCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSStart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Start a new task by shutting the system down after building up the stuff we'll need to run the program in question. CALLED BY: DR_TASK_START PASS: ds = segment of DosExecArgs block cx:dx = boot-up path RETURN: carry set if couldn't start: ax = FileError carry clear if task on its way: ax = destroyed DESTROYED: bx, cx, dx, si, di, es, ds PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/ 9/92 Initial version dlitwin 8/12/93 ERROR_DOS_EXEC_IN_PROGRESS check %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NTSStart proc far uses bp .enter ; ; Gain exclusive access to the NTSExecCode block and make sure another ; DR_TASK_START isn't already in progress. ; segmov es, dgroup, ax PSem es, ntsStartSem, TRASH_AX_BX clr bx ; set/clear nothing call SysSetExitFlags test bl, mask EF_RUN_DOS jz doIt mov ax, ERROR_DOS_EXEC_IN_PROGRESS stc jmp done doIt: ; ; Lock down the exec stub resource. Once brought in, it will not ; be discarded, so we can resize it to our hearts' content. ; mov bx, handle NTSExecCode call MemLock mov es, ax ; ; Copy all the arguments into the frame. ; push cx clr si mov di, offset ntsExecFrame.NTSEF_args mov cx, size DosExecArgs rep movsb pop cx ; ; Free the arguments, as we need them no longer. ; mov bx, ds:[DEA_handle] call MemFree ; ; Copy in the bootup path. ; mov ds, cx mov si, dx mov di, offset ntsExecFrame.NTSEF_bootPath mov cx, length NTSEF_bootPath if DBCS_PCGEOS ; ; copy and convert drive letter to DOS ; findDrive: lodsw ; drive letter stosb cmp al, ':' loopne findDrive jcxz noDrive mov bx, di ; ds:bx = rest of path jmp copyPath noDrive: mov bx, offset ntsExecFrame.NTSEF_bootPath mov cx, length NTSEF_bootPath ; ; copy rest of path ; copyPath: rep movsw ; copy rest of path ; ; convert rest to path to DOS ; push ds, es mov ax, SGIT_SYSTEM_DISK call SysGetInfo mov si, ax ; si = system disk handle segmov ds, es ; ds:dx = src path mov dx, bx mov bx, ds ; bx:cx = dest (same as src) mov cx, dx call FSDLockInfoShared mov es, ax ; es = FSInfo mov ax, FSPOF_MAP_VIRTUAL_NAME shl 8 ; allow abort mov di, DR_FS_PATH_OP push bp push si call DiskLock call es:[bp].FSD_strategy pop si call DiskUnlock pop bp call FSDUnlockInfoShared pop ds, es else rep movsb endif ; ; Locate the loader, if possible. ; mov di, offset ntsExecFrame.NTSEF_loader call DosExecLocateLoader jc err ; ; Set up the environment for the thing. ; call NTSSetupEnvironment ; di <- start for ; strings jc insufficientMemory ; ; Now copy in the message strings. ; call NTSSetupStrings jc insufficientMemory ; ; Set up NTSEF_execBlock ; call NTSSetupExecBlock ; ; All done with setup, so unlock the block with the code and data. ; mov bx, handle NTSExecCode call MemUnlock ; ; Now shut down the system. ; mov bx, mask EF_RUN_DOS call SysSetExitFlags mov ax, SST_CLEAN clr cx ; notify UI when done. call SysShutdown clc done: segmov ds, dgroup, bx VSem ds, ntsStartSem ; doesn't touch carry jnc exit ; ; 8/12/93 dlitwin: Check to see if ax (the error code) is ; ERROR_DOS_EXEC_IN_PROGRESS because if it is we don't need ; to call NTSShutdownAborted, as we don't want to resize ; NTSExecCode and abort our shelling to DOS (by clearing ; EF_RUN_DOS from the exitFlag byte). ; This situation occurs when DosExec is called while a DosExec ; is already in progress, and if we were to call NTSShutdownAborted ; now it would exit GEOS instead of shelling to DOS and ignoring ; the second DosExec. ; cmp ax, ERROR_DOS_EXEC_IN_PROGRESS je carrySetExit ; ; Revert the NTSExecCode segment to its former beauty. ; push ax mov cx, TRUE ; flag called internally call NTSShutdownAborted pop ax carrySetExit: stc exit: .leave ret insufficientMemory: mov ax, ERROR_INSUFFICIENT_MEMORY err: mov bx, handle NTSExecCode call MemUnlock stc jmp done NTSStart endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSSizeWithProductName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure the size of a string, including any replacements for the product name. CALLED BY: (INTERNAL) NTSSetupEnvironment, NTSSetupStrings PASS: ds:si = string to size (DBCS) RETURN: cx = length of string, including null DESTROYED: nothing SIDE EFFECTS: ntsProductName* will be filled in if they haven't been already. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/18/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ uiCategory char 'ui', 0 productNameKey char 'productName', 0 NTSSizeWithProductName proc near uses es, si, ax .enter ; ; See if we've already fetched the product name. ; segmov es, dgroup, ax tst es:[ntsProductNameLen] jnz haveName ; ; Nope. Look for it in ui::productName in the ini file. ; push ds, si, dx, bp, di, bx segmov ds, cs, cx ; ds, cx <- cs mov dx, offset productNameKey ; cx:dx <- key mov si, offset uiCategory ; ds:si <- cat mov di, offset ntsProductName ; es:di <- buffer mov bp, length ntsProductName ; bp <- size + no cvt call InitFileReadString jnc popThingsStoreLen ; => got it ; ; Nothing in the .ini file, so we have to use the default string ; stored in our own NTSStrings resource. ; mov bx, handle NTSStrings call MemLock mov ds, ax assume ds:NTSStrings mov si, ds:[defaultProduct] ; (DBCS) mov cx, length ntsProductName-1 copyDefProductLoop: if DBCS_PCGEOS lodsw stosw tst ax loopnz copyDefProductLoop clr ax stosw ; null-terminate else lodsb stosb tst al loopnz copyDefProductLoop clr al stosb ; null-terminate endif sub cx, length ntsProductName-1 ; compute size w/o null not cx call MemUnlock assume ds:nothing popThingsStoreLen: mov es:[ntsProductNameLen], cx pop ds, si, dx, bp, di, bx haveName: clr cx countNameLoop: inc cx countNameLoopNoInc: if DBCS_PCGEOS lodsw cmp ax, 1 else lodsb cmp al, 1 endif ja countNameLoop ; => neither done nor subst, so ; just count the thing jb haveLength ; => al == 0, so done add cx, es:[ntsProductNameLen] jmp countNameLoopNoInc ; don't inc, to account for ; elimination of \1 that we ; already counted haveLength: .leave ret NTSSizeWithProductName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSCopyWithProductName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy a string, coping with \1 substitution requests for the product name. CALLED BY: (INTERNAL) NTSSetupEnvironment, NTSSetupStrings PASS: ds:si = string to copy (DBCS) es:di = place to put it (SBCS) RETURN: es:di = after null terminator DESTROYED: si, ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/18/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NTSCopyWithProductName proc near uses cx .enter copyLoop: if DBCS_PCGEOS ;============================================================= push si lengthLoop: lodsw cmp ax, 1 ja lengthLoop ; stop at null or \1 mov cx, si pop si ; ds:si = string push cx ; save end of section sub cx, si ; cx = #bytes shr cx, 1 ; # bytes -> # chars clr bx, dx call LocalGeosToDos ; (ignore error) add di, cx ; advance dest ptr pop si ; si = end of section cmp {wchar} ds:[si-2], 0 ; processed null? je done ; yes, done else ;===================================================================== lodsb stosb cmp al, 1 ja copyLoop jb done endif ;===================================================================== dec di push ds, si segmov ds, dgroup, si mov si, offset ntsProductName mov cx, ds:[ntsProductNameLen] if DBCS_PCGEOS ;------------------------------------------------------------- push bx, dx clr bx, dx call LocalGeosToDos ; (ignore error) pop bx, dx add di, cx ; advance dest ptr else ;--------------------------------------------------------------------- rep movsb endif ;--------------------------------------------------------------------- pop ds, si jmp copyLoop done: .leave ret NTSCopyWithProductName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSSetupEnvironment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set up the environment for the child with the "Type exit to return to PC/GEOS" string in the prompt, regardless of the interactiveness of the child. CALLED BY: NTSStart PASS: es = NTSExecCode RETURN: carry set on error carry clear if ok: es:di = place to store first localizable message string. DESTROYED: ax, bx, cx, si, ds PSEUDO CODE/STRATEGY: foreach variable in the environment: if it's PROMPT, record position after the = size required <- end pointer + size promptMessage if PROMPT not found: add size of promptVariable chunk+size defaultPrompt enlarge NTSExecCode to hold the environment copy env up to after the = if PROMPT not found: copy in promptVariable copy in promptMessage if PROMPT not found: copy in defaultPrompt else copy the rest of the env store final null KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NTSSetupEnvironment proc near .enter mov bx, handle NTSStrings call MemLock mov ds, ax mov es, es:[ntsExecFrame].NTSEF_args.DEA_psp mov es, es:[PSP_envBlk] clr di mov si, ds:[promptVariable] ChunkSizePtr ds, si, cx clr dx mov ax, dx ; al <- 0, for finding the end of ; things lookForPromptLoop: ; ; es:di = start of next envar ; ds:si = start of promptVariable ; cx = length of promptVariable (includes =) ; dx <- position in environment after PROMPT= ; push cx, si repe cmpsb pop si je foundPrompt dec di ; in case mismatch was null... ; ; Scan to the end of the variable (the null-terminator) ; mov cx, -1 repne scasb pop cx ; cx <- promptVariable length ; ; If next char not null too, there's another variable to examine. Else ; we've hit the end of the environment. ; cmp es:[di], al jne lookForPromptLoop ChunkSizeHandle ds, defaultPrompt, ax add cx, ax ; cx <- extra space needed b/c ; PROMPT variable not present jmp enlargeNTSEC foundPrompt: ; ; Found the PROMPT variable, and di is now the place at which we'll ; want to insert our adorable little string. Record that position ; in dx and skip to the end of the environment. ; inc sp inc sp ; discard saved CX mov dx, di ; es:dx <- insertion point findEnvEndLoop: mov cx, -1 repne scasb ; skip to null scasb ; another null? jne findEnvEndLoop ; => no, so not at end dec di ; point back to final null clr cx ; no extra space needed, beyond the ; adorable string itself ;-------------------- enlargeNTSEC: ; ds = NTSStrings ; es:di = null at end of the environment ; cx = number of extra bytes, beyond those required for the prompt ; message itself ; es:dx = place at which to insert the prompt message. ; ; Enlarge NTSExecCode to hold the new environment. ; stc ; +1 to have room for final null adc cx, di push cx mov si, ds:[promptMessage] call NTSSizeWithProductName mov_tr ax, cx pop cx push ax ; save length for conversion to DOS DBCS < shl ax, 1 ; # chars -> # bytes > add ax, cx ; ax <- amount needed. mov cx, offset ntsEnvKindaStart+15 andnf cx, not 0xf add ax, cx clr cx ; no special flags mov bx, handle NTSExecCode EC < push es > EC < segmov es, ds ; avoid ec +segment death > call MemReAlloc EC < pop es > pop cx ; cx <- length of promptMessage jc done ; => can't enlarge, so can't exec mov bx, ds ; bx <- NTSStrings segmov ds, es ; ds <- environment mov es, ax ; es <- NTSExecCode clr si push di ; save the end of the environment mov di, offset ntsEnvKindaStart+15 andnf di, not 0xf ; ; Copy environment data up to the insertion point. ; xchg cx, dx ; cx <- length up to var, dx <- length ; of promptMessage jcxz storeNewPromptVar rep movsb ; ; Copy in the promptMessage and convert it to the DOS character set. ; push ds, si ; save environment pointer mov ds, bx ; ds <- NTSStrings mov si, ds:[promptMessage] ; ds:si <- promptMessage SBCS < push di ; save start for conversion > ; to DOS character set call NTSCopyWithProductName dec di ; point to null if DBCS_PCGEOS convertPromptMessageToDOS: else pop si mov cx, dx ; cx <- # chars to convert convertPromptMessageToDOS: ; es:si = string to convert ; cx = # chars to convert ; ; on_stack: ds, si ; first byte of the rest of the env ; mov ax, '?' ; what the heck. Use ? as the default segmov ds, es ; ds:si <- string to convert call LocalGeosToDos endif pop ds, si ; recover environment pointer ; ds:si = place from which to copy ; es:di = place to which to copy pop cx ; cx <- end of environment sub cx, si rep movsb ; copy remaining bytes clr al ; store second null byte to terminate stosb ; the environment. ; ; All done, so unlock the strings block. ; clc ; success done: EC < segmov ds, es ; avoid ec +segment death > mov bx, handle NTSStrings call MemUnlock .leave ret storeNewPromptVar: push ds, si mov dx, di ; save starting point mov ds, bx ; ds <- NTSStrings mov si, ds:[promptVariable] ; (SBCS) ChunkSizePtr ds, si, cx rep movsb mov si, ds:[promptMessage] call NTSCopyWithProductName dec di ; point to null mov si, ds:[defaultPrompt] ChunkSizePtr ds, si, cx rep movsb if not DBCS_PCGEOS mov si, dx ; si <- start of strings just copied in mov cx, di sub cx, dx ; cx <- # chars to convert endif jmp convertPromptMessageToDOS NTSSetupEnvironment endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSSetupStrings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy in the message strings from the NTSStrings block, and convert them to the DOS character set, pointing the various fields in nontsExecFrame to their respective strings. CALLED BY: NTSStart PASS: es:di = place to store first string RETURN: carry set on error DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ntsStringChunks word DE_execError, DE_prompt, DE_failedReload, noMemError ntsStringPtrs word ntsExecFrame.NTSEF_execError, ntsExecFrame.NTSEF_prompt, ntsExecFrame.NTSEF_failedReload, ntsExecFrame.NTSEF_noMemory NTSSetupStrings proc near .enter mov bx, handle NTSStrings call MemLock mov ds, ax ; ; First figure the number of bytes all these strings will require. ; dx ends up with the # bytes ; mov si, offset ntsStringChunks mov cx, length ntsStringChunks clr dx figureLengthLoop: lodsw cs: xchg ax, si ; *ds:si <- string push cx mov si, ds:[si] ; ds:si <- string call NTSSizeWithProductName ; cx <- length of same add dx, cx ; add into total mov_tr si, ax ; cs:si <- addr of next chunk pop cx loop figureLengthLoop DBCS < shl dx, 1 ; # chars -> # bytes > ; ; Enlarge the NTSExecCode block to hold them all. ; mov ax, di add ax, dx ; ax <- size of block. no ; special flags to pass, and ; cx is already 0... mov bx, handle NTSExecCode call MemReAlloc jc done mov es, ax ; es <- new segment ; ; Now copy the chunks into the block and convert them to the DOS ; character set. ; mov si, offset ntsStringChunks mov cx, length ntsStringChunks copyStringLoop: ; ; Store the start of the string in the apropriate part of the ; nontsExecFrame. ; mov bx, cs:[si+(ntsStringPtrs-ntsStringChunks)] mov es:[bx], di ; ; Copy the string into the block. ; lodsw cs: push ds, si, cx mov_tr si, ax ; *ds:si <- string mov si, ds:[si] ; ds:si <- string SBCS < push di ; save start for conversion> call NTSCopyWithProductName if not DBCS_PCGEOS pop si mov cx, di stc sbb cx, si ; cx <- # chars to convert (w/o ; null) segmov ds, es ; ds:si <- string to convert mov ax, '?' ; default char (foo) call LocalGeosToDos endif ; ; Loop to deal with the next string ; pop ds, si, cx loop copyStringLoop clc done: mov bx, handle NTSStrings call MemUnlock .leave ret NTSSetupStrings endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NTSSetupExecBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform all the piddly-hooey things we must do to run a DOS program, setting up the NTSEF_execBlock. CALLED BY: NTSStart PASS: es = NTSExecCode RETURN: nothing DESTROYED: ax, bx, cx, dx, si, ds, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NTSSetupExecBlock proc near .enter segmov ds, es lea si, ds:[ntsExecFrame].NTSEF_args.DEA_args lea di, es:[ntsExecFrame].NTSEF_fcb1 mov ax, MSDOS_PARSE_FILENAME shl 8 or \ DosParseFilenameControl < 0, ; always set ext 0, ; always set name 0, ; always set drive 1 ; ignore leading space > call FileInt21 ; ds:si <- after first name lea di, es:[ntsExecFrame].NTSEF_fcb2 mov ax, MSDOS_PARSE_FILENAME shl 8 or \ DosParseFilenameControl < 0, ; always set ext 0, ; always set name 0, ; always set drive 1 ; ignore leading space > call FileInt21 .leave ret NTSSetupExecBlock endp NTSMovableCode ends
3-mid/impact/source/3d/collision/shapes/impact-d3-shape-concave-triangle_mesh-bvh.adb
charlie5/lace
20
24464
<reponame>charlie5/lace<filename>3-mid/impact/source/3d/collision/shapes/impact-d3-shape-concave-triangle_mesh-bvh.adb package body impact.d3.Shape.concave.triangle_mesh.bvh is procedure performRaycast (Self : in out Item; callback : access impact.d3.triangle_Callback.Item'Class; raySource, rayTarget : in math.Vector_3) is begin raise Program_Error with "TBD31"; end performRaycast; end impact.d3.Shape.concave.triangle_mesh.bvh; -- //#define DISABLE_BVH -- -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.concave.triangle_mesh.bvh.h" -- #include "BulletCollision/CollisionShapes/impact.d3.collision.quantized_Bvh.optimized.h" -- #include "LinearMath/btSerializer.h" -- -- ///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization. -- ///Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -- impact.d3.Shape.concave.triangle_mesh.bvh::impact.d3.Shape.concave.triangle_mesh.bvh(impact.d3.striding_Mesh* meshInterface, bool useQuantizedAabbCompression, bool buildBvh) -- :impact.d3.Shape.concave.triangle_mesh(meshInterface), -- m_bvh(0), -- m_triangleInfoMap(0), -- m_useQuantizedAabbCompression(useQuantizedAabbCompression), -- m_ownsBvh(false) -- { -- m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; -- //construct bvh from meshInterface -- #ifndef DISABLE_BVH -- -- if (buildBvh) -- { -- buildOptimizedBvh(); -- } -- -- #endif //DISABLE_BVH -- -- } -- -- impact.d3.Shape.concave.triangle_mesh.bvh::impact.d3.Shape.concave.triangle_mesh.bvh(impact.d3.striding_Mesh* meshInterface, bool useQuantizedAabbCompression,const impact.d3.Vector& bvhAabbMin,const impact.d3.Vector& bvhAabbMax,bool buildBvh) -- :impact.d3.Shape.concave.triangle_mesh(meshInterface), -- m_bvh(0), -- m_triangleInfoMap(0), -- m_useQuantizedAabbCompression(useQuantizedAabbCompression), -- m_ownsBvh(false) -- { -- m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; -- //construct bvh from meshInterface -- #ifndef DISABLE_BVH -- -- if (buildBvh) -- { -- void* mem = btAlignedAlloc(sizeof(impact.d3.collision.quantized_Bvh.optimized),16); -- m_bvh = new (mem) impact.d3.collision.quantized_Bvh.optimized(); -- -- m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax); -- m_ownsBvh = true; -- } -- -- #endif //DISABLE_BVH -- -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::partialRefitTree(const impact.d3.Vector& aabbMin,const impact.d3.Vector& aabbMax) -- { -- m_bvh->refitPartial( m_meshInterface,aabbMin,aabbMax ); -- -- m_localAabbMin.setMin(aabbMin); -- m_localAabbMax.setMax(aabbMax); -- } -- -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::refitTree(const impact.d3.Vector& aabbMin,const impact.d3.Vector& aabbMax) -- { -- m_bvh->refit( m_meshInterface, aabbMin,aabbMax ); -- -- recalcLocalAabb(); -- } -- -- impact.d3.Shape.concave.triangle_mesh.bvh::~impact.d3.Shape.concave.triangle_mesh.bvh() -- { -- if (m_ownsBvh) -- { -- m_bvh->~impact.d3.collision.quantized_Bvh.optimized(); -- btAlignedFree(m_bvh); -- } -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::performRaycast (impact.d3.triangle_Callback* callback, const impact.d3.Vector& raySource, const impact.d3.Vector& rayTarget) -- { -- struct MyNodeOverlapCallback : public btNodeOverlapCallback -- { -- impact.d3.striding_Mesh* m_meshInterface; -- impact.d3.triangle_Callback* m_callback; -- -- MyNodeOverlapCallback(impact.d3.triangle_Callback* callback,impact.d3.striding_Mesh* meshInterface) -- :m_meshInterface(meshInterface), -- m_callback(callback) -- { -- } -- -- virtual void processNode(int nodeSubPart, int nodeTriangleIndex) -- { -- impact.d3.Vector m_triangle[3]; -- const unsigned char *vertexbase; -- int numverts; -- PHY_ScalarType type; -- int stride; -- const unsigned char *indexbase; -- int indexstride; -- int numfaces; -- PHY_ScalarType indicestype; -- -- m_meshInterface->getLockedReadOnlyVertexIndexBase( -- &vertexbase, -- numverts, -- type, -- stride, -- &indexbase, -- indexstride, -- numfaces, -- indicestype, -- nodeSubPart); -- -- unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); -- btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); -- -- const impact.d3.Vector& meshScaling = m_meshInterface->getScaling(); -- for (int j=2;j>=0;j--) -- { -- int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; -- -- if (type == PHY_FLOAT) -- { -- float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); -- } -- else -- { -- double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector(impact.d3.Scalar(graphicsbase[0])*meshScaling.getX(),impact.d3.Scalar(graphicsbase[1])*meshScaling.getY(),impact.d3.Scalar(graphicsbase[2])*meshScaling.getZ()); -- } -- } -- -- /* Perform ray vs. triangle collision here */ -- m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); -- m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); -- } -- }; -- -- MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); -- -- m_bvh->reportRayOverlappingNodex(&myNodeCallback,raySource,rayTarget); -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::performConvexcast (impact.d3.triangle_Callback* callback, const impact.d3.Vector& raySource, const impact.d3.Vector& rayTarget, const impact.d3.Vector& aabbMin, const impact.d3.Vector& aabbMax) -- { -- struct MyNodeOverlapCallback : public btNodeOverlapCallback -- { -- impact.d3.striding_Mesh* m_meshInterface; -- impact.d3.triangle_Callback* m_callback; -- -- MyNodeOverlapCallback(impact.d3.triangle_Callback* callback,impact.d3.striding_Mesh* meshInterface) -- :m_meshInterface(meshInterface), -- m_callback(callback) -- { -- } -- -- virtual void processNode(int nodeSubPart, int nodeTriangleIndex) -- { -- impact.d3.Vector m_triangle[3]; -- const unsigned char *vertexbase; -- int numverts; -- PHY_ScalarType type; -- int stride; -- const unsigned char *indexbase; -- int indexstride; -- int numfaces; -- PHY_ScalarType indicestype; -- -- m_meshInterface->getLockedReadOnlyVertexIndexBase( -- &vertexbase, -- numverts, -- type, -- stride, -- &indexbase, -- indexstride, -- numfaces, -- indicestype, -- nodeSubPart); -- -- unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); -- btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); -- -- const impact.d3.Vector& meshScaling = m_meshInterface->getScaling(); -- for (int j=2;j>=0;j--) -- { -- int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; -- -- if (type == PHY_FLOAT) -- { -- float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); -- } -- else -- { -- double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector(impact.d3.Scalar(graphicsbase[0])*meshScaling.getX(),impact.d3.Scalar(graphicsbase[1])*meshScaling.getY(),impact.d3.Scalar(graphicsbase[2])*meshScaling.getZ()); -- } -- } -- -- /* Perform ray vs. triangle collision here */ -- m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); -- m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); -- } -- }; -- -- MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); -- -- m_bvh->reportBoxCastOverlappingNodex (&myNodeCallback, raySource, rayTarget, aabbMin, aabbMax); -- } -- -- //perform bvh tree traversal and report overlapping triangles to 'callback' -- void impact.d3.Shape.concave.triangle_mesh.bvh::processAllTriangles(impact.d3.triangle_Callback* callback,const impact.d3.Vector& aabbMin,const impact.d3.Vector& aabbMax) const -- { -- -- #ifdef DISABLE_BVH -- //brute force traverse all triangles -- impact.d3.Shape.concave.triangle_mesh::processAllTriangles(callback,aabbMin,aabbMax); -- #else -- -- //first get all the nodes -- -- -- struct MyNodeOverlapCallback : public btNodeOverlapCallback -- { -- impact.d3.striding_Mesh* m_meshInterface; -- impact.d3.triangle_Callback* m_callback; -- impact.d3.Vector m_triangle[3]; -- -- -- MyNodeOverlapCallback(impact.d3.triangle_Callback* callback,impact.d3.striding_Mesh* meshInterface) -- :m_meshInterface(meshInterface), -- m_callback(callback) -- { -- } -- -- virtual void processNode(int nodeSubPart, int nodeTriangleIndex) -- { -- const unsigned char *vertexbase; -- int numverts; -- PHY_ScalarType type; -- int stride; -- const unsigned char *indexbase; -- int indexstride; -- int numfaces; -- PHY_ScalarType indicestype; -- -- -- m_meshInterface->getLockedReadOnlyVertexIndexBase( -- &vertexbase, -- numverts, -- type, -- stride, -- &indexbase, -- indexstride, -- numfaces, -- indicestype, -- nodeSubPart); -- -- unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); -- btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT||indicestype==PHY_UCHAR); -- -- const impact.d3.Vector& meshScaling = m_meshInterface->getScaling(); -- for (int j=2;j>=0;j--) -- { -- -- int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:indicestype==PHY_INTEGER?gfxbase[j]:((unsigned char*)gfxbase)[j]; -- -- -- #ifdef DEBUG_TRIANGLE_MESH -- printf("%d ,",graphicsindex); -- #endif //DEBUG_TRIANGLE_MESH -- if (type == PHY_FLOAT) -- { -- float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector( -- graphicsbase[0]*meshScaling.getX(), -- graphicsbase[1]*meshScaling.getY(), -- graphicsbase[2]*meshScaling.getZ()); -- } -- else -- { -- double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); -- -- m_triangle[j] = impact.d3.Vector( -- impact.d3.Scalar(graphicsbase[0])*meshScaling.getX(), -- impact.d3.Scalar(graphicsbase[1])*meshScaling.getY(), -- impact.d3.Scalar(graphicsbase[2])*meshScaling.getZ()); -- } -- #ifdef DEBUG_TRIANGLE_MESH -- printf("triangle vertices:%f,%f,%f\n",triangle[j].x(),triangle[j].y(),triangle[j].z()); -- #endif //DEBUG_TRIANGLE_MESH -- } -- -- m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); -- m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); -- } -- -- }; -- -- MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); -- -- m_bvh->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax); -- -- -- #endif//DISABLE_BVH -- -- -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::setLocalScaling(const impact.d3.Vector& scaling) -- { -- if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) -- { -- impact.d3.Shape.concave.triangle_mesh::setLocalScaling(scaling); -- buildOptimizedBvh(); -- } -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::buildOptimizedBvh() -- { -- if (m_ownsBvh) -- { -- m_bvh->~impact.d3.collision.quantized_Bvh.optimized(); -- btAlignedFree(m_bvh); -- } -- ///m_localAabbMin/m_localAabbMax is already re-calculated in impact.d3.Shape.concave.triangle_mesh. We could just scale aabb, but this needs some more work -- void* mem = btAlignedAlloc(sizeof(impact.d3.collision.quantized_Bvh.optimized),16); -- m_bvh = new(mem) impact.d3.collision.quantized_Bvh.optimized(); -- //rebuild the bvh... -- m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax); -- m_ownsBvh = true; -- } -- -- void impact.d3.Shape.concave.triangle_mesh.bvh::setOptimizedBvh(impact.d3.collision.quantized_Bvh.optimized* bvh, const impact.d3.Vector& scaling) -- { -- btAssert(!m_bvh); -- btAssert(!m_ownsBvh); -- -- m_bvh = bvh; -- m_ownsBvh = false; -- // update the scaling without rebuilding the bvh -- if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) -- { -- impact.d3.Shape.concave.triangle_mesh::setLocalScaling(scaling); -- } -- } --
libsrc/_DEVELOPMENT/math/float/math16/lm16/c/sdcc/asin_fastcall.asm
ahjelm/z88dk
640
103279
SECTION code_fp_math16 PUBLIC _asinf16_fastcall EXTERN asinf16 defc _asinf16_fastcall = asinf16
programs/oeis/024/A024854.asm
neoneye/loda
22
161031
<reponame>neoneye/loda ; A024854: a(n) = s(1)t(n) + s(2)t(n-1) + ... + s(k)t(n-k+1), where k = [ n/2 ], s = (natural numbers), t = (natural numbers >= 3). ; 4,5,16,19,40,46,80,90,140,155,224,245,336,364,480,516,660,705,880,935,1144,1210,1456,1534,1820,1911,2240,2345,2720,2840,3264,3400,3876,4029,4560,4731,5320,5510,6160,6370,7084,7315,8096,8349,9200,9476,10400,10700,11700 add $0,1 lpb $0 add $0,3 add $2,$0 trn $0,5 add $1,$2 lpe mov $0,$1
legend-pure-m2-dsl-mapping/src/main/antlr4/org/finos/legend/pure/m2/dsl/mapping/serialization/grammar/OperationParser.g4
hausea/legend-pure
1
4100
<filename>legend-pure-m2-dsl-mapping/src/main/antlr4/org/finos/legend/pure/m2/dsl/mapping/serialization/grammar/OperationParser.g4 parser grammar OperationParser; options { tokenVocab = OperationLexer; } mapping: functionPath (parameters | mergeParameters) (END_LINE)? EOF ; parameters: GROUP_OPEN (VALID_STRING (COMMA VALID_STRING)*)? GROUP_CLOSE ; functionPath: qualifiedName ; qualifiedName: packagePath? identifier ; packagePath: (identifier PATH_SEPARATOR)+ ; identifier: VALID_STRING ; setParameter: BRACKET_OPEN (VALID_STRING (COMMA VALID_STRING)*)? BRACKET_CLOSE ; lambdaElement: INNER_CURLY_BRACKET_OPEN | CONTENT | INNER_CURLY_BRACKET_CLOSE ; mergeParameters: GROUP_OPEN setParameter COMMA validationLambdaInstance GROUP_CLOSE ; validationLambdaInstance: CURLY_BRACKET_OPEN (lambdaElement)* ;
programs/oeis/211/A211004.asm
neoneye/loda
22
164254
; A211004: Number of distinct regions in the set of partitions of n. ; 1,2,3,5,7,9,12,15,18,22,26,30,35,40,45,51 add $0,3 bin $0,2 div $0,3
libsrc/stdio/m5/fputc_cons_rom.asm
jpoikela/z88dk
640
6757
; ; Basic video handling for the SORD M5 ; ; (HL)=char to display ; ; $Id: fputc_cons.asm,v 1.6+ (GIT imported) $ ; SECTION code_clib PUBLIC fputc_cons_native EXTERN msxbios INCLUDE "target/m5/def/m5bios.def" .fputc_cons_native ld hl,2 add hl,sp ld a,(hl) IF STANDARDESCAPECHARS cp 10 jr nz,nocr ld a,13 .nocr ENDIF ld ix,DSPCH jp msxbios
src/fsmaker-toml.adb
Fabien-Chouteau/fsmaker
0
7801
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with TOML; use TOML; with TOML.File_IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with CLIC.User_Input; use CLIC.User_Input; with Simple_Logging; use Simple_Logging; with FSmaker.Target; with FSmaker.Target.LittleFS; with FSmaker.Source; package body FSmaker.TOML is type FS_Format is (LFS); type Image_Info is record Format : FS_Format; Size : Natural; end record; function Open_Image (Path_To_Output : String) return File_Descriptor; function Get_Image_Info (V : TOML_Value) return Image_Info; ---------------- -- Open_Image -- ---------------- function Open_Image (Path_To_Output : String) return File_Descriptor is FD : File_Descriptor; begin if not Is_Regular_File (Path_To_Output) then -- The file doesn't exists, we try to create it FD := Create_File (Path_To_Output, Binary); elsif not GNAT.OS_Lib.Is_Owner_Writable_File (Path_To_Output) then raise Program_Error with "Image file '" & Path_To_Output & "' is not writable"; else Always ("Existing image file '" & Path_To_Output & "' will be overwritten."); if Query ("Do you want to continue?", Valid => (Yes | No => True, Always => False), Default => Yes) = Yes then FD := Open_Read_Write (Path_To_Output, Binary); else raise Program_Error with "Cannot overwrite existing file"; end if; end if; if FD = Invalid_FD then raise Program_Error with "Cannot open image file '" & Path_To_Output & "'"; end if; return FD; end Open_Image; -------------------- -- Get_Image_Info -- -------------------- function Get_Image_Info (V : TOML_Value) return Image_Info is Res : Image_Info; begin declare Format : constant TOML_Value := V.Get_Or_Null ("format"); begin if Format.Is_Null then raise Program_Error with "missing 'format'"; elsif Format.Kind /= TOML_String then raise Program_Error with "'format' should be a string"; end if; if Format.As_String /= "littlefs" then raise Program_Error with "Unknown image format '" & Format.As_String & "' (use littlefs)"; end if; end; declare Size : constant TOML_Value := V.Get_Or_Null ("size"); begin if Size.Is_Null then raise Program_Error with "missing 'size'"; elsif Size.Kind /= TOML_Integer then raise Program_Error with "'size' should be an integer"; end if; Res.Size := Natural (Size.As_Integer); end; return Res; end Get_Image_Info; ----------- -- Mkdir -- ----------- procedure Mkdir (T : not null Target.Any_Filesystem_Ref; Mk : TOML_Value) is begin if Mk.Is_Null then Simple_Logging.Always ("No dirs to make"); return; -- No dir to make elsif Mk.Kind /= TOML_Array or else Mk.Item_Kind /= TOML_String then raise Program_Error with "'mkdir' should be an array of strings (" & Mk.Kind'Img & ")"; end if; for Index in 1 .. Mk.Length loop declare Dir : constant String := MK.Item (Index).As_String; begin if not Valid_Target_Path (Dir) then raise Program_Error with "Invalid target path: '" & Dir & "'"; else T.Make_Dir (To_Target_Path (Dir)); end if; end; end loop; end Mkdir; ------------ -- Import -- ------------ procedure Import (T : not null Target.Any_Filesystem_Ref; Imp : TOML_Value) is begin if Imp.Is_Null then Simple_Logging.Always ("No imports"); return; elsif imp.Kind /= TOML_Table then raise Program_Error with "'[import]' section should be an table (" & Imp.Kind'Img & ")"; end if; for Elt of Imp.Iterate_On_Table loop declare Key : constant String := To_String (Elt.Key); Val : constant TOML_Value := Elt.Value; begin if not Valid_Target_Path (Key) then raise Program_Error with "Invalid target path: '" & Key & "'"; end if; if Val.Kind /= TOML_String then raise Program_Error with "Import source must be strings"; end if; declare Src : Source.Instance := Source.Create (Val.As_String); begin T.Import (To_Target_Path (Key), Src); end; end; end loop; end Import; ------------------ -- Process_TOML -- ------------------ procedure Process_TOML (Root : TOML_Value; FD : File_Descriptor) is Img_Info : Image_Info; T : Target.Any_Filesystem_Ref; begin if Root.Kind /= TOML_Table then raise Program_Error with "Invalid TOML file. Table expected"; end if; Img_Info := Get_Image_Info (Root); T := new Target.LittleFS.Instance; T.Format (FD, Size => Img_Info.Size); T.Mount (FD); declare Mk : constant TOML_Value := Root.Get_Or_Null ("mkdir"); begin Mkdir (T, Mk); end; declare Imp : constant TOML_Value := Root.Get_Or_Null ("import"); begin Import (T, Imp); end; end Process_TOML; --------------------- -- Build_From_TOML -- --------------------- procedure Build_From_TOML (Path_To_TOML, Path_To_Output : String) is Result : Read_Result := File_IO.Load_File (Path_To_TOML); FD : File_Descriptor; begin if Result.Success then FD := Open_Image (Path_To_Output); Process_TOML (Result.Value, FD); else raise Program_Error with Path_To_Toml & ":" & Format_Error (Result); end if; end Build_From_TOML; end FSmaker.TOML;
src/caches-simple_caches.adb
HeisenbugLtd/cache-sim
0
2312
------------------------------------------------------------------------------ -- Copyright (C) 2012-2020 by Heisenbug Ltd. -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); with Ada.Text_IO; with Ada.Numerics.Float_Random; package body Caches.Simple_Caches is Debug : constant Boolean := False; Random : Ada.Numerics.Float_Random.Generator; ----------------------------------------------------------------------------- -- Connect ----------------------------------------------------------------------------- procedure Connect (This : in out Simple_Cache; Next : access Cache'Class; Speed_Factor : in Long_Float := 8.0) is begin This.Next_Level := Cache_Ptr (Next); This.Config.Speed_Factor := Speed_Factor; end Connect; ----------------------------------------------------------------------------- -- Fetch_Line ----------------------------------------------------------------------------- procedure Fetch_Line (This : in out Simple_Cache; Block : in Unsigned; Tag : in Address; State : in Line_State) is Slot : Unsigned; begin if Debug then Ada.Text_IO.Put_Line ("LEVEL" & Positive'Image (This.Level_Id) & ": Fetching block" & Unsigned'Image (Block) & ", tag" & Address'Image (Tag) & "."); end if; -- If a line needs to be fetched, we had a cache miss. This.Events.Misses := This.Events.Misses + 1; This.Events.Lines_Fetched := This.Events.Lines_Fetched + 1; -- Find a free slot in the block and fetch the line. for i in This.State'Range (2) loop if This.State (Block, i).State = Invalid then Slot := i; goto FETCH; end if; end loop; -- No free slot has been found, select a random slot. -- (TODO: LRU scheme) Slot := Unsigned (Ada.Numerics.Float_Random.Random (Gen => Random) * Float (This.Association - 1)) + 1; if Debug then Ada.Text_IO.Put_Line ("LEVEL" & Positive'Image (This.Level_Id) & ": Selected slot" & Unsigned'Image (Slot) & "."); end if; -- If selected slot contains a dirty cache line, it must be written out -- first. if This.State (Block, Slot).State = Dirty then -- Flush cache line. This.Events.Lines_Flushed := This.Events.Lines_Flushed + 1; -- Propagate the flush to the next level if there is one. if This.Next_Level /= null then Write (This => This.Next_Level.all, Where => To_Address (This => Simple_Cache'Class (This), Tag => This.State (Block, Slot).Tag, Block => Block)); end if; end if; <<FETCH>> -- Simulate getting the line from the next level if there is one. if This.Next_Level /= null then Read (This => This.Next_Level.all, Where => To_Address (This => Simple_Cache'Class (This), Tag => Tag, Block => Block)); end if; This.State (Block, Slot) := Cache_Line_Info'(State => State, Tag => Tag); end Fetch_Line; ----------------------------------------------------------------------------- -- Flush ----------------------------------------------------------------------------- procedure Flush (This : in out Simple_Cache; Recursive : in Boolean := True) is begin This.State := (others => (others => Cache_Line_Info'(State => Invalid, Tag => 0))); if Recursive and then This.Next_Level /= null then Flush (This => This.Next_Level.all); end if; end Flush; ----------------------------------------------------------------------------- -- Get_Block ----------------------------------------------------------------------------- procedure Get_Block (This : in Simple_Cache; Where : in Address; Block : out Unsigned; Tag : out Address) is Mem_Block : Address; begin -- Check if address is cached already. Scan the appropriate block. -- -- _ _ _ _ _ _ _ _ _ -- |_|_|_|_|_|_|_|_|_| -- |___| |_____| |_| -- | | | -- | | +------ cache line length -- | +------------ cache block -- +------------------- address tag -- -- Calculation: -- Address blocks divided by the cache-line length results in the -- memory block. Mem_Block := Where / Address (This.Cache_Line); -- The address tag to be stored Tag := Mem_Block / Address (This.Num_Blocks); -- The responsible cache block is the memory block modulo block size. Block := (Unsigned (Mem_Block) mod This.Num_Blocks) + 1; if Debug then Ada.Text_IO.Put ("LEVEL" & Positive'Image (This.Level_Id) & ": Accessing address" & Address'Image (Where) & " (block" & Unsigned'Image (Block) & ", tag" & Address'Image (Tag) & ")..."); end if; end Get_Block; ----------------------------------------------------------------------------- -- Initialize ----------------------------------------------------------------------------- procedure Initialize (This : in out Simple_Cache) is begin This.Config := Configuration' (Cache_Line => This.Cache_Line, Association => This.Association, Num_Blocks => This.Num_Blocks, Cache_Size => This.Cache_Line * This.Association * This.Num_Blocks, Speed_Factor => 1.0); Reset (This => Simple_Cache'Class (This)); Flush (This => Simple_Cache'Class (This)); This.Next_Level := null; end Initialize; ----------------------------------------------------------------------------- -- Perf_Index ----------------------------------------------------------------------------- function Perf_Index (This : in Simple_Cache; Recursive : in Boolean := True) return Long_Float is Result : Long_Float; begin Result := 1.0 * Long_Float (This.Events.Hits) + 1.0 * Long_Float (This.Events.Misses) + Long_Float (This.Cache_Line) * Long_Float (This.Events.Lines_Fetched) + Long_Float (This.Cache_Line) * Long_Float (This.Events.Lines_Flushed); -- Simpler calculation, probably "good enough". -- # hits + # misses * Some_Miss_Factor. -- Result := ( 1.0 * Long_Float (This.Events.Hits) -- + 8.0 * Long_Float (This.Events.Misses)); if Recursive and then This.Next_Level /= null then Result := (Result + This.Config.Speed_Factor * Perf_Index (This.Next_Level.all)); end if; return Result; end Perf_Index; ----------------------------------------------------------------------------- -- Read ----------------------------------------------------------------------------- procedure Read (This : in out Simple_Cache; Where : in Address) is Tag : Address; Block : Unsigned; begin if Debug then Ada.Text_IO.Put_Line ("LEVEL" & Positive'Image (This.Level_Id) & ": Read from address" & Address'Image (Where) & "."); end if; This.Events.Reads := This.Events.Reads + 1; -- Get block in cache where to look up for given address. Get_Block (This => Simple_Cache'Class (This), Where => Where, Block => Block, Tag => Tag); -- Check if memory is loaded in one of the available slots. for i in This.State'Range (2) loop if This.State (Block, i).State in Full .. Dirty and then This.State (Block, i).Tag = Tag then if Debug then Ada.Text_IO.Put_Line ("HIT (slot" & Unsigned'Image (i) & ")!"); end if; This.Events.Hits := This.Events.Hits + 1; return; end if; end loop; if Debug then Ada.Text_IO.Put_Line ("MISS!"); end if; -- Cache miss. Fetch the required cache line. Fetch_Line (This => Simple_Cache'Class (This), Block => Block, Tag => Tag, State => Full); end Read; ----------------------------------------------------------------------------- -- Reset ----------------------------------------------------------------------------- procedure Reset (This : in out Simple_Cache; Recursive : in Boolean := True) is begin This.Events := Event_Info'(Reads => 0, Writes => 0, Lines_Fetched => 0, Lines_Flushed => 0, Hits => 0, Misses => 0); if Recursive and then This.Next_Level /= null then Reset (This.Next_Level.all); end if; end Reset; ----------------------------------------------------------------------------- -- To_Address ----------------------------------------------------------------------------- function To_Address (This : in Simple_Cache; Tag : in Address; Block : in Unsigned) return Address is begin return Tag * Address (This.Num_Blocks) * Address (This.Cache_Line) + Address (Block - 1) * Address (This.Cache_Line); end To_Address; ----------------------------------------------------------------------------- -- Write ----------------------------------------------------------------------------- procedure Write (This : in out Simple_Cache; Where : in Address) is Block : Unsigned; Tag : Address; begin if Debug then Ada.Text_IO.Put_Line ("LEVEL" & Positive'Image (This.Level_Id) & ": Write to address" & Address'Image (Where) & "."); end if; This.Events.Writes := This.Events.Writes + 1; -- Get block in cache where to look up for given address. Get_Block (This => Simple_Cache'Class (This), Where => Where, Block => Block, Tag => Tag); -- Check if memory is loaded in one of the available slots. for i in This.State'Range (2) loop if This.State (Block, i).State in Full .. Dirty and then This.State (Block, i).Tag = Tag then if Debug then Ada.Text_IO.Put_Line ("HIT (slot" & Unsigned'Image (i) & ")!"); end if; -- Mark line as dirty, as we've written to it. This.State (Block, i).State := Dirty; This.Events.Hits := This.Events.Hits + 1; return; end if; end loop; if Debug then Ada.Text_IO.Put_Line ("MISS!"); end if; -- Cache miss. Whole line needs to be fetched. Fetch_Line (This => Simple_Cache'Class (This), Block => Block, Tag => Tag, State => Dirty); end Write; end Caches.Simple_Caches;
8/8-2.asm
userElaina/MicrocomputerLab
0
22736
<gh_stars>0 DATA SEGMENT STRING DB 'ERROR!DIVIDE BY ZERO!',0AH,0DH,'$' CODE SEGMENT ASSUME CS:CODE,DS:DATA MAIN PROC FAR LEA DX,INT0 MOV AX,CS MOV DS,AX MOV AL,32 MOV AH,25H INT 21H MOV AX,DATA MOV DS,AX MOV CX,10 MOV BL,6 A1: MOV AX,9 DIV BL ADD AL,30H MOV DL,AL MOV AH,2 INT 21H MOV DL,0DH MOV AH,2 INT 21H MOV DL,0AH MOV AH,2 INT 21H DEC BL CMP BL,0 JZ A2 LOOP A1 A3: MOV AH,4CH INT 21H A2: INT 32 JMP A3 MAIN ENDP INT0 PROC FAR LEA DX,STRING MOV AH,9 INT 21H MOV BL,3 IRET INT0 ENDP CODE ENDS END MAIN
oeis/337/A337503.asm
neoneye/loda-programs
11
88542
; A337503: Minimum number of painted cells in an n X n grid to avoid unpainted pentominoes. ; Submitted by <NAME> ; 0,0,3,5,8,13,17,24,31,39 pow $0,2 mov $2,$0 lpb $0 mov $0,$2 add $1,1 add $4,$2 add $4,2 lpb $4 add $0,$1 add $3,1 div $0,$3 sub $0,$3 add $1,$0 mov $4,$0 lpe lpe mov $0,$3
tests/regex_test_suite.adb
skordal/ada-regex
2
29906
<reponame>skordal/ada-regex<gh_stars>1-10 -- Ada regular expression library -- (c) <NAME> 2020-2021 <<EMAIL>> -- Report bugs and issues on <https://github.com/skordal/ada-regex> with Regex_Test_Cases; with AUnit.Test_Caller; package body Regex_Test_Suite is package Regex_Test_Caller is new AUnit.Test_Caller (Regex_Test_Cases.Test_Fixture); function Test_Suite return AUnit.Test_Suites.Access_Test_Suite is Retval : constant AUnit.Test_Suites.Access_Test_Suite := new AUnit.Test_Suites.Test_Suite; begin Retval.Add_Test (Regex_Test_Caller.Create ("single-character", Regex_Test_Cases.Test_Single_Character'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("kleene-closure", Regex_Test_Cases.Test_Kleene_Closure'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("concatenation", Regex_Test_Cases.Test_Concatenation'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("alternation-single", Regex_Test_Cases.Test_Alternation_Single'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("alternation-multiple", Regex_Test_Cases.Test_Alternation_Multiple'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("dragon-book", Regex_Test_Cases.Test_Dragon_Example'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-character-single", Regex_Test_Cases.Test_Any_Char_Single'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-character-optional", Regex_Test_Cases.Test_Any_Char_Optional'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-alternate", Regex_Test_Cases.Test_Any_Alternate'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("escaped-char", Regex_Test_Cases.Test_Escape_Seqs'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("quotes", Regex_Test_Cases.Test_Quotes'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("single-quotes", Regex_Test_Cases.Test_Single_Quotes'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("single-range", Regex_Test_Cases.Test_Single_Range'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("multiple-ranges", Regex_Test_Cases.Test_Multiple_Ranges'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("ranges-and-chars", Regex_Test_Cases.Test_Ranges_And_Chars'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("plus-operator", Regex_Test_Cases.Test_Plus_Operator'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("hexadecimal", Regex_Test_Cases.Test_Hexadecimal'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("question-mark", Regex_Test_Cases.Test_Question_Operator'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("partial-match", Regex_Test_Cases.Test_Partial_Matching'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("newlines", Regex_Test_Cases.Test_Newlines'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("syntax-tree-compile", Regex_Test_Cases.Test_Syntax_Tree_Compile'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("multiple-accept", Regex_Test_Cases.Test_Multiple_Accept'Access)); return Retval; end Test_Suite; end Regex_Test_Suite;
programs/oeis/021/A021509.asm
jmorken/loda
1
172927
<filename>programs/oeis/021/A021509.asm ; A021509: Decimal expansion of 1/505. ; 0,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1,9,8,0,1 lpb $0 mov $1,$0 trn $$4,4 lpe add $5,$$1 add $2,4 mov $$1,1 add $1,$2 add $5,$0 mov $$2,$2 add $$3,2 sub $$5,$1
5_KTMT_HN/learn_mips/toupper.asm
SummerSad/HCMUS-Lectures
8
162934
# 'a' -> 'A' .text main: # read char addi $v0, $zero, 12 syscall # function add $a0, $zero, $v0 # $v0 contains char read jal toupper # print char add $a0, $zero, $v0 addi $v0, $zero, 11 syscall # exit addi $v0, $zero, 10 syscall toupper: addi $v0, $a0, -32 jr $ra
library/fmGUI_Database/openFileMakerDatabase.applescript
NYHTC/applescript-fm-helper
1
4131
<filename>library/fmGUI_Database/openFileMakerDatabase.applescript -- openFileMakerDatabase({serverIP:"", dbName:"", mainDbName:"", customLinkReceiverScriptName:""}) -- <NAME>, NYHTC -- FIRST make sure it is open, then make sure it is showing a WINDOW. (* HISTORY: 1.4.1 - 2017-11-20 ( eshagdar ): disable logging 1.4 - narrowed scope 1.3 - now takes record param: {serverIP:, mainDbName:, customLinkReceiverScriptName:, dbName: } 1.2 - be sure to send the ShowWindow param. 1.1 - 1.0 - created REQUIRES: encodeTextForURL logConsole replaceSimple *) property debugMode : true property ScriptName : "openFileMakerDatabase_TEST" on run openFileMakerDatabase({mainDbName:"a00_TIMESSQUARE", dbName:"WUSHOP", serverIP:"192.168.254.6", customLinkReceiverScriptName:"ReceiveSomeLink_DO_NOT_RENAME"}) end run -------------------- -- START OF CODE -------------------- on openFileMakerDatabase(prefs) -- version 1.4.1 try set customURL to "htclink://AccessFile?FileName=" & dbName of prefs & "&Command=Open&SilentOpen=1&ShowWindow=1" set fmpURL to "FMP://" & serverIP of prefs & "/" & mainDbName of prefs & "?script=" & customLinkReceiverScriptName of prefs & "&param=" & encodeTextForURL(customURL, true, false) -- we must double-encode equals (%3D) and ampersand (%26) to work-around FileMaker bug: set fmpURL to replaceSimple({fmpURL, "%3D", "%253D"}) set fmpURL to replaceSimple({fmpURL, "%26", "%2526"}) --if debugMode then logConsole(ScriptName, "openFileMakerDatabase fmpURL: " & fmpURL) tell application "System Events" to open location fmpURL return true on error errMsg number errNum -- ANY error should return FALSE, as in "could not be opened" return errMsg --false end try end openFileMakerDatabase -------------------- -- END OF CODE -------------------- on encodeTextForURL(this_text, encode_URL_A, encode_URL_B) tell application "htcLib" to encodeTextForURL(this_text, encode_URL_A, encode_URL_B) end encodeTextForURL on logConsole(processName, consoleMsg) tell application "htcLib" to logConsole(processName, consoleMsg) end logConsole on replaceSimple(prefs) tell application "htcLib" to replaceSimple(prefs) end replaceSimple
srv_quit.adb
byllgrim/iictl
0
17349
<gh_stars>0 package body Srv_Quit is procedure Detect_Quits (Irc_Dir : String) is begin null; -- TODO detect and handle parting commands -- TODO for each server -- TODO continue reading out -- TODO purge if '/part' end Detect_Quits; end Srv_Quit;
src/text.asm
maziac/dezogif
2
245414
<reponame>maziac/dezogif ;======================================================== ; text.asm ;======================================================== ; Code to use in strings for positioning: AT x, y (in pixels) AT: equ 0x16 ; Routines that draw text on the ULA or layer2 screen. ; Can be used as substitute for the original ZX Spectrum ; text drawing routines. MODULE text ; Note: The loader copies the original spectrum font to the ROM_FONT address. ; This subroutine initializes the used font to ROM_FONT address. ; This is also the default value. ; IN: ; - ; OUT: ; - ; Changed registers: ; HL, DE, BC init: ; Store the used font address. The font starts normally at char index 0, so ; it's lower than the original address. ;ld hl,ROM_START+ROM_SIZE-ROM_FONT_SIZE-0x20*8 ld hl,MAIN_ADDR+0x2000-ROM_FONT_SIZE-0x20*8+MF_ORIGIN_ROM-MF.main_prg_copy ; Flow through ; Sets the font address. ; IN: ; HL = address of font to use. Contains 256 character, but the first 8 bytes are not used (0). ; OUT: ; - ; Changed registers: ; - set_font: ; Store the used font address. ld (font_address),hl ret ; ----------------------------------------------------------------------- ; ULA routines. ; Calculates the address in the screen from x and y position. ; Use this before you call any 'print' subroutine. ; In general this uses the PIXELDN instructions to calculate ; the screen address. But additionally it sets the B register ; with X mod 8, so that it can be used by the print sub routines. ; IN: ; E = x-position, [0..255] ; D = y-position, [0..191] ; OUT: ; HL = points to the corresponding address in the ULA screen. ; B = x mod 8 ; Changed registers: ; HL, B ula.calc_address: ; Get x mod 8 ld a,e and 00000111b ld b,a ; Calculate screen address PIXELAD ret ; Prints a single character at ULA screen address in HL. ; IN: ; HL = screen address to write to. ; B = x mod 8, i.e. the number to shift the character ; A = character to write. ; OUT: ; - ; Changed registers: ; DE, BC, IX ula.print_char: push hl push hl ; Calculate offset of character in font ld e,a ld d,8 ; 8 byte per character mul d,e ; Add to font start address ld hl,(font_address) add hl,de ld ix,hl ; ix points to character in font ; Now copy the character to the screen pop hl ld c,8 ; 8 byte per character .loop: ldi d,(ix) ; Load from font ld e,0 bsrl de,b ; shift ; XOR screen with character (1) ld a,(hl) xor d ld (hl),a ; Next address on screen inc l ; XOR screen with character (2) ld a,(hl) xor e ld (hl),a ; Correct x-position dec l ; Next line PIXELDN ; Next dec c jr nz,.loop ; Restore screen address pop hl ; Restore screen address ret ; Prints a complete string (until 0) at ULA screen address in HL. ; IN: ; HL = screen address to write to. ; DE = pointer to 0-terminated string ; B = x mod 8, i.e. the number to shift the character ; OUT: ; - ; Changed registers: ; HL, DE, C ula.print_string: .loop: ld a,(de) or a ret z ; Return on 0 ; Check for AT cp AT jr z,.at ; print one character push de call ula.print_char pop de ; Next inc de inc l ; Increase x-position jr .loop ret .at: ; AT x, y (pixels) inc de ldi a,(de) ; x ld l,a ldi a,(de) ; y push de ld e,l ld d,a call ula.calc_address pop de jr .loop ENDMODULE
separation/src/algorithmic.ads
gerr135/ada_gems
6
24401
-- -- This module contains interfaces implementing algorithms, but no data storage. -- -- Copyright (c) 2019, <NAME> <<EMAIL>> -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- package algorithmic is type Naive_Interface is interface; function Get_Data (NI : Naive_Interface) return Integer is abstract; procedure Set_Data (NI : in out Naive_Interface; data : Integer) is abstract; -- placeholder primitive intended to glue back class-wide method into type hierarchy -- the gueing has to be done in implementer types, by calling appropriate class-wide function Do_Complex_Calculation(NI : Naive_Interface; input : Integer) return Integer is abstract; type Optimized_Interface is interface and Naive_Interface; function Get_Extra_Data (OI : Optimized_Interface) return Integer is abstract; procedure Set_Extra_Data (OI : in out Optimized_Interface; data : Integer) is abstract; ------------------------------------------ -- class wide utility - algorithms function Do_Naive_Calculation (NIC : Naive_Interface'Class; input : Integer) return Integer; function Do_Optimized_Calculation(OIC : Optimized_Interface'Class; input : Integer) return Integer; -- Unfortunately we cannot use the same name for both methods -- In fact we can declare and implement 2 such methods of the same name -- but there is no way to use them, as compiler cannot decide which one to call.. -- -- Here we could really benefit from allowing non class-wide methods to be non-abstract -- or null in Ada, in case we need to override the code and use a uniform call interface.. -- This can be handy in some situations. -- Lets say, we intend to use our algorithms in some other object and we want to keep -- the invocation code simple. We could do a many-if or a switch invocation, but that -- can look rather messy for a more complex logic. Plus, what's even the point of having OOP -- if we cannot use it? -- -- One way to go about "fixing" this is by -- The ways to go about it are shown below type Unrelated_Interface is interface; -- could be made tagged null record just the same in our case -- keep it an interface for consistency (to follow through with ideology of algorithm and data separation) function do_some_calc_messy(UIC : Unrelated_Interface'Class; input : Integer; IFC : Naive_Interface'Class) return Integer; -- function do_some_calc_oop (UIC : Unrelated_Interface'Class; input : Integer; IFC : Naive_Interface'Class) return Integer; end algorithmic;
PICVisionPortable.X/c8test.asm
Picatout/PICVisionPortable
0
95722
CALL code_00E CALL code_066 CALL code_018 CALL code_066 CALL code_022 CALL code_02C code_00C: JP code_00C code_00E: LD V0, 2 LD V1, 21 ADD V0, V1 CALL code_030 RET code_018: LD V0, 23 LD V1, 45 SUB V0, V1 CALL code_030 RET code_022: LD V0, 21 LD V1, 10 SUB V0, V1 CALL code_030 RET code_02C: NOISE 4 RET code_030: CLS LD VE, VF LD V4, 0 LD V5, 0 CALL code_042 ADD V4, 4 LD V0, VE CALL code_042 RET code_042: LD I, data_078 LD B, V0 LD V3, 0 code_048: LD I, data_078 ADD I, V3 LD V0, [I] LD F, V0 DRW V4, V5, 5 ADD V4, 4 ADD V3, 1 SE V3, 3 JP code_048 RET code_05C: LD DT, V0 code_05E: LD V0, DT SE V0, 0 JP code_05E RET code_066: LD V0, 2 SKP V0 JP code_066 LD V0, 2 CALL code_05C LD V0, 2 code_072: SKNP V0 JP code_072 RET data_078: DB #00, #00, #00
Working Disassembly/General/Sprites/Level Misc/Map - Invisible Block.asm
TeamASM-Blur/Sonic-3-Blue-Balls-Edition
5
87812
dc.w word_1ECCC-Map_InvisibleBlock dc.w word_1ECE6-Map_InvisibleBlock dc.w word_1ED00-Map_InvisibleBlock word_1ECCC: dc.w 4 ; DATA XREF: ROM:0001ECC6o dc.b $F0, 5, 0, $1C, $FF, $F0 dc.b $F0, 5, 0, $1C, 0, 0 dc.b 0, 5, 0, $1C, $FF, $F0 dc.b 0, 5, 0, $1C, 0, 0 word_1ECE6: dc.w 4 ; DATA XREF: ROM:0001ECC6o dc.b $E0, 5, 0, $1C, $FF, $C0 dc.b $E0, 5, 0, $1C, 0, $30 dc.b $10, 5, 0, $1C, $FF, $C0 dc.b $10, 5, 0, $1C, 0, $30 word_1ED00: dc.w 4 ; DATA XREF: ROM:0001ECC6o dc.b $E0, 5, 0, $1C, $FF, $80 dc.b $E0, 5, 0, $1C, 0, $70 dc.b $10, 5, 0, $1C, $FF, $80 dc.b $10, 5, 0, $1C, 0, $70
forth/fibonacci.asm
baioc/S4PU
0
290
<reponame>baioc/S4PU ( S4PU-Forth Stack Fibonacci ) ( jump to main routine ) branch main ( x1 x2 -- x1 x2 x1 ) $over: lit 1 pick exit ( x1 x2 -- x1 x2 x1 x2 ) $2dup: over over exit ( f[n-2] f[n-1] -- f[n-2] f[n-1] f[n] ) nop $fibonacci: 2dup + exit $main: lit 0 ( stdout ) >R lit 0 dup R> dup 1+ >R ! lit 1 dup R> dup 1+ >R ! ( until stack overflow ) $loop: fibonacci dup R> dup 1+ >R ! branch loop
code/non1996/29.asm
KongoHuster/assembly-exercise
1
17734
DATA SEGMENT ARRAY DW 1, 2, 1 DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX, DATA MOV DS, AX MOV BX, 0 MOV DX, 0 MOV AX, ARRAY[BX] FIRST: CMP AX, ARRAY[BX + 2] JNZ SECOND INC DL SECOND: CMP AX, ARRAY[BX + 4] JNZ THIRD INC DL CMP DL, 2 JZ COUT THIRD: MOV AX, ARRAY[BX + 2] CMP AX, ARRAY[BX + 4] JNZ COUT INC DL COUT: MOV AH, 02H ADD DL, '0' INT 21H MOV AH, 04CH INT 21H CODE ENDS END START
oeis/197/A197189.asm
neoneye/loda-programs
11
179616
<reponame>neoneye/loda-programs<gh_stars>10-100 ; A197189: a(n) = 3*a(n-1) + 5*a(n-2), with a(0)=1, a(1)=2. ; Submitted by <NAME>(s2) ; 1,2,11,43,184,767,3221,13498,56599,237287,994856,4171003,17487289,73316882,307387091,1288745683,5403172504,22653245927,94975600301,398193030538,1669457093119,6999336432047,29345294761736,123032566445443,515824173145009,2162635351662242,9067026920711771,38014257520446523,159377907164898424,668205009096927887,2801504563115275781,11745538734830466778,49244139020067779239,206460110734355671607,865601027303405911016,3629103635581996091083,15215316043263017828329,63791466307699033940402 mov $3,1 lpb $0 sub $0,1 mov $2,$3 mul $2,7 mul $3,2 add $3,$1 add $1,$2 lpe mov $0,$3
src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx_neq_vwuc2_then_la1.asm
jbrandwood/kickc
2
95015
lda {c1}+1,x cmp #>{c2} bne {la1} lda {c1},x cmp #<{c2} bne {la1}
libsrc/_DEVELOPMENT/stdio/c/sccz80/fputc_unlocked_callee.asm
meesokim/z88dk
0
10652
; int fputc_unlocked(int c, FILE *stream) SECTION code_stdio PUBLIC fputc_unlocked_callee EXTERN asm_fputc_unlocked fputc_unlocked_callee: pop af pop ix pop de push af jp asm_fputc_unlocked
orka_simd/src/x86/gnat/orka-simd-avx-doubles-swizzle.ads
onox/orka
52
3133
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <<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 Orka.SIMD.SSE.Singles; with Orka.SIMD.SSE2.Doubles; package Orka.SIMD.AVX.Doubles.Swizzle is pragma Pure; use SIMD.SSE2.Doubles; use SIMD.SSE.Singles; function Shuffle_Within_Lanes (Left, Right : m256d; Mask : Unsigned_32) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_shufpd256"; -- Shuffle the 64-bit doubles in Left and Right per 128-bit lane -- using the given Mask. The first and third doubles are retrieved -- from Left. The second and fourth doubles are retrieved from Right: -- -- Result (1) := if Mask (a) = 0 then Left (1) else Left (2) -- Result (2) := if Mask (b) = 0 then Right (1) else Right (2) -- Result (3) := if Mask (c) = 0 then Left (3) else Left (4) -- Result (4) := if Mask (d) = 0 then Right (3) else Right (4) -- -- The compiler needs access to the Mask at compile-time, thus construct it -- as follows: -- -- Mask_a_b_c_d : constant Unsigned_32 := a or b * 2 or c * 4 or d * 8; -- -- or by simply writing 2#dcba#. a, b, c, and d must be either 0 or 1. -- a and c select the doubles to use from Left, b and d from Right. -- -- Warning: shuffling works per 128-bit lane. An element cannot be -- shuffled to the other half. function Unpack_High (Left, Right : m256d) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_unpckhpd256"; -- Unpack and interleave the 64-bit doubles from the upper halves of -- the 128-bit lanes of Left and Right as follows: -- Left (2), Right (2), Left (4), Right (4) function Unpack_Low (Left, Right : m256d) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_unpcklpd256"; -- Unpack and interleave the 64-bit doubles from the lower halves of -- the 128-bit lanes of Left and Right as follows: -- Left (1), Right (1), Left (3), Right (3) function Duplicate (Elements : m256d) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_movddup256"; -- Duplicate first and third element as follows: -- Elements (1), Elements (1), Elements (3), Elements (3) function Duplicate_LH (Elements : m256d) return m256d with Inline; function Duplicate_HL (Elements : m256d) return m256d with Inline; procedure Transpose (Matrix : in out m256d_Array) with Inline; function Transpose (Matrix : m256d_Array) return m256d_Array with Inline; function Blend (Left, Right : m256d; Mask : Unsigned_32) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendpd256"; -- Select elements from two sources (Left and Right) using a constant mask. -- -- The compiler needs access to the Mask at compile-time, thus construct it -- as follows: -- -- Mask_a_b_c_d : constant Unsigned_32 := a or b * 2 or c * 4 or d * 8; -- -- or by simply writing 2#dcba#. a, b, c, and d must be either 0 or 1. function Blend (Left, Right, Mask : m256d) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendvpd256"; -- Select elements from two sources (Left and Right) using a variable mask function Cast (Elements : m256d) return m128d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pd_pd256"; function Convert (Elements : m256d) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtpd2ps256"; function Convert (Elements : m128) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtps2pd256"; function Extract (Elements : m256d; Mask : Unsigned_32) return m128d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vextractf128_pd256"; -- Extract 128-bit from either the lower half (Mask = 0) or upper -- half (Mask = 1) function Insert (Left : m256d; Right : m128d; Mask : Unsigned_32) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vinsertf128_pd256"; -- Insert Right into the lower half (Mask = 0) or upper half (Mask = 1) function Permute (Elements : m128d; Mask : Unsigned_32) return m128d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vpermilpd"; -- Shuffle the 64-bit doubles in Elements. Similar to Shuffle (Elements, Elements, Mask): -- -- Result (1) := if Mask (a) = 0 then Elements (1) else Elements (2) -- Result (2) := if Mask (b) = 0 then Elements (1) else Elements (2) -- -- The compiler needs access to the Mask at compile-time, thus construct it -- as follows: -- -- Mask_a_b : constant Unsigned_32 := a or b * 2; -- -- or by simply writing 2#ba#. a and b must be either 0 or 1. function Permute_Within_Lanes (Elements : m256d; Mask : Unsigned_32) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vpermilpd256"; -- Shuffle elements within the two 128-bit lanes. Similar to -- Shuffle_Within_Lanes (Elements, Elements, Mask): -- -- Result (1) := if Mask (a) = 0 then Elements (1) else Elements (2) -- Result (2) := if Mask (b) = 0 then Elements (1) else Elements (2) -- Result (3) := if Mask (c) = 0 then Elements (3) else Elements (4) -- Result (4) := if Mask (d) = 0 then Elements (3) else Elements (4) -- -- The compiler needs access to the Mask at compile-time, thus construct it -- as follows: -- -- Mask_a_b_c_d : constant Unsigned_32 := a or b * 2 or c * 4 or d * 8; -- -- or by simply writing 2#dcba#. a, b, c, and d must be either 0 or 1. function Permute_Lanes (Left, Right : m256d; Mask : Unsigned_32) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vperm2f128_pd256"; -- Shuffle 128-bit lanes. -- -- Bits 1-2 of Mask are used to control which of the four 128-bit lanes -- to use for the lower half (128-bit) of the result. Bits 5-6 to select -- a lane for the upper half of the result: -- -- 0 => Left (1 .. 2) -- 1 => Left (3 .. 4) -- 2 => Right (1 .. 2) -- 3 => Right (3 .. 4) -- -- Bits 4 and 8 are used to zero the corresponding half (lower or upper). -- -- The compiler needs access to the Mask at compile-time, thus construct it -- as follows: -- -- Mask_l_u_zl_zu : constant Unsigned_32 := l or u * 16 or zl * 8 or zu * 128; -- -- u and l are numbers between 0 and 3 (see above). zu and zl are either 0 or 1 -- to zero a lane. end Orka.SIMD.AVX.Doubles.Swizzle;
programs/oeis/115/A115362.asm
karttu/loda
0
2888
<reponame>karttu/loda<gh_stars>0 ; A115362: Row sums of ((1,x) + (x,x^2))^(-1)*((1,x)-(x,x^2))^(-1) (using Riordan array notation). ; 1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,4,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,4,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,4,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1 add $0,1 gcd $0,1073741824 log $0,4 mov $1,$0 add $1,1
oeis/256/A256299.asm
neoneye/loda-programs
11
240565
; A256299: Apply the transformation 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 0 to the digits of n written in base 9, then convert back to base 10. ; Submitted by <NAME>(s2) ; 1,2,3,4,5,6,7,8,0,19,20,21,22,23,24,25,26,18,28,29,30,31,32,33,34,35,27,37,38,39,40,41,42,43,44,36,46,47,48,49,50,51,52,53,45,55,56,57,58,59,60,61,62,54,64,65,66,67,68,69 add $0,1 mov $3,1 lpb $0 mov $2,$0 sub $0,1 div $0,9 mod $2,9 mul $2,$3 add $2,$3 add $1,$2 mul $3,9 lpe mov $0,$1 sub $0,1
oeis/037/A037749.asm
neoneye/loda-programs
11
245802
; A037749: Base 9 digits are, in order, the first n terms of the periodic sequence with initial period 2,3,0,1. ; Submitted by <NAME> ; 2,21,189,1702,15320,137883,1240947,11168524,100516718,904650465,8141854185,73276687666,659490188996,5935411700967,53418705308703,480768347778328,4326915130004954 mov $2,2 lpb $0 sub $0,1 add $1,$2 mul $1,9 add $2,13 mod $2,4 lpe add $1,$2 mov $0,$1
programs/oeis/071/A071099.asm
neoneye/loda
22
16015
<filename>programs/oeis/071/A071099.asm ; A071099: a(n) = (n-1)*(n+3) - 2^n + 4. ; 0,2,5,8,9,4,-15,-64,-175,-412,-903,-1904,-3927,-7996,-16159,-32512,-65247,-130748,-261783,-523888,-1048135,-2096668,-4193775,-8388032,-16776591,-33553756,-67108135,-134216944,-268434615,-536870012,-1073740863,-2147482624,-4294966207,-8589933436,-17179867959,-34359737072,-68719475367,-137438952028,-274877905423,-549755812288,-1099511626095,-2199023253788,-4398046509255,-8796093020272,-17592186042391,-35184372086716,-70368744175455,-140737488353024,-281474976708255,-562949953418812,-1125899906840023,-2251799813682544,-4503599627367687,-9007199254738076,-18014398509478959,-36028797018960832,-72057594037924687,-144115188075852508,-288230376151708263,-576460752303419888,-1152921504606843255,-2305843009213690108,-4611686018427383935,-9223372036854771712,-18446744073709547391,-36893488147419098876,-73786976294838201975,-147573952589676408304,-295147905179352821095,-590295810358705646812,-1180591620717411298383,-2361183241434822601664,-4722366482869645208367,-9444732965739290421916,-18889465931478580849159,-37778931862957161703792,-75557863725914323413207,-151115727451828646832188,-302231454903657293670303,-604462909807314587346688,-1208925819614629174699615,-2417851639229258349405628,-4835703278458516698817815,-9671406556917033397642352,-19342813113834066795291591,-38685626227668133590590236,-77371252455336267181187695,-154742504910672534362382784,-309485009821345068724773135,-618970019642690137449554012,-1237940039285380274899115943,-2475880078570760549798239984,-4951760157141521099596488247,-9903520314283042199192984956,-19807040628566084398385978559,-39614081257132168796771965952,-79228162514264337593543940927,-158456325028528675187087891068,-316912650057057350374175791543,-633825300114114700748351592688 mov $1,$0 add $1,1 pow $1,2 mov $2,2 pow $2,$0 sub $1,$2 mov $0,$1
Appl/Games/Sokoban/sokobanApplication.asm
steakknife/pcgeos
504
176689
<reponame>steakknife/pcgeos COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992-1995. All rights reserved. GEOWORKS CONFIDENTIAL PROJECT: GEOS MODULE: Sokoban FILE: sokobanApplication.asm AUTHOR: <NAME>, Dec 20, 1993 ROUTINES: Name Description ---- ----------- MTD MSG_META_LOAD_OPTIONS Load our options from the ini file. MTD MSG_META_SAVE_OPTIONS Save our options to the ini file. INT SaveThemOptions Writes options to ini file. REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 12/20/93 Initial revision DESCRIPTION: Load/save options stuff. $Id: sokobanApplication.asm,v 1.1 97/04/04 15:12:59 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ApplicationCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SokobanAppLoadOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load our options from the ini file. CALLED BY: MSG_META_LOAD_OPTIONS PASS: *ds:si = SokobanApplicationClass object ds:di = SokobanApplicationClass instance data RETURN: nothing DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/ 6/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SokobanAppLoadOptions method dynamic SokobanApplicationClass, MSG_META_LOAD_OPTIONS .enter ; ; Call the superclass. ; mov di, offset SokobanApplicationClass call ObjCallSuperNoLock ; ; Get the ini file category. ; sub sp, INI_CATEGORY_BUFFER_SIZE movdw cxdx, sssp mov ax, MSG_META_GET_INI_CATEGORY call ObjCallInstanceNoLock mov ax, sp ; ; Get the background color. ; segmov ds, ss mov_tr si, ax ; ds:si = category mov cx, cs ; cx:dx = key mov dx, offset colorKey call InitFileReadInteger ; ax = value jc noColor mov es:[colorOption], ax jmp short doneColor noColor: mov es:[colorOption], C_WHITE ; default doneColor: ; ; Get the sound prefs. ; mov cx, cs ; cx:dx = key mov dx, offset soundKey call InitFileReadInteger ; ax = value jc noOption mov es:[soundOption], ax jmp short doneSound noOption: ; ; User hasn't previously saved options...use SSO_USE_DEFAULT. ; mov es:[soundOption], SSO_USE_DEFAULT doneSound: add sp, INI_CATEGORY_BUFFER_SIZE ; ; Set the view's background color based on the INI setting. ; call UpdateViewColor .leave ret colorKey char "color",0 soundKey char "sound",0 SokobanAppLoadOptions endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SokobanAppSaveOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Save our options to the ini file. CALLED BY: MSG_META_SAVE_OPTIONS PASS: *ds:si = SokobanApplicationClass object ds:di = SokobanApplicationClass instance data RETURN: nothing DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/ 6/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SokobanAppSaveOptions method dynamic SokobanApplicationClass, MSG_META_SAVE_OPTIONS .enter ; ; Call the superclass. ; mov di, offset SokobanApplicationClass call ObjCallSuperNoLock ; ; Mark busy. ; mov ax, MSG_GEN_APPLICATION_MARK_BUSY call ObjCallInstanceNoLock ; ; Save options to ini file. ; call SaveThemOptions ; ; Mark not busy. ; mov ax, MSG_GEN_APPLICATION_MARK_NOT_BUSY call ObjCallInstanceNoLock .leave ret SokobanAppSaveOptions endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SaveThemOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Writes options to ini file. CALLED BY: SokobanAppSaveOptions PASS: *ds:si = SokobanApplication object RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SaveThemOptions proc near uses ax,bx,cx,dx,si,di,bp,ds .enter ; ; Get the ini file category. ; sub sp, INI_CATEGORY_BUFFER_SIZE mov bp, sp ; ss:bp = category movdw cxdx, ssbp mov ax, MSG_META_GET_INI_CATEGORY call ObjCallInstanceNoLock segmov ds, ss if SET_BACKGROUND_COLOR ; ; Get the background color. ; push bp GetResourceHandleNS BackgroundColorSelector, bx mov si, offset BackgroundColorSelector mov di, mask MF_CALL mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION call ObjMessage ; ax = color pop bp xchg ax, bp ; bp = color, ss:ax = category ; ; Write background color to ini file. ; mov_tr si, ax ; ds:si = category mov cx, cs ; cx:dx = key mov dx, offset colorKey call InitFileWriteInteger endif ; SET_BACKGROUND_COLOR if PLAY_SOUNDS ; ; Get the sound options. ; push si GetResourceHandleNS SoundItemGroup, bx mov si, offset SoundItemGroup mov di, mask MF_CALL mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION call ObjMessage pop si ; ds:si = category mov_tr bp, ax ; bp = sound option ; ; Write sound option to ini file. ; mov cx, cs mov dx, offset soundKey call InitFileWriteInteger endif add sp, INI_CATEGORY_BUFFER_SIZE .leave ret SaveThemOptions endp ApplicationCode ends
scripts/ViridianForestSouthGate.asm
AmateurPanda92/pokemon-rby-dx
9
178609
<reponame>AmateurPanda92/pokemon-rby-dx ViridianForestSouthGate_Script: jp EnableAutoTextBoxDrawing ViridianForestSouthGate_TextPointers: dw ViridianForestEntranceText1 dw ViridianForestEntranceText2 ViridianForestEntranceText1: TX_FAR _ViridianForestEntranceText1 db "@" ViridianForestEntranceText2: TX_FAR _ViridianForestEntranceText2 db "@"
alloy/logical.als
koko1996/EECS-4302-Project
0
4536
<reponame>koko1996/EECS-4302-Project abstract sig Bool{} one sig True extends Bool {} one sig False extends Bool {} sig state { arg1: Bool, arg2: Bool, arg3: Bool } fun andGate (x, y: Bool) : state { {v: state | v.arg1 = x and v.arg2 = y and v.arg3 = (((x in True) and (y in True)) => True else False)} } fun orGate (x, y: Bool) : state { {v: state | v.arg1 = x and v.arg2 = y and v.arg3 = (((x in True) or (y in True)) => True else False)} } fun xorGate (x, y: Bool): state { {v: state | v.arg1 = x and v.arg2 = y and v.arg3 = ((andGate[x, y].arg3 in False) and (orGate[x, y].arg3 in True) => True else False)} } pred andCheck [preval1, preval2, preresult, postval1, postval2, postresult: Bool] { {v: state | v.arg1 = postval1 and v.arg2 = postval2 and v.arg3 = postresult} = andGate[preval1, preval2] } pred orCheck [preval1, preval2, preresult, postval1, postval2, postresult : Bool] { {v: state | v.arg1 = postval1 and v.arg2 = postval2 and v.arg3 = postresult} = orGate[preval1, preval2] } pred xorCheck [preval1, preval2, preresult, postval1, postval2, postresult : Bool] { {v: state | v.arg1 = postval1 and v.arg2 = postval2 and v.arg3 = postresult} = xorGate[preval1, preval2] } assert logicAnd { all v: state | (v.arg1 in True and v.arg2 in True) => andCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, True] else andCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, False] } assert logicOr { all v: state | (v.arg1 in True or v.arg2 in True) => orCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, True] else orCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, False] } assert logicXor { all v: state | ((v.arg1 in True and v.arg2 in False) or (v.arg1 in False and v.arg2 in True)) => xorCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, True] else xorCheck[v.arg1, v.arg2, v.arg3, v.arg1, v.arg2, False] } check logicAnd check logicOr check logicXor
libsrc/_DEVELOPMENT/temp/sp1/zx/c/sccz80/sp1_IterateUpdateRect.asm
meesokim/z88dk
0
164966
<gh_stars>0 ; void sp1_IterateUpdateRect(struct sp1_Rect *r, void *hook) ; CALLER linkage for function pointers SECTION code_temp_sp1 PUBLIC sp1_IterateUpdateRect EXTERN asm0_sp1_IterateUpdateRect sp1_IterateUpdateRect: pop bc pop ix pop hl push hl push hl push bc jp asm0_sp1_IterateUpdateRect
programs/oeis/212/A212598.asm
karttu/loda
1
167098
; A212598: a(n) = n - m!, where m is the largest number such that m! <= n. ; 0,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130 mov $1,$0 cal $0,48764 ; Largest factorial <= n. sub $0,1 add $2,$0 sub $1,$2
vendor/stdlib/src/Induction.agda
isabella232/Lemmachine
56
13222
------------------------------------------------------------------------ -- An abstraction of various forms of recursion/induction ------------------------------------------------------------------------ -- Note: The types in this module can perhaps be easier to understand -- if they are normalised. Note also that Agda can do the -- normalisation for you. module Induction where open import Relation.Unary -- A RecStruct describes the allowed structure of recursion. The -- examples in Induction.Nat should explain what this is all about. RecStruct : Set → Set₁ RecStruct a = Pred a → Pred a -- A recursor builder constructs an instance of a recursion structure -- for a given input. RecursorBuilder : ∀ {a} → RecStruct a → Set₁ RecursorBuilder {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal (Rec P) -- A recursor can be used to actually compute/prove something useful. Recursor : ∀ {a} → RecStruct a → Set₁ Recursor {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal P -- And recursors can be constructed from recursor builders. build : ∀ {a} {Rec : RecStruct a} → RecursorBuilder Rec → Recursor Rec build builder P f x = f x (builder P f x) -- We can repeat the exercise above for subsets of the type we are -- recursing over. SubsetRecursorBuilder : ∀ {a} → Pred a → RecStruct a → Set₁ SubsetRecursorBuilder {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ Rec P SubsetRecursor : ∀ {a} → Pred a → RecStruct a → Set₁ SubsetRecursor {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ P subsetBuild : ∀ {a} {Q : Pred a} {Rec : RecStruct a} → SubsetRecursorBuilder Q Rec → SubsetRecursor Q Rec subsetBuild builder P f x q = f x (builder P f x q)
autovectorization-tests/results/msvc19.28.29333-avx512/count_if.asm
clayne/toys
0
97878
_x$ = 8 ; size = 4 bool <lambda_b04b230afa1f9f4d5d61ec8317e156ba>::operator()(int)const PROC ; <lambda_b04b230afa1f9f4d5d61ec8317e156ba>::operator(), COMDAT mov eax, DWORD PTR _x$[esp-4] cmp eax, 42 ; 0000002aH je SHORT $LN3@operator cmp eax, -1 je SHORT $LN3@operator xor al, al ret 4 $LN3@operator: mov al, 1 ret 4 bool <lambda_b04b230afa1f9f4d5d61ec8317e156ba>::operator()(int)const ENDP ; <lambda_b04b230afa1f9f4d5d61ec8317e156ba>::operator() _x$ = 8 ; size = 4 bool <lambda_1ca96eb0ae177b0888bc5941a2950080>::operator()(int)const PROC ; <lambda_1ca96eb0ae177b0888bc5941a2950080>::operator(), COMDAT mov eax, DWORD PTR _x$[esp-4] cmp eax, 42 ; 0000002aH je SHORT $LN3@operator cmp eax, -1 je SHORT $LN3@operator xor al, al ret 4 $LN3@operator: mov al, 1 ret 4 bool <lambda_1ca96eb0ae177b0888bc5941a2950080>::operator()(int)const ENDP ; <lambda_1ca96eb0ae177b0888bc5941a2950080>::operator() _v$ = 8 ; size = 4 unsigned int count_if_epi32(std::vector<int,std::allocator<int> > const &) PROC ; count_if_epi32, COMDAT mov eax, DWORD PTR _v$[esp-4] push esi push edi xor esi, esi mov edi, DWORD PTR [eax+4] mov ecx, DWORD PTR [eax] cmp ecx, edi je SHORT $LN30@count_if_e $LL23@count_if_e: mov eax, DWORD PTR [ecx] cmp eax, 42 ; 0000002aH je SHORT $LN24@count_if_e cmp eax, -1 je SHORT $LN24@count_if_e xor dl, dl jmp SHORT $LN25@count_if_e $LN24@count_if_e: mov dl, 1 $LN25@count_if_e: test dl, dl lea eax, DWORD PTR [esi+1] cmove eax, esi add ecx, 4 mov esi, eax cmp ecx, edi jne SHORT $LL23@count_if_e $LN30@count_if_e: pop edi mov eax, esi pop esi ret 0 unsigned int count_if_epi32(std::vector<int,std::allocator<int> > const &) ENDP ; count_if_epi32 _v$ = 8 ; size = 4 unsigned int count_if_epi8(std::vector<signed char,std::allocator<signed char> > const &) PROC ; count_if_epi8, COMDAT mov eax, DWORD PTR _v$[esp-4] push esi push edi xor esi, esi mov edi, DWORD PTR [eax+4] mov ecx, DWORD PTR [eax] cmp ecx, edi je SHORT $LN30@count_if_e $LL23@count_if_e: movsx eax, BYTE PTR [ecx] cmp eax, 42 ; 0000002aH je SHORT $LN24@count_if_e cmp eax, -1 je SHORT $LN24@count_if_e xor dl, dl jmp SHORT $LN25@count_if_e $LN24@count_if_e: mov dl, 1 $LN25@count_if_e: test dl, dl lea eax, DWORD PTR [esi+1] cmove eax, esi inc ecx mov esi, eax cmp ecx, edi jne SHORT $LL23@count_if_e $LN30@count_if_e: pop edi mov eax, esi pop esi ret 0 unsigned int count_if_epi8(std::vector<signed char,std::allocator<signed char> > const &) ENDP ; count_if_epi8
data/mapObjects/route5.asm
adhi-thirumala/EvoYellow
0
97851
Route5Object: db $a ; border block db $5 ; warps db $1d, $a, $2, ROUTE_5_GATE db $1d, $9, $2, ROUTE_5_GATE db $21, $a, $0, ROUTE_5_GATE db $1b, $11, $0, PATH_ENTRANCE_ROUTE_5 db $15, $a, $0, DAYCAREM db $1 ; signs db $1d, $11, $1 ; Route5Text1 db $0 ; objects ; warp-to EVENT_DISP ROUTE_5_WIDTH, $1d, $a ; ROUTE_5_GATE EVENT_DISP ROUTE_5_WIDTH, $1d, $9 ; ROUTE_5_GATE EVENT_DISP ROUTE_5_WIDTH, $21, $a ; ROUTE_5_GATE EVENT_DISP ROUTE_5_WIDTH, $1b, $11 ; PATH_ENTRANCE_ROUTE_5 EVENT_DISP ROUTE_5_WIDTH, $15, $a ; DAYCAREM