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
prelude.agda
asajeffrey/finite-dtypes
6
9538
<filename>prelude.agda {-# OPTIONS --type-in-type #-} -- DANGER! postulate HOLE : {A : Set} -> A -- MORE DANGER! infixr 6 _\\ _/quad/ infixr 6 _\\&\indent infixl 2 &_ infixr 3 [_ infixr 5 _,_ infixr 7 _] infixr 5 _/xor/_ _/land/_ _/lor/_ _+_ _/ll/_ _/gg/_ infixr 5 /Sigma/ /Sigmap/ /Pi/ /Pip/ lambda tlambda infixr 2 id infixl 1 WHEN infixl 1 AND -- Definitions used in the main body data ⊥ : Set where record ⊤ : Set where constructor /epsilon/ record Π (A : Set) (B : A -> Set) : Set where constructor _,_ field fst : A field snd : B(fst) syntax Π A (\x -> B) = Π x ∈ A ∙ B _×_ : Set → Set → Set (A × B) = Π x ∈ A ∙ B data 𝔹 : Set where /false/ : 𝔹 /true/ : 𝔹 if_then_else_ : ∀ {A : 𝔹 -> Set} -> (b : 𝔹) -> A(/true/) -> A(/false/) -> A(b) if /false/ then T else F = F if /true/ then T else F = T ⟨_⟩ : 𝔹 → Set ⟨ /false/ ⟩ = ⊥ ⟨ /true/ ⟩ = ⊤ data ℕ : Set where zero : ℕ succ : ℕ -> ℕ one = succ zero two = succ one three = succ two four = succ three _+n_ : ℕ → ℕ → ℕ zero +n k = k (succ j) +n k = succ(j +n k) _⊔_ : ℕ → ℕ → ℕ zero ⊔ n = n succ m ⊔ zero = succ m succ m ⊔ succ n = succ (m ⊔ n) _↑_ : Set → ℕ → Set (A ↑ zero) = ⊤ (A ↑ (succ n)) = (A × (A ↑ n)) len : ∀ {k} → (𝔹 ↑ k) → ℕ len {k} n = k /IF/_/THEN/_/ELSE/_ : forall {A : 𝔹 -> Set} -> (b : 𝔹) -> A(/true/) -> A(/false/) -> A(b) /IF/ /false/ /THEN/ T /ELSE/ F = F /IF/ /true/ /THEN/ T /ELSE/ F = T -- Binary arithmetic indn : ∀ {k} {A : Set} → A → (A → A) → (𝔹 ↑ k) → A indn {zero} e f n = e indn {succ k} e f (/false/ , n) = indn e (λ x → f (f x)) n indn {succ k} e f (/true/ , n) = f (indn e (λ x → f (f x)) n) unary : ∀ {k} → (𝔹 ↑ k) → ℕ unary = indn zero succ /zerop/ : ∀ {k} → (𝔹 ↑ k) /zerop/ {zero} = /epsilon/ /zerop/ {succ n} = (/false/ , /zerop/) /epsilon/[_] : ∀ {k} → (n : 𝔹 ↑ k) → (𝔹 ↑ unary n) /epsilon/[ n ] = /zerop/ /onep/ : ∀ {k} → (𝔹 ↑ succ k) /onep/ = (/true/ , /zerop/) /one/ : (𝔹 ↑ one) /one/ = /onep/ /max/ : ∀ {k} → (𝔹 ↑ k) /max/ {zero} = /epsilon/ /max/ {succ n} = (/true/ , /max/) /IMPOSSIBLE/ : {A : Set} → {{p : ⊥}} → A /IMPOSSIBLE/ {A} {{()}} /not/ : 𝔹 → 𝔹 /not/ /false/ = /true/ /not/ /true/ = /false/ /extend/ : ∀ {k} → (𝔹 ↑ k) → (𝔹 ↑ succ k) /extend/ {zero} _ = (/false/ , /epsilon/) /extend/ {succ k} (b , n) = (b , /extend/ n) /succp/ : ∀ {k} → (𝔹 ↑ k) → (𝔹 ↑ succ k) /succp/ {zero} n = (/false/ , /epsilon/) /succp/ {succ k} (/false/ , n) = (/true/ , /extend/ n) /succp/ {succ k} (/true/ , n) = (/false/ , /succp/ n) _/land/_ : 𝔹 → 𝔹 → 𝔹 (/false/ /land/ b) = /false/ (/true/ /land/ b) = b _/lor/_ : 𝔹 → 𝔹 → 𝔹 (/false/ /lor/ b) = b (/true/ /lor/ b) = /true/ /neg/ : 𝔹 → 𝔹 /neg/ /false/ = /true/ /neg/ /true/ = /false/ _/xor/_ : 𝔹 → 𝔹 → 𝔹 (/false/ /xor/ b) = b (/true/ /xor/ /false/) = /true/ (/true/ /xor/ /true/) = /false/ /carry/ : 𝔹 → 𝔹 → 𝔹 → 𝔹 /carry/ /false/ a b = a /land/ b /carry/ /true/ a b = a /lor/ b addclen : ∀ {j k} → 𝔹 → (𝔹 ↑ j) → (𝔹 ↑ k) → ℕ addclen {zero} {k} /false/ m n = k addclen {zero} {zero} /true/ m n = one addclen {zero} {succ k} /true/ m (b , n) = succ (addclen b m n) addclen {succ j} {zero} /false/ m n = succ j addclen {succ j} {zero} /true/ (a , m) n = succ (addclen a m n) addclen {succ j} {succ k} c (a , m) (b , n) = succ (addclen (/carry/ c a b) m n) addlen : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) → ℕ addlen = addclen /false/ /addc/ : ∀ {j k} c → (m : 𝔹 ↑ j) → (n : 𝔹 ↑ k) → (𝔹 ↑ addclen c m n) /addc/ {zero} {k} /false/ m n = n /addc/ {zero} {zero} /true/ m n = /one/ /addc/ {zero} {succ k} /true/ m (b , n) = (/not/ b , /addc/ b m n) /addc/ {succ j} {zero} /false/ (a , m) n = (a , m) /addc/ {succ j} {zero} /true/ (a , m) n = (/not/ a , /addc/ a m n) /addc/ {succ j} {succ k} c (a , m) (b , n) = ((c /xor/ a /xor/ b) , (/addc/ (/carry/ c a b) m n)) _+_ : ∀ {j k} → (m : 𝔹 ↑ j) → (n : 𝔹 ↑ k) → (𝔹 ↑ addlen m n) _+_ = /addc/ /false/ /succ/ : ∀ {k} → (n : 𝔹 ↑ k) → (𝔹 ↑ addclen /true/ /epsilon/ n) /succ/ = /addc/ /true/ /epsilon/ dindn : (A : ∀ {k} → (𝔹 ↑ k) → Set) → (∀ {k} → A(/zerop/ {k})) → (∀ {k} (n : 𝔹 ↑ k) → A(n) → A(/succ/(n))) → ∀ {k} → (n : 𝔹 ↑ k) → A(n) dindn A e f {zero} n = e dindn A e f {succ k} (/false/ , n) = dindn (λ {j} m → A (/false/ , m)) e (λ {j} m x → f (/true/ , m) (f (/false/ , m) x)) n dindn A e f {succ k} (/true/ , n) = f (/false/ , n) (dindn (λ {j} m → A (/false/ , m)) e (λ {j} m x → f (/true/ , m) (f (/false/ , m) x)) n) _++_ : ∀ {A j k} → (A ↑ j) → (A ↑ k) → (A ↑ (j +n k)) _++_ {A} {zero} xs ys = ys _++_ {A} {succ j} (x , xs) ys = (x , xs ++ ys) _/ll/_ : ∀ {j k} → (𝔹 ↑ j) → (n : 𝔹 ↑ k) → (𝔹 ↑ (unary n +n j)) (m /ll/ n) = (/zerop/ {unary n} ++ m) _-n_ : ℕ → ℕ → ℕ (m -n zero) = m (zero -n n) = zero (succ m -n succ n) = (m -n n) drop : ∀ {A j} (k : ℕ) → (A ↑ j) → (A ↑ (j -n k)) drop zero xs = xs drop {A} {zero} (succ k) xs = /epsilon/ drop {A} {succ j} (succ k) (x , xs) = drop k xs _/gg/_ : ∀ {j k} → (𝔹 ↑ j) → (n : 𝔹 ↑ k) → (𝔹 ↑ (j -n unary n)) m /gg/ n = drop (unary n) m /truncate/ : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) /truncate/ {j} {zero} n = /epsilon/ /truncate/ {zero} {succ k} n = /zerop/ /truncate/ {succ j} {succ k} (a , n) = (a , /truncate/ n) -- Finite sets EncodableIn : ∀ {k} → Set → (𝔹 ↑ k) → Set EncodableIn = HOLE record FSet {k} (n : 𝔹 ↑ k) : Set where field Carrier : Set field .encodable : EncodableIn Carrier n open FSet public /sizeof/ : ∀ {k} → {n : 𝔹 ↑ k} → FSet(n) → (𝔹 ↑ k) /sizeof/ {k} {n} A = n data _≡_ {A : Set} (x : A) : A → Set where refl : (x ≡ x) data ℂ : Set where less : ℂ eq : ℂ gtr : ℂ isless : ℂ → Set isless less = ⊤ isless _ = ⊥ isleq : ℂ → Set isleq gtr = ⊥ isleq _ = ⊤ cmpb : 𝔹 → 𝔹 → ℂ cmpb /false/ /false/ = eq cmpb /false/ /true/ = less cmpb /true/ /false/ = gtr cmpb /true/ /true/ = eq cmpcb : 𝔹 → 𝔹 → ℂ → ℂ cmpcb /false/ /false/ c = c cmpcb /false/ /true/ c = less cmpcb /true/ /false/ c = gtr cmpcb /true/ /true/ c = c cmpc : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) → ℂ → ℂ cmpc {zero} {zero} m n c = c cmpc {zero} {succ k} m (b , n) c = cmpc m n (cmpcb /false/ b c) cmpc {succ j} {zero} (a , m) n c = cmpc m n (cmpcb a /false/ c) cmpc {succ j} {succ k} (a , m) (b , n) c = cmpc m n (cmpcb a b c) cmp : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) → ℂ cmp m n = cmpc m n eq _<_ : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) → Set (m < n) = isless (cmp m n) _≤_ : ∀ {j k} → (𝔹 ↑ j) → (𝔹 ↑ k) → Set (m ≤ n) with cmp m n (m ≤ n) | gtr = ⊥ (m ≤ n) | _ = ⊤ borrow : 𝔹 → 𝔹 → 𝔹 → 𝔹 borrow /false/ /false/ c = c borrow /false/ /true/ c = /true/ borrow /true/ /false/ c = /false/ borrow /true/ /true/ c = c subc : ∀ {j k} → (m : 𝔹 ↑ j) → (n : 𝔹 ↑ k) → 𝔹 → (𝔹 ↑ j) subc {zero} m n c = /epsilon/ subc {succ j} {zero} (a , m) n c = ((a /xor/ c) , (subc m n (borrow a /false/ c))) subc {succ j} {succ k} (a , m) (b , n) c = ((a /xor/ b /xor/ c) , (subc m n (borrow a b c))) _∸_ : ∀ {j k} → (m : 𝔹 ↑ j) → (n : 𝔹 ↑ k) → (𝔹 ↑ j) (m ∸ n) = subc m n /false/ /FSetp/ : ∀ {j k} {m : 𝔹 ↑ j} -> (n : 𝔹 ↑ k) -> {p : n < m} -> FSet(m) /FSetp/ n = record { Carrier = FSet(n); encodable = HOLE } /FSet/ : ∀ {k} -> (n : 𝔹 ↑ k) -> FSet(/succp/ n) /FSet/ n = record { Carrier = FSet(n); encodable = HOLE } /nothingp/ : ∀ {k} {n : 𝔹 ↑ k} → FSet(n) /nothingp/ = record { Carrier = ⊥; encodable = HOLE } /nothing/ : FSet(/epsilon/) /nothing/ = /nothingp/ /boolp/ : ∀ {k} {n : 𝔹 ↑ k} {p : /epsilon/ < n} → FSet(n) /boolp/ = record { Carrier = 𝔹; encodable = HOLE } /bool/ : FSet(/one/) /bool/ = /boolp/ /unitp/ : ∀ {k} {n : 𝔹 ↑ k} → FSet(n) /unitp/ = record { Carrier = ⊤; encodable = HOLE } /unit/ : FSet(/epsilon/) /unit/ = /unitp/ /bitsp/ : ∀ {j k} {m : 𝔹 ↑ j} → (n : 𝔹 ↑ k) -> {p : n ≤ m} -> FSet(m) /bitsp/ n = record { Carrier = (𝔹 ↑ unary n); encodable = HOLE } /bits/ : ∀ {k} (n : 𝔹 ↑ k) -> {p : n ≤ n} -> FSet(n) /bits/ n {p} = /bitsp/ n {p} /Pi/ : ∀ {j k} -> {m : 𝔹 ↑ j} {n : 𝔹 ↑ k} -> (A : FSet(m)) -> (Carrier(A) → FSet(n)) -> FSet(m + n) /Pi/ A B = record { Carrier = Π x ∈ (Carrier A) ∙ Carrier (B x) ; encodable = HOLE } syntax /Pi/ A (λ x → B) = /prod/ x /in/ A /cdot/ B /Pip/ : ∀ {j k} -> {m : 𝔹 ↑ j} -> {n : 𝔹 ↑ k} -> (A : FSet(m)) -> {p : m ≤ n} → (Carrier(A) → FSet(n ∸ m)) -> FSet(n) /Pip/ A B = record { Carrier = Π x ∈ (Carrier A) ∙ Carrier (B x) ; encodable = HOLE } syntax /Pip/ A (λ x → B) = /prodp/ x /in/ A /cdot/ B /Sigma/ : ∀ {j k} -> {m : 𝔹 ↑ j} {n : 𝔹 ↑ k} -> (A : FSet(m)) → ((Carrier A) → FSet(n)) -> FSet(n /ll/ m) /Sigma/ A B = record { Carrier = (x : Carrier A) → (Carrier (B x)) ; encodable = HOLE } syntax /Sigma/ A (λ x → B) = /sum/ x /in/ A /cdot/ B /Sigmap/ : ∀ {j k} -> {m : 𝔹 ↑ j} {n : 𝔹 ↑ k} -> (A : FSet(m)) → {p : m ≤ n} → ((Carrier A) → FSet(n /gg/ m)) -> FSet(n) /Sigmap/ A B = record { Carrier = (x : Carrier A) → (Carrier (B x)) ; encodable = HOLE } syntax /Sigmap/ A (λ x → B) = /sump/ x /in/ A /cdot/ B lambda : ∀ {A : Set} {B : A → Set} → (∀ x → B(x)) → (∀ x → B(x)) lambda f = f syntax lambda (λ x → e) = /fn/ x /cdot/ e tlambda : ∀ {k} {n : 𝔹 ↑ k} (A : FSet(n)) {B : Carrier A → Set} → (∀ x → B(x)) → (∀ x → B(x)) tlambda A f = f syntax tlambda A (λ x → e) = /fn/ x /in/ A /cdot/ e /indn/ : {h : ∀ {k} → (𝔹 ↑ k) → ℕ} → {g : ∀ {k} → (n : 𝔹 ↑ k) → (𝔹 ↑ h(n))} → (A : ∀ {k} → (n : 𝔹 ↑ k) → FSet(g(n))) → (∀ {k} → Carrier(A(/zerop/ {k}))) → (∀ {k} (n : 𝔹 ↑ k) → Carrier(A(n)) → Carrier(A(/one/ + n))) → ∀ {k} → (n : 𝔹 ↑ k) → Carrier(A(n)) /indn/ A e f = dindn (λ n → Carrier(A(n))) e (λ n x → g n (f n x)) where g : ∀ {k} → (n : 𝔹 ↑ k) → Carrier(A(/one/ + n)) → Carrier(A(/succ/(n))) g {zero} n x = x g {succ k} (/false/ , n) x = x g {succ k} (/true/ , n) x = x -- Stuff to help with LaTeX layout id : ∀ {k} → {n : 𝔹 ↑ k} → (A : FSet(n)) → (Carrier A) → (Carrier A) id A x = x typeof : ∀ {k} → {n : 𝔹 ↑ k} → (A : FSet(n)) → (Carrier A) → Set typeof A x = Carrier A WHEN : ∀ {k} → {n : 𝔹 ↑ k} → (A : FSet(n)) → {B : Carrier A → Set} → (∀ x → B(x)) → (∀ x → B(x)) WHEN A F = F AND : ∀ {k} → {n : 𝔹 ↑ k} → (A : FSet(n)) → {B : Carrier A → Set} → (∀ x → B(x)) → (∀ x → B(x)) AND A F = F [_ : ∀ {A k} → (A ↑ k) → (A ↑ k) [_ x = x _] : ∀ {A} → A → (A ↑ one) _] x = (x , /epsilon/) _\\ : forall {A : Set} -> A -> A x \\ = x _/quad/ : forall {A : Set} -> A -> A x /quad/ = x _\\&\indent : forall {A : Set} -> A -> A x \\&\indent = x &_ : forall {A : Set} -> A -> A & x = x syntax id A x = x &/in/ A syntax WHEN A (λ x → B) = B &/WHEN/ x /in/ A syntax AND A (λ x → B) = B /AND/ x /in/ A
programs/oeis/204/A204423.asm
neoneye/loda
22
169246
<reponame>neoneye/loda ; A204423: Infinite matrix: f(i,j)=(2i+j mod 3), by antidiagonals. ; 0,1,2,2,0,1,0,1,2,0,1,2,0,1,2,2,0,1,2,0,1,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,2,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,2,0,1,2,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2 seq $0,51162 ; Triangle T(n,k) = n+k, n >= 0, 0 <= k <= n. mod $0,3
oeis/045/A045465.asm
neoneye/loda-programs
11
23659
<gh_stars>10-100 ; A045465: Primes congruent to {0, 1} mod 7. ; Submitted by <NAME> ; 7,29,43,71,113,127,197,211,239,281,337,379,421,449,463,491,547,617,631,659,673,701,743,757,827,883,911,953,967,1009,1051,1093,1163,1289,1303,1373,1429,1471,1499,1583,1597,1667,1709,1723,1877,1933,2003,2017,2087,2129,2143,2213,2269,2297,2311,2339,2381,2423,2437,2521,2549,2591,2633,2647,2689,2731,2801,2843,2857,2927,2969,3011,3067,3109,3137,3221,3319,3347,3361,3389,3529,3557,3571,3613,3697,3739,3767,3823,3851,3907,4019,4159,4201,4229,4243,4271,4327,4397,4481,4523 mov $2,$0 sub $0,1 mov $1,2 add $2,1 pow $2,2 mov $4,1 lpb $2 add $1,5 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,2 mov $5,$4 mov $4,$0 max $4,0 lpb $5 cmp $4,$0 mul $2,$4 trn $5,2 lpe lpe div $1,2 sub $1,2 mul $1,2 mov $0,$1 add $0,3
programs/oeis/322/A322598.asm
karttu/loda
0
174816
; A322598: a(n) is the number of unlabeled rank-3 graded lattices with 3 coatoms and n atoms. ; 1,3,8,13,20,29,39,50,64,78,94,112,131,151,174,197,222,249,277,306,338,370,404,440,477,515,556,597,640,685,731,778,828,878,930,984,1039,1095,1154,1213,1274,1337,1401,1466,1534,1602,1672,1744,1817,1891,1968,2045,2124,2205,2287,2370,2456,2542,2630,2720,2811,2903,2998,3093,3190,3289,3389,3490,3594,3698,3804,3912,4021,4131,4244,4357,4472,4589,4707,4826,4948,5070,5194,5320,5447,5575,5706,5837,5970,6105,6241,6378,6518,6658,6800,6944,7089,7235,7384,7533,7684,7837,7991,8146,8304,8462,8622,8784,8947,9111,9278,9445,9614,9785,9957,10130,10306,10482,10660,10840,11021,11203,11388,11573,11760,11949,12139,12330,12524,12718,12914,13112,13311,13511,13714,13917,14122,14329,14537,14746,14958,15170,15384,15600,15817,16035,16256,16477,16700,16925,17151,17378,17608,17838,18070,18304,18539,18775,19014,19253,19494,19737,19981,20226,20474,20722,20972,21224,21477,21731,21988,22245,22504,22765,23027,23290,23556,23822,24090,24360,24631,24903,25178,25453,25730,26009,26289,26570,26854,27138,27424,27712,28001,28291,28584,28877,29172,29469,29767,30066,30368,30670,30974,31280,31587,31895,32206,32517,32830,33145,33461,33778,34098,34418,34740,35064,35389,35715,36044,36373,36704,37037,37371,37706,38044,38382,38722,39064,39407,39751,40098,40445,40794,41145,41497,41850,42206,42562,42920,43280,43641,44003,44368,44733,45100,45469,45839,46210,46584,46958 mov $19,$0 mov $21,$0 add $21,1 lpb $21,1 clr $0,19 mov $0,$19 sub $21,1 sub $0,$21 mov $16,$0 mov $18,$0 add $18,1 lpb $18,1 mov $0,$16 sub $18,1 sub $0,$18 mov $1,$0 mod $1,3 mov $3,$0 gcd $3,2 add $1,$3 sub $1,1 add $17,$1 lpe add $20,$17 lpe mov $1,$20
source/uaflex/uaflex-generator-tables.adb
svn2github/matreshka
24
12489
<reponame>svn2github/matreshka<filename>source/uaflex/uaflex-generator-tables.adb<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2017, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with UAFLEX.Nodes; with Ada.Containers; with Ada.Containers.Ordered_Maps; with Ada.Strings.Wide_Wide_Fixed; with Ada.Wide_Wide_Text_IO; with League.Character_Sets; with Matreshka.Internals.Unicode.Ucd; with Matreshka.Internals.Graphs; -- with Debug; package body UAFLEX.Generator.Tables is package Char_Set_Vectors renames Matreshka.Internals.Finite_Automatons.Vectors; package Start_Maps renames Matreshka.Internals.Finite_Automatons.Start_Maps; package State_Maps renames Matreshka.Internals.Finite_Automatons.State_Maps; subtype State is Matreshka.Internals.Finite_Automatons.State; use type State; subtype Character_Class is Matreshka.Internals.Graphs.Edge_Identifier'Base; subtype First_Stage_Index is Matreshka.Internals.Unicode.Ucd.First_Stage_Index; subtype Second_Stage_Index is Matreshka.Internals.Unicode.Ucd.Second_Stage_Index; type First_Stage_Array is array (First_Stage_Index) of Natural; type Second_Stage_Array is array (Second_Stage_Index) of Character_Class; package Second_Stage_Array_Maps is new Ada.Containers.Ordered_Maps (Second_Stage_Array, Natural); -------- -- Go -- -------- procedure Go (DFA : Matreshka.Internals.Finite_Automatons.DFA; Dead_End_Map : State_Map; First_Dead_End : Matreshka.Internals.Finite_Automatons.State; First_Final : Matreshka.Internals.Finite_Automatons.State; Unit : League.Strings.Universal_String; File : String; Types : League.Strings.Universal_String; Scanner : League.Strings.Universal_String; Classes : Matreshka.Internals.Finite_Automatons.Vectors.Vector) is pragma Unreferenced (Types); procedure P (Text : Wide_Wide_String); procedure N (Text : Wide_Wide_String); procedure Print_Char_Classes; procedure Print_Switch; procedure Print_Rules; procedure Print_Classes (Id : Matreshka.Internals.Graphs.Edge_Identifier; Count : in out Natural); function Get_Second (X : First_Stage_Index) return Second_Stage_Array; Output : Ada.Wide_Wide_Text_IO.File_Type; Length : Natural := 0; -- Length of last output line Indent : Natural := 0; -- Last indent ---------------- -- Get_Second -- ---------------- function Get_Second (X : First_Stage_Index) return Second_Stage_Array is Result : Second_Stage_Array := (others => 0); Char : Wide_Wide_Character; begin for J in Result'Range loop Char := Wide_Wide_Character'Val (Natural (X) * 256 + Natural (J)); for C in Classes.First_Index .. Classes.Last_Index loop if Classes.Element (C).Has (Char) then Result (J) := C; exit; end if; end loop; end loop; return Result; end Get_Second; procedure N (Text : Wide_Wide_String) is use Ada.Strings.Wide_Wide_Fixed; begin if Length = 0 then Indent := Ada.Strings.Wide_Wide_Fixed.Index_Non_Blank (Text & "."); end if; if Length + Text'Length > 74 then Ada.Wide_Wide_Text_IO.Put_Line (Output, Trim (Text, Ada.Strings.Right)); Ada.Wide_Wide_Text_IO.Put (Output, Indent * ' '); Length := Indent; else Ada.Wide_Wide_Text_IO.Put (Output, Text); Length := Length + Text'Length; end if; end N; procedure P (Text : Wide_Wide_String) is begin if Length = 0 then Indent := Ada.Strings.Wide_Wide_Fixed.Index_Non_Blank (Text); end if; Ada.Wide_Wide_Text_IO.Put_Line (Output, Text); Length := 0; end P; procedure Print_Char_Classes is use Second_Stage_Array_Maps; use type First_Stage_Index; use type Second_Stage_Index; Known : Map; Pos : Cursor; First : First_Stage_Array; Second : Second_Stage_Array; begin for F in First_Stage_Index loop Second := Get_Second (F); Pos := Known.Find (Second); if Has_Element (Pos) then First (F) := Element (Pos); else First (F) := Natural (Known.Length); Known.Insert (Second, First (F)); P (" S_" & Image (First (F)) & " : aliased constant Second_Stage_Array :="); for J in Second_Stage_Index'Range loop if J = 0 then N (" ("); elsif J mod 8 = 0 then P (""); N (" "); else N (" "); end if; N (Image (Natural (Second (J)))); if J = Second_Stage_Index'Last then P (");"); P (""); else N (","); end if; end loop; end if; end loop; P (" First : constant First_Stage_Array :="); for F in First_Stage_Index loop if F = 0 then N (" ("); elsif F mod 4 = 0 then P (""); N (" "); else N (" "); end if; N ("S_" & Image (First (F)) & "'Access"); if F = First_Stage_Index'Last then P (");"); P (""); else N (","); end if; end loop; end Print_Char_Classes; procedure Print_Classes (Id : Matreshka.Internals.Graphs.Edge_Identifier; Count : in out Natural) is Set : constant League.Character_Sets.Universal_Character_Set := DFA.Edge_Char_Set.Element (Id); First : Boolean := True; begin for J in Classes.First_Index .. Classes.Last_Index loop if Classes.Element (J).Is_Subset (Set) then if First then First := False; else N (" | "); end if; N (Image (Positive (J))); Count := Count + 1; end if; end loop; end Print_Classes; procedure Print_Rules is procedure Each_Rule (Cursor : State_Maps.Cursor); Count : Natural := 0; procedure Each_Rule (Cursor : State_Maps.Cursor) is begin if Count = 0 then N (" ("); elsif Count mod 6 = 0 then P (","); N (" "); else N (", "); end if; N (Image (Natural (Dead_End_Map (State_Maps.Key (Cursor))) - 1) & " => " & Image (State_Maps.Element (Cursor))); Count := Count + 1; end Each_Rule; begin P (" Rule_Table : constant array (State range " & Image (Positive (First_Final) - 1) & " .. " & Image (Positive (DFA.Graph.Node_Count) - 1) & ") of Rule_Index :="); DFA.Final.Iterate (Each_Rule'Access); P (");"); P (""); end Print_Rules; procedure Print_Switch is First : Boolean := True; begin P (" Switch_Table : constant array " & "(State range 0 .. " & Image (Positive (First_Dead_End) - 2) & ","); P (" Character_Class range 0 .. " & Image (Positive (Classes.Length)) & ") of State :="); for J in 1 .. DFA.Graph.Node_Count loop declare use type Matreshka.Internals.Graphs.Edge_Index; Count : Natural := 0; Edge : Matreshka.Internals.Graphs.Edge; Item : constant Matreshka.Internals.Graphs.Node := DFA.Graph.Get_Node (J); F : constant Matreshka.Internals.Graphs.Edge_Index := Item.First_Edge_Index; L : constant Matreshka.Internals.Graphs.Edge_List_Length := Item.Last_Edge_Index; begin if Dead_End_Map (J) < First_Dead_End then if First then N (" ("); First := False; else P (","); N (" "); end if; P (Image (Positive (Dead_End_Map (J)) - 1) & " =>"); for K in F .. L loop Edge := DFA.Graph.Get_Edge (K); if K = F then N (" ("); else N (" "); end if; Print_Classes (Edge.Edge_Id, Count); N (" =>"); N (State'Wide_Wide_Image (Dead_End_Map (Edge.Target_Node.Index) - 1)); if K /= L then N (","); end if; end loop; if Count /= Positive (Classes.Length) + 1 then if Count = 0 then N (" ("); elsif Length > 65 then P (""); N (" , "); else N (", "); end if; N ("others =>" & State'Wide_Wide_Image (DFA.Graph.Node_Count)); end if; N (")"); end if; end; end loop; P (");"); P (""); end Print_Switch; begin Ada.Wide_Wide_Text_IO.Create (Output, Name => File); P ("with Matreshka.Internals.Unicode.Ucd;"); P (""); P ("separate (" & Scanner.To_Wide_Wide_String & ")"); P ("package body " & Unit.To_Wide_Wide_String & " is"); P (" subtype First_Stage_Index is"); P (" Matreshka.Internals.Unicode.Ucd.First_Stage_Index;"); P (""); P (" subtype Second_Stage_Index is"); P (" Matreshka.Internals.Unicode.Ucd.Second_Stage_Index;"); P (""); P (" type Second_Stage_Array is array (Second_Stage_Index) " & "of Character_Class;"); P (""); P (" type Second_Stage_Array_Access is"); P (" not null access constant Second_Stage_Array;"); P (""); P (" type First_Stage_Array is"); P (" array (First_Stage_Index) of Second_Stage_Array_Access;"); P (""); Print_Char_Classes; Print_Switch; Print_Rules; P (" function Rule (S : State) return Rule_Index is"); P (" begin"); P (" return Rule_Table (S);"); P (" end Rule;"); P (""); P (" function Switch (S : State; Class : Character_Class) " & "return State is"); P (" begin"); P (" return Switch_Table (S, Class);"); P (" end Switch;"); P (""); P (" function To_Class (Value : " & "Matreshka.Internals.Unicode.Code_Point)"); P (" return Character_Class"); P (" is"); P (" function Element is new " & "Matreshka.Internals.Unicode.Ucd.Generic_Element"); P (" (Character_Class, Second_Stage_Array,"); P (" Second_Stage_Array_Access, First_Stage_Array);"); P (" begin"); P (" return Element (First, Value);"); P (" end To_Class;"); P (""); P ("end " & Unit.To_Wide_Wide_String & ";"); end Go; --------------------------- -- Remap_Final_Dead_Ends -- --------------------------- procedure Map_Final_Dead_Ends (DFA : Matreshka.Internals.Finite_Automatons.DFA; First_Dead_End : out Matreshka.Internals.Finite_Automatons.State; First_Final : out Matreshka.Internals.Finite_Automatons.State; Dead_End_Map : out State_Map) is Dead_End_Index : Matreshka.Internals.Finite_Automatons.State; Final_Index : Matreshka.Internals.Finite_Automatons.State; Free_Index : Matreshka.Internals.Finite_Automatons.State; begin First_Dead_End := Dead_End_Map'Last + 1; First_Final := First_Dead_End; for J in Dead_End_Map'Range loop if DFA.Final.Contains (J) then First_Final := First_Final - 1; if DFA.Graph.Get_Node (J).Outgoing_Edges'Length = 0 then First_Dead_End := First_Dead_End - 1; end if; end if; end loop; Dead_End_Index := First_Dead_End; Final_Index := First_Final; Free_Index := 1; for J in Dead_End_Map'Range loop if not DFA.Final.Contains (J) then Dead_End_Map (J) := Free_Index; Free_Index := Free_Index + 1; elsif DFA.Graph.Get_Node (J).Outgoing_Edges'Length > 0 then Dead_End_Map (J) := Final_Index; Final_Index := Final_Index + 1; else Dead_End_Map (J) := Dead_End_Index; Dead_End_Index := Dead_End_Index + 1; end if; end loop; end Map_Final_Dead_Ends; ----------------------- -- Split_To_Distinct -- ----------------------- procedure Split_To_Distinct (List : Char_Set_Vectors.Vector; Result : out Char_Set_Vectors.Vector) is begin for J in List.First_Index .. List.Last_Index loop declare use League.Character_Sets; Rest : Universal_Character_Set := List.Element (J); begin for K in Result.First_Index .. Result.Last_Index loop declare Item : constant Universal_Character_Set := Result.Element (K); Intersection : constant Universal_Character_Set := Item and Rest; begin if not Intersection.Is_Empty then declare Extra : constant Universal_Character_Set := Item - Rest; begin if not Extra.Is_Empty then Result.Append (Extra); end if; Result.Replace_Element (K, Intersection); Rest := Rest - Item; exit when Rest.Is_Empty; end; end if; end; end loop; if not Rest.Is_Empty then Result.Append (Rest); end if; end; end loop; end Split_To_Distinct; ----------- -- Types -- ----------- procedure Types (DFA : Matreshka.Internals.Finite_Automatons.DFA; Dead_End_Map : State_Map; First_Dead_End : Matreshka.Internals.Finite_Automatons.State; First_Final : Matreshka.Internals.Finite_Automatons.State; Unit : League.Strings.Universal_String; File : String; Classes : Char_Set_Vectors.Vector) is use type Ada.Containers.Count_Type; procedure P (Text : Wide_Wide_String); procedure Print_Start (Cursor : Start_Maps.Cursor); Output : Ada.Wide_Wide_Text_IO.File_Type; procedure P (Text : Wide_Wide_String) is begin -- Ada.Wide_Wide_Text_IO.Put_Line (Text); Ada.Wide_Wide_Text_IO.Put_Line (Output, Text); end P; procedure Print_Start (Cursor : Start_Maps.Cursor) is begin P (" " & Start_Maps.Key (Cursor).To_Wide_Wide_String & " : constant State :=" & State'Wide_Wide_Image (Dead_End_Map (Start_Maps.Element (Cursor)) - 1) & ";"); end Print_Start; begin Ada.Wide_Wide_Text_IO.Create (Output, Name => File); -- Debug.Print_Character_Classes (Classes); P ("package " & Unit.To_Wide_Wide_String & " is"); P (" pragma Preelaborate;"); P (""); P (" type State is mod +" & Image (Positive (DFA.Graph.Node_Count + 1)) & ";"); P (" subtype Looping_State is State range 0 .. " & Image (Positive (First_Dead_End) - 2) & ";"); P (" subtype Final_State is State range " & Image (Positive (First_Final) - 1) & " .. State'Last - 1;"); P (""); P (" Error_State : constant State := State'Last;"); P (""); DFA.Start.Iterate (Print_Start'Access); P (""); P (" type Character_Class is mod +" & Image (Positive (Classes.Length + 1)) & ";"); P (""); P (" type Rule_Index is range 0 .." & Natural'Wide_Wide_Image (Nodes.Rules.Length) & ";"); P (""); P ("end " & Unit.To_Wide_Wide_String & ";"); end Types; end UAFLEX.Generator.Tables;
tests/roms/simplified_state_changes.asm
AndreaOrru/Gilgamesh
25
246577
incsrc lorom.asm org $8000 reset: rep #$30 ; $008000 jsr double_state_change ; $008002 lda #$FFFF ; $008005 ldx #$FFFF ; $008008 .loop: jmp .loop ; $00800B double_state_change: bcs .return2 ; $00800E .return1: rep #$20 ; $008010 rts ; $008012 .return2: rep #$10 ; $008013 rts ; $008015
app/assets/images/materials/course4/rEqualsItsClosureBuggy.als
se-unrc/cacic-site
0
564
sig A { } one sig Rel { r : A -> A } fact reflexive { A<:iden in Rel.r } fact symmetric { Rel.r = ~(Rel.r) } assert rEqualsItsClosure { r = A<:*(Rel.r) } check rEqualsItsClosure for 5
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2829.asm
ljhsiun2/medusa
9
26734
<filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2829.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %rcx push %rdi push %rdx lea addresses_WT_ht+0x3ce4, %rcx nop nop sub %rdi, %rdi and $0xffffffffffffffc0, %rcx movntdqa (%rcx), %xmm3 vpextrq $0, %xmm3, %r12 nop and %r14, %r14 lea addresses_A_ht+0xaaa4, %rcx nop nop cmp $6638, %r10 mov $0x6162636465666768, %r13 movq %r13, %xmm5 movups %xmm5, (%rcx) nop nop nop nop and $27682, %r13 lea addresses_UC_ht+0x8464, %r13 add %r14, %r14 mov (%r13), %r12w nop nop nop xor %r12, %r12 lea addresses_A_ht+0x2e64, %rcx nop nop nop and $20766, %rdx movw $0x6162, (%rcx) nop nop nop nop nop add $64731, %r14 lea addresses_UC_ht+0x1c53a, %rcx nop and %rdi, %rdi mov $0x6162636465666768, %r12 movq %r12, (%rcx) nop nop nop add %rdi, %rdi lea addresses_WC_ht+0xdcb7, %r10 clflush (%r10) nop nop dec %r14 movups (%r10), %xmm5 vpextrq $0, %xmm5, %r13 cmp $50144, %r10 lea addresses_WT_ht+0x8064, %r12 xor %r13, %r13 movw $0x6162, (%r12) nop nop cmp $40180, %r13 pop %rdx pop %rdi pop %rcx pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r15 push %rcx push %rsi // Store lea addresses_WC+0x196a4, %rcx sub %rsi, %rsi movb $0x51, (%rcx) nop nop nop and $27135, %rcx // Load lea addresses_WC+0x18564, %r10 nop and $16377, %r13 mov (%r10), %r14w nop nop nop nop cmp $41014, %r10 // Faulty Load lea addresses_normal+0x19064, %r14 sub $50818, %rcx movups (%r14), %xmm2 vpextrq $1, %xmm2, %r13 lea oracles, %r10 and $0xff, %r13 shlq $12, %r13 mov (%r10,%r13,1), %r13 pop %rsi pop %rcx pop %r15 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 16, 'same': True, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
programs/oeis/212/A212837.asm
karttu/loda
0
93568
<reponame>karttu/loda ; A212837: Number of 0..n arrays of length 4 with 0 never adjacent to n. ; 2,41,178,497,1106,2137,3746,6113,9442,13961,19922,27601,37298,49337,64066,81857,103106,128233,157682,191921,231442,276761,328418,386977,453026,527177,610066,702353,804722,917881,1042562,1179521,1329538,1493417,1671986,1866097,2076626,2304473,2550562,2815841,3101282,3407881,3736658,4088657,4464946,4866617,5294786,5750593,6235202,6749801,7295602,7873841,8485778,9132697,9815906,10536737,11296546,12096713,12938642,13823761,14753522,15729401,16752898,17825537,18948866,20124457,21353906,22638833,23980882,25381721,26843042,28366561,29954018,31607177,33327826,35117777,36978866,38912953,40921922,43007681,45172162,47417321,49745138,52157617,54656786,57244697,59923426,62695073,65561762,68525641,71588882,74753681,78022258,81396857,84879746,88473217,92179586,96001193,99940402,103999601,108181202,112487641,116921378,121484897,126180706,131011337,135979346,141087313,146337842,151733561,157277122,162971201,168818498,174821737,180983666,187307057,193794706,200449433,207274082,214271521,221444642,228796361,236329618,244047377,251952626,260048377,268337666,276823553,285509122,294397481,303491762,312795121,322310738,332041817,341991586,352163297,362560226,373185673,384042962,395135441,406466482,418039481,429857858,441925057,454244546,466819817,479654386,492751793,506115602,519749401,533656802,547841441,562306978,577057097,592095506,607425937,623052146,638977913,655207042,671743361,688590722,705753001,723234098,741037937,759168466,777629657,796425506,815560033,835037282,854861321,875036242,895566161,916455218,937707577,959327426,981318977,1003686466,1026434153,1049566322,1073087281,1097001362,1121312921,1146026338,1171146017,1196676386,1222621897,1248987026,1275776273,1302994162,1330645241,1358734082,1387265281,1416243458,1445673257,1475559346,1505906417,1536719186,1568002393,1599760802,1631999201,1664722402,1697935241,1731642578,1765849297,1800560306,1835780537,1871514946,1907768513,1944546242,1981853161 mov $2,$0 mov $7,$0 lpb $0,1 lpb $0,1 sub $0,1 add $4,$2 lpe lpb $4,1 add $1,$4 sub $4,1 lpe mul $1,2 lpe add $1,2 mov $3,12 mov $8,$7 lpb $3,1 add $1,$8 sub $3,1 lpe mov $5,$7 lpb $5,1 sub $5,1 add $6,$8 lpe mov $3,17 mov $8,$6 lpb $3,1 add $1,$8 sub $3,1 lpe mov $5,$7 mov $6,0 lpb $5,1 sub $5,1 add $6,$8 lpe mov $3,8 mov $8,$6 lpb $3,1 add $1,$8 sub $3,1 lpe
stressfs.asm
jieun-cloud/xv6-logging
0
168956
<filename>stressfs.asm _stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp int fd, i; char path[] = "stressfs0"; 1: b8 30 00 00 00 mov $0x30,%eax #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 6: 89 e5 mov %esp,%ebp 8: 57 push %edi 9: 56 push %esi a: 53 push %ebx char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) b: 31 db xor %ebx,%ebx #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { d: 83 e4 f0 and $0xfffffff0,%esp 10: 81 ec 20 02 00 00 sub $0x220,%esp int fd, i; char path[] = "stressfs0"; char data[512]; printf(1, "stressfs starting\n"); 16: c7 44 24 04 16 08 00 movl $0x816,0x4(%esp) 1d: 00 memset(data, 'a', sizeof(data)); 1e: 8d 74 24 20 lea 0x20(%esp),%esi { int fd, i; char path[] = "stressfs0"; char data[512]; printf(1, "stressfs starting\n"); 22: c7 04 24 01 00 00 00 movl $0x1,(%esp) int main(int argc, char *argv[]) { int fd, i; char path[] = "stressfs0"; 29: 66 89 44 24 1e mov %ax,0x1e(%esp) 2e: c7 44 24 16 73 74 72 movl $0x65727473,0x16(%esp) 35: 65 36: c7 44 24 1a 73 73 66 movl $0x73667373,0x1a(%esp) 3d: 73 char data[512]; printf(1, "stressfs starting\n"); 3e: e8 6d 04 00 00 call 4b0 <printf> memset(data, 'a', sizeof(data)); 43: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 4a: 00 4b: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 52: 00 53: 89 34 24 mov %esi,(%esp) 56: e8 95 01 00 00 call 1f0 <memset> for(i = 0; i < 4; i++) if(fork() > 0) 5b: e8 fa 02 00 00 call 35a <fork> 60: 85 c0 test %eax,%eax 62: 0f 8f c3 00 00 00 jg 12b <main+0x12b> char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) 68: 83 c3 01 add $0x1,%ebx 6b: 83 fb 04 cmp $0x4,%ebx 6e: 75 eb jne 5b <main+0x5b> 70: bf 04 00 00 00 mov $0x4,%edi if(fork() > 0) break; printf(1, "write %d\n", i); 75: 89 5c 24 08 mov %ebx,0x8(%esp) path[8] += i; fd = open(path, O_CREATE | O_RDWR); 79: bb 14 00 00 00 mov $0x14,%ebx for(i = 0; i < 4; i++) if(fork() > 0) break; printf(1, "write %d\n", i); 7e: c7 44 24 04 29 08 00 movl $0x829,0x4(%esp) 85: 00 86: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8d: e8 1e 04 00 00 call 4b0 <printf> path[8] += i; 92: 89 f8 mov %edi,%eax 94: 00 44 24 1e add %al,0x1e(%esp) fd = open(path, O_CREATE | O_RDWR); 98: 8d 44 24 16 lea 0x16(%esp),%eax 9c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) a3: 00 a4: 89 04 24 mov %eax,(%esp) a7: e8 f6 02 00 00 call 3a2 <open> ac: 89 c7 mov %eax,%edi ae: 66 90 xchg %ax,%ax for(i = 0; i < 20; i++) // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); b0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) b7: 00 b8: 89 74 24 04 mov %esi,0x4(%esp) bc: 89 3c 24 mov %edi,(%esp) bf: e8 be 02 00 00 call 382 <write> printf(1, "write %d\n", i); path[8] += i; fd = open(path, O_CREATE | O_RDWR); for(i = 0; i < 20; i++) c4: 83 eb 01 sub $0x1,%ebx c7: 75 e7 jne b0 <main+0xb0> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); close(fd); c9: 89 3c 24 mov %edi,(%esp) printf(1, "read\n"); fd = open(path, O_RDONLY); cc: bb 14 00 00 00 mov $0x14,%ebx path[8] += i; fd = open(path, O_CREATE | O_RDWR); for(i = 0; i < 20; i++) // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); close(fd); d1: e8 b4 02 00 00 call 38a <close> printf(1, "read\n"); d6: c7 44 24 04 33 08 00 movl $0x833,0x4(%esp) dd: 00 de: c7 04 24 01 00 00 00 movl $0x1,(%esp) e5: e8 c6 03 00 00 call 4b0 <printf> fd = open(path, O_RDONLY); ea: 8d 44 24 16 lea 0x16(%esp),%eax ee: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) f5: 00 f6: 89 04 24 mov %eax,(%esp) f9: e8 a4 02 00 00 call 3a2 <open> fe: 89 c7 mov %eax,%edi for (i = 0; i < 20; i++) read(fd, data, sizeof(data)); 100: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 107: 00 108: 89 74 24 04 mov %esi,0x4(%esp) 10c: 89 3c 24 mov %edi,(%esp) 10f: e8 66 02 00 00 call 37a <read> close(fd); printf(1, "read\n"); fd = open(path, O_RDONLY); for (i = 0; i < 20; i++) 114: 83 eb 01 sub $0x1,%ebx 117: 75 e7 jne 100 <main+0x100> read(fd, data, sizeof(data)); close(fd); 119: 89 3c 24 mov %edi,(%esp) 11c: e8 69 02 00 00 call 38a <close> wait(); 121: e8 44 02 00 00 call 36a <wait> exit(); 126: e8 37 02 00 00 call 362 <exit> 12b: 89 df mov %ebx,%edi 12d: 8d 76 00 lea 0x0(%esi),%esi 130: e9 40 ff ff ff jmp 75 <main+0x75> 135: 66 90 xchg %ax,%ax 137: 66 90 xchg %ax,%ax 139: 66 90 xchg %ax,%ax 13b: 66 90 xchg %ax,%ax 13d: 66 90 xchg %ax,%ax 13f: 90 nop 00000140 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 8b 45 08 mov 0x8(%ebp),%eax 146: 8b 4d 0c mov 0xc(%ebp),%ecx 149: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 14a: 89 c2 mov %eax,%edx 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 150: 83 c1 01 add $0x1,%ecx 153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 157: 83 c2 01 add $0x1,%edx 15a: 84 db test %bl,%bl 15c: 88 5a ff mov %bl,-0x1(%edx) 15f: 75 ef jne 150 <strcpy+0x10> ; return os; } 161: 5b pop %ebx 162: 5d pop %ebp 163: c3 ret 164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 16a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000170 <strcmp>: int strcmp(const char *p, const char *q) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 8b 55 08 mov 0x8(%ebp),%edx 176: 53 push %ebx 177: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 17a: 0f b6 02 movzbl (%edx),%eax 17d: 84 c0 test %al,%al 17f: 74 2d je 1ae <strcmp+0x3e> 181: 0f b6 19 movzbl (%ecx),%ebx 184: 38 d8 cmp %bl,%al 186: 74 0e je 196 <strcmp+0x26> 188: eb 2b jmp 1b5 <strcmp+0x45> 18a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 190: 38 c8 cmp %cl,%al 192: 75 15 jne 1a9 <strcmp+0x39> p++, q++; 194: 89 d9 mov %ebx,%ecx 196: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 199: 0f b6 02 movzbl (%edx),%eax p++, q++; 19c: 8d 59 01 lea 0x1(%ecx),%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 19f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx 1a3: 84 c0 test %al,%al 1a5: 75 e9 jne 190 <strcmp+0x20> 1a7: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 1a9: 29 c8 sub %ecx,%eax } 1ab: 5b pop %ebx 1ac: 5d pop %ebp 1ad: c3 ret 1ae: 0f b6 09 movzbl (%ecx),%ecx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 1b1: 31 c0 xor %eax,%eax 1b3: eb f4 jmp 1a9 <strcmp+0x39> 1b5: 0f b6 cb movzbl %bl,%ecx 1b8: eb ef jmp 1a9 <strcmp+0x39> 1ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000001c0 <strlen>: return (uchar)*p - (uchar)*q; } uint strlen(const char *s) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 1c6: 80 39 00 cmpb $0x0,(%ecx) 1c9: 74 12 je 1dd <strlen+0x1d> 1cb: 31 d2 xor %edx,%edx 1cd: 8d 76 00 lea 0x0(%esi),%esi 1d0: 83 c2 01 add $0x1,%edx 1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1d7: 89 d0 mov %edx,%eax 1d9: 75 f5 jne 1d0 <strlen+0x10> ; return n; } 1db: 5d pop %ebp 1dc: c3 ret uint strlen(const char *s) { int n; for(n = 0; s[n]; n++) 1dd: 31 c0 xor %eax,%eax ; return n; } 1df: 5d pop %ebp 1e0: c3 ret 1e1: eb 0d jmp 1f0 <memset> 1e3: 90 nop 1e4: 90 nop 1e5: 90 nop 1e6: 90 nop 1e7: 90 nop 1e8: 90 nop 1e9: 90 nop 1ea: 90 nop 1eb: 90 nop 1ec: 90 nop 1ed: 90 nop 1ee: 90 nop 1ef: 90 nop 000001f0 <memset>: void* memset(void *dst, int c, uint n) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 8b 55 08 mov 0x8(%ebp),%edx 1f6: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1f7: 8b 4d 10 mov 0x10(%ebp),%ecx 1fa: 8b 45 0c mov 0xc(%ebp),%eax 1fd: 89 d7 mov %edx,%edi 1ff: fc cld 200: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 202: 89 d0 mov %edx,%eax 204: 5f pop %edi 205: 5d pop %ebp 206: c3 ret 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <strchr>: char* strchr(const char *s, char c) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 8b 45 08 mov 0x8(%ebp),%eax 216: 53 push %ebx 217: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 21a: 0f b6 18 movzbl (%eax),%ebx 21d: 84 db test %bl,%bl 21f: 74 1d je 23e <strchr+0x2e> if(*s == c) 221: 38 d3 cmp %dl,%bl 223: 89 d1 mov %edx,%ecx 225: 75 0d jne 234 <strchr+0x24> 227: eb 17 jmp 240 <strchr+0x30> 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 230: 38 ca cmp %cl,%dl 232: 74 0c je 240 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 234: 83 c0 01 add $0x1,%eax 237: 0f b6 10 movzbl (%eax),%edx 23a: 84 d2 test %dl,%dl 23c: 75 f2 jne 230 <strchr+0x20> if(*s == c) return (char*)s; return 0; 23e: 31 c0 xor %eax,%eax } 240: 5b pop %ebx 241: 5d pop %ebp 242: c3 ret 243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <gets>: char* gets(char *buf, int max) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 57 push %edi 254: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 255: 31 f6 xor %esi,%esi return 0; } char* gets(char *buf, int max) { 257: 53 push %ebx 258: 83 ec 2c sub $0x2c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ cc = read(0, &c, 1); 25b: 8d 7d e7 lea -0x19(%ebp),%edi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 25e: eb 31 jmp 291 <gets+0x41> cc = read(0, &c, 1); 260: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 267: 00 268: 89 7c 24 04 mov %edi,0x4(%esp) 26c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 273: e8 02 01 00 00 call 37a <read> if(cc < 1) 278: 85 c0 test %eax,%eax 27a: 7e 1d jle 299 <gets+0x49> break; buf[i++] = c; 27c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 280: 89 de mov %ebx,%esi cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 282: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 285: 3c 0d cmp $0xd,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 287: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 28b: 74 0c je 299 <gets+0x49> 28d: 3c 0a cmp $0xa,%al 28f: 74 08 je 299 <gets+0x49> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 291: 8d 5e 01 lea 0x1(%esi),%ebx 294: 3b 5d 0c cmp 0xc(%ebp),%ebx 297: 7c c7 jl 260 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 299: 8b 45 08 mov 0x8(%ebp),%eax 29c: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 2a0: 83 c4 2c add $0x2c,%esp 2a3: 5b pop %ebx 2a4: 5e pop %esi 2a5: 5f pop %edi 2a6: 5d pop %ebp 2a7: c3 ret 2a8: 90 nop 2a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000002b0 <stat>: int stat(const char *n, struct stat *st) { 2b0: 55 push %ebp 2b1: 89 e5 mov %esp,%ebp 2b3: 56 push %esi 2b4: 53 push %ebx 2b5: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 2b8: 8b 45 08 mov 0x8(%ebp),%eax 2bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2c2: 00 2c3: 89 04 24 mov %eax,(%esp) 2c6: e8 d7 00 00 00 call 3a2 <open> if(fd < 0) 2cb: 85 c0 test %eax,%eax stat(const char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 2cd: 89 c3 mov %eax,%ebx if(fd < 0) 2cf: 78 27 js 2f8 <stat+0x48> return -1; r = fstat(fd, st); 2d1: 8b 45 0c mov 0xc(%ebp),%eax 2d4: 89 1c 24 mov %ebx,(%esp) 2d7: 89 44 24 04 mov %eax,0x4(%esp) 2db: e8 da 00 00 00 call 3ba <fstat> close(fd); 2e0: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 2e3: 89 c6 mov %eax,%esi close(fd); 2e5: e8 a0 00 00 00 call 38a <close> return r; 2ea: 89 f0 mov %esi,%eax } 2ec: 83 c4 10 add $0x10,%esp 2ef: 5b pop %ebx 2f0: 5e pop %esi 2f1: 5d pop %ebp 2f2: c3 ret 2f3: 90 nop 2f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 2f8: b8 ff ff ff ff mov $0xffffffff,%eax 2fd: eb ed jmp 2ec <stat+0x3c> 2ff: 90 nop 00000300 <atoi>: return r; } int atoi(const char *s) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 8b 4d 08 mov 0x8(%ebp),%ecx 306: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 307: 0f be 11 movsbl (%ecx),%edx 30a: 8d 42 d0 lea -0x30(%edx),%eax 30d: 3c 09 cmp $0x9,%al int atoi(const char *s) { int n; n = 0; 30f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 314: 77 17 ja 32d <atoi+0x2d> 316: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 318: 83 c1 01 add $0x1,%ecx 31b: 8d 04 80 lea (%eax,%eax,4),%eax 31e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 322: 0f be 11 movsbl (%ecx),%edx 325: 8d 5a d0 lea -0x30(%edx),%ebx 328: 80 fb 09 cmp $0x9,%bl 32b: 76 eb jbe 318 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 32d: 5b pop %ebx 32e: 5d pop %ebp 32f: c3 ret 00000330 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 330: 55 push %ebp char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 331: 31 d2 xor %edx,%edx return n; } void* memmove(void *vdst, const void *vsrc, int n) { 333: 89 e5 mov %esp,%ebp 335: 56 push %esi 336: 8b 45 08 mov 0x8(%ebp),%eax 339: 53 push %ebx 33a: 8b 5d 10 mov 0x10(%ebp),%ebx 33d: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 340: 85 db test %ebx,%ebx 342: 7e 12 jle 356 <memmove+0x26> 344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 348: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 34c: 88 0c 10 mov %cl,(%eax,%edx,1) 34f: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 352: 39 da cmp %ebx,%edx 354: 75 f2 jne 348 <memmove+0x18> *dst++ = *src++; return vdst; } 356: 5b pop %ebx 357: 5e pop %esi 358: 5d pop %ebp 359: c3 ret 0000035a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 35a: b8 01 00 00 00 mov $0x1,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <exit>: SYSCALL(exit) 362: b8 02 00 00 00 mov $0x2,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <wait>: SYSCALL(wait) 36a: b8 03 00 00 00 mov $0x3,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <pipe>: SYSCALL(pipe) 372: b8 04 00 00 00 mov $0x4,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <read>: SYSCALL(read) 37a: b8 05 00 00 00 mov $0x5,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <write>: SYSCALL(write) 382: b8 10 00 00 00 mov $0x10,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <close>: SYSCALL(close) 38a: b8 15 00 00 00 mov $0x15,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <kill>: SYSCALL(kill) 392: b8 06 00 00 00 mov $0x6,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <exec>: SYSCALL(exec) 39a: b8 07 00 00 00 mov $0x7,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <open>: SYSCALL(open) 3a2: b8 0f 00 00 00 mov $0xf,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <mknod>: SYSCALL(mknod) 3aa: b8 11 00 00 00 mov $0x11,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <unlink>: SYSCALL(unlink) 3b2: b8 12 00 00 00 mov $0x12,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <fstat>: SYSCALL(fstat) 3ba: b8 08 00 00 00 mov $0x8,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <link>: SYSCALL(link) 3c2: b8 13 00 00 00 mov $0x13,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <mkdir>: SYSCALL(mkdir) 3ca: b8 14 00 00 00 mov $0x14,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <chdir>: SYSCALL(chdir) 3d2: b8 09 00 00 00 mov $0x9,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <dup>: SYSCALL(dup) 3da: b8 0a 00 00 00 mov $0xa,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <getpid>: SYSCALL(getpid) 3e2: b8 0b 00 00 00 mov $0xb,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <sbrk>: SYSCALL(sbrk) 3ea: b8 0c 00 00 00 mov $0xc,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <sleep>: SYSCALL(sleep) 3f2: b8 0d 00 00 00 mov $0xd,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <uptime>: SYSCALL(uptime) 3fa: b8 0e 00 00 00 mov $0xe,%eax 3ff: cd 40 int $0x40 401: c3 ret 402: 66 90 xchg %ax,%ax 404: 66 90 xchg %ax,%ax 406: 66 90 xchg %ax,%ax 408: 66 90 xchg %ax,%ax 40a: 66 90 xchg %ax,%ax 40c: 66 90 xchg %ax,%ax 40e: 66 90 xchg %ax,%ax 00000410 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 89 c6 mov %eax,%esi 417: 53 push %ebx 418: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 41b: 8b 5d 08 mov 0x8(%ebp),%ebx 41e: 85 db test %ebx,%ebx 420: 74 09 je 42b <printint+0x1b> 422: 89 d0 mov %edx,%eax 424: c1 e8 1f shr $0x1f,%eax 427: 84 c0 test %al,%al 429: 75 75 jne 4a0 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 42b: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 42d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 434: 89 75 c0 mov %esi,-0x40(%ebp) x = -xx; } else { x = xx; } i = 0; 437: 31 ff xor %edi,%edi 439: 89 ce mov %ecx,%esi 43b: 8d 5d d7 lea -0x29(%ebp),%ebx 43e: eb 02 jmp 442 <printint+0x32> do{ buf[i++] = digits[x % base]; 440: 89 cf mov %ecx,%edi 442: 31 d2 xor %edx,%edx 444: f7 f6 div %esi 446: 8d 4f 01 lea 0x1(%edi),%ecx 449: 0f b6 92 40 08 00 00 movzbl 0x840(%edx),%edx }while((x /= base) != 0); 450: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 452: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 455: 75 e9 jne 440 <printint+0x30> if(neg) 457: 8b 55 c4 mov -0x3c(%ebp),%edx x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 45a: 89 c8 mov %ecx,%eax 45c: 8b 75 c0 mov -0x40(%ebp),%esi }while((x /= base) != 0); if(neg) 45f: 85 d2 test %edx,%edx 461: 74 08 je 46b <printint+0x5b> buf[i++] = '-'; 463: 8d 4f 02 lea 0x2(%edi),%ecx 466: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 46b: 8d 79 ff lea -0x1(%ecx),%edi 46e: 66 90 xchg %ax,%ax 470: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 475: 83 ef 01 sub $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 478: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 47f: 00 480: 89 5c 24 04 mov %ebx,0x4(%esp) 484: 89 34 24 mov %esi,(%esp) 487: 88 45 d7 mov %al,-0x29(%ebp) 48a: e8 f3 fe ff ff call 382 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 48f: 83 ff ff cmp $0xffffffff,%edi 492: 75 dc jne 470 <printint+0x60> putc(fd, buf[i]); } 494: 83 c4 4c add $0x4c,%esp 497: 5b pop %ebx 498: 5e pop %esi 499: 5f pop %edi 49a: 5d pop %ebp 49b: c3 ret 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 4a0: 89 d0 mov %edx,%eax 4a2: f7 d8 neg %eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 4a4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 4ab: eb 87 jmp 434 <printint+0x24> 4ad: 8d 76 00 lea 0x0(%esi),%esi 000004b0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4b0: 55 push %ebp 4b1: 89 e5 mov %esp,%ebp 4b3: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 4b4: 31 ff xor %edi,%edi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4b6: 56 push %esi 4b7: 53 push %ebx 4b8: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4bb: 8b 5d 0c mov 0xc(%ebp),%ebx char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 4be: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4c1: 8b 75 08 mov 0x8(%ebp),%esi char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 4c4: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 4c7: 0f b6 13 movzbl (%ebx),%edx 4ca: 83 c3 01 add $0x1,%ebx 4cd: 84 d2 test %dl,%dl 4cf: 75 39 jne 50a <printf+0x5a> 4d1: e9 c2 00 00 00 jmp 598 <printf+0xe8> 4d6: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4d8: 83 fa 25 cmp $0x25,%edx 4db: 0f 84 bf 00 00 00 je 5a0 <printf+0xf0> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4e1: 8d 45 e2 lea -0x1e(%ebp),%eax 4e4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4eb: 00 4ec: 89 44 24 04 mov %eax,0x4(%esp) 4f0: 89 34 24 mov %esi,(%esp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; } else { putc(fd, c); 4f3: 88 55 e2 mov %dl,-0x1e(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4f6: e8 87 fe ff ff call 382 <write> 4fb: 83 c3 01 add $0x1,%ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4fe: 0f b6 53 ff movzbl -0x1(%ebx),%edx 502: 84 d2 test %dl,%dl 504: 0f 84 8e 00 00 00 je 598 <printf+0xe8> c = fmt[i] & 0xff; if(state == 0){ 50a: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 50c: 0f be c2 movsbl %dl,%eax if(state == 0){ 50f: 74 c7 je 4d8 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 511: 83 ff 25 cmp $0x25,%edi 514: 75 e5 jne 4fb <printf+0x4b> if(c == 'd'){ 516: 83 fa 64 cmp $0x64,%edx 519: 0f 84 31 01 00 00 je 650 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 51f: 25 f7 00 00 00 and $0xf7,%eax 524: 83 f8 70 cmp $0x70,%eax 527: 0f 84 83 00 00 00 je 5b0 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 52d: 83 fa 73 cmp $0x73,%edx 530: 0f 84 a2 00 00 00 je 5d8 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 536: 83 fa 63 cmp $0x63,%edx 539: 0f 84 35 01 00 00 je 674 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 53f: 83 fa 25 cmp $0x25,%edx 542: 0f 84 e0 00 00 00 je 628 <printf+0x178> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 548: 8d 45 e6 lea -0x1a(%ebp),%eax 54b: 83 c3 01 add $0x1,%ebx 54e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 555: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 556: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 558: 89 44 24 04 mov %eax,0x4(%esp) 55c: 89 34 24 mov %esi,(%esp) 55f: 89 55 d0 mov %edx,-0x30(%ebp) 562: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 566: e8 17 fe ff ff call 382 <write> } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 56b: 8b 55 d0 mov -0x30(%ebp),%edx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 56e: 8d 45 e7 lea -0x19(%ebp),%eax 571: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 578: 00 579: 89 44 24 04 mov %eax,0x4(%esp) 57d: 89 34 24 mov %esi,(%esp) } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 580: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 583: e8 fa fd ff ff call 382 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 588: 0f b6 53 ff movzbl -0x1(%ebx),%edx 58c: 84 d2 test %dl,%dl 58e: 0f 85 76 ff ff ff jne 50a <printf+0x5a> 594: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, c); } state = 0; } } } 598: 83 c4 3c add $0x3c,%esp 59b: 5b pop %ebx 59c: 5e pop %esi 59d: 5f pop %edi 59e: 5d pop %ebp 59f: c3 ret ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 5a0: bf 25 00 00 00 mov $0x25,%edi 5a5: e9 51 ff ff ff jmp 4fb <printf+0x4b> 5aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 5b0: 8b 45 d4 mov -0x2c(%ebp),%eax 5b3: b9 10 00 00 00 mov $0x10,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5b8: 31 ff xor %edi,%edi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 5ba: c7 04 24 00 00 00 00 movl $0x0,(%esp) 5c1: 8b 10 mov (%eax),%edx 5c3: 89 f0 mov %esi,%eax 5c5: e8 46 fe ff ff call 410 <printint> ap++; 5ca: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5ce: e9 28 ff ff ff jmp 4fb <printf+0x4b> 5d3: 90 nop 5d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 5d8: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 5db: 83 45 d4 04 addl $0x4,-0x2c(%ebp) ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 5df: 8b 38 mov (%eax),%edi ap++; if(s == 0) s = "(null)"; 5e1: b8 39 08 00 00 mov $0x839,%eax 5e6: 85 ff test %edi,%edi 5e8: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 5eb: 0f b6 07 movzbl (%edi),%eax 5ee: 84 c0 test %al,%al 5f0: 74 2a je 61c <printf+0x16c> 5f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 5f8: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5fb: 8d 45 e3 lea -0x1d(%ebp),%eax ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 5fe: 83 c7 01 add $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 601: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 608: 00 609: 89 44 24 04 mov %eax,0x4(%esp) 60d: 89 34 24 mov %esi,(%esp) 610: e8 6d fd ff ff call 382 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 615: 0f b6 07 movzbl (%edi),%eax 618: 84 c0 test %al,%al 61a: 75 dc jne 5f8 <printf+0x148> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 61c: 31 ff xor %edi,%edi 61e: e9 d8 fe ff ff jmp 4fb <printf+0x4b> 623: 90 nop 624: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 628: 8d 45 e5 lea -0x1b(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 62b: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 62d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 634: 00 635: 89 44 24 04 mov %eax,0x4(%esp) 639: 89 34 24 mov %esi,(%esp) 63c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 640: e8 3d fd ff ff call 382 <write> 645: e9 b1 fe ff ff jmp 4fb <printf+0x4b> 64a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 650: 8b 45 d4 mov -0x2c(%ebp),%eax 653: b9 0a 00 00 00 mov $0xa,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 658: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 65b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 662: 8b 10 mov (%eax),%edx 664: 89 f0 mov %esi,%eax 666: e8 a5 fd ff ff call 410 <printint> ap++; 66b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 66f: e9 87 fe ff ff jmp 4fb <printf+0x4b> while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 674: 8b 45 d4 mov -0x2c(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 677: 31 ff xor %edi,%edi while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 679: 8b 00 mov (%eax),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 67b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 682: 00 683: 89 34 24 mov %esi,(%esp) while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 686: 88 45 e4 mov %al,-0x1c(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 689: 8d 45 e4 lea -0x1c(%ebp),%eax 68c: 89 44 24 04 mov %eax,0x4(%esp) 690: e8 ed fc ff ff call 382 <write> putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 695: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 699: e9 5d fe ff ff jmp 4fb <printf+0x4b> 69e: 66 90 xchg %ax,%ax 000006a0 <free>: static Header base; static Header *freep; void free(void *ap) { 6a0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6a1: a1 bc 0a 00 00 mov 0xabc,%eax static Header base; static Header *freep; void free(void *ap) { 6a6: 89 e5 mov %esp,%ebp 6a8: 57 push %edi 6a9: 56 push %esi 6aa: 53 push %ebx 6ab: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6ae: 8b 08 mov (%eax),%ecx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 6b0: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6b3: 39 d0 cmp %edx,%eax 6b5: 72 11 jb 6c8 <free+0x28> 6b7: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6b8: 39 c8 cmp %ecx,%eax 6ba: 72 04 jb 6c0 <free+0x20> 6bc: 39 ca cmp %ecx,%edx 6be: 72 10 jb 6d0 <free+0x30> 6c0: 89 c8 mov %ecx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6c2: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6c4: 8b 08 mov (%eax),%ecx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6c6: 73 f0 jae 6b8 <free+0x18> 6c8: 39 ca cmp %ecx,%edx 6ca: 72 04 jb 6d0 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6cc: 39 c8 cmp %ecx,%eax 6ce: 72 f0 jb 6c0 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 6d0: 8b 73 fc mov -0x4(%ebx),%esi 6d3: 8d 3c f2 lea (%edx,%esi,8),%edi 6d6: 39 cf cmp %ecx,%edi 6d8: 74 1e je 6f8 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6da: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 6dd: 8b 48 04 mov 0x4(%eax),%ecx 6e0: 8d 34 c8 lea (%eax,%ecx,8),%esi 6e3: 39 f2 cmp %esi,%edx 6e5: 74 28 je 70f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6e7: 89 10 mov %edx,(%eax) freep = p; 6e9: a3 bc 0a 00 00 mov %eax,0xabc } 6ee: 5b pop %ebx 6ef: 5e pop %esi 6f0: 5f pop %edi 6f1: 5d pop %ebp 6f2: c3 ret 6f3: 90 nop 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6f8: 03 71 04 add 0x4(%ecx),%esi 6fb: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6fe: 8b 08 mov (%eax),%ecx 700: 8b 09 mov (%ecx),%ecx 702: 89 4b f8 mov %ecx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 705: 8b 48 04 mov 0x4(%eax),%ecx 708: 8d 34 c8 lea (%eax,%ecx,8),%esi 70b: 39 f2 cmp %esi,%edx 70d: 75 d8 jne 6e7 <free+0x47> p->s.size += bp->s.size; 70f: 03 4b fc add -0x4(%ebx),%ecx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 712: a3 bc 0a 00 00 mov %eax,0xabc bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 717: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 71a: 8b 53 f8 mov -0x8(%ebx),%edx 71d: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 71f: 5b pop %ebx 720: 5e pop %esi 721: 5f pop %edi 722: 5d pop %ebp 723: c3 ret 724: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 72a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000730 <malloc>: return freep; } void* malloc(uint nbytes) { 730: 55 push %ebp 731: 89 e5 mov %esp,%ebp 733: 57 push %edi 734: 56 push %esi 735: 53 push %ebx 736: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 739: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 73c: 8b 1d bc 0a 00 00 mov 0xabc,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 742: 8d 48 07 lea 0x7(%eax),%ecx 745: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 748: 85 db test %ebx,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 74a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 74d: 0f 84 9b 00 00 00 je 7ee <malloc+0xbe> 753: 8b 13 mov (%ebx),%edx 755: 8b 7a 04 mov 0x4(%edx),%edi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 758: 39 fe cmp %edi,%esi 75a: 76 64 jbe 7c0 <malloc+0x90> 75c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 763: bb 00 80 00 00 mov $0x8000,%ebx 768: 89 45 e4 mov %eax,-0x1c(%ebp) 76b: eb 0e jmp 77b <malloc+0x4b> 76d: 8d 76 00 lea 0x0(%esi),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 770: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 772: 8b 78 04 mov 0x4(%eax),%edi 775: 39 fe cmp %edi,%esi 777: 76 4f jbe 7c8 <malloc+0x98> 779: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 77b: 3b 15 bc 0a 00 00 cmp 0xabc,%edx 781: 75 ed jne 770 <malloc+0x40> morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 783: 8b 45 e4 mov -0x1c(%ebp),%eax 786: 81 fe 00 10 00 00 cmp $0x1000,%esi 78c: bf 00 10 00 00 mov $0x1000,%edi 791: 0f 43 fe cmovae %esi,%edi 794: 0f 42 c3 cmovb %ebx,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 797: 89 04 24 mov %eax,(%esp) 79a: e8 4b fc ff ff call 3ea <sbrk> if(p == (char*)-1) 79f: 83 f8 ff cmp $0xffffffff,%eax 7a2: 74 18 je 7bc <malloc+0x8c> return 0; hp = (Header*)p; hp->s.size = nu; 7a4: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 7a7: 83 c0 08 add $0x8,%eax 7aa: 89 04 24 mov %eax,(%esp) 7ad: e8 ee fe ff ff call 6a0 <free> return freep; 7b2: 8b 15 bc 0a 00 00 mov 0xabc,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 7b8: 85 d2 test %edx,%edx 7ba: 75 b4 jne 770 <malloc+0x40> return 0; 7bc: 31 c0 xor %eax,%eax 7be: eb 20 jmp 7e0 <malloc+0xb0> if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 7c0: 89 d0 mov %edx,%eax 7c2: 89 da mov %ebx,%edx 7c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 7c8: 39 fe cmp %edi,%esi 7ca: 74 1c je 7e8 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 7cc: 29 f7 sub %esi,%edi 7ce: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 7d1: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 7d4: 89 70 04 mov %esi,0x4(%eax) } freep = prevp; 7d7: 89 15 bc 0a 00 00 mov %edx,0xabc return (void*)(p + 1); 7dd: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 7e0: 83 c4 1c add $0x1c,%esp 7e3: 5b pop %ebx 7e4: 5e pop %esi 7e5: 5f pop %edi 7e6: 5d pop %ebp 7e7: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 7e8: 8b 08 mov (%eax),%ecx 7ea: 89 0a mov %ecx,(%edx) 7ec: eb e9 jmp 7d7 <malloc+0xa7> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7ee: c7 05 bc 0a 00 00 c0 movl $0xac0,0xabc 7f5: 0a 00 00 base.s.size = 0; 7f8: ba c0 0a 00 00 mov $0xac0,%edx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7fd: c7 05 c0 0a 00 00 c0 movl $0xac0,0xac0 804: 0a 00 00 base.s.size = 0; 807: c7 05 c4 0a 00 00 00 movl $0x0,0xac4 80e: 00 00 00 811: e9 46 ff ff ff jmp 75c <malloc+0x2c>
Ada/problem_18/problem_18.adb
PyllrNL/Project_Euler_Solutions
0
25244
<gh_stars>0 package body problem_18 is function Solution_1 return Integer is Triangle : array (Natural range 1 .. 15, Natural range 1 .. 15) of Natural := ( (75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0), (88, 2, 77, 73, 7, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0), (99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0), (41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0), (41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0), (53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0), (70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0), (91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0), (63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0), (4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23) ); begin for I in reverse Triangle'First(1) .. Triangle'Last(1) - 1 loop for J in 1 .. I loop if Triangle(I+1, J) > Triangle(I+1, J+1) then Triangle(I,J) := Triangle(I,J) + Triangle(I+1, J); else Triangle(I,J) := Triangle(I,J) + Triangle(I+1, J+1); end if; end loop; end loop; return Triangle(Triangle'First(1), Triangle'First(2)); end Solution_1; procedure Test_Solution_1 is Solution : constant Integer := 1074; begin Assert( Solution_1 = Solution ); end Test_Solution_1; function Get_Solutions return Solution_Case is Ret : Solution_Case; begin Set_Name( Ret, "Problem 18"); Add_Test( Ret, Test_Solution_1'Access ); return Ret; end Get_Solutions; end problem_18;
my-integer.agda
logicshan/IAL
0
1504
module my-integer where open import bool open import bool-thms2 open import eq open import nat open import nat-thms open import product --open import product-thms open import sum -- open import unit data ⊤ : Set where triv : ⊤ ℤ-pos-t : ℕ → Set ℤ-pos-t 0 = ⊤ ℤ-pos-t (suc _) = 𝔹 data ℤ : Set where mkℤ : (n : ℕ) → ℤ-pos-t n → ℤ 0ℤ : ℤ 0ℤ = mkℤ 0 triv 1ℤ : ℤ 1ℤ = mkℤ 1 tt -1ℤ : ℤ -1ℤ = mkℤ 1 ff abs-val : ℤ → ℕ abs-val (mkℤ n _) = n is-evenℤ : ℤ → 𝔹 is-evenℤ (mkℤ n _) = is-even n is-oddℤ : ℤ → 𝔹 is-oddℤ (mkℤ n _) = is-odd n {- subtract the second natural number from the first, returning an integer. This is mostly a helper for _+ℤ_ -} diffℤ : ℕ → ℕ → ℤ diffℤ n m with ℕ-trichotomy n m diffℤ n m | inj₁ p with <∸suc{m}{n} p -- n < m diffℤ n m | inj₁ p | x , _ = mkℤ (suc x) ff diffℤ n m | inj₂ (inj₁ p) = mkℤ 0 triv -- n = m diffℤ n m | inj₂ (inj₂ p) with <∸suc{n}{m} p diffℤ n m | inj₂ (inj₂ p) | x , _ = mkℤ (suc x) tt -- m < n _+ℤ_ : ℤ → ℤ → ℤ (mkℤ 0 _) +ℤ x = x x +ℤ (mkℤ 0 _) = x (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) with p1 xor p2 (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | ff = mkℤ (suc n + suc m) p1 (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | tt = if p1 imp p2 then diffℤ m n else diffℤ n m
hudi-spark-datasource/hudi-spark2/src/main/antlr4/org/apache/hudi/spark/sql/parser/HoodieSqlBase.g4
chenmm2021/hudi
0
3708
/* * 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. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar HoodieSqlBase; import SqlBase; singleStatement : statement EOF ; statement : mergeInto #mergeIntoTable | updateTableStmt #updateTable | deleteTableStmt #deleteTable | .*? #passThrough ; mergeInto : MERGE INTO target=tableIdentifier tableAlias USING (source=tableIdentifier | '(' subquery = query ')') tableAlias mergeCondition matchedClauses* notMatchedClause* ; mergeCondition : ON condition=booleanExpression ; matchedClauses : deleteClause | updateClause ; notMatchedClause : insertClause ; deleteClause : WHEN MATCHED (AND deleteCond=booleanExpression)? THEN deleteAction | WHEN deleteCond=booleanExpression THEN deleteAction ; updateClause : WHEN MATCHED (AND updateCond=booleanExpression)? THEN updateAction | WHEN updateCond=booleanExpression THEN updateAction ; insertClause : WHEN NOT MATCHED (AND insertCond=booleanExpression)? THEN insertAction | WHEN insertCond=booleanExpression THEN insertAction ; deleteAction : DELETE ; updateAction : UPDATE SET ASTERISK | UPDATE SET assignmentList ; insertAction : INSERT ASTERISK | INSERT '(' columns=qualifiedNameList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=qualifiedName EQ value=expression ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; updateTableStmt : UPDATE tableIdentifier SET assignmentList (WHERE where=booleanExpression)? ; deleteTableStmt : DELETE FROM tableIdentifier (WHERE where=booleanExpression)? ; PRIMARY: 'PRIMARY'; KEY: 'KEY'; MERGE: 'MERGE'; MATCHED: 'MATCHED'; UPDATE: 'UPDATE';
oeis/112/A112367.asm
neoneye/loda-programs
11
100689
; A112367: a(n) = A000217(n-k), where k is the largest triangular number less than n. ; 0,0,1,0,1,3,0,1,3,6,0,1,3,6,10,0,1,3,6,10,15,0,1,3,6,10,15,21,0,1,3,6,10,15,21,28,0,1,3,6,10,15,21,28,36,0,1,3,6,10,15,21,28,36,45,0,1,3,6,10,15,21,28,36,45,55,0,1,3,6,10 mov $1,1 lpb $0 sub $0,$1 add $1,1 lpe mov $1,$0 pow $0,2 add $1,$0 mov $0,$1 div $0,2
Evaluator.agda
JacquesCarette/pi-dual
14
15373
<filename>Evaluator.agda -- {-# OPTIONS --without-K #-} module Evaluator where open import Agda.Prim open import Data.Unit open import Data.Nat hiding (_⊔_) open import Data.Sum open import Data.Product open import Function open import Relation.Binary.PropositionalEquality open import Paths ------------------------------------------------------------------------------ -- For the usual situation, we can only establish one direction of univalence swap₊ : {ℓ : Level} {A B : Set ℓ} → A ⊎ B → B ⊎ A swap₊ (inj₁ a) = inj₂ a swap₊ (inj₂ b) = inj₁ b assocl₊ : {ℓ : Level} {A B C : Set ℓ} → A ⊎ (B ⊎ C) → (A ⊎ B) ⊎ C assocl₊ (inj₁ a) = inj₁ (inj₁ a) assocl₊ (inj₂ (inj₁ b)) = inj₁ (inj₂ b) assocl₊ (inj₂ (inj₂ c)) = inj₂ c assocr₊ : {ℓ : Level} {A B C : Set ℓ} → (A ⊎ B) ⊎ C → A ⊎ (B ⊎ C) assocr₊ (inj₁ (inj₁ a)) = inj₁ a assocr₊ (inj₁ (inj₂ b)) = inj₂ (inj₁ b) assocr₊ (inj₂ c) = inj₂ (inj₂ c) unite⋆ : {ℓ : Level} {A : Set ℓ} → ⊤ × A → A unite⋆ (tt , a) = a uniti⋆ : {ℓ : Level} {A : Set ℓ} → A → ⊤ × A uniti⋆ a = (tt , a) swap⋆ : {ℓ : Level} {A B : Set ℓ} → A × B → B × A swap⋆ (a , b) = (b , a) assocl⋆ : {ℓ : Level} {A B C : Set ℓ} → A × (B × C) → (A × B) × C assocl⋆ (a , (b , c)) = ((a , b) , c) assocr⋆ : {ℓ : Level} {A B C : Set ℓ} → (A × B) × C → A × (B × C) assocr⋆ ((a , b) , c) = (a , (b , c)) dist : {ℓ : Level} {A B C : Set ℓ} → (A ⊎ B) × C → (A × C ⊎ B × C) dist (inj₁ a , c) = inj₁ (a , c) dist (inj₂ b , c) = inj₂ (b , c) fact : {ℓ : Level} {A B C : Set ℓ} → (A × C ⊎ B × C) → (A ⊎ B) × C fact (inj₁ (a , c)) = (inj₁ a , c) fact (inj₂ (b , c)) = (inj₂ b , c) eval : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → Path a b → (A → B) eval swap₁₊⇛ = swap₊ eval swap₂₊⇛ = swap₊ eval assocl₁₊⇛ = assocl₊ eval assocl₁₊⇛' = assocl₊ {-- eval (assocl₂₁₊⇛ _) = assocl₊ eval (assocl₂₂₊⇛ _) = assocl₊ eval (assocr₁₁₊⇛ _) = assocr₊ eval (assocr₁₂₊⇛ _) = assocr₊ eval (assocr₂₊⇛ _) = assocr₊ eval (unite⋆⇛ _) = unite⋆ eval (uniti⋆⇛ _) = uniti⋆ eval (swap⋆⇛ _ _) = swap⋆ eval (assocl⋆⇛ _ _ _) = assocl⋆ eval (assocr⋆⇛ _ _ _) = assocr⋆ eval (dist₁⇛ _ _) = dist eval (dist₂⇛ _ _) = dist eval (factor₁⇛ _ _) = fact eval (factor₂⇛ _ _) = fact eval (id⇛ _) = id eval (trans⇛ c d) = eval d ∘ eval c eval (plus₁⇛ c d) = Data.Sum.map (eval c) (eval d) eval (plus₂⇛ c d) = Data.Sum.map (eval c) (eval d) eval (times⇛ c d) = Data.Product.map (eval c) (eval d) --} -- Inverses evalB : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → Path a b → (B → A) evalB swap₂₊⇛ = swap₊ evalB swap₁₊⇛ = swap₊ evalB assocl₁₊⇛ = assocr₊ evalB assocl₁₊⇛' = assocr₊ {-- evalB (assocr₂₊⇛ _) = assocl₊ evalB (assocr₁₂₊⇛ _) = assocl₊ evalB (assocr₁₁₊⇛ _) = assocl₊ evalB (assocl₂₂₊⇛ _) = assocr₊ evalB (assocl₂₁₊⇛ _) = assocr₊ evalB (uniti⋆⇛ _) = unite⋆ evalB (unite⋆⇛ _) = uniti⋆ evalB (swap⋆⇛ _ _) = swap⋆ evalB (assocr⋆⇛ _ _ _) = assocl⋆ evalB (assocl⋆⇛ _ _ _) = assocr⋆ evalB (dist₁⇛ _ _) = fact evalB (dist₂⇛ _ _) = fact evalB (factor₁⇛ _ _) = dist evalB (factor₂⇛ _ _) = dist evalB (id⇛ _) = id evalB (trans⇛ c d) = evalB c ∘ evalB d evalB (plus₁⇛ c d) = Data.Sum.map (evalB c) (evalB d) evalB (plus₂⇛ c d) = Data.Sum.map (evalB c) (evalB d) evalB (times⇛ c d) = Data.Product.map (evalB c) (evalB d) --} ------------------------------------------------------------------------------ -- Proving univalence• eval-resp-• : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (c : Path a b) → eval c a ≡ b eval-resp-• swap₁₊⇛ = refl eval-resp-• swap₂₊⇛ = refl eval-resp-• assocl₁₊⇛ = refl eval-resp-• assocl₁₊⇛' = refl {-- eval-resp-• (assocl₂₁₊⇛ b) = refl eval-resp-• (assocl₂₂₊⇛ c) = refl eval-resp-• (assocr₁₁₊⇛ a) = refl eval-resp-• (assocr₁₂₊⇛ b) = refl eval-resp-• (assocr₂₊⇛ c) = refl eval-resp-• {b = b} (unite⋆⇛ .b) = refl eval-resp-• {a = a} (uniti⋆⇛ .a) = refl eval-resp-• (swap⋆⇛ a b) = refl eval-resp-• (assocl⋆⇛ a b c) = refl eval-resp-• (assocr⋆⇛ a b c) = refl eval-resp-• (dist₁⇛ a c) = refl eval-resp-• (dist₂⇛ b c) = refl eval-resp-• (factor₁⇛ a c) = refl eval-resp-• (factor₂⇛ b c) = refl eval-resp-• {a = a} (id⇛ .a) = refl eval-resp-• {a = a} (trans⇛ c d) rewrite eval-resp-• c | eval-resp-• d = refl eval-resp-• (plus₁⇛ c d) rewrite eval-resp-• c = refl eval-resp-• (plus₂⇛ c d) rewrite eval-resp-• d = refl eval-resp-• (times⇛ c d) rewrite eval-resp-• c | eval-resp-• d = refl --} evalB-resp-• : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (c : Path a b) → evalB c b ≡ a evalB-resp-• swap₁₊⇛ = refl evalB-resp-• swap₂₊⇛ = refl evalB-resp-• assocl₁₊⇛ = refl evalB-resp-• assocl₁₊⇛' = refl {-- evalB-resp-• (assocl₂₁₊⇛ b) = refl evalB-resp-• (assocl₂₂₊⇛ c) = refl evalB-resp-• (assocr₁₁₊⇛ a) = refl evalB-resp-• (assocr₁₂₊⇛ b) = refl evalB-resp-• (assocr₂₊⇛ c) = refl evalB-resp-• {b = b} (unite⋆⇛ .b) = refl evalB-resp-• {a = a} (uniti⋆⇛ .a) = refl evalB-resp-• (swap⋆⇛ a b) = refl evalB-resp-• (assocl⋆⇛ a b c) = refl evalB-resp-• (assocr⋆⇛ a b c) = refl evalB-resp-• (dist₁⇛ a c) = refl evalB-resp-• (dist₂⇛ b c) = refl evalB-resp-• (factor₁⇛ a c) = refl evalB-resp-• (factor₂⇛ b c) = refl evalB-resp-• {a = a} (id⇛ .a) = refl evalB-resp-• {a = a} (trans⇛ c d) rewrite evalB-resp-• d | evalB-resp-• c = refl evalB-resp-• (plus₁⇛ c d) rewrite evalB-resp-• c = refl evalB-resp-• (plus₂⇛ c d) rewrite evalB-resp-• d = refl evalB-resp-• (times⇛ c d) rewrite evalB-resp-• c | evalB-resp-• d = refl --} -- the proof that eval ∙ evalB x ≡ x will be useful below eval∘evalB≡id : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (c : Path a b) → evalB c (eval c a) ≡ a eval∘evalB≡id c rewrite eval-resp-• c | evalB-resp-• c = refl {-- -- if this is useful, move it elsewhere -- but it might not be, as it appears to be 'level raising' cong⇚ : {ℓ : Level} {A B : Set ℓ} {a₁ a₂ : A} (f : Path a₁ a₂ ) → (x : A) → Path (evalB f x) (evalB f x) cong⇚ f x = id⇛ (evalB f x) --} {-- eval∘evalB : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (c : Path a b) → (x : A) → Path (evalB c (eval c x)) x eval∘evalB (swap₁₊⇛ a) (inj₁ x) = id⇛ (inj₁ x) eval∘evalB (swap₁₊⇛ a) (inj₂ y) = id⇛ (inj₂ y) eval∘evalB (swap₂₊⇛ b) (inj₁ x) = id⇛ (inj₁ x) eval∘evalB (swap₂₊⇛ b) (inj₂ y) = id⇛ (inj₂ y) eval∘evalB (assocl₁₊⇛ a) (inj₁ x) = id⇛ (inj₁ x) eval∘evalB (assocl₁₊⇛ a) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x)) eval∘evalB (assocl₁₊⇛ a) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y)) eval∘evalB (assocl₂₁₊⇛ b) (inj₁ x) = id⇛ (inj₁ x) eval∘evalB (assocl₂₁₊⇛ b) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x)) eval∘evalB (assocl₂₁₊⇛ b) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y)) eval∘evalB (assocl₂₂₊⇛ c) (inj₁ x) = id⇛ (inj₁ x) eval∘evalB (assocl₂₂₊⇛ c) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x)) eval∘evalB (assocl₂₂₊⇛ c) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y)) eval∘evalB (assocr₁₁₊⇛ a) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x)) eval∘evalB (assocr₁₁₊⇛ a) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y)) eval∘evalB (assocr₁₁₊⇛ a) (inj₂ y) = id⇛ (inj₂ y) eval∘evalB (assocr₁₂₊⇛ b) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x)) eval∘evalB (assocr₁₂₊⇛ b) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y)) eval∘evalB (assocr₁₂₊⇛ b) (inj₂ y) = id⇛ (inj₂ y) eval∘evalB (assocr₂₊⇛ c) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x)) eval∘evalB (assocr₂₊⇛ c) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y)) eval∘evalB (assocr₂₊⇛ c) (inj₂ y) = id⇛ (inj₂ y) eval∘evalB {b = b} (unite⋆⇛ .b) (tt , x) = id⇛ (tt , x) eval∘evalB {a = a} (uniti⋆⇛ .a) x = id⇛ x eval∘evalB (swap⋆⇛ a b) (x , y) = id⇛ (x , y) eval∘evalB (assocl⋆⇛ a b c) (x , y , z) = id⇛ (x , y , z) eval∘evalB (assocr⋆⇛ a b c) ((x , y) , z) = id⇛ ((x , y) , z) eval∘evalB (dist₁⇛ a c) (inj₁ x , y) = id⇛ (inj₁ x , y) eval∘evalB (dist₁⇛ a c) (inj₂ y , z) = id⇛ (inj₂ y , z) eval∘evalB (dist₂⇛ b c) (inj₁ x , z) = id⇛ (inj₁ x , z) eval∘evalB (dist₂⇛ b c) (inj₂ y , z) = id⇛ (inj₂ y , z) eval∘evalB (factor₁⇛ a c) (inj₁ (x , y)) = id⇛ (inj₁ (x , y)) eval∘evalB (factor₁⇛ a c) (inj₂ (x , y)) = id⇛ (inj₂ (x , y)) eval∘evalB (factor₂⇛ b c) (inj₁ (x , y)) = id⇛ (inj₁ (x , y)) eval∘evalB (factor₂⇛ b c) (inj₂ (x , y)) = id⇛ (inj₂ (x , y)) eval∘evalB {a = a} (id⇛ .a) x = id⇛ x eval∘evalB (trans⇛ {A = A} {B} {C} {a} {b} {c} c₁ c₂) x = trans⇛ {!cong⇚ ? (id⇛ (eval c₁ x))!} (eval∘evalB c₁ x) eval∘evalB (plus₁⇛ {b = b} c₁ c₂) (inj₁ x) = plus₁⇛ (eval∘evalB c₁ x) (id⇛ b) eval∘evalB (plus₁⇛ {a = a} c₁ c₂) (inj₂ y) = plus₂⇛ (id⇛ a) (eval∘evalB c₂ y) eval∘evalB (plus₂⇛ {b = b} c₁ c₂) (inj₁ x) = plus₁⇛ (eval∘evalB c₁ x) (id⇛ b) eval∘evalB (plus₂⇛ {a = a} c₁ c₂) (inj₂ y) = plus₂⇛ (id⇛ a) (eval∘evalB c₂ y) eval∘evalB (times⇛ c₁ c₂) (x , y) = times⇛ (eval∘evalB c₁ x) (eval∘evalB c₂ y) --} {-- eval-gives-id⇛ : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (c : Path a b) → Path (eval c a) b eval-gives-id⇛ {b = b} c rewrite eval-resp-• c = id⇛ b --}
hw1/homework.asm
yuhanchengo/assembly
0
3238
TITLE Example of ASM (asmExample.ASM) ; This program locates the cursor and displays the ; system time. It uses two Win32 API structures. ; Last update: 6/30/2005 INCLUDE Irvine32.inc ; Redefine external symbols for convenience ; Redifinition is necessary for using stdcall in .model directive ; using "start" is because for linking to WinDbg. added by Huang main EQU start@0 .data ;some data .code main PROC MOV al, 00110101b ; last two digits of leader’s students ID in binary format MOV ah, 02 ; last two digits of member’s students ID in decimal format MOV ax, 41Dh ; last four digits of student’s ID in hexadecimal MOV dx, 0eeeah ; let the value of dx is eeea SUB dx, ax ; value of dx subtracting by ax exit main ENDP END main
linux32/lesson02.asm
mashingan/notes-asmtutor
1
172045
<gh_stars>1-10 format ELF executable 3 entry start segment readable writable msg db 'Hello world!', 0Ah msglen = $ - msg segment readable executable start: mov edx, msglen mov ecx, msg mov ebx, 1 mov eax, 4 int 80h mov ebx, 0 mov eax, 1 int 80h
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/prefix2.adb
best08618/asylo
7
11773
<gh_stars>1-10 -- { dg-do compile } package body prefix2 is procedure Positionne (Objet : in out Instance; X, Y : Coordonnee) is begin Objet.X := X; Objet.Y := Y; end Positionne; function RetourneX (Objet : in Instance) return Coordonnee is begin return Objet.X; end RetourneX; function RetourneY (Objet : in Instance) return Coordonnee is begin return Objet.Y; end RetourneY; procedure Affiche (Objet : in Class; EstVisible : Boolean) is begin if EstVisible then Objet.Allume; else Objet.Eteins; end if; end Affiche; procedure Deplace (Objet : in out Class; DX, DY : Coordonnee) is begin Objet.Affiche (False); -- erreur Objet.Positionne (Objet.X + DX, Objet.Y + DY); Objet.Affiche (True); -- erreur end Deplace; end prefix2;
archive/a/ada/Baklava.adb
jrg94/sample-programs-in-every-language
422
8847
with Ada.Text_IO; use Ada.Text_IO; procedure Baklava is M : Integer := 11; begin for I in 1 .. 11 loop for J in 1 .. (M-1) loop Put(" "); end loop; for K in 1 .. (2*I - 1) loop Put("*"); end loop; M := M -1; Put_Line(""); end loop; M:=2; for I in reverse 1 .. 10 loop for J in 1 .. (M-1) loop Put(" "); end loop; for K in 1 .. (2*I - 1) loop Put("*"); end loop; M := M + 1; Put_Line(""); end loop; end Baklava;
alloy4fun_models/trashltl/models/9/hEWd5n24fEkr9RtSx.als
Kaixi26/org.alloytools.alloy
0
4911
open main pred idhEWd5n24fEkr9RtSx_prop10 { always (all f:Protected | f in Protected') } pred __repair { idhEWd5n24fEkr9RtSx_prop10 } check __repair { idhEWd5n24fEkr9RtSx_prop10 <=> prop10o }
Transynther/x86/_processed/AVXALIGN/_zr_/i9-9900K_12_0xca.log_21829_887.asm
ljhsiun2/medusa
9
13465
<filename>Transynther/x86/_processed/AVXALIGN/_zr_/i9-9900K_12_0xca.log_21829_887.asm<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r8 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0x19cdd, %r8 clflush (%r8) nop nop nop dec %rax mov (%r8), %ebp nop nop nop cmp %rsi, %rsi lea addresses_WT_ht+0x79fd, %r13 nop nop sub %rcx, %rcx mov $0x6162636465666768, %r12 movq %r12, (%r13) nop inc %r12 lea addresses_D_ht+0x7035, %r8 nop nop nop sub $60566, %r13 movl $0x61626364, (%r8) nop nop nop sub %rbp, %rbp lea addresses_D_ht+0x11309, %rsi lea addresses_WT_ht+0x4f35, %rdi clflush (%rsi) nop nop sub %r8, %r8 mov $125, %rcx rep movsb nop nop nop add %r13, %r13 lea addresses_UC_ht+0x2b57, %rsi lea addresses_D_ht+0x79a5, %rdi nop nop dec %rbp mov $59, %rcx rep movsw xor $40682, %rsi lea addresses_WC_ht+0x3a35, %r12 cmp $10232, %rax movups (%r12), %xmm7 vpextrq $1, %xmm7, %r8 nop nop and %r12, %r12 lea addresses_WC_ht+0x17035, %rbp nop nop nop nop nop xor %r12, %r12 mov $0x6162636465666768, %rcx movq %rcx, %xmm1 vmovups %ymm1, (%rbp) nop nop nop nop cmp %rbp, %rbp lea addresses_UC_ht+0x10575, %rcx nop nop nop nop nop cmp %r13, %r13 mov (%rcx), %si nop nop add %rcx, %rcx lea addresses_normal_ht+0x7735, %rdi nop nop cmp %rax, %rax mov $0x6162636465666768, %rbp movq %rbp, %xmm2 vmovups %ymm2, (%rdi) nop inc %rdi lea addresses_UC_ht+0x10635, %rcx nop dec %rbp movb (%rcx), %al sub %rsi, %rsi lea addresses_normal_ht+0x14d65, %rsi lea addresses_normal_ht+0x1cd35, %rdi nop nop inc %r8 mov $56, %rcx rep movsq and $53134, %rbp lea addresses_WT_ht+0x4d95, %rsi nop nop nop nop nop cmp $33021, %rax movw $0x6162, (%rsi) nop nop nop nop and %rbp, %rbp lea addresses_normal_ht+0x55b2, %rsi lea addresses_WT_ht+0x13a35, %rdi nop nop nop nop sub %rax, %rax mov $29, %rcx rep movsl nop nop nop nop xor %rdi, %rdi lea addresses_D_ht+0xafb5, %rsi nop add $19542, %r12 mov $0x6162636465666768, %rdi movq %rdi, %xmm0 vmovups %ymm0, (%rsi) nop inc %r13 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r15 push %r9 push %rbx // Store lea addresses_normal+0x1fb5, %r14 clflush (%r14) nop cmp %r9, %r9 mov $0x5152535455565758, %rbx movq %rbx, (%r14) and $57126, %r9 // Faulty Load lea addresses_D+0x1fe35, %r13 clflush (%r13) nop nop nop nop sub %r10, %r10 movaps (%r13), %xmm2 vpextrq $0, %xmm2, %r9 lea oracles, %r15 and $0xff, %r9 shlq $12, %r9 mov (%r15,%r9,1), %r9 pop %rbx pop %r9 pop %r15 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 7}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': True, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'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 */
grep.asm
via007/learnos-xv6
1
240997
_grep: 文件格式 elf32-i386 Disassembly of section .text: 00000000 <main>: } } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: 83 ec 18 sub $0x18,%esp 14: 8b 01 mov (%ecx),%eax 16: 8b 59 04 mov 0x4(%ecx),%ebx 19: 89 45 e4 mov %eax,-0x1c(%ebp) int fd, i; char *pattern; if(argc <= 1){ 1c: 83 f8 01 cmp $0x1,%eax 1f: 7e 77 jle 98 <main+0x98> printf(2, "usage: grep pattern [file ...]\n"); exit(); } pattern = argv[1]; 21: 8b 43 04 mov 0x4(%ebx),%eax 24: 83 c3 08 add $0x8,%ebx if(argc <= 2){ 27: 83 7d e4 02 cmpl $0x2,-0x1c(%ebp) grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 2b: be 02 00 00 00 mov $0x2,%esi pattern = argv[1]; 30: 89 45 e0 mov %eax,-0x20(%ebp) if(argc <= 2){ 33: 75 35 jne 6a <main+0x6a> grep(pattern, 0); 35: 52 push %edx 36: 52 push %edx 37: 6a 00 push $0x0 39: 50 push %eax 3a: e8 f1 01 00 00 call 230 <grep> exit(); 3f: e8 4d 05 00 00 call 591 <exit> 44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if((fd = open(argv[i], 0)) < 0){ printf(1, "grep: cannot open %s\n", argv[i]); exit(); } grep(pattern, fd); 48: 83 ec 08 sub $0x8,%esp for(i = 2; i < argc; i++){ 4b: 83 c6 01 add $0x1,%esi 4e: 83 c3 04 add $0x4,%ebx grep(pattern, fd); 51: 50 push %eax 52: ff 75 e0 pushl -0x20(%ebp) 55: e8 d6 01 00 00 call 230 <grep> close(fd); 5a: 89 3c 24 mov %edi,(%esp) 5d: e8 57 05 00 00 call 5b9 <close> for(i = 2; i < argc; i++){ 62: 83 c4 10 add $0x10,%esp 65: 39 75 e4 cmp %esi,-0x1c(%ebp) 68: 7e 29 jle 93 <main+0x93> if((fd = open(argv[i], 0)) < 0){ 6a: 83 ec 08 sub $0x8,%esp 6d: 6a 00 push $0x0 6f: ff 33 pushl (%ebx) 71: e8 5b 05 00 00 call 5d1 <open> 76: 83 c4 10 add $0x10,%esp 79: 89 c7 mov %eax,%edi 7b: 85 c0 test %eax,%eax 7d: 79 c9 jns 48 <main+0x48> printf(1, "grep: cannot open %s\n", argv[i]); 7f: 50 push %eax 80: ff 33 pushl (%ebx) 82: 68 b8 0a 00 00 push $0xab8 87: 6a 01 push $0x1 89: e8 a2 06 00 00 call 730 <printf> exit(); 8e: e8 fe 04 00 00 call 591 <exit> } exit(); 93: e8 f9 04 00 00 call 591 <exit> printf(2, "usage: grep pattern [file ...]\n"); 98: 51 push %ecx 99: 51 push %ecx 9a: 68 98 0a 00 00 push $0xa98 9f: 6a 02 push $0x2 a1: e8 8a 06 00 00 call 730 <printf> exit(); a6: e8 e6 04 00 00 call 591 <exit> ab: 66 90 xchg %ax,%ax ad: 66 90 xchg %ax,%ax af: 90 nop 000000b0 <matchstar>: return 0; } // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 57 push %edi b4: 56 push %esi b5: 53 push %ebx b6: 83 ec 0c sub $0xc,%esp b9: 8b 5d 08 mov 0x8(%ebp),%ebx bc: 8b 75 0c mov 0xc(%ebp),%esi bf: 8b 7d 10 mov 0x10(%ebp),%edi c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ // a * matches zero or more instances if(matchhere(re, text)) c8: 83 ec 08 sub $0x8,%esp cb: 57 push %edi cc: 56 push %esi cd: e8 3e 00 00 00 call 110 <matchhere> d2: 83 c4 10 add $0x10,%esp d5: 85 c0 test %eax,%eax d7: 75 1f jne f8 <matchstar+0x48> return 1; }while(*text!='\0' && (*text++==c || c=='.')); d9: 0f be 17 movsbl (%edi),%edx dc: 84 d2 test %dl,%dl de: 74 0c je ec <matchstar+0x3c> e0: 83 c7 01 add $0x1,%edi e3: 39 da cmp %ebx,%edx e5: 74 e1 je c8 <matchstar+0x18> e7: 83 fb 2e cmp $0x2e,%ebx ea: 74 dc je c8 <matchstar+0x18> return 0; } ec: 8d 65 f4 lea -0xc(%ebp),%esp ef: 5b pop %ebx f0: 5e pop %esi f1: 5f pop %edi f2: 5d pop %ebp f3: c3 ret f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi f8: 8d 65 f4 lea -0xc(%ebp),%esp return 1; fb: b8 01 00 00 00 mov $0x1,%eax } 100: 5b pop %ebx 101: 5e pop %esi 102: 5f pop %edi 103: 5d pop %ebp 104: c3 ret 105: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 10c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000110 <matchhere>: { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 56 push %esi 115: 53 push %ebx 116: 83 ec 0c sub $0xc,%esp if(re[0] == '\0') 119: 8b 45 08 mov 0x8(%ebp),%eax { 11c: 8b 7d 0c mov 0xc(%ebp),%edi if(re[0] == '\0') 11f: 0f b6 10 movzbl (%eax),%edx 122: 84 d2 test %dl,%dl 124: 74 67 je 18d <matchhere+0x7d> if(re[1] == '*') 126: 0f be 40 01 movsbl 0x1(%eax),%eax 12a: 3c 2a cmp $0x2a,%al 12c: 74 6c je 19a <matchhere+0x8a> if(re[0] == '$' && re[1] == '\0') 12e: 0f b6 1f movzbl (%edi),%ebx 131: 80 fa 24 cmp $0x24,%dl 134: 75 08 jne 13e <matchhere+0x2e> 136: 84 c0 test %al,%al 138: 0f 84 81 00 00 00 je 1bf <matchhere+0xaf> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 13e: 84 db test %bl,%bl 140: 74 09 je 14b <matchhere+0x3b> 142: 38 da cmp %bl,%dl 144: 74 3c je 182 <matchhere+0x72> 146: 80 fa 2e cmp $0x2e,%dl 149: 74 37 je 182 <matchhere+0x72> } 14b: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 14e: 31 c0 xor %eax,%eax } 150: 5b pop %ebx 151: 5e pop %esi 152: 5f pop %edi 153: 5d pop %ebp 154: c3 ret 155: 8d 76 00 lea 0x0(%esi),%esi if(re[1] == '*') 158: 8b 75 08 mov 0x8(%ebp),%esi 15b: 0f b6 56 01 movzbl 0x1(%esi),%edx 15f: 80 fa 2a cmp $0x2a,%dl 162: 74 3b je 19f <matchhere+0x8f> if(re[0] == '$' && re[1] == '\0') 164: 3c 24 cmp $0x24,%al 166: 75 04 jne 16c <matchhere+0x5c> 168: 84 d2 test %dl,%dl 16a: 74 4f je 1bb <matchhere+0xab> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 16c: 0f b6 33 movzbl (%ebx),%esi 16f: 89 f1 mov %esi,%ecx 171: 84 c9 test %cl,%cl 173: 74 d6 je 14b <matchhere+0x3b> 175: 89 df mov %ebx,%edi 177: 3c 2e cmp $0x2e,%al 179: 74 04 je 17f <matchhere+0x6f> 17b: 38 c1 cmp %al,%cl 17d: 75 cc jne 14b <matchhere+0x3b> 17f: 0f be c2 movsbl %dl,%eax return matchhere(re+1, text+1); 182: 8d 5f 01 lea 0x1(%edi),%ebx 185: 83 45 08 01 addl $0x1,0x8(%ebp) if(re[0] == '\0') 189: 84 c0 test %al,%al 18b: 75 cb jne 158 <matchhere+0x48> return 1; 18d: b8 01 00 00 00 mov $0x1,%eax } 192: 8d 65 f4 lea -0xc(%ebp),%esp 195: 5b pop %ebx 196: 5e pop %esi 197: 5f pop %edi 198: 5d pop %ebp 199: c3 ret if(re[1] == '*') 19a: 89 fb mov %edi,%ebx 19c: 0f be c2 movsbl %dl,%eax return matchstar(re[0], re+2, text); 19f: 8b 7d 08 mov 0x8(%ebp),%edi 1a2: 83 ec 04 sub $0x4,%esp 1a5: 53 push %ebx 1a6: 8d 4f 02 lea 0x2(%edi),%ecx 1a9: 51 push %ecx 1aa: 50 push %eax 1ab: e8 00 ff ff ff call b0 <matchstar> 1b0: 83 c4 10 add $0x10,%esp } 1b3: 8d 65 f4 lea -0xc(%ebp),%esp 1b6: 5b pop %ebx 1b7: 5e pop %esi 1b8: 5f pop %edi 1b9: 5d pop %ebp 1ba: c3 ret 1bb: 0f b6 5f 01 movzbl 0x1(%edi),%ebx return *text == '\0'; 1bf: 31 c0 xor %eax,%eax 1c1: 84 db test %bl,%bl 1c3: 0f 94 c0 sete %al 1c6: eb ca jmp 192 <matchhere+0x82> 1c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1cf: 90 nop 000001d0 <match>: { 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 56 push %esi 1d4: 8b 75 08 mov 0x8(%ebp),%esi 1d7: 53 push %ebx 1d8: 8b 5d 0c mov 0xc(%ebp),%ebx if(re[0] == '^') 1db: 80 3e 5e cmpb $0x5e,(%esi) 1de: 75 11 jne 1f1 <match+0x21> 1e0: eb 2e jmp 210 <match+0x40> 1e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi }while(*text++ != '\0'); 1e8: 83 c3 01 add $0x1,%ebx 1eb: 80 7b ff 00 cmpb $0x0,-0x1(%ebx) 1ef: 74 16 je 207 <match+0x37> if(matchhere(re, text)) 1f1: 83 ec 08 sub $0x8,%esp 1f4: 53 push %ebx 1f5: 56 push %esi 1f6: e8 15 ff ff ff call 110 <matchhere> 1fb: 83 c4 10 add $0x10,%esp 1fe: 85 c0 test %eax,%eax 200: 74 e6 je 1e8 <match+0x18> return 1; 202: b8 01 00 00 00 mov $0x1,%eax } 207: 8d 65 f8 lea -0x8(%ebp),%esp 20a: 5b pop %ebx 20b: 5e pop %esi 20c: 5d pop %ebp 20d: c3 ret 20e: 66 90 xchg %ax,%ax return matchhere(re+1, text); 210: 83 c6 01 add $0x1,%esi 213: 89 75 08 mov %esi,0x8(%ebp) } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp return matchhere(re+1, text); 21c: e9 ef fe ff ff jmp 110 <matchhere> 221: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 228: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 22f: 90 nop 00000230 <grep>: { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 57 push %edi 234: 56 push %esi 235: 53 push %ebx 236: 83 ec 1c sub $0x1c,%esp m = 0; 239: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) { 240: 8b 75 08 mov 0x8(%ebp),%esi 243: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 247: 90 nop while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 248: 8b 4d e4 mov -0x1c(%ebp),%ecx 24b: b8 ff 03 00 00 mov $0x3ff,%eax 250: 83 ec 04 sub $0x4,%esp 253: 29 c8 sub %ecx,%eax 255: 50 push %eax 256: 8d 81 a0 0e 00 00 lea 0xea0(%ecx),%eax 25c: 50 push %eax 25d: ff 75 0c pushl 0xc(%ebp) 260: e8 44 03 00 00 call 5a9 <read> 265: 83 c4 10 add $0x10,%esp 268: 85 c0 test %eax,%eax 26a: 0f 8e c0 00 00 00 jle 330 <grep+0x100> m += n; 270: 01 45 e4 add %eax,-0x1c(%ebp) 273: 8b 4d e4 mov -0x1c(%ebp),%ecx p = buf; 276: bb a0 0e 00 00 mov $0xea0,%ebx buf[m] = '\0'; 27b: c6 81 a0 0e 00 00 00 movb $0x0,0xea0(%ecx) while((q = strchr(p, '\n')) != 0){ 282: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 288: 83 ec 08 sub $0x8,%esp 28b: 6a 0a push $0xa 28d: 53 push %ebx 28e: e8 7d 01 00 00 call 410 <strchr> 293: 83 c4 10 add $0x10,%esp 296: 89 c7 mov %eax,%edi 298: 85 c0 test %eax,%eax 29a: 74 44 je 2e0 <grep+0xb0> if(match(pattern, p)){ 29c: 83 ec 08 sub $0x8,%esp *q = 0; 29f: c6 07 00 movb $0x0,(%edi) if(match(pattern, p)){ 2a2: 53 push %ebx 2a3: 56 push %esi 2a4: e8 27 ff ff ff call 1d0 <match> 2a9: 83 c4 10 add $0x10,%esp 2ac: 8d 57 01 lea 0x1(%edi),%edx 2af: 85 c0 test %eax,%eax 2b1: 75 0d jne 2c0 <grep+0x90> p = q+1; 2b3: 89 d3 mov %edx,%ebx 2b5: eb d1 jmp 288 <grep+0x58> 2b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2be: 66 90 xchg %ax,%ax write(1, p, q+1 - p); 2c0: 89 d0 mov %edx,%eax 2c2: 83 ec 04 sub $0x4,%esp *q = '\n'; 2c5: c6 07 0a movb $0xa,(%edi) write(1, p, q+1 - p); 2c8: 29 d8 sub %ebx,%eax 2ca: 89 55 e0 mov %edx,-0x20(%ebp) 2cd: 50 push %eax 2ce: 53 push %ebx 2cf: 6a 01 push $0x1 2d1: e8 db 02 00 00 call 5b1 <write> 2d6: 8b 55 e0 mov -0x20(%ebp),%edx 2d9: 83 c4 10 add $0x10,%esp p = q+1; 2dc: 89 d3 mov %edx,%ebx 2de: eb a8 jmp 288 <grep+0x58> if(p == buf) 2e0: 81 fb a0 0e 00 00 cmp $0xea0,%ebx 2e6: 74 38 je 320 <grep+0xf0> if(m > 0){ 2e8: 8b 4d e4 mov -0x1c(%ebp),%ecx 2eb: 85 c9 test %ecx,%ecx 2ed: 0f 8e 55 ff ff ff jle 248 <grep+0x18> m -= p - buf; 2f3: 89 d8 mov %ebx,%eax memmove(buf, p, m); 2f5: 83 ec 04 sub $0x4,%esp m -= p - buf; 2f8: 2d a0 0e 00 00 sub $0xea0,%eax 2fd: 29 c1 sub %eax,%ecx memmove(buf, p, m); 2ff: 51 push %ecx 300: 53 push %ebx 301: 68 a0 0e 00 00 push $0xea0 m -= p - buf; 306: 89 4d e4 mov %ecx,-0x1c(%ebp) memmove(buf, p, m); 309: e8 52 02 00 00 call 560 <memmove> 30e: 83 c4 10 add $0x10,%esp 311: e9 32 ff ff ff jmp 248 <grep+0x18> 316: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 31d: 8d 76 00 lea 0x0(%esi),%esi m = 0; 320: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 327: e9 1c ff ff ff jmp 248 <grep+0x18> 32c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } 330: 8d 65 f4 lea -0xc(%ebp),%esp 333: 5b pop %ebx 334: 5e pop %esi 335: 5f pop %edi 336: 5d pop %ebp 337: c3 ret 338: 66 90 xchg %ax,%ax 33a: 66 90 xchg %ax,%ax 33c: 66 90 xchg %ax,%ax 33e: 66 90 xchg %ax,%ax 00000340 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 340: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 341: 31 d2 xor %edx,%edx { 343: 89 e5 mov %esp,%ebp 345: 53 push %ebx 346: 8b 45 08 mov 0x8(%ebp),%eax 349: 8b 5d 0c mov 0xc(%ebp),%ebx 34c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while((*s++ = *t++) != 0) 350: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 354: 88 0c 10 mov %cl,(%eax,%edx,1) 357: 83 c2 01 add $0x1,%edx 35a: 84 c9 test %cl,%cl 35c: 75 f2 jne 350 <strcpy+0x10> ; return os; } 35e: 5b pop %ebx 35f: 5d pop %ebp 360: c3 ret 361: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 368: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 36f: 90 nop 00000370 <strcmp>: int strcmp(const char *p, const char *q) { 370: 55 push %ebp 371: 89 e5 mov %esp,%ebp 373: 56 push %esi 374: 53 push %ebx 375: 8b 5d 08 mov 0x8(%ebp),%ebx 378: 8b 75 0c mov 0xc(%ebp),%esi while(*p && *p == *q) 37b: 0f b6 13 movzbl (%ebx),%edx 37e: 0f b6 0e movzbl (%esi),%ecx 381: 84 d2 test %dl,%dl 383: 74 1e je 3a3 <strcmp+0x33> 385: b8 01 00 00 00 mov $0x1,%eax 38a: 38 ca cmp %cl,%dl 38c: 74 09 je 397 <strcmp+0x27> 38e: eb 20 jmp 3b0 <strcmp+0x40> 390: 83 c0 01 add $0x1,%eax 393: 38 ca cmp %cl,%dl 395: 75 19 jne 3b0 <strcmp+0x40> 397: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 39b: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 39f: 84 d2 test %dl,%dl 3a1: 75 ed jne 390 <strcmp+0x20> 3a3: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; } 3a5: 5b pop %ebx 3a6: 5e pop %esi return (uchar)*p - (uchar)*q; 3a7: 29 c8 sub %ecx,%eax } 3a9: 5d pop %ebp 3aa: c3 ret 3ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3af: 90 nop 3b0: 0f b6 c2 movzbl %dl,%eax 3b3: 5b pop %ebx 3b4: 5e pop %esi return (uchar)*p - (uchar)*q; 3b5: 29 c8 sub %ecx,%eax } 3b7: 5d pop %ebp 3b8: c3 ret 3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000003c0 <strlen>: uint strlen(const char *s) { 3c0: 55 push %ebp 3c1: 89 e5 mov %esp,%ebp 3c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 3c6: 80 39 00 cmpb $0x0,(%ecx) 3c9: 74 15 je 3e0 <strlen+0x20> 3cb: 31 d2 xor %edx,%edx 3cd: 8d 76 00 lea 0x0(%esi),%esi 3d0: 83 c2 01 add $0x1,%edx 3d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 3d7: 89 d0 mov %edx,%eax 3d9: 75 f5 jne 3d0 <strlen+0x10> ; return n; } 3db: 5d pop %ebp 3dc: c3 ret 3dd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 3e0: 31 c0 xor %eax,%eax } 3e2: 5d pop %ebp 3e3: c3 ret 3e4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3ef: 90 nop 000003f0 <memset>: void* memset(void *dst, int c, uint n) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 3f7: 8b 4d 10 mov 0x10(%ebp),%ecx 3fa: 8b 45 0c mov 0xc(%ebp),%eax 3fd: 89 d7 mov %edx,%edi 3ff: fc cld 400: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 402: 89 d0 mov %edx,%eax 404: 5f pop %edi 405: 5d pop %ebp 406: c3 ret 407: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 40e: 66 90 xchg %ax,%ax 00000410 <strchr>: char* strchr(const char *s, char c) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 53 push %ebx 414: 8b 45 08 mov 0x8(%ebp),%eax 417: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 41a: 0f b6 18 movzbl (%eax),%ebx 41d: 84 db test %bl,%bl 41f: 74 1d je 43e <strchr+0x2e> 421: 89 d1 mov %edx,%ecx if(*s == c) 423: 38 d3 cmp %dl,%bl 425: 75 0d jne 434 <strchr+0x24> 427: eb 17 jmp 440 <strchr+0x30> 429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 430: 38 ca cmp %cl,%dl 432: 74 0c je 440 <strchr+0x30> for(; *s; s++) 434: 83 c0 01 add $0x1,%eax 437: 0f b6 10 movzbl (%eax),%edx 43a: 84 d2 test %dl,%dl 43c: 75 f2 jne 430 <strchr+0x20> return (char*)s; return 0; 43e: 31 c0 xor %eax,%eax } 440: 5b pop %ebx 441: 5d pop %ebp 442: c3 ret 443: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 44a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000450 <gets>: char* gets(char *buf, int max) { 450: 55 push %ebp 451: 89 e5 mov %esp,%ebp 453: 57 push %edi 454: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 455: 31 f6 xor %esi,%esi { 457: 53 push %ebx 458: 89 f3 mov %esi,%ebx 45a: 83 ec 1c sub $0x1c,%esp 45d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 460: eb 2f jmp 491 <gets+0x41> 462: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 468: 83 ec 04 sub $0x4,%esp 46b: 8d 45 e7 lea -0x19(%ebp),%eax 46e: 6a 01 push $0x1 470: 50 push %eax 471: 6a 00 push $0x0 473: e8 31 01 00 00 call 5a9 <read> if(cc < 1) 478: 83 c4 10 add $0x10,%esp 47b: 85 c0 test %eax,%eax 47d: 7e 1c jle 49b <gets+0x4b> break; buf[i++] = c; 47f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 483: 83 c7 01 add $0x1,%edi 486: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 489: 3c 0a cmp $0xa,%al 48b: 74 23 je 4b0 <gets+0x60> 48d: 3c 0d cmp $0xd,%al 48f: 74 1f je 4b0 <gets+0x60> for(i=0; i+1 < max; ){ 491: 83 c3 01 add $0x1,%ebx 494: 89 fe mov %edi,%esi 496: 3b 5d 0c cmp 0xc(%ebp),%ebx 499: 7c cd jl 468 <gets+0x18> 49b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 49d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 4a0: c6 03 00 movb $0x0,(%ebx) } 4a3: 8d 65 f4 lea -0xc(%ebp),%esp 4a6: 5b pop %ebx 4a7: 5e pop %esi 4a8: 5f pop %edi 4a9: 5d pop %ebp 4aa: c3 ret 4ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 4af: 90 nop 4b0: 8b 75 08 mov 0x8(%ebp),%esi 4b3: 8b 45 08 mov 0x8(%ebp),%eax 4b6: 01 de add %ebx,%esi 4b8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 4ba: c6 03 00 movb $0x0,(%ebx) } 4bd: 8d 65 f4 lea -0xc(%ebp),%esp 4c0: 5b pop %ebx 4c1: 5e pop %esi 4c2: 5f pop %edi 4c3: 5d pop %ebp 4c4: c3 ret 4c5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000004d0 <stat>: int stat(const char *n, struct stat *st) { 4d0: 55 push %ebp 4d1: 89 e5 mov %esp,%ebp 4d3: 56 push %esi 4d4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 4d5: 83 ec 08 sub $0x8,%esp 4d8: 6a 00 push $0x0 4da: ff 75 08 pushl 0x8(%ebp) 4dd: e8 ef 00 00 00 call 5d1 <open> if(fd < 0) 4e2: 83 c4 10 add $0x10,%esp 4e5: 85 c0 test %eax,%eax 4e7: 78 27 js 510 <stat+0x40> return -1; r = fstat(fd, st); 4e9: 83 ec 08 sub $0x8,%esp 4ec: ff 75 0c pushl 0xc(%ebp) 4ef: 89 c3 mov %eax,%ebx 4f1: 50 push %eax 4f2: e8 f2 00 00 00 call 5e9 <fstat> close(fd); 4f7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 4fa: 89 c6 mov %eax,%esi close(fd); 4fc: e8 b8 00 00 00 call 5b9 <close> return r; 501: 83 c4 10 add $0x10,%esp } 504: 8d 65 f8 lea -0x8(%ebp),%esp 507: 89 f0 mov %esi,%eax 509: 5b pop %ebx 50a: 5e pop %esi 50b: 5d pop %ebp 50c: c3 ret 50d: 8d 76 00 lea 0x0(%esi),%esi return -1; 510: be ff ff ff ff mov $0xffffffff,%esi 515: eb ed jmp 504 <stat+0x34> 517: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 51e: 66 90 xchg %ax,%ax 00000520 <atoi>: int atoi(const char *s) { 520: 55 push %ebp 521: 89 e5 mov %esp,%ebp 523: 53 push %ebx 524: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 527: 0f be 11 movsbl (%ecx),%edx 52a: 8d 42 d0 lea -0x30(%edx),%eax 52d: 3c 09 cmp $0x9,%al n = 0; 52f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 534: 77 1f ja 555 <atoi+0x35> 536: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 53d: 8d 76 00 lea 0x0(%esi),%esi n = n*10 + *s++ - '0'; 540: 83 c1 01 add $0x1,%ecx 543: 8d 04 80 lea (%eax,%eax,4),%eax 546: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 54a: 0f be 11 movsbl (%ecx),%edx 54d: 8d 5a d0 lea -0x30(%edx),%ebx 550: 80 fb 09 cmp $0x9,%bl 553: 76 eb jbe 540 <atoi+0x20> return n; } 555: 5b pop %ebx 556: 5d pop %ebp 557: c3 ret 558: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 55f: 90 nop 00000560 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 560: 55 push %ebp 561: 89 e5 mov %esp,%ebp 563: 57 push %edi 564: 8b 55 10 mov 0x10(%ebp),%edx 567: 8b 45 08 mov 0x8(%ebp),%eax 56a: 56 push %esi 56b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 56e: 85 d2 test %edx,%edx 570: 7e 13 jle 585 <memmove+0x25> 572: 01 c2 add %eax,%edx dst = vdst; 574: 89 c7 mov %eax,%edi 576: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 57d: 8d 76 00 lea 0x0(%esi),%esi *dst++ = *src++; 580: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 581: 39 fa cmp %edi,%edx 583: 75 fb jne 580 <memmove+0x20> return vdst; } 585: 5e pop %esi 586: 5f pop %edi 587: 5d pop %ebp 588: c3 ret 00000589 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 589: b8 01 00 00 00 mov $0x1,%eax 58e: cd 40 int $0x40 590: c3 ret 00000591 <exit>: SYSCALL(exit) 591: b8 02 00 00 00 mov $0x2,%eax 596: cd 40 int $0x40 598: c3 ret 00000599 <wait>: SYSCALL(wait) 599: b8 03 00 00 00 mov $0x3,%eax 59e: cd 40 int $0x40 5a0: c3 ret 000005a1 <pipe>: SYSCALL(pipe) 5a1: b8 04 00 00 00 mov $0x4,%eax 5a6: cd 40 int $0x40 5a8: c3 ret 000005a9 <read>: SYSCALL(read) 5a9: b8 05 00 00 00 mov $0x5,%eax 5ae: cd 40 int $0x40 5b0: c3 ret 000005b1 <write>: SYSCALL(write) 5b1: b8 10 00 00 00 mov $0x10,%eax 5b6: cd 40 int $0x40 5b8: c3 ret 000005b9 <close>: SYSCALL(close) 5b9: b8 15 00 00 00 mov $0x15,%eax 5be: cd 40 int $0x40 5c0: c3 ret 000005c1 <kill>: SYSCALL(kill) 5c1: b8 06 00 00 00 mov $0x6,%eax 5c6: cd 40 int $0x40 5c8: c3 ret 000005c9 <exec>: SYSCALL(exec) 5c9: b8 07 00 00 00 mov $0x7,%eax 5ce: cd 40 int $0x40 5d0: c3 ret 000005d1 <open>: SYSCALL(open) 5d1: b8 0f 00 00 00 mov $0xf,%eax 5d6: cd 40 int $0x40 5d8: c3 ret 000005d9 <mknod>: SYSCALL(mknod) 5d9: b8 11 00 00 00 mov $0x11,%eax 5de: cd 40 int $0x40 5e0: c3 ret 000005e1 <unlink>: SYSCALL(unlink) 5e1: b8 12 00 00 00 mov $0x12,%eax 5e6: cd 40 int $0x40 5e8: c3 ret 000005e9 <fstat>: SYSCALL(fstat) 5e9: b8 08 00 00 00 mov $0x8,%eax 5ee: cd 40 int $0x40 5f0: c3 ret 000005f1 <link>: SYSCALL(link) 5f1: b8 13 00 00 00 mov $0x13,%eax 5f6: cd 40 int $0x40 5f8: c3 ret 000005f9 <mkdir>: SYSCALL(mkdir) 5f9: b8 14 00 00 00 mov $0x14,%eax 5fe: cd 40 int $0x40 600: c3 ret 00000601 <chdir>: SYSCALL(chdir) 601: b8 09 00 00 00 mov $0x9,%eax 606: cd 40 int $0x40 608: c3 ret 00000609 <dup>: SYSCALL(dup) 609: b8 0a 00 00 00 mov $0xa,%eax 60e: cd 40 int $0x40 610: c3 ret 00000611 <getpid>: SYSCALL(getpid) 611: b8 0b 00 00 00 mov $0xb,%eax 616: cd 40 int $0x40 618: c3 ret 00000619 <sbrk>: SYSCALL(sbrk) 619: b8 0c 00 00 00 mov $0xc,%eax 61e: cd 40 int $0x40 620: c3 ret 00000621 <sleep>: SYSCALL(sleep) 621: b8 0d 00 00 00 mov $0xd,%eax 626: cd 40 int $0x40 628: c3 ret 00000629 <uptime>: SYSCALL(uptime) 629: b8 0e 00 00 00 mov $0xe,%eax 62e: cd 40 int $0x40 630: c3 ret 00000631 <printingMyFavoriteYear>: SYSCALL(printingMyFavoriteYear) 631: b8 16 00 00 00 mov $0x16,%eax 636: cd 40 int $0x40 638: c3 ret 00000639 <getChildren>: SYSCALL(getChildren) 639: b8 17 00 00 00 mov $0x17,%eax 63e: cd 40 int $0x40 640: c3 ret 00000641 <getRunningProcessPID>: SYSCALL(getRunningProcessPID) 641: b8 18 00 00 00 mov $0x18,%eax 646: cd 40 int $0x40 648: c3 ret 00000649 <changePolicy>: SYSCALL(changePolicy) 649: b8 19 00 00 00 mov $0x19,%eax 64e: cd 40 int $0x40 650: c3 ret 00000651 <Quantum_Increaser>: SYSCALL(Quantum_Increaser) 651: b8 1a 00 00 00 mov $0x1a,%eax 656: cd 40 int $0x40 658: c3 ret 00000659 <Quantum_Decreaser>: SYSCALL(Quantum_Decreaser) 659: b8 1b 00 00 00 mov $0x1b,%eax 65e: cd 40 int $0x40 660: c3 ret 661: 66 90 xchg %ax,%ax 663: 66 90 xchg %ax,%ax 665: 66 90 xchg %ax,%ax 667: 66 90 xchg %ax,%ax 669: 66 90 xchg %ax,%ax 66b: 66 90 xchg %ax,%ax 66d: 66 90 xchg %ax,%ax 66f: 90 nop 00000670 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 670: 55 push %ebp 671: 89 e5 mov %esp,%ebp 673: 57 push %edi 674: 56 push %esi 675: 53 push %ebx uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 676: 89 d3 mov %edx,%ebx { 678: 83 ec 3c sub $0x3c,%esp 67b: 89 45 bc mov %eax,-0x44(%ebp) if(sgn && xx < 0){ 67e: 85 d2 test %edx,%edx 680: 0f 89 92 00 00 00 jns 718 <printint+0xa8> 686: f6 45 08 01 testb $0x1,0x8(%ebp) 68a: 0f 84 88 00 00 00 je 718 <printint+0xa8> neg = 1; 690: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) x = -xx; 697: f7 db neg %ebx } else { x = xx; } i = 0; 699: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 6a0: 8d 75 d7 lea -0x29(%ebp),%esi 6a3: eb 08 jmp 6ad <printint+0x3d> 6a5: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 6a8: 89 7d c4 mov %edi,-0x3c(%ebp) }while((x /= base) != 0); 6ab: 89 c3 mov %eax,%ebx buf[i++] = digits[x % base]; 6ad: 89 d8 mov %ebx,%eax 6af: 31 d2 xor %edx,%edx 6b1: 8b 7d c4 mov -0x3c(%ebp),%edi 6b4: f7 f1 div %ecx 6b6: 83 c7 01 add $0x1,%edi 6b9: 0f b6 92 d8 0a 00 00 movzbl 0xad8(%edx),%edx 6c0: 88 14 3e mov %dl,(%esi,%edi,1) }while((x /= base) != 0); 6c3: 39 d9 cmp %ebx,%ecx 6c5: 76 e1 jbe 6a8 <printint+0x38> if(neg) 6c7: 8b 45 c0 mov -0x40(%ebp),%eax 6ca: 85 c0 test %eax,%eax 6cc: 74 0d je 6db <printint+0x6b> buf[i++] = '-'; 6ce: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 6d3: ba 2d 00 00 00 mov $0x2d,%edx buf[i++] = digits[x % base]; 6d8: 89 7d c4 mov %edi,-0x3c(%ebp) 6db: 8b 45 c4 mov -0x3c(%ebp),%eax 6de: 8b 7d bc mov -0x44(%ebp),%edi 6e1: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 6e5: eb 0f jmp 6f6 <printint+0x86> 6e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 6ee: 66 90 xchg %ax,%ax 6f0: 0f b6 13 movzbl (%ebx),%edx 6f3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 6f6: 83 ec 04 sub $0x4,%esp 6f9: 88 55 d7 mov %dl,-0x29(%ebp) 6fc: 6a 01 push $0x1 6fe: 56 push %esi 6ff: 57 push %edi 700: e8 ac fe ff ff call 5b1 <write> while(--i >= 0) 705: 83 c4 10 add $0x10,%esp 708: 39 de cmp %ebx,%esi 70a: 75 e4 jne 6f0 <printint+0x80> putc(fd, buf[i]); } 70c: 8d 65 f4 lea -0xc(%ebp),%esp 70f: 5b pop %ebx 710: 5e pop %esi 711: 5f pop %edi 712: 5d pop %ebp 713: c3 ret 714: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 718: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp) 71f: e9 75 ff ff ff jmp 699 <printint+0x29> 724: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 72b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 72f: 90 nop 00000730 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 730: 55 push %ebp 731: 89 e5 mov %esp,%ebp 733: 57 push %edi 734: 56 push %esi 735: 53 push %ebx 736: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 739: 8b 75 0c mov 0xc(%ebp),%esi 73c: 0f b6 1e movzbl (%esi),%ebx 73f: 84 db test %bl,%bl 741: 0f 84 b9 00 00 00 je 800 <printf+0xd0> ap = (uint*)(void*)&fmt + 1; 747: 8d 45 10 lea 0x10(%ebp),%eax 74a: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 74d: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 750: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 752: 89 45 d0 mov %eax,-0x30(%ebp) 755: eb 38 jmp 78f <printf+0x5f> 757: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 75e: 66 90 xchg %ax,%ax 760: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 763: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 768: 83 f8 25 cmp $0x25,%eax 76b: 74 17 je 784 <printf+0x54> write(fd, &c, 1); 76d: 83 ec 04 sub $0x4,%esp 770: 88 5d e7 mov %bl,-0x19(%ebp) 773: 6a 01 push $0x1 775: 57 push %edi 776: ff 75 08 pushl 0x8(%ebp) 779: e8 33 fe ff ff call 5b1 <write> 77e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 781: 83 c4 10 add $0x10,%esp 784: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 787: 0f b6 5e ff movzbl -0x1(%esi),%ebx 78b: 84 db test %bl,%bl 78d: 74 71 je 800 <printf+0xd0> c = fmt[i] & 0xff; 78f: 0f be cb movsbl %bl,%ecx 792: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 795: 85 d2 test %edx,%edx 797: 74 c7 je 760 <printf+0x30> } } else if(state == '%'){ 799: 83 fa 25 cmp $0x25,%edx 79c: 75 e6 jne 784 <printf+0x54> if(c == 'd'){ 79e: 83 f8 64 cmp $0x64,%eax 7a1: 0f 84 99 00 00 00 je 840 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 7a7: 81 e1 f7 00 00 00 and $0xf7,%ecx 7ad: 83 f9 70 cmp $0x70,%ecx 7b0: 74 5e je 810 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 7b2: 83 f8 73 cmp $0x73,%eax 7b5: 0f 84 d5 00 00 00 je 890 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 7bb: 83 f8 63 cmp $0x63,%eax 7be: 0f 84 8c 00 00 00 je 850 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 7c4: 83 f8 25 cmp $0x25,%eax 7c7: 0f 84 b3 00 00 00 je 880 <printf+0x150> write(fd, &c, 1); 7cd: 83 ec 04 sub $0x4,%esp 7d0: c6 45 e7 25 movb $0x25,-0x19(%ebp) 7d4: 6a 01 push $0x1 7d6: 57 push %edi 7d7: ff 75 08 pushl 0x8(%ebp) 7da: e8 d2 fd ff ff call 5b1 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 7df: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 7e2: 83 c4 0c add $0xc,%esp 7e5: 6a 01 push $0x1 7e7: 83 c6 01 add $0x1,%esi 7ea: 57 push %edi 7eb: ff 75 08 pushl 0x8(%ebp) 7ee: e8 be fd ff ff call 5b1 <write> for(i = 0; fmt[i]; i++){ 7f3: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 7f7: 83 c4 10 add $0x10,%esp } state = 0; 7fa: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 7fc: 84 db test %bl,%bl 7fe: 75 8f jne 78f <printf+0x5f> } } } 800: 8d 65 f4 lea -0xc(%ebp),%esp 803: 5b pop %ebx 804: 5e pop %esi 805: 5f pop %edi 806: 5d pop %ebp 807: c3 ret 808: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80f: 90 nop printint(fd, *ap, 16, 0); 810: 83 ec 0c sub $0xc,%esp 813: b9 10 00 00 00 mov $0x10,%ecx 818: 6a 00 push $0x0 81a: 8b 5d d0 mov -0x30(%ebp),%ebx 81d: 8b 45 08 mov 0x8(%ebp),%eax 820: 8b 13 mov (%ebx),%edx 822: e8 49 fe ff ff call 670 <printint> ap++; 827: 89 d8 mov %ebx,%eax 829: 83 c4 10 add $0x10,%esp state = 0; 82c: 31 d2 xor %edx,%edx ap++; 82e: 83 c0 04 add $0x4,%eax 831: 89 45 d0 mov %eax,-0x30(%ebp) 834: e9 4b ff ff ff jmp 784 <printf+0x54> 839: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 840: 83 ec 0c sub $0xc,%esp 843: b9 0a 00 00 00 mov $0xa,%ecx 848: 6a 01 push $0x1 84a: eb ce jmp 81a <printf+0xea> 84c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 850: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 853: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 856: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 858: 6a 01 push $0x1 ap++; 85a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 85d: 57 push %edi 85e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 861: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 864: e8 48 fd ff ff call 5b1 <write> ap++; 869: 89 5d d0 mov %ebx,-0x30(%ebp) 86c: 83 c4 10 add $0x10,%esp state = 0; 86f: 31 d2 xor %edx,%edx 871: e9 0e ff ff ff jmp 784 <printf+0x54> 876: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 87d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 880: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 883: 83 ec 04 sub $0x4,%esp 886: e9 5a ff ff ff jmp 7e5 <printf+0xb5> 88b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 88f: 90 nop s = (char*)*ap; 890: 8b 45 d0 mov -0x30(%ebp),%eax 893: 8b 18 mov (%eax),%ebx ap++; 895: 83 c0 04 add $0x4,%eax 898: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 89b: 85 db test %ebx,%ebx 89d: 74 17 je 8b6 <printf+0x186> while(*s != 0){ 89f: 0f b6 03 movzbl (%ebx),%eax state = 0; 8a2: 31 d2 xor %edx,%edx while(*s != 0){ 8a4: 84 c0 test %al,%al 8a6: 0f 84 d8 fe ff ff je 784 <printf+0x54> 8ac: 89 75 d4 mov %esi,-0x2c(%ebp) 8af: 89 de mov %ebx,%esi 8b1: 8b 5d 08 mov 0x8(%ebp),%ebx 8b4: eb 1a jmp 8d0 <printf+0x1a0> s = "(null)"; 8b6: bb ce 0a 00 00 mov $0xace,%ebx while(*s != 0){ 8bb: 89 75 d4 mov %esi,-0x2c(%ebp) 8be: b8 28 00 00 00 mov $0x28,%eax 8c3: 89 de mov %ebx,%esi 8c5: 8b 5d 08 mov 0x8(%ebp),%ebx 8c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 8cf: 90 nop write(fd, &c, 1); 8d0: 83 ec 04 sub $0x4,%esp s++; 8d3: 83 c6 01 add $0x1,%esi 8d6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 8d9: 6a 01 push $0x1 8db: 57 push %edi 8dc: 53 push %ebx 8dd: e8 cf fc ff ff call 5b1 <write> while(*s != 0){ 8e2: 0f b6 06 movzbl (%esi),%eax 8e5: 83 c4 10 add $0x10,%esp 8e8: 84 c0 test %al,%al 8ea: 75 e4 jne 8d0 <printf+0x1a0> 8ec: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 8ef: 31 d2 xor %edx,%edx 8f1: e9 8e fe ff ff jmp 784 <printf+0x54> 8f6: 66 90 xchg %ax,%ax 8f8: 66 90 xchg %ax,%ax 8fa: 66 90 xchg %ax,%ax 8fc: 66 90 xchg %ax,%ax 8fe: 66 90 xchg %ax,%ax 00000900 <free>: static Header base; static Header *freep; void free(void *ap) { 900: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 901: a1 80 0e 00 00 mov 0xe80,%eax { 906: 89 e5 mov %esp,%ebp 908: 57 push %edi 909: 56 push %esi 90a: 53 push %ebx 90b: 8b 5d 08 mov 0x8(%ebp),%ebx 90e: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 910: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 913: 39 c8 cmp %ecx,%eax 915: 73 19 jae 930 <free+0x30> 917: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 91e: 66 90 xchg %ax,%ax 920: 39 d1 cmp %edx,%ecx 922: 72 14 jb 938 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 924: 39 d0 cmp %edx,%eax 926: 73 10 jae 938 <free+0x38> { 928: 89 d0 mov %edx,%eax 92a: 8b 10 mov (%eax),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 92c: 39 c8 cmp %ecx,%eax 92e: 72 f0 jb 920 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 930: 39 d0 cmp %edx,%eax 932: 72 f4 jb 928 <free+0x28> 934: 39 d1 cmp %edx,%ecx 936: 73 f0 jae 928 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 938: 8b 73 fc mov -0x4(%ebx),%esi 93b: 8d 3c f1 lea (%ecx,%esi,8),%edi 93e: 39 fa cmp %edi,%edx 940: 74 1e je 960 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 942: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 945: 8b 50 04 mov 0x4(%eax),%edx 948: 8d 34 d0 lea (%eax,%edx,8),%esi 94b: 39 f1 cmp %esi,%ecx 94d: 74 28 je 977 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 94f: 89 08 mov %ecx,(%eax) freep = p; } 951: 5b pop %ebx freep = p; 952: a3 80 0e 00 00 mov %eax,0xe80 } 957: 5e pop %esi 958: 5f pop %edi 959: 5d pop %ebp 95a: c3 ret 95b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 95f: 90 nop bp->s.size += p->s.ptr->s.size; 960: 03 72 04 add 0x4(%edx),%esi 963: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 966: 8b 10 mov (%eax),%edx 968: 8b 12 mov (%edx),%edx 96a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 96d: 8b 50 04 mov 0x4(%eax),%edx 970: 8d 34 d0 lea (%eax,%edx,8),%esi 973: 39 f1 cmp %esi,%ecx 975: 75 d8 jne 94f <free+0x4f> p->s.size += bp->s.size; 977: 03 53 fc add -0x4(%ebx),%edx freep = p; 97a: a3 80 0e 00 00 mov %eax,0xe80 p->s.size += bp->s.size; 97f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 982: 8b 53 f8 mov -0x8(%ebx),%edx 985: 89 10 mov %edx,(%eax) } 987: 5b pop %ebx 988: 5e pop %esi 989: 5f pop %edi 98a: 5d pop %ebp 98b: c3 ret 98c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000990 <malloc>: return freep; } void* malloc(uint nbytes) { 990: 55 push %ebp 991: 89 e5 mov %esp,%ebp 993: 57 push %edi 994: 56 push %esi 995: 53 push %ebx 996: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 999: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 99c: 8b 3d 80 0e 00 00 mov 0xe80,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 9a2: 8d 70 07 lea 0x7(%eax),%esi 9a5: c1 ee 03 shr $0x3,%esi 9a8: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 9ab: 85 ff test %edi,%edi 9ad: 0f 84 ad 00 00 00 je a60 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 9b3: 8b 17 mov (%edi),%edx if(p->s.size >= nunits){ 9b5: 8b 4a 04 mov 0x4(%edx),%ecx 9b8: 39 f1 cmp %esi,%ecx 9ba: 73 72 jae a2e <malloc+0x9e> 9bc: 81 fe 00 10 00 00 cmp $0x1000,%esi 9c2: bb 00 10 00 00 mov $0x1000,%ebx 9c7: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 9ca: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax 9d1: 89 45 e4 mov %eax,-0x1c(%ebp) 9d4: eb 1b jmp 9f1 <malloc+0x61> 9d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 9dd: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 9e0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 9e2: 8b 48 04 mov 0x4(%eax),%ecx 9e5: 39 f1 cmp %esi,%ecx 9e7: 73 4f jae a38 <malloc+0xa8> 9e9: 8b 3d 80 0e 00 00 mov 0xe80,%edi 9ef: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 9f1: 39 d7 cmp %edx,%edi 9f3: 75 eb jne 9e0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 9f5: 83 ec 0c sub $0xc,%esp 9f8: ff 75 e4 pushl -0x1c(%ebp) 9fb: e8 19 fc ff ff call 619 <sbrk> if(p == (char*)-1) a00: 83 c4 10 add $0x10,%esp a03: 83 f8 ff cmp $0xffffffff,%eax a06: 74 1c je a24 <malloc+0x94> hp->s.size = nu; a08: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); a0b: 83 ec 0c sub $0xc,%esp a0e: 83 c0 08 add $0x8,%eax a11: 50 push %eax a12: e8 e9 fe ff ff call 900 <free> return freep; a17: 8b 15 80 0e 00 00 mov 0xe80,%edx if((p = morecore(nunits)) == 0) a1d: 83 c4 10 add $0x10,%esp a20: 85 d2 test %edx,%edx a22: 75 bc jne 9e0 <malloc+0x50> return 0; } } a24: 8d 65 f4 lea -0xc(%ebp),%esp return 0; a27: 31 c0 xor %eax,%eax } a29: 5b pop %ebx a2a: 5e pop %esi a2b: 5f pop %edi a2c: 5d pop %ebp a2d: c3 ret if(p->s.size >= nunits){ a2e: 89 d0 mov %edx,%eax a30: 89 fa mov %edi,%edx a32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) a38: 39 ce cmp %ecx,%esi a3a: 74 54 je a90 <malloc+0x100> p->s.size -= nunits; a3c: 29 f1 sub %esi,%ecx a3e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; a41: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; a44: 89 70 04 mov %esi,0x4(%eax) freep = prevp; a47: 89 15 80 0e 00 00 mov %edx,0xe80 } a4d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); a50: 83 c0 08 add $0x8,%eax } a53: 5b pop %ebx a54: 5e pop %esi a55: 5f pop %edi a56: 5d pop %ebp a57: c3 ret a58: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a5f: 90 nop base.s.ptr = freep = prevp = &base; a60: c7 05 80 0e 00 00 84 movl $0xe84,0xe80 a67: 0e 00 00 base.s.size = 0; a6a: bf 84 0e 00 00 mov $0xe84,%edi base.s.ptr = freep = prevp = &base; a6f: c7 05 84 0e 00 00 84 movl $0xe84,0xe84 a76: 0e 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ a79: 89 fa mov %edi,%edx base.s.size = 0; a7b: c7 05 88 0e 00 00 00 movl $0x0,0xe88 a82: 00 00 00 if(p->s.size >= nunits){ a85: e9 32 ff ff ff jmp 9bc <malloc+0x2c> a8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; a90: 8b 08 mov (%eax),%ecx a92: 89 0a mov %ecx,(%edx) a94: eb b1 jmp a47 <malloc+0xb7>
oeis/128/A128788.asm
neoneye/loda-programs
11
10327
; A128788: n^2*9^n. ; 0,9,324,6561,104976,1476225,19131876,234365481,2754990144,31381059609,348678440100,3797108212689,40669853253264,429575324987601,4483851321172356,46325504721296025,474373168346071296,4819705511203638441,48630661836227715204,487657470079950144129,4863066183622771520400,48253774206996950411169,476629116656867836714404,4688494265296173079746441,45945471212278565681295936,448686242307407867981405625,4367691357117231150078194916,42391158275216203514294433201,410304544293450661175393032464 mov $2,9 pow $2,$0 mul $2,$0 mul $0,$2
src/FRP/LTL/ISet/Future.agda
agda/agda-frp-ltl
21
13925
<gh_stars>10-100 open import FRP.LTL.ISet.Core using ( ISet ; ⌈_⌉ ; ⌊_⌋ ) open import FRP.LTL.RSet using ( RSet ) open import FRP.LTL.Time using ( Time ; _≤_ ) module FRP.LTL.ISet.Future where data Future (A : RSet) (t : Time) : Set where _,_ : ∀ {u} .(t≤u : t ≤ u) → A u → Future A t ◇ : ISet → ISet ◇ A = ⌈ Future ⌊ A ⌋ ⌉
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_301.asm
ljhsiun2/medusa
9
171311
<reponame>ljhsiun2/medusa<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x7886, %rdx nop nop add $32928, %r15 movl $0x61626364, (%rdx) nop sub $38542, %r12 lea addresses_D_ht+0x3926, %rdi cmp %r8, %r8 vmovups (%rdi), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $0, %xmm6, %rax nop nop nop nop and $21482, %r15 lea addresses_D_ht+0x2086, %r15 nop nop inc %rax movw $0x6162, (%r15) nop nop nop nop nop dec %r15 lea addresses_UC_ht+0x1a176, %r8 nop nop add $26669, %r13 mov (%r8), %r12d nop nop nop add $877, %r15 lea addresses_normal_ht+0x1211a, %rsi lea addresses_normal_ht+0x14a86, %rdi nop nop nop nop sub %rax, %rax mov $125, %rcx rep movsq add %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r12 push %rbx push %rcx push %rsi // Faulty Load lea addresses_WT+0x3486, %rbx nop nop nop nop nop add $56680, %r12 movups (%rbx), %xmm0 vpextrq $1, %xmm0, %rcx lea oracles, %r12 and $0xff, %rcx shlq $12, %rcx mov (%r12,%rcx,1), %rcx pop %rsi pop %rcx pop %rbx pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WT', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_WT', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
electives/pw/lab/lista-2/ada/sender.adb
jerry-sky/academic-notebook
4
4630
<filename>electives/pw/lab/lista-2/ada/sender.adb package body Sender is task body SenderTask is tmpMessage: pMessage; subtype RangeK is Natural range 1..k; begin for I in RangeK'Range loop tmpMessage := new Message'(content => I, health => h); firstNode.all.nodeTask.all.SendMessage(tmpMessage); end loop; end SenderTask; end Sender;
programs/oeis/142/A142091.asm
neoneye/loda
22
177029
; A142091: Primes congruent to 23 mod 35. ; 23,163,233,373,443,653,863,1213,1283,1423,1493,1913,2053,2333,2473,2543,2683,2753,2963,3313,3593,3733,3803,3943,4013,4153,4363,4643,4783,4993,5273,5413,5483,5623,5693,5903,6043,6113,6323,6673,6883,7583,7723,7793,7933,8353,8423,8563,9403,9473,9613,10103,10243,10313,10453,10663,10733,11083,11503,11783,11923,12203,12343,12413,12553,12763,12973,13043,13183,13463,13883,14303,14653,14723,15073,15493,15773,15913,16193,16333,16823,16963,17033,17383,18013,18223,18433,18503,18713,19273,19483,19553,19763,19973,20113,20183,20323,20393,20533,20743 mov $2,$0 add $2,2 pow $2,2 lpb $2 add $1,22 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,13 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe div $1,2 sub $1,22 mul $1,2 add $1,33 mov $0,$1
oeis/055/A055303.asm
neoneye/loda-programs
11
7358
<reponame>neoneye/loda-programs ; A055303: Number of labeled rooted trees with n nodes and 2 leaves. ; Submitted by <NAME> ; 3,36,360,3600,37800,423360,5080320,65318400,898128000,13172544000,205491686400,3399953356800,59499183744000,1098446469120000,21341245685760000,435361411989504000,9305850181275648000,208013121699102720000,4853639506312396800000 mov $1,$0 add $0,2 bin $0,$1 add $1,3 lpb $1 mul $0,$1 sub $1,1 lpe div $0,2
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c87b40a.ada
best08618/asylo
7
26183
<reponame>best08618/asylo -- C87B40A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT OVERLOADING RESOLUTION USES THE FOLLOWING RULES: -- -- THE SAME OPERATIONS ARE PREDEFINED FOR THE TYPE UNIVERSAL_INTEGER -- AS FOR ANY INTEGER TYPE. THE SAME OPERATIONS ARE PREDEFINED FOR THE -- TYPE UNIVERSAL_REAL AS FOR ANY FLOATING POINT TYPE. IN ADDITION -- THESE OPERATIONS INCLUDE THE FOLLOWING MULTIPLICATION AND DIVISION -- OPERATORS: -- -- "*" (UNIVERSAL_REAL, UNIVERSAL_INTEGER) RETURN UNIVERSAL_REAL -- "*" (UNIVERSAL_INTEGER, UNIVERSAL_REAL) RETURN UNIVERSAL_REAL -- "*" (UNIVERSAL_REAL, UNIVERSAL_REAL) RETURN UNIVERSAL_REAL -- "*" (UNIVERSAL_INTEGER, UNIVERSAL_INTEGER) RETURN UNIVERSAL_INTEGER -- "/" (UNIVERSAL_REAL, UNIVERSAL_INTEGER) RETURN UNIVERSAL_REAL -- "**" (UNIVERSAL_INTEGER, INTEGER) RETURN UNIVERSAL_INTEGER -- "**" (UNIVERSAL_REAL, INTEGER) RETURN UNIVERSAL_REAL -- "MOD" (UNIVERSAL_INTEGER, UNIVERSAL_INTEGER) RETURN UNIVERSAL_INTEGER -- "DIV" (UNIVERSAL_INTEGER, UNIVERSAL_INTEGER) RETURN UNIVERSAL_INTEGER -- "ABS" (UNIVERSAL_INTEGER) RETURN UNIVERSAL INTEGER -- "ABS" (UNIVERSAL_REAL) RETURN UNIVERSAL_REAL -- TRH 15 SEPT 82 WITH REPORT; USE REPORT; PROCEDURE C87B40A IS ERR : BOOLEAN := FALSE; B : ARRAY (1 .. 12) OF BOOLEAN := (1 .. 12 => TRUE); FUNCTION "-" (X : INTEGER) RETURN INTEGER RENAMES STANDARD."+"; FUNCTION "+" (X : INTEGER) RETURN INTEGER IS BEGIN ERR := TRUE; RETURN X; END "+"; FUNCTION "+" (X : FLOAT) RETURN FLOAT IS BEGIN ERR := TRUE; RETURN X; END "+"; BEGIN TEST ("C87B40A","OVERLOADING RESOLUTION OF UNIVERSAL " & "EXPRESSIONS"); B(1) := 1.0 * (+1) IN 0.0 .. 0.0; -- 1.0 * 1 B(2) := (+1) * 1.0 IN 0.0 .. 0.0; -- 1 * 1.0 B(3) := 1.0 / (+1) IN 0.0 .. 0.0; -- 1.0 / 1 B(4) := (+1) + (+1) <= (+1) - (+1); -- 1+1< 1 - 1 B(5) := (+1) * (+1) > (+1) / (+1); -- 1*1 > 1/1 B(6) := (+1) MOD (+1) /= (+1) REM (+1); -- 1 MOD 1 /= 1 REM 1 BEGIN B(7) := (+2) ** (-2) < "-" (-1); -- 2**2 < 1 EXCEPTION WHEN CONSTRAINT_ERROR => FAILED("INCORRECT RESOLUTION FOR INTEGER EXPONENT - 7"); END; B(8) := (+1) REM (+1) > "ABS" (+1); -- 1 REM 1 > ABS 1 B(9) := (+1.0) + (+1.0) <= (+1.0) - (+1.0); -- 2.0 <= 0.0 B(10) := (+1.0) * (+1.0) > (+1.0) / (+1.0); -- 1.0 > 1.0 B(11) := (+2.0) ** (-1) < "-" (-1.0); -- 2.0 < 1.0 B(12) := (+2.0) ** (-1) <= "ABS" (+1.0); -- 2.0 <= 1.0 FOR I IN B'RANGE LOOP IF B(I) /= FALSE THEN FAILED("RESOLUTION OR OPERATIONS INCORRECT FOR " & "UNIVERSAL EXPRESSIONS - " & INTEGER'IMAGE(I) ); END IF; END LOOP; IF ERR THEN FAILED ("RESOLUTION INCORRECT FOR UNIVERSAL EXPRESSIONS"); END IF; RESULT; END C87B40A;
oeis/294/A294956.asm
neoneye/loda-programs
11
1183
<reponame>neoneye/loda-programs ; A294956: a(n) = Sum_{d|n} d^(d + n/d). ; Submitted by <NAME> ; 1,9,82,1041,15626,280212,5764802,134221889,3486785131,100000078254,3138428376722,106993207077516,3937376385699290,155568095598166344,6568408355713287812,295147905180426634241,14063084452067724991010,708235345355369067516669,37589973457545958193355602,2097152000000001000002219366,122694327386105632949286147140,7511413302012830297248940070972,480250763996501976790165756943042,32009658644406818988061882464442364,2220446049250313080847263336191406251,160059109085386090080764717391419421702 add $0,1 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 mov $4,$3 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 add $4,$3 pow $3,$4 add $1,$3 lpe add $1,1 mov $0,$1
asm/script/profiles/profile_2/script.asm
h3rmit-git/F-Zero-Climax-GBA-Translation
6
161696
; F-Zero Climax Translation by Normmatt .align 4 Profile2_CharacterProfile: .sjis "高機動小隊の一員で",TextNL,"有能な外科医。",TextNL,"ジョディの相談役で",TextNL,"もある。元は宇宙連",TextNL,"邦の有能なおかかえ",TextNL,"医師だったが所長の",TextNL,"の命を受けジョディ",TextNL,"のサポート役として",TextNL,"高機動小隊にはけん",TextNL,"された。",TextNL,"パイロットとしての",TextNL,"うでも一流だ。",TextNL,"" .align 4 Profile2_VehicleProfile: .sjis "マシンナンバー03",TextNL,TextNL,"ボディはデリケート、",TextNL,"グリップも弱く、",TextNL,"コーナリングのテク",TextNL,"ニックを必要とする",TextNL,"マシンだが、ストレ",TextNL,"ートでのブースター",TextNL,"の加速、スピードは",TextNL,"他のマシンを寄せつ",TextNL,"けない。",TextNL,"" ; make sure to leave an empty line at the end
ShockRaid.asm
RichardTND/ShockRaid
0
5251
<gh_stars>0 ;############################# ;# Shock Raid # ;# # ;# by <NAME> # ;# # ;# (C)2021 The New Dimension # ;# For Reset Magazine # ;############################# DiskVersion = 1 ;Insert variables source file !source "vars.asm" ;Generate main program !to "shockraid.prg",cbm ;Insert the title screen text charset *=$0800 !bin "bin\textcharset.bin" ;Insert music data 1 (Title, In game music and Game Over jingle) *=$1000 !bin "bin\music.prg",,2 ;Insert main game sprites *=$2000 !bin "bin\gamesprites.bin" ;Insert main game graphics character set *=$3800 !bin "bin\gamecharset.bin" ;There's a bit of space for DISK access for hi score ;saving and loading. *=$4000 !source "diskaccess.asm" ;Insert end screen sequence code *=$4100 !source "endscreen.asm" CharsBackupMemory !align $ff,0 *=$4600 BlankFormation !Fill $ff,0 !byte 0 !Fill $ff,0 !byte 0 ;Insert the game's map (Built from Charpad) *=$4800 mapstart MAPDATA !bin "bin\gamemap.bin" ;Mark the start of the map (mapend = starting position) mapend *=*+10 *=$6200 ;Insert the onetime assembly source code - This is where to jump to after ;packing/crunching this production. !source "onetime.asm" ;Insert title screen code assembly source code !source "titlescreen.asm" ;Insert the main game code !source "gamecode.asm" ;Insert the hi-score check routine code !source "hiscore.asm" ;There should be enough room here (hopefully for alien formation data) ;but the code data should be aligned to the nearest $x00 position !align $ff,0 ;The following files are the X, and Y tables for each alien movement ;pattern. FormationData01 ;!bin "bin\Formation01.prg",,2 !bin "bin\wave1.prg",,2 FormationData02 ;!bin "bin\Formation02.prg",,2 !bin "bin\wave2.prg",,2 FormationData03 ;!bin "bin\Formation03.prg",,2 !bin "bin\wave3.prg",,2 FormationData04 ;!bin "bin\Formation04.prg",,2 !bin "bin\formation05.prg",,2 FormationData05 ;!bin "bin\Formation05.prg",,2 !bin "bin\wave5.prg",,2 FormationData06 ;!bin "bin\Formation06.prg",,2 !bin "bin\wave6.prg",,2 FormationData07 ;!bin "bin\Formation07.prg",,2 !bin "bin\wave7.prg",,2 FormationData08 ;!bin "bin\Formation08.prg",,2 !bin "bin\wave13.prg",,2 FormationData09 ;!bin "bin\Formation09.prg",,2 !bin "bin\wave9.prg",,2 FormationData10 ;!bin "bin\Formation10.prg",,2 !bin "bin\wave10.prg",,2 FormationData11 ;!bin "bin\Formation11.prg",,2 !bin "bin\wave11.prg",,2 FormationData12 ;!bin "bin\Formation12.prg",,2 !bin "bin\wave12.prg",,2 FormationData13 ;!bin "bin\Formation13.prg",,2 !bin "bin\wave8.prg",,2 FormationData14 ;!bin "bin\Formation14.prg",,2 !bin "bin\Formation01.prg",,2 FormationData15 ;!bin "bin\Formation15.prg",,2 !bin "bin\Formation02.prg",,2 FormationData16 ;!bin "bin\Formation16.prg",,2 !bin "bin\formation03.prg",,2 *=$ac00 endscreen2 !bin "bin\endscreen2.bin" ;Insert the game tile data. *=$b000 TILEMEMORY !bin "bin\gametiles.bin" ;Insert title screen end (game completion) text *=$b800 endtext !bin "bin\endtext.bin" *=$bc00 endattribs !bin "bin\endattribs.bin" *=$c400 endscreenmemory !bin "bin\endscreen.bin" ;Insert logo bitmap video RAM data *=$c800 colram !bin "bin\logocolram.prg",,2 ;Insert logo bitmap colour RAM data *=$cc00 vidram !bin "bin\logovidram.prg",,2 ;Insert title screen scroll text *=$d000 !source "scrolltext.asm" ;Insert title screen bitmap graphics data *=$e000 !bin "bin\logobitmap.prg",,2 ;Insert in game sound effects player data *=$f000 !bin "bin\shockraidsfx.prg",,2 ;Insert end screen / hi score music data *=$f400 !bin "bin\music2.prg",,2 ;Insert the HUD graphics data then ;the attributes hud !bin "bin\hud.bin" hudattribs !bin "bin\hudattribs.bin"
stdlib-exts/Prelude.agda
WhatisRT/meta-cedille
35
1810
{-# OPTIONS --guardedness #-} module Prelude where open import Class.Equality public open import Class.Functor public open import Class.Monad public open import Class.Monoid public open import Class.Show public open import Class.Traversable public open import Data.Bool hiding (_≟_; _<_; _<?_; _≤_; _≤?_) public open import Data.Bool.Instance public open import Data.Char using (Char) public open import Data.Char.Instance public open import Data.Empty public open import Data.Empty.Instance public open import Data.Fin using (Fin) public open import Data.List using (List; []; [_]; _∷_; drop; boolFilter; filter; head; reverse; _++_; zipWith; foldl; intersperse; map; null; span; break; allFin; length; mapMaybe; or; and) public open import Data.List.Exts public open import Data.List.Instance public open import Data.Maybe using (Maybe; just; nothing; maybe; from-just; is-just; is-nothing; _<∣>_) public open import Data.Maybe.Instance public open import Data.Nat hiding (_+_; _≟_) public open import Data.Nat.Instance public open import Data.Product using (_×_; _,_; proj₁; proj₂; ∃-syntax; -,_; Σ; swap; Σ-syntax; map₁; map₂) public open import Data.Product.Instance public open import Data.String using (String; unwords; unlines; padRight; _<+>_) public open import Data.String.Exts public open import Data.String.Instance public open import Data.Sum using (_⊎_; inj₁; inj₂; from-inj₁; from-inj₂) public open import Data.Sum.Instance public open import Data.Unit.Instance public open import Data.Unit.Polymorphic using (⊤; tt) public open import IO using (IO; putStr) public open import IO.Finite using (getLine) public open import IO.Exts public open import IO.Instance public open import System.Environment public open import System.Exit public open import Function public open import Relation.Nullary using (Dec; yes; no) public open import Relation.Nullary.Decidable using (⌊_⌋) public open import Relation.Nullary.Negation public open import Relation.Unary using (Decidable) public open import Relation.Binary.PropositionalEquality using (_≡_; refl) public
src/Bisimilarity/Classical.agda
nad/up-to
0
10147
<reponame>nad/up-to<gh_stars>0 ------------------------------------------------------------------------ -- The classical definition of (strong) bisimilarity ------------------------------------------------------------------------ -- This module is largely based on "Enhancements of the bisimulation -- proof method" by <NAME> Sangiorgi. {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Classical {ℓ} (lts : LTS ℓ) where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Function-universe equality-with-J hiding (id; _∘_) open LTS lts open import Bisimilarity.Step lts _[_]⟶_ _[_]⟶_ as S hiding (⟨_,_⟩) open import Indexed-container hiding (⟨_⟩; Bisimilarity; larger⇔smallest) open import Relation ------------------------------------------------------------------------ -- Progressions, bisimulations and bisimilarity -- Progressions. Progression : ∀ {r s} → Rel₂ r Proc → Rel₂ s Proc → Type (ℓ ⊔ r ⊔ s) Progression R S = R ⊆ Step S module Progression {r s} {R : Rel₂ r Proc} {S : Rel₂ s Proc} (P : Progression R S) where -- Some "projections". left-to-right : ∀ {p p′ q μ} → R (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × S (p′ , q′) left-to-right pRq = Step.left-to-right (P pRq) right-to-left : ∀ {p q q′ μ} → R (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × S (p′ , q′) right-to-left pRq = Step.right-to-left (P pRq) open Progression public -- A "constructor" for Progression. ⟪_,_⟫ : ∀ {r s} {R : Rel₂ r Proc} {S : Rel₂ s Proc} → (∀ {p p′ q μ} → R (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × S (p′ , q′)) → (∀ {p q q′ μ} → R (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × S (p′ , q′)) → Progression R S ⟪ lr , rl ⟫ = λ pRq → S.⟨ lr pRq , rl pRq ⟩ -- Bisimulations. Bisimulation : ∀ {r} → Rel₂ r Proc → Type (ℓ ⊔ r) Bisimulation R = Progression R R -- Bisimilarity with a level argument. Bisimilarity′ : ∀ ℓ′ → Rel₂ (lsuc (ℓ ⊔ ℓ′)) Proc Bisimilarity′ ℓ′ = gfp ℓ′ StepC -- Bisimilarity′ ℓ′ is pointwise logically equivalent to -- Bisimilarity′ lzero. -- -- For this reason the code below is mostly restricted to -- Bisimilarity′ lzero. larger⇔smallest : ∀ ℓ′ {p} → Bisimilarity′ ℓ′ p ⇔ Bisimilarity′ lzero p larger⇔smallest ℓ′ = Indexed-container.larger⇔smallest ℓ′ -- Bisimilarity. Bisimilarity : Rel₂ (lsuc ℓ) Proc Bisimilarity = Bisimilarity′ lzero infix 4 _∼_ _∼_ : Proc → Proc → Type (lsuc ℓ) p ∼ q = ∃ λ R → R ⊆ ⟦ StepC ⟧ R × R (p , q) private -- The definition of _∼_ could also have been given more indirectly. indirect-∼ : _∼_ ≡ curry Bisimilarity indirect-∼ = refl -- An unfolding lemma for Bisimilarity′. Bisimilarity′↔ : ∀ {k} ℓ′ {pq} → Extensionality? k (ℓ ⊔ ℓ′) (ℓ ⊔ ℓ′) → Bisimilarity′ ℓ′ pq ↝[ k ] ∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → Bisimulation R × R pq Bisimilarity′↔ {k} ℓ′ {pq} ext = Bisimilarity′ ℓ′ pq ↔⟨⟩ gfp ℓ′ StepC pq ↔⟨⟩ (∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → R ⊆ ⟦ StepC ⟧ R × R pq) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → ⊆-congʳ ext $ inverse-ext? Step↔StepC (lower-extensionality? k ℓ′ lzero ext)) ⟩□ (∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → Bisimulation R × R pq) □ -- An unfolding lemma for Bisimilarity. Bisimilarity↔ : ∀ {k pq} → Extensionality? k ℓ ℓ → Bisimilarity pq ↝[ k ] ∃ λ (R : Rel₂ ℓ Proc) → Bisimulation R × R pq Bisimilarity↔ = Bisimilarity′↔ lzero -- A "constructor". ⟨_,_,_⟩ : ∀ {p q} → (R : Rel₂ ℓ Proc) → Bisimulation R → R (p , q) → p ∼ q ⟨ R , bisim , pRq ⟩ = _⇔_.from (Bisimilarity↔ _) (R , bisim , pRq) ------------------------------------------------------------------------ -- Bisimilarity is an equivalence relation -- Reflexivity, proved generally for Bisimilarity′. reflexive-∼′ : ∀ ℓ {p} → Bisimilarity′ ℓ (p , p) reflexive-∼′ ℓ = _⇔_.from (Bisimilarity′↔ ℓ _) ( ↑ ℓ ∘ uncurry _≡_ , ⟪ (λ p≡q p⟶p′ → _ , subst (_[ _ ]⟶ _) (lower p≡q) p⟶p′ , lift refl) , (λ p≡q q⟶q′ → _ , subst (_[ _ ]⟶ _) (sym $ lower p≡q) q⟶q′ , lift refl) ⟫ , lift refl ) -- Reflexivity. reflexive-∼ : ∀ {p} → p ∼ p reflexive-∼ = reflexive-∼′ lzero -- Symmetry. symmetric-∼ : ∀ {p q} → p ∼ q → q ∼ p symmetric-∼ p∼q with _⇔_.to (Bisimilarity↔ _) p∼q ... | R , R-is-a-bisimulation , pRq = ⟨ R ⁻¹ , ⟪ right-to-left R-is-a-bisimulation , left-to-right R-is-a-bisimulation ⟫ , pRq ⟩ -- Transitivity. transitive-∼ : ∀ {p q r} → p ∼ q → q ∼ r → p ∼ r transitive-∼ p∼q q∼r with _⇔_.to (Bisimilarity↔ _) p∼q | _⇔_.to (Bisimilarity↔ _) q∼r ... | R₁ , R-is₁ , pR₁q | R₂ , R-is₂ , qR₂r = ⟨ R₁ ⊙ R₂ , ⟪_,_⟫ {R = _ ⊙ _} (λ { (q , pR₁q , qR₂r) p⟶p′ → let q′ , q⟶q′ , p′R₁q′ = left-to-right R-is₁ pR₁q p⟶p′ r′ , r⟶r′ , q′R₂r′ = left-to-right R-is₂ qR₂r q⟶q′ in r′ , r⟶r′ , (q′ , p′R₁q′ , q′R₂r′) }) (λ { (q , pR₁q , qR₂r) r⟶r′ → let q′ , q⟶q′ , q′R₂r′ = right-to-left R-is₂ qR₂r r⟶r′ p′ , p⟶p′ , p′R₁q′ = right-to-left R-is₁ pR₁q q⟶q′ in p′ , p⟶p′ , (q′ , p′R₁q′ , q′R₂r′) }) , (_ , pR₁q , qR₂r) ⟩ -- A function that can be used to aid the instance resolution -- mechanism. infix -2 ∼:_ ∼:_ : ∀ {p q} → p ∼ q → p ∼ q ∼:_ = id ------------------------------------------------------------------------ -- Lemmas relating bisimulations and bisimilarity -- Bisimilarity is a bisimulation. bisimilarity-is-a-bisimulation : Bisimulation Bisimilarity bisimilarity-is-a-bisimulation = Bisimilarity ⊆⟨ gfp-out ℓ ⟩ ⟦ StepC ⟧ Bisimilarity ⊆⟨ _⇔_.from (Step↔StepC _) ⟩∎ Step Bisimilarity ∎ -- Bisimilarity is larger than every bisimulation. bisimulation⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation R → R ⊆ Bisimilarity bisimulation⊆∼ {r} {R} R-is-a-bisimulation = R ⊆⟨ gfp-unfold lzero ( R ⊆⟨ R-is-a-bisimulation ⟩ Step R ⊆⟨ Step↔StepC _ ⟩∎ ⟦ StepC ⟧ R ∎) ⟩ Bisimilarity′ r ⊆⟨ _⇔_.to (larger⇔smallest r) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to bisimilarity -- Bisimulations up to bisimilarity. Bisimulation-up-to-bisimilarity : ∀ {r} → Rel₂ r Proc → Type (lsuc ℓ ⊔ r) Bisimulation-up-to-bisimilarity R = Progression R (Bisimilarity ⊙ R ⊙ Bisimilarity) -- If R is a bisimulation up to bisimilarity, then ∼R∼ is a -- bisimulation. bisimulation-up-to-∼⇒bisimulation : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-bisimilarity R → Bisimulation (Bisimilarity ⊙ R ⊙ Bisimilarity) bisimulation-up-to-∼⇒bisimulation R-is = ⟪_,_⟫ {R = _ ⊙ _ ⊙ _} (λ { (q , p∼q , r , qRr , r∼s) p⟶p′ → let q′ , q⟶q′ , p′∼q′ = left-to-right bisimilarity-is-a-bisimulation p∼q p⟶p′ r′ , r⟶r′ , (q″ , q′∼q″ , r″ , q″Rr″ , r″∼r′) = left-to-right R-is qRr q⟶q′ s′ , s⟶s′ , r′∼s′ = left-to-right bisimilarity-is-a-bisimulation r∼s r⟶r′ in s′ , s⟶s′ , q″ , transitive-∼ p′∼q′ q′∼q″ , r″ , q″Rr″ , transitive-∼ r″∼r′ r′∼s′ }) (λ { (q , p∼q , r , qRr , r∼s) s⟶s′ → let r′ , r⟶r′ , r′∼s′ = right-to-left bisimilarity-is-a-bisimulation r∼s s⟶s′ q′ , q⟶q′ , (q″ , q′∼q″ , r″ , q″Rr″ , r″∼r′) = right-to-left R-is qRr r⟶r′ p′ , p⟶p′ , p′∼q′ = right-to-left bisimilarity-is-a-bisimulation p∼q q⟶q′ in p′ , p⟶p′ , q″ , transitive-∼ p′∼q′ q′∼q″ , r″ , q″Rr″ , transitive-∼ r″∼r′ r′∼s′ }) -- If R is a bisimulation up to bisimilarity, then R is contained in -- bisimilarity. bisimulation-up-to-∼⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-bisimilarity R → R ⊆ Bisimilarity bisimulation-up-to-∼⊆∼ {R = R} R-is = R ⊆⟨ (λ { {p , q} pRq → p , reflexive-∼ , q , pRq , reflexive-∼ }) ⟩ Bisimilarity ⊙ R ⊙ Bisimilarity ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-∼⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to union -- Bisimulations up to ∪. Bisimulation-up-to-∪ : ∀ {r} → Rel₂ r Proc → Type (lsuc ℓ ⊔ r) Bisimulation-up-to-∪ R = Progression R (R ∪ Bisimilarity) -- If _R_ is a bisimulation up to ∪, then _R_ ∪ _∼_ is a bisimulation. bisimulation-up-to-∪⇒bisimulation : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-∪ R → Bisimulation (R ∪ Bisimilarity) bisimulation-up-to-∪⇒bisimulation R-is = ⟪ [ left-to-right R-is , (λ p∼q → Σ-map id (Σ-map id inj₂) ∘ left-to-right bisimilarity-is-a-bisimulation p∼q) ] , [ right-to-left R-is , (λ p∼q → Σ-map id (Σ-map id inj₂) ∘ right-to-left bisimilarity-is-a-bisimulation p∼q) ] ⟫ -- If R is a bisimulation up to ∪, then R is contained in -- bisimilarity. bisimulation-up-to-∪⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-∪ R → R ⊆ Bisimilarity bisimulation-up-to-∪⊆∼ {R = R} R-is = R ⊆⟨ inj₁ ⟩ R ∪ Bisimilarity ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-∪⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to reflexive transitive closure -- Bisimulations up to reflexive transitive closure. Bisimulation-up-to-* : Rel₂ ℓ Proc → Type ℓ Bisimulation-up-to-* R = Progression R (R *) -- If R is a bisimulation up to reflexive transitive closure, then R * -- is a bisimulation. bisimulation-up-to-*⇒bisimulation : ∀ {R} → Bisimulation-up-to-* R → Bisimulation (R *) bisimulation-up-to-*⇒bisimulation {R} R-is = ⟪ lr , rl ⟫ where lr : ∀ {p p′ q μ} → (R *) (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × (R *) (p′ , q′) lr (zero , refl) q⟶p′ = _ , q⟶p′ , zero , refl lr (suc n , r , pRr , rRⁿq) p⟶p′ = let r′ , r⟶r′ , p′R*r′ = left-to-right R-is pRr p⟶p′ q′ , q⟶q′ , r′R*q′ = lr (n , rRⁿq) r⟶r′ in q′ , q⟶q′ , *-trans p′R*r′ r′R*q′ rl : ∀ {p q q′ μ} → (R *) (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × (R *) (p′ , q′) rl (zero , refl) p⟶q′ = _ , p⟶q′ , zero , refl rl (suc n , r , pRr , rRⁿq) q⟶q′ = let r′ , r⟶r′ , r′R*q′ = rl (n , rRⁿq) q⟶q′ p′ , p⟶p′ , p′R*r′ = right-to-left R-is pRr r⟶r′ in p′ , p⟶p′ , *-trans p′R*r′ r′R*q′ -- If R is a bisimulation up to reflexive transitive closure, then R -- is contained in bisimilarity. bisimulation-up-to-*⊆∼ : ∀ {R} → Bisimulation-up-to-* R → R ⊆ Bisimilarity bisimulation-up-to-*⊆∼ {R} R-is = R ⊆⟨ (λ pRq → 1 , _ , pRq , refl) ⟩ (R *) ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-*⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Some preservation results -- These results are not taken from "Enhancements of the bisimulation -- proof method". -- Equal processes are bisimilar. ≡⇒∼ : ∀ {p q} → p ≡ q → p ∼ q ≡⇒∼ refl = reflexive-∼ -- Precomposition with the lifting operator preserves the "is a -- bisimulation" relation. ↑-preserves-bisimulations : ∀ {ℓ r} {R : Rel₂ r Proc} → Bisimulation R → Bisimulation (↑ ℓ ∘ R) ↑-preserves-bisimulations R-is = ⟪ (λ pRq → Σ-map id (Σ-map id lift) ∘ left-to-right R-is (lower pRq)) , (λ pRq → Σ-map id (Σ-map id lift) ∘ right-to-left R-is (lower pRq)) ⟫ -- The "times two" operator preserves the "is a bisimulation" -- relation. ×2-preserves-bisimulations : ∀ {r} {R : Rel₂ r Proc} → Bisimulation R → Bisimulation (R ∪ R) ×2-preserves-bisimulations R-is = ⟪ (let f = λ pRq p⟶p′ → Σ-map id (Σ-map id inj₁) (left-to-right R-is pRq p⟶p′) in [ f , f ]) , (let f = λ pRq q⟶q′ → Σ-map id (Σ-map id inj₁) (right-to-left R-is pRq q⟶q′) in [ f , f ]) ⟫
programs/oeis/210/A210984.asm
neoneye/loda
22
86088
; A210984: Total number of states of the first n subshells of the nuclear shell model in which the subshells are ordered by energy level in increasing order. ; 2,6,8,14,16,20,28,32,34,40,50,56,58,62,70,82,90,94,96,102,112,126,136,142,144,148,156,168,184,196,204,208,210,216,226,240,258,272,282,288,290,294,302,314,330,350,366,378,386,390,392,398,408,422,440,462 mul $0,2 lpb $0 mov $2,$0 sub $0,2 seq $2,4737 ; Concatenation of sequences (1,2,...,n-1,n,n-1,...,1) for n >= 1. add $1,$2 add $1,$2 lpe add $1,2 mov $0,$1
source/nodes/program-nodes-use_clauses.adb
reznikmm/gela
0
17856
<gh_stars>0 -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package body Program.Nodes.Use_Clauses is function Create (Use_Token : not null Program.Lexical_Elements .Lexical_Element_Access; All_Token : Program.Lexical_Elements.Lexical_Element_Access; Type_Token : Program.Lexical_Elements.Lexical_Element_Access; Clause_Names : not null Program.Elements.Expressions .Expression_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Use_Clause is begin return Result : Use_Clause := (Use_Token => Use_Token, All_Token => All_Token, Type_Token => Type_Token, Clause_Names => Clause_Names, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Clause_Names : not null Program.Elements.Expressions .Expression_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_All : Boolean := False; Has_Type : Boolean := False) return Implicit_Use_Clause is begin return Result : Implicit_Use_Clause := (Clause_Names => Clause_Names, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Has_All => Has_All, Has_Type => Has_Type, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Clause_Names (Self : Base_Use_Clause) return not null Program.Elements.Expressions.Expression_Vector_Access is begin return Self.Clause_Names; end Clause_Names; overriding function Use_Token (Self : Use_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Use_Token; end Use_Token; overriding function All_Token (Self : Use_Clause) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.All_Token; end All_Token; overriding function Type_Token (Self : Use_Clause) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Type_Token; end Type_Token; overriding function Semicolon_Token (Self : Use_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Has_All (Self : Use_Clause) return Boolean is begin return Self.All_Token.Assigned; end Has_All; overriding function Has_Type (Self : Use_Clause) return Boolean is begin return Self.Type_Token.Assigned; end Has_Type; overriding function Is_Part_Of_Implicit (Self : Implicit_Use_Clause) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Use_Clause) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Use_Clause) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Has_All (Self : Implicit_Use_Clause) return Boolean is begin return Self.Has_All; end Has_All; overriding function Has_Type (Self : Implicit_Use_Clause) return Boolean is begin return Self.Has_Type; end Has_Type; procedure Initialize (Self : in out Base_Use_Clause'Class) is begin for Item in Self.Clause_Names.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Use_Clause (Self : Base_Use_Clause) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Use_Clause; overriding function Is_Clause (Self : Base_Use_Clause) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Clause; overriding procedure Visit (Self : not null access Base_Use_Clause; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Use_Clause (Self); end Visit; overriding function To_Use_Clause_Text (Self : in out Use_Clause) return Program.Elements.Use_Clauses.Use_Clause_Text_Access is begin return Self'Unchecked_Access; end To_Use_Clause_Text; overriding function To_Use_Clause_Text (Self : in out Implicit_Use_Clause) return Program.Elements.Use_Clauses.Use_Clause_Text_Access is pragma Unreferenced (Self); begin return null; end To_Use_Clause_Text; end Program.Nodes.Use_Clauses;
grammars/UCParser.g4
PolaricEntropy/UnrealScript-Language-Service
0
4177
parser grammar UCParser; options { tokenVocab = UCLexer; } // Class modifier keywords have been commented out, because we are not using them for parsing. identifier : ID | 'default' | 'self' | 'super' | 'global' | 'class' | 'interface' | 'within' | 'const' | 'enum' | 'struct' | 'var' | 'local' | 'replication' | 'operator' | 'preoperator' | 'postoperator' | 'delegate' | 'function' | 'event' | 'state' | 'map' | 'defaultproperties' | 'structdefaultproperties' | 'for' | 'foreach' | 'return' | 'break' | 'continue' | 'stop' | 'case' | 'switch' | 'until' | 'do' | 'while' | 'else' | 'if' | 'ignores' | 'unreliable' | 'reliable' | 'cpptext' | 'cppstruct' | 'structcpptext' | 'array' | 'byte' | 'int' | 'float' | 'string' | 'pointer' | 'button' | 'bool' | 'name' | 'true' | 'false' | 'none' | 'extends' | 'expands' | 'public' | 'protected' | 'protectedwrite' | 'private' | 'privatewrite' | 'localized' | 'out' | 'optional' | 'init' | 'skip' | 'coerce' | 'final' | 'latent' | 'singular' | 'static' | 'exec' | 'iterator' | 'simulated' | 'auto' | 'noexport' | 'noexportheader' | 'editconst' | 'edfindable' | 'editinline' | 'editinlinenotify' | 'editinlineuse' | 'edithide' | 'editconstarray' | 'editfixedsize' | 'editoronly' | 'editortextbox' | 'noclear' | 'noimport' | 'nontransactional' | 'serializetext' | 'config' | 'globalconfig' | 'intrinsic' | 'native' // |'nativereplication' // |'nativeonly' | 'export' // |'abstract' // |'perobjectconfig' // |'perobjectlocalized' // |'placeable' // |'nousercreate' // |'notplaceable' // |'safereplace' // |'dependson' // |'showcategories' // |'hidecategories' // |'guid' | 'long' | 'transient' // |'nontransient' | 'cache' | 'interp' | 'repretry' | 'repnotify' | 'notforconsole' | 'archetype' | 'crosslevelactive' | 'crosslevelpassive' | 'allowabstract' | 'automated' | 'travel' | 'input' // |'cacheexempt' // |'hidedropdown' | 'instanced' | 'databinding' | 'duplicatetransient' // |'parseconfig' // |'editinlinenew' // |'noteditinlinenew' // |'exportstructs' // |'dllbind' | 'deprecated' | 'strictconfig' | 'atomic' | 'atomicwhencooked' | 'immutable' | 'immutablewhencooked' | 'virtual' | 'server' | 'client' | 'dllimport' | 'demorecording' | 'k2call' | 'k2pure' | 'k2override' // |'collapsecategories' // |'dontcollapsecategories' // |'implements' // |'classgroup' // |'autoexpandcategories' // |'autocollapsecategories' // |'dontautocollapsecategories' // |'dontsortcategories' // |'inherits' // |'forcescriptorder' | 'begin' | 'object' | 'end' | 'new' | 'goto' | 'assert' | 'vect' | 'rot' | 'rng' ; // Parses the following possiblities. // Package.Class // Class.Field // Class / Field qualifiedIdentifier: left=identifier (DOT right=identifier)?; // FIXME: Consumes atleast one token after "#error" directive : SHARP identifier {((): boolean => { if (!this.currentToken) { return true; } const initialLine = this.currentToken.line; while (this.currentToken.line === initialLine) { if (this.matchedEOF) { break; } this.consume(); // FIXME! if (!this.currentToken || this.currentToken.text === '<EOF>') { break; } } return true; })()}? ; program: member* EOF; member : classDecl | constDecl | (enumDecl SEMICOLON) | (structDecl SEMICOLON) | varDecl | cppText | replicationBlock | functionDecl | stateDecl | defaultPropertiesBlock | directive | SEMICOLON ; literal : boolLiteral | intLiteral | floatLiteral | stringLiteral | noneLiteral | nameLiteral | vectToken | rotToken | rngToken | nameOfToken | objectLiteral ; floatLiteral: (MINUS | PLUS)? FLOAT; intLiteral: (MINUS | PLUS)? INTEGER; numberLiteral: (MINUS | PLUS)? (FLOAT | INTEGER); stringLiteral: STRING; nameLiteral: NAME; boolLiteral : 'true' | 'false' ; noneLiteral: 'none'; // e.g. Class'Engine.Actor'.const.MEMBER or Texture'Textures.Group.Name'.default objectLiteral: identifier NAME; classDecl : ('class' | 'interface') identifier (extendsClause withinClause?)? classModifier* SEMICOLON ; extendsClause: ('extends' | 'expands') id=qualifiedIdentifier; withinClause: 'within' id=qualifiedIdentifier; classModifier: identifier modifierArguments?; // in UC3 a class can have a custom native name. // (kwNATIVE modifierArgument?) // | kwNATIVEREPLICATION // | kwLOCALIZED // UC1 // | kwABSTRACT // | kwPEROBJECTCONFIG // | kwTRANSIENT // | kwEXPORT // | kwNOEXPORT // | kwNOUSERCREATE // | kwSAFEREPLACE // | (kwCONFIG modifierArgument?) // // UC2+ // | kwPLACEABLE // | kwNOTPLACEABLE // | kwCACHEEXEMPT // UT2004 // | kwHIDEDROPDOWN // | kwEXPORTSTRUCTS // | kwINSTANCED // | kwPARSECONFIG // | kwEDITINLINENEW // | kwNOTEDITINLINENEW // | (kwDEPENDSON modifierArguments) // | (kwCOLLAPSECATEGORIES modifierArguments) // | (kwDONTCOLLAPSECATEGORIES modifierArguments?) // | (kwSHOWCATEGORIES modifierArguments) // | (kwHIDECATEGORIES modifierArguments) // | (kwGUID (LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA INTEGER RPAREN)) // // UC3+ // | kwNATIVEONLY // | kwNONTRANSIENT // | kwPEROBJECTLOCALIZED // | kwDEPRECATED // | (kwCLASSREDIRECT modifierArguments) // | (kwDLLBIND modifierArgument) // | (kwIMPLEMENTS modifierArgument) // | (kwCLASSGROUP modifierArguments) // | (kwAUTOEXPANDCATEGORIES modifierArguments) // | (kwAUTOCOLLAPSECATEGORIES modifierArguments) // | (kwDONTAUTOCOLLAPSECATEGORIES modifierArguments) // | (kwDONTSORTCATEGORIES modifierArguments) // | (kwINHERITS modifierArguments) // // true/false only // | (kwFORCESCRIPTORDER modifierArgument) // ; //ID (LPARENT ID (COMMA ID)* RPARENT)? modifierValue : identifier | numberLiteral ; modifierArgument : OPEN_PARENS modifierValue CLOSE_PARENS ; modifierArguments : OPEN_PARENS (modifierValue COMMA?)+ CLOSE_PARENS ; constDecl : 'const' identifier (ASSIGNMENT expr=constValue)? SEMICOLON ; constValue : noneLiteral | boolLiteral | floatLiteral | intLiteral | stringLiteral | objectLiteral | nameLiteral | vectToken | rotToken | rngToken | arrayCountToken | nameOfToken | sizeOfToken ; vectToken : 'vect' (OPEN_PARENS numberLiteral COMMA numberLiteral COMMA numberLiteral CLOSE_PARENS) ; rotToken : 'rot' (OPEN_PARENS numberLiteral COMMA numberLiteral COMMA numberLiteral CLOSE_PARENS) ; rngToken : 'rng' (OPEN_PARENS numberLiteral COMMA numberLiteral CLOSE_PARENS) ; arrayCountToken : 'arraycount' (OPEN_PARENS identifier CLOSE_PARENS) ; nameOfToken : 'nameof' (OPEN_PARENS identifier CLOSE_PARENS) ; sizeOfToken : 'sizeof' (OPEN_PARENS identifier CLOSE_PARENS) ; enumDecl: 'enum' identifier metaData? OPEN_BRACE (enumMember (COMMA enumMember)* COMMA?)? CLOSE_BRACE ; enumMember : identifier metaData? COMMA? ; structDecl : 'struct' exportBlockText? structModifier* identifier extendsClause? OPEN_BRACE structMember* CLOSE_BRACE ; structMember : constDecl | (enumDecl SEMICOLON) | (structDecl SEMICOLON) | varDecl | structCppText | structDefaultPropertiesBlock | directive | SEMICOLON ; structModifier // UC2+ : 'native' | 'transient' | 'export' | 'init' | 'long' // UC3+ | 'strictconfig' | 'atomic' | 'atomicwhencooked' | 'immutable' | 'immutablewhencooked' ; arrayDimRefer : INTEGER | qualifiedIdentifier // Referres a constant in class scope, or an enum's member. ; // var (GROUP) // MODIFIER TYPE // VARIABLE, VARIABLE...; varDecl : 'var' (OPEN_PARENS categoryList? CLOSE_PARENS)? varType variable (COMMA variable)* SEMICOLON ; // id[5] {DWORD} <Order=1> variable : identifier (OPEN_BRACKET arrayDim=arrayDimRefer? CLOSE_BRACKET)? exportBlockText? metaData? ; // UC3 <UIMin=0.0|UIMax=1.0|Toolip=Hello world!> metaData : LT metaTagList? GT ; metaTagList : metaTag (BITWISE_OR metaTag)* ; metaTag : identifier (ASSIGNMENT metaText)? ; metaText : (~(BITWISE_OR | GT))* ; categoryList : identifier (COMMA identifier)* ; variableModifier : ('localized' | 'native' | 'const' | 'editconst' | 'globalconfig' | 'transient' | 'travel' | 'input' // UC2 | 'export' | 'noexport' | 'noimport' | 'cache' | 'automated' | 'editinline' | 'editinlinenotify' | 'editinlineuse' | 'editconstarray' | 'edfindable' // UC3 | 'init' | 'edithide' | 'editfixedsize' | 'editoronly' | 'editortextbox' | 'noclear' | 'serializetext' | 'nontransactional' | 'instanced' | 'databinding' | 'duplicatetransient' | 'repretry' | 'repnotify' | 'interp' | 'deprecated' | 'notforconsole' | 'archetype' | 'crosslevelactive' | 'crosslevelpassive' | 'allowabstract') // I have only see this occur in XCOM2, but may possibly be a late UC3+ feature | ('config' (OPEN_PARENS identifier CLOSE_PARENS)? ) | ('public' exportBlockText?) | ('protected' exportBlockText?) | ('protectedwrite' exportBlockText?) | ('private' exportBlockText?) | ('privatewrite' exportBlockText?) ; primitiveType : 'byte' | 'int' | 'float' | 'bool' | 'pointer' | 'string' | 'name' | 'button' // alias for a string with an input modifier ; typeDecl : enumDecl // Only allowed as a top-scope member. | structDecl // Only allowed as a top-scope member. | primitiveType | classType | arrayType | delegateType | mapType | qualifiedIdentifier ; varType : variableModifier* typeDecl ; // Note: inlinedDeclTypes includes another arrayGeneric! arrayType : 'array' (LT varType GT) ; classType : 'class' (LT identifier GT)? ; delegateType : 'delegate' (LT qualifiedIdentifier GT) ; // TODO: qualifiedIdentifier is hardcoded to 2 identifiers MAX. mapType : 'map' exportBlockText ; cppText : 'cpptext' exportBlockText ; structCppText : ('structcpptext' | 'cppstruct') exportBlockText ; // UnrealScriptBug: Anything WHATSOEVER can be written after this closing brace as long as it's on the same line! exportBlockText : OPEN_BRACE (~(OPEN_BRACE | CLOSE_BRACE)+ | exportBlockText)* CLOSE_BRACE ; replicationBlock : 'replication' OPEN_BRACE replicationStatement* CLOSE_BRACE ; replicationModifier : 'reliable' | 'unreliable' ; replicationStatement : replicationModifier? 'if' (OPEN_PARENS expression CLOSE_PARENS) identifier (COMMA identifier)* SEMICOLON ; /* Parses: * public simulated function coerce class<Actor> test(optional int p1, int p2) const; */ functionDecl : functionSpecifier+ (returnTypeModifier? returnType=typeDecl)? functionName (OPEN_PARENS params=parameters? CLOSE_PARENS) 'const'? functionBody ; functionBody : SEMICOLON | (OPEN_BRACE functionMember* statement* CLOSE_BRACE) ; /* Parses: * { local Actor test, test2; return test.Class; } */ functionMember : constDecl | localDecl | directive | SEMICOLON ; functionSpecifier : ('function' | 'simulated' | 'static' | 'exec' | 'final' | 'event' | 'delegate' | 'preoperator' | 'postoperator' | 'latent' | 'singular' | 'iterator' // UC3 | 'const' | 'noexport' | 'noexportheader' | 'virtual' | 'reliable' | 'unreliable' | 'server' | 'client' | 'dllimport' | 'demorecording' | 'k2call' | 'k2pure' | 'k2override') | ('native' (OPEN_PARENS nativeToken=INTEGER CLOSE_PARENS)?) | ('operator' (OPEN_PARENS operatorPrecedence=INTEGER CLOSE_PARENS)) | ('public' exportBlockText?) | ('protected' exportBlockText?) | ('private' exportBlockText?) ; functionName: identifier | operatorName; parameters: paramDecl (COMMA paramDecl)*; paramDecl: paramModifier* typeDecl variable (ASSIGNMENT expression)?; returnTypeModifier : 'coerce' // UC3+ ; paramModifier : 'out' | 'optional' | 'init' | 'skip' | 'coerce' | 'const' ; localDecl : 'local' typeDecl variable (COMMA variable)* SEMICOLON ; stateDecl : stateModifier* 'state' (OPEN_PARENS CLOSE_PARENS)? identifier extendsClause? OPEN_BRACE stateMember* statement* CLOSE_BRACE ; stateModifier : 'auto' | 'simulated' ; stateMember : constDecl | localDecl | ignoresDecl | functionDecl | directive | SEMICOLON ; ignoresDecl : 'ignores' (identifier (COMMA identifier)*) SEMICOLON ; codeBlockOptional : (OPEN_BRACE statement* CLOSE_BRACE) | statement ; statement : SEMICOLON | ifStatement | forStatement | foreachStatement | whileStatement | doStatement | switchStatement | breakStatement | continueStatement | returnStatement | gotoStatement | labeledStatement | assertStatement | stopStatement | constDecl // We must check for expressions after ALL statements so that we don't end up capturing statement keywords as identifiers. | expressionStatement | directive ; expressionStatement: expressionWithAssignment SEMICOLON; ifStatement : 'if' (OPEN_PARENS expression CLOSE_PARENS) codeBlockOptional elseStatement? ; elseStatement: 'else' codeBlockOptional; foreachStatement: 'foreach' primaryExpression codeBlockOptional; forStatement : 'for' (OPEN_PARENS (initExpr=expressionWithAssignment SEMICOLON) (condExpr=expressionWithAssignment SEMICOLON) nextExpr=expressionWithAssignment CLOSE_PARENS) codeBlockOptional ; whileStatement : 'while' (OPEN_PARENS expression CLOSE_PARENS) codeBlockOptional ; doStatement : 'do' codeBlockOptional 'until' (OPEN_PARENS expression CLOSE_PARENS) ; switchStatement : 'switch' (OPEN_PARENS expression CLOSE_PARENS) // Note: Switch braces are NOT optional OPEN_BRACE caseClause* defaultClause? CLOSE_BRACE ; caseClause : 'case' expression? COLON statement* ; defaultClause : 'default' COLON statement* ; returnStatement: 'return' expression? SEMICOLON; breakStatement: 'break' SEMICOLON; continueStatement: 'continue' SEMICOLON; stopStatement: 'stop' SEMICOLON; labeledStatement: identifier COLON; gotoStatement: 'goto' expression SEMICOLON; assertStatement: 'assert' (OPEN_PARENS expression CLOSE_PARENS) SEMICOLON; // All valid operator names (for declarations) operatorName : STAR | DIV | MODULUS | PLUS | MINUS | LSHIFT | RSHIFT | SHIFT | DOLLAR | AT | SHARP | BANG | AMP | BITWISE_OR | CARET | INCR | DECR | TILDE | EXP | LT | GT | OR | AND | EQ | NEQ | GEQ | LEQ | IEQ | MEQ | ASSIGNMENT_INCR | ASSIGNMENT_DECR | ASSIGNMENT_AT | ASSIGNMENT_DOLLAR | ASSIGNMENT_AND | ASSIGNMENT_OR | ASSIGNMENT_STAR | ASSIGNMENT_CARET | ASSIGNMENT_DIV ; expressionWithAssignment : assignmentExpression | primaryExpression ; expression : primaryExpression ; // Inclusive template argument (will be parsed as a function call) assignmentExpression : left=primaryExpression id=ASSIGNMENT right=primaryExpression | left=primaryExpression id=(ASSIGNMENT_INCR | ASSIGNMENT_DECR | ASSIGNMENT_AT | ASSIGNMENT_DOLLAR | ASSIGNMENT_AND | ASSIGNMENT_OR | ASSIGNMENT_STAR | ASSIGNMENT_CARET | ASSIGNMENT_DIV) right=primaryExpression ; primaryExpression : primaryExpression (OPEN_BRACKET expression CLOSE_BRACKET) #elementAccessExpression | primaryExpression '.' classPropertyAccessSpecifier '.' identifier #propertyAccessExpression | primaryExpression '.' identifier #propertyAccessExpression | primaryExpression (OPEN_PARENS arguments? CLOSE_PARENS) #callExpression | 'new' (OPEN_PARENS arguments? CLOSE_PARENS)? primaryExpression #newExpression | 'class' (LT identifier GT) (OPEN_PARENS expression CLOSE_PARENS) #metaClassExpression | 'arraycount' (OPEN_PARENS primaryExpression CLOSE_PARENS) #arrayCountExpression | 'super' (OPEN_PARENS identifier CLOSE_PARENS)? #superExpression | id=INCR right=primaryExpression #preOperatorExpression | id=DECR right=primaryExpression #preOperatorExpression | id=PLUS right=primaryExpression #preOperatorExpression | id=MINUS right=primaryExpression #preOperatorExpression | id=TILDE right=primaryExpression #preOperatorExpression | id=BANG right=primaryExpression #preOperatorExpression | id=MODULUS right=primaryExpression #preOperatorExpression | id=SHARP right=primaryExpression #preOperatorExpression | id=DOLLAR right=primaryExpression #preOperatorExpression | id=AT right=primaryExpression #preOperatorExpression | left=primaryExpression id=INCR #postOperatorExpression | left=primaryExpression id=DECR #postOperatorExpression | left=primaryExpression id=EXP right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(STAR|DIV) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=MODULUS right=primaryExpression #binaryOperatorExpression // Note, checking for ID instead of identifier here, // -- so that we don't missmtach 'if, or return' statements // -- after a foreach's expression. | left=primaryExpression id=ID right=primaryExpression #binaryNamedOperatorExpression | left=primaryExpression id=(PLUS|MINUS) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(LSHIFT|RSHIFT|SHIFT) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(LT|GT|LEQ|GEQ|EQ|IEQ) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=NEQ right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(AMP|CARET|BITWISE_OR) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(AND|MEQ) right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=OR right=primaryExpression #binaryOperatorExpression | left=primaryExpression id=(DOLLAR|AT) right=primaryExpression #binaryOperatorExpression | cond=primaryExpression INTERR left=primaryExpression COLON right=primaryExpression #conditionalExpression | 'self' #selfReferenceExpression | 'default' #defaultReferenceExpression | 'static' #staticAccessExpression | 'global' #globalAccessExpression | literal #literalExpression // Note any keyword must preceed identifier! | identifier #memberExpression // | id=identifier right=primaryExpression #preNamedOperatorExpression // | left=primaryExpression id=identifier #postNamedOperatorExpression | (OPEN_PARENS expression CLOSE_PARENS) #parenthesizedExpression ; classPropertyAccessSpecifier : 'default' | 'static' | 'const' ; // created(, s, test); argument: COMMA | expression COMMA?; arguments: argument+; defaultPropertiesBlock : 'defaultproperties' // UnrealScriptBug: Must be on the line after keyword! OPEN_BRACE defaultStatement* CLOSE_BRACE ; structDefaultPropertiesBlock : 'structdefaultproperties' // UnrealScriptBug: Must be on the line after keyword! OPEN_BRACE defaultStatement* CLOSE_BRACE ; // TODO: Perhaps do what we do in the directive rule, just skip until we hit a new line or a "|". defaultStatement : objectDecl | defaultAssignmentExpression // TODO: Add a warning, from a technical point of view, // -- the UC compiler just skips any character till it hits a newline character. | SEMICOLON // "command chaining", e.g. "IntA=1|IntB=2" is valid code, // -- but if the | were a space, the second variable will be ignored (by the compiler). | BITWISE_OR ; defaultExpression : identifier DOT defaultExpression #defaultPropertyAccessExpression | identifier (OPEN_PARENS INTEGER CLOSE_PARENS) #defaultElementAccessExpression | identifier (OPEN_PARENS arguments? CLOSE_PARENS ) #defaultCallExpression | identifier (OPEN_BRACKET INTEGER CLOSE_BRACKET) #defaultElementAccessExpression | identifier #defaultMemberExpression ; defaultAssignmentExpression : defaultExpression ASSIGNMENT ((OPEN_BRACE defaultLiteral CLOSE_BRACE) | defaultLiteral) ; objectDecl : // UnrealScriptBug: name= and class= are required to be on the same line as the keyword! 'begin' 'object' defaultStatement* 'end' 'object' ; // (variableList) structLiteral : OPEN_PARENS defaultArguments? CLOSE_PARENS ; qualifiedIdentifierLiteral : identifier (DOT identifier)+ ; identifierLiteral : identifier ; // id=literal,* or literal,* defaultArguments : (defaultLiteral (COMMA defaultLiteral)*) | (defaultAssignmentExpression (COMMA defaultAssignmentExpression)*) ; defaultLiteral : structLiteral | noneLiteral | boolLiteral | floatLiteral | intLiteral | stringLiteral | objectLiteral | qualifiedIdentifierLiteral | identifierLiteral ;
sql-parser/src/main/antlr/SqlBase.g4
scampi/crate
0
1175
/* * Licensed to Crate.io Inc. or its affiliates ("Crate.io") under one or * more contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright ownership. * Crate.io licenses this file to you under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * However, if you have executed another commercial license agreement with * Crate.io these terms will supersede the license and you may use the * software solely pursuant to the terms of the relevant commercial * agreement. */ grammar SqlBase; singleStatement : statement SEMICOLON? EOF ; singleExpression : expr EOF ; statement : query #default | BEGIN (WORK | TRANSACTION)? (transactionMode (',' transactionMode)*)? #begin | COMMIT #commit | EXPLAIN (ANALYZE)? statement #explain | OPTIMIZE TABLE tableWithPartitions withProperties? #optimize | REFRESH TABLE tableWithPartitions #refreshTable | UPDATE aliasedRelation SET assignment (',' assignment)* where? #update | DELETE FROM aliasedRelation where? #delete | SHOW (TRANSACTION ISOLATION LEVEL | TRANSACTION_ISOLATION) #showTransaction | SHOW CREATE TABLE table #showCreateTable | SHOW TABLES ((FROM | IN) qname)? (LIKE pattern=stringLiteral | where)? #showTables | SHOW SCHEMAS (LIKE pattern=stringLiteral | where)? #showSchemas | SHOW COLUMNS (FROM | IN) tableName=qname ((FROM | IN) schema=qname)? (LIKE pattern=stringLiteral | where)? #showColumns | SHOW (qname | ALL) #showSessionParameter | ALTER TABLE alterTableDefinition ADD COLUMN? addColumnDefinition #addColumn | ALTER TABLE alterTableDefinition (SET '(' genericProperties ')' | RESET ('(' ident (',' ident)* ')')?) #alterTableProperties | ALTER BLOB TABLE alterTableDefinition (SET '(' genericProperties ')' | RESET ('(' ident (',' ident)* ')')?) #alterBlobTableProperties | ALTER (BLOB)? TABLE alterTableDefinition (OPEN | CLOSE) #alterTableOpenClose | ALTER (BLOB)? TABLE alterTableDefinition RENAME TO qname #alterTableRename | ALTER (BLOB)? TABLE alterTableDefinition REROUTE rerouteOption #alterTableReroute | ALTER CLUSTER REROUTE RETRY FAILED #alterClusterRerouteRetryFailed | ALTER CLUSTER SWAP TABLE source=qname TO target=qname withProperties? #alterClusterSwapTable | ALTER CLUSTER DECOMMISSION node=expr #alterClusterDecommissionNode | ALTER CLUSTER GC DANGLING ARTIFACTS #alterClusterGCDanglingArtifacts | ALTER USER name=ident SET '(' genericProperties ')' #alterUser | RESET GLOBAL primaryExpression (',' primaryExpression)* #resetGlobal | SET SESSION CHARACTERISTICS AS TRANSACTION setExpr (setExpr)* #setSessionTransactionMode | SET (SESSION | LOCAL)? qname (EQ | TO) (DEFAULT | setExpr (',' setExpr)*) #set | SET GLOBAL (PERSISTENT | TRANSIENT)? setGlobalAssignment (',' setGlobalAssignment)* #setGlobal | SET LICENSE stringLiteral #setLicense | KILL (ALL | jobId=parameterOrString) #kill | INSERT INTO table ('(' ident (',' ident)* ')')? insertSource onConflict? #insert | RESTORE SNAPSHOT qname (ALL | TABLE tableWithPartitions) withProperties? #restore | COPY tableWithPartition FROM path=expr withProperties? (RETURN SUMMARY)? #copyFrom | COPY tableWithPartition columns? where? TO DIRECTORY? path=expr withProperties? #copyTo | DROP BLOB TABLE (IF EXISTS)? table #dropBlobTable | DROP TABLE (IF EXISTS)? table #dropTable | DROP ALIAS qname #dropAlias | DROP REPOSITORY ident #dropRepository | DROP SNAPSHOT qname #dropSnapshot | DROP FUNCTION (IF EXISTS)? name=qname '(' (functionArgument (',' functionArgument)*)? ')' #dropFunction | DROP USER (IF EXISTS)? name=ident #dropUser | DROP VIEW (IF EXISTS)? names=qnames #dropView | DROP ANALYZER name=ident #dropAnalyzer | GRANT (priviliges=idents | ALL PRIVILEGES?) (ON clazz qnames)? TO users=idents #grantPrivilege | DENY (priviliges=idents | ALL PRIVILEGES?) (ON clazz qnames)? TO users=idents #denyPrivilege | REVOKE (privileges=idents | ALL PRIVILEGES?) (ON clazz qnames)? FROM users=idents #revokePrivilege | createStmt #create | DEALLOCATE (PREPARE)? (ALL | prepStmt=stringLiteralOrIdentifierOrQname) #deallocate | ANALYZE #analyze ; query: queryTerm (ORDER BY sortItem (',' sortItem)*)? (LIMIT limit=parameterOrInteger)? (OFFSET offset=parameterOrInteger)? ; queryTerm : querySpec #queryTermDefault | first=querySpec operator=(INTERSECT | EXCEPT) second=querySpec #setOperation | left=queryTerm operator=UNION setQuant? right=queryTerm #setOperation ; setQuant : DISTINCT | ALL ; sortItem : expr ordering=(ASC | DESC)? (NULLS nullOrdering=(FIRST | LAST))? ; querySpec : SELECT setQuant? selectItem (',' selectItem)* (FROM relation (',' relation)*)? where? (GROUP BY expr (',' expr)*)? (HAVING having=booleanExpression)? (WINDOW windows+=namedWindow (',' windows+=namedWindow)*)? #defaultQuerySpec | VALUES values (',' values)* #valuesRelation ; selectItem : expr (AS? ident)? #selectSingle | qname '.' ASTERISK #selectAll | ASTERISK #selectAll ; where : WHERE condition=booleanExpression ; filter : FILTER '(' where ')' ; relation : left=relation ( CROSS JOIN right=aliasedRelation | joinType JOIN rightRelation=relation joinCriteria | NATURAL joinType JOIN right=aliasedRelation ) #joinRelation | aliasedRelation #relationDefault ; joinType : INNER? | LEFT OUTER? | RIGHT OUTER? | FULL OUTER? ; joinCriteria : ON booleanExpression | USING '(' ident (',' ident)* ')' ; aliasedRelation : relationPrimary (AS? ident aliasedColumns?)? ; relationPrimary : table #tableRelation | '(' query ')' #subqueryRelation | '(' relation ')' #parenthesizedRelation ; tableWithPartition : qname ( PARTITION '(' assignment ( ',' assignment )* ')')? ; table : qname #tableName | qname '(' valueExpression? (',' valueExpression)* ')' #tableFunction ; aliasedColumns : '(' ident (',' ident)* ')' ; expr : booleanExpression ; booleanExpression : predicated #booleanDefault | NOT booleanExpression #logicalNot | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary | MATCH '(' matchPredicateIdents ',' term=primaryExpression ')' (USING matchType=ident withProperties?)? #match ; predicated : valueExpression predicate[$valueExpression.ctx]? ; predicate[ParserRuleContext value] : cmpOp right=valueExpression #comparison | cmpOp setCmpQuantifier primaryExpression #quantifiedComparison | NOT? BETWEEN lower=valueExpression AND upper=valueExpression #between | NOT? IN '(' expr (',' expr)* ')' #inList | NOT? IN subqueryExpression #inSubquery | NOT? (LIKE | ILIKE) pattern=valueExpression (ESCAPE escape=valueExpression)? #like | NOT? (LIKE | ILIKE) quant=setCmpQuantifier '(' v=valueExpression')' (ESCAPE escape=valueExpression)? #arrayLike | IS NOT? NULL #nullPredicate | IS NOT? DISTINCT FROM right=valueExpression #distinctFrom ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS) right=valueExpression #arithmeticBinary | left=valueExpression CONCAT right=valueExpression #concatenation | dataType stringLiteral #fromStringLiteralCast ; primaryExpression : parameterOrLiteral #defaultParamOrLiteral | explicitFunction #explicitFunctionDefault | qname '(' ASTERISK ')' filter? over? #functionCall | ident #columnReference | qname '(' (setQuant? expr (',' expr)*)? ')' filter? over? #functionCall | subqueryExpression #subqueryExpressionDefault // This case handles a simple parenthesized expression. | '(' expr ')' #nestedExpression // This is an extension to ANSI SQL, which considers EXISTS to be a <boolean expression> | EXISTS '(' query ')' #exists | value=primaryExpression '[' index=valueExpression ']' #subscript | ident ('.' ident)* #dereference | primaryExpression CAST_OPERATOR dataType #doubleColonCast | timestamp=primaryExpression AT TIME ZONE zone=primaryExpression #atTimezone ; explicitFunction : name=CURRENT_DATE #specialDateTimeFunction | name=CURRENT_TIME ('(' precision=integerLiteral')')? #specialDateTimeFunction | name=CURRENT_TIMESTAMP ('(' precision=integerLiteral')')? #specialDateTimeFunction | CURRENT_SCHEMA #currentSchema | (CURRENT_USER | USER) #currentUser | SESSION_USER #sessionUser | LEFT '(' strOrColName=expr ',' len=expr ')' #left | RIGHT '(' strOrColName=expr ',' len=expr ')' #right | SUBSTRING '(' expr FROM expr (FOR expr)? ')' #substring | TRIM '(' ((trimMode=(LEADING | TRAILING | BOTH))? (charsToTrim=expr)? FROM)? target=expr ')' #trim | EXTRACT '(' stringLiteralOrIdentifier FROM expr ')' #extract | CAST '(' expr AS dataType ')' #cast | TRY_CAST '(' expr AS dataType ')' #cast | CASE operand=expr whenClause+ (ELSE elseExpr=expr)? END #simpleCase | CASE whenClause+ (ELSE elseExpr=expr)? END #searchedCase | IF '('condition=expr ',' trueValue=expr (',' falseValue=expr)? ')' #ifCase | ARRAY subqueryExpression #arraySubquery ; subqueryExpression : '(' query ')' ; parameterOrLiteral : parameterOrSimpleLiteral | arrayLiteral | objectLiteral ; parameterOrSimpleLiteral : nullLiteral | intervalLiteral | escapedCharsStringLiteral | stringLiteral | numericLiteral | booleanLiteral | parameterExpr ; parameterOrInteger : parameterExpr | integerLiteral ; parameterOrIdent : parameterExpr | ident ; parameterOrString : parameterExpr | stringLiteral ; parameterExpr : '$' integerLiteral #positionalParameter | '?' #parameterPlaceholder ; nullLiteral : NULL ; escapedCharsStringLiteral : ESCAPED_STRING ; stringLiteral : STRING ; subscriptSafe : value=subscriptSafe '[' index=valueExpression']' | qname ; cmpOp : EQ | NEQ | LT | LTE | GT | GTE | LLT | REGEX_MATCH | REGEX_NO_MATCH | REGEX_MATCH_CI | REGEX_NO_MATCH_CI ; setCmpQuantifier : ANY | SOME | ALL ; whenClause : WHEN condition=expr THEN result=expr ; namedWindow : name=ident AS windowDefinition ; over : OVER windowDefinition ; windowDefinition : windowRef=ident | '(' (windowRef=ident)? (PARTITION BY partition+=expr (',' partition+=expr)*)? (ORDER BY sortItem (',' sortItem)*)? windowFrame? ')' ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=PRECEDING #unboundedFrame | UNBOUNDED boundType=FOLLOWING #unboundedFrame | CURRENT ROW #currentRowBound | expr boundType=(PRECEDING | FOLLOWING) #boundedFrame ; qnames : qname (',' qname)* ; qname : ident ('.' ident)* ; idents : ident (',' ident)* ; ident : unquotedIdent | quotedIdent ; unquotedIdent : IDENTIFIER #unquotedIdentifier | nonReserved #unquotedIdentifier | DIGIT_IDENTIFIER #digitIdentifier // not supported | COLON_IDENT #colonIdentifier // not supported ; quotedIdent : QUOTED_IDENTIFIER #quotedIdentifier | BACKQUOTED_IDENTIFIER #backQuotedIdentifier // not supported ; stringLiteralOrIdentifier : ident | stringLiteral ; stringLiteralOrIdentifierOrQname : ident | qname | stringLiteral ; numericLiteral : decimalLiteral | integerLiteral ; intervalLiteral : INTERVAL sign=(PLUS | MINUS)? stringLiteral from=intervalField (TO to=intervalField)? ; intervalField : YEAR | MONTH | DAY | HOUR | MINUTE | SECOND ; booleanLiteral : TRUE | FALSE ; decimalLiteral : DECIMAL_VALUE ; integerLiteral : INTEGER_VALUE ; arrayLiteral : ARRAY? '[' (expr (',' expr)*)? ']' ; objectLiteral : '{' (objectKeyValue (',' objectKeyValue)*)? '}' ; objectKeyValue : key=ident EQ value=expr ; insertSource : VALUES values (',' values)* | query | '(' query ')' ; onConflict : ON CONFLICT conflictTarget? DO NOTHING | ON CONFLICT conflictTarget DO UPDATE SET assignment (',' assignment)* ; conflictTarget : '(' ident (',' ident)* ')' ; values : '(' expr (',' expr)* ')' ; columns : '(' primaryExpression (',' primaryExpression)* ')' ; assignment : primaryExpression EQ expr ; createStmt : CREATE TABLE (IF NOT EXISTS)? table '(' tableElement (',' tableElement)* ')' partitionedByOrClusteredInto withProperties? #createTable | CREATE BLOB TABLE table numShards=blobClusteredInto? withProperties? #createBlobTable | CREATE REPOSITORY name=ident TYPE type=ident withProperties? #createRepository | CREATE SNAPSHOT qname (ALL | TABLE tableWithPartitions) withProperties? #createSnapshot | CREATE ANALYZER name=ident (EXTENDS extendedName=ident)? WITH? '(' analyzerElement ( ',' analyzerElement )* ')' #createAnalyzer | CREATE (OR REPLACE)? FUNCTION name=qname '(' (functionArgument (',' functionArgument)*)? ')' RETURNS returnType=dataType LANGUAGE language=parameterOrIdent AS body=parameterOrString #createFunction | CREATE USER name=ident withProperties? #createUser | CREATE ( OR REPLACE )? VIEW name=qname AS query #createView ; functionArgument : (name=ident)? type=dataType ; alterTableDefinition : ONLY qname #tableOnly | tableWithPartition #tableWithPartitionDefault ; partitionedByOrClusteredInto : partitionedBy? clusteredBy? | clusteredBy? partitionedBy? ; partitionedBy : PARTITIONED BY columns ; clusteredBy : CLUSTERED (BY '(' routing=primaryExpression ')')? (INTO numShards=parameterOrInteger SHARDS)? ; blobClusteredInto : CLUSTERED INTO numShards=parameterOrInteger SHARDS ; tableElement : columnDefinition #columnDefinitionDefault | PRIMARY_KEY columns #primaryKeyConstraint | INDEX name=ident USING method=ident columns withProperties? #indexDefinition ; columnDefinition : ident dataType? (DEFAULT defaultExpr=expr)? ((GENERATED ALWAYS)? AS generatedExpr=expr)? columnConstraint* ; addColumnDefinition : subscriptSafe dataType? ((GENERATED ALWAYS)? AS expr)? columnConstraint* ; rerouteOption : MOVE SHARD shardId=parameterOrInteger FROM fromNodeId=parameterOrString TO toNodeId=parameterOrString #rerouteMoveShard | ALLOCATE REPLICA SHARD shardId=parameterOrInteger ON nodeId=parameterOrString #rerouteAllocateReplicaShard | PROMOTE REPLICA SHARD shardId=parameterOrInteger ON nodeId=parameterOrString withProperties? #reroutePromoteReplica | CANCEL SHARD shardId=parameterOrInteger ON nodeId=parameterOrString withProperties? #rerouteCancelShard ; dataType : definedDataType #definedDataTypeDefault | ident #dataTypeIdent | objectTypeDefinition #objectDataType | arrayTypeDefinition #arrayDataType ; definedDataType : DOUBLE PRECISION | TIMESTAMP WITHOUT TIME ZONE | TIMESTAMP WITH TIME ZONE ; objectTypeDefinition : OBJECT ('(' type=(DYNAMIC | STRICT | IGNORED) ')')? (AS '(' columnDefinition ( ',' columnDefinition )* ')')? ; arrayTypeDefinition : ARRAY '(' dataType ')' ; columnConstraint : PRIMARY_KEY #columnConstraintPrimaryKey | NOT NULL #columnConstraintNotNull | INDEX USING method=ident withProperties? #columnIndexConstraint | INDEX OFF #columnIndexOff | STORAGE withProperties #columnStorageDefinition ; withProperties : WITH '(' genericProperties ')' #withGenericProperties ; genericProperties : genericProperty (',' genericProperty)* ; genericProperty : ident EQ expr ; matchPredicateIdents : matchPred=matchPredicateIdent | '(' matchPredicateIdent (',' matchPredicateIdent)* ')' ; matchPredicateIdent : subscriptSafe boost=parameterOrSimpleLiteral? ; analyzerElement : tokenizer | tokenFilters | charFilters | genericProperty ; tokenizer : TOKENIZER namedProperties ; tokenFilters : TOKEN_FILTERS '(' namedProperties (',' namedProperties )* ')' ; charFilters : CHAR_FILTERS '(' namedProperties (',' namedProperties )* ')' ; namedProperties : ident withProperties? ; tableWithPartitions : tableWithPartition (',' tableWithPartition)* ; setGlobalAssignment : name=primaryExpression (EQ | TO) value=expr ; setExpr : stringLiteral | booleanLiteral | numericLiteral | ident | on ; on : ON ; clazz : SCHEMA | TABLE | VIEW ; transactionMode : ISOLATION LEVEL isolationLevel | (READ WRITE | READ ONLY) | (NOT)? DEFERRABLE ; isolationLevel : SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED ; nonReserved : ALIAS | ANALYZE | ANALYZER | AT | BERNOULLI | BLOB | CATALOGS | CHAR_FILTERS | CLUSTERED | COLUMNS | COPY | CURRENT | DAY | DEALLOCATE | DISTRIBUTED | DUPLICATE | DYNAMIC | EXPLAIN | EXTENDS | FOLLOWING | FORMAT | FULLTEXT | FUNCTIONS | GEO_POINT | GEO_SHAPE | GLOBAL | GRAPHVIZ | HOUR | IGNORED | ILIKE | INTERVAL | KEY | KILL | LICENSE | LOGICAL | LOCAL | MATERIALIZED | MINUTE | MONTH | OFF | ONLY | OVER | OPTIMIZE | PARTITION | PARTITIONED | PARTITIONS | PLAIN | PRECEDING | RANGE | REFRESH | ROW | ROWS | SCHEMAS | SECOND | SESSION | SHARDS | SHOW | STORAGE | STRICT | SYSTEM | TABLES | TABLESAMPLE | TEXT | TIME | ZONE | WITHOUT | TIMESTAMP | TO | TOKENIZER | TOKEN_FILTERS | TYPE | VALUES | VIEW | YEAR | REPOSITORY | SNAPSHOT | RESTORE | GENERATED | ALWAYS | BEGIN | COMMIT | ISOLATION | TRANSACTION | CHARACTERISTICS | LEVEL | LANGUAGE | OPEN | CLOSE | RENAME | PRIVILEGES | SCHEMA | PREPARE | REROUTE | MOVE | SHARD | ALLOCATE | REPLICA | CANCEL | CLUSTER | RETRY | FAILED | FILTER | DO | NOTHING | CONFLICT | TRANSACTION_ISOLATION | RETURN | SUMMARY | WORK | SERIALIZABLE | REPEATABLE | COMMITTED | UNCOMMITTED | READ | WRITE | WINDOW | DEFERRABLE | STRING_TYPE | IP | DOUBLE | FLOAT | TIMESTAMP | LONG | INT | INTEGER | SHORT | BYTE | BOOLEAN | PRECISION | REPLACE | SWAP | GC | DANGLING | ARTIFACTS | DECOMMISSION | LEADING | TRAILING | BOTH | TRIM | CURRENT_SCHEMA | PROMOTE ; SELECT: 'SELECT'; FROM: 'FROM'; TO: 'TO'; AS: 'AS'; AT: 'AT'; ALL: 'ALL'; ANY: 'ANY'; SOME: 'SOME'; DEALLOCATE: 'DEALLOCATE'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; WHERE: 'WHERE'; GROUP: 'GROUP'; BY: 'BY'; ORDER: 'ORDER'; HAVING: 'HAVING'; LIMIT: 'LIMIT'; OFFSET: 'OFFSET'; OR: 'OR'; AND: 'AND'; IN: 'IN'; NOT: 'NOT'; EXISTS: 'EXISTS'; BETWEEN: 'BETWEEN'; LIKE: 'LIKE'; ILIKE: 'ILIKE'; IS: 'IS'; NULL: 'NULL'; TRUE: 'TRUE'; FALSE: 'FALSE'; NULLS: 'NULLS'; FIRST: 'FIRST'; LAST: 'LAST'; ESCAPE: 'ESCAPE'; ASC: 'ASC'; DESC: 'DESC'; SUBSTRING: 'SUBSTRING'; TRIM: 'TRIM'; LEADING: 'LEADING'; TRAILING: 'TRAILING'; BOTH: 'BOTH'; FOR: 'FOR'; TIME: 'TIME'; ZONE: 'ZONE'; YEAR: 'YEAR'; MONTH: 'MONTH'; DAY: 'DAY'; HOUR: 'HOUR'; MINUTE: 'MINUTE'; SECOND: 'SECOND'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_SCHEMA: 'CURRENT_SCHEMA'; CURRENT_USER: 'CURRENT_USER'; SESSION_USER: 'SESSION_USER'; EXTRACT: 'EXTRACT'; CASE: 'CASE'; WHEN: 'WHEN'; THEN: 'THEN'; ELSE: 'ELSE'; END: 'END'; IF: 'IF'; INTERVAL: 'INTERVAL'; JOIN: 'JOIN'; CROSS: 'CROSS'; OUTER: 'OUTER'; INNER: 'INNER'; LEFT: 'LEFT'; RIGHT: 'RIGHT'; FULL: 'FULL'; NATURAL: 'NATURAL'; USING: 'USING'; ON: 'ON'; OVER: 'OVER'; WINDOW: 'WINDOW'; PARTITION: 'PARTITION'; PROMOTE: 'PROMOTE'; RANGE: 'RANGE'; ROWS: 'ROWS'; UNBOUNDED: 'UNBOUNDED'; PRECEDING: 'PRECEDING'; FOLLOWING: 'FOLLOWING'; CURRENT: 'CURRENT'; ROW: 'ROW'; WITH: 'WITH'; WITHOUT: 'WITHOUT'; RECURSIVE: 'RECURSIVE'; CREATE: 'CREATE'; BLOB: 'BLOB'; TABLE: 'TABLE'; SWAP: 'SWAP'; GC: 'GC'; DANGLING: 'DANGLING'; ARTIFACTS: 'ARTIFACTS'; DECOMMISSION: 'DECOMMISSION'; CLUSTER: 'CLUSTER'; REPOSITORY: 'REPOSITORY'; SNAPSHOT: 'SNAPSHOT'; ALTER: 'ALTER'; KILL: 'KILL'; ONLY: 'ONLY'; ADD: 'ADD'; COLUMN: 'COLUMN'; OPEN: 'OPEN'; CLOSE: 'CLOSE'; RENAME: 'RENAME'; REROUTE: 'REROUTE'; MOVE: 'MOVE'; SHARD: 'SHARD'; ALLOCATE: 'ALLOCATE'; REPLICA: 'REPLICA'; CANCEL: 'CANCEL'; RETRY: 'RETRY'; FAILED: 'FAILED'; BOOLEAN: 'BOOLEAN'; BYTE: 'BYTE'; SHORT: 'SHORT'; INTEGER: 'INTEGER'; INT: 'INT'; LONG: 'LONG'; FLOAT: 'FLOAT'; DOUBLE: 'DOUBLE'; PRECISION: 'PRECISION'; TIMESTAMP: 'TIMESTAMP'; IP: 'IP'; OBJECT: 'OBJECT'; STRING_TYPE: 'STRING'; GEO_POINT: 'GEO_POINT'; GEO_SHAPE: 'GEO_SHAPE'; GLOBAL : 'GLOBAL'; SESSION : 'SESSION'; LOCAL : 'LOCAL'; LICENSE : 'LICENSE'; BEGIN: 'BEGIN'; COMMIT: 'COMMIT'; WORK: 'WORK'; TRANSACTION: 'TRANSACTION'; TRANSACTION_ISOLATION: 'TRANSACTION_ISOLATION'; CHARACTERISTICS: 'CHARACTERISTICS'; ISOLATION: 'ISOLATION'; LEVEL: 'LEVEL'; SERIALIZABLE: 'SERIALIZABLE'; REPEATABLE: 'REPEATABLE'; COMMITTED: 'COMMITTED'; UNCOMMITTED: 'UNCOMMITTED'; READ: 'READ'; WRITE: 'WRITE'; DEFERRABLE: 'DEFERRABLE'; RETURNS: 'RETURNS'; CALLED: 'CALLED'; REPLACE: 'REPLACE'; FUNCTION: 'FUNCTION'; LANGUAGE: 'LANGUAGE'; INPUT: 'INPUT'; ANALYZE: 'ANALYZE'; CONSTRAINT: 'CONSTRAINT'; DESCRIBE: 'DESCRIBE'; EXPLAIN: 'EXPLAIN'; FORMAT: 'FORMAT'; TYPE: 'TYPE'; TEXT: 'TEXT'; GRAPHVIZ: 'GRAPHVIZ'; LOGICAL: 'LOGICAL'; DISTRIBUTED: 'DISTRIBUTED'; CAST: 'CAST'; TRY_CAST: 'TRY_CAST'; SHOW: 'SHOW'; TABLES: 'TABLES'; SCHEMAS: 'SCHEMAS'; CATALOGS: 'CATALOGS'; COLUMNS: 'COLUMNS'; PARTITIONS: 'PARTITIONS'; FUNCTIONS: 'FUNCTIONS'; MATERIALIZED: 'MATERIALIZED'; VIEW: 'VIEW'; OPTIMIZE: 'OPTIMIZE'; REFRESH: 'REFRESH'; RESTORE: 'RESTORE'; DROP: 'DROP'; ALIAS: 'ALIAS'; UNION: 'UNION'; EXCEPT: 'EXCEPT'; INTERSECT: 'INTERSECT'; SYSTEM: 'SYSTEM'; BERNOULLI: 'BERNOULLI'; TABLESAMPLE: 'TABLESAMPLE'; STRATIFY: 'STRATIFY'; INSERT: 'INSERT'; INTO: 'INTO'; VALUES: 'VALUES'; DELETE: 'DELETE'; UPDATE: 'UPDATE'; KEY: 'KEY'; DUPLICATE: 'DUPLICATE'; CONFLICT: 'CONFLICT'; DO: 'DO'; NOTHING: 'NOTHING'; SET: 'SET'; RESET: 'RESET'; DEFAULT: 'DEFAULT'; COPY: 'COPY'; CLUSTERED: 'CLUSTERED'; SHARDS: 'SHARDS'; PRIMARY_KEY: 'PRIMARY KEY'; OFF: 'OFF'; FULLTEXT: 'FULLTEXT'; FILTER: 'FILTER'; PLAIN: 'PLAIN'; INDEX: 'INDEX'; STORAGE: 'STORAGE'; DYNAMIC: 'DYNAMIC'; STRICT: 'STRICT'; IGNORED: 'IGNORED'; ARRAY: 'ARRAY'; ANALYZER: 'ANALYZER'; EXTENDS: 'EXTENDS'; TOKENIZER: 'TOKENIZER'; TOKEN_FILTERS: 'TOKEN_FILTERS'; CHAR_FILTERS: 'CHAR_FILTERS'; PARTITIONED: 'PARTITIONED'; PREPARE: 'PREPARE'; TRANSIENT: 'TRANSIENT'; PERSISTENT: 'PERSISTENT'; MATCH: 'MATCH'; GENERATED: 'GENERATED'; ALWAYS: 'ALWAYS'; USER: 'USER'; GRANT: 'GRANT'; DENY: 'DENY'; REVOKE: 'REVOKE'; PRIVILEGES: 'PRIVILEGES'; SCHEMA: 'SCHEMA'; RETURN: 'RETURN'; SUMMARY: 'SUMMARY'; EQ : '='; NEQ : '<>' | '!='; LT : '<'; LTE : '<='; GT : '>'; GTE : '>='; LLT : '<<'; REGEX_MATCH: '~'; REGEX_NO_MATCH: '!~'; REGEX_MATCH_CI: '~*'; REGEX_NO_MATCH_CI: '!~*'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; CONCAT: '||'; CAST_OPERATOR: '::'; SEMICOLON: ';'; STRING : '\'' ( ~'\'' | '\'\'' )* '\'' ; ESCAPED_STRING : 'E' '\'' ( ~'\'' | '\'\'' | '\\\'' )* '\'' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ '.' DIGIT* | '.' DIGIT+ | DIGIT+ ('.' DIGIT*)? EXPONENT | '.' DIGIT+ EXPONENT ; IDENTIFIER : (LETTER | '_') (LETTER | DIGIT | '_' | '@')* ; DIGIT_IDENTIFIER : DIGIT (LETTER | DIGIT | '_' | '@')+ ; QUOTED_IDENTIFIER : '"' ( ~'"' | '""' )* '"' ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; COLON_IDENT : (LETTER | DIGIT | '_' )+ ':' (LETTER | DIGIT | '_' )+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Za-z] ; COMMENT : ('--' ~[\r\n]* '\r'? '\n'? | '/*' .*? '*/') -> channel(HIDDEN) ; WS : [ \r\n\t]+ -> channel(HIDDEN) ; UNRECOGNIZED : . ;
libsrc/_DEVELOPMENT/target/yaz180/device/asci/c/asci1_getc.asm
jpoikela/z88dk
640
161813
<reponame>jpoikela/z88dk<gh_stars>100-1000 SECTION code_driver PUBLIC _asci1_getc EXTERN asm_asci1_getc defc _asci1_getc = asm_asci1_getc EXTERN asm_asci1_need defc NEED = asm_asci1_need
adm/code/src/admbase-runge.adb
leo-brewin/adm-bssn-numerical
1
15809
with Support; use Support; package body ADMBase.Runge is -- increments in data delta_gab_ptr : MetricGridArray_ptr := new MetricGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); delta_Kab_ptr : ExtcurvGridArray_ptr := new ExtcurvGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); delta_N_ptr : LapseGridArray_ptr := new LapseGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); delta_gab : MetricGridArray renames delta_gab_ptr.all; delta_Kab : ExtcurvGridArray renames delta_Kab_ptr.all; delta_N : LapseGridArray renames delta_N_ptr.all; -- data at start of time step old_gab_ptr : MetricGridArray_ptr := new MetricGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); old_Kab_ptr : ExtcurvGridArray_ptr := new ExtcurvGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); old_N_ptr : LapseGridArray_ptr := new LapseGridArray (1..max_num_x, 1..max_num_y, 1..max_num_z); old_gab : MetricGridArray renames old_gab_ptr.all; old_Kab : ExtcurvGridArray renames old_Kab_ptr.all; old_N : LapseGridArray renames old_N_ptr.all; -- the_time at start of time step old_time : Real; procedure set_time_step is courant_time_step : Real; begin courant_time_step := courant * min ( dx, min (dy,dz) ); time_step := min (courant_time_step, constant_time_step); end set_time_step; procedure set_time_step_min is courant_time_step : Real; begin courant_time_step := courant_min * min ( dx, min (dy,dz) ); time_step_min := min (courant_time_step, constant_time_step); end set_time_step_min; procedure rk_step (ct : Real; cw : Real; params : SlaveParams) is i, j, k : Integer; the_task : Integer := params (1); beg_point : Integer := params (2); end_point : Integer := params (3); begin for b in beg_point .. end_point loop i := grid_point_list (b).i; j := grid_point_list (b).j; k := grid_point_list (b).k; gab (i,j,k) := old_gab (i,j,k) + time_step * ct * dot_gab (i,j,k); Kab (i,j,k) := old_Kab (i,j,k) + time_step * ct * dot_Kab (i,j,k); N (i,j,k) := old_N (i,j,k) + time_step * ct * dot_N (i,j,k); delta_gab (i,j,k) := delta_gab (i,j,k) + time_step * cw * dot_gab (i,j,k); delta_Kab (i,j,k) := delta_Kab (i,j,k) + time_step * cw * dot_Kab (i,j,k); delta_N (i,j,k) := delta_N (i,j,k) + time_step * cw * dot_N (i,j,k); end loop; if the_task = 1 then the_time := old_time + time_step * ct; end if; end rk_step; procedure beg_runge_kutta (params : SlaveParams) is i, j, k : Integer; the_task : Integer := params (1); beg_point : Integer := params (2); end_point : Integer := params (3); begin for b in beg_point .. end_point loop i := grid_point_list (b).i; j := grid_point_list (b).j; k := grid_point_list (b).k; old_gab (i,j,k) := gab (i,j,k); old_Kab (i,j,k) := Kab (i,j,k); old_N (i,j,k) := N (i,j,k); dot_gab (i,j,k) := (others => 0.0); dot_Kab (i,j,k) := (others => 0.0); dot_N (i,j,k) := 0.0; delta_gab (i,j,k) := (others => 0.0); delta_Kab (i,j,k) := (others => 0.0); delta_N (i,j,k) := 0.0; end loop; if the_task = 1 then old_time := the_time; end if; end beg_runge_kutta; procedure end_runge_kutta (params : SlaveParams) is i, j, k : Integer; the_task : Integer := params (1); beg_point : Integer := params (2); end_point : Integer := params (3); begin for b in beg_point .. end_point loop i := grid_point_list (b).i; j := grid_point_list (b).j; k := grid_point_list (b).k; gab (i,j,k) := old_gab (i,j,k) + delta_gab (i,j,k); Kab (i,j,k) := old_Kab (i,j,k) + delta_Kab (i,j,k); N (i,j,k) := old_N (i,j,k) + delta_N (i,j,k); end loop; if the_task = 1 then the_time := the_time + time_step; end if; end end_runge_kutta; end ADMBase.Runge;
Tools/String/General.asm
jaredwhitney/os3
5
82520
String.getLength : ; String in ebx, length out in edx xor edx, edx push ebx push ax mov al, [ebx] cmp al, 0x0 je String.getLength.kret String.getLength.loop : add ebx, 1 add edx, 1 mov al, [ebx] cmp al, 0x0 jne String.getLength.loop pop ax pop ebx add edx, 1 ret String.getLength.kret : pop ax pop ebx mov edx, 1 ret String.getEffectiveLength : ; charwidth in eax, String in ebx, length out in edx FINISH WRITING THIS pusha mov bl, [ebx] cmp bl, 0x0A jne String.getEffectiveLength.noadd xor edx, edx mov ecx, eax String.getEffectiveLength.noadd : popa ret String.fromHex : ; eax = buffer to store string in, ebx = hex number pusha mov [String._buffer], eax xor eax, eax mov [String._bufferOffs], eax mov cl, 28 mov ch, 0x0 ; num out String.fromHex.start : cmp ebx, 0x0 jne String.fromHex.cont mov al, '0' call String.fromHex.cprint popa ret String.fromHex.cont : mov edx, ebx shr edx, cl and edx, 0xF cmp dx, 0x0 je String.fromHex.checkZ mov ch, 0x1 String.fromHex.dontcare : push ebx mov eax, edx cmp dx, 0x9 jg String.fromHex.g10 add eax, 0x30 jmp String.fromHex.goPrint String.fromHex.g10 : add eax, 0x37 String.fromHex.goPrint : push ax call String.fromHex.cprint pop ax pop ebx String.fromHex.goCont : cmp cl, 0 jle String.fromHex.end sub cl, 4 jmp String.fromHex.start String.fromHex.end : mov al, 0x0 call String.fromHex.cprint popa ret String.fromHex.checkZ : cmp ch, 0x0 je String.fromHex.goCont jmp String.fromHex.dontcare String.fromHex.cprint : pusha ;mov ah, 0xFF mov ebx, [String._buffer] add ebx, [String._bufferOffs] mov [ebx], al mov ebx, [String._bufferOffs] add ebx, 0x1 mov [String._bufferOffs], ebx popa ret String.copy : ; eax = String to copy, ebx = new location to copy it to pusha String.copy.loop : mov cl, [eax] cmp cl, 0x0 je String.copy.ret mov [ebx], cl add eax, 1 add ebx, 1 jmp String.copy.loop String.copy.ret : mov byte [ebx], 0x0 popa ret String.copyRawToWhite : ; eax = String to copy, ebx = location to copy it to pusha mov ch, 0xFF String.copyRawToWhite.loop : mov cl, [eax] cmp cl, 0x0 je String.copyRawToWhite.ret mov [ebx], cx add eax, 1 add ebx, 2 jmp String.copyRawToWhite.loop String.copyRawToWhite.ret : mov word [ebx], 0x0 ; i think word is right... popa ret String.copyRawToWhite_auto : ; ebx = String to copy, returns ecx = new String push eax push ebx push edx mov eax, ebx call String.getLength imul edx, 2 mov ebx, edx call ProgramManager.reserveMemory ;mov ebx, 0x4000 ; TESTING mov ecx, ebx push ecx mov ch, 0xFF ;mov eax, HelloWorld.welcomeMessage String.copyRawToWhite_auto.loop : mov cl, [eax] cmp cl, 0x0 je String.copyRawToWhite_auto.ret mov [ebx], cx add eax, 1 add ebx, 2 jmp String.copyRawToWhite_auto.loop String.copyRawToWhite_auto.ret : mov word [ebx], 0x0 ; i think word is right... pop ecx pop edx pop ebx pop eax ret String.copyColorToRaw : ; eax = String to copy, ebx = location to copy it to pusha String.copyColorToRaw.loop : mov cx, [eax] cmp cl, 0x0 je String.copyColorToRaw.ret mov [ebx], cl add eax, 2 add ebx, 1 jmp String.copyColorToRaw.loop String.copyColorToRaw.ret : mov byte [ebx], 0x0 popa ret String.copyUntilBothZeroed : ; eax = String to copy, ebx = new location to copy it to pusha mov edx, [Graphics.SCREEN_MEMPOS] mov ecx, [Clock.tics] and ecx, 0xFF add edx, ecx mov dword [edx], 0xFF String.copyUntilBothZeroed.loop : mov cx, [eax] cmp cx, 0x0 jne String.copyUntilBothZeroed.cont cmp word [ebx], 0x0 je String.copyUntilBothZeroed.ret String.copyUntilBothZeroed.cont : mov [ebx], cx add eax, 2 add ebx, 2 jmp String.copyUntilBothZeroed.loop String.copyUntilBothZeroed.ret : mov byte [ebx], 0x0 popa ret String.append : ; eax = main String, ebx = text to append pusha push ebx mov ebx, eax call String.getLength sub edx, 1 add eax, edx pop ebx xchg eax, ebx call String.copy popa ret String._buffer : dd 0x0 String._bufferOffs : dd 0x0
_build/dispatcher/jmp_ippsGFpECSetPointHashBackCompatible_rmf_d4f25f5b.asm
zyktrcn/ippcp
1
9436
<filename>_build/dispatcher/jmp_ippsGFpECSetPointHashBackCompatible_rmf_d4f25f5b.asm extern m7_ippsGFpECSetPointHashBackCompatible_rmf:function extern n8_ippsGFpECSetPointHashBackCompatible_rmf:function extern y8_ippsGFpECSetPointHashBackCompatible_rmf:function extern e9_ippsGFpECSetPointHashBackCompatible_rmf:function extern l9_ippsGFpECSetPointHashBackCompatible_rmf:function extern n0_ippsGFpECSetPointHashBackCompatible_rmf:function extern k0_ippsGFpECSetPointHashBackCompatible_rmf:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsGFpECSetPointHashBackCompatible_rmf .Larraddr_ippsGFpECSetPointHashBackCompatible_rmf: dq m7_ippsGFpECSetPointHashBackCompatible_rmf dq n8_ippsGFpECSetPointHashBackCompatible_rmf dq y8_ippsGFpECSetPointHashBackCompatible_rmf dq e9_ippsGFpECSetPointHashBackCompatible_rmf dq l9_ippsGFpECSetPointHashBackCompatible_rmf dq n0_ippsGFpECSetPointHashBackCompatible_rmf dq k0_ippsGFpECSetPointHashBackCompatible_rmf segment .text global ippsGFpECSetPointHashBackCompatible_rmf:function (ippsGFpECSetPointHashBackCompatible_rmf.LEndippsGFpECSetPointHashBackCompatible_rmf - ippsGFpECSetPointHashBackCompatible_rmf) .Lin_ippsGFpECSetPointHashBackCompatible_rmf: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsGFpECSetPointHashBackCompatible_rmf: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsGFpECSetPointHashBackCompatible_rmf] mov r11, qword [r11+rax*8] jmp r11 .LEndippsGFpECSetPointHashBackCompatible_rmf:
c2000/C2000Ware_1_00_06_00/libraries/control/DCL/c28/source/DCL_DF22_L1.asm
ramok/Themis_ForHPSDR
0
163873
<filename>c2000/C2000Ware_1_00_06_00/libraries/control/DCL/c28/source/DCL_DF22_L1.asm ; DCL_DF22_L1.asm - Full Direct Form 2 implementation in second order ; ; Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ ; ALL RIGHTS RESERVED .if __TI_EABI__ .asg DCL_runDF22_L1, _DCL_runDF22_L1 .endif .global _DCL_runDF22_L1 .def __cla_DCL_DF22_L1_sp SIZEOF_LFRAME .set 2 LFRAME_MR3 .set 0 .align 2 __cla_DCL_DF22_L1_sp .usect ".scratchpad:Cla1Prog:_DCL_DF22_L1_LSECT", SIZEOF_LFRAME, 0, 1 .asg __cla_DCL_DF22_L1_sp, LFRAME .sect "Cla1Prog:_DCL_DF22_L1_LSECT" ; C prototype: float DCL_runDF22_L1(DCL_DF22 *p, float32_t ek) ; argument 1 = *p : structure address [MAR0] ; argument 2 = ek : controller input [MR0] ; return = uk : controller output [MR0] _DCL_runDF22_L1: MMOV32 @LFRAME + LFRAME_MR3, MR3 ; save MR3 MNOP ; MAR0 load delay MNOP ; MAR0 load delay MMOV32 MR1, *MAR0[10]++ ; MR1 = b0 MMPYF32 MR2, MR0, MR1 ; MR2 = v0 || MMOV32 MR3, *MAR0[-8]++ ; MR3 = x1 MADDF32 MR1, MR2, MR3 ; MR1 = uk || MMOV32 MR3, *MAR0[10]++ ; MR3 = b1 MMPYF32 MR2, MR0, MR3 ; MR2 = v1 || MMOV32 MR3, *MAR0[-6]++ ; MR3 = x2 MADDF32 MR3, MR2, MR3 ; MR3 = v1 + x2 || MMOV32 MR2, *MAR0[4]++ ; MR2 = a1 MMPYF32 MR2, MR2, MR1 ; MR2 = v3 MNOP ; MR2 delay slot MSUBF32 MR3, MR3, MR2 ; MR3 = x1d MMOV32 *MAR0[-6]++, MR3 ; save x1 MMOV32 MR3, *MAR0[4]++ ; MR3 = b2 MMPYF32 MR2, MR0, MR3 ; MR2 = v2 || MMOV32 MR3, *MAR0[4]++ ; MR3 = a2 MMOV32 MR0, MR1 ; return uk MMPYF32 MR1, MR1, MR3 ; MR1 = v4 MRCNDD UNC ; return call MSUBF32 MR3, MR2, MR1 ; MR3 = x2d MMOV32 *MAR0, MR3 ; save x2 MMOV32 MR3, @LFRAME + LFRAME_MR3 ; restore MR3 .unasg LFRAME ; end of file
oeis/079/A079675.asm
neoneye/loda-programs
11
6389
; A079675: a(1)=1; a(n)=sum(u=1,n-1,sum(v=1,u,sum(w=1,v,sum(x=1, w,sum(y=1,x,a(y)))))). ; 1,1,6,26,106,431,1757,7168,29244,119305,486716,1985603,8100456,33046585,134816705,549997641,2243767969,9153665985,37343255690,152345382480,621507555626,2535499503900,10343812679475,42198572937400,172153113473000,702315088294876,2865161560519781,11688700562892401,47685171660677756,194536217612338956,793629101981876157,3237685811120702718,13208448865288347919,53885130183940804880,219829541269671335441,896815634477881805603,3658645137494664491131,14925792690831466568685,60891198538656556684505 sub $0,1 mul $0,5 max $0,0 seq $0,99559 ; a(n) = Sum_{k=0..floor(n/5)} C(n-4k,k+1). add $0,1
.emacs.d/elpa/ada-mode-5.2.0/gpr_query.adb
caqg/linux-home
0
4988
<gh_stars>0 -- Abstract : -- -- Support Emacs Ada mode and gpr-query minor mode queries about -- GNAT projects and cross reference data -- -- requires gnatcoll 1.7w 20140330, gnat 7.2.1 -- -- Copyright (C) 2014-2016 Free Software Foundation All Rights Reserved. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, 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 -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with Ada.Characters.Handling; with Ada.Command_Line; with Ada.Directories; with Ada.Environment_Variables; with Ada.Exceptions.Traceback; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; with Ada.Text_IO; with GNAT.Command_Line; with GNAT.Directory_Operations; with GNAT.OS_Lib; with GNAT.Strings; with GNAT.Traceback.Symbolic; with GNATCOLL.Arg_Lists; with GNATCOLL.Paragraph_Filling; with GNATCOLL.Projects; with GNATCOLL.SQL.Sqlite; with GNATCOLL.Traces; use GNATCOLL.Traces; with GNATCOLL.Utils; with GNATCOLL.VFS; with GNATCOLL.VFS_Utils; with GNATCOLL.Xref; with Prj; procedure Gpr_Query is use GNATCOLL; Me : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create ("gpr_query"); Db_Error : exception; Invalid_Command : exception; function "+" (Item : in Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; function "+" (Item : in GNATCOLL.VFS.Filesystem_String) return String is begin return String (Item); end "+"; procedure Process_Line (Line : String); -- Process a full line of commands. -- Raise Invalid_Command when the command is invalid. function Get_Entity (Arg : String) return GNATCOLL.Xref.Entity_Information; -- Return the entity matching the "name:file:line:column" argument type My_Xref_Database is new GNATCOLL.Xref.Xref_Database with null record; -- Derived so we can override Image to output full paths overriding function Image (Self : My_Xref_Database; File : GNATCOLL.VFS.Virtual_File) return String; function Image (Self : GNATCOLL.Xref.Entity_Information) return String; -- Return a display version of the argument Xref : aliased My_Xref_Database; Env : GNATCOLL.Projects.Project_Environment_Access; Tree : aliased GNATCOLL.Projects.Project_Tree; Previous_Progress : Natural := 0; Progress_Reporter : access procedure (Current, Total : Integer) := null; -- Subprogram specs for subprograms used before bodies procedure Check_Arg_Count (Args : in GNATCOLL.Arg_Lists.Arg_List; Expected : in Integer); procedure Dump (Curs : in out GNATCOLL.Xref.Entities_Cursor'Class); procedure Dump (Refs : in out GNATCOLL.Xref.References_Cursor'Class); -- Display the results of a query procedure Put (Item : GNATCOLL.VFS.File_Array); generic with function Compute (Self : in GNATCOLL.Xref.Xref_Database'Class; Entity : in GNATCOLL.Xref.Entity_Information) return GNATCOLL.Xref.Entity_Information; procedure Process_Command_Single (Args : GNATCOLL.Arg_Lists.Arg_List); -- Get the entity identified by Args, which must contain a single -- argument. Then call Compute, and output the result. -- -- Appropriate for queries that return a single entity result. procedure Process_Command_Single (Args : GNATCOLL.Arg_Lists.Arg_List) is use GNATCOLL.Arg_Lists; use GNATCOLL.Xref; Entity : Entity_Information; Comp : Entity_Information; begin Check_Arg_Count (Args, 1); Entity := Get_Entity (Nth_Arg (Args, 1)); Comp := Compute (Xref, Entity); if Comp /= No_Entity then Ada.Text_IO.Put_Line (Image (Comp)); end if; end Process_Command_Single; generic with procedure Compute (Self : in GNATCOLL.Xref.Xref_Database'Class; Entity : in GNATCOLL.Xref.Entity_Information; Cursor : out GNATCOLL.Xref.Entities_Cursor'Class); procedure Process_Command_Multiple (Args : GNATCOLL.Arg_Lists.Arg_List); procedure Process_Command_Multiple (Args : GNATCOLL.Arg_Lists.Arg_List) is use GNATCOLL.Arg_Lists; use GNATCOLL.Xref; Entity : Entity_Information; Descendants : Recursive_Entities_Cursor; -- Apparently a generic formal parameter cannot match a subprogram access type, so we need this: procedure Do_Compute (Self : in GNATCOLL.Xref.Xref_Database'Class; Entity : in GNATCOLL.Xref.Entity_Information; Cursor : out GNATCOLL.Xref.Entities_Cursor'Class) is begin Compute (Self, Entity, Cursor); end Do_Compute; begin Check_Arg_Count (Args, 1); Entity := Get_Entity (Nth_Arg (Args, 1)); Recursive (Self => Xref'Unchecked_Access, Entity => Entity, Compute => Do_Compute'Unrestricted_Access, Cursor => Descendants); Dump (Descendants); end Process_Command_Multiple; -- Command procedures; Args is the command line. -- -- Infrastructure commands procedure Process_Help (Args : GNATCOLL.Arg_Lists.Arg_List); procedure Process_Refresh (Args : GNATCOLL.Arg_Lists.Arg_List); -- Queries; alphabetical procedure Process_Overridden is new Process_Command_Single (GNATCOLL.Xref.Overrides); procedure Process_Overriding is new Process_Command_Multiple (GNATCOLL.Xref.Overridden_By); procedure Process_Parent_Types is new Process_Command_Multiple (GNATCOLL.Xref.Parent_Types); procedure Process_Project_Path (Args : GNATCOLL.Arg_Lists.Arg_List); procedure Process_Refs (Args : GNATCOLL.Arg_Lists.Arg_List); procedure Process_Source_Dirs (Args : GNATCOLL.Arg_Lists.Arg_List); type Command_Descr is record Name : GNAT.Strings.String_Access; Args : GNAT.Strings.String_Access; Help : GNAT.Strings.String_Access; Handler : access procedure (Args : GNATCOLL.Arg_Lists.Arg_List); end record; Commands : constant array (Natural range <>) of Command_Descr := ((new String'("help"), new String'("[command or variable name]"), new String'("Display the list of commands and their syntax."), Process_Help'Access), (new String'("refresh"), null, new String'("Refresh the contents of the xref database."), Process_Refresh'Access), -- queries (new String'("overridden"), new String'("name:file:line:column"), new String'("The entity that is overridden by the parameter"), Process_Overridden'Access), (new String'("overriding"), new String'("name:file:line:column"), new String'("The entities that override the parameter"), Process_Overriding'Access), (new String'("parent_types"), new String'("name:file:line:column"), new String'("The parent types of the entity."), Process_Parent_Types'Access), (new String'("project_path"), null, new String'("The project search path."), Process_Project_Path'Access), (new String'("refs"), new String'("name:file:line:column"), new String'("All known references to the entity."), Process_Refs'Access), (new String'("source_dirs"), null, new String'("The project source directories, recursively."), Process_Source_Dirs'Access)); -- Parsed command line info Cmdline : GNAT.Command_Line.Command_Line_Configuration; Commands_From_Switch : aliased GNAT.Strings.String_Access; DB_Name : aliased GNAT.Strings.String_Access := new String'("gpr_query.db"); Force_Refresh : aliased Boolean; Nightly_DB_Name : aliased GNAT.Strings.String_Access; Show_Progress : aliased Boolean; Project_Name : aliased GNAT.Strings.String_Access; Traces_Config_File : aliased GNAT.Strings.String_Access; Gpr_Config_File : aliased GNAT.Strings.String_Access; ALI_Encoding : aliased GNAT.Strings.String_Access := new String'(""); ---------- -- Procedure bodies, alphabetical procedure Display_Progress (Current, Total : Integer) is Now : constant Integer := Integer (Float'Floor (Float (Current) / Float (Total) * 100.0)); begin if Now /= Previous_Progress then Ada.Text_IO.Put_Line ("completed" & Current'Img & " out of" & Total'Img & " (" & GNATCOLL.Utils.Image (Now, Min_Width => 0) & "%)..."); Previous_Progress := Now; end if; end Display_Progress; procedure Dump (Curs : in out GNATCOLL.Xref.Entities_Cursor'Class) is use GNATCOLL.Xref; begin while Curs.Has_Element loop Ada.Text_IO.Put_Line (Image (Curs.Element)); Curs.Next; end loop; end Dump; procedure Dump (Refs : in out GNATCOLL.Xref.References_Cursor'Class) is use GNATCOLL.Xref; begin while Has_Element (Refs) loop declare Ref : constant Entity_Reference := Refs.Element; begin Ada.Text_IO.Put_Line (Xref.Image (Ref) & " (" & (+Ref.Kind) & ")"); end; Next (Refs); end loop; end Dump; function Get_Entity (Arg : String) return GNATCOLL.Xref.Entity_Information is use GNAT.Directory_Operations; use GNATCOLL.Xref; Words : GNAT.Strings.String_List_Access := GNATCOLL.Utils.Split (Arg, On => ':'); Ref : GNATCOLL.Xref.Entity_Reference; begin case Words'Length is when 4 => Ref := Xref.Get_Entity (Name => Words (Words'First).all, File => Format_Pathname (Style => UNIX, Path => Words (Words'First + 1).all), Project => GNATCOLL.Projects.No_Project, Line => Integer'Value (Words (Words'First + 2).all), Column => Visible_Column (Integer'Value (Words (Words'First + 3).all))); when 3 => Ref := Xref.Get_Entity (Name => Words (Words'First).all, File => Format_Pathname (Style => UNIX, Path => Words (Words'First + 1).all), Project => GNATCOLL.Projects.No_Project, Line => Integer'Value (Words (Words'First + 2).all)); when 2 => Ref := Xref.Get_Entity (Name => Words (Words'First).all, File => Format_Pathname (Style => UNIX, Path => Words (Words'First + 1).all), Project => GNATCOLL.Projects.No_Project); -- Xref.Get_Entity treats 'File => ""' as searching for pre-defined entities such as "Integer". when others => raise Invalid_Command with "Invalid parameter '" & Arg & "', expecting name:file:line:column"; end case; GNAT.Strings.Free (Words); if Ref.Entity = GNATCOLL.Xref.No_Entity then Ada.Text_IO.Put_Line ("Error: entity not found '" & Arg & "'"); elsif GNATCOLL.Xref.Is_Fuzzy_Match (Ref.Entity) then Ada.Text_IO.Put_Line ("warning: fuzzy match for the entity"); -- FIXME: gnat-query.el look for this, prompt for reparse? end if; return Ref.Entity; end Get_Entity; overriding function Image (Self : My_Xref_Database; File : GNATCOLL.VFS.Virtual_File) return String is pragma Unreferenced (Self); begin return File.Display_Full_Name; end Image; function Image (Self : GNATCOLL.Xref.Entity_Information) return String is use GNATCOLL.Xref; begin if Self = No_Entity then return "Unknown entity"; else declare Decl : constant Entity_Declaration := Xref.Declaration (Self); begin if Is_Predefined_Entity (Decl) then return "predefined entity: " & (+Decl.Name); else return Xref.Image (Decl.Location); end if; end; end if; end Image; procedure Check_Arg_Count (Args : in GNATCOLL.Arg_Lists.Arg_List; Expected : in Integer) is Count : constant Integer := GNATCOLL.Arg_Lists.Args_Length (Args); begin if Count /= Expected then raise Invalid_Command with "Invalid number of arguments" & Integer'Image (Count) & "; expecting" & Integer'Image (Expected); end if; end Check_Arg_Count; procedure Process_Help (Args : GNATCOLL.Arg_Lists.Arg_List) is use Ada.Text_IO; use GNATCOLL.Arg_Lists; use type GNAT.Strings.String_Access; begin for C in Commands'Range loop if Args_Length (Args) <= 0 -- Empty_Command_Line returns -1 or else Nth_Arg (Args, 1) = Commands (C).Name.all then Put (" " & Commands (C).Name.all); if Commands (C).Args = null then New_Line; else Put_Line (" " & Commands (C).Args.all); end if; Put (Ada.Strings.Unbounded.To_String (GNATCOLL.Paragraph_Filling.Knuth_Fill (Commands (C).Help.all, Max_Line_Length => 70, Line_Prefix => " "))); end if; end loop; New_Line; Put_Line ("'exit' to quit"); end Process_Help; procedure Process_Line (Line : String) is Expr : GNAT.Strings.String_List_Access; begin if Ada.Strings.Fixed.Trim (Line, Ada.Strings.Both) = "" then return; end if; Expr := GNATCOLL.Utils.Split (Line, On => ';'); for C in Expr'Range loop if Ada.Strings.Fixed.Trim (Expr (C).all, Ada.Strings.Both) = "" then null; else declare use GNATCOLL.Arg_Lists; List : constant Arg_List := Parse_String (Expr (C).all, Mode => Separate_Args); Cmd : constant String := Ada.Characters.Handling.To_Lower (Get_Command (List)); Found : Boolean := False; begin for Co in Commands'Range loop if Commands (Co).Name.all = Cmd then Commands (Co).Handler (List); Found := True; exit; end if; end loop; if not Found then raise Invalid_Command with "Invalid command: '" & Cmd & "'"; end if; end; end if; end loop; GNAT.Strings.Free (Expr); end Process_Line; procedure Process_Project_Path (Args : GNATCOLL.Arg_Lists.Arg_List) is pragma Unreferenced (Args); Dirs : constant GNATCOLL.VFS.File_Array := GNATCOLL.Projects.Predefined_Project_Path (Env.all); begin Put (Dirs); end Process_Project_Path; procedure Process_Refresh (Args : GNATCOLL.Arg_Lists.Arg_List) is use type GNATCOLL.Projects.Project_Environment_Access; pragma Unreferenced (Args); begin Xref.Parse_All_LI_Files (Tree => Tree, Project => Tree.Root_Project, Parse_Runtime_Files => False, -- True encounters bug in gnatcoll.projects; null pointer Show_Progress => Progress_Reporter, ALI_Encoding => ALI_Encoding.all, From_DB_Name => Nightly_DB_Name.all, To_DB_Name => DB_Name.all, Force_Refresh => Force_Refresh); end Process_Refresh; procedure Process_Refs (Args : GNATCOLL.Arg_Lists.Arg_List) is use GNATCOLL.Arg_Lists; begin Check_Arg_Count (Args, 1); declare use GNATCOLL.Xref; Entity : constant Entity_Information := Get_Entity (Nth_Arg (Args, 1)); Refs : References_Cursor; begin Xref.References (Entity, Cursor => Refs); Dump (Refs); end; end Process_Refs; procedure Process_Source_Dirs (Args : GNATCOLL.Arg_Lists.Arg_List) is pragma Unreferenced (Args); use GNATCOLL.VFS; use GNATCOLL.Projects; Dirs : constant File_Array := Source_Dirs (Project => Tree.Root_Project, Recursive => True) & Predefined_Source_Path (Env.all); begin Put (Dirs); end Process_Source_Dirs; procedure Put (Item : GNATCOLL.VFS.File_Array) is use GNATCOLL.VFS; begin for I in Item'Range loop Ada.Text_IO.Put_Line (+Full_Name (Item (I))); end loop; end Put; begin declare use GNAT.Command_Line; begin Set_Usage (Cmdline, Help => "Query project info and cross-references on source code. See ada-mode docs for more help."); -- Switch variable alphabetic order Define_Switch (Cmdline, Output => ALI_Encoding'Access, Long_Switch => "--encoding=", Switch => "-e=", Help => "The character encoding used for source and ALI files"); Define_Switch (Cmdline, Output => Commands_From_Switch'Access, Switch => "-c:", Long_Switch => "--command=", Help => "Execute the commands from ARG, and exit"); Define_Switch (Cmdline, Output => DB_Name'Access, Long_Switch => "--db=", Help => "Specifies the name of the database (or ':memory:')"); Define_Switch (Cmdline, Output => Force_Refresh'Access, Long_Switch => "--force_refresh", Help => "Force rebuilding the database."); Define_Switch (Cmdline, Output => Gpr_Config_File'Access, Long_Switch => "--autoconf=", Help => "Specify the gpr configuration file (.cgpr)"); Define_Switch (Cmdline, Output => Nightly_DB_Name'Access, Long_Switch => "--nightlydb=", Help => "Specifies the name of a prebuilt database"); Define_Switch (Cmdline, Output => Project_Name'Access, Switch => "-P:", Long_Switch => "--project=", Help => "Load the given project (mandatory)"); Define_Switch (Cmdline, Output => Show_Progress'Access, Long_Switch => "--display_progress", Switch => "-d", Help => "Show progress as LI files are parsed"); Define_Switch (Cmdline, Output => Traces_Config_File'Access, Long_Switch => "--tracefile=", Help => "Specify a traces configuration file"); Getopt (Cmdline, Callback => null); end; if Project_Name.all = "" then Ada.Text_IO.Put_Line ("No project file specified"); GNAT.Command_Line.Display_Help (Cmdline); return; end if; -- Only trace if user specifies --tracefile if Traces_Config_File.all /= "" and then GNAT.OS_Lib.Is_Regular_File (Traces_Config_File.all) then GNATCOLL.Traces.Parse_Config_File (Filename => Traces_Config_File.all, Force_Activation => False); Trace (Me, "trace enabled"); -- Prj.* not controlled by Traces Prj.Current_Verbosity := Prj.High; end if; GNATCOLL.Projects.Initialize (Env); -- for register_default_language if Gpr_Config_File.all /= "" and then GNAT.OS_Lib.Is_Regular_File (Gpr_Config_File.all) then Env.Set_Config_File (GNATCOLL.VFS.Create_From_UTF8 (GNAT.OS_Lib.Normalize_Pathname (Name => Gpr_Config_File.all, Directory => GNAT.Directory_Operations.Get_Current_Dir))); else -- Apparently Ada language extensions are already registered (sigh) Env.Register_Default_Language_Extension (Language_Name => "C", Default_Spec_Suffix => ".h", Default_Body_Suffix => ".c"); Env.Register_Default_Language_Extension (Language_Name => "C++", Default_Spec_Suffix => ".hh", Default_Body_Suffix => ".cpp"); end if; declare use Ada.Environment_Variables; use Ada.Text_IO; use GNATCOLL.VFS; use GNATCOLL.VFS_Utils; use GNAT.Directory_Operations; use type GNAT.Strings.String_Access; Gpr_Project_Path : constant String := (if Exists ("GPR_PROJECT_PATH") then Ada.Directories.Current_Directory & GNAT.OS_Lib.Path_Separator & Value ("GPR_PROJECT_PATH") else Ada.Directories.Current_Directory); Path : constant Virtual_File := -- must be an absolute file name (if Is_Absolute_Path (+Project_Name.all) then Create_From_UTF8 (Project_Name.all, Normalize => True) else Locate_Regular_File (+Project_Name.all, From_Path (+Gpr_Project_Path))); begin if not Path.Is_Regular_File then Put (Project_Name.all & ": not found on path " & Gpr_Project_Path); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); return; end if; Trace (Me, "using project file " & (+Path.Full_Name)); if Show_Progress then Progress_Reporter := Display_Progress'Unrestricted_Access; end if; begin -- Recompute_View => True registers all the source files -- (among other things), so we will know that a .[ag]li -- belongs to this project Tree.Load (Path, Env, Errors => Ada.Text_IO.Put_Line'Access, Recompute_View => True); exception when GNATCOLL.Projects.Invalid_Project => Ada.Text_IO.Put_Line ("project search path:"); Put (GNATCOLL.Projects.Predefined_Project_Path (Env.all)); raise GNATCOLL.Projects.Invalid_Project with +Path.Full_Name & ": invalid project"; end; end; if DB_Name.all /= ":memory:" then declare use GNATCOLL.VFS; N : constant String := DB_Name.all; Temp : Virtual_File := Tree.Root_Project.Object_Dir; Dir2 : Virtual_File; begin GNAT.Strings.Free (DB_Name); -- If the project does not have an object directory, create -- the database in the directory containing the project file. if Temp = No_File then Temp := Tree.Root_Project.Project_Path.Dir; end if; Temp := Create_From_Base (Base_Dir => Temp.Full_Name.all, Base_Name => +N); Dir2 := Create (Temp.Dir_Name); if not Dir2.Is_Directory then Dir2.Make_Dir (Recursive => True); end if; DB_Name := new String'(Temp.Display_Full_Name); end; end if; declare use type GNAT.Strings.String_Access; Error : GNAT.Strings.String_Access; begin Trace (Me, "using database " & DB_Name.all); Setup_DB (Self => Xref, Tree => Tree'Unchecked_Access, DB => GNATCOLL.SQL.Sqlite.Setup (Database => DB_Name.all), Error => Error); if Error /= null then -- old db schema raise Db_Error with Error.all; end if; end; Process_Refresh (GNATCOLL.Arg_Lists.Empty_Command_Line); if Commands_From_Switch.all /= "" then Process_Line (Commands_From_Switch.all); return; end if; loop Ada.Text_IO.Put (">>> "); declare Input : constant String := Ada.Text_IO.Get_Line; begin exit when Input = "exit"; Process_Line (Input); exception when E : Invalid_Command => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Process_Help (GNATCOLL.Arg_Lists.Empty_Command_Line); end; end loop; exception when E : GNATCOLL.Projects.Invalid_Project => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : Db_Error => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : Invalid_Command => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Process_Help (GNATCOLL.Arg_Lists.Empty_Command_Line); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when GNAT.Command_Line.Invalid_Switch => GNAT.Command_Line.Display_Help (Cmdline); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : others => Ada.Text_IO.Put_Line ("Unexpected exception"); Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (Ada.Exceptions.Traceback.Tracebacks (E))); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end Gpr_Query;
tests/kat/xof_runner.adb
damaki/libkeccak
26
985
------------------------------------------------------------------------------- -- Copyright (c) 2019, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Unchecked_Deallocation; with Interfaces; use Interfaces; with Keccak.Types; with Test_Vectors; use Test_Vectors; package body XOF_Runner is procedure Free is new Ada.Unchecked_Deallocation (Object => Keccak.Types.Byte_Array, Name => Byte_Array_Access); procedure Run_Tests (File_Name : in String; Num_Passed : out Natural; Num_Failed : out Natural) is use type Keccak.Types.Byte_Array; package Integer_IO is new Ada.Text_IO.Integer_IO(Integer); Len_Key : constant Unbounded_String := To_Unbounded_String ("Len"); Msg_Key : constant Unbounded_String := To_Unbounded_String ("Msg"); Repeat_Key : constant Unbounded_String := To_Unbounded_String ("Repeat"); Text_Key : constant Unbounded_String := To_Unbounded_String ("Text"); Output_Key : constant Unbounded_String := To_Unbounded_String ("Output"); Schema : Test_Vectors.Schema_Maps.Map; Tests : Test_Vectors.Lists.List; Ctx : XOF.Context; Digest : Byte_Array_Access := null; Msg : Byte_Array_Access; Len : Natural; begin Num_Passed := 0; Num_Failed := 0; -- Setup schema to support two types of test vector files: -- Long or ShortMsgKAT containing: "Len", "Msg", and "Output" fields; and -- ExtremelyLongMsgKAT containing: "Repeat", "Text", and "Output" fields. Schema.Insert (Key => Len_Key, New_Item => Schema_Entry'(VType => Integer_Type, Required => False, Is_List => False)); Schema.Insert (Key => Msg_Key, New_Item => Schema_Entry'(VType => Hex_Array_Type, Required => False, Is_List => False)); Schema.Insert (Key => Repeat_Key, New_Item => Schema_Entry'(VType => Integer_Type, Required => False, Is_List => False)); Schema.Insert (Key => Text_Key, New_Item => Schema_Entry'(VType => String_Type, Required => False, Is_List => False)); Schema.Insert (Key => Output_Key, New_Item => Schema_Entry'(VType => Hex_Array_Type, Required => True, Is_List => False)); -- Load the test file using the file name given on the command line Ada.Text_IO.Put_Line("Loading file: " & File_Name); Test_Vectors.Load (File_Name => File_Name, Schema => Schema, Vectors_List => Tests); Ada.Text_IO.Put ("Running "); Integer_IO.Put (Integer (Tests.Length), Width => 0); Ada.Text_IO.Put_Line (" tests ..."); -- Run each test. for C of Tests loop XOF.Init(Ctx); if C.Contains (Len_Key) then -- Test vector contains "Len", "Msg", and "Output" fields Len := C.Element (Len_Key).First_Element.Int; if Len > 0 then Msg := new Keccak.Types.Byte_Array'(C.Element (Msg_Key).First_Element.Hex.all); XOF.Update(Ctx, Msg.all, Len); Free (Msg); end if; else -- Assume test vector defines "Repeat", "Text", and "Output" fields Msg := String_To_Byte_Array (To_String (C.Element (Text_Key).First_Element.Str)); for I in 1 .. C.Element (Repeat_Key).First_Element.Int loop XOF.Update(Ctx, Msg.all); end loop; Free (Msg); end if; Digest := new Keccak.Types.Byte_Array (C.Element(Output_Key).First_Element.Hex.all'Range); XOF.Extract(Ctx, Digest.all); if Digest.all = C.Element(Output_Key).First_Element.Hex.all then Num_Passed := Num_Passed + 1; else Num_Failed := Num_Failed + 1; -- Display a message on failure to help with debugging. if C.Contains (Len_Key) then Ada.Text_IO.Put("FAILURE (Msg bit-len: "); Integer_IO.Put(C.Element (Len_Key).First_Element.Int, Width => 0); Ada.Text_IO.Put_Line(")"); else Ada.Text_IO.Put_Line("FAILURE:"); end if; Ada.Text_IO.Put(" Expected Output: "); Ada.Text_IO.Put(Byte_Array_To_String (C.Element (Output_Key).First_Element.Hex.all)); Ada.Text_IO.New_Line; Ada.Text_IO.Put(" Actual Output: "); Ada.Text_IO.Put(Byte_Array_To_String(Digest.all)); Ada.Text_IO.New_Line; end if; Free (Digest); end loop; end Run_Tests; end XOF_Runner;
ada/hello.adb
cbuschka/distrolessc
2
5154
<gh_stars>1-10 with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line ("Hello world."); end Hello;
library_dir_dir/system_library_unbundled/source/pc_mowse_.s.archive/rs232out.asm
dancrossnyc/multics
65
9374
; *********************************************************** ; * * ; * Copyright, (C) Honeywell Bull Inc., 1987 * ; * * ; * Copyright, (C) Honeywell Information Systems Inc., 1986 * ; * * ; *********************************************************** PAGE 55,132 ; HISTORY COMMENTS: ; 1) change(85-12-15,Flegel), approve(87-07-13,MCR7580), ; audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072): ; Created. ; END HISTORY COMMENTS ;/* : PROCEDURE FUNCTION (RS232_out): ; ;Send the byte in al to the RS232 port only when it is safe to do so. ;*/ ;/* : ARGUMENTS ; ; al - byte to be outputted to RS232 port ;*/ include dos.mac ;Lattice include file include mowsdefs.mac ;Constant values include rs232err.mac ; Hardware interrupt errors include ws_buf.mac ; circular buffer macros ;******************************************************************* ; DATA ;******************************************************************* dseg ;-------- External declarations extrn COM_PORT:word ;-------- Public Declarations public RS232_out endds page ;******************************************************************* ; MAIN ;******************************************************************* pseg ;--------- External Procedures extrn put_inbuff:near RS232_out proc near push ax push bx push cx push dx ;/* : Set up RS232 */ mov bl,al ;Save char to bl temporarily mov dx,MCR ;Modem control Register add dx,COM_PORT mov al,MCRREAD ;Out2, DTR, RTS out dx,al sub cx,cx ;Initialize timeout count mov dx,MSR ;Modem status Register add dx,COM_PORT ;/* : Wait for CTS (Clear to send) */ RS150: sub cx,cx ;Another timeout count TIME_LOOP: in al,dx test al,MSRCTS ;Clear to send? jnz SEND_CLEAR ;yes loop TIME_LOOP ;No, loop til timeout ;/* : Too long, exit */ mov ah,INTERRUPT_STATUS mov al, ISCTSTO ; record CTS timeout call put_inbuff jmp short RSXIT ;And QUIT ;/* : Wait for THRE (Transmit Holding Register Empty) */ SEND_CLEAR: mov dx,LSR ;Line Status register add dx,COM_PORT sub cx,cx ;Another time out STATUS_TIMING: in al,dx ;LSR status test al,LSRTHRE ;Transmit holding reg empty jnz SEND_CHAR ;Yes loop STATUS_TIMING ;No, loop til timeout ;/* : Too long, exit */ mov ah,INTERRUPT_STATUS mov al,ISTHRETO call put_inbuff ;record error jmp short RSXIT ;And QUIT ;/* : Get line status , send char */ SEND_CHAR: mov ah,al ;Get line status for return and ah,MASK7 ;mask bit 7 mov al,bl ;restore char to al mov dx,THR ;transmit holding register add dx,COM_PORT out dx,al ;Output it to RS232 RSXIT: pop dx ;Restore Registers pop cx pop bx pop ax ret RS232_out endp endps end 
programs/oeis/110/A110560.asm
karttu/loda
1
28178
<filename>programs/oeis/110/A110560.asm ; A110560: Numerators of T(n+1)/n! reduced to lowest terms, where T(n) are the triangular numbers A000217. ; 1,3,3,5,5,7,7,1,1,11,11,13,13,1,1,17,17,19,19,1,1,23,23,1,1,1,1,29,29,31,31,1,1,1,1,37,37,1,1,41,41,43,43,1,1,47,47,1,1,1,1,53,53,1,1,1,1,59,59,61,61,1,1,1,1,67,67,1,1,71,71,73,73,1,1,1,1,79,79,1,1,83,83,1,1,1,1,89,89,1,1,1,1,1,1,97,97,1,1,101,101,103,103,1,1,107,107,109,109,1,1,113,113,1,1,1,1,1,1,1,1,1,1,1,1,127,127,1,1,131,131,1,1,1,1,137,137,139,139,1,1,1,1,1,1,1,1,149,149,151,151,1,1,1,1,157,157,1,1,1,1,163,163,1,1,167,167,1,1,1,1,173,173,1,1,1,1,179,179,181,181,1,1,1,1,1,1,1,1,191,191,193,193,1,1,197,197,199,199,1,1,1,1,1,1,1,1,1,1,211,211,1,1,1,1,1,1,1,1,1,1,223,223,1,1,227,227,229,229,1,1,233,233,1,1,1,1,239,239,241,241,1,1,1,1,1,1,1,1,251 mov $1,$0 add $1,1 div $1,2 mov $0,$1 add $0,$1 mov $1,$0 cal $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0. mul $1,$0 div $1,2 mul $1,2 add $1,1
oeis/227/A227469.asm
neoneye/loda-programs
11
161219
<gh_stars>10-100 ; A227469: a(n) = binomial((n+1)^2, n) * (2*n+1) / (n+1)^2 for n>=0. ; Submitted by <NAME> ; 1,3,20,245,4554,115192,3709992,145597545,6750522350,361424043596,21958844607336,1493260499980119,112400273159533800,9279595605913516080,833858283261973732944,81027308003810095983825,8466793463341565312119830,946776552967215128481968260,112816032067073649248569919400 mov $1,1 mov $2,$0 seq $0,143669 ; a(n) = binomial((n+1)^2, n) / (n+1)^2. add $1,$2 add $1,$2 mul $1,$0 mov $0,$1
gcc-gcc-7_3_0-release/gcc/ada/s-utf_32.ads
best08618/asylo
7
496
<filename>gcc-gcc-7_3_0-release/gcc/ada/s-utf_32.ads ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . U T F _ 3 2 -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2013, 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 3, 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is an internal package that provides basic character -- classification capabilities needed by the compiler for handling full -- 32-bit wide wide characters. We avoid the use of the actual type -- Wide_Wide_Character, since we want to use these routines in the compiler -- itself, and we want to be able to compile the compiler with old versions -- of GNAT that did not implement Wide_Wide_Character. -- System.UTF_32 should not be directly used from an application program, but -- an equivalent package GNAT.UTF_32 can be used directly and provides exactly -- the same services. The reason this package is in System is so that it can -- with'ed by other packages in the Ada and System hierarchies. pragma Compiler_Unit_Warning; package System.UTF_32 is pragma Pure; type UTF_32 is range 0 .. 16#7FFF_FFFF#; -- So far, the only defined character codes are in 0 .. 16#01_FFFF# -- The following type defines the categories from the unicode definitions. -- The one addition we make is Fe, which represents the characters FFFE -- and FFFF in any of the planes. type Category is ( Cc, -- Other, Control Cf, -- Other, Format Cn, -- Other, Not Assigned Co, -- Other, Private Use Cs, -- Other, Surrogate Ll, -- Letter, Lowercase Lm, -- Letter, Modifier Lo, -- Letter, Other Lt, -- Letter, Titlecase Lu, -- Letter, Uppercase Mc, -- Mark, Spacing Combining Me, -- Mark, Enclosing Mn, -- Mark, Nonspacing Nd, -- Number, Decimal Digit Nl, -- Number, Letter No, -- Number, Other Pc, -- Punctuation, Connector Pd, -- Punctuation, Dash Pe, -- Punctuation, Close Pf, -- Punctuation, Final quote Pi, -- Punctuation, Initial quote Po, -- Punctuation, Other Ps, -- Punctuation, Open Sc, -- Symbol, Currency Sk, -- Symbol, Modifier Sm, -- Symbol, Math So, -- Symbol, Other Zl, -- Separator, Line Zp, -- Separator, Paragraph Zs, -- Separator, Space Fe); -- relative position FFFE/FFFF in any plane function Get_Category (U : UTF_32) return Category; -- Given a UTF32 code, returns corresponding Category, or Cn if -- the code does not have an assigned unicode category. -- The following functions perform category tests corresponding to lexical -- classes defined in the Ada standard. There are two interfaces for each -- function. The second takes a Category (e.g. returned by Get_Category). -- The first takes a UTF_32 code. The form taking the UTF_32 code is -- typically more efficient than calling Get_Category, but if several -- different tests are to be performed on the same code, it is more -- efficient to use Get_Category to get the category, then test the -- resulting category. function Is_UTF_32_Letter (U : UTF_32) return Boolean; function Is_UTF_32_Letter (C : Category) return Boolean; pragma Inline (Is_UTF_32_Letter); -- Returns true iff U is a letter that can be used to start an identifier, -- or if C is one of the corresponding categories, which are the following: -- Letter, Uppercase (Lu) -- Letter, Lowercase (Ll) -- Letter, Titlecase (Lt) -- Letter, Modifier (Lm) -- Letter, Other (Lo) -- Number, Letter (Nl) function Is_UTF_32_Digit (U : UTF_32) return Boolean; function Is_UTF_32_Digit (C : Category) return Boolean; pragma Inline (Is_UTF_32_Digit); -- Returns true iff U is a digit that can be used to extend an identifier, -- or if C is one of the corresponding categories, which are the following: -- Number, Decimal_Digit (Nd) function Is_UTF_32_Line_Terminator (U : UTF_32) return Boolean; pragma Inline (Is_UTF_32_Line_Terminator); -- Returns true iff U is an allowed line terminator for source programs, -- if U is in the category Zp (Separator, Paragraph), or Zl (Separator, -- Line), or if U is a conventional line terminator (CR, LF, VT, FF). -- There is no category version for this function, since the set of -- characters does not correspond to a set of Unicode categories. function Is_UTF_32_Mark (U : UTF_32) return Boolean; function Is_UTF_32_Mark (C : Category) return Boolean; pragma Inline (Is_UTF_32_Mark); -- Returns true iff U is a mark character which can be used to extend an -- identifier, or if C is one of the corresponding categories, which are -- the following: -- Mark, Non-Spacing (Mn) -- Mark, Spacing Combining (Mc) function Is_UTF_32_Other (U : UTF_32) return Boolean; function Is_UTF_32_Other (C : Category) return Boolean; pragma Inline (Is_UTF_32_Other); -- Returns true iff U is an other format character, which means that it -- can be used to extend an identifier, but is ignored for the purposes of -- matching of identifiers, or if C is one of the corresponding categories, -- which are the following: -- Other, Format (Cf) function Is_UTF_32_Punctuation (U : UTF_32) return Boolean; function Is_UTF_32_Punctuation (C : Category) return Boolean; pragma Inline (Is_UTF_32_Punctuation); -- Returns true iff U is a punctuation character that can be used to -- separate pieces of an identifier, or if C is one of the corresponding -- categories, which are the following: -- Punctuation, Connector (Pc) function Is_UTF_32_Space (U : UTF_32) return Boolean; function Is_UTF_32_Space (C : Category) return Boolean; pragma Inline (Is_UTF_32_Space); -- Returns true iff U is considered a space to be ignored, or if C is one -- of the corresponding categories, which are the following: -- Separator, Space (Zs) function Is_UTF_32_Non_Graphic (U : UTF_32) return Boolean; function Is_UTF_32_Non_Graphic (C : Category) return Boolean; pragma Inline (Is_UTF_32_Non_Graphic); -- Returns true iff U is considered to be a non-graphic character, or if C -- is one of the corresponding categories, which are the following: -- Other, Control (Cc) -- Other, Private Use (Co) -- Other, Surrogate (Cs) -- Separator, Line (Zl) -- Separator, Paragraph (Zp) -- FFFE or FFFF positions in any plane (Fe) -- -- Note that the Ada category format effector is subsumed by the above -- list of Unicode categories. -- -- Note that Other, Unassigned (Cn) is quite deliberately not included -- in the list of categories above. This means that should any of these -- code positions be defined in future with graphic characters they will -- be allowed without a need to change implementations or the standard. -- -- Note that Other, Format (Cf) is also quite deliberately not included -- in the list of categories above. This means that these characters can -- be included in character and string literals. -- The following function is used to fold to upper case, as required by -- the Ada 2005 standard rules for identifier case folding. Two -- identifiers are equivalent if they are identical after folding all -- letters to upper case using this routine. A corresponding routine to -- fold to lower case is also provided. function UTF_32_To_Lower_Case (U : UTF_32) return UTF_32; pragma Inline (UTF_32_To_Lower_Case); -- If U represents an upper case letter, returns the corresponding lower -- case letter, otherwise U is returned unchanged. The folding rule is -- simply that if the code corresponds to a 10646 entry whose name contains -- the string CAPITAL LETTER, and there is a corresponding entry whose name -- is the same but with CAPITAL LETTER replaced by SMALL LETTER, then the -- code is folded to this SMALL LETTER code. Otherwise the input code is -- returned unchanged. function UTF_32_To_Upper_Case (U : UTF_32) return UTF_32; pragma Inline (UTF_32_To_Upper_Case); -- If U represents a lower case letter, returns the corresponding lower -- case letter, otherwise U is returned unchanged. The folding rule is -- simply that if the code corresponds to a 10646 entry whose name contains -- the string SMALL LETTER, and there is a corresponding entry whose name -- is the same but with SMALL LETTER replaced by CAPITAL LETTER, then the -- code is folded to this CAPITAL LETTER code. Otherwise the input code is -- returned unchanged. end System.UTF_32;
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca_notsx.log_7067_1484.asm
ljhsiun2/medusa
9
105386
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %r15 push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x93ac, %r12 nop nop cmp $35515, %rbx mov (%r12), %r13 nop sub $59120, %r10 lea addresses_WT_ht+0x919c, %r14 nop nop add $12159, %r13 mov (%r14), %r15w nop xor %r15, %r15 lea addresses_WT_ht+0xe27c, %r14 clflush (%r14) nop nop nop nop sub %r10, %r10 mov $0x6162636465666768, %r13 movq %r13, %xmm0 and $0xffffffffffffffc0, %r14 vmovntdq %ymm0, (%r14) and $1478, %r12 lea addresses_A_ht+0x1c7bc, %rsi lea addresses_D_ht+0xb02c, %rdi nop add %rbx, %rbx mov $39, %rcx rep movsl nop nop nop nop nop add $31769, %r12 lea addresses_D_ht+0x15a7a, %rsi lea addresses_WT_ht+0x14e54, %rdi cmp %r12, %r12 mov $55, %rcx rep movsb nop nop cmp %r10, %r10 lea addresses_WT_ht+0x1383c, %rbx sub $45703, %r14 mov (%rbx), %esi nop nop nop nop nop and $28615, %rbx lea addresses_A_ht+0xabbc, %rsi lea addresses_normal_ht+0x1483c, %rdi sub %r14, %r14 mov $19, %rcx rep movsw nop nop nop nop nop cmp $10499, %rcx lea addresses_D_ht+0x803c, %rsi lea addresses_D_ht+0x1e03c, %rdi nop nop inc %r15 mov $39, %rcx rep movsq cmp %rsi, %rsi lea addresses_D_ht+0xc0bc, %r15 nop nop nop nop nop add $39126, %rbx and $0xffffffffffffffc0, %r15 vmovaps (%r15), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %rcx nop nop nop nop and $25729, %rdi lea addresses_normal_ht+0x1197c, %rsi lea addresses_UC_ht+0x743c, %rdi add %r15, %r15 mov $82, %rcx rep movsl nop nop nop add $29886, %rcx lea addresses_UC_ht+0x65c, %r12 sub %rsi, %rsi movl $0x61626364, (%r12) nop nop xor $45366, %rdi lea addresses_UC_ht+0xb53c, %r13 nop xor $48515, %rdi mov $0x6162636465666768, %rcx movq %rcx, %xmm7 movups %xmm7, (%r13) dec %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %r15 pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r9 push %rbp push %rdi push %rdx // Store lea addresses_normal+0x1571c, %rdx nop nop nop nop xor $23358, %rbp movw $0x5152, (%rdx) nop nop nop nop nop and %r15, %r15 // Store lea addresses_RW+0x1883c, %r11 xor %r10, %r10 mov $0x5152535455565758, %r9 movq %r9, (%r11) nop nop nop nop sub %r10, %r10 // Faulty Load lea addresses_RW+0x1883c, %rbp add $26432, %rdx movb (%rbp), %r11b lea oracles, %rbp and $0xff, %r11 shlq $12, %r11 mov (%rbp,%r11,1), %r11 pop %rdx pop %rdi pop %rbp pop %r9 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5}} {'58': 7067} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
dino/lcs/base/6B30.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
179277
<gh_stars>1-10 copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004B98 clr.w ($6b30,A5) 004B9C lea ($6b64,A5), A0 004BBA addq.w #1, ($6b30,A5) [base+6B32] 004BBE rts [base+6B30] 010656 move.w D0, ($6b30,A5) [base+6AFE] 01065A lea ($6b64,A5), A0 01185A move.w ($6b30,A5), D7 01185E beq $1189a [base+6B30] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
oeis/159/A159702.asm
neoneye/loda-programs
11
8926
<filename>oeis/159/A159702.asm ; A159702: Decimal expansion of (969 + 44*sqrt(2))/967. ; Submitted by <NAME> ; 1,0,6,6,4,1,7,1,6,3,1,2,7,6,2,7,9,0,2,9,4,4,4,4,0,8,5,1,9,8,0,5,8,6,0,5,5,2,8,1,3,5,0,1,1,6,3,5,6,3,4,5,1,0,3,6,3,9,8,9,0,2,8,7,9,7,4,7,5,9,2,8,5,4,7,2,9,3,9,7,2,0,4,8,5,4,3,6,4,5,4,5,0,9,2,2,0,5,0,5 bin $1,$0 mov $2,2 mov $3,$0 mul $3,4 lpb $3 add $5,$2 add $1,$5 add $2,$1 mov $1,$2 sub $3,1 lpe mul $1,2 add $2,$5 mov $4,10 pow $4,$0 add $5,$2 div $2,3 mul $2,60 add $2,$5 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
cmd/replace/_replace.asm
minblock/msdos
0
302
<reponame>minblock/msdos<gh_stars>0 page 60,132 ; name _replace title Critical error or control break exit ;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ ;------------------------------------------------------------------- ; ; MODULE: _replace ; ; PURPOSE: Supplies assembler exit routines for ; critical error or control break situations ; ; CALLING FORMAT: ; crit_err_handler; ; ctl_brk_handler; ; ; DATE: 10/87 ; ;------------------------------------------------------------------- public _crit_err_handler ;AN000; public _ctl_brk_handler ;AN000; ;------------------------------------------------------------------- RET_EXIT equ 4ch ; terminate ;AN000; CTLBRK equ 3 ; errorlevel return in al ;AN000; ABORT equ 2 ; if >=, retry ;AN000; XABORT equ 1 ; errorlevel return in al ;AN000; ;------------------------------------------------------------------- NULL SEGMENT PARA PUBLIC 'BEGDATA' ;AN000; NULL ENDS ;AN000; _DATA SEGMENT PARA PUBLIC 'DATA' ;AN000; extrn _oldint24:dword ;AN000; _DATA ENDS ;AN000; CONST SEGMENT WORD PUBLIC 'CONST' ;AN000; CONST ENDS ;AN000; _BSS SEGMENT WORD PUBLIC 'BSS' ;AN000; _BSS ENDS ;AN000; STACK SEGMENT PARA STACK 'DATA' ;AN000; STACK ENDS ;AN000; PGROUP GROUP _TEXT ;AN000; DGROUP GROUP NULL, _DATA, CONST, _BSS, STACK ;AN000; _TEXT segment para public 'CODE' ;AN000; ASSUME CS:PGROUP ;AN000; extrn _restore:near ;AN000; ;------------------------------------------------------------------- ; CRITICAL ERROR HANDLER ;------------------------------------------------------------------- vector dd 0 ;receives a copy of _oldint24 ;AN000; _crit_err_handler proc near ;AN000; pushf ; req by int24 handler ;AN000; push ax ; will use ax ;AN000; push ds ; will use ds ;AN000; mov ax,dgroup ; setup ;AN000; mov ds,ax ; ;AN000; ASSUME DS:DGROUP ;AN000; mov ax,word ptr _oldint24 ; load vector so we can use it ;AN000; mov word ptr vector,ax ; ;AN000; mov ax,word ptr _oldint24+2 ; ;AN000; mov word ptr vector+2,ax ; ;AN000; pop ds ; finished with ds ;AN000; ASSUME DS:NOTHING pop ax ; finished with ax ;AN000; call dword ptr vector ; invoke DOS err hndlr ;AN000; cmp al,ABORT ; what was the user's response ;AN000; jnge retry ; ;AN000; mov ax,(RET_EXIT shl 8)+XABORT ; return to DOS w/criterr error ;AN000; call call_restore ; restore user's orig append/x ;AN000; ; =================== this call does not return =============== retry: ;AN000; ASSUME DS:NOTHING ASSUME ES:NOTHING iret ; user response was "retry" ;AN000; _crit_err_handler endp ;AN000; ;------------------------------------------------------------------- ; CONTROL BREAK HANDLER ;------------------------------------------------------------------- _ctl_brk_handler proc near ;AN000; ASSUME DS:NOTHING ASSUME ES:NOTHING mov ax,(RET_EXIT shl 8)+CTLBRK ; return to DOS w/ctlbrk error ;AN000; ;------------------------------------------------------------------- call call_restore ; restore user's orig append/x ;AN000; ;------------------------------------------------------------------- ; =================== this call does not return =============== _ctl_brk_handler endp ;AN000; call_restore proc near ;input: ah has the RETURN TO DOS WITH RET CODE function request ; al has the ERRORLEVEL return code to be passed back to DOS ;output: this routine does NOT RETURN, but exits to DOS with ret code. push ax ;save errorlevel return code push ds push es mov ax,dgroup ; setup "c" code regs ;AN000; mov ds,ax ; ;AN000; ASSUME DS:DGROUP ;AN000; mov es,ax ; ;AN000; ASSUME ES:DGROUP ;AN000; ;------------------------------------------------------------------- call _restore ; restore user's orig append/x ;AN000; ;------------------------------------------------------------------- pop es pop ds pop ax ;restore return code int 21h ; ;AN000; int 20h ; in case int21 fails ;AN000; call_restore endp _TEXT ends ; end code segment ;AN000; end ;AN000; 
oeis/162/A162442.asm
neoneye/loda-programs
11
166337
<reponame>neoneye/loda-programs ; A162442: Denominators of the column sums of the EG1 matrix coefficients ; Submitted by <NAME> ; 2,16,48,512,1280,2048,14336,262144,589824,2621440,5767168,50331648,109051904,469762048,67108864,34359738368,73014444032,103079215104,652835028992,1099511627776,3848290697216,48378511622144 mul $0,2 mov $1,4 mov $3,2 lpb $0 mov $2,$0 sub $2,1 div $2,2 mul $3,$0 sub $0,1 mul $1,2 add $2,2 mul $1,$2 lpe gcd $3,$1 div $1,$3 mov $0,$1
src/main/antlr/ClassFeature.g4
Morichan/ClassesGrammar
1
6128
<reponame>Morichan/ClassesGrammar<gh_stars>1-10 grammar ClassFeature; property : visibility? divided? name propType? multiplicityRange? defaultValue? propModifiers? ; operation : visibility? name parameterList returnType? operProperties? ; visibility : PUBLIC | PRIBATE | PROTECTED | PACKAGE ; divided : SLASH ; name : IDENTIFIER ; propType : type ; type : COLON ( IDENTIFIER | primitiveType ) ; multiplicityRange : LBRACK (lower RANGE)? upper RBRACK ; lower : integerLiteral | valueSpecification ; upper : UNLIMITATION | integerLiteral | valueSpecification ; valueSpecification : LPAREN expression* (COMMA expression*)* RPAREN ; defaultValue : ASSIGN expression ; propModifiers : properties ; properties : LBRACE propModifier (COMMA propModifier)* RBRACE ; propModifier : READONLY | UNION | SUBSETS propertyName | REDEFINES propertyName | ORDERED | UNIQUE ; propertyName : name | expression ; parameterList : LPAREN (parameter (COMMA parameter)*)* RPAREN ; parameter : direction? parameterName typeExpression multiplicityRange? defaultValue? paramProperties? ; direction : IN | OUT | INOUT | RETURN ; parameterName : name | expression ; typeExpression : type ; paramProperties : properties ; returnType : type | COLON VOID ; operProperties : LBRACE operProperty (COMMA operProperty)* RBRACE ; operProperty : REDEFINES operName | QUERY | ORDERED | UNIQUE ; operName : name | expression ; expression : LPAREN expression RPAREN | literal | IDENTIFIER | expression bop='.' ( IDENTIFIER | explicitGenericInvocationSuffix ) | expression arguments | NEW creator | bop=('+' | '-') expression | bop=('!' | 'not' | 'NOT') expression | expression bop=('*'|'/'|'%') expression | expression bop=('+'|'-') expression | expression bop=('<=' | '>=' | '>' | '<') expression | expression bop=('==' | '!=') expression | expression bop=('&&' | 'and' | 'AND') expression | expression bop=('||' | 'or' | 'OR') expression ; creator : createdName classCreatorRest ; createdName : IDENTIFIER ('.' IDENTIFIER)* ; classCreatorRest : arguments ; explicitGenericInvocationSuffix : IDENTIFIER arguments ; arguments : LPAREN expressionList? RPAREN ; expressionList : expression (',' expression)* ; primitiveType : BOOLEAN | INTEGER | STRING | UNLIMITED_NATURAL ; literal : integerLiteral | floatLiteral | SQUOT_LITERAL | DQUOT_LITERAL | BOOL_LITERAL | NULL_LITERAL ; integerLiteral : DECIMAL_LITERAL | HEX_LITERAL | OCT_LITERAL | BINARY_LITERAL ; floatLiteral : FLOAT_LITERAL | HEX_FLOAT_LITERAL ; READONLY: 'readOnly'; UNION: 'union'; SUBSETS: 'subsets'; REDEFINES: 'redefines'; ORDERED: 'ordered'; UNIQUE: 'unique'; QUERY: 'query'; IN: 'in'; OUT: 'out'; INOUT: 'inout'; RETURN: 'return'; PUBLIC: '+'; PRIBATE: '-'; PROTECTED: '#'; PACKAGE: '~'; UNLIMITATION: '*'; RANGE: '..'; NEW: 'new'; BOOLEAN: 'Boolean'; INTEGER: 'Integer'; STRING: 'String'; UNLIMITED_NATURAL: 'UnlimitedNatural'; VOID: 'void'; //BOOLEAN: 'bool' | 'boolean'; //CHAR: 'c' | 'char' | 'character'; //BYTE: 'i8' | 'int8' | 'int8_t' | 'byte'; //SHORT: 'i16' | 'int16' | 'int16_t' | 'short'; //INT: 'i32' | 'int32' | 'int32_t' | 'int' | 'integer'; //LONG: 'i64' | 'int64' | 'int64_t' | 'long'; //FLOAT: 'f32' | 'float'; //DOUBLE: 'lf' | 'f64' | 'double'; LPAREN: '('; RPAREN: ')'; LBRACE: '{'; RBRACE: '}'; LBRACK: '['; RBRACK: ']'; SQUOT: '\''; DQUOT: '"'; COMMA: ','; DOT: '.'; ASSIGN: '='; COLON: ':'; SLASH: '/'; DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; HEX_LITERAL: '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])? [lL]?; OCT_LITERAL: '0' ('_'* | 'o'?) [0-7] ([0-7_]* [0-7])? [lL]?; BINARY_LITERAL: '0' [bB] [01] ([01_]* [01])? [lL]?; INTEGER_LITERAL: Digits; FLOAT_LITERAL: (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? | Digits (ExponentPart [fFdD]? | [fFdD]) ; HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; BOOL_LITERAL: TRUL_LITERAL | FALSE_LITERAL ; TRUL_LITERAL: 'true' | 'TRUE' | 'True' | '1'; FALSE_LITERAL: 'false' | 'FALSE' | 'False' | '0'; NULL_LITERAL: NULL | NUL | NIL | NONE | UNDEF; NULL: 'null' | 'NULL' | 'Null'; NUL: 'nul' | 'NUL' | 'Nul'; NIL: 'nil' | 'NIL' | 'Nil'; NONE: 'none' | 'NONE' | 'None'; UNDEF: 'undef' | 'UNDEF' | 'Undef'; WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); SQUOT_LITERAL: SQUOT (~['\\\r\n] | EscapeSequence)* SQUOT; DQUOT_LITERAL: DQUOT (~["\\\r\n] | EscapeSequence)* DQUOT; IDENTIFIER: Letter LetterOrDigit*; fragment ExponentPart : [eE] [+-]? Digits ; fragment EscapeSequence : '\\' [0abtnvfrs"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit ; fragment HexDigits : HexDigit ((HexDigit | '_')* HexDigit)? ; fragment HexDigit : [0-9a-fA-F] ; fragment Digits : [0-9] ([0-9_]* [0-9])? ; fragment LetterOrDigit : Letter | [0-9] ; fragment Letter : [a-zA-Z$_] // these are the "java letters" below 0x7F | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF ;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/volatile10.adb
best08618/asylo
7
11069
-- { dg-do compile } with Volatile10_Pkg; use Volatile10_Pkg; procedure Volatile10 is N : Num; begin N := F.N1; N := F.N2; end;
src/process-cmd.agda
ice1k/cedille
0
3610
<filename>src/process-cmd.agda import cedille-options open import general-util module process-cmd (options : cedille-options.options) {mF : Set → Set} {{mFm : monad mF}} (progress-update : string → mF ⊤) (write-to-log : string → mF ⊤) where --open import cedille-find open import cedille-types open import classify options {mF} ⦃ mFm ⦄ write-to-log open import constants open import conversion open import ctxt open import free-vars open import rename open import spans options { mF } ⦃ mFm ⦄ open import subst open import syntax-util open import type-util open import toplevel-state options { mF } ⦃ mFm ⦄ open import to-string options open import datatype-util open import rewriting open import elab-util options import cws-types import cws -- generate spans from the given comments-and-whitespace syntax tree process-cwst-etys : cws-types.entities → spanM ⊤ process-cwst-ety : cws-types.entity → spanM ⊤ process-cwst-etys (cws-types.Entity ety etys) = process-cwst-ety ety >> process-cwst-etys etys process-cwst-etys cws-types.EndEntity = return triv process-cwst-ety cws-types.EntityNonws = return triv process-cwst-ety (cws-types.EntityWs pi pi') = return triv process-cwst-ety (cws-types.EntityComment pi pi') = [- comment-span pi pi' -] return triv process-cwst : toplevel-state → filepath → spanM toplevel-state process-cwst s filename with include-elt.cwst (get-include-elt s filename) process-cwst s filename | nothing = return s process-cwst s filename | just (cws-types.File etys) = process-cwst-etys etys >> return s check-and-add-params : ctxt → posinfo → ex-params → spanM (ctxt × params) check-and-add-params Γ pi' (p@(ExParam pi1 me pi1' x atk pi2) :: ps') = Γ ⊢ atk ↝ atk~ / let Γ' = Γ , pi1' - x :` atk~ qx = pi1' % x in [- punctuation-span "Parens (parameter)" pi1 pi2 -] [- Decl-span Γ' decl-param pi1 pi1' x atk~ me pi2 pi' -] [- var-span me Γ' pi1' x checking atk~ nothing -] check-and-add-params Γ' pi' ps' >>=c λ Γ'' ps~ → return2 Γ'' (Param me qx atk~ :: ps~) check-and-add-params Γ pi' [] = return2 Γ [] optAs-posinfo-var : ctxt → maybe import-as → posinfo × var → spanM (posinfo × var) optAs-posinfo-var Γ nothing = return optAs-posinfo-var Γ (just (ImportAs pi x)) orig = [- Import-module-span Γ orig [] [ not-for-navigation ] nothing -] return2 pi x {-# TERMINATING #-} {- notice that these are elaborating functions: they take an ex-QQQ and return a QQQ (along with other activity) -} process-cmd : toplevel-state → ex-cmd → spanM (toplevel-state × cmd) process-cmds : toplevel-state → ex-cmds → spanM (toplevel-state × cmds) process-ctrs : (uqv lqv mqv : var) → params → posinfo → toplevel-state → ex-ctrs → spanM ((ctxt → ctxt) × ctrs) process-params : toplevel-state → posinfo → ex-params → spanM (toplevel-state × params) process-start : toplevel-state → filepath → (progress-name : string) → ex-file → spanM (toplevel-state × file) process-file : toplevel-state → filepath → (progress-name : string) → mF (toplevel-state × file × string × string × params × qualif) maybe-add-opaque-span : optopaque → (end : posinfo) → spanM ⊤ maybe-add-opaque-span nothing pi = return triv maybe-add-opaque-span (just piₒ) pi = spanM-add $ Opaque-span piₒ pi process-cmd s (ExCmdDef op (ExDefTerm pi x (just tp) t) pi') = let Γ = toplevel-state.Γ s in Γ ⊢ tp ⇐ KdStar ↝ tp' / Γ ⊢ t ⇐ tp' ↝ t' / check-erased-margs Γ (term-start-pos t) (term-end-pos t) t' (just tp') >> let Γ' = ctxt-term-def pi globalScope (isNothing op) x (just t') tp' Γ in maybe-add-opaque-span op pi' >> [- DefTerm-span Γ' pi x checking (just tp') t' pi' [] -] check-redefined pi x s (CmdDefTerm x t') ([- uncurry (Var-span Γ' pi x checking) (compileFail-in Γ t') -] return (record s { Γ = Γ' })) process-cmd s (ExCmdDef op (ExDefTerm pi x nothing t) pi') = let Γ = toplevel-state.Γ s in Γ ⊢ t ↝ t~ ⇒ T~ / check-erased-margs Γ (term-start-pos t) (term-end-pos t) t~ nothing >> let Γ' = ctxt-term-def pi globalScope (isNothing op) x (just t~) T~ Γ in maybe-add-opaque-span op pi' >> [- DefTerm-span Γ' pi x synthesizing (just T~) t~ pi' [] -] check-redefined pi x s (CmdDefTerm x t~) ([- uncurry (Var-span Γ' pi x synthesizing) (compileFail-in Γ t~) -] return (record s { Γ = Γ' })) process-cmd s (ExCmdDef op (ExDefType pi x k tp) pi') = let Γ = toplevel-state.Γ s in Γ ⊢ k ↝ k~ / Γ ⊢ tp ⇐ k~ ↝ tp~ / let Γ' = ctxt-type-def pi globalScope (isNothing op) x (just tp~) k~ Γ in maybe-add-opaque-span op pi' >> spanM-add (DefType-span Γ' pi x checking (just k~) tp~ pi' []) >> check-redefined pi x s (CmdDefType x k~ tp~) ([- TpVar-span Γ' pi x checking [] nothing -] return (record s { Γ = Γ' })) process-cmd s (ExCmdKind pi x ps k pi') = let Γ = toplevel-state.Γ s in check-and-add-params Γ pi' ps >>=c λ Γₚₛ ps~ → Γₚₛ ⊢ k ↝ k~ / let Γ' = ctxt-kind-def pi x ps~ k~ Γ in [- DefKind-span Γ' pi x k~ pi' -] check-redefined pi x s (CmdDefKind x ps~ k~) ([- KdVar-span Γ' (pi , x) (posinfo-plus-str pi x) ps~ checking [] nothing -] return (record s { Γ = Γ' })) process-cmd s (ExCmdData (DefDatatype pi pi' x ps k cs) pi'') = let Γ = toplevel-state.Γ s old-Γ = Γ in [- DefDatatype-header-span pi -] check-and-add-params Γ pi'' ps >>=c λ Γₚₛ ps' → Γₚₛ ⊢ k ↝ k' / let mn = ctxt.mn Γ qx = mn # x mps = ctxt.ps Γ ++ ps' Γ-decl = λ Γ → ctxt-type-decl pi' x k' $ data-highlight Γ (pi' % x) cmd-fail = CmdDefType x (params-to-kind ps' k') (TpHole pi') fail = λ e → [- TpVar-span Γ pi' x checking [] (just e) -] return2 s cmd-fail in process-ctrs x (pi' % x) qx mps pi' (record s {Γ = Γ-decl Γₚₛ}) cs >>=c λ Γ-cs cs~ → maybe-else' (cedille-options.options.datatype-encoding options >>=c λ fp f → f) (fail "Missing directive for datatype encoding. Please add a datatype-encoding directive to your .cedille/options file. See cedille/.cedille/options for the current location") λ de → let is = kind-to-indices Γₚₛ k' kᵢ = indices-to-kind is $ KdAbs ignored-var (Tkt $ indices-to-tpapps is $ params-to-tpapps mps $ TpVar qx) KdStar in either-else' (init-encoding Γₚₛ de (Data x ps' is cs~)) fail λ ecs → check-redefined pi' x (record s {Γ = Γ-cs Γ}) (CmdDefData ecs x ps' k' cs~) let fₓ = fresh-var (add-indices-to-ctxt is Γ) "X" cs~ = map-fst (mn #_) <$> cs~ Γ' = Γ-cs Γ kₘᵤ = abs-expand-kind ps' $ KdAbs ignored-var (Tkk k') KdStar Γ' = ctxt-type-def pi' globalScope opacity-open (data-Is/ x) nothing kₘᵤ Γ' Tₘᵤ = params-to-alls ps' $ TpApp (params-to-tpapps mps (TpVar (mn # data-Is/ x))) (Ttp (params-to-tpapps mps $ TpVar qx)) Γ' = ctxt-term-def pi' globalScope opacity-open (data-is/ x) nothing Tₘᵤ Γ' Tₜₒ = abs-expand-type ps' $ mall fₓ (Tkk $ indices-to-kind is KdStar) $ TpAbs Erased ignored-var (Tkt (TpApp (params-to-tpapps mps $ TpVar $ mn # data-Is/ x) $ Ttp $ TpVar fₓ)) $ indices-to-alls is $ TpAbs NotErased ignored-var (Tkt (indices-to-tpapps is $ TpVar fₓ)) $ indices-to-tpapps is $ params-to-tpapps mps $ TpVar qx Γ' = ctxt-term-def pi' globalScope opacity-open (data-to/ x) (just id-term) Tₜₒ Γ' Γ' = ctxt-datatype-def pi' x ps' kᵢ k' cs~ ecs Γ' in [- DefDatatype-span Γ' pi pi' x ps' (abs-expand-kind ps' k') kₘᵤ k' Tₘᵤ Tₜₒ cs~ k pi'' -] [- TpVar-span Γ' pi' x checking (kind-data old-Γ k' :: params-data old-Γ ps') nothing -] return (record s {Γ = Γ'}) -- TODO ignore checking but still gen spans if need-to-check false? process-cmd s (ExCmdImport (ExImport pi op pi' x oa as pi'')) = let fnₒ = ctxt.fn (toplevel-state.Γ s) ie = get-include-elt s fnₒ oa' = maybe-map (λ {(ImportAs pi x) → x}) oa in case trie-lookup (include-elt.import-to-dep ie) x of λ where nothing → [- Import-span pi "missing" pi'' [] (just ("File not found: " ^ x)) -] return2 (set-include-elt s fnₒ (record ie {err = tt})) (CmdImport (Import op x x oa' [])) (just fnᵢ) → spanM-push (process-file s fnᵢ x) >>= uncurry₂ λ s f _ → process-import (toplevel-state.Γ s) op oa fnₒ fnᵢ (lookup-mod-params (toplevel-state.Γ s) fnᵢ) (maybe-else' (lookup-mod-params (toplevel-state.Γ s) fnₒ) [] id) >>=c λ e as~ → let s-e = scope-file s fnₒ fnᵢ oa' as~ Γ = toplevel-state.Γ s in [- Import-span pi fnᵢ pi'' [] (snd s-e ||-maybe e) -] return2 (fst s-e) (CmdImport (Import op fnᵢ x oa' as~)) where -- When importing a file publicly, you may use any number of arguments as long as the -- parameters of the current module are not free in them. -- You may then use any number of single-variable parameters from the current module -- as arguments as long as they retain the same order as before and have no non-parameter -- arguments between them -- (so parameters A, B, C, ..., Z can be used as arguments ·C ·X, but not ·X ·C) public-import-params-ok : params → args → err-m public-import-params-ok ps = h nothing where err = just "You can only use parameters for arguments to public imports if the are in order at the end" params-order : params → trie ℕ params-order = h 0 where h : ℕ → params → trie ℕ h n [] = empty-trie h n (Param me x atk :: ps) = trie-insert (h (suc n) ps) x n pso = params-order ps ps-free : arg → err-m → err-m ps-free a e = if ~ are-free-in-h pso (free-vars-arg a) then e else err h : maybe ℕ → args → err-m h c (a :: as) = maybe-else' (arg-var a >>= trie-lookup pso) (maybe-else' c (ps-free a $ h nothing as) λ _ → err) λ aₙ → maybe-else' c (h (just aₙ) as) λ cₙ → if cₙ ≥ aₙ then err else h (just aₙ) as h n [] = nothing process-import : ctxt → opt-public → maybe import-as → (cur imp : filepath) → maybe params → params → spanM (err-m × args) process-import Γ op oa fnₒ fnᵢ nothing _ = return2 (just "Undefined module import (this probably shouldn't happen?)") [] process-import Γ Public (just _) fnₒ fnᵢ (just psᵢ) psₒ = return2 (just "Public imports aren't allowed to be qualified") [] process-import Γ op oa fnₒ fnᵢ (just psᵢ) psₒ = optAs-posinfo-var Γ oa (pi' , x) >>= λ pi-v → check-args Γ as psᵢ >>= λ as~ → [- Import-module-span Γ (pi' , x) psᵢ [ location-data (fnᵢ , "1") ] nothing -] return2 (ifMaybe op $ public-import-params-ok psₒ as~) as~ process-cmds s (c :: cs) = process-cmd s c >>=c λ s c → process-cmds s cs >>=c λ s cs → return2 s (c :: cs) process-cmds s [] = return2 s [] process-ctrs uX lX mX ps piₓ s csₒ c? = h s csₒ c? where h : toplevel-state → ex-ctrs → spanM ((ctxt → ctxt) × ctrs) h s [] = return2 id [] h s (ExCtr pi x T :: cs) = let Γ = toplevel-state.Γ s in Γ ⊢ T ⇐ KdStar ↝ T~ / let T = hnf-ctr Γ lX T~ 𝕃tpkd-to-string = foldr (λ tk s → rope-to-string (tpkd-to-string Γ tk) ^ " ; " ^ s) "" neg-ret-err : maybe string neg-ret-err = let err-msg = λ s s' → just (uX ^ s ^ " type of the constructor: " ^ s') in case run-posM (positivity.ctr-positive lX Γ T) of λ where (ctorOk , l) → nothing (ctorNegative , l) → err-msg " occurs negatively in the" ("Searching types: " ^ 𝕃tpkd-to-string l) (ctorNotInReturnType , l) → err-msg " is not the return" "" in let T = [ Γ - TpVar mX / lX ] T Tₚₛ = [ Γ - params-to-tpapps ps (TpVar mX) / lX ] T~ in h s cs >>=c λ Γ-f cs → let Γ = toplevel-state.Γ s Γ-f' = ctxt-ctr-def pi x Tₚₛ ps (length csₒ) (length csₒ ∸ suc (length cs)) in check-redefined pi x s (Ctr x T :: cs) (let Γ = Γ-f' Γ in [- Var-span Γ pi x checking [ summary-data x (ctxt-type-def piₓ globalScope opacity-open uX nothing KdStar Γ) (abs-expand-type ps T) ] neg-ret-err -] return (record s {Γ = Γ})) >>=c λ s → return2 (Γ-f ∘ Γ-f') process-params s pi ps = let Γ = toplevel-state.Γ s in check-and-add-params Γ pi ps >>=c λ Γₚₛ ps → return2 (record s {Γ = ctxt-add-current-params (record Γₚₛ { ps = ps })}) ps process-start s filename pn (ExModule is pi1 pi2 mn ps cs pi3) = spanM-push (progress-update pn) >> process-cmds s (map ExCmdImport is) >>=c λ s is' → process-params s (params-end-pos first-position ps) ps >>=c λ s ps → process-cmds s cs >>=c λ s cs → process-cwst s filename >>= λ s → let pi2' = posinfo-plus-str pi2 mn in [- File-span (toplevel-state.Γ s) first-position (posinfo-plus pi3 1) filename -] [- Module-span pi2 pi2' -] [- Module-header-span pi1 pi2' -] return2 s (Module mn ps (is' ++ cs)) -- where -- unqual-cmd : ctxt → renamectxt → cmd → cmd -- unqual-cmd Γ ρ (CmdDefTerm x t) = CmdDefTerm x (subst-renamectxt Γ ρ t) -- unqual-cmd Γ ρ (CmdDefType x k T) = CmdDefType x (subst-renamectxt Γ ρ k) (subst-renamectxt Γ ρ T) -- unqual-cmd Γ ρ (CmdDefKind x ps k) = CmdDefKind x (substh-params Γ ρ empty-trie ps) (subst-renamectxt (add-params-to-ctxt ps Γ) ρ k) -- unqual-cmd Γ ρ (CmdDefData eds x ps k cs) = CmdDefData eds x (substh-params Γ ρ empty-trie ps) (subst-renamectxt (add-params-to-ctxt ps Γ) ρ k) (map-snd (subst-renamectxt (add-params-to-ctxt ps Γ) ρ) <$> cs) -- unqual-cmd Γ ρ (CmdImport (Import op fnᵢ x oa as)) = CmdImport (Import op fnᵢ x oa (subst-renamectxt Γ ρ -arg_ <$> as)) {- process (type-check if necessary) the given file. We assume the given top-level state has a syntax tree associated with the file. -} process-file s filename pn with get-include-elt s filename process-file s filename pn | ie = proceed s (include-elt.ast ie) (include-elt.ast~ ie) (set-need-to-add-symbols-to-context-include-elt ie ff) >>= λ where (s , ie , ret-mod , f) → return ({-set-include-elt s filename ie-} s , f , ret-mod) where proceed : toplevel-state → maybe ex-file → maybe file → include-elt → mF (toplevel-state × include-elt × (string × string × params × qualif) × file) proceed s nothing f~ ie' = progress-update filename >> -- write-to-log "should not happen" >> return (s , ie' , ctxt-get-current-mod (toplevel-state.Γ s) , maybe-else' f~ (Module ignored-var [] []) id) {- should not happen -} proceed s (just x) f~ ie' with include-elt.need-to-add-symbols-to-context ie proceed s (just x) (just f~) ie' | ff = let Γ = toplevel-state.Γ s mod = ctxt.fn Γ , ctxt.mn Γ , ctxt.ps Γ , ctxt.qual Γ in return (s , ie' , mod , f~) proceed (mk-toplevel-state ip fns is Γ logFilePath) (just x) f~ ie' | _ with include-elt.do-type-check ie | ctxt-get-current-mod Γ proceed (mk-toplevel-state ip fns is Γ logFilePath) (just x) f~ ie' | _ | do-check | prev-mod = let Γ = ctxt-initiate-file Γ filename (start-modname x) in process-start (mk-toplevel-state ip fns (trie-insert is filename ie') Γ logFilePath) filename pn x empty-spans >>= λ where ((mk-toplevel-state ip fns is Γ logFilePath , f) , ss) → let ret-mod = ctxt.fn Γ , ctxt.mn Γ , ctxt.ps Γ , ctxt.qual Γ ie'' = if do-check then set-spans-include-elt ie' ss f else record ie' { ast~ = include-elt.ast~ ie' ||-maybe just f } in progress-update pn >> return (mk-toplevel-state ip (if do-check then (filename :: fns) else fns) (trie-insert is filename ie'') (ctxt-set-current-mod Γ prev-mod) logFilePath , ie'' , ret-mod , f) -- proceed s (just x) f~ ie' | ff = -- return (s , ie' , ctxt-get-current-mod (toplevel-state.Γ s) , -- maybe-else' f~ (Module ignored-var [] []) id)
iowriteread.adb
zerodois-bcc/SEL0632-2019
0
6144
<reponame>zerodois-bcc/SEL0632-2019 -- Simple file opener and writer. -- <NAME> - ICMC/USP - March, 2019. WITH Ada.Sequential_IO; PROCEDURE TEST1 is PACKAGE Seq_Float_IO is new Ada.Sequential_IO (Element_Type => float); blank, container : Seq_Float_IO.File_Type; str : CONSTANT String := "stream_init.dat"; ord : CONSTANT String := "ordinate.mif"; BEGIN PROCEDURE Open_Data(File : in out Seq_Float_IO.File_Type; Name : in String) is BEGIN Seq_Float_IO.Open ( File => File, Mode => Seq_Float_IO.Append_File, Name => str ); EXCEPTION WHEN Seq_Float_IO.Name_Error => Seq_Float_IO.Create ( File => File, Mode => Seq_Float_IO.Out_File, Name => str); END; END Open_Data; x : CONSTANT float := 2.0; BEGIN -- bloco principal do programa Open_Data(File => blank, Name => str); Seq_Float_IO.Write(File => blank, Item => x); Seq_Float_IO.Close(File => blank); Open_Data(File => container, Name => ord); Seq_Float_IO.Write(File => container, Item => x); Seq_Float_IO.Close(File => container); END TEST1;
Light/Implementation/Data/These.agda
zamfofex/lightlib
1
1796
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Implementation.Data.These where open import Light.Library.Data.These using (Library ; Dependencies) open import Light.Variable.Levels open import Light.Level using (_⊔_) dependencies : Dependencies dependencies = record {} instance library : Library dependencies library = record { Implementation } where module Implementation where data These (𝕒 : Set aℓ) (𝕓 : Set bℓ) : Set (aℓ ⊔ bℓ) where this : 𝕒 → These 𝕒 𝕓 that : 𝕓 → These 𝕒 𝕓 these : 𝕒 → 𝕓 → These 𝕒 𝕓
mat/src/mat-commands.ads
stcarrez/mat
7
16132
<filename>mat/src/mat-commands.ads ----------------------------------------------------------------------- -- mat-commands -- Command support and execution -- Copyright (C) 2014, 2015 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with MAT.Targets; package MAT.Commands is -- Exception raised to stop the program. Stop_Interp : exception; -- Exception raised to stop the command (program continues). Stop_Command : exception; -- Exception raised by a command when a filter expression is invalid. Filter_Error : exception; -- Exception raised by a command when some command argument is invalid. Usage_Error : exception; -- Procedure that defines a command handler. type Command_Handler is access procedure (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Execute the command given in the line. procedure Execute (Target : in out MAT.Targets.Target_Type'Class; Line : in String); -- Initialize the process targets by loading the MAT files. procedure Initialize_Files (Target : in out MAT.Targets.Target_Type'Class); -- Symbol command. -- Load the symbols from the binary file. procedure Symbol_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Sizes command. -- Collect statistics about the used memory slots and report the different slot -- sizes with count. procedure Sizes_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Threads command. -- Collect statistics about the threads and their allocation. procedure Threads_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Events command. -- Print the probe events. procedure Events_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Event command. -- Print the probe event with the stack frame. procedure Event_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Info command to print symmary information about the program. procedure Info_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Timeline command. -- Identify the interesting timeline groups in the events and display them. procedure Timeline_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Addr command to print a description of an address. procedure Addr_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); end MAT.Commands;
fox32rom/monitor/shell.asm
ry755/fox32
6
2825
; debug monitor shell monitor_shell_start: mov.8 [MODIFIER_BITMAP], 0 call monitor_shell_clear_buffer mov r0, monitor_shell_prompt call print_string_to_monitor monitor_shell_event_loop: call get_next_event ; was a key pressed? cmp r0, EVENT_TYPE_KEY_DOWN ifz call monitor_shell_key_down_event ; was a key released? cmp r0, EVENT_TYPE_KEY_UP ifz call monitor_shell_key_up_event jmp monitor_shell_event_loop monitor_shell_key_down_event: mov r0, r1 cmp.8 r0, LSHIFT ifz jmp shift_pressed cmp.8 r0, RSHIFT ifz jmp shift_pressed cmp.8 r0, CAPS ifz jmp caps_pressed ; first, check if enter, delete, or backspace was pressed cmp.8 r0, 0x1C ; enter ifz jmp monitor_shell_key_down_event_enter cmp.8 r0, 0x6F ; delete ifz jmp monitor_shell_key_down_event_backspace cmp.8 r0, 0x0E ; backspace ifz jmp monitor_shell_key_down_event_backspace ; then, overwrite the cursor mov r1, r0 mov r0, 8 ; backspace character call print_character_to_monitor mov r0, r1 ; then, add it to the text buffer and print it to the screen call scancode_to_ascii call print_character_to_monitor call monitor_shell_push_character ; finally, print the cursor and redraw the line mov r0, '_' call print_character_to_monitor call redraw_monitor_console_line ret monitor_shell_key_down_event_enter: ; clear the cursor from the screen mov r0, 8 ; backspace character call print_character_to_monitor mov r0, ' ' ; space character call print_character_to_monitor mov r0, 8 ; backspace character call print_character_to_monitor mov r0, 10 ; line feed call print_character_to_monitor mov r0, 0 call monitor_shell_push_character call monitor_shell_parse_line call monitor_shell_clear_buffer mov r0, monitor_shell_prompt call print_string_to_monitor ret monitor_shell_key_down_event_backspace: ; check if we are already at the start of the prompt mov r1, [MONITOR_SHELL_TEXT_BUF_PTR] cmp r1, MONITOR_SHELL_TEXT_BUF_BOTTOM iflteq ret ; delete the last character from the screen, draw the cursor, and pop the last character from the buffer mov r0, 8 ; backspace character call print_character_to_monitor mov r0, ' ' ; space character call print_character_to_monitor mov r0, 8 ; backspace character call print_character_to_monitor call print_character_to_monitor mov r0, '_' ; cursor call print_character_to_monitor call monitor_shell_delete_character call redraw_monitor_console_line ret monitor_shell_key_up_event: mov r0, r1 cmp.8 r0, LSHIFT ifz jmp shift_released cmp.8 r0, RSHIFT ifz jmp shift_released ret monitor_shell_parse_line: ; if the line is empty, just return cmp.8 [MONITOR_SHELL_TEXT_BUF_BOTTOM], 0 ifz ret ; separate the command from the arguments ; store the pointer to the arguments mov r0, MONITOR_SHELL_TEXT_BUF_BOTTOM mov r1, ' ' call monitor_shell_tokenize mov [MONTIOR_SHELL_ARGS_PTR], r0 call monitor_shell_parse_command ret ; return tokens separated by the specified character ; returns the next token in the list ; inputs: ; r0: pointer to null-terminated string ; r1: separator character ; outputs: ; r0: pointer to next token or zero if none monitor_shell_tokenize: cmp.8 [r0], r1 ifz jmp monitor_shell_tokenize_found_token cmp.8 [r0], 0 ifz mov r0, 0 ifz ret inc r0 jmp monitor_shell_tokenize monitor_shell_tokenize_found_token: mov.8 [r0], 0 inc r0 ret ; parse up to 4 arguments into individual strings ; for example, "this is a test" will be converted to ; r0: pointer to "this" data.8 0 ; r1: pointer to "is" data.8 0 ; r2: pointer to "a" data.8 0 ; r3: pointer to "test" data.8 0 ; inputs: ; none ; outputs: ; r0: pointer to 1st null-terminated argument, or zero if none ; r1: pointer to 2nd null-terminated argument, or zero if none ; r2: pointer to 3rd null-terminated argument, or zero if none ; r3: pointer to 4th null-terminated argument, or zero if none monitor_shell_parse_arguments: push r31 mov r0, [MONTIOR_SHELL_ARGS_PTR] mov r1, ' ' mov r31, 3 push r0 monitor_shell_parse_arguments_loop: call monitor_shell_tokenize push r0 loop monitor_shell_parse_arguments_loop pop r3 pop r2 pop r1 pop r0 pop r31 ret ; push a character to the text buffer ; inputs: ; r0: character ; outputs: ; none monitor_shell_push_character: push r1 mov r1, [MONITOR_SHELL_TEXT_BUF_PTR] cmp r1, MONITOR_SHELL_TEXT_BUF_TOP ifgteq jmp monitor_shell_push_character_end mov.8 [r1], r0 inc [MONITOR_SHELL_TEXT_BUF_PTR] monitor_shell_push_character_end: pop r1 ret ; pop a character from the text buffer and zero it ; inputs: ; none ; outputs: ; r0: character monitor_shell_delete_character: push r1 mov r1, [MONITOR_SHELL_TEXT_BUF_PTR] cmp r1, MONITOR_SHELL_TEXT_BUF_BOTTOM iflteq jmp monitor_shell_pop_character_end dec [MONITOR_SHELL_TEXT_BUF_PTR] movz.8 r0, [r1] mov.8 [r1], 0 monitor_shell_pop_character_end: pop r1 ret ; mark the text buffer as empty ; inputs: ; none ; outputs: ; none monitor_shell_clear_buffer: push r0 ; set the text buffer poinrer to the start of the text buffer mov [MONITOR_SHELL_TEXT_BUF_PTR], MONITOR_SHELL_TEXT_BUF_BOTTOM ; set the first character as null mov r0, [MONITOR_SHELL_TEXT_BUF_PTR] mov.8 [r0], 0 pop r0 ret const MONITOR_SHELL_TEXT_BUF_TOP: 0x03ED4000 const MONITOR_SHELL_TEXT_BUF_BOTTOM: 0x03ED3FE0 ; 32 characters const MONITOR_SHELL_TEXT_BUF_PTR: 0x03ED3FDC ; 4 bytes - pointer to the current input character const MONTIOR_SHELL_ARGS_PTR: 0x03ED36C5 ; 4 bytes - pointer to the beginning of the command arguments monitor_shell_prompt: data.str "> _" data.8 0
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/rep_clause5.adb
best08618/asylo
7
30912
-- { dg-do compile } -- { dg-options "-O" } package body Rep_Clause5 is function To_LNumber(S : String) return LNumber_Type is V : VString; LV : Long_Type; LN : LNumber_Type; begin LV := To_Long(V, 10); LN := LNumber_Type(LV); return LN; end; procedure Merge_Numbered(LNodes : in out LNodes_Ptr) is T1 : Token_Type; LNO : LNumber_Type; begin for X in LNodes.all'Range loop T1 := LNodes(X).Line(0); if T1.Token /= LEX_LF then declare S : String := Element(T1.SID); begin begin LNO := To_LNumber(S); exception when Bad_Number => LNO := 0; when Too_Large => LNO := 0; end; end; end if; end loop; end; end Rep_Clause5;
Transynther/x86/_processed/AVXALIGN/_st_zr_4k_sm_/i9-9900K_12_0xca.log_7_493.asm
ljhsiun2/medusa
9
166499
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r8 push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1739d, %rsi nop nop nop nop cmp $56150, %r12 movw $0x6162, (%rsi) xor %rdi, %rdi lea addresses_D_ht+0x1967d, %rsi lea addresses_A_ht+0x190ad, %rdi nop nop nop add %r10, %r10 mov $102, %rcx rep movsl nop nop nop add %rdi, %rdi lea addresses_D_ht+0x6a7d, %rsi lea addresses_A_ht+0x4cf5, %rdi nop sub $12334, %r10 mov $59, %rcx rep movsl nop nop cmp $3875, %r12 lea addresses_D_ht+0xd99d, %rcx nop and %r12, %r12 movb $0x61, (%rcx) nop nop xor $10944, %r10 lea addresses_WT_ht+0x9e7d, %r8 nop sub $6472, %rsi mov (%r8), %di xor %rdi, %rdi lea addresses_WC_ht+0x1067d, %r10 nop nop nop nop nop xor $55980, %rcx movl $0x61626364, (%r10) nop nop nop and $22904, %rsi lea addresses_WC_ht+0x58bd, %rcx nop add %r8, %r8 mov (%rcx), %edi nop nop nop nop xor %rsi, %rsi lea addresses_normal_ht+0x16efd, %rcx nop nop nop nop nop cmp $47927, %r11 movb (%rcx), %r8b nop xor $46482, %rsi lea addresses_WT_ht+0x66fd, %r11 nop cmp %rcx, %rcx vmovups (%r11), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %r8 nop nop nop nop and $51770, %rdi lea addresses_D_ht+0x177d, %rsi lea addresses_UC_ht+0x10e7b, %rdi nop nop cmp %r12, %r12 mov $124, %rcx rep movsw nop nop nop nop sub %rcx, %rcx lea addresses_normal_ht+0x1c6fd, %rsi lea addresses_A_ht+0x16f6d, %rdi clflush (%rsi) cmp $16458, %r8 mov $84, %rcx rep movsq nop nop nop cmp %r11, %r11 pop %rsi pop %rdi pop %rcx pop %r8 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %rbx push %rcx push %rsi // Load lea addresses_D+0xfafd, %rcx nop xor $12026, %r14 mov (%rcx), %r10 nop nop nop sub $15913, %r10 // Store lea addresses_D+0x1067d, %rsi nop nop nop nop nop add $45479, %rbx mov $0x5152535455565758, %r14 movq %r14, (%rsi) nop nop cmp $64137, %rcx // Load lea addresses_RW+0xa7d, %r11 nop nop nop nop nop and $55191, %rbx movb (%r11), %cl nop nop sub %rcx, %rcx // Store lea addresses_PSE+0x148fd, %r14 cmp $35357, %r13 mov $0x5152535455565758, %r10 movq %r10, (%r14) nop nop nop nop nop add %r10, %r10 // Load lea addresses_WC+0x14efd, %r14 clflush (%r14) nop nop nop nop add %rsi, %rsi movb (%r14), %r10b nop nop nop and %r13, %r13 // Store lea addresses_D+0x1ac2d, %rcx nop nop nop cmp %r10, %r10 movl $0x51525354, (%rcx) nop nop nop xor $50261, %r11 // Store mov $0x67d2ea0000000e7d, %r13 nop nop nop nop nop cmp %r14, %r14 mov $0x5152535455565758, %rsi movq %rsi, %xmm3 vmovups %ymm3, (%r13) xor %rbx, %rbx // Store lea addresses_RW+0x427d, %r13 cmp $44762, %rcx movl $0x51525354, (%r13) nop nop nop nop dec %rsi // Store lea addresses_D+0x1067d, %rbx nop nop and %r11, %r11 mov $0x5152535455565758, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%rbx) nop nop add $42281, %rsi // Faulty Load lea addresses_D+0x1067d, %rbx xor %r14, %r14 vmovntdqa (%rbx), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rsi lea oracles, %rbx and $0xff, %rsi shlq $12, %rsi mov (%rbx,%rsi,1), %rsi pop %rsi pop %rcx pop %rbx pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': True, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': True, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 2, 'NT': True, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 9}, 'dst': {'same': True, 'type': 'addresses_A_ht', 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': True, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'00': 4, '58': 3} 58 00 00 58 00 58 00 */
libsrc/_DEVELOPMENT/math/float/math48/c/sccz80/cm48_sccz80_fmin.asm
meesokim/z88dk
0
18481
<gh_stars>0 ; double fmin(double x, double y) SECTION code_fp_math48 PUBLIC cm48_sccz80_fmin EXTERN am48_fmin, cm48_sccz80p_dparam2 cm48_sccz80_fmin: call cm48_sccz80p_dparam2 ; AC'= y ; AC = x jp am48_fmin
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_optimization23_pkg.adb
best08618/asylo
7
19877
-- { dg-do compile } -- { dg-options "-O3" } -- PR tree-optimization/71083 package body Loop_Optimization23_Pkg is procedure Foo (X : in out ArrayOfStructB) is begin for K in 0..99 loop X (K+1).b.b := X (K).b.b; end loop; end Foo; end Loop_Optimization23_Pkg;
libsrc/target/nc100/lapcat_receive.asm
jpoikela/z88dk
640
178586
SECTION code_clib PUBLIC lapcat_receive PUBLIC _lapcat_receive .lapcat_receive ._lapcat_receive call 0xb8d5 ld h, 0 ld l, a ret c ld hl, 0xffff ret
agda/BTree/Equality.agda
bgbianchi/sorting
6
1015
module BTree.Equality {A : Set} where open import BTree {A} data _≃_ : BTree → BTree → Set where ≃lf : leaf ≃ leaf ≃nd : {l r l' r' : BTree} (x x' : A) → l ≃ r → l ≃ l' → l' ≃ r' → node x l r ≃ node x' l' r'
src/x86-64/syscalls/input.asm
ohnx/ge
0
1381
; ============================================================================= ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems ; Copyright (C) 2008-2015 Return Infinity -- see LICENSE.TXT ; ; Input Functions ; ============================================================================= ; ----------------------------------------------------------------------------- ; os_input -- Take string from keyboard entry ; IN: RDI = location where string will be stored ; RCX = maximum number of characters to accept ; OUT: RCX = length of string that was input (NULL not counted) ; All other registers preserved os_input: push rdi push rdx ; Counter to keep track of max accepted characters push rax mov rdx, rcx ; Max chars to accept xor rcx, rcx ; Offset from start os_input_more: mov al, '_' call os_output_char call os_dec_cursor call os_input_key jnc os_input_halt ; No key entered... halt until an interrupt is received cmp al, 0x1C ; If Enter key pressed, finish je os_input_done cmp al, 0x0E ; Backspace je os_input_backspace cmp al, 32 ; In ASCII range (32 - 126)? jl os_input_more cmp al, 126 jg os_input_more cmp rcx, rdx ; Check if we have reached the max number of chars je os_input_more ; Jump if we have (should beep as well) stosb ; Store AL at RDI and increment RDI by 1 inc rcx ; Increment the counter call os_output_char ; Display char jmp os_input_more os_input_backspace: cmp rcx, 0 ; backspace at the beginning? get a new char je os_input_more mov al, ' ' ; 0x20 is the character for a space call os_output_char ; Write over the last typed character with the space call os_dec_cursor ; Decrement the cursor again call os_dec_cursor ; Decrement the cursor dec rdi ; go back one in the string mov byte [rdi], 0x00 ; NULL out the char dec rcx ; decrement the counter by one jmp os_input_more os_input_halt: hlt ; Halt until another keystroke is received jmp os_input_more os_input_done: mov al, 0x00 stosb ; We NULL terminate the string mov al, ' ' call os_output_char pop rax pop rdx pop rdi ret ; ----------------------------------------------------------------------------- ; ----------------------------------------------------------------------------- ; os_input_key -- Scans keyboard for input ; IN: Nothing ; OUT: AL = 0 if no key pressed, otherwise ASCII code, other regs preserved ; Carry flag is set if there was a keystroke, clear if there was not ; All other registers preserved os_input_key: mov al, [key] cmp al, 0 je os_input_key_no_key mov byte [key], 0x00 ; clear the variable as the keystroke is in AL now stc ; set the carry flag ret os_input_key_no_key: clc ; clear the carry flag ret ; ----------------------------------------------------------------------------- ; ============================================================================= ; EOF
tools/SPARK2005/examples/erfRiemann/riemann.adb
michalkonecny/polypaver
1
8740
<filename>tools/SPARK2005/examples/erfRiemann/riemann.adb with PP_F_Elementary; package body Riemann is function erf_Riemann(x : Float; n : Integer) return Float is partitionSize : Integer; stepSize : Float; stepStart : Float; valueStart : Float; result : Float; step : Integer; begin partitionSize := 2 ** n; stepSize := x/Float(partitionSize); result := 0.0; step := 0; while step < partitionSize loop -- for step = 0..((2^n)-1) loop stepStart := stepSize * Float(step); --# assert --# PP_F_Exact.Contained_In( --# result --# , --# PP_F_Exact.Integral --# (0.0, stepStart, --# PP_F_Exact.Exp(-PP_F_Exact.Integration_Variable**2) --# ) --# + --# PP_F_Exact.Interval( --# - c*Float(step+1) --# , --# (1.0-PP_F_Exact.Exp(-(x * Float(step)/Float(partitionSize))**2))*x/Float(partitionSize) --# + c*Float(step+1) --# ) --# ) --# and PP_F_Exact.Is_Range(result,-10, 100.0) --# and PP_Integer.Is_Range(n, 1, 10) --# and PP_Integer.Is_Range(step, 0, partitionSize-1) --# and partitionSize = 2 ** n --# and stepStart = PP_F_Rounded.Multiply(6, stepSize, Float(step)) --# and stepSize = PP_F_Rounded.Divide(6, x, Float(partitionSize)); valueStart := PP_F_Elementary.Exp(-(stepStart * stepStart)); result := result + stepSize * valueStart; step := step + 1; end loop; return result; end erf_Riemann; <NAME>;
programs/oeis/055/A055087.asm
karttu/loda
0
97744
; A055087: Integers 0..n then 0..n then 0..n+1 then 0..n+1 etc. ; 0,0,0,1,0,1,0,1,2,0,1,2,0,1,2,3,0,1,2,3,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11,12,0,1,2,3,4,5,6,7,8,9,10,11,12,0,1,2,3,4,5,6,7,8,9,10,11,12,13,0,1,2,3,4,5,6,7,8,9,10,11,12,13,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9 mov $1,$0 lpb $0,1 sub $0,1 mov $3,$1 mov $1,$0 trn $2,$3 trn $0,$2 mov $2,$3 lpe
programs/oeis/195/A195279.asm
jmorken/loda
1
102769
; A195279: Number of lower triangles of a 3 X 3 integer array with each element differing from all of its vertical and horizontal neighbors by n or less and triangles differing by a constant counted only once. ; 171,2125,11319,39609,107811,248261,507375,948209,1653019,2725821,4294951,6515625,9572499,13682229,19096031,26102241,35028875,46246189,60169239,77260441,98032131,123049125,152931279,188356049,230061051 mov $2,$0 add $2,$0 mov $4,3 add $4,$2 add $2,3 mul $2,2 mov $0,$2 pow $4,2 mul $0,$4 mov $3,$4 mul $3,2 add $3,1 lpb $0 mul $3,$0 sub $0,$0 mov $1,$3 lpe sub $1,1026 div $1,12 mul $1,2 add $1,171
programs/oeis/044/A044837.asm
jmorken/loda
1
167527
; A044837: Positive integers having more base-11 runs of even length than odd. ; 12,24,36,48,60,72,84,96,108,120,1452,1464,1476,1488,1500,1512,1524,1536,1548,1560,1572,2904,2916,2928,2940,2952,2964,2976,2988,3000,3012,3024,4356,4368,4380,4392,4404,4416,4428,4440 mov $2,$0 add $2,1 mov $5,$0 lpb $2 mov $0,$5 sub $2,1 sub $0,$2 add $0,1 mov $7,$0 lpb $0 mov $0,4 mov $3,$6 add $3,1 lpe add $3,9 gcd $7,$3 add $0,$7 add $0,4 mov $4,$0 sub $4,8 div $4,10 mul $4,1320 add $4,12 add $1,$4 mov $6,1 lpe
Linux/numberExists/numberExists.asm
shikhar-scs/Assembly-with-MacOS
19
18289
<filename>Linux/numberExists/numberExists.asm DATA SEGMENT MSG1 DB 10,13,'CHARACTER FOUND :) $' MSG2 DB 10,13,'CHARACTER NOT FOUND :($' MSG3 DB 10,13,'ENTER 10 NUMBERS : $' MSG4 DB 10,13,'ENTER THE NUMBER TO BE SEARCHED : $' NEW DB 10,13,'$' INST DB 10 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX LEA DX,MSG3 MOV AH,09H INT 21H MOV BX,00 UP: MOV AH,01H INT 21H CMP AL,0DH JE DOWN MOV [INST+BX],AL INC BX JMP UP DOWN:LEA DX,NEW MOV AH,09H INT 21H LEA DX,MSG4 MOV AH,09H INT 21H MOV AH,01H INT 21H MOV CX,BX MOV DI,0 UP1: CMP AL,[INST+DI] JE DOWN1 INC DI LOOP UP1 LEA DX,MSG2 MOV AH,09H INT 21H JMP FINISH DOWN1: LEA DX,MSG1 MOV AH,09H INT 21H FINISH: INT 3 CODE ENDS END START END
8085_programming/8085 Programs/test12.asm
SayanGhoshBDA/code-backup
16
10994
<filename>8085_programming/8085 Programs/test12.asm<gh_stars>10-100 DAD B HLT
.emacs.d/elpa/wisi-3.1.3/wisitoken-parse-lr-mckenzie_recover-explore.adb
caqg/linux-home
0
3174
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2020 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, 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 MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Exceptions; with SAL.Gen_Bounded_Definite_Queues; with WisiToken.Parse.LR.McKenzie_Recover.Parse; with WisiToken.Parse.LR.Parser; package body WisiToken.Parse.LR.McKenzie_Recover.Explore is procedure Do_Shift (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; State : in State_Index; ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is use Config_Op_Arrays; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Op : constant Config_Op := (Insert, ID, Config.Current_Shared_Token); begin Config.Strategy_Counts (Strategy) := Config.Strategy_Counts (Strategy) + 1; if Is_Full (Config.Ops) then Super.Config_Full ("do_shift ops", Parser_Index); raise Bad_Config; else Append (Config.Ops, Op); end if; if Cost_Delta = 0 then Config.Cost := Config.Cost + McKenzie_Param.Insert (ID); else -- Cost_Delta /= 0 comes from Insert_Minimal_Complete_Actions. That -- doesn't mean it is better than any other solution, so don't let -- cost be 0. -- -- We don't just eliminate all cost for Minimal_Complete_Actions; -- that leads to using it far too much at the expense of better -- solutions. Config.Cost := Integer'Max (1, Config.Cost + McKenzie_Param.Insert (ID) + Cost_Delta); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Config.Stack.Is_Full then Super.Config_Full ("do_shift stack", Parser_Index); raise Bad_Config; else Config.Stack.Push ((State, Invalid_Node_Index, (ID, Virtual => True, others => <>))); end if; if Trace_McKenzie > Detail then Base.Put ((if Label'Length > 0 then Label & ": " else "") & "insert " & Image (ID, Super.Trace.Descriptor.all), Super, Shared, Parser_Index, Config); end if; Local_Config_Heap.Add (Config); end Do_Shift; procedure Do_Reduce_1 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Action : in Reduce_Action_Rec; Do_Language_Fixes : in Boolean := True) is use all type Semantic_Checks.Check_Status_Label; use all type WisiToken.Parse.LR.Parser.Language_Fixes_Access; Prev_State : constant Unknown_State_Index := Config.Stack.Peek.State; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Nonterm : Recover_Token; New_State : Unknown_State_Index; begin Config.Check_Status := Parse.Reduce_Stack (Shared, Config.Stack, Action, Nonterm, Default_Virtual => True); case Config.Check_Status.Label is when Ok => null; when Semantic_Checks.Error => Config.Error_Token := Nonterm; Config.Check_Token_Count := Action.Token_Count; if Do_Language_Fixes then if Shared.Language_Fixes /= null then Shared.Language_Fixes (Super.Trace.all, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); end if; end if; -- Finish the reduce; ignore the check fail. if Config.Stack.Depth < SAL.Base_Peek_Type (Config.Check_Token_Count) then raise SAL.Programmer_Error; else Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end case; if Config.Stack.Depth = 0 or else Config.Stack.Peek.State = Unknown_State then raise Bad_Config; end if; New_State := Goto_For (Table, Config.Stack.Peek.State, Action.Production.LHS); if New_State = Unknown_State then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & ": Do_Reduce_1: unknown_State " & Config.Stack.Peek.State'Image & " " & Image (Action.Production.LHS, Descriptor)); end if; raise Bad_Config; end if; Config.Stack.Push ((New_State, Invalid_Node_Index, Nonterm)); if Trace_McKenzie > Extra and Label'Length > 0 then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & ": state" & State_Index'Image (Prev_State) & " reduce" & Ada.Containers.Count_Type'Image (Action.Token_Count) & " to " & Image (Action.Production.LHS, Descriptor) & ", goto" & State_Index'Image (New_State) & " via" & State_Index'Image (Config.Stack.Peek (2).State)); end if; end Do_Reduce_1; procedure Do_Reduce_2 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Inserted_ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is -- Perform reduce actions until shift Inserted_ID; if all succeed, -- add the final configuration to the heap, return True. If a conflict is -- encountered, process the other action the same way. If a semantic -- check fails, enqueue possible solutions. For parse table error -- actions, or exception Bad_Config, return False. Orig_Config : Configuration; Table : Parse_Table renames Shared.Table.all; Next_Action : Parse_Action_Node_Ptr := Action_For (Table, Config.Stack.Peek.State, Inserted_ID); begin if Next_Action.Next /= null then Orig_Config := Config; end if; case Next_Action.Item.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It"; when Error => if Trace_McKenzie > Extra and Label'Length > 0 then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & ": error on " & Image (Inserted_ID, Super.Trace.Descriptor.all) & " in state" & State_Index'Image (Config.Stack.Peek.State)); end if; end case; loop exit when Next_Action.Next = null; -- There is a conflict; create a new config to shift or reduce. declare New_Config : Configuration := Orig_Config; Action : Parse_Action_Rec renames Next_Action.Next.Item; begin case Action.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It conflict"; when Error => null; end case; end; Next_Action := Next_Action.Next; end loop; exception when Bad_Config => if Debug_Mode then raise; end if; end Do_Reduce_2; function Edit_Point_Matches_Ops (Config : in Configuration) return Boolean is use Config_Op_Arrays, Config_Op_Array_Refs; pragma Assert (Length (Config.Ops) > 0); Op : Config_Op renames Constant_Ref (Config.Ops, Last_Index (Config.Ops)); begin return Config.Current_Shared_Token = (case Op.Op is when Fast_Forward => Op.FF_Token_Index, when Undo_Reduce => Invalid_Token_Index, -- ie, "we don't know", so return False. when Push_Back => Op.PB_Token_Index, when Insert => Op.Ins_Token_Index, when Delete => Op.Del_Token_Index + 1); end Edit_Point_Matches_Ops; procedure Fast_Forward (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in Configuration) is -- Apply the ops in Config; they were inserted by some fix. -- Leaves Config.Error_Token, Config.Check_Status set. -- If there are conflicts, all are parsed; if more than one succeed. -- All configs are enqueued in Local_Config_Heap. use Parse.Parse_Item_Arrays; use Config_Op_Arrays; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => "fast_forward"); begin -- This solution is from Language_Fixes (see gate on call site -- below); any cost increase is done there. -- -- We used to handle the Parse_Items.Length = 1 case specially, and -- return Continue. Maintaining that requires too much code -- duplication. for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then -- Item.Config.Error_Token.ID, Check_Status are correct. if not Edit_Point_Matches_Ops (Item.Config) then if Is_Full (Item.Config.Ops) then Super.Config_Full ("fast_forward 1", Parser_Index); raise Bad_Config; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; end if; Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put ("fast forward enqueue", Super, Shared, Parser_Index, Item.Config); end if; end if; exception when Bad_Config => null; end; end loop; end Fast_Forward; function Check (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Check_Status is use Config_Op_Arrays, Config_Op_Array_Refs; use Parse.Parse_Item_Arrays; use all type Semantic_Checks.Check_Status_Label; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Result : Check_Status := Continue; begin if Length (Config.Ops) > 0 then declare Op : Config_Op renames Constant_Ref (Config.Ops, Last_Index (Config.Ops)); begin case Op.Op is when Push_Back => -- Check would undo the Push_Back, leading to -- duplicate results. See test_mckenzie_recover.adb Do_Delete_First and -- three_action_conflict_lalr.parse_good for examples. return Continue; when Undo_Reduce => if Config.Check_Status.Label /= Ok then -- This is the "ignore error" solution for a check fail; check it. Config.Check_Status := (Label => Ok); Config.Error_Token.ID := Invalid_Token_ID; else -- Check would undo the Undo_Reduce, leading to -- duplicate results. return Continue; end if; when others => -- Check it null; end case; end; end if; if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Config.Resume_Token_Goal, All_Conflicts => False, Trace_Prefix => "check") then Config.Error_Token.ID := Invalid_Token_ID; -- FIXME: if there were conflicts, enqueue them; they might yield a -- cheaper or same cost solution? if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "check result: SUCCESS"); end if; return Success; end if; -- Set Config.error to reflect failure, if it is at current token, so -- Use_Minimal_Complete_Actions can see it. declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, First_Index (Parse_Items)); begin if Item.Config.Check_Status.Label /= Ok then Config.Check_Status := Item.Config.Check_Status; Config.Error_Token := Item.Config.Error_Token; -- Explore cannot fix a check fail; only Language_Fixes can. The -- "ignore error" case is handled immediately on return from -- Language_Fixes in Process_One, below. Result := Abandon; elsif Item.Config.Error_Token.ID /= Invalid_Token_ID then if Item.Shift_Count = 0 then Config.Error_Token := Item.Config.Error_Token; Config.Check_Status := (Label => Ok); else -- Error is not at current token, but Explore might find something -- that will help (see test_mckenzie_recover.adb Extra_Begin). On the -- other hand, this can lead to lots of bogus configs (see -- If_In_Handler). Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end if; end if; end; -- All Parse_Items either failed or were not parsed; if they failed -- and made progress, enqueue them. for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin -- When Parse starts above, Config.Current_Shared_Token matches -- Config.Ops. So if Item.Config.Current_Shared_Token > -- Config.Current_Shared_Token, it made some progress. Append or -- update a Fast_Forward to indicate the changed edit point. if Item.Config.Error_Token.ID /= Invalid_Token_ID and Item.Config.Current_Shared_Token > Config.Current_Shared_Token then Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; if Constant_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).Op = Fast_Forward then -- Update the trailing Fast_Forward. Variable_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).FF_Token_Index := Item.Config.Current_Shared_Token; else if Is_Full (Item.Config.Ops) then Super.Config_Full ("check 1", Parser_Index); raise Bad_Config; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; end if; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put ("new error point ", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "check result: " & Result'Image); end if; return Result; exception when Bad_Config => return Abandon; end Check; function Check_Reduce_To_Start (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in Configuration) return Boolean -- Returns True if Config reduces to the start nonterm. is Table : Parse_Table renames Shared.Table.all; function To_Reduce_Action (Item : in Minimal_Action) return Reduce_Action_Rec is begin return (Reduce, Item.Production, null, null, Item.Token_Count); end To_Reduce_Action; Local_Config_Heap : Config_Heaps.Heap_Type; -- never used, because Do_Language_Fixes is False. Config : Configuration := Orig_Config; Actions : Minimal_Action_Arrays.Vector := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; begin loop case Actions.Length is when 0 => if (for some Item of Table.States (Config.Stack.Peek.State).Kernel => Item.Production.LHS = Super.Trace.Descriptor.Accept_ID) then return True; else return False; end if; when 1 => case Actions (Actions.First_Index).Verb is when Shift => return False; when Reduce => Do_Reduce_1 ("", Super, Shared, Parser_Index, Local_Config_Heap, Config, To_Reduce_Action (Actions (Actions.First_Index)), Do_Language_Fixes => False); Actions := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; end case; when others => return False; end case; -- loop only exits via returns above end loop; exception when Bad_Config => -- From Do_Reduce_1 return False; end Check_Reduce_To_Start; procedure Try_Push_Back (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Prev_Recover : constant WisiToken.Base_Token_Index := Super.Parser_State (Parser_Index).Resume_Token_Goal; Token : constant Recover_Token := Config.Stack.Peek.Token; begin -- Try pushing back the stack top, to allow insert and other -- operations at that point. -- -- Since we are not actually changing the source text, it is tempting -- to give this operation zero cost. But then we keep doing push_back -- forever, making no progress. So we give it a cost. if Token.Min_Terminal_Index /= Invalid_Token_Index and -- No point in pushing back an empty nonterm; that leads to duplicate -- solutions with Undo_Reduce; see test_mckenzie_recover.adb Error_2. (Prev_Recover = Invalid_Token_Index or else Prev_Recover < Token.Min_Terminal_Index) -- Don't push back past previous error recover (that would require -- keeping track of previous inserts/deletes, and would not be useful -- in most cases). then declare use Config_Op_Arrays; New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Stack.Pop; if Is_Full (New_Config.Ops) then Super.Config_Full ("push_back 1", Parser_Index); raise Bad_Config; else if Token.Min_Terminal_Index = Invalid_Token_Index then -- Token is empty; Config.current_shared_token does not change, no -- cost increase. Append (New_Config.Ops, (Push_Back, Token.ID, New_Config.Current_Shared_Token)); else New_Config.Cost := New_Config.Cost + McKenzie_Param.Push_Back (Token.ID); Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); New_Config.Current_Shared_Token := Token.Min_Terminal_Index; end if; end if; New_Config.Strategy_Counts (Push_Back) := New_Config.Strategy_Counts (Push_Back) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("push_back " & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Push_Back; function Just_Pushed_Back_Or_Deleted (Config : in Configuration; ID : in Token_ID) return Boolean is use Config_Op_Arrays, Config_Op_Array_Refs; Last_Token_Index : WisiToken.Token_Index := Config.Current_Shared_Token; -- Index of token in last op checked. begin -- This function is called when considering whether to insert ID before -- Config.Current_Shared_Token. -- -- We need to consider more than one recent op here; see test_mckenzie_recover.adb -- Check_Multiple_Delete_For_Insert. Checking only one op allows this solution there: -- -- ... (DELETE, END, 7), (DELETE, SEMICOLON, 8), (INSERT, END, 9), (INSERT, SEMICOLON, 9) -- for I in reverse First_Index (Config.Ops) .. Last_Index (Config.Ops) loop declare Op : Config_Op renames Constant_Ref (Config.Ops, I); begin case Op.Op is when Push_Back => -- The case we are preventing for Push_Back is typically one of: -- (PUSH_BACK, Identifier, 2), (INSERT, Identifier, 2) -- (PUSH_BACK, Identifier, 2), (PUSH_BACK, END, 3), (INSERT, Identifier, 3), (INSERT, END, 3), if Op.PB_Token_Index = Last_Token_Index then if Op.PB_ID = ID then return True; else if Op.PB_Token_Index = WisiToken.Token_Index'First then return False; else Last_Token_Index := Op.PB_Token_Index - 1; end if; end if; else -- Op is at a different edit point. return False; end if; when Delete => if Op.Del_Token_Index = Last_Token_Index - 1 then if Op.Del_ID = ID then return True; else Last_Token_Index := Op.Del_Token_Index; end if; else -- Op is at a different edit point. return False; end if; when Fast_Forward | Insert | Undo_Reduce => return False; end case; end; end loop; return False; end Just_Pushed_Back_Or_Deleted; procedure Try_Undo_Reduce (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use Config_Op_Arrays; Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Token : constant Recover_Token := Config.Stack.Peek.Token; New_Config : Configuration := Config; Token_Count : Ada.Containers.Count_Type; begin -- Try expanding the nonterm on the stack top, to allow pushing_back -- its components, or insert and other operations at that point. New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Token_Count := Undo_Reduce (New_Config.Stack, Super.Parser_State (Parser_Index).Tree); if Token.Min_Terminal_Index /= Invalid_Token_Index then -- If Token is empty no cost increase. New_Config.Cost := New_Config.Cost + McKenzie_Param.Undo_Reduce (Token.ID); end if; if Is_Full (New_Config.Ops) then Super.Config_Full ("undo_reduce 1", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Undo_Reduce, Token.ID, Token_Count)); end if; New_Config.Strategy_Counts (Undo_Reduce) := New_Config.Strategy_Counts (Undo_Reduce) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("undo_reduce " & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end Try_Undo_Reduce; procedure Insert_From_Action_List (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Minimal_Insert : in Token_ID_Arrays.Vector; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Table : Parse_Table renames Shared.Table.all; EOF_ID : Token_ID renames Super.Trace.Descriptor.EOI_ID; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; -- Find terminal insertions from the current state's action_list to try. -- -- We perform any needed reductions and one shift, so the config is -- in a consistent state, and enqueue the result. If there are any -- conflicts or semantic check fails encountered, they create other -- configs to enqueue. Current_Token : constant Token_ID := Current_Token_ID_Peek (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete); Cached_Config : Configuration; Cached_Action : Reduce_Action_Rec; -- Most of the time, all the reductions in a state are the same. So -- we cache the first result. This includes one reduction; if an -- associated semantic check failed, this does not include the fixes. I : Parse_Action_Node_Ptr; begin for Node of Table.States (Config.Stack.Peek.State).Action_List loop I := Node.Actions; loop exit when I = null; declare ID : constant Token_ID := Node.Symbol; Action : Parse_Action_Rec renames I.Item; begin if ID /= EOF_ID and then -- can't insert eof ID /= Invalid_Token_ID -- invalid when Verb = Error then if Just_Pushed_Back_Or_Deleted (Config, ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) & ": undo push_back"); end if; elsif ID = Current_Token then -- This is needed because we allow explore when the error is not at -- the explore point; it prevents inserting useless tokens (ie -- 'identifier ;' in ada_lite). if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) & ": current token"); end if; elsif (for some Minimal of Minimal_Insert => ID = Minimal) then -- Was inserted by Insert_Minimal_Complete_Actions null; else case Action.Verb is when Shift => declare New_Config : Configuration := Config; begin Do_Shift ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, ID, Cost_Delta => 0, Strategy => Insert); end; when Reduce => if not Equal (Action, Cached_Action) then declare New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Do_Reduce_1 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Cached_Config := New_Config; Cached_Action := Action; Do_Reduce_2 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Insert); end; else declare New_Config : Configuration := Cached_Config; begin Do_Reduce_2 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Insert); end; end if; when Accept_It => raise SAL.Programmer_Error with "found test case for Process_One Accept_It"; when Error => null; end case; end if; end if; end; I := I.Next; end loop; end loop; end Insert_From_Action_List; function Insert_Minimal_Complete_Actions (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Token_ID_Arrays.Vector -- Return tokens inserted (empty if none). is use Ada.Containers; Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Inserted : Token_ID_Array (1 .. 10) := (others => Invalid_Token_ID); Inserted_Last : Integer := Inserted'First - 1; type Work_Item is record Action : Minimal_Action; Cost_Delta : Integer; Config : Configuration; end record; package Item_Queues is new SAL.Gen_Bounded_Definite_Queues (Work_Item); use Item_Queues; Work : Queue_Type (10); -- The required queue size depends on the number of multiple-item -- Minimal_Complete_Actions encountered. That is limited by compound -- statement nesting, and by the frequency of such actions. procedure Safe_Add_Work (Label : in String; Item : in Work_Item) is begin if Is_Full (Work) then Super.Config_Full ("Minimal_Complete_Actions " & Label, Parser_Index); raise Bad_Config; else Add (Work, Item); end if; end Safe_Add_Work; function To_Reduce_Action (Action : in Minimal_Action) return Reduce_Action_Rec is (Reduce, Action.Production, null, null, Action.Token_Count); procedure Minimal_Do_Shift (Action : in Minimal_Action; Cost_Delta : in Integer; Config : in out Configuration) is begin if Just_Pushed_Back_Or_Deleted (Config, Action.ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: abandon " & Image (Action.ID, Descriptor) & ": undo push back"); end if; else Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Config.Minimal_Complete_State := Active; Inserted_Last := Inserted_Last + 1; if Inserted_Last <= Inserted'Last then Inserted (Inserted_Last) := Action.ID; else Super.Config_Full ("minimal_do_shift Inserted", Parser_Index); raise Bad_Config; end if; Do_Shift ("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Config, Action.State, Action.ID, Cost_Delta, Strategy => Minimal_Complete); end if; end Minimal_Do_Shift; procedure Enqueue_Min_Actions (Label : in String; Actions : in Minimal_Action_Arrays.Vector; Config : in Configuration) is use SAL; Length : array (Actions.First_Index .. Actions.Last_Index) of Count_Type := (others => Count_Type'Last); Min_Length : Count_Type := Count_Type'Last; begin if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: " & Label & Image (Actions, Descriptor)); end if; if Actions.Length = 0 then return; elsif Actions.Length = 1 then Safe_Add_Work ("1", (Actions (Actions.First_Index), Table.McKenzie_Param.Minimal_Complete_Cost_Delta, Config)); return; end if; -- More than one minimal action in State; try to use next states and -- recursion to pick one. Actions_Loop : for I in Actions.First_Index .. Actions.Last_Index loop declare function Matches (Item : in Kernel_Info; Action : in Minimal_Action) return Boolean is begin case Action.Verb is when Shift => return Item.Before_Dot = Action.ID; when Reduce => return Item.Before_Dot = Action.Production.LHS; end case; end Matches; function Length_After_Dot (Item : in Kernel_Info; Action : in Minimal_Action; Stack : in Recover_Stacks.Stack) return Ada.Containers.Count_Type is Match_ID : Token_ID; New_Stack : Recover_Stacks.Stack := Stack; Next_State : Unknown_State_Index; Result : Ada.Containers.Count_Type; Min_Result : Ada.Containers.Count_Type := Ada.Containers.Count_Type'Last; begin case Action.Verb is when Shift => New_Stack.Push ((Action.State, Invalid_Node_Index, (ID => Action.ID, others => <>))); Next_State := Action.State; Match_ID := Action.ID; when Reduce => New_Stack.Pop (SAL.Base_Peek_Type (Action.Token_Count)); Next_State := Goto_For (Shared.Table.all, New_Stack.Peek.State, Action.Production.LHS); if Next_State = Unknown_State then -- We get here when Insert_From_Action_Table started us down a bad path raise Bad_Config; end if; New_Stack.Push ((Next_State, Invalid_Node_Index, (ID => Action.Production.LHS, others => <>))); Match_ID := Action.Production.LHS; end case; if Trace_McKenzie > Extra then Super.Trace.Put (Next_State'Image & " " & Trimmed_Image (Item.Production)); end if; for Item of Shared.Table.States (Next_State).Kernel loop if Item.Before_Dot = Match_ID then if Item.Length_After_Dot = 0 then Result := Length_After_Dot (Item, (Reduce, Item.Reduce_Production, Item.Reduce_Count), New_Stack); else Result := Item.Length_After_Dot; end if; end if; if Result < Min_Result then Min_Result := Result; end if; end loop; return Min_Result; end Length_After_Dot; Action : constant Minimal_Action := Actions (I); Next_State : constant State_Index := (case Action.Verb is when Shift => Action.State, when Reduce => Goto_For (Shared.Table.all, Config.Stack.Peek (Base_Peek_Type (Action.Token_Count) + 1).State, Action.Production.LHS)); begin if Trace_McKenzie > Extra then Super.Trace.Put ("task" & Task_Attributes.Value'Image & Super.Label (Parser_Index)'Image & ": Minimal_Complete_Actions: " & Image (Action, Descriptor)); end if; for Item of Shared.Table.States (Next_State).Kernel loop if Matches (Item, Action) then -- For Action.Verb = Reduce, more than one item may match if Item.Length_After_Dot = 0 then -- Set Length from a non-zero-length non-recursive item. Length (I) := Length_After_Dot (Item, Action, Config.Stack); elsif Item.Length_After_Dot < Length (I) then if Trace_McKenzie > Extra then -- Length_After_Dot outputs this in other branch Super.Trace.Put (Next_State'Image & " " & Trimmed_Image (Item.Production)); end if; Length (I) := Item.Length_After_Dot; end if; if Trace_McKenzie > Extra then Super.Trace.Put (" length" & Length (I)'Image); end if; if Length (I) < Min_Length then Min_Length := Length (I); end if; end if; end loop; if Trace_McKenzie > Extra then Super.Trace.New_Line; end if; end; end loop Actions_Loop; for I in Length'Range loop if Length (I) = Min_Length then Safe_Add_Work ("2", (Actions (I), Table.McKenzie_Param.Minimal_Complete_Cost_Delta, Config)); elsif Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: drop " & Image (Actions (I), Descriptor) & " not minimal or recursive"); end if; end loop; end Enqueue_Min_Actions; begin if Orig_Config.Stack.Depth = 1 then -- Get here with an empty source file, or a syntax error on the first -- token. return Token_ID_Arrays.Empty_Vector; elsif Orig_Config.Minimal_Complete_State = Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: done"); end if; return Token_ID_Arrays.Empty_Vector; end if; Enqueue_Min_Actions ("", Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions, Orig_Config); loop exit when Is_Empty (Work); declare Item : Work_Item := Get (Work); begin if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: dequeue work item " & Image (Item.Action, Descriptor)); end if; case Item.Action.Verb is when Reduce => -- Do a reduce, look at resulting state. Keep reducing until we can't -- anymore. declare Reduce_Action : Reduce_Action_Rec := To_Reduce_Action (Item.Action); Actions : Minimal_Action_Arrays.Vector; begin loop Do_Reduce_1 ("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Item.Config, Reduce_Action, Do_Language_Fixes => False); Actions := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions; case Actions.Length is when 0 => if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions abandoned: no actions"); end if; exit; when 1 => case Actions (Actions.First_Index).Verb is when Shift => Minimal_Do_Shift (Actions (Actions.First_Index), Item.Cost_Delta, Item.Config); exit; when Reduce => Reduce_Action := To_Reduce_Action (Actions (Actions.First_Index)); end case; when others => Enqueue_Min_Actions ("multiple actions ", Actions, Item.Config); exit; end case; end loop; end; when Shift => Minimal_Do_Shift (Item.Action, Item.Cost_Delta, Item.Config); end case; end; end loop; if Inserted_Last = Inserted'First - 1 then -- Nothing inserted this round. if Orig_Config.Minimal_Complete_State = Active then Orig_Config.Minimal_Complete_State := Done; end if; end if; return To_Vector (Inserted (1 .. Inserted_Last)); exception when Bad_Config => return Token_ID_Arrays.Empty_Vector; end Insert_Minimal_Complete_Actions; procedure Insert_Matching_Begin (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type; Matching_Begin_Tokens : in Token_ID_Arrays.Vector) is Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; begin -- We don't check for insert = current token; that's either ok or a -- severe bug in Shared.Language_Matching_Begin_Tokens. if Config.Matching_Begin_Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned: done"); end if; return; end if; if Just_Pushed_Back_Or_Deleted (Config, Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index)) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned " & Image (Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index), Descriptor) & ": undo push_back"); end if; return; end if; declare New_Config : Configuration := Config; begin for ID of Matching_Begin_Tokens loop Insert (New_Config, ID); end loop; declare use Parse.Parse_Item_Arrays; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : constant Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => "parse Matching_Begin"); begin for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then Item.Config.Matching_Begin_Done := True; Item.Config.Cost := Item.Config.Cost + Table.McKenzie_Param.Matching_Begin; Item.Config.Strategy_Counts (Matching_Begin) := Item.Config.Strategy_Counts (Matching_Begin) + 1; Item.Config.Error_Token.ID := Invalid_Token_ID; Item.Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Trace_McKenzie > Detail then Base.Put ("Matching_Begin: insert " & Image (Matching_Begin_Tokens, Descriptor), Super, Shared, Parser_Index, Item.Config); end if; Local_Config_Heap.Add (Item.Config); else if Trace_McKenzie > Detail then Base.Put ("Matching_Begin: abandon " & Image (Matching_Begin_Tokens, Descriptor) & ": parse fail", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; end; end; exception when SAL.Container_Full => -- From config_ops_sorted Super.Config_Full ("Minimal_Complete_Actions 3", Parser_Index); end Insert_Matching_Begin; procedure Try_Insert_Terminal (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use all type WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access; Tokens : Token_ID_Array_1_3; Matching_Begin_Tokens : Token_ID_Arrays.Vector; Forbid_Minimal_Insert : Boolean := False; Minimal_Inserted : Token_ID_Arrays.Vector; begin if Shared.Language_Matching_Begin_Tokens /= null then Current_Token_ID_Peek_3 (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete, Tokens); Shared.Language_Matching_Begin_Tokens (Tokens, Config, Matching_Begin_Tokens, Forbid_Minimal_Insert); end if; if not Forbid_Minimal_Insert then -- See test_mckenzie_recover.adb Forbid_Minimal_Insert for rationale. Minimal_Inserted := Insert_Minimal_Complete_Actions (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; if Matching_Begin_Tokens.Length > 0 then Insert_Matching_Begin (Super, Shared, Parser_Index, Config, Local_Config_Heap, Matching_Begin_Tokens); end if; -- We always do all three; Insert_Minimal_Complete (unless -- Forbid_Minimal_Insert), Insert_Matching_Begin, -- Insert_From_Action_List; in general it's not possible to tell when -- one will be better (see test_mckenzie_recover.adb -- Always_Minimal_Complete, Always_Matching_Begin). -- Insert_From_Action_List does not insert the Minimal_Inserted tokens, -- and it will never insert the Matching_Begin_Tokens, so there is no -- duplication. Insert_From_Action_List will normally be more -- expensive. Insert_From_Action_List (Super, Shared, Parser_Index, Config, Minimal_Inserted, Local_Config_Heap); -- It is tempting to use the Goto_List to find nonterms to insert. -- But that can easily lead to error states, and it turns out to be -- not useful, especially if the grammar has been relaxed so most -- expressions and lists can be empty. exception when Bad_Config => null; end Try_Insert_Terminal; procedure Try_Insert_Quote (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use Config_Op_Arrays; use all type Parser.Language_String_ID_Set_Access; Descriptor : WisiToken.Descriptor renames Shared.Trace.Descriptor.all; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; Current_Line : constant Line_Number_Type := Shared.Terminals.all (Config.Current_Shared_Token).Line; Lexer_Error_Token : Base_Token; function Recovered_Lexer_Error (Line : in Line_Number_Type) return Base_Token_Index is begin -- We are assuming the list of lexer errors is short, so binary -- search would not be significantly faster. for Err of reverse Shared.Lexer.Errors loop if Err.Recover_Token /= Invalid_Token_Index and then Shared.Terminals.all (Err.Recover_Token).Line = Line then return Err.Recover_Token; end if; end loop; return Invalid_Token_Index; end Recovered_Lexer_Error; Lexer_Error_Token_Index : constant Base_Token_Index := Recovered_Lexer_Error (Current_Line); function String_ID_Set (String_ID : in Token_ID) return Token_ID_Set is begin if Shared.Language_String_ID_Set = null then return (String_ID .. String_ID => True); else return Shared.Language_String_ID_Set (Descriptor, String_ID); end if; end String_ID_Set; procedure String_Literal_In_Stack (Label : in String; New_Config : in out Configuration; Matching : in SAL.Peek_Type; String_Literal_ID : in Token_ID) is Saved_Shared_Token : constant WisiToken.Token_Index := New_Config.Current_Shared_Token; Tok : Recover_Token; J : WisiToken.Token_Index; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; begin -- Matching is the index of a token on New_Config.Stack containing a string -- literal. Push back thru that token, then delete all tokens after -- the string literal to Saved_Shared_Token. if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Matching)) then Super.Config_Full ("insert quote 1 " & Label, Parser_Index); raise Bad_Config; end if; for I in 1 .. Matching loop if Push_Back_Valid (New_Config) then Tok := New_Config.Stack.Pop.Token; Append (New_Config.Ops, (Push_Back, Tok.ID, Tok.Min_Terminal_Index)); else -- Probably pushing back thru a previously inserted token raise Bad_Config; end if; end loop; New_Config.Current_Shared_Token := Tok.Min_Terminal_Index; -- Find last string literal in pushed back terminals. J := Saved_Shared_Token - 1; loop exit when Shared.Terminals.all (J).ID = String_Literal_ID; J := J - 1; end loop; begin if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => J, All_Conflicts => False, Trace_Prefix => "insert quote parse pushback " & Label) then -- The non-deleted tokens parsed without error. We don't care if any -- conflicts were encountered; we are not using the parse result. New_Config := Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1).Config; Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); else raise SAL.Programmer_Error; end if; exception when Bad_Config => raise SAL.Programmer_Error; end; if New_Config.Current_Shared_Token < Saved_Shared_Token - 1 and then (not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Saved_Shared_Token - 1 - New_Config.Current_Shared_Token))) then Super.Config_Full ("insert quote 2 " & Label, Parser_Index); raise Bad_Config; end if; for J in New_Config.Current_Shared_Token .. Saved_Shared_Token - 1 loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (J).ID, J)); end loop; New_Config.Current_Shared_Token := Saved_Shared_Token; end String_Literal_In_Stack; procedure Push_Back_Tokens (Full_Label : in String; New_Config : in out Configuration; Min_Pushed_Back_Index : out Base_Token_Index) is Item : Recover_Stack_Item; begin loop Item := New_Config.Stack.Peek; if Item.Token.Virtual then -- Don't push back an inserted token exit; elsif Item.Token.Byte_Region = Null_Buffer_Region then -- Don't need push_back for an empty token New_Config.Stack.Pop; elsif Item.Tree_Index = Invalid_Node_Index then -- Item was pushed on stack during recovery, and we do not know -- its Line. To avoid crossing a line boundary, we stop push_backs -- here. exit; else if Shared.Terminals.all (Super.Parser_State (Parser_Index).Tree.First_Shared_Terminal (Item.Tree_Index)).Line = Current_Line -- Don't let push_back cross a line boundary. then if Is_Full (New_Config.Ops) then Super.Config_Full (Full_Label, Parser_Index); raise Bad_Config; else New_Config.Stack.Pop; Append (New_Config.Ops, (Push_Back, Item.Token.ID, Item.Token.Min_Terminal_Index)); end if; end if; exit; end if; end loop; Min_Pushed_Back_Index := Item.Token.Min_Terminal_Index; end Push_Back_Tokens; procedure Finish (Label : in String; New_Config : in out Configuration; First, Last : in Base_Token_Index) is Adj_First : constant Base_Token_Index := (if First = Invalid_Token_Index then Last else First); Adj_Last : constant Base_Token_Index := (if Last = Invalid_Token_Index then First else Last); begin -- Delete tokens First .. Last; either First - 1 or Last + 1 should -- be a String_Literal. Leave Current_Shared_Token at Last + 1. if Adj_Last = Invalid_Token_Index or Adj_First = Invalid_Token_Index then pragma Assert (False); raise Bad_Config; end if; New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); -- This is a guess, so we give it a nominal cost New_Config.Cost := New_Config.Cost + 1; if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Last - First)) then Super.Config_Full ("insert quote 3 " & Label, Parser_Index); raise Bad_Config; end if; for I in Adj_First .. Adj_Last loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (I).ID, I)); end loop; New_Config.Current_Shared_Token := Last + 1; -- Let explore do insert after these deletes. Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "resume_token_goal:" & WisiToken.Token_Index'Image (New_Config.Resume_Token_Goal)); end if; end if; New_Config.Strategy_Counts (String_Quote) := New_Config.Strategy_Counts (String_Quote) + 1; if Trace_McKenzie > Detail then Base.Put ("insert quote " & Label & " ", Super, Shared, Parser_Index, New_Config); end if; end Finish; begin -- When the lexer finds an unbalanced quote, it inserts a virtual -- balancing quote at the same character position as the unbalanced -- quote, returning an empty string literal token there. The parser -- does not see that as an error; it encounters a syntax error -- before, at, or after that string literal. -- -- Here we assume the parse error in Config.Error_Token is due to -- putting the balancing quote in the wrong place (although we do -- check that; see test_mckenzie_recover.adb String_Quote_6), and -- attempt to find a better place to put the balancing quote. Then -- all tokens from the balancing quote to the unbalanced quote are -- now part of a string literal, so delete them, leaving just the -- string literal created by Lexer error recovery. -- First we check to see if there is an unbalanced quote in the -- current line; if not, just return. Some lexer errors are for other -- unrecognized characters; see ada_mode-recover_bad_char.adb. -- -- An alternate strategy is to treat the lexer error as a parse error -- immediately, but that complicates the parse logic. Config.String_Quote_Checked := Current_Line; if Lexer_Error_Token_Index = Invalid_Token_Index then return; end if; Lexer_Error_Token := Shared.Terminals.all (Lexer_Error_Token_Index); -- It is not possible to tell where the best place to put the -- balancing quote is, so we always try all reasonable places. if Lexer_Error_Token.Byte_Region.First = Config.Error_Token.Byte_Region.First then -- The parse error token is the string literal at the lexer error. -- -- case a: Insert the balancing quote somewhere before the error -- point. There is no way to tell how far back to put the balancing -- quote, so we just do one non-empty token. See -- test_mckenzie_recover.adb String_Quote_0. So far we have not found -- a test case for more than one token. declare New_Config : Configuration := Config; Min_Pushed_Back_Index : Base_Token_Index; begin Push_Back_Tokens ("insert quote 4 a", New_Config, Min_Pushed_Back_Index); Finish ("a", New_Config, Min_Pushed_Back_Index, Config.Current_Shared_Token - 1); Local_Config_Heap.Add (New_Config); end; -- Note that it is not reasonable to insert a quote after the error -- in this case. If that were the right solution, the parser error -- token would not be the lexer repaired string literal, since a -- string literal would be legal here. elsif Lexer_Error_Token.Byte_Region.First < Config.Error_Token.Byte_Region.First then -- The unbalanced quote is before the parse error token; see -- test_mckenzie_recover.adb String_Quote_2. -- -- The missing quote belongs after the parse error token, before or -- at the end of the current line; try inserting it at the end of -- the current line. -- -- The lexer repaired string literal may be in a reduced token on the -- stack. declare Matching : SAL.Peek_Type := 1; begin Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- String literal is in a virtual nonterm; give up. So far this only -- happens in a high cost non critical config. if Trace_McKenzie > Detail then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "insert quote b abandon; string literal in virtual"); end if; return; end if; declare New_Config : Configuration := Config; begin String_Literal_In_Stack ("b", New_Config, Matching, Lexer_Error_Token.ID); Finish ("b", New_Config, Config.Current_Shared_Token, Shared.Line_Begin_Token.all (Current_Line + 1) - 1); Local_Config_Heap.Add (New_Config); end; end; else -- The unbalanced quote is after the parse error token. -- case c: Assume a missing quote belongs immediately before the current token. -- See test_mckenzie_recover.adb String_Quote_3. declare New_Config : Configuration := Config; begin Finish ("c", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when Bad_Config => null; end; -- case d: Assume a missing quote belongs somewhere farther before -- the current token; try one non-empty (as in case a above). See -- test_mckenzie_recover.adb String_Quote_4, String_Quote_6. declare New_Config : Configuration := Config; Min_Pushed_Back_Index : Base_Token_Index; begin Push_Back_Tokens ("insert quote 5 d", New_Config, Min_Pushed_Back_Index); Finish ("d", New_Config, Min_Pushed_Back_Index, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when SAL.Container_Empty => -- From Stack.Pop null; when Bad_Config => null; end; -- case e: Assume the actual error is an extra quote that terminates -- an intended string literal early, in which case there is a token -- on the stack containing the string literal that should be extended -- to the found quote. See test_mckenzie_recover.adb String_Quote_1. declare Matching : SAL.Peek_Type := 1; begin -- Lexer_Error_Token is a string literal; find a matching one. Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- No matching string literal, so this case does not apply. null; else declare New_Config : Configuration := Config; begin String_Literal_In_Stack ("e", New_Config, Matching, Lexer_Error_Token.ID); Finish ("e", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index); Local_Config_Heap.Add (New_Config); end; end if; end; end if; exception when Bad_Config => null; end Try_Insert_Quote; procedure Try_Delete_Input (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is -- Try deleting (= skipping) the current shared input token. use Config_Op_Arrays, Config_Op_Array_Refs; Trace : WisiToken.Trace'Class renames Super.Trace.all; EOF_ID : Token_ID renames Trace.Descriptor.EOI_ID; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; ID : constant Token_ID := Shared.Terminals.all (Config.Current_Shared_Token).ID; begin if ID /= EOF_ID and then -- can't delete EOF (Length (Config.Ops) = 0 or else -- Don't delete an ID we just inserted; waste of time (not Equal (Constant_Ref (Config.Ops, Last_Index (Config.Ops)), (Insert, ID, Config.Current_Shared_Token)))) then declare New_Config : Configuration := Config; function Matching_Push_Back return Boolean is begin for I in reverse First_Index (New_Config.Ops) .. Last_Index (New_Config.Ops) loop declare Op : Config_Op renames Config_Op_Array_Refs.Variable_Ref (New_Config.Ops, I).Element.all; begin exit when not (Op.Op in Undo_Reduce | Push_Back | Delete); if Op = (Push_Back, ID, New_Config.Current_Shared_Token) then return True; end if; end; end loop; return False; end Matching_Push_Back; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Cost := New_Config.Cost + McKenzie_Param.Delete (ID); New_Config.Strategy_Counts (Delete) := Config.Strategy_Counts (Delete) + 1; if Matching_Push_Back then -- We are deleting a push_back; cancel the push_back cost, to make -- this the same as plain deleting. New_Config.Cost := Natural'Max (Natural'First, New_Config.Cost - McKenzie_Param.Push_Back (ID)); end if; if Is_Full (New_Config.Ops) then Super.Config_Full ("delete", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Delete, ID, Config.Current_Shared_Token)); end if; New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1; if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; end if; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("delete " & Image (ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Delete_Input; procedure Process_One (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Config_Status : out Base.Config_Status) is -- Get one config from Super, check to see if it is a viable -- solution. If not, enqueue variations to check. use all type Base.Config_Status; use all type Parser.Language_Fixes_Access; use all type Semantic_Checks.Check_Status_Label; Trace : WisiToken.Trace'Class renames Super.Trace.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Parser_Index : SAL.Base_Peek_Type; Config : Configuration; Local_Config_Heap : Config_Heaps.Heap_Type; -- We collect all the variants to enqueue, then deliver them all at -- once to Super, to minimizes task interactions. begin Super.Get (Parser_Index, Config, Config_Status); if Config_Status = All_Done then return; end if; if Trace_McKenzie > Detail then Base.Put ("dequeue", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Fast_Forward; parse Insert, Delete in Config.Ops that have not -- been parsed yet. 'parse' here means adjusting Config.Stack and -- Current_Terminal_Index. Code in this file always parses when -- adding ops to Config (except as noted); Language_Fixes should use -- McKenzie_Recover.Insert, Delete instead. if Config.Current_Insert_Delete = 1 then -- Config is from Language_Fixes. Fast_Forward (Super, Shared, Parser_Index, Local_Config_Heap, Config); Super.Put (Parser_Index, Local_Config_Heap); return; end if; pragma Assert (Config.Current_Insert_Delete = 0); -- Config.Current_Insert_Delete > 1 is a programming error. if Config.Error_Token.ID /= Invalid_Token_ID then if Shared.Language_Fixes = null then null; else Shared.Language_Fixes (Trace, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); -- The solutions enqueued by Language_Fixes should be lower cost than -- others (typically 0), so they will be checked first. end if; if Config.Check_Status.Label = Ok then -- Parse table Error action. -- -- We don't clear Config.Error_Token here, because -- Language_Use_Minimal_Complete_Actions needs it. We only clear it -- when a parse results in no error (or a different error), or a -- push_back moves the Current_Token. null; else -- Assume "ignore check error" is a viable solution. But give it a -- cost, so a solution provided by Language_Fixes is preferred. declare New_State : Unknown_State_Index; begin Config.Cost := Config.Cost + Table.McKenzie_Param.Ignore_Check_Fail; Config.Strategy_Counts (Ignore_Error) := Config.Strategy_Counts (Ignore_Error) + 1; -- finish reduce. Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); New_State := Goto_For (Table, Config.Stack.Peek.State, Config.Error_Token.ID); if New_State = Unknown_State then if Config.Stack.Depth = 1 then -- Stack is empty, and we did not get Accept; really bad syntax got -- us here; abandon this config. See ada_mode-recover_bad_char.adb. Super.Put (Parser_Index, Local_Config_Heap); return; else raise SAL.Programmer_Error with "process_one found test case for new_state = Unknown; old state " & Trimmed_Image (Config.Stack.Peek.State) & " nonterm " & Image (Config.Error_Token.ID, Trace.Descriptor.all); end if; end if; Config.Stack.Push ((New_State, Invalid_Node_Index, Config.Error_Token)); -- We _don't_ clear Check_Status and Error_Token here; Check needs -- them, and sets them as appropriate. end; end if; end if; -- Call Check to see if this config succeeds. case Check (Super, Shared, Parser_Index, Config, Local_Config_Heap) is when Success => Super.Success (Parser_Index, Config, Local_Config_Heap); return; when Abandon => Super.Put (Parser_Index, Local_Config_Heap); return; when Continue => null; end case; if Trace_McKenzie > Detail then Base.Put ("continuing", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Grouping these operations (push_back, delete, insert) ensures that -- there are no duplicate solutions found. We reset the grouping -- after each fast_forward. -- -- We do delete before insert so Insert_Matching_Begin can operate on -- the new next token, before Fast_Forwarding past it. -- -- All possible permutations will be explored. pragma Assert (Config.Stack.Depth > 0); Try_Insert_Terminal (Super, Shared, Parser_Index, Config, Local_Config_Heap); if Push_Back_Valid (Config) and then (not Check_Reduce_To_Start (Super, Shared, Parser_Index, Config)) -- If Config reduces to the start nonterm, there's no point in Push_Back or Undo_Reduce. then Try_Push_Back (Super, Shared, Parser_Index, Config, Local_Config_Heap); if Undo_Reduce_Valid (Config.Stack, Super.Parser_State (Parser_Index).Tree) then Try_Undo_Reduce (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; end if; if None_Since_FF (Config.Ops, Insert) then Try_Delete_Input (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; -- This is run once per input line, independent of what other ops -- have been done. if Config.Check_Status.Label = Ok and (Descriptor.String_1_ID /= Invalid_Token_ID or Descriptor.String_2_ID /= Invalid_Token_ID) and (Config.String_Quote_Checked = Invalid_Line_Number or else Config.String_Quote_Checked < Shared.Terminals.all (Config.Current_Shared_Token).Line) then -- See if there is a mismatched quote. The solution is to delete -- tokens, nominally replacing them with an expanded string literal. -- So we try this when it is ok to try delete. if None_Since_FF (Config.Ops, Insert) then Try_Insert_Quote (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; end if; Super.Put (Parser_Index, Local_Config_Heap); exception when Bad_Config => -- Just abandon this config; tell Super we are done. Super.Put (Parser_Index, Local_Config_Heap); when E : others => Super.Put (Parser_Index, Local_Config_Heap); if Debug_Mode then raise; elsif Trace_McKenzie > Outline then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Process_One: unhandled exception " & Ada.Exceptions.Exception_Name (E) & ": " & Ada.Exceptions.Exception_Message (E)); end if; end Process_One; end WisiToken.Parse.LR.McKenzie_Recover.Explore;
drivers/drivers-rfm69.adb
ekoeppen/MSP430_Generic_Ada_Drivers
0
13241
with System; with Utils; use Utils; package body Drivers.RFM69 is package IRQHandler is new HAL.Pin_IRQ (Pin => IRQ); F_Osc : constant Unsigned_32 := 32_000_000; type Unsigned_2 is mod 2 ** 2; type Unsigned_3 is mod 2 ** 3; type Unsigned_5 is mod 2 ** 5; type Unsigned_7 is mod 2 ** 7; type Register_Type is ( FIFO, OPMODE, DATAMODUL, BITRATEMSB, BITRATELSB, FDEVMSB, FDEVLSB, FRFMSB, FRFMID, FRFLSB, OSC1, AFCCTRL, LOWBAT, LISTEN1, LISTEN2, LISTEN3, VERSION, PALEVEL, PARAMP, OCP, AGCREF, AGCTHRESH1, AGCTHRESH2, AGCTHRESH3, LNA, RXBW, AFCBW, OOKPEAK, OOKAVG, OOKFIX, AFCFEI, AFCMSB, AFCLSB, FEIMSB, FEILSB, RSSICONFIG, RSSIVALUE, DIOMAPPING1, DIOMAPPING2, IRQFLAGS1, IRQFLAGS2, RSSITHRESH, RXTIMEOUT1, RXTIMEOUT2, PREAMBLEMSB, PREAMBLELSB, SYNCCONFIG, SYNCVALUE1, SYNCVALUE2, SYNCVALUE3, SYNCVALUE4, SYNCVALUE5, SYNCVALUE6, SYNCVALUE7, SYNCVALUE8, PACKETCONFIG1, PAYLOADLENGTH, NODEADRS, BROADCASTADRS, AUTOMODES, FIFOTHRESH, PACKETCONFIG2, AESKEY1, AESKEY2, AESKEY3, AESKEY4, AESKEY5, AESKEY6, AESKEY7, AESKEY8, AESKEY9, AESKEY10, AESKEY11, AESKEY12, AESKEY13, AESKEY14, AESKEY15, AESKEY16, TEMP1, TEMP2); for Register_Type use ( FIFO => 16#00#, OPMODE => 16#01#, DATAMODUL => 16#02#, BITRATEMSB => 16#03#, BITRATELSB => 16#04#, FDEVMSB => 16#05#, FDEVLSB => 16#06#, FRFMSB => 16#07#, FRFMID => 16#08#, FRFLSB => 16#09#, OSC1 => 16#0A#, AFCCTRL => 16#0B#, LOWBAT => 16#0C#, LISTEN1 => 16#0D#, LISTEN2 => 16#0E#, LISTEN3 => 16#0F#, VERSION => 16#10#, PALEVEL => 16#11#, PARAMP => 16#12#, OCP => 16#13#, AGCREF => 16#14#, AGCTHRESH1 => 16#15#, AGCTHRESH2 => 16#16#, AGCTHRESH3 => 16#17#, LNA => 16#18#, RXBW => 16#19#, AFCBW => 16#1A#, OOKPEAK => 16#1B#, OOKAVG => 16#1C#, OOKFIX => 16#1D#, AFCFEI => 16#1E#, AFCMSB => 16#1F#, AFCLSB => 16#20#, FEIMSB => 16#21#, FEILSB => 16#22#, RSSICONFIG => 16#23#, RSSIVALUE => 16#24#, DIOMAPPING1 => 16#25#, DIOMAPPING2 => 16#26#, IRQFLAGS1 => 16#27#, IRQFLAGS2 => 16#28#, RSSITHRESH => 16#29#, RXTIMEOUT1 => 16#2A#, RXTIMEOUT2 => 16#2B#, PREAMBLEMSB => 16#2C#, PREAMBLELSB => 16#2D#, SYNCCONFIG => 16#2E#, SYNCVALUE1 => 16#2F#, SYNCVALUE2 => 16#30#, SYNCVALUE3 => 16#31#, SYNCVALUE4 => 16#32#, SYNCVALUE5 => 16#33#, SYNCVALUE6 => 16#34#, SYNCVALUE7 => 16#35#, SYNCVALUE8 => 16#36#, PACKETCONFIG1 => 16#37#, PAYLOADLENGTH => 16#38#, NODEADRS => 16#39#, BROADCASTADRS => 16#3A#, AUTOMODES => 16#3B#, FIFOTHRESH => 16#3C#, PACKETCONFIG2 => 16#3D#, AESKEY1 => 16#3E#, AESKEY2 => 16#3F#, AESKEY3 => 16#40#, AESKEY4 => 16#41#, AESKEY5 => 16#42#, AESKEY6 => 16#43#, AESKEY7 => 16#44#, AESKEY8 => 16#45#, AESKEY9 => 16#46#, AESKEY10 => 16#47#, AESKEY11 => 16#48#, AESKEY12 => 16#49#, AESKEY13 => 16#4A#, AESKEY14 => 16#4B#, AESKEY15 => 16#4C#, AESKEY16 => 16#4D#, TEMP1 => 16#4E#, TEMP2 => 16#4F#); type OPMODE_Mode_Type is (SLEEP, STDBY, FS, TX, RX) with Size => 3; for OPMODE_Mode_Type use ( SLEEP => 2#000#, STDBY => 2#001#, FS => 2#010#, TX => 2#011#, RX => 2#100#); type Command_Type is (R_REGISTER, W_REGISTER); for Command_Type use ( R_REGISTER => 2#0000_0000#, W_REGISTER => 2#1000_0000#); type OPMODE_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Sequencer_Off : Boolean; Listen_On : Boolean; Listen_Abort : Boolean; Mode : OPMODE_Mode_Type; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for OPMODE_Register_Type use record Val at 0 range 0 .. 7; Sequencer_Off at 0 range 7 .. 7; Listen_On at 0 range 6 .. 6; Listen_Abort at 0 range 5 .. 5; Mode at 0 range 2 .. 4; end record; subtype DIO_Mapping_Type is Unsigned_2; type DIOMAPPING1_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => DIO0_Mapping : DIO_Mapping_Type; DIO1_Mapping : DIO_Mapping_Type; DIO2_Mapping : DIO_Mapping_Type; DIO3_Mapping : DIO_Mapping_Type; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for DIOMAPPING1_Register_Type use record DIO0_Mapping at 0 range 6 .. 7; DIO1_Mapping at 0 range 4 .. 5; DIO2_Mapping at 0 range 2 .. 3; DIO3_Mapping at 0 range 0 .. 1; end record; type IRQFLAGS1_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Mode_Ready : Boolean; Rx_Ready : Boolean; Tx_Ready : Boolean; PLL_Lock : Boolean; RSSI : Boolean; Timeout : Boolean; Auto_Mode : Boolean; Sync_Address_Match : Boolean; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for IRQFLAGS1_Register_Type use record Mode_Ready at 0 range 7 .. 7; Rx_Ready at 0 range 6 .. 6; Tx_Ready at 0 range 5 .. 5; PLL_Lock at 0 range 4 .. 4; RSSI at 0 range 3 .. 3; Timeout at 0 range 2 .. 2; Auto_Mode at 0 range 1 .. 1; Sync_Address_Match at 0 range 0 .. 0; end record; type IRQFLAGS2_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => FIFO_Full : Boolean; FIFO_Not_Emtpy : Boolean; FIFO_Level : Boolean; FIFO_Overrun : Boolean; Packet_Sent : Boolean; Payload_Ready : Boolean; CRC_Ok : Boolean; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for IRQFLAGS2_Register_Type use record FIFO_Full at 0 range 7 .. 7; FIFO_Not_Emtpy at 0 range 6 .. 6; FIFO_Level at 0 range 5 .. 5; FIFO_Overrun at 0 range 4 .. 4; Packet_Sent at 0 range 3 .. 3; Payload_Ready at 0 range 2 .. 2; CRC_Ok at 0 range 1 .. 1; end record; type SYNCCONFIG_FIFO_Fill_Condition_Type is (Sync_Address, Always) with Size => 1; for SYNCCONFIG_FIFO_Fill_Condition_Type use (Sync_Address => 2#0#, Always => 2#1#); type SYNCCONFIG_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Sync_On : Boolean; FIFO_Fill_Condition : SYNCCONFIG_FIFO_Fill_Condition_Type; Sync_Size : Unsigned_3; Sync_Tol : Unsigned_3; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for SYNCCONFIG_Register_Type use record Sync_On at 0 range 7 .. 7; FIFO_Fill_Condition at 0 range 6 .. 6; Sync_Size at 0 range 3 .. 5; Sync_Tol at 0 range 0 .. 2; end record; type DATAMODUL_Data_Mode_Type is (Packet_Mode, Continuous_Synchronizer, Continuous_No_Synchronizer) with Size => 2; for DATAMODUL_Data_Mode_Type use ( Packet_Mode => 2#00#, Continuous_Synchronizer => 2#10#, Continuous_No_Synchronizer => 2#11#); type DATAMODUL_Modulation_Type is (FSK, OOK) with Size => 2; for DATAMODUL_Modulation_Type use ( FSK => 2#00#, OOK => 2#01#); type DATAMODUL_Modulation_Shaping is (No_Shaping, Shaping_1, Shaping_2, Shaping_3); for DATAMODUL_Modulation_Shaping use ( No_Shaping => 0, Shaping_1 => 1, Shaping_2 => 2, Shaping_3 => 3); type DATAMODUL_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Data_Mode : DATAMODUL_Data_Mode_Type; Modulation_Type : DATAMODUL_Modulation_Type; Modulation_Shaping : DATAMODUL_Modulation_Shaping; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for DATAMODUL_Register_Type use record Data_Mode at 0 range 5 .. 6; Modulation_Type at 0 range 3 .. 4; Modulation_Shaping at 0 range 0 .. 2; end record; type FIFOTHRESH_Start_Condition_Type is (FIFO_Level, FIFO_Not_Empty); for FIFOTHRESH_Start_Condition_Type use ( FIFO_Level => 2#0#, FIFO_Not_Empty => 2#1#); type FIFOTHRESH_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Start_Condition : FIFOTHRESH_Start_Condition_Type; FIFO_Threshold : Unsigned_7; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for FIFOTHRESH_Register_Type use record Start_Condition at 0 range 7 .. 7; FIFO_Threshold at 0 range 0 .. 6; end record; type RXBW_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => DCC_Freq : Unsigned_3; RX_BW_Mant : Unsigned_2; RX_BW_Exp : Unsigned_3; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for RXBW_Register_Type use record DCC_Freq at 0 range 5 .. 7; RX_BW_Mant at 0 range 3 .. 4; RX_BW_Exp at 0 range 0 .. 2; end record; type PALEVEL_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => PA0_On : Boolean; PA1_On : Boolean; PA2_On : Boolean; Output_Power : Unsigned_5; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for PALEVEL_Register_Type use record PA0_On at 0 range 7 .. 7; PA1_On at 0 range 6 .. 6; PA2_On at 0 range 5 .. 5; Output_Power at 0 range 0 .. 4; end record; type AFCBW_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => DCC_Freq_AFC : Unsigned_3; RX_BW_Mant_AFC : Unsigned_2; RX_BW_Exp_AFC : Unsigned_3; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for AFCBW_Register_Type use record DCC_Freq_AFC at 0 range 5 .. 7; RX_BW_Mant_AFC at 0 range 3 .. 4; RX_BW_Exp_AFC at 0 range 0 .. 2; end record; type PACKETCONFIG1_Packet_Format_Type is (Fixed_Length, Variable_Length) with Size => 1; for PACKETCONFIG1_Packet_Format_Type use ( Fixed_Length => 2#0#, Variable_Length => 2#1#); type PACKETCONFIG1_DC_Free_Type is (None, Manchester, Whitening) with Size => 2; for PACKETCONFIG1_DC_Free_Type use ( None => 2#00#, Manchester => 2#01#, Whitening => 2#10#); type PACKETCONFIG1_Address_Filtering_Type is (None, Node_Address, Node_or_Broadcast_Address) with Size => 2; for PACKETCONFIG1_Address_Filtering_Type use ( None => 2#00#, Node_Address => 2#01#, Node_or_Broadcast_Address => 2#10#); type PACKETCONFIG1_Register_Type (As_Value : Boolean := False) is record case As_Value is when True => Val : Unsigned_8; when False => Packet_Format : PACKETCONFIG1_Packet_Format_Type; DC_Free : PACKETCONFIG1_DC_Free_Type; CRC_On : Boolean; CRC_Auto_Clear_Off : Boolean; Address_Filtering : PACKETCONFIG1_Address_Filtering_Type; end case; end record with Unchecked_Union, Size => 8, Bit_Order => System.Low_Order_First; for PACKETCONFIG1_Register_Type use record Packet_Format at 0 range 7 .. 7; DC_Free at 0 range 5 .. 6; CRC_On at 0 range 4 .. 4; CRC_Auto_Clear_Off at 0 range 3 .. 3; Address_Filtering at 0 range 1 .. 2; end record; OPMODE_Init : constant OPMODE_Register_Type := ( Mode => STDBY, others => False); SYNCCONFIG_Init : constant SYNCCONFIG_Register_Type := ( As_Value => False, Sync_On => True, FIFO_Fill_Condition => Sync_Address, Sync_Size => 3, Sync_Tol => 0); PACKETCONFIG1_Init : constant PACKETCONFIG1_Register_Type := ( As_Value => False, Packet_Format => Variable_Length, DC_Free => None, CRC_On => True, CRC_Auto_Clear_Off => False, Address_Filtering => None); DATAMODUL_Init : constant DATAMODUL_Register_Type := ( As_Value => False, Data_Mode => Packet_Mode, Modulation_Type => FSK, Modulation_Shaping => No_Shaping); RXBW_Init : constant RXBW_Register_Type := ( As_Value => False, DCC_Freq => 2, RX_BW_Mant => 0, RX_BW_Exp => 2); AFCBW_Init : constant AFCBW_Register_Type := ( As_Value => False, DCC_Freq_AFC => 2, RX_BW_Mant_AFC => 0, RX_BW_Exp_AFC => 2); RSSITHRESH_Init : constant Unsigned_8 := 100 * 2; SYNCVALUE1_Init : constant Unsigned_8 := 16#F0#; SYNCVALUE2_Init : constant Unsigned_8 := 16#12#; SYNCVALUE3_Init : constant Unsigned_8 := 16#78#; PREAMBLELSB_Init : constant Unsigned_8 := 6; FDEVMSB_Init : constant Unsigned_8 := 195; FDEVLSB_Init : constant Unsigned_8 := 5; procedure Write_Register (Register : Register_Type; Value : Unsigned_8); procedure Read_Register (Register : Register_Type; Value : out Unsigned_8); function Read_Register (Register : Register_Type) return Unsigned_8; procedure Set_Mode (Mode : OPMODE_Mode_Type); procedure Write_Register (Register : Register_Type; Value : Unsigned_8) is begin Chip_Select.Clear; SPI.Send (Register'Enum_Rep + W_REGISTER'Enum_Rep); SPI.Send (Value); Chip_Select.Set; end Write_Register; procedure Read_Register (Register : Register_Type; Value : out Unsigned_8) is begin Chip_Select.Clear; SPI.Send (Register'Enum_Rep + R_REGISTER'Enum_Rep); SPI.Receive (Value); Chip_Select.Set; end Read_Register; function Read_Register (Register : Register_Type) return Unsigned_8 is Value : Unsigned_8; begin Chip_Select.Clear; SPI.Send (Register'Enum_Rep + R_REGISTER'Enum_Rep); SPI.Receive (Value); Chip_Select.Set; return Value; end Read_Register; procedure Read_Registers (Registers : out Raw_Register_Array) is begin for R in Register_Type loop Read_Register(R, Registers (R'Enum_Rep)); end loop; end Read_Registers; procedure Print_Registers is begin Put_Line ( "Version: " & To_Hex_String (Read_Register (VERSION)) & " OpMode: " & To_Hex_String (Read_Register (OPMODE)) & " IrqFlags: " & To_Hex_String (Read_Register (IRQFLAGS1)) & " " & To_Hex_String (Read_Register (IRQFLAGS2)) & " PacketConfig: " & To_Hex_String (Read_Register (PACKETCONFIG1)) & " " & To_Hex_String (Read_Register (PACKETCONFIG2)) & " PayloadLength: " & To_Hex_String (Read_Register (PAYLOADLENGTH))); Put_Line ( "FifoThresh: " & To_Hex_String (Read_Register (FIFOTHRESH)) & " RSSIConfig: " & To_Hex_String (Read_Register (RSSICONFIG)) & " RSSIValue: " & To_Hex_String (Read_Register (RSSIVALUE)) & " SyncConfig: " & To_Hex_String (Read_Register (SYNCCONFIG)) & " DataModul: " & To_Hex_String (Read_Register (DATAMODUL)) & " PaLevel: " & To_Hex_String (Read_Register (PALEVEL)) & " Frequency: " & To_Hex_String (Read_Register (FRFMSB)) & To_Hex_String (Read_Register (FRFMID)) & To_Hex_String (Read_Register (FRFLSB)) & " Bitrate: " & To_Hex_String (Read_Register (BITRATEMSB)) & " " & To_Hex_String (Read_Register (BITRATELSB)) ); end Print_Registers; procedure Init is FIFOTHRESH_Init : constant FIFOTHRESH_Register_Type := ( As_Value => False, Start_Condition => FIFO_Not_Empty, FIFO_Threshold => Unsigned_7 (Packet_Size / 2)); begin Write_Register (OPMODE, OPMODE_Init.Val); Write_Register (FIFOTHRESH, FIFOTHRESH_Init.Val); Write_Register (PACKETCONFIG1, PACKETCONFIG1_Init.Val); Write_Register (RSSITHRESH, RSSITHRESH_Init); Write_Register (SYNCCONFIG, SYNCCONFIG_Init.Val); Write_Register (SYNCVALUE1, SYNCVALUE1_Init); Write_Register (SYNCVALUE2, SYNCVALUE2_Init); Write_Register (SYNCVALUE3, SYNCVALUE3_Init); Write_Register (PREAMBLELSB, PREAMBLELSB_Init); Write_Register (DATAMODUL, DATAMODUL_Init.Val); Write_Register (FDEVMSB, FDEVMSB_Init); Write_Register (FDEVLSB, FDEVLSB_Init); Write_Register (RXBW, RXBW_Init.Val); Write_Register (AFCBW, AFCBW_Init.Val); Set_Frequency (Frequency); IRQHandler.Configure_Trigger (Falling => True); end Init; procedure Set_Sync_Word (Sync_Word : Sync_Word_Type) is begin null; end Set_Sync_Word; procedure Set_Frequency (Frequency : Unsigned_32) is F : Unsigned_32; begin F := (Frequency / 1_000_000) * (2 ** 19) / (F_Osc / 1_000_000); Chip_Select.Clear; SPI.Send (FRFMSB'Enum_Rep + W_REGISTER'Enum_Rep); SPI.Send (Unsigned_8 ((F / (2 ** 16)) mod 2 ** 8)); SPI.Send (Unsigned_8 ((F / (2 ** 8)) mod 2 ** 8)); SPI.Send (Unsigned_8 (F mod 2 ** 8)); Chip_Select.Set; end Set_Frequency; procedure Set_Bitrate (Bitrate : Unsigned_32) is B : Unsigned_32; begin B := F_Osc / Bitrate; Chip_Select.Clear; SPI.Send (BITRATEMSB'Enum_Rep + W_REGISTER'Enum_Rep); SPI.Send (Unsigned_8 ((B / (2 ** 8)) mod 2 ** 8)); SPI.Send (Unsigned_8 (B mod 2 ** 8)); Chip_Select.Set; end Set_Bitrate; procedure Set_Broadcast_Address (Address : Address_Type) is begin null; end Set_Broadcast_Address; procedure Set_RX_Address (Address : Address_Type) is begin null; end Set_RX_Address; procedure Set_TX_Address (Address : Address_Type) is begin null; end Set_TX_Address; procedure Set_Mode (Mode : OPMODE_Mode_Type) is M : OPMODE_Register_Type; F : IRQFLAGS1_Register_Type; R : Unsigned_8; begin Read_Register (OPMODE, R); M.Val := R; M.Mode := Mode; Write_Register (OPMODE, M.Val); loop Read_Register (IRQFLAGS1, R); F.Val := R; exit when F.Mode_Ready; end loop; end Set_Mode; procedure Set_Output_Power (Power : Output_Power_Type) is P : PALEVEL_Register_Type; R : Unsigned_8; begin Read_Register (PALEVEL, R); P.Val := R; P.Output_Power := Unsigned_5 (Power + 18); Write_Register (PALEVEL, P.Val); end Set_Output_Power; procedure TX_Mode is begin Set_Mode (TX); end TX_Mode; procedure RX_Mode is begin Set_Mode (RX); Write_Register (IRQFLAGS1, 2#0000_1001#); end RX_Mode; procedure TX (Packet: Packet_Type) is begin TX (Packet, Packet'Length); end TX; procedure TX (Packet: Packet_Type; Length: Unsigned_8) is Wait : Unsigned_32; begin Set_Mode (TX); Chip_Select.Clear; SPI.Send (FIFO'Enum_Rep + W_REGISTER'Enum_Rep); SPI.Send (Length); for I in 0 .. Length - 1 loop SPI.Send (Packet (I + Packet'First)); end loop; Chip_Select.Set; Wait := 100000; while not TX_Complete and Wait > 0 loop Wait := Wait - 1; end loop; Set_Mode (STDBY); end TX; function TX_Complete return Boolean is Flags : IRQFLAGS2_Register_Type; F : Unsigned_8; begin Read_Register (IRQFLAGS2, F); Flags.Val := F; return Flags.Packet_Sent; end TX_Complete; function RX_Available_Reg return Boolean is Flags : IRQFLAGS2_Register_Type; F : Unsigned_8; begin Read_Register (IRQFLAGS2, F); Flags.Val := F; return Flags.Payload_Ready; end RX_Available_Reg; function RX_Available return Boolean is begin return IRQ.Is_Set; end RX_Available; function Wait_For_RX return Boolean is begin loop exit when RX_Available; end loop; return True; end Wait_For_RX; procedure RX (Packet : out Packet_Type; Length : out Unsigned_8) is L : Unsigned_8; begin Chip_Select.Clear; SPI.Send (FIFO'Enum_Rep + R_REGISTER'Enum_Rep); SPI.Receive (L); for I in 0 .. L - 1 loop exit when I = Packet'Length; SPI.Receive (Packet (I + Packet'First)); end loop; Chip_Select.Set; Length := L; end RX; procedure Power_Down is begin Set_Mode (SLEEP); end Power_Down; procedure Cancel is begin IRQHandler.Cancel_Wait; end Cancel; end Drivers.RFM69;
awa/plugins/awa-tags/src/awa-tags-beans.ads
fuzzysloth/ada-awa
0
8698
----------------------------------------------------------------------- -- awa-tags-beans -- Beans for the tags module -- Copyright (C) 2013 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Containers.Hashed_Maps; with Ada.Containers.Ordered_Sets; with Ada.Finalization; with Util.Beans.Basic; with Util.Beans.Objects.Lists; with Util.Beans.Lists.Strings; with Util.Strings.Vectors; with ADO; with ADO.Utils; with ADO.Schemas; with ADO.Sessions; with AWA.Tags.Models; with AWA.Tags.Modules; -- == Tag Beans == -- Several bean types are provided to represent and manage a list of tags. -- The tag module registers the bean constructors when it is initialized. -- To use them, one must declare a bean definition in the application XML configuration. -- -- === Tag_List_Bean === -- The <tt>Tag_List_Bean</tt> holds a list of tags and provides operations used by the -- <tt>awa:tagList</tt> component to add or remove tags within a <tt>h:form</tt> component. -- A bean can be declared and configured as follows in the XML application configuration file: -- -- <managed-bean> -- <managed-bean-name>questionTags</managed-bean-name> -- <managed-bean-class>AWA.Tags.Beans.Tag_List_Bean</managed-bean-class> -- <managed-bean-scope>request</managed-bean-scope> -- <managed-property> -- <property-name>entity_type</property-name> -- <property-class>String</property-class> -- <value>awa_question</value> -- </managed-property> -- <managed-property> -- <property-name>permission</property-name> -- <property-class>String</property-class> -- <value>question-edit</value> -- </managed-property> -- </managed-bean> -- -- The <tt>entity_type</tt> property defines the name of the database table to which the tags -- are assigned. The <tt>permission</tt> property defines the permission name that must be used -- to verify that the user has the permission do add or remove the tag. Such permission is -- verified only when the <tt>awa:tagList</tt> component is used within a form. -- -- === Tag_Search_Bean === -- The <tt>Tag_Search_Bean</tt> is dedicated to searching for tags that start with a given -- pattern. The auto complete feature of the <tt>awa:tagList</tt> component can use this -- bean type to look in the database for tags matching a start pattern. The declaration of the -- bean should define the database table to search for tags associated with a given database -- table. This is done in the XML configuration with the <tt>entity_type</tt> property. -- -- <managed-bean> -- <managed-bean-name>questionTagSearch</managed-bean-name> -- <managed-bean-class>AWA.Tags.Beans.Tag_Search_Bean</managed-bean-class> -- <managed-bean-scope>request</managed-bean-scope> -- <managed-property> -- <property-name>entity_type</property-name> -- <property-class>String</property-class> -- <value>awa_question</value> -- </managed-property> -- </managed-bean> -- -- === Tag_Info_List_Bean === -- The <tt>Tag_Info_List_Bean</tt> holds a collection of tags with their weight. It is used -- by the <tt>awa:tagCloud</tt> component. -- -- <managed-bean> -- <managed-bean-name>questionTagList</managed-bean-name> -- <managed-bean-class>AWA.Tags.Beans.Tag_Info_List_Bean</managed-bean-class> -- <managed-bean-scope>request</managed-bean-scope> -- <managed-property> -- <property-name>entity_type</property-name> -- <property-class>String</property-class> -- <value>awa_question</value> -- </managed-property> -- </managed-bean> -- package AWA.Tags.Beans is -- Compare two tags on their count and name. function "<" (Left, Right : in AWA.Tags.Models.Tag_Info) return Boolean; package Tag_Ordered_Sets is new Ada.Containers.Ordered_Sets (Element_Type => AWA.Tags.Models.Tag_Info, "=" => AWA.Tags.Models."="); type Tag_List_Bean is new Util.Beans.Objects.Lists.List_Bean and Util.Beans.Basic.Bean with private; type Tag_List_Bean_Access is access all Tag_List_Bean'Class; -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. overriding procedure Set_Value (From : in out Tag_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Set the entity type (database table) onto which the tags are associated. procedure Set_Entity_Type (Into : in out Tag_List_Bean; Table : in ADO.Schemas.Class_Mapping_Access); -- Set the permission to check before removing or adding a tag on the entity. procedure Set_Permission (Into : in out Tag_List_Bean; Permission : in String); -- Load the tags associated with the given database identifier. procedure Load_Tags (Into : in out Tag_List_Bean; Session : in ADO.Sessions.Session; For_Entity_Id : in ADO.Identifier); -- Set the list of tags to add. procedure Set_Added (Into : in out Tag_List_Bean; Tags : in Util.Strings.Vectors.Vector); -- Set the list of tags to remove. procedure Set_Deleted (Into : in out Tag_List_Bean; Tags : in Util.Strings.Vectors.Vector); -- Update the tags associated with the tag entity represented by <tt>For_Entity_Id</tt>. -- The list of tags defined by <tt>Set_Deleted</tt> are removed first and the list of -- tags defined by <tt>Set_Added</tt> are associated with the database entity. procedure Update_Tags (From : in Tag_List_Bean; For_Entity_Id : in ADO.Identifier); -- Create the tag list bean instance. function Create_Tag_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; type Tag_Search_Bean is new Util.Beans.Objects.Lists.List_Bean and Util.Beans.Basic.Bean with private; type Tag_Search_Bean_Access is access all Tag_Search_Bean'Class; -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. overriding procedure Set_Value (From : in out Tag_Search_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Search the tags that match the search string. procedure Search_Tags (Into : in out Tag_Search_Bean; Session : in ADO.Sessions.Session; Search : in String); -- Set the entity type (database table) onto which the tags are associated. procedure Set_Entity_Type (Into : in out Tag_Search_Bean; Table : in ADO.Schemas.Class_Mapping_Access); -- Create the tag search bean instance. function Create_Tag_Search_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; type Tag_Info_List_Bean is new AWA.Tags.Models.Tag_Info_List_Bean and Util.Beans.Basic.Bean with private; type Tag_Info_List_Bean_Access is access all Tag_Info_List_Bean'Class; -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. overriding procedure Set_Value (From : in out Tag_Info_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Load the list of tags. procedure Load_Tags (Into : in out Tag_Info_List_Bean; Session : in out ADO.Sessions.Session); -- Create the tag info list bean instance. function Create_Tag_Info_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; -- The <tt>Entity_Tag_Map</tt> contains a list of tags associated with some entities. -- It allows to retrieve from the database all the tags associated with several entities -- and get the list of tags for a given entity. type Entity_Tag_Map is new Ada.Finalization.Limited_Controlled with private; -- Get the list of tags associated with the given entity. -- Returns null if the entity does not have any tag. function Get_Tags (From : in Entity_Tag_Map; For_Entity : in ADO.Identifier) return Util.Beans.Lists.Strings.List_Bean_Access; -- Get the list of tags associated with the given entity. -- Returns a null object if the entity does not have any tag. function Get_Tags (From : in Entity_Tag_Map; For_Entity : in ADO.Identifier) return Util.Beans.Objects.Object; -- Release the list of tags. procedure Clear (List : in out Entity_Tag_Map); -- Load the list of tags associated with a list of entities. procedure Load_Tags (Into : in out Entity_Tag_Map; Session : in out ADO.Sessions.Session'Class; Entity_Type : in String; List : in ADO.Utils.Identifier_Vector); -- Release the list of tags. overriding procedure Finalize (List : in out Entity_Tag_Map); private type Tag_List_Bean is new Util.Beans.Objects.Lists.List_Bean and Util.Beans.Basic.Bean with record Module : AWA.Tags.Modules.Tag_Module_Access; Entity_Type : Ada.Strings.Unbounded.Unbounded_String; Permission : Ada.Strings.Unbounded.Unbounded_String; Current : Natural := 0; Added : Util.Strings.Vectors.Vector; Deleted : Util.Strings.Vectors.Vector; end record; type Tag_Search_Bean is new Util.Beans.Objects.Lists.List_Bean and Util.Beans.Basic.Bean with record Module : AWA.Tags.Modules.Tag_Module_Access; Entity_Type : Ada.Strings.Unbounded.Unbounded_String; end record; type Tag_Info_List_Bean is new AWA.Tags.Models.Tag_Info_List_Bean and Util.Beans.Basic.Bean with record Module : AWA.Tags.Modules.Tag_Module_Access; Entity_Type : Ada.Strings.Unbounded.Unbounded_String; end record; package Entity_Tag_Maps is new Ada.Containers.Hashed_Maps (Key_Type => ADO.Identifier, Element_Type => Util.Beans.Lists.Strings.List_Bean_Access, Hash => ADO.Utils.Hash, Equivalent_Keys => ADO."=", "=" => Util.Beans.Lists.Strings."="); type Entity_Tag_Map is new Ada.Finalization.Limited_Controlled with record Tags : Entity_Tag_Maps.Map; end record; end AWA.Tags.Beans;
oeis/075/A075870.asm
neoneye/loda-programs
11
246182
; A075870: Numbers k such that 2*k^2 - 4 is a square. ; 2,10,58,338,1970,11482,66922,390050,2273378,13250218,77227930,450117362,2623476242,15290740090,89120964298,519435045698,3027489309890,17645500813642,102845515571962,599427592618130,3493720040136818,20362892648202778,118683635849079850,691738922446276322,4031749898828578082,23498760470525192170,136960812924322574938,798266117075410257458,4652635889528138969810,27117549220093423561402,158052659431032402398602,921198407366100990830210,5369137784765573542582658,31293628301227340264665738 mov $1,2 mov $2,1 lpb $0 sub $0,1 add $1,$2 add $2,$1 add $2,$1 add $1,$2 lpe mov $0,$1
programs/oeis/047/A047927.asm
neoneye/loda
22
241186
; A047927: a(n) = n*(n-1)*(n-2)^2. ; 0,6,48,180,480,1050,2016,3528,5760,8910,13200,18876,26208,35490,47040,61200,78336,98838,123120,151620,184800,223146,267168,317400,374400,438750,511056,591948,682080,782130,892800,1014816,1148928,1295910,1456560,1631700,1822176,2028858,2252640,2494440,2755200,3035886,3337488,3661020,4007520,4378050,4773696,5195568,5644800,6122550,6630000,7168356,7738848,8342730,8981280,9655800,10367616,11118078,11908560,12740460,13615200,14534226,15499008,16511040,17571840,18682950,19845936,21062388,22333920,23662170,25048800,26495496,28003968,29575950,31213200,32917500,34690656,36534498,38450880,40441680,42508800,44654166,46879728,49187460,51579360,54057450,56623776,59280408,62029440,64872990,67813200,70852236,73992288,77235570,80584320,84040800,87607296,91286118,95079600,98990100 mov $1,2 add $1,$0 bin $1,3 mul $1,$0 mul $1,6 mov $0,$1
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_2217.asm
ljhsiun2/medusa
9
28273
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x11253, %rsi nop nop nop cmp %r12, %r12 mov $0x6162636465666768, %rdx movq %rdx, (%rsi) and %r15, %r15 lea addresses_A_ht+0x571b, %r8 nop nop nop dec %r15 movb (%r8), %r10b nop cmp $54346, %rsi lea addresses_D_ht+0xf67b, %rdx nop nop nop nop nop sub %rax, %rax movl $0x61626364, (%rdx) nop nop nop nop nop add %r12, %r12 lea addresses_WC_ht+0x16e7b, %rsi lea addresses_A_ht+0x1de7b, %rdi clflush (%rdi) nop nop nop nop nop xor %r12, %r12 mov $42, %rcx rep movsq nop nop nop xor $44460, %rsi lea addresses_A_ht+0xecbb, %rsi lea addresses_UC_ht+0x447b, %rdi nop nop nop nop nop add $37730, %r8 mov $28, %rcx rep movsq nop nop nop nop nop and %rsi, %rsi lea addresses_WC_ht+0x15461, %r12 nop cmp %rdx, %rdx movb $0x61, (%r12) nop xor $48664, %r10 lea addresses_UC_ht+0x1a67b, %rsi lea addresses_D_ht+0x183fb, %rdi nop nop nop add %r15, %r15 mov $75, %rcx rep movsb cmp %rdi, %rdi lea addresses_UC_ht+0xee7b, %rsi nop inc %r15 mov $0x6162636465666768, %rdx movq %rdx, %xmm4 vmovups %ymm4, (%rsi) dec %rsi lea addresses_normal_ht+0xf12f, %rsi lea addresses_A_ht+0x19d7b, %rdi nop sub %r15, %r15 mov $33, %rcx rep movsl nop nop nop nop nop cmp $51705, %r12 lea addresses_UC_ht+0x1627b, %rsi lea addresses_UC_ht+0x1beab, %rdi cmp %r15, %r15 mov $98, %rcx rep movsw nop nop nop nop nop cmp $61083, %rcx lea addresses_UC_ht+0x1a47b, %rsi lea addresses_normal_ht+0x1e27b, %rdi xor $16528, %r15 mov $97, %rcx rep movsq xor %r8, %r8 lea addresses_D_ht+0x1af1f, %r12 nop nop xor $2127, %r10 movb $0x61, (%r12) nop cmp %r12, %r12 lea addresses_A_ht+0x185bb, %rsi lea addresses_normal_ht+0x1847b, %rdi nop nop nop and $52510, %r12 mov $11, %rcx rep movsq nop nop nop cmp $17760, %r15 lea addresses_D_ht+0x18123, %rsi nop and $59315, %rdi vmovups (%rsi), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdx nop nop nop nop nop xor $8234, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r14 push %r15 push %r8 push %rax push %rbp push %rcx push %rdi // Store lea addresses_WT+0x1a53b, %rcx nop nop nop nop add %r8, %r8 mov $0x5152535455565758, %rax movq %rax, %xmm0 vmovups %ymm0, (%rcx) nop nop nop xor $25385, %rcx // Faulty Load lea addresses_D+0x67b, %rbp nop cmp $4233, %r15 mov (%rbp), %eax lea oracles, %r8 and $0xff, %rax shlq $12, %rax mov (%r8,%rax,1), %rax pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r15 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 3, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 11, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 32, 'same': True, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': True, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 32, 'same': False, 'NT': False}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
Library/Spline/Spline/splineUtils.asm
steakknife/pcgeos
504
85997
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS - Spline edit object MODULE: FILE: splineUtils.asm AUTHOR: <NAME> REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 4/91 Initial version GLOBAL ROUTINES: LOCAL ROUTINES: DESCRIPTION: This file contains general "Utility" routines $Id: splineUtils.asm,v 1.1 97/04/07 11:08:56 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplinePtrCode segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineMouseMethodCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Subtract the upper left-hand corner of the VIS bounds from the mouse coordinates (cx and dx). Store these coordinates and the mouse-flags (UIFA etc) in the scratch data chunk. CALLED BY: SplineStartSelect, SplineDragSelect, SplinePtr, etc. PASS: *ds:si - VisSpline object ds:di - Vis instance data cx, dx - mouse position (screen coordinates) RETURN: cx, dx - "Vis" object coordinates (also, see SplineMethodCommon for values returned) bx - SplineMode DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 6/20/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineMouseMethodCommonReadOnly proc far class VisSplineClass .enter ; Read-only version of SplineMouseMethodCommon (doesn't mark ; blocks dirty) sub cx, ds:[di].VI_bounds.R_left sub dx, ds:[di].VI_bounds.R_top call SplineMethodCommonReadOnly GetEtypeFromRecord bx, SS_MODE, es:[bp].VSI_state .leave ret SplineMouseMethodCommonReadOnly endp SplineMouseMethodCommon proc far class VisSplineClass sub cx, ds:[di].VI_bounds.R_left sub dx, ds:[di].VI_bounds.R_top call SplineMethodCommon GetEtypeFromRecord bx, SS_MODE, es:[bp].VSI_state ret SplineMouseMethodCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineMethodCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set up the common registers, lock the spline's lmem block. CALLED BY: methods PASS: *ds:si - VisSpline object ds:di - VisSpline instance data RETURN: es:bp - VisSplineInstance data *ds:si - spline points DESTROYED: nothing PSEUDO CODE/STRATEGY: Most spline methods write data, therefore the default case is to mark both blocks dirty here at the beginning. If a method is known not to write data, then SplineMethodCommonReadOnly should be called instead. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 4/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineMethodCommonReadOnly proc far ; Read-only version of SplineMethodCommon (doesn't mark object ; block dirty) call SplineMethodCommonLow ret SplineMethodCommonReadOnly endp SplineMethodCommon proc far .enter call ObjMarkDirty call SplineMethodCommonLow ; ; Mark the points block dirty, too ; push bp mov bp, ds:[LMBH_handle] call VMDirty pop bp .leave ret SplineMethodCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineMethodCommonLow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common routine called whenever we want to lock the points block, etc. CALLED BY: SplineMethodCommon, SplineMethodCommonReadOnly PASS: *ds:si - spline object ds:di - VisSplineInstance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chrisb 10/12/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineMethodCommonLow proc near class VisSplineClass uses ax,bx .enter ; set ES pointing to spline block segmov es, ds, ax ; set DS to spline's points block mov bx, es:[di].VSI_lmemBlock call ObjLockObjBlock mov ds, ax ; create scratch chunk call SplineCreateScratchChunk ; Now, set ES:BP as fptr to VSI data mov bp, di ; set *DS:SI as points array mov si, es:[bp].VSI_points EC < call ECSplineInstanceAndLMemBlock > .leave ret SplineMethodCommonLow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineGetVMFile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the VM file containing the current spline CALLED BY: SplineMethodCommon PASS: ds - segment in same VM file as VisSpline object RETURN: bx - spline's VM file DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 3/12/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineGetVMFile proc far uses ax .enter mov bx, ds:[LMBH_handle] mov ax, MGIT_OWNER_OR_VM_FILE_HANDLE call MemGetInfo mov_tr bx, ax .leave ret SplineGetVMFile endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineEndmCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common routine for ending a method: free the scratch chunk, unlock the spline's memory block CALLED BY: methods PASS: es:bp - VisSplineInstance data ds - data segment of spline's lmem block RETURN: nothing DESTROYED: bx (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 10/ 3/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineEndmCommon proc far call class VisSplineClass .enter pushf EC < call ECSplineInstanceAndLMemBlock > ; Free the scratch chunk and unlock the points block call SplineFreeScratchChunk mov bx, ds:[LMBH_handle] call MemUnlock popf .leave ret SplineEndmCommon endp SplinePtrCode ends SplineUtilCode segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineSendMyselfAMessage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send a message to myself, fixing up any moved segments and pointers if necessary CALLED BY: SplineDetermineIfBoundsGrown PASS: es:bp - VisSplineInstance data ds - spline's data block ax - message number cx, dx, bx - other data to pass (in cx, dx, and bp) RETURN: es, bp, and ds fixed up, if necessary ax, cx, dx - returned from method (sorry, no bp!) DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 6/21/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineSendMyselfAMessage proc far uses bx,si class VisSplineClass .enter EC < call ECSplineInstanceAndLMemBlock > push ds:[LMBH_handle] SplineDerefScratchChunk si mov si, ds:[si].SD_splineChunkHandle segmov ds, es ; point DS to my object block mov bp, bx call ObjCallInstanceNoLock ; send message! ; Point ES:BP back to the spline segmov es, ds mov bp, es:[si] add bp, es:[bp].VisSpline_offset ; Pop the points block's handle. pop bx ; Dereference the (locked) points block call MemDerefDS EC < call ECSplineInstanceAndLMemBlock > .leave ret SplineSendMyselfAMessage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SplineRelocate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: PASS: *ds:si = VisSplineClass object ds:di = VisSplineClass instance data ax - MSG_META_RELOCATE/MSG_META_UNRELOCATE cx - handle of block containing relocation dx - VMRelocType: VMRT_UNRELOCATE_BEFORE_WRITE VMRT_RELOCATE_AFTER_READ VMRT_RELOCATE_AFTER_WRITE bp - data to pass to ObjRelocOrUnRelocSuper RETURN: carry - set if error bp - unchanged DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 6/24/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SplineRelocate method dynamic VisSplineClass, reloc cmp dx, VMRT_RELOCATE_AFTER_READ jne done mov di, ds:[si] add di, ds:[di].Vis_offset clr ax mov ds:[di].VSI_gstate, ax mov ds:[di].VSI_gstateRefCount, al done: mov di, offset VisSplineClass call ObjRelocOrUnRelocSuper ret SplineRelocate endm SplineUtilCode ends
thirdparty/glut/progs/ada/pickdepth_procs.adb
ShiroixD/pag_zad_2
1
24712
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with GL; use GL; with GLU; use GLU; with GLUT; use GLUT; with Text_IO; package body PickDepth_Procs is package tio renames Text_IO; procedure DoInit is begin glClearColor (0.0, 0.0, 0.0, 0.0); glDepthFunc (GL_LESS); glEnable (GL_DEPTH_TEST); glShadeModel (GL_FLAT); glDepthRange (0.0, 1.0); end DoInit; procedure DrawRects (mode : RenderingMode) is begin if mode = GL_SELECT then glLoadName (1); end if; glBegin (GL_QUADS); glColor3f (1.0, 1.0, 0.0); glVertex3i (2, 0, 0); glVertex3i (2, 6, 0); glVertex3i (6, 6, 0); glVertex3i (6, 0, 0); glEnd; if mode = GL_SELECT then glLoadName (2); end if; glBegin (GL_QUADS); glColor3f (0.0, 1.0, 1.0); glVertex3i (3, 2, -1); glVertex3i (3, 8, -1); glVertex3i (8, 8, -1); glVertex3i (8, 2, -1); glEnd; if mode = GL_SELECT then glLoadName (3); end if; glBegin (GL_QUADS); glColor3f (1.0, 0.0, 1.0); glVertex3i (0, 2, -2); glVertex3i (0, 7, -2); glVertex3i (5, 7, -2); glVertex3i (5, 2, -2); glEnd; end DrawRects; type int_ar is array (Integer range <>) of aliased GLuint; procedure ProcessHits (hits : GLint; buffer : in int_ar) is j : Integer := buffer'First; begin tio.Put_Line ("Hits = " & GLint'Image (hits)); if hits /= 0 then for i in Integer (buffer'First) .. Integer (buffer'First + Integer (hits) - 1) loop tio.Put_Line (" number of names for hit = " & GLuint'Image (buffer (j))); j := j + 1; tio.Put (" z1 is " & GLuint'Image (buffer (j))); j := j + 1; tio.Put ("; z2 is " & GLuint'Image (buffer (j))); j := j + 1; tio.New_Line; tio.Put (" names:"); for k in 1 .. Integer (buffer (buffer'First)) loop tio.Put (" " & GLuint'Image (buffer (j))); j := j + 1; end loop; tio.New_Line; end loop; end if; end ProcessHits; BUFSIZE : constant := 512; procedure PickRects (btn : Integer; state: Integer; x, y: Integer) is selectBuf : array (1 .. BUFSIZE) of aliased GLuint; hits : GLint; viewport : array (0 .. 3) of aliased GLint; begin if state = GLUT_LEFT_BUTTON then if state = GLUT_DOWN then glGetIntegerv (GL_VIEWPORT, viewport (0)'Access); glSelectBuffer (BUFSIZE, selectBuf (1)'Access); hits := glRenderMode (GL_SELECT); glInitNames; glPushName (-1); glMatrixMode (GL_PROJECTION); glPushMatrix; glLoadIdentity; gluPickMatrix (GLdouble (x), GLdouble (viewport (3) - GLint(y)), 5.0, 5.0, viewport (0)'Access); glOrtho (0.0, 8.0, 0.0, 8.0, -0.5, 2.5); DrawRects (GL_SELECT); glPopMatrix; glFlush; hits := glRenderMode (GL_RENDER); ProcessHits (hits, int_ar (selectBuf)); end if; end if; end PickRects; procedure DoDisplay is begin glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); DrawRects (GL_RENDER); glFlush; end DoDisplay; procedure ReshapeCallback (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; glOrtho (0.0, 8.0, 0.0, 8.0, -0.5, 2.5); glMatrixMode (GL_MODELVIEW); glLoadIdentity; end ReshapeCallback; end PickDepth_Procs;
source/containers/a-cogeso.adb
ytomino/drake
33
6913
<filename>source/containers/a-cogeso.adb<gh_stars>10-100 with Ada.Containers.Array_Sorting; with System.Long_Long_Integer_Types; procedure Ada.Containers.Generic_Sort (First, Last : Index_Type'Base) is subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer; begin if Index_Type'Pos (Index_Type'First) in Long_Long_Integer (Word_Integer'First) .. Long_Long_Integer (Word_Integer'Last) and then Index_Type'Pos (Index_Type'Last) in Long_Long_Integer (Word_Integer'First) .. Long_Long_Integer (Word_Integer'Last) then declare function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean; function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean is pragma Unreferenced (Params); Left_Index : constant Index_Type := Index_Type'Val (Left); Right_Index : constant Index_Type := Index_Type'Val (Right); begin return Before (Left_Index, Right_Index); end LT; procedure Swap ( Left, Right : Word_Integer; Params : System.Address); procedure Swap ( Left, Right : Word_Integer; Params : System.Address) is pragma Unreferenced (Params); Left_Index : constant Index_Type := Index_Type'Val (Left); Right_Index : constant Index_Type := Index_Type'Val (Right); begin Swap (Left_Index, Right_Index); end Swap; begin Array_Sorting.In_Place_Merge_Sort ( Index_Type'Pos (First), Index_Type'Pos (Last), System.Null_Address, LT => LT'Access, Swap => Swap'Access); end; else declare type Context_Type is limited record Offset : Long_Long_Integer; end record; pragma Suppress_Initialization (Context_Type); function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean; function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean is Context : Context_Type; for Context'Address use Params; Left_Index : constant Index_Type := Index_Type'Val (Long_Long_Integer (Left) + Context.Offset); Right_Index : constant Index_Type := Index_Type'Val (Long_Long_Integer (Right) + Context.Offset); begin return Before (Left_Index, Right_Index); end LT; procedure Swap ( Left, Right : Word_Integer; Params : System.Address); procedure Swap ( Left, Right : Word_Integer; Params : System.Address) is Context : Context_Type; for Context'Address use Params; Left_Index : constant Index_Type := Index_Type'Val (Long_Long_Integer (Left) + Context.Offset); Right_Index : constant Index_Type := Index_Type'Val (Long_Long_Integer (Right) + Context.Offset); begin Swap (Left_Index, Right_Index); end Swap; Offset : constant Long_Long_Integer := Index_Type'Pos (First); Context : aliased Context_Type := (Offset => Offset); begin Array_Sorting.In_Place_Merge_Sort ( 0, Word_Integer (Long_Long_Integer'(Index_Type'Pos (Last) - Offset)), Context'Address, LT => LT'Access, Swap => Swap'Access); end; end if; end Ada.Containers.Generic_Sort;
src/interrupts.asm
Codesmith512/Apex
1
23382
<gh_stars>1-10 ; ########################### ; APEX OS Interrupt Services ; ########################### [bits 32] ; ######################### ; IDT descriptor goes here ; ######################### section .bss idtr: .size: resw 1; The size-1 of the IDT .addr: resd 1; The linear address of the IDT ; #################### ; Interrupt functions ; #################### section .text ; @func void load_idt(void*) ; Loads a 256-entry IDT with the given address global load_idt load_idt: mov [idtr.size], word (8*256)-1 push eax mov eax, [esp+8] mov [idtr.addr], eax pop eax lidt [idtr] ret ; @func void enable_int() ; Enables interrupts global enable_hw_interrupts enable_hw_interrupts: sti ret ; @func void disable_int() ; Disables interrupts global disable_hw_interrupts disable_hw_interrupts: cli ret ; @func void int_wrapper ; A function that can be used to generate ; interrupt wrapper code for C/C++ functions global int_wrapper_f int_wrapper_f: push .return jmp 0x8:0xdeadc0de .return: iret .end: ; @uint32_t int_wrapper_size ; The size of the int_wrapper function global int_wrapper_s int_wrapper_s: dd (int_wrapper_f.end - int_wrapper_f)
src/pm/common/_joy.asm
OS2World/DEV-UTIL-ScitechOS_PML
0
22373
;**************************************************************************** ;* ;* SciTech OS Portability Manager Library ;* ;* ======================================================================== ;* ;* The contents of this file are subject to the SciTech MGL Public ;* License Version 1.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.scitechsoft.com/mgl-license.txt ;* ;* Software distributed under the License is distributed on an ;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or ;* implied. See the License for the specific language governing ;* rights and limitations under the License. ;* ;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. ;* ;* The Initial Developer of the Original Code is SciTech Software, Inc. ;* All Rights Reserved. ;* ;* ======================================================================== ;* ;* Language: 80386 Assembler ;* Environment: Intel x86, any OS ;* ;* Description: Assembly language support routines for reading analogue ;* joysticks. ;* ;**************************************************************************** ideal include "scitech.mac" ; Memory model macros ifdef flatmodel header _joy ; Set up memory model begcodeseg _joy ; Start of code segment ;---------------------------------------------------------------------------- ; initTimer ;---------------------------------------------------------------------------- ; Sets up 8253 timer 2 (PC speaker) to start timing, but not produce output. ;---------------------------------------------------------------------------- cprocstatic initTimer ; Start timer 2 counting in al,61h and al,0FDh ; Disable speaker output (just in case) or al,1 out 61h,al ; Set the timer 2 count to 0 again to start the timing interval. mov al,10110100b ; set up to load initial (timer 2) out 43h,al ; timer count sub al,al out 42h,al ; load count lsb out 42h,al ; load count msb ret cprocend ;---------------------------------------------------------------------------- ; readTimer2 ;---------------------------------------------------------------------------- ; Reads the number of ticks from the 8253 timer chip using channel 2 (PC ; speaker). This is non-destructive and does not screw up other libraries. ;---------------------------------------------------------------------------- cprocstatic readTimer xor al,al ; Latch timer 0 command out 43h,al ; Latch timer in al,42h ; least significant byte mov ah,al in al,42h ; most significant byte xchg ah,al and eax,0FFFFh ret cprocend ;---------------------------------------------------------------------------- ; exitTimer ;---------------------------------------------------------------------------- ; Stops the 8253 timer 2 (PC speaker) counting ;---------------------------------------------------------------------------- cprocstatic exitTimer ; Stop timer 2 from counting push eax in al,61h and al,0FEh out 61h,al ; Some programs have a problem if we change the control port; better change it ; to something they expect (mode 3 - square wave generator)... mov al,0B6h out 43h,al pop eax ret cprocend ;---------------------------------------------------------------------------- ; int _EVT_readJoyAxis(int jmask,int *axis); ;---------------------------------------------------------------------------- ; Function to poll the joystick to read the current axis positions. ;---------------------------------------------------------------------------- cprocstart _EVT_readJoyAxis ARG jmask:UINT, axis:DPTR LOCAL firstTick:UINT, lastTick:UINT, totalTicks:UINT = LocalSize enter_c mov ebx,[jmask] mov edi,[axis] mov ecx,(1193180/100) and ebx,01111b ; Mask out supported axes mov dx,201h ; DX := joystick I/O port call initTimer ; Start timer 2 counting call readTimer ; Returns counter in EAX mov [lastTick],eax @@WaitStable: in al,dx and al,bl ; Wait for the axes in question to be jz @@Stable ; done reading... call readTimer ; Returns counter in EAX xchg eax,[lastTick] cmp eax,[lastTick] jb @@1 sub eax,[lastTick] @@1: add [totalTicks],eax cmp [totalTicks],ecx ; Check for timeout jae @@Stable jmp @@WaitStable @@Stable: mov al,0FFh out dx,al ; Start joystick reading call initTimer ; Start timer 2 counting call readTimer ; Returns counter in EAX mov [firstTick],eax ; Store initial count mov [lastTick],eax mov [DWORD totalTicks],0 cli @@PollLoop: in al,dx ; Read Joystick port not al and al,bl ; Mask off channels we don't want to read jnz @@AxisFlipped ; See if any of the channels flipped call readTimer ; Returns counter in EAX xchg eax,[lastTick] cmp eax,[lastTick] jb @@2 sub eax,[lastTick] @@2: add [totalTicks],eax cmp [totalTicks],ecx ; Check for timeout jae @@TimedOut jmp @@PollLoop @@AxisFlipped: xor esi,esi mov ah,1 test al,ah jnz @@StoreCount ; Joystick 1, X axis flipped add esi,4 mov ah,2 test al,ah jnz @@StoreCount ; Joystick 1, Y axis flipped add esi,4 mov ah,4 test al,ah jnz @@StoreCount ; Joystick 2, X axis flipped add esi,4 ; Joystick 2, Y axis flipped mov ah,8 @@StoreCount: or bh,ah ; Indicate this axis is active xor bl,ah ; Unmark the channels that just tripped call readTimer ; Returns counter in EAX xchg eax,[lastTick] cmp eax,[lastTick] jb @@3 sub eax,[lastTick] @@3: add [totalTicks],eax mov eax,[totalTicks] mov [edi+esi],eax ; Record the time this channel flipped cmp bl,0 ; If there are more channels to read, jne @@PollLoop ; keep looping @@TimedOut: sti call exitTimer ; Stop timer 2 counting movzx eax,bh ; Return the mask of working axes leave_c ret cprocend ;---------------------------------------------------------------------------- ; int _EVT_readJoyButtons(void); ;---------------------------------------------------------------------------- ; Function to poll the current joystick buttons ;---------------------------------------------------------------------------- cprocstart _EVT_readJoyButtons mov dx,0201h in al,dx shr al,4 not al and eax,0Fh ret cprocend endcodeseg _joy endif END ; End of module
Lambda/Syntax.agda
nad/codata
1
8015
------------------------------------------------------------------------ -- The syntax of, and a type system for, the untyped λ-calculus with -- constants ------------------------------------------------------------------------ module Lambda.Syntax where open import Codata.Musical.Notation open import Data.Nat open import Data.Fin hiding (_≤?_) open import Data.Vec open import Relation.Nullary.Decidable ------------------------------------------------------------------------ -- Terms -- Variables are represented using de Bruijn indices. infixl 9 _·_ data Tm (n : ℕ) : Set where con : (i : ℕ) → Tm n var : (x : Fin n) → Tm n ƛ : (t : Tm (suc n)) → Tm n _·_ : (t₁ t₂ : Tm n) → Tm n -- Convenient helper. vr : ∀ m {n} {m<n : True (suc m ≤? n)} → Tm n vr _ {m<n = m<n} = var (#_ _ {m<n = m<n}) ------------------------------------------------------------------------ -- Values, potentially with free variables module WHNF where data Value (n : ℕ) : Set where con : (i : ℕ) → Value n ƛ : (t : Tm (suc n)) → Value n ⌜_⌝ : ∀ {n} → Value n → Tm n ⌜ con i ⌝ = con i ⌜ ƛ t ⌝ = ƛ t ------------------------------------------------------------------------ -- Closure-based definition of values -- Environments and values. Defined in a module parametrised on the -- type of terms. module Closure (Tm : ℕ → Set) where mutual -- Environments. Env : ℕ → Set Env n = Vec Value n -- Values. Lambdas are represented using closures, so values do -- not contain any free variables. data Value : Set where con : (i : ℕ) → Value ƛ : ∀ {n} (t : Tm (suc n)) (ρ : Env n) → Value ------------------------------------------------------------------------ -- Type system (following Leroy and Grall) -- Recursive, simple types, defined coinductively. infixr 8 _⇾_ data Ty : Set where nat : Ty _⇾_ : (σ τ : ∞ Ty) → Ty -- Contexts. Ctxt : ℕ → Set Ctxt n = Vec Ty n -- Type system. infix 4 _⊢_∈_ data _⊢_∈_ {n} (Γ : Ctxt n) : Tm n → Ty → Set where con : ∀ {i} → Γ ⊢ con i ∈ nat var : ∀ {x} → Γ ⊢ var x ∈ lookup Γ x ƛ : ∀ {t σ τ} (t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) → Γ ⊢ ƛ t ∈ σ ⇾ τ _·_ : ∀ {t₁ t₂ σ τ} (t₁∈ : Γ ⊢ t₁ ∈ σ ⇾ τ) (t₂∈ : Γ ⊢ t₂ ∈ ♭ σ) → Γ ⊢ t₁ · t₂ ∈ ♭ τ ------------------------------------------------------------------------ -- Example -- A non-terminating term. ω : Tm 0 ω = ƛ (vr 0 · vr 0) Ω : Tm 0 Ω = ω · ω -- Ω is well-typed. Ω-well-typed : (τ : Ty) → [] ⊢ Ω ∈ τ Ω-well-typed τ = _·_ {σ = ♯ σ} {τ = ♯ τ} (ƛ (var · var)) (ƛ (var · var)) where σ = ♯ σ ⇾ ♯ τ -- A call-by-value fix-point combinator. Z : Tm 0 Z = ƛ (t · t) where t = ƛ (vr 1 · ƛ (vr 1 · vr 1 · vr 0)) -- This combinator is also well-typed. fix-well-typed : ∀ {σ τ} → [] ⊢ Z ∈ ♯ (♯ (σ ⇾ τ) ⇾ ♯ (σ ⇾ τ)) ⇾ ♯ (σ ⇾ τ) fix-well-typed = ƛ (_·_ {σ = υ} {τ = ♯ _} (ƛ (var · ƛ (var · var · var))) (ƛ (var · ƛ (var · var · var)))) where υ : ∞ Ty υ = ♯ (υ ⇾ ♯ _)
Examples/Multi_Word_Addition.asm
Pyxxil/rust-lc3-as
3
82646
; ; Add two 30-bit numbers, check whether or not they carried/overflowed, and print them to the display. ; .ORIG x3000 BR START OP1_LSW .FILL b101010101010101 ; The lowest 15 bits of the first operand. OP1_MSW .FILL b110000000000010 ; The upper 15 bits of the first operand. OP2_LSW .FILL b111111111111111 ; The lowest 15 bits of the second operand. OP2_MSW .FILL b110000000000001 ; The upper 15 bits of the second operand. ; Start by printing the two operands START: LD R6, OP1_MSW JSR BEGIN_PRINT_BINARY LD R0, ASCII_SPACE OUT LD R6, OP1_LSW JSR BEGIN_PRINT_BINARY LD R0, ASCII_NEWLINE OUT LD R6, OP2_MSW JSR BEGIN_PRINT_BINARY LD R0, ASCII_SPACE OUT LD R6, OP2_LSW JSR BEGIN_PRINT_BINARY LD R0, ASCII_NEWLINE OUT LEA R0, SEPERATOR PUTS LD R0, ASCII_NEWLINE OUT ; Add the least significant words of the two operands. ADD_LSW: AND R4, R4, #0 LD R0, OP1_LSW LD R1, OP2_LSW ADD R6, R0, R1 LD R5, MASK ; Make sure the result is only 15 bits wide. AND R5, R5, R6 ST R5, LSW_RESULT LD R5, CARRY_BIT ; Check whether or not the addition carried. AND R5, R5, R6 BRz ADD_MSW ; If it didn't carry, we don't need to add 1 to the MSW addition. LSW_CARRY: ADD R4, R4, #1 ; Add the most significant words of the two operands. ADD_MSW: LD R0, OP1_MSW LD R1, OP2_MSW ADD R6, R1, R0 ADD R6, R6, R4 LD R5, MASK AND R5, R5, R6 ST R5, MSW_RESULT LD R5, CARRY_BIT ; Check if the result carried. AND R5, R5, R6 BRz CHECK_OVERFLOW ; If it didn't carry, just start checking for overflow. MSW_CARRY: ADD R0, R0, #1 ; Store the fact that the addition did carry. ST R0, CARRY CHECK_OVERFLOW: LD R2, SIGN_BIT ; Check the sign of the MSW of the first operand. AND R0, R0, R2 BRz OP1_POSITIVE OP1_NEGATIVE: AND R1, R1, R2 ; Check the sign of the MSW of the second operand. BRz PRINT_RESULT ; If they aren't the same, then no overflow occurred. OP2_ALSO_NEGATIVE: ; Overflow might have occurred. AND R6, R6, R2 BRnp PRINT_RESULT ; No overflow. BR OVERFLOWED OP1_POSITIVE: AND R1, R1, R2 ; Check the sign of the MSW of the second operand. BRnp PRINT_RESULT ; If they're different, then no overflow occurred. OP2_ALSO_POSITIVE: ; Overflow may have occurred. AND R6, R6, R2 BRz PRINT_RESULT ; No overflow. OVERFLOWED: ; Overflow occurred, so store that fact. AND R2, R2, #0 ADD R2, R2, #1 ST R2, OVERFLOW ; Print out the 30-bit result. PRINT_RESULT: LD R6, MSW_RESULT JSR BEGIN_PRINT_BINARY LD R0, ASCII_SPACE OUT LD R6, LSW_RESULT JSR BEGIN_PRINT_BINARY LD R0, CARRY BRz PRINT_OVERFLOW ; If there wasn't a carry, then just jump to printing overflow. PRINT_CARRY: LEA R0, CARRY_STR PUTS PRINT_OVERFLOW: LD R0, OVERFLOW BRz FINISH ; If no overflow occurred, we're done. LEA R0, OVERFLOW_STR PUTS FINISH: HALT ; Print the binary representation of the value passed in through R6. BEGIN_PRINT_BINARY: ST R7, RETURN_ADDRESS ; store return address LEA R3, BITMASKS PRINT_BINARY: LDR R4, R3, #0 ; Load the current bit mask. BRz END_PRINT_BINARY ; We've reached the end of the bit masks, sp finish AND R4, R4, R6 ; Check whether the bit is set... BRnp PRINT_ONE ; If yes, print a one, ... PRINT_ZERO: ; Otherwise, print a 0. LD R0, ASCII_ZERO OUT ADD R3, R3, #1 ; Increment the bitmask pointer. BR PRINT_BINARY ; Print the next bit PRINT_ONE: LD R0, ASCII_ONE OUT ADD R3, R3, #1 ; Increment the bitmask pointer. BR PRINT_BINARY ; Print the next bit END_PRINT_BINARY: LD R7, RETURN_ADDRESS ; load the correct return address RET ; Important bit masks MASK .FILL b0111111111111111 SIGN_BIT .FILL b0100000000000000 CARRY_BIT .FILL b1000000000000000 ; Places to store important information MSW_RESULT .FILL 0x0 LSW_RESULT .FILL 0x0 CARRY .FILL 0x0 OVERFLOW .FILL 0x0 RETURN_ADDRESS .FILL 0x0 ; Values to be used to print out. ASCII_ZERO .FILL 0x30 ASCII_ONE .FILL 0x31 ASCII_NEWLINE .FILL 0xA ASCII_SPACE .FILL 0x20 SEPERATOR .STRINGZ "=============== ===============" CARRY_STR .STRINGZ " c" OVERFLOW_STR .STRINGZ " v" ; More important bit masks which will be used when printing out the binary representation. BITMASKS: .FILL b100000000000000 .FILL b010000000000000 .FILL b001000000000000 .FILL b000100000000000 .FILL b000010000000000 .FILL b000001000000000 .FILL b000000100000000 .FILL b000000010000000 .FILL b000000001000000 .FILL b000000000100000 .FILL b000000000010000 .FILL b000000000001000 .FILL b000000000000100 .FILL b000000000000010 .FILL b000000000000001 .FILL b000000000000000 .END
arch/ARM/STM32/svd/stm32l151/stm32_svd-opamp.ads
morbos/Ada_Drivers_Library
2
15251
-- This spec has been automatically generated from STM32L151.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.OPAMP is pragma Preelaborate; --------------- -- Registers -- --------------- -- CSR_ANAWSEL array type CSR_ANAWSEL_Field_Array is array (1 .. 3) of Boolean with Component_Size => 1, Size => 3; -- Type definition for CSR_ANAWSEL type CSR_ANAWSEL_Field (As_Array : Boolean := False) is record case As_Array is when False => -- ANAWSEL as a value Val : HAL.UInt3; when True => -- ANAWSEL as an array Arr : CSR_ANAWSEL_Field_Array; end case; end record with Unchecked_Union, Size => 3; for CSR_ANAWSEL_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- control/status register type CSR_Register is record -- OPAMP1 power down OPA1PD : Boolean := True; -- Switch 3 for OPAMP1 enable S3SEL1 : Boolean := False; -- Switch 4 for OPAMP1 enable S4SEL1 : Boolean := False; -- Switch 5 for OPAMP1 enable S5SEL1 : Boolean := False; -- Switch 6 for OPAMP1 enable S6SEL1 : Boolean := False; -- OPAMP1 offset calibration for P differential pair OPA1CAL_L : Boolean := False; -- OPAMP1 offset calibration for N differential pair OPA1CAL_H : Boolean := False; -- OPAMP1 low power mode OPA1LPM : Boolean := False; -- OPAMP2 power down OPA2PD : Boolean := True; -- Switch 3 for OPAMP2 enable S3SEL2 : Boolean := False; -- Switch 4 for OPAMP2 enable S4SEL2 : Boolean := False; -- Switch 5 for OPAMP2 enable S5SEL2 : Boolean := False; -- Switch 6 for OPAMP2 enable S6SEL2 : Boolean := False; -- OPAMP2 offset Calibration for P differential pair OPA2CAL_L : Boolean := False; -- OPAMP2 offset calibration for N differential pair OPA2CAL_H : Boolean := False; -- OPAMP2 low power mode OPA2LPM : Boolean := False; -- OPAMP3 power down OPA3PD : Boolean := True; -- Switch 3 for OPAMP3 Enable S3SEL3 : Boolean := False; -- Switch 4 for OPAMP3 enable S4SEL3 : Boolean := False; -- Switch 5 for OPAMP3 enable S5SEL3 : Boolean := False; -- Switch 6 for OPAMP3 enable S6SEL3 : Boolean := False; -- OPAMP3 offset Calibration for P differential pair OPA3CAL_L : Boolean := False; -- OPAMP3 offset calibration for N differential pair OPA3CAL_H : Boolean := False; -- OPAMP3 low power mode OPA3LPM : Boolean := False; -- Switch SanA enable for OPAMP1 ANAWSEL : CSR_ANAWSEL_Field := (As_Array => False, Val => 16#0#); -- Switch 7 for OPAMP2 enable S7SEL2 : Boolean := False; -- Power range selection AOP_RANGE : Boolean := False; -- OPAMP1 calibration output OPA1CALOUT : Boolean := False; -- OPAMP2 calibration output OPA2CALOUT : Boolean := False; -- OPAMP3 calibration output OPA3CALOUT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record OPA1PD at 0 range 0 .. 0; S3SEL1 at 0 range 1 .. 1; S4SEL1 at 0 range 2 .. 2; S5SEL1 at 0 range 3 .. 3; S6SEL1 at 0 range 4 .. 4; OPA1CAL_L at 0 range 5 .. 5; OPA1CAL_H at 0 range 6 .. 6; OPA1LPM at 0 range 7 .. 7; OPA2PD at 0 range 8 .. 8; S3SEL2 at 0 range 9 .. 9; S4SEL2 at 0 range 10 .. 10; S5SEL2 at 0 range 11 .. 11; S6SEL2 at 0 range 12 .. 12; OPA2CAL_L at 0 range 13 .. 13; OPA2CAL_H at 0 range 14 .. 14; OPA2LPM at 0 range 15 .. 15; OPA3PD at 0 range 16 .. 16; S3SEL3 at 0 range 17 .. 17; S4SEL3 at 0 range 18 .. 18; S5SEL3 at 0 range 19 .. 19; S6SEL3 at 0 range 20 .. 20; OPA3CAL_L at 0 range 21 .. 21; OPA3CAL_H at 0 range 22 .. 22; OPA3LPM at 0 range 23 .. 23; ANAWSEL at 0 range 24 .. 26; S7SEL2 at 0 range 27 .. 27; AOP_RANGE at 0 range 28 .. 28; OPA1CALOUT at 0 range 29 .. 29; OPA2CALOUT at 0 range 30 .. 30; OPA3CALOUT at 0 range 31 .. 31; end record; subtype OTR_AO1_OPT_OFFSET_TRIM_Field is HAL.UInt10; subtype OTR_AO2_OPT_OFFSET_TRIM_Field is HAL.UInt10; subtype OTR_AO3_OPT_OFFSET_TRIM_Field is HAL.UInt10; -- offset trimming register for normal mode type OTR_Register is record -- OPAMP1, 10-bit offset trim value for normal mode AO1_OPT_OFFSET_TRIM : OTR_AO1_OPT_OFFSET_TRIM_Field := 16#0#; -- OPAMP2, 10-bit offset trim value for normal mode AO2_OPT_OFFSET_TRIM : OTR_AO2_OPT_OFFSET_TRIM_Field := 16#0#; -- OPAMP3, 10-bit offset trim value for normal mode AO3_OPT_OFFSET_TRIM : OTR_AO3_OPT_OFFSET_TRIM_Field := 16#0#; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- Select user or factory trimming value OT_USER : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTR_Register use record AO1_OPT_OFFSET_TRIM at 0 range 0 .. 9; AO2_OPT_OFFSET_TRIM at 0 range 10 .. 19; AO3_OPT_OFFSET_TRIM at 0 range 20 .. 29; Reserved_30_30 at 0 range 30 .. 30; OT_USER at 0 range 31 .. 31; end record; subtype LPOTR_AO1_OPT_OFFSET_TRIM_LP_Field is HAL.UInt10; subtype LPOTR_AO2_OPT_OFFSET_TRIM_LP_Field is HAL.UInt10; subtype LPOTR_AO3_OPT_OFFSET_TRIM_LP_Field is HAL.UInt10; -- OPAMP offset trimming register for low power mode type LPOTR_Register is record -- OPAMP1, 10-bit offset trim value for low power mode AO1_OPT_OFFSET_TRIM_LP : LPOTR_AO1_OPT_OFFSET_TRIM_LP_Field := 16#0#; -- OPAMP2, 10-bit offset trim value for low power mode AO2_OPT_OFFSET_TRIM_LP : LPOTR_AO2_OPT_OFFSET_TRIM_LP_Field := 16#0#; -- OPAMP3, 10-bit offset trim value for low power mode AO3_OPT_OFFSET_TRIM_LP : LPOTR_AO3_OPT_OFFSET_TRIM_LP_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LPOTR_Register use record AO1_OPT_OFFSET_TRIM_LP at 0 range 0 .. 9; AO2_OPT_OFFSET_TRIM_LP at 0 range 10 .. 19; AO3_OPT_OFFSET_TRIM_LP at 0 range 20 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Operational amplifiers type OPAMP_Peripheral is record -- control/status register CSR : aliased CSR_Register; -- offset trimming register for normal mode OTR : aliased OTR_Register; -- OPAMP offset trimming register for low power mode LPOTR : aliased LPOTR_Register; end record with Volatile; for OPAMP_Peripheral use record CSR at 16#0# range 0 .. 31; OTR at 16#4# range 0 .. 31; LPOTR at 16#8# range 0 .. 31; end record; -- Operational amplifiers OPAMP_Periph : aliased OPAMP_Peripheral with Import, Address => System'To_Address (16#40007C5C#); end STM32_SVD.OPAMP;
source/asis/spec/interfaces-c-pointers.ads
faelys/gela-asis
4
21067
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ generic type Index is (<>); type Element is private; type Element_Array is array (Index range <>) of aliased Element; Default_Terminator : Element; package Interfaces.C.Pointers is pragma Preelaborate (Pointers); type Pointer is access all Element; function Value (Ref : in Pointer; Terminator : in Element := Default_Terminator) return Element_Array; function Value (Ref : in Pointer; Length : in ptrdiff_t) return Element_Array; Pointer_Error : exception; -- C-style Pointer arithmetic function "+" (Left : in Pointer; Right : in ptrdiff_t) return Pointer; function "+" (Left : in ptrdiff_t; Right : in Pointer) return Pointer; function "-" (Left : in Pointer; Right : in ptrdiff_t) return Pointer; function "-" (Left : in Pointer; Right : in Pointer) return ptrdiff_t; procedure Increment (Ref : in out Pointer); procedure Decrement (Ref : in out Pointer); pragma Convention (Intrinsic, "+"); pragma Convention (Intrinsic, "-"); pragma Convention (Intrinsic, Increment); pragma Convention (Intrinsic, Decrement); function Virtual_Length (Ref : in Pointer; Terminator : in Element := Default_Terminator) return ptrdiff_t; procedure Copy_Terminated_Array (Source : in Pointer; Target : in Pointer; Limit : in ptrdiff_t := ptrdiff_t'Last; Terminator : in Element := Default_Terminator); procedure Copy_Array (Source : in Pointer; Target : in Pointer; Length : in ptrdiff_t); end Interfaces.C.Pointers;
libtool/src/gmp-6.1.2/mpn/x86/sqr_basecase.asm
kroggen/aergo
1,602
90485
<gh_stars>1000+ dnl x86 generic mpn_sqr_basecase -- square an mpn number. dnl Copyright 1999, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/crossproduct cycles/triangleproduct C P5 C P6 C K6 C K7 C P4 C void mpn_sqr_basecase (mp_ptr dst, mp_srcptr src, mp_size_t size); C C The algorithm is basically the same as mpn/generic/sqr_basecase.c, but a C lot of function call overheads are avoided, especially when the size is C small. C C The mul1 loop is not unrolled like mul_1.asm, it doesn't seem worth the C code size to do so here. C C Enhancements: C C The addmul loop here is also not unrolled like aorsmul_1.asm and C mul_basecase.asm are. Perhaps it should be done. It'd add to the C complexity, but if it's worth doing in the other places then it should be C worthwhile here. C C A fully-unrolled style like other sqr_basecase.asm versions (k6, k7, p6) C might be worth considering. That'd add quite a bit to the code size, but C only as much as is used would be dragged into L1 cache. defframe(PARAM_SIZE,12) defframe(PARAM_SRC, 8) defframe(PARAM_DST, 4) TEXT ALIGN(8) PROLOGUE(mpn_sqr_basecase) deflit(`FRAME',0) movl PARAM_SIZE, %edx movl PARAM_SRC, %eax cmpl $2, %edx movl PARAM_DST, %ecx je L(two_limbs) ja L(three_or_more) C ----------------------------------------------------------------------------- C one limb only C eax src C ebx C ecx dst C edx movl (%eax), %eax mull %eax movl %eax, (%ecx) movl %edx, 4(%ecx) ret C ----------------------------------------------------------------------------- ALIGN(8) L(two_limbs): C eax src C ebx C ecx dst C edx pushl %ebx pushl %ebp movl %eax, %ebx movl (%eax), %eax mull %eax C src[0]^2 pushl %esi pushl %edi movl %edx, %esi C dst[1] movl %eax, (%ecx) C dst[0] movl 4(%ebx), %eax mull %eax C src[1]^2 movl %eax, %edi C dst[2] movl %edx, %ebp C dst[3] movl (%ebx), %eax mull 4(%ebx) C src[0]*src[1] addl %eax, %esi adcl %edx, %edi adcl $0, %ebp addl %esi, %eax adcl %edi, %edx movl %eax, 4(%ecx) adcl $0, %ebp movl %edx, 8(%ecx) movl %ebp, 12(%ecx) popl %edi popl %esi popl %ebp popl %ebx ret C ----------------------------------------------------------------------------- ALIGN(8) L(three_or_more): deflit(`FRAME',0) C eax src C ebx C ecx dst C edx size pushl %ebx FRAME_pushl() pushl %edi FRAME_pushl() pushl %esi FRAME_pushl() pushl %ebp FRAME_pushl() leal (%ecx,%edx,4), %edi C &dst[size], end of this mul1 leal (%eax,%edx,4), %esi C &src[size] C First multiply src[0]*src[1..size-1] and store at dst[1..size]. movl (%eax), %ebp C src[0], multiplier movl %edx, %ecx negl %ecx C -size xorl %ebx, %ebx C clear carry limb incl %ecx C -(size-1) L(mul1): C eax scratch C ebx carry C ecx counter, limbs, negative C edx scratch C esi &src[size] C edi &dst[size] C ebp multiplier movl (%esi,%ecx,4), %eax mull %ebp addl %eax, %ebx adcl $0, %edx movl %ebx, (%edi,%ecx,4) movl %edx, %ebx incl %ecx jnz L(mul1) movl %ebx, (%edi) C Add products src[n]*src[n+1..size-1] at dst[2*n-1...], for C n=1..size-2. C C The last products src[size-2]*src[size-1], which is the end corner C of the product triangle, is handled separately at the end to save C looping overhead. If size is 3 then it's only this that needs to C be done. C C In the outer loop %esi is a constant, and %edi just advances by 1 C limb each time. The size of the operation decreases by 1 limb C each time. C eax C ebx carry (needing carry flag added) C ecx C edx C esi &src[size] C edi &dst[size] C ebp movl PARAM_SIZE, %ecx subl $3, %ecx jz L(corner) negl %ecx dnl re-use parameter space define(VAR_OUTER,`PARAM_DST') L(outer): C eax C ebx C ecx C edx outer loop counter, -(size-3) to -1 C esi &src[size] C edi dst, pointing at stored carry limb of previous loop C ebp movl %ecx, VAR_OUTER addl $4, %edi C advance dst end movl -8(%esi,%ecx,4), %ebp C next multiplier subl $1, %ecx xorl %ebx, %ebx C initial carry limb L(inner): C eax scratch C ebx carry (needing carry flag added) C ecx counter, -n-1 to -1 C edx scratch C esi &src[size] C edi dst end of this addmul C ebp multiplier movl (%esi,%ecx,4), %eax mull %ebp addl %ebx, %eax adcl $0, %edx addl %eax, (%edi,%ecx,4) adcl $0, %edx movl %edx, %ebx addl $1, %ecx jl L(inner) movl %ebx, (%edi) movl VAR_OUTER, %ecx incl %ecx jnz L(outer) L(corner): C esi &src[size] C edi &dst[2*size-3] movl -4(%esi), %eax mull -8(%esi) C src[size-1]*src[size-2] addl %eax, 0(%edi) adcl $0, %edx movl %edx, 4(%edi) C dst high limb C ----------------------------------------------------------------------------- C Left shift of dst[1..2*size-2], high bit shifted out becomes dst[2*size-1]. movl PARAM_SIZE, %eax negl %eax addl $1, %eax C -(size-1) and clear carry L(lshift): C eax counter, negative C ebx next limb C ecx C edx C esi C edi &dst[2*size-4] C ebp rcll 8(%edi,%eax,8) rcll 12(%edi,%eax,8) incl %eax jnz L(lshift) adcl %eax, %eax C high bit out movl %eax, 8(%edi) C dst most significant limb C Now add in the squares on the diagonal, namely src[0]^2, src[1]^2, ..., C src[size-1]^2. dst[0] hasn't yet been set at all yet, and just gets the C low limb of src[0]^2. movl PARAM_SRC, %esi movl (%esi), %eax C src[0] mull %eax C src[0]^2 movl PARAM_SIZE, %ecx leal (%esi,%ecx,4), %esi C src end negl %ecx C -size movl %edx, %ebx C initial carry movl %eax, 12(%edi,%ecx,8) C dst[0] incl %ecx C -(size-1) L(diag): C eax scratch (low product) C ebx carry limb C ecx counter, -(size-1) to -1 C edx scratch (high product) C esi &src[size] C edi &dst[2*size-3] C ebp scratch (fetched dst limbs) movl (%esi,%ecx,4), %eax mull %eax addl %ebx, 8(%edi,%ecx,8) movl %edx, %ebx adcl %eax, 12(%edi,%ecx,8) adcl $0, %ebx incl %ecx jnz L(diag) addl %ebx, 8(%edi) C dst most significant limb popl %ebp popl %esi popl %edi popl %ebx ret EPILOGUE()
kernel/utility/tointeger.asm
paulscottrobson/eris
13
10167
; ***************************************************************************** ; ***************************************************************************** ; ; Name: tointeger.asm ; Purpose: Convert string to integer ; Created: 8th March 2020 ; Reviewed: 16th March 2020 ; Author: <NAME> (<EMAIL>) ; ; ***************************************************************************** ; ***************************************************************************** ; ***************************************************************************** ; ; Convert String to Integer. ; ; On entry R1 contains the base 2-16 and R0 the character fetch routine. ; ; Calling the character fetch retrieves the next character from the input ; stream ; it should return $00 if it runs out of data. ; ; The stream is converted into an integer which is returned in R0. R1 is ; non-zero if an error has occurred. In this case the first bad character ; has already been 'got', so it is possible to get it back, by (say) ; decrementing the character pointer and re-reading it. ; ; R10 and R11 are not used by the routine, and can be used to contain ; values for the character fetch which are maintained between calls ; (e.g. a data pointer) ; ; ***************************************************************************** .OSXStrToInt push r2,r3,r4,r5,r6,link mov r2,r0,#0 ; put the 'get' routine in R2 clr r3 ; r3 is the result clr r4 ; r4 is the signed flag. mov r6,#1 ; error flag, cleared on a successful conversion ; brl r13,r2,#0 ; call the get routine and r0,#$00FF ; mask character off. mov r5,r0,#0 ; put in R5. xor r5,#'-' ; is it - ? skz r5 jmp #_OSSILoop inc r4 ; if so, set the signed flag. brl r13,r2,#0 ; get the next character ; ; Convert loop, already has next character in R0. ; ._OSSILoop jsr #OSUpperCase ; make U/C which also clears bits 8-15 sub r0,#'0' ; base shift - we're checking 0-9 A... skge ; exit if < '0' jmp #_OSSIExit mov r5,r0,#0 ; put this base value in R5. sub r0,#10 ; 0-9 check skge jmp #_OSSHaveDigit sub r5,#7 ; check A-F - adjust the base value. sub r0,#7 skge ; this exits if in the bit between 9 and A. jmp #_OSSIExit ._OSSHaveDigit mov r0,r5,#0 ; check the digit < base sub r0,r1,#0 sklt jmp #_OSSIExit ; mult r3,r1,#0 ; x current by base and add add r3,r5,#0 clr r6 ; clear error flag as we have one valid digit brl r13,r2,#0 ; get next character and go around jmp #_OSSILoop ._OSSIExit clr r5 ; R5 = -result sub r5,r3,#0 skz r4 ; use this if signed flag set (result in r3) mov r3,r5,#0 ; mov r0,r3,#0 ; result in R0 mov r1,r6,#0 ; error flag in R1 pop r2,r3,r4,r5,r6,link ret
programs/oeis/017/A017287.asm
neoneye/loda
22
103039
; A017287: a(n) = (10*n + 1)^7. ; 1,19487171,1801088541,27512614111,194754273881,897410677851,3142742836021,9095120158391,22876792454961,51676101935731,107213535210701,207616015289871,379749833583241,662062621900811,1107984764452581,1789940649848551,2804020163098721,4275360817613091,6364290927201661,9273284218074431,13254776280841401,18619893262512571,25748143198497941,35098120384607511,47219273189051281,62764785704439251,82505623639781421,107345794852487791,138338874920368361,176705848153633131,223854314446892101,281399112371155271,351184408905832641,435307306210734211,536143015838069981,656371650784449951,799006685782884121,967425136234782491,1165399506181955061,1397131555718611831,1667287938243362801,1981037757951217971,2344092097965587341,2762745569510280911,3243919932521508681,3795209838099880651,4424930743202406821,5142169047974497191,5956834506121961761,6879714958723010531,7922533441880253501,9098007718612700671,10419912285387762041,11903142903693247611,13563783707049367381,15419176933860731351,17487995336508349521,19790317317081631891,22347704840150388461,25183284172976829231,28321829503567564201,31789849486965603371,35615676770182356741,39829560546169634311,44463762187231646081,49552654008277002051,55132821210310712221,61243167054566186591,67925021317677235161,75222252078290067931,83181380885515294901,91851701359619926071,101285401275359371441,111537688178349441011,122666918584878344781,134734730815558692751,147806181513219494921,161949885895438161291,177238161792112501861,193747177518472726631,211557103633933445601,230752268637185668771,251421318647928806141,273657381125642667711,297558232675799463481,323226470993915803451,350769690997844697621,380300665198707555991,411937528360866188561,445803966501334805331,482029410279032016301,520749232824272831471,562104952058900660841,606244437557459314411,653322121999805002181,703499217265558334151,756943935220796320321,813831713247384370691,874345444565348295261,938675713398686304031 mul $0,10 add $0,1 pow $0,7
experiments/models/addr.als
saiema/ARepair
5
586
/* Specification */ // types (only relations, sigs/universe, preds assumed fix) abstract sig Listing { } sig Address extends Listing { } sig Name extends Listing { } sig Book { entry: set Name, // T1 listed: entry ->set Listing // T2 } fun lookup [b: Book, n: Name] : set Listing {n.^(b.listed)} // constraints // T. type constraints (multiplicity & range restriction) // T1 // set // T2 // A name entry maps to at most one name or address. fact {all b:Book | all n:b.entry | some b.listed[n] } // F. fact constraints // F1 All names reachable from any name entry in the book are themselves entries. fact { all b:Book | all n,l:Name | l in lookup[b,n] implies l in b.entry } // F2 Acyclic fact { all b:Book | all n:b.entry | not n in lookup[b,n] } /* Refinement Task */ // A. assertion (universal statement over constraints; in this case, C1) assert lookupEndsInAddr { all b:Book | all n:b.entry | some (lookup[b,n]&Address) } check lookupEndsInAddr for 4 // P. problem (subset of the universal statement over constraints) // some b:Book | some n:b.entry_in | no (lookup[b,n]&Addr) // F. fix (spec + fix + assert = UNSAT) //fact {all b:Book | all n:b.entry_in | some b.target_of[n]}
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_980.asm
ljhsiun2/medusa
9
174673
<filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_980.asm .global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r9 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x1add2, %rbx nop nop nop cmp $9705, %r15 mov (%rbx), %r11d nop nop nop nop nop sub $61654, %rdi lea addresses_D_ht+0x14dd2, %rbp nop add %rdx, %rdx movups (%rbp), %xmm4 vpextrq $0, %xmm4, %r9 nop nop nop cmp %r9, %r9 lea addresses_normal_ht+0xa452, %rbp nop add %r9, %r9 movups (%rbp), %xmm3 vpextrq $0, %xmm3, %r15 nop nop dec %r9 lea addresses_UC_ht+0x19dd2, %rbx dec %rdi movb (%rbx), %r9b nop and $3708, %rbp lea addresses_WC_ht+0x197d2, %r9 nop nop nop nop nop inc %rbp movups (%r9), %xmm5 vpextrq $0, %xmm5, %rdi nop nop nop nop xor %rbp, %rbp lea addresses_A_ht+0xa26, %rsi lea addresses_A_ht+0xc0d2, %rdi cmp %r15, %r15 mov $67, %rcx rep movsw nop nop sub %r11, %r11 lea addresses_WT_ht+0x29d2, %rsi nop nop cmp $28470, %rdi and $0xffffffffffffffc0, %rsi movaps (%rsi), %xmm3 vpextrq $1, %xmm3, %rbp nop add %r9, %r9 lea addresses_A_ht+0x82f2, %rbx nop inc %rbp mov (%rbx), %dx nop nop nop nop nop xor $7331, %r9 lea addresses_WT_ht+0x515e, %rcx nop nop xor %r9, %r9 and $0xffffffffffffffc0, %rcx movaps (%rcx), %xmm4 vpextrq $0, %xmm4, %rdi nop xor %rdi, %rdi lea addresses_WT_ht+0x1872b, %r15 clflush (%r15) inc %r11 movl $0x61626364, (%r15) nop nop nop nop nop xor $29078, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_WT+0x68cc, %rdi nop nop nop dec %r13 movl $0x51525354, (%rdi) nop xor %r13, %r13 // REPMOV lea addresses_US+0x8e52, %rsi mov $0xcd2, %rdi nop add $52265, %rbx mov $67, %rcx rep movsw nop inc %rdi // Faulty Load lea addresses_RW+0x75d2, %rbp nop nop inc %r10 vmovups (%rbp), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $0, %xmm4, %rcx lea oracles, %rbp and $0xff, %rcx shlq $12, %rcx mov (%rbp,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_US'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_P'}, 'OP': 'REPM'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_RW'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'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/arch/zx/bifrost_l/z80/asm_BIFROSTL_resetAnim4Frames.asm
jpoikela/z88dk
640
10335
; ---------------------------------------------------------------- ; Z88DK INTERFACE LIBRARY FOR THE BIFROST* ENGINE - RELEASE 1.2/L ; ; See "bifrost_l.h" for further details ; ---------------------------------------------------------------- SECTION code_clib SECTION code_bifrost_l PUBLIC asm_BIFROSTL_resetAnim4Frames asm_BIFROSTL_resetAnim4Frames: halt ld a,15 ld (58780),a ld hl,64+(256*7) ld (58782),hl ret
RECTANGLE_AVR/RectangleScenario2CTR/Rectangle128FlashLowF.asm
FreeDisciplina/BlockCiphersOnAVR
12
168420
<filename>RECTANGLE_AVR/RectangleScenario2CTR/Rectangle128FlashLowF.asm .EQU COUNTER_BYTE = 8 .EQU COUNT_NUM_BYTE = (8) .EQU PTEXT_NUM_BYTE = (8*2) #define ENCRYPT ; Registers declarations .def s0 =r0 .def s1 =r1 .def s2 =r2 .def s3 =r3 .def s4 =r4 .def s5 =r5 .def s6 =r6 .def s7 =r7 .def s10 =r8 .def s11 =r9 .def s12 =r10 .def s13 =r11 .def s14 =r12 .def s15 =r13 .def s16 =r14 .def s17 =r15 .def t0 =r16 .def t1 =r17 .def t2 =r18 .def t3 =r19 .def rrn =r20 .def rcnt =r21 .def rzero =r22 .def kt0 =r24 .def kt1 =r25 .def YL =r28 .def YH =r29 .def ZL =r30 .def ZH =r31 ;;;**************************************************************************** ;;; ;;; store_output ;;; .MACRO store_output ld t0, Y eor s0, t0 st Y+, s0 ld t0, Y eor s1, t0 st Y+, s1 ld t0, Y eor s2, t0 st Y+, s2 ld t0, Y eor s3, t0 st Y+, s3 ld t0, Y eor s4, t0 st Y+, s4 ld t0, Y eor s5, t0 st Y+, s5 ld t0, Y eor s6, t0 st Y+, s6 ld t0, Y eor s7, t0 st Y+, s7 .ENDMACRO ;;;**************************************************************************** .MACRO keyxor eor s3, kt0 eor s7, kt1 lpm t0, Z+ eor s0, t0 lpm t0, Z+ eor s2, t0 lpm t0, Z+ eor s4, t0 lpm t0, Z+ eor s6, t0 lpm kt0, Z+ eor s5, kt0 lpm kt1, Z+ eor s1, kt1 .ENDMACRO ;;;**************************************************************************** .MACRO forward_round keyxor ;forward_sbox block0 movw t0, s4 eor s4, s2 eor s5, s3 com s2 com s3 movw t2, s0 and s0, s2 and s1, s3 or s2, s6 or s3, s7 eor s6, t0 eor s7, t1 eor s0, s6 eor s1, s7 eor s2, t2 eor s3, t3 and s6, s2 and s7, s3 eor s6, s4 eor s7, s5 or s4, s0 or s5, s1 eor s4, s2 eor s5, s3 eor s2, t0 eor s3, t1 ;forward_permutation block0 ;rotate16_left_row1 <<< 1 lsl s2 rol s3 adc s2, rzero ;rotate16_left_row2 <<< 12 = >>> 4 swap s4 swap s5 movw t0, s4 eor t1, t0 andi t1, 0xf0 eor s4, t1 eor s5, t1 ;rotate16_left_row3 <<< 13 = >>> 3 = ((>>>4)<<<1) swap s6 swap s7 movw t0, s6 eor t1, t0 andi t1, 0xf0 eor s6, t1 eor s7, t1 lsl s6 rol s7 adc s6, rzero .ENDMACRO .MACRO forward_last_round keyxor .ENDMACRO #ifdef ENCRYPT encrypt: clr rzero ldi XH, high(SRAM_COUNT) ldi XL, low(SRAM_COUNT) ld s0, X+ ld s1, X+ ld s2, X+ ld s3, X+ ld s4, X+ ld s5, X+ ld s6, X+ ld s7, X+ movw s10, s0 movw s12, s2 movw s14, s4 movw s16, s6 inc s17 ldi YH, high(SRAM_PTEXT) ;SRAM_PTEXT ldi YL, low(SRAM_PTEXT) ;SRAM_PTEXT ldi rrn, 1 blocks: ldi rcnt, 25 ldi ZH, high(RK<<1) ldi ZL, low(RK<<1) lpm kt0, Z+ lpm kt1, Z+ encrypt_start: forward_round dec rcnt cpse rcnt, rzero rjmp encrypt_start forward_last_round store_output dec rrn cpse rrn, rzero rjmp encrypt_end movw s0, s10 movw s2, s12 movw s4, s14 movw s6, s16 rjmp blocks encrypt_end: ret ; master key is: 10 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 ; reordered: 0 1 2 3 4 5 6 7 => 3 7 0 2 4 6 5 1 and then remove the duplicated 3 7 inter-round RK: .db 0x0b, 0x03, 0x10, 0x0c, 0x08, 0x04, 0x07, 0x0f .db 0xe3, 0xfb, 0x06, 0x1c, 0x06, 0x17 .db 0xfc, 0x00, 0x1e, 0x1a, 0x09, 0x1d .db 0x19, 0xfd, 0x10, 0xf8, 0x1c, 0xfe .db 0xed, 0x0e, 0xf5, 0xe8, 0x13, 0xe1 .db 0x1c, 0xeb, 0xf0, 0xfc, 0xe2, 0xe0 .db 0xeb, 0xfb, 0x14, 0x18, 0xe5, 0x0b .db 0xed, 0x18, 0xe0, 0x0c, 0xed, 0xee .db 0x0f, 0xfb, 0xf9, 0x09, 0x10, 0xec .db 0xfe, 0xf4, 0x06, 0xf4, 0x06, 0x19 .db 0xe0, 0xfb, 0x02, 0xf8, 0x07, 0xe8 .db 0x08, 0xe7, 0xff, 0xfa, 0x16, 0xfc .db 0xfc, 0xef, 0x12, 0x0d, 0x11, 0x0a .db 0xeb, 0x1e, 0x0e, 0x0f, 0xef, 0x19 .db 0x0e, 0xf4, 0x16, 0xe0, 0xed, 0xf1 .db 0xfe, 0x1b, 0x10, 0xfc, 0xe1, 0x13 .db 0x02, 0x09, 0x10, 0x08, 0x07, 0xe5 .db 0xfb, 0xe7, 0xe3, 0x1a, 0xe1, 0xfb .db 0xe0, 0x04, 0xf5, 0xe1, 0xee, 0xe6 .db 0xe1, 0xee, 0xe0, 0xf4, 0x15, 0x15 .db 0xe0, 0x0b, 0x0a, 0x15, 0xfb, 0xfb .db 0x0a, 0xea, 0x06, 0xff, 0x0c, 0xea .db 0xe1, 0x08, 0x01, 0xf9, 0x12, 0x02 .db 0xfa, 0x07, 0x0d, 0x19, 0xfe, 0x15 .db 0x11, 0xed, 0xe6, 0xec, 0x19, 0xfe .db 0x1e, 0xf4, 0x14, 0x1a, 0x19, 0xe4 #endif
programs/oeis/038/A038665.asm
neoneye/loda
22
3705
<gh_stars>10-100 ; A038665: Convolution of A007054 (super ballot numbers) with A000984 (central binomial coefficients). ; 3,8,25,84,294,1056,3861,14300,53482,201552,764218,2912168,11143500,42791040,164812365,636438060,2463251010,9552774000,37112526990,144410649240,562724141460,2195581527360,8576490341250,33537507830424,131272552839204,514285886020256,2016472976564116,7912438552510800,31069508716192408,122079568066953728,479972989294487997,1888158205819638732,7431764564428508850,29265985517390307504,115302563311570146694,454472338662697232696,1792081368660247952196,7069354511480268056000,27897440240929007815990,110129335775612668570440,434898499440429619762860,1717954916123795534206560,6788406564228840824731500,26831805501277847882049840,106084539141630659442924840,419535778153592322722223360,1659569914102361297435045010,6566394912108468273899595000,25987164504160474040785037172,102869606203320353988436271712,407293640537258768417233256268,1612935015071721801307690545648,6388682930068033883780461523400,25309744209565394401066132527744,100286633146702675646571352930404,397442501815002662857880190930096,1575356218549716262350468033847176,6245307617347338242009899128724800,24762644702782196129569250045393832,98198759804959442646579912300411552,389474061390845905980686093374629168 add $0,1 mov $1,$0 mul $0,2 bin $0,$1 add $1,1 mov $2,$0 div $2,$1 add $2,13 add $0,$2 add $0,2 mul $0,2 sub $0,34 div $0,2 add $0,2
src/helpers.asm
ioncodes/c64-intro
0
4732
clear_screen: lda #$20 ldx #$00 sta $0400,x sta $0500,x sta $0600,x sta $0700,x dex bne *-13 rts clear_color: lda #$03 ldx #$00 sta $d800,x sta $d900,x sta $da00,x sta $db00,x dex bne *-13 rts