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
notes/FOT/FOTC/Program/ABP/StrongerInductionPrinciple/CorrectnessProofATP.agda
asr/fotc
11
290
<filename>notes/FOT/FOTC/Program/ABP/StrongerInductionPrinciple/CorrectnessProofATP.agda ------------------------------------------------------------------------------ -- The alternating bit protocol (ABP) is correct ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- This module proves the correctness of the ABP by simplifing the -- formalization in Dybjer and Sander (1989) using a stronger (maybe -- invalid) co-induction principle. module FOT.FOTC.Program.ABP.StrongerInductionPrinciple.CorrectnessProofATP where open import FOT.FOTC.Relation.Binary.Bisimilarity.Type open import FOT.FOTC.Program.ABP.StrongerInductionPrinciple.LemmaATP open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Stream.Type open import FOTC.Data.Stream.Equality.PropertiesATP open import FOTC.Program.ABP.ABP hiding ( B ) open import FOTC.Program.ABP.Fair.Type open import FOTC.Program.ABP.Terms open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ postulate helper : ∀ b i' is' os₁ os₂ → S b (i' ∷ is') os₁ os₂ (has (send b) (ack b) (out b) (corrupt os₁) (corrupt os₂) (i' ∷ is')) (hbs (send b) (ack b) (out b) (corrupt os₁) (corrupt os₂) (i' ∷ is')) (hcs (send b) (ack b) (out b) (corrupt os₁) (corrupt os₂) (i' ∷ is')) (hds (send b) (ack b) (out b) (corrupt os₁) (corrupt os₂) (i' ∷ is')) (abpTransfer b os₁ os₂ (i' ∷ is')) {-# ATP prove helper #-} -- Main theorem. -- See Issue https://github.com/asr/apia/issues/81 . abpCorrectB : D → D → Set abpCorrectB xs ys = xs ≡ xs {-# ATP definition abpCorrectB #-} abpCorrect : ∀ {b is os₁ os₂} → Bit b → Stream is → Fair os₁ → Fair os₂ → is ≈ abpTransfer b os₁ os₂ is abpCorrect {b} {is} {os₁} {os₂} Bb Sis Fos₁ Fos₂ = ≈-stronger-coind abpCorrectB h refl where postulate h : abpCorrectB is (abpTransfer b os₁ os₂ is) → ∃[ i' ] ∃[ is' ] ∃[ js' ] is ≡ i' ∷ is' ∧ abpTransfer b os₁ os₂ is ≡ i' ∷ js' ∧ abpCorrectB is' js' {-# ATP prove h helper lemma #-} ------------------------------------------------------------------------------ -- abpTransfer produces a Stream. postulate abpTransfer-Stream : ∀ {b is os₁ os₂} → Bit b → Stream is → Fair os₁ → Fair os₂ → Stream (abpTransfer b os₁ os₂ is) {-# ATP prove abpTransfer-Stream ≈→Stream₂ abpCorrect #-} ------------------------------------------------------------------------------ -- References -- -- Dybjer, Peter and Sander, <NAME>. (1989). A Functional -- Programming Approach to the Specification and Verification of -- Concurrent Systems. Formal Aspects of Computing 1, pp. 303–319.
bench/squeeze.asm
dsprenkels/curve13318-ivybridge
2
100700
<reponame>dsprenkels/curve13318-ivybridge<gh_stars>1-10 ; Compare which is faster, two times vaddpd with operands from memory, or one vmovdqa ; and two vaddpd with register operand. ; ; Author: <NAME> <<EMAIL>> %include "bench.asm" section .rodata: _bench1_name: db `squeeze_separate_load\0` _bench2_name: db `squeeze_immediate_load\0` _bench3_name: db `squeeze_noparallel\0` _bench4_name: db `carry_sandy2x\0` _bench5_name: db `squeeze_triple\0` align 8, db 0 _bench_fns_arr: dq bench_squeeze1, bench_squeeze2, bench_squeeze3, bench_carry_sandy2x, bench_squeeze_triple _bench_names_arr: dq _bench1_name, _bench2_name, _bench3_name, _bench4_name, _bench5_name _bench_fns: dq _bench_fns_arr _bench_names: dq _bench_names_arr _bench_fns_n: dd 5 section .text: bench_squeeze1: bench_prologue ; round 1 vmovapd ymm12, yword [rel long_precisionloss0] vmovapd ymm13, yword [rel long_precisionloss6] vaddpd ymm14, ymm0, ymm12 vaddpd ymm15, ymm6, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm1, ymm1, ymm14 vaddpd ymm7, ymm7, ymm15 vsubpd ymm0, ymm0, ymm14 vsubpd ymm6, ymm6, ymm15 ; round 2 vmovapd ymm12, yword [rel long_precisionloss1] vmovapd ymm13, yword [rel long_precisionloss7] vaddpd ymm14, ymm1, ymm12 vaddpd ymm15, ymm7, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm2, ymm2, ymm14 vaddpd ymm8, ymm8, ymm15 vsubpd ymm1, ymm1, ymm14 vsubpd ymm7, ymm7, ymm15 ; round 3 vmovapd ymm12, yword [rel long_precisionloss2] vmovapd ymm13, yword [rel long_precisionloss8] vaddpd ymm14, ymm2, ymm12 vaddpd ymm15, ymm8, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm3, ymm3, ymm14 vaddpd ymm9, ymm9, ymm15 vsubpd ymm2, ymm2, ymm14 vsubpd ymm8, ymm8, ymm15 ; round 4 vmovapd ymm12, yword [rel long_precisionloss3] vmovapd ymm13, yword [rel long_precisionloss9] vaddpd ymm14, ymm3, ymm12 vaddpd ymm15, ymm9, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm4, ymm4, ymm14 vaddpd ymm10, ymm10, ymm15 vsubpd ymm3, ymm3, ymm14 vsubpd ymm9, ymm9, ymm15 ; round 5 vmovapd ymm12, yword [rel long_precisionloss4] vmovapd ymm13, yword [rel long_precisionloss10] vaddpd ymm14, ymm4, ymm12 vaddpd ymm15, ymm10, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm5, ymm5, ymm14 vaddpd ymm11, ymm11, ymm15 vsubpd ymm4, ymm4, ymm14 vsubpd ymm10, ymm10, ymm15 ; round 6 vmovapd ymm12, yword [rel long_precisionloss5] vmovapd ymm13, yword [rel long_precisionloss11] vaddpd ymm14, ymm5, ymm12 vaddpd ymm15, ymm11, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vsubpd ymm5, ymm5, ymm14 vsubpd ymm11, ymm11, ymm15 vmulpd ymm15, ymm15, yword [rel long_reduceconstant] vaddpd ymm6, ymm6, ymm14 vaddpd ymm0, ymm0, ymm15 ; round 7 vmovapd ymm12, yword [rel long_precisionloss6] vmovapd ymm13, yword [rel long_precisionloss0] vaddpd ymm14, ymm6, ymm12 vaddpd ymm15, ymm0, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm7, ymm7, ymm14 vaddpd ymm1, ymm1, ymm15 vsubpd ymm6, ymm6, ymm14 vsubpd ymm0, ymm0, ymm15 ; round 8 vmovapd ymm12, yword [rel long_precisionloss7] vmovapd ymm13, yword [rel long_precisionloss1] vaddpd ymm14, ymm7, ymm12 vaddpd ymm15, ymm1, ymm13 vsubpd ymm14, ymm14, ymm12 vsubpd ymm15, ymm15, ymm13 vaddpd ymm8, ymm8, ymm14 vaddpd ymm2, ymm2, ymm15 vsubpd ymm7, ymm7, ymm14 vsubpd ymm1, ymm1, ymm15 bench_epilogue ret bench_squeeze2: bench_prologue ; round 1 vaddpd ymm14, ymm0, yword [rel long_precisionloss0] vaddpd ymm15, ymm6, yword [rel long_precisionloss6] vsubpd ymm14, ymm14, yword [rel long_precisionloss0] vsubpd ymm15, ymm15, yword [rel long_precisionloss6] vaddpd ymm1, ymm1, ymm14 vaddpd ymm7, ymm7, ymm15 vsubpd ymm0, ymm0, ymm14 vsubpd ymm6, ymm6, ymm15 ; round 2 vaddpd ymm14, ymm1, yword [rel long_precisionloss1] vaddpd ymm15, ymm7, yword [rel long_precisionloss7] vsubpd ymm14, ymm14, yword [rel long_precisionloss1] vsubpd ymm15, ymm15, yword [rel long_precisionloss7] vaddpd ymm2, ymm2, ymm14 vaddpd ymm8, ymm8, ymm15 vsubpd ymm1, ymm1, ymm14 vsubpd ymm7, ymm7, ymm15 ; round 3 vaddpd ymm14, ymm2, yword [rel long_precisionloss2] vaddpd ymm15, ymm8, yword [rel long_precisionloss8] vsubpd ymm14, ymm14, yword [rel long_precisionloss2] vsubpd ymm15, ymm15, yword [rel long_precisionloss8] vaddpd ymm3, ymm3, ymm14 vaddpd ymm9, ymm9, ymm15 vsubpd ymm2, ymm2, ymm14 vsubpd ymm8, ymm8, ymm15 ; round 4 vaddpd ymm14, ymm3, yword [rel long_precisionloss3] vaddpd ymm15, ymm9, yword [rel long_precisionloss9] vsubpd ymm14, ymm14, yword [rel long_precisionloss3] vsubpd ymm15, ymm15, yword [rel long_precisionloss9] vaddpd ymm4, ymm4, ymm14 vaddpd ymm10, ymm10, ymm15 vsubpd ymm3, ymm3, ymm14 vsubpd ymm9, ymm9, ymm15 ; round 5 vaddpd ymm14, ymm4, yword [rel long_precisionloss4] vaddpd ymm15, ymm10, yword [rel long_precisionloss10] vsubpd ymm14, ymm14, yword [rel long_precisionloss4] vsubpd ymm15, ymm15, yword [rel long_precisionloss10] vaddpd ymm5, ymm5, ymm14 vaddpd ymm11, ymm11, ymm15 vsubpd ymm4, ymm4, ymm14 vsubpd ymm10, ymm10, ymm15 ; round 6 vaddpd ymm14, ymm5, yword [rel long_precisionloss5] vaddpd ymm15, ymm11, yword [rel long_precisionloss11] vsubpd ymm14, ymm14, yword [rel long_precisionloss5] vsubpd ymm15, ymm15, yword [rel long_precisionloss11] vsubpd ymm5, ymm5, ymm14 vsubpd ymm11, ymm11, ymm15 vmulpd ymm15, ymm15, yword [rel long_reduceconstant] vaddpd ymm6, ymm6, ymm14 vaddpd ymm0, ymm0, ymm15 ; round 7 vaddpd ymm14, ymm6, yword [rel long_precisionloss6] vaddpd ymm15, ymm0, yword [rel long_precisionloss0] vsubpd ymm14, ymm14, yword [rel long_precisionloss6] vsubpd ymm15, ymm15, yword [rel long_precisionloss0] vaddpd ymm7, ymm7, ymm14 vaddpd ymm1, ymm1, ymm15 vsubpd ymm6, ymm6, ymm14 vsubpd ymm0, ymm0, ymm15 ; round 8 vaddpd ymm14, ymm7, yword [rel long_precisionloss7] vaddpd ymm15, ymm1, yword [rel long_precisionloss1] vsubpd ymm14, ymm14, yword [rel long_precisionloss7] vsubpd ymm15, ymm15, yword [rel long_precisionloss1] vaddpd ymm8, ymm8, ymm14 vaddpd ymm2, ymm2, ymm15 vsubpd ymm7, ymm7, ymm14 vsubpd ymm1, ymm1, ymm15 bench_epilogue ret bench_squeeze3: bench_prologue ; round 1 vmovapd ymm14, yword [rel long_precisionloss0] vaddpd ymm15, ymm0, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm1, ymm1, ymm15 vsubpd ymm0, ymm0, ymm15 vmovapd ymm14, yword [rel long_precisionloss6] vaddpd ymm15, ymm6, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm7, ymm7, ymm15 vsubpd ymm6, ymm6, ymm15 ; round 2 vmovapd ymm14, yword [rel long_precisionloss1] vaddpd ymm15, ymm1, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm2, ymm2, ymm15 vsubpd ymm1, ymm1, ymm15 vmovapd ymm14, yword [rel long_precisionloss7] vaddpd ymm15, ymm7, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm8, ymm8, ymm15 vsubpd ymm7, ymm7, ymm15 ; round 3 vmovapd ymm14, yword [rel long_precisionloss2] vaddpd ymm15, ymm2, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm3, ymm3, ymm15 vsubpd ymm2, ymm2, ymm15 vmovapd ymm14, yword [rel long_precisionloss8] vaddpd ymm15, ymm8, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm9, ymm9, ymm15 vsubpd ymm8, ymm8, ymm15 ; round 4 vmovapd ymm14, yword [rel long_precisionloss3] vaddpd ymm15, ymm3, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm4, ymm4, ymm15 vsubpd ymm3, ymm3, ymm15 vmovapd ymm14, yword [rel long_precisionloss9] vaddpd ymm15, ymm9, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm10, ymm10, ymm15 vsubpd ymm9, ymm9, ymm15 ; round 5 vmovapd ymm14, yword [rel long_precisionloss4] vaddpd ymm15, ymm4, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm5, ymm5, ymm15 vsubpd ymm4, ymm4, ymm15 vmovapd ymm14, yword [rel long_precisionloss10] vaddpd ymm15, ymm10, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm11, ymm11, ymm15 vsubpd ymm10, ymm10, ymm15 ; round 6 vmovapd ymm14, yword [rel long_precisionloss5] vaddpd ymm15, ymm5, ymm14 vsubpd ymm15, ymm15, ymm14 vsubpd ymm5, ymm5, ymm15 vaddpd ymm6, ymm6, ymm15 vmovapd ymm14, yword [rel long_precisionloss11] vaddpd ymm15, ymm11, ymm14 vsubpd ymm15, ymm15, ymm14 vsubpd ymm11, ymm11, ymm15 vmulpd ymm15, ymm15, yword [rel long_reduceconstant] vaddpd ymm0, ymm0, ymm15 ; round 7 vmovapd ymm14, yword [rel long_precisionloss6] vaddpd ymm15, ymm6, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm7, ymm7, ymm15 vsubpd ymm6, ymm6, ymm15 vmovapd ymm14, yword [rel long_precisionloss0] vaddpd ymm15, ymm0, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm1, ymm1, ymm15 vsubpd ymm0, ymm0, ymm15 ; round 8 vmovapd ymm14, yword [rel long_precisionloss7] vaddpd ymm14, ymm7, ymm14 vsubpd ymm14, ymm14, ymm14 vaddpd ymm8, ymm8, ymm14 vsubpd ymm7, ymm7, ymm14 vmovapd ymm14, yword [rel long_precisionloss1] vaddpd ymm15, ymm1, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd ymm2, ymm2, ymm15 vsubpd ymm1, ymm1, ymm15 bench_epilogue ret section .rodata: align 8, db 0 short_precisionloss0: dq 0x3p73 short_precisionloss1: dq 0x3p94 short_precisionloss2: dq 0x3p115 short_precisionloss3: dq 0x3p136 short_precisionloss4: dq 0x3p158 short_precisionloss5: dq 0x3p179 short_precisionloss6: dq 0x3p200 short_precisionloss7: dq 0x3p221 short_precisionloss8: dq 0x3p243 short_precisionloss9: dq 0x3p264 short_precisionloss10: dq 0x3p285 short_precisionloss11: dq 0x3p306 short_reduceconstant: dq 0x13p-255 align 32, db 0 long_precisionloss0: times 4 dq 0x3p73 long_precisionloss1: times 4 dq 0x3p94 long_precisionloss2: times 4 dq 0x3p115 long_precisionloss3: times 4 dq 0x3p136 long_precisionloss4: times 4 dq 0x3p158 long_precisionloss5: times 4 dq 0x3p179 long_precisionloss6: times 4 dq 0x3p200 long_precisionloss7: times 4 dq 0x3p221 long_precisionloss8: times 4 dq 0x3p243 long_precisionloss9: times 4 dq 0x3p264 long_precisionloss10: times 4 dq 0x3p285 long_precisionloss11: times 4 dq 0x3p306 long_reduceconstant: times 4 dq 0x13p-255 section .text: bench_carry_sandy2x: bench_prologue ; qhasm: 2x carry5 = h5 unsigned>>= 25 ; asm 1: vpsrlq $25,<h5=reg128#5,>carry5=reg128#4 ; asm 2: vpsrlq $25,<h5=%xmm4,>carry5=%xmm3 vpsrlq xmm3, xmm4, 25 ; qhasm: 2x h6 += carry5 ; asm 1: paddq <carry5=reg128#4,<h6=reg128#7 ; asm 2: paddq <carry5=%xmm3,<h6=%xmm6 paddq xmm6, xmm3 ; qhasm: h5 &= mem128[ m25 ] ; asm 1: pand m25,<h5=reg128#5 ; asm 2: pand m25,<h5=%xmm4 pand xmm4, [rel m25] ; qhasm: 2x carry0 = h0 unsigned>>= 26 ; asm 1: vpsrlq $26,<h0=reg128#12,>carry0=reg128#4 ; asm 2: vpsrlq $26,<h0=%xmm11,>carry0=%xmm3 vpsrlq xmm3, xmm11, 26 ; qhasm: 2x h1 += carry0 ; asm 1: paddq <carry0=reg128#4,<h1=reg128#14 ; asm 2: paddq <carry0=%xmm3,<h1=%xmm13 paddq xmm13, xmm3 ; qhasm: h0 &= mem128[ m26 ] ; asm 1: pand m26,<h0=reg128#12 ; asm 2: pand m26,<h0=%xmm11 pand xmm11, [rel m26] ; qhasm: 2x carry6 = h6 unsigned>>= 26 ; asm 1: vpsrlq $26,<h6=reg128#7,>carry6=reg128#4 ; asm 2: vpsrlq $26,<h6=%xmm6,>carry6=%xmm3 vpsrlq xmm3, xmm6, 26 ; qhasm: 2x h7 += carry6 ; asm 1: paddq <carry6=reg128#4,<h7=reg128#6 ; asm 2: paddq <carry6=%xmm3,<h7=%xmm5 paddq xmm5, xmm3 ; qhasm: h6 &= mem128[ m26 ] ; asm 1: pand m26,<h6=reg128#7 ; asm 2: pand m26,<h6=%xmm6 pand xmm6, [rel m26] ; qhasm: 2x carry1 = h1 unsigned>>= 25 ; asm 1: vpsrlq $25,<h1=reg128#14,>carry1=reg128#4 ; asm 2: vpsrlq $25,<h1=%xmm13,>carry1=%xmm3 vpsrlq xmm3, xmm13, 25 ; qhasm: 2x h2 += carry1 ; asm 1: paddq <carry1=reg128#4,<h2=reg128#1 ; asm 2: paddq <carry1=%xmm3,<h2=%xmm0 paddq xmm0, xmm3 ; qhasm: h1 &= mem128[ m25 ] ; asm 1: pand m25,<h1=reg128#14 ; asm 2: pand m25,<h1=%xmm13 pand xmm13, [rel m25] ; qhasm: 2x carry7 = h7 unsigned>>= 25 ; asm 1: vpsrlq $25,<h7=reg128#6,>carry7=reg128#4 ; asm 2: vpsrlq $25,<h7=%xmm5,>carry7=%xmm3 vpsrlq xmm3, xmm5, 25 ; qhasm: 2x h8 += carry7 ; asm 1: paddq <carry7=reg128#4,<h8=reg128#9 ; asm 2: paddq <carry7=%xmm3,<h8=%xmm8 paddq xmm8, xmm3 ; qhasm: h7 &= mem128[ m25 ] ; asm 1: pand m25,<h7=reg128#6 ; asm 2: pand m25,<h7=%xmm5 pand xmm5, [rel m25] ; qhasm: 2x carry2 = h2 unsigned>>= 26 ; asm 1: vpsrlq $26,<h2=reg128#1,>carry2=reg128#4 ; asm 2: vpsrlq $26,<h2=%xmm0,>carry2=%xmm3 vpsrlq xmm3, xmm0, 26 ; qhasm: 2x h3 += carry2 ; asm 1: paddq <carry2=reg128#4,<h3=reg128#3 ; asm 2: paddq <carry2=%xmm3,<h3=%xmm2 paddq xmm2, xmm3 ; qhasm: h2 &= mem128[ m26 ] ; asm 1: pand m26,<h2=reg128#1 ; asm 2: pand m26,<h2=%xmm0 pand xmm0, [rel m26] ; qhasm: 2x carry8 = h8 unsigned>>= 26 ; asm 1: vpsrlq $26,<h8=reg128#9,>carry8=reg128#4 ; asm 2: vpsrlq $26,<h8=%xmm8,>carry8=%xmm3 vpsrlq xmm3, xmm8, 26 ; qhasm: 2x h9 += carry8 ; asm 1: paddq <carry8=reg128#4,<h9=reg128#8 ; asm 2: paddq <carry8=%xmm3,<h9=%xmm7 paddq xmm7, xmm3 ; qhasm: h8 &= mem128[ m26 ] ; asm 1: pand m26,<h8=reg128#9 ; asm 2: pand m26,<h8=%xmm8 pand xmm8, [rel m26] ; qhasm: 2x carry3 = h3 unsigned>>= 25 ; asm 1: vpsrlq $25,<h3=reg128#3,>carry3=reg128#4 ; asm 2: vpsrlq $25,<h3=%xmm2,>carry3=%xmm3 vpsrlq xmm3, xmm2, 25 ; qhasm: 2x h4 += carry3 ; asm 1: paddq <carry3=reg128#4,<h4=reg128#2 ; asm 2: paddq <carry3=%xmm3,<h4=%xmm1 paddq xmm1, xmm3 ; qhasm: h3 &= mem128[ m25 ] ; asm 1: pand m25,<h3=reg128#3 ; asm 2: pand m25,<h3=%xmm2 pand xmm2, [rel m25] ; qhasm: 2x carry9 = h9 unsigned>>= 25 ; asm 1: vpsrlq $25,<h9=reg128#8,>carry9=reg128#4 ; asm 2: vpsrlq $25,<h9=%xmm7,>carry9=%xmm3 vpsrlq xmm3, xmm7, 25 ; qhasm: 2x r0 = carry9 << 4 ; asm 1: vpsllq $4,<carry9=reg128#4,>r0=reg128#10 ; asm 2: vpsllq $4,<carry9=%xmm3,>r0=%xmm9 vpsllq xmm9, xmm3, 4 ; qhasm: 2x h0 += carry9 ; asm 1: paddq <carry9=reg128#4,<h0=reg128#12 ; asm 2: paddq <carry9=%xmm3,<h0=%xmm11 paddq xmm11, xmm3 ; qhasm: 2x carry9 <<= 1 ; asm 1: psllq $1,<carry9=reg128#4 ; asm 2: psllq $1,<carry9=%xmm3 psllq xmm3, 1 ; qhasm: 2x r0 += carry9 ; asm 1: paddq <carry9=reg128#4,<r0=reg128#10 ; asm 2: paddq <carry9=%xmm3,<r0=%xmm9 paddq xmm9, xmm3 ; qhasm: 2x h0 += r0 ; asm 1: paddq <r0=reg128#10,<h0=reg128#12 ; asm 2: paddq <r0=%xmm9,<h0=%xmm11 paddq xmm11, xmm9 ; qhasm: h9 &= mem128[ m25 ] ; asm 1: pand m25,<h9=reg128#8 ; asm 2: pand m25,<h9=%xmm7 pand xmm7, [rel m25] ; qhasm: 2x carry4 = h4 unsigned>>= 26 ; asm 1: vpsrlq $26,<h4=reg128#2,>carry4=reg128#4 ; asm 2: vpsrlq $26,<h4=%xmm1,>carry4=%xmm3 vpsrlq xmm3, xmm1, 26 ; qhasm: 2x h5 += carry4 ; asm 1: paddq <carry4=reg128#4,<h5=reg128#5 ; asm 2: paddq <carry4=%xmm3,<h5=%xmm4 paddq xmm4, xmm3 ; qhasm: h4 &= mem128[ m26 ] ; asm 1: pand m26,<h4=reg128#2 ; asm 2: pand m26,<h4=%xmm1 pand xmm1, [rel m26] ; qhasm: 2x carry0 = h0 unsigned>>= 26 ; asm 1: vpsrlq $26,<h0=reg128#12,>carry0=reg128#4 ; asm 2: vpsrlq $26,<h0=%xmm11,>carry0=%xmm3 vpsrlq xmm3, xmm11, 26 ; qhasm: 2x h1 += carry0 ; asm 1: paddq <carry0=reg128#4,<h1=reg128#14 ; asm 2: paddq <carry0=%xmm3,<h1=%xmm13 paddq xmm13, xmm3 ; qhasm: h0 &= mem128[ m26 ] ; asm 1: pand m26,<h0=reg128#12 ; asm 2: pand m26,<h0=%xmm11 pand xmm11, [rel m26] ; qhasm: 2x carry5 = h5 unsigned>>= 25 ; asm 1: vpsrlq $25,<h5=reg128#5,>carry5=reg128#4 ; asm 2: vpsrlq $25,<h5=%xmm4,>carry5=%xmm3 vpsrlq xmm3, xmm4, 25 ; qhasm: 2x h6 += carry5 ; asm 1: paddq <carry5=reg128#4,<h6=reg128#7 ; asm 2: paddq <carry5=%xmm3,<h6=%xmm6 paddq xmm6, xmm3 ; qhasm: h5 &= mem128[ m25 ] ; asm 1: pand m25,<h5=reg128#5 ; asm 2: pand m25,<h5=%xmm4 pand xmm4, [rel m25] bench_epilogue ret section .rodata: align 4, db 0 m25: dq 33554431, 33554431 m26: dq 67108863, 67108863 section .text: %macro .carrystep 3 ; Arguments: ; %1: carry to this register ; %2: carry from this register ; %3: this label contains the precisionloss value vmovapd ymm14, yword [rel %3] vaddpd ymm15, %2, ymm14 vsubpd ymm15, ymm15, ymm14 vaddpd %1, %1, ymm15 vsubpd %2, %2, ymm15 %endmacro bench_squeeze_triple: ; Interleave three carry chains (5 rounds): ; ; - a: z[0] -> z[1] -> z[2] -> z[3] -> z[4] -> z[5] ; - b: z[4] -> z[5] -> z[6] -> z[7] -> z[8] -> z[9] ; - c: z[8] -> z[9] -> z[10] -> z[11] -> z[0] -> z[1] ; ; Input: one vectorized field element (ymm0..ymm11) ; Output: one vectorized field element (ymm0..ymm11) ; ; Precondition: ; - For all limbs x in z : |x| <= 0.99 * 2^53 ; ; Postcondition: ; - All significands fit in b + 1 bits (b = 22, 21, 21, etc.) ; ; Registers: ; - ymm0..ymm11: four input and output field elments ; - ymm14,ymm14: large values to force precision loss ; - ymm14,ymm15: two temporary registers for t0 and t1 bench_prologue ; round 1 .carrystep ymm1, ymm0, .precisionloss0 .carrystep ymm5, ymm4, .precisionloss4 .carrystep ymm9, ymm8, .precisionloss8 ; round 2 .carrystep ymm2, ymm1, .precisionloss1 .carrystep ymm6, ymm5, .precisionloss5 .carrystep ymm10, ymm9, .precisionloss9 ; round 3 .carrystep ymm3, ymm2, .precisionloss2 .carrystep ymm7, ymm6, .precisionloss6 .carrystep ymm11, ymm10, .precisionloss10 ; round 4 .carrystep ymm4, ymm3, .precisionloss3 .carrystep ymm8, ymm7, .precisionloss7 vmovapd ymm14, yword [rel .precisionloss11] vaddpd ymm15, ymm11, ymm14 vsubpd ymm15, ymm15, ymm14 vmovapd ymm14, yword [rel .reduceconstant] vmulpd ymm14, ymm15, ymm14 vaddpd ymm0, ymm0, ymm14 vsubpd ymm11, ymm11, ymm15 ; round 5 .carrystep ymm5, ymm4, .precisionloss4 .carrystep ymm9, ymm8, .precisionloss8 .carrystep ymm1, ymm0, .precisionloss0 bench_epilogue ret section .rodata: align 32, db 0 .precisionloss0: times 4 dq 0x3p73 .precisionloss1: times 4 dq 0x3p94 .precisionloss2: times 4 dq 0x3p115 .precisionloss3: times 4 dq 0x3p136 .precisionloss4: times 4 dq 0x3p158 .precisionloss5: times 4 dq 0x3p179 .precisionloss6: times 4 dq 0x3p200 .precisionloss7: times 4 dq 0x3p221 .precisionloss8: times 4 dq 0x3p243 .precisionloss9: times 4 dq 0x3p264 .precisionloss10: times 4 dq 0x3p285 .precisionloss11: times 4 dq 0x3p306 .reduceconstant: times 4 dq 0x13p-255
alloy4fun_models/trashltl/models/4/8D4hvDb6bgBsmZ4uD.als
Kaixi26/org.alloytools.alloy
0
4483
<filename>alloy4fun_models/trashltl/models/4/8D4hvDb6bgBsmZ4uD.als open main pred id8D4hvDb6bgBsmZ4uD_prop5 { some File after eventually no File } pred __repair { id8D4hvDb6bgBsmZ4uD_prop5 } check __repair { id8D4hvDb6bgBsmZ4uD_prop5 <=> prop5o }
bb-runtimes/runtimes/ravenscar-sfp-stm32g474/gnarl/s-bbtiev.ads
JCGobbi/Nucleo-STM32G474RE
0
866
<reponame>JCGobbi/Nucleo-STM32G474RE ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . T I M I N G _ E V E N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2011-2021, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with System.BB.Time; with System.Multiprocessors; package System.Bb.Timing_Events is pragma Preelaborate; type Timing_Event is tagged limited private; type Timing_Event_Handler is access procedure (Event : in out Timing_Event'Class); type Timing_Event_Access is access all Timing_Event; procedure Set_Handler (Event : in out Timing_Event; At_Time : System.BB.Time.Time; Handler : Timing_Event_Handler); -- Associate the handler Handler with the event Event: if Handler is null -- the event is cleared; otherwise, it is set, and the execution time for -- the event to be At_Time. -- -- A call of a procedure Set_Handler for an event that is already set -- replaces the handler and the time of execution; if Handler is not null, -- the event remains set. procedure Cancel_Handler (Event : in out Timing_Event; Cancelled : out Boolean); -- Clear the event if it is set. Cancelled is assigned True if the event -- was set prior to it being cleared; otherwise, it is assigned False. function Time_Of_Event (Event : Timing_Event) return System.BB.Time.Time; -- Return the time of the event if the event is set, Time'First otherwise function Get_Next_Timeout (CPU_Id : System.Multiprocessors.CPU) return System.BB.Time.Time; pragma Inline (Get_Next_Timeout); -- Return the next expiration time for all timing events associated with -- CPU_Id. Return Time'Last if no timing event is pending for CPU_Id. procedure Execute_Expired_Timing_Events (Now : System.BB.Time.Time); -- Execute all timing events whose expiration time is before Now private type Timing_Event is tagged limited record Timeout : System.BB.Time.Time := System.BB.Time.Time'First; -- The time at which the user's handler should be invoked when the event -- is "set" (i.e., when Handler is not null). Handler : Timing_Event_Handler := null; -- An access value designating the protected procedure to be invoked at -- the Timeout time in the future. When this value is null the event is -- said to be "cleared" and no timeout is processed. Next : Timing_Event_Access := null; -- Next event in the list Prev : Timing_Event_Access := null; -- Previous event in the list CPU : System.Multiprocessors.CPU; -- Owner of the timing event end record; end System.BB.Timing_Events;
programs/oeis/004/A004695.asm
jmorken/loda
1
91040
; A004695: a(n) = floor(Fibonacci(n)/2). ; 0,0,0,1,1,2,4,6,10,17,27,44,72,116,188,305,493,798,1292,2090,3382,5473,8855,14328,23184,37512,60696,98209,158905,257114,416020,673134,1089154,1762289,2851443,4613732,7465176,12078908,19544084,31622993,51167077,82790070,133957148,216747218,350704366,567451585,918155951,1485607536,2403763488,3889371024,6293134512,10182505537,16475640049,26658145586,43133785636,69791931222,112925716858,182717648081,295643364939,478361013020,774004377960,1252365390980,2026369768940,3278735159921,5305104928861,8583840088782,13888945017644,22472785106426,36361730124070,58834515230497,95196245354567,154030760585064,249227005939632,403257766524696,652484772464328,1055742538989025,1708227311453353,2763969850442378,4472197161895732,7236167012338110 mov $2,1 lpb $0 sub $0,1 add $3,$2 mov $2,$5 mov $5,$3 lpe mov $1,1 add $1,$3 sub $1,1 gcd $4,2 add $1,$4 sub $1,2 div $1,2
source/library/program-directory_unit_schemas.ads
reznikmm/gela
0
7282
<reponame>reznikmm/gela -- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Unit_Naming; private with Ada.Strings.Wide_Wide_Unbounded; package Program.Directory_Unit_Schemas is pragma Preelaborate; type Directory_Unit_Schema (Base_Name : Program.Unit_Naming.Unit_Naming_Schema_Access) is new Program.Unit_Naming.Unit_Naming_Schema with private; -- This object returns full file name. It uses Base_Name to find a base -- file name. It looks into a current directory if Add_Directory -- was never called. Otherwise it looks given Path only. procedure Add_Directory (Self : in out Directory_Unit_Schema; Path : Program.Text); -- Add the Path to directory search list. private type Directory_Unit_Schema_Access is access all Directory_Unit_Schema; type Directory_Unit_Schema (Base_Name : Program.Unit_Naming.Unit_Naming_Schema_Access) is new Program.Unit_Naming.Unit_Naming_Schema with record Path : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; Next : Directory_Unit_Schema_Access; end record; overriding function Standard_Text_Name (Self : Directory_Unit_Schema) return Program.Text; -- Get compilation Text_Name for Standard library package. overriding function Declaration_Text_Name (Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text; -- Get compilation Text_Name for given library declaration unit. overriding function Body_Text_Name (Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text; -- Get compilation Text_Name for given body. overriding function Subunit_Text_Name (Self : Directory_Unit_Schema; Name : Program.Text) return Program.Text; end Program.Directory_Unit_Schemas;
3-mid/opengl/source/lean/text/opengl-glyph-container.ads
charlie5/lace
20
21922
with freetype.Face, freetype.charMap; private with ada.Containers.Vectors; package openGL.Glyph.Container -- -- Contains the post processed Glyph objects. -- is type Item is tagged private; type Glyph_view is access all Glyph.item'Class; --------- -- Forge -- function to_glyph_Container (parent_Face : in freetype.Face.view) return glyph.Container.item; -- -- parent_Face: The Freetype face. procedure destruct (Self : in out Item); -------------- -- Attributes -- function CharMap (Self : access Item; Encoding : in freeType_c.FT_Encoding) return Boolean; -- -- Sets the character map for the face. -- -- Encoding: The Freetype encoding symbol. -- -- Returns True if charmap was valid and set correctly. function FontIndex (Self : in Item; Character : in freetype.charMap.characterCode) return Natural; -- -- Get the font index of the input character. -- -- Character: The character code of the requested glyph in the current encoding (eg apple roman). -- -- Returns the font index for the character. procedure add (Self : in out Item; Glyph : in Glyph_view; Character : in freetype.charMap.characterCode); -- -- Adds a glyph to this glyph list. -- -- Glyph: The FTGlyph to be inserted into the container. -- Character: The char code of the glyph NOT the glyph index. function Glyph (Self : in Item; Character : in freetype.charMap.characterCode) return Glyph_view; -- -- Get a glyph from the glyph list. -- -- Character: The char code of the glyph NOT the glyph index. -- -- Returns a Glyph or null is it hasn't been loaded. function BBox (Self : in Item; Character : in freetype.charMap.characterCode) return Bounds; -- -- Get the bounding box for a character. -- -- Character: The char code of the glyph NOT the glyph index. function Advance (Self : in Item; Character : in freetype.charMap.characterCode; nextCharacterCode : in freetype.charMap.characterCode) return Real; -- -- Character: Glyph index of the character. -- nextCharacterCode: The next glyph in a string. -- -- Returns the kerned advance width for a glyph. function Error (Self : in Item) return freetype_c.FT_Error; -- -- Queries the glyph container for errors. -- -- Returns the current error code. -------------- -- Operations -- function render (Self : access Item; Character : in freetype.charMap.characterCode; nextCharacterCode : in freetype.charMap.characterCode; penPosition : in Vector_3; renderMode : in Integer) return Vector_3; -- -- Renders a character. -- -- Character: The glyph to be Rendered. -- nextCharacterCode: The next glyph in the string. Used for kerning. -- penPosition: The position to Render the glyph. -- renderMode: Render mode to display. -- -- Returns the distance to advance the pen position after rendering, private type charMap_view is access all freetype.charMap.item'class; package glyph_Vectors is new ada.Containers.Vectors (Positive, Glyph_view); type Item is tagged record Face : freetype.Face.view; -- The FTGL face. charMap : charMap_view; -- The character map object associated with the current face. Glyphs : glyph_Vectors.Vector; -- A structure to hold the glyphs. Err : freeType_c.FT_Error; -- Current error code. Zero means no error. end record; end openGL.Glyph.Container;
libsrc/_DEVELOPMENT/alloc/obstack/c/sccz80/obstack_grow0.asm
teknoplop/z88dk
8
176256
; int obstack_grow0(struct obstack *ob, void *data, size_t size) SECTION code_clib SECTION code_alloc_obstack PUBLIC obstack_grow0 EXTERN asm_obstack_grow0 obstack_grow0: pop af pop bc pop de pop hl push hl push de push bc push af jp asm_obstack_grow0
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca.log_65_1528.asm
ljhsiun2/medusa
9
14639
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x13380, %rax nop nop nop dec %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm1 movups %xmm1, (%rax) nop nop nop nop nop sub %r12, %r12 lea addresses_WT_ht+0x51c0, %r9 nop nop dec %r10 mov $0x6162636465666768, %r11 movq %r11, %xmm6 movups %xmm6, (%r9) nop nop nop inc %r12 lea addresses_A_ht+0x180c0, %rsi lea addresses_A_ht+0x7cbb, %rdi cmp %rax, %rax mov $118, %rcx rep movsw nop and %rsi, %rsi lea addresses_A_ht+0x186c0, %r9 nop nop inc %rdi mov $0x6162636465666768, %r11 movq %r11, %xmm4 movups %xmm4, (%r9) nop cmp %r12, %r12 lea addresses_UC_ht+0x14320, %rsi xor $17196, %rdi mov (%rsi), %rax nop nop nop nop xor $59454, %r11 lea addresses_A_ht+0xe724, %rsi lea addresses_WT_ht+0xbec0, %rdi nop cmp %rax, %rax mov $30, %rcx rep movsw nop nop inc %rdi lea addresses_A_ht+0x2f40, %rsi lea addresses_UC_ht+0xe6c0, %rdi nop nop nop nop and $10469, %r11 mov $86, %rcx rep movsl nop nop nop nop xor $19228, %rdi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r14 push %r15 push %rax push %rdi // Store mov $0x980, %rax nop nop nop nop and $21212, %rdi movb $0x51, (%rax) nop nop nop cmp %r12, %r12 // Store lea addresses_A+0x1ab20, %rax nop nop inc %r11 mov $0x5152535455565758, %r14 movq %r14, %xmm4 movups %xmm4, (%rax) nop nop nop nop nop sub $63119, %r15 // Store lea addresses_PSE+0x8360, %rdi nop nop nop nop nop and $62139, %r11 mov $0x5152535455565758, %rax movq %rax, %xmm4 movaps %xmm4, (%rdi) nop nop and $10799, %r14 // Load mov $0x9f0, %r14 nop nop nop nop nop sub $47539, %rax vmovups (%r14), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %r10 nop nop nop nop nop xor $50328, %rax // Load lea addresses_WT+0x1e4c0, %r15 xor %r14, %r14 movb (%r15), %r11b cmp %r12, %r12 // Load lea addresses_UC+0x1b8c0, %rax clflush (%rax) nop xor %r14, %r14 movups (%rax), %xmm3 vpextrq $0, %xmm3, %r11 xor $25480, %r10 // Store lea addresses_PSE+0xfcc0, %r14 nop add $37768, %r12 mov $0x5152535455565758, %r11 movq %r11, (%r14) nop nop nop nop xor $37487, %r11 // Store mov $0x41cd3b0000000640, %rax cmp %r15, %r15 movw $0x5152, (%rax) nop nop inc %r15 // Store lea addresses_normal+0xb4c0, %r15 nop nop nop nop cmp %rax, %rax movw $0x5152, (%r15) sub $5260, %rax // Load lea addresses_WT+0xcdc0, %rdi nop nop nop cmp %r11, %r11 mov (%rdi), %r15 sub %r15, %r15 // Load lea addresses_WC+0x148c0, %r10 nop nop nop nop cmp %r15, %r15 movups (%r10), %xmm6 vpextrq $0, %xmm6, %r11 xor $44563, %rax // Faulty Load lea addresses_normal+0xb4c0, %rdi and $17582, %r10 mov (%rdi), %r12w lea oracles, %r15 and $0xff, %r12 shlq $12, %r12 mov (%r15,%r12,1), %r12 pop %rdi pop %rax pop %r15 pop %r14 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': True, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}, 'dst': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 9}} {'52': 65} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
Univalence/Pi0Semiring.agda
JacquesCarette/pi-dual
14
449
{-# OPTIONS --without-K #-} module Pi0Semiring where import Level open import PiU open import PiLevel0 open import Algebra using (CommutativeSemiring) open import Algebra.Structures using (IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring) ------------------------------------------------------------------------------ -- Commutative semiring structure of U typesPlusIsSG : IsSemigroup _⟷_ PLUS typesPlusIsSG = record { isEquivalence = record { refl = id⟷ ; sym = ! ; trans = _◎_ } ; assoc = λ t₁ t₂ t₃ → assocr₊ {t₁} {t₂} {t₃} ; ∙-cong = _⊕_ } typesTimesIsSG : IsSemigroup _⟷_ TIMES typesTimesIsSG = record { isEquivalence = record { refl = id⟷ ; sym = ! ; trans = _◎_ } ; assoc = λ t₁ t₂ t₃ → assocr⋆ {t₁} {t₂} {t₃} ; ∙-cong = _⊗_ } typesPlusIsCM : IsCommutativeMonoid _⟷_ PLUS ZERO typesPlusIsCM = record { isSemigroup = typesPlusIsSG ; identityˡ = λ t → unite₊l {t} ; comm = λ t₁ t₂ → swap₊ {t₁} {t₂} } typesTimesIsCM : IsCommutativeMonoid _⟷_ TIMES ONE typesTimesIsCM = record { isSemigroup = typesTimesIsSG ; identityˡ = λ t → unite⋆l {t} ; comm = λ t₁ t₂ → swap⋆ {t₁} {t₂} } typesIsCSR : IsCommutativeSemiring _⟷_ PLUS TIMES ZERO ONE typesIsCSR = record { +-isCommutativeMonoid = typesPlusIsCM ; *-isCommutativeMonoid = typesTimesIsCM ; distribʳ = λ t₁ t₂ t₃ → dist {t₂} {t₃} {t₁} ; zeroˡ = λ t → absorbr {t} } typesCSR : CommutativeSemiring Level.zero Level.zero typesCSR = record { Carrier = U ; _≈_ = _⟷_ ; _+_ = PLUS ; _*_ = TIMES ; 0# = ZERO ; 1# = ONE ; isCommutativeSemiring = typesIsCSR } ------------------------------------------------------------------------------
LPS/Esercizi/26.04.2022_compito/es5.asm
Giacomix02/esercitazioni-java
3
170181
#specifica 3 MIPS .text li $s0,0x12 li $s1,0xb6 and $s0,$s0,$s1 #GIUSTO!
test/fail/RewriteRelationNotEnoughArguments.agda
larrytheliquid/agda
1
9786
-- 2014-05-27 Jesper and Andreas postulate A : Set {-# BUILTIN REWRITE A #-} -- Expected error: -- A does not have the right type for a rewriting relation -- because it should accept at least two arguments -- when checking the pragma BUILTIN REWRITE A
wtbeep/music.asm
bushy555/ZX-Spectrum-1-Bit-Routines
59
175832
<reponame>bushy555/ZX-Spectrum-1-Bit-Routines<filename>wtbeep/music.asm dw ptn2 dw ptn2a dw ptn2b dw ptn2c dw ptn3 dw ptn3 dw ptn3 dw ptn3 dw ptn3a dw ptn3a dw ptn3b dw ptn3b dw ptn3 dw ptn3 dw ptn3 dw ptn3 dw ptn3a dw ptn3a dw ptn3b dw ptn3c mLoop dw ptn4 dw ptn4x dw ptn4a dw ptn4aa dw ptn4b dw ptn4bx dw ptn4c dw ptn4cx dw ptn4 dw ptn4x dw ptn4a dw ptn4aa dw ptn4b dw ptn4bx dw ptn4c dw ptn4cxa ; mLoop dw ptn5x dw ptn5ax dw ptn5bx dw ptn5cx dw ptn5d dw ptn5e dw ptn5f dw ptn5g dw ptn5 dw ptn5a dw ptn5b dw ptn5c dw ptn5d dw ptn5e dw ptn5f dw ptn5g dw ptn6 dw ptn6a dw ptn6b dw ptn6c dw ptn6d dw ptn6e dw ptn6f dw ptn6g dw ptn7 dw ptn7a dw ptn7b dw ptn7c dw ptn7d dw ptn7e dw ptn7f dw ptn7g dw 0 ptn5 dw #800, wave20|c3, rest, rest dw kick|#500 dw #884, wave20|c4 db 0 dw #884, wave20|c5 db 0 dw #884, wave20|c4 db 0 db #40 ptn5a dw #800, wave21|c3, rest, rest dw kick|#500 dw #884, wave21|c4 db 0 dw #884, wave21|c5 db 0 dw #884, wave21|c4 db 0 db #40 ptn5b dw #800, wave22|c3, rest, rest dw kick|#500 dw #884, wave22|c4 db 0 dw #884, wave22|c5 db 0 dw #884, wave22|c4 db 0 db #40 ptn5c dw #800, wave23|c3, rest, rest dw kick|#500 dw #884, wave23|c4 db 0 dw #884, wave23|c5 db 0 dw #884, wave23|c4 db 0 db #40 ptn5x dw #800, wave20|c3, wave1|c1, rest dw kick|#500 dw #884, wave20|c4 db 0 dw #884, wave20|c5 db 0 dw #884, wave20|c4 db 0 db #40 ptn5ax dw #800, wave21|c3, wave2|c1, rest dw kick|#500 dw #884, wave21|c4 db 0 dw #884, wave21|c5 db 0 dw #884, wave21|c4 db 0 db #40 ptn5bx dw #800, wave22|c3, wave5|c1, rest dw kick|#500 dw #884, wave22|c4 db 0 dw #884, wave22|c5 db 0 dw #884, wave22|c4 db 0 db #40 ptn5cx dw #800, wave23|c3, wave6|c1, rest dw kick|#500 dw #884, wave23|c4 db 0 dw #884, wave23|c5 db 0 dw #884, wave23|c4 db 0 db #40 ptn5d dw #800, wave24|c2, rest, rest dw kick|#500 dw #884, wave24|c3 db 0 dw #884, wave24|c4 db 0 dw #884, wave24|c3 db 0 db #40 ptn5e dw #800, wave25|c2, rest, rest dw kick|#500 dw #884, wave25|c3 db 0 dw #884, wave25|c4 db 0 dw #884, wave25|c2 db 0 db #40 ptn5f dw #800, wave26|c3, rest, rest dw kick|#500 dw #884, wave26|c4 db 0 dw #884, wave26|c5 db 0 dw #884, wave26|c4 db 0 db #40 ptn5g dw #800, wave27|c3, rest, rest dw kick|#500 dw #884, wave27|c4 db 0 dw #884, wave27|c5 db 0 dw #884, wave27|c4 db 0 db #40 ptn6 dw #800, wave20|a2, rest, rest dw kick|#500 dw #884, wave20|a3 db 0 dw #884, wave20|a4 db 0 dw #884, wave20|a3 db 0 db #40 ptn6a dw #800, wave21|a2, rest, rest dw kick|#500 dw #884, wave21|a3 db 0 dw #884, wave21|a4 db 0 dw #884, wave21|a3 db 0 db #40 ptn6b dw #800, wave22|a2, rest, rest dw kick|#500 dw #884, wave22|a3 db 0 dw #884, wave22|a4 db 0 dw #884, wave22|a3 db 0 db #40 ptn6c dw #800, wave23|a2, rest, rest dw kick|#500 dw #884, wave23|a3 db 0 dw #884, wave23|a4 db 0 dw #884, wave23|a3 db 0 db #40 ptn6d dw #800, wave24|a1, rest, rest dw kick|#500 dw #884, wave24|a2 db 0 dw #884, wave24|a3 db 0 dw #884, wave24|a2 db 0 db #40 ptn6e dw #800, wave25|a1, rest, rest dw kick|#500 dw #884, wave25|a2 db 0 dw #884, wave25|a3 db 0 dw #884, wave25|a2 db 0 db #40 ptn6f dw #800, wave26|a2, rest, rest dw kick|#500 dw #884, wave26|a3 db 0 dw #884, wave26|a4 db 0 dw #884, wave26|a3 db 0 db #40 ptn6g dw #800, wave27|a2, rest, rest dw kick|#500 dw #884, wave27|a3 db 0 dw #884, wave27|a4 db 0 dw #884, wave27|a3 db 0 db #40 ptn7 dw #800, wave20|ais2, wave5|g3, wave5|ais3 dw kick|#500 dw #884, wave20|ais3 db 0 dw #884, wave20|ais4 db 0 dw #884, wave20|ais3 db 0 db #40 ptn7a dw #800, wave21|ais2, wave5|g3, wave5|ais3 dw kick|#500 dw #884, wave21|ais3 db 0 dw #884, wave21|ais4 db 0 dw #884, wave21|ais3 db 0 db #40 ptn7b dw #800, wave22|ais2, wave5|g3, wave5|ais3 dw kick|#500 dw #884, wave22|ais3 db 0 dw #884, wave22|ais4 db 0 dw #884, wave22|ais3 db 0 db #40 ptn7c dw #800, wave23|ais2, wave5|g3, wave5|ais3 dw kick|#500 dw #884, wave23|ais3 db 0 dw #884, wave23|ais4 db 0 dw #884, wave23|ais3 db 0 db #40 ptn7d dw #800, wave24|ais1, wave5|f3, wave5|ais3 dw kick|#500 dw #884, wave24|ais2 db 0 dw #884, wave24|ais3 db 0 dw #884, wave24|ais2 db 0 db #40 ptn7e dw #800, wave25|ais1, wave5|f3, wave5|ais3 dw kick|#500 dw #884, wave25|ais2 db 0 dw #884, wave25|ais3 db 0 dw #884, wave25|ais2 db 0 db #40 ptn7f dw #800, wave26|ais2, wave5|f3, wave5|ais3 dw kick|#500 dw #884, wave26|ais3 db 0 dw #884, wave26|ais4 db 0 dw #884, wave26|ais3 db 0 db #40 ptn7g dw #800, wave27|ais2, wave6|f3, wave16|ais4 dw kick|#500 dw #804, wave27|ais3, wave15|ais4 db 0 dw #804, wave27|ais4, wave14|ais4 db 0 dw #804, wave27|ais3, wave13|ais4 db 0 db #40 ptn4 dw #800, wave2|c3, wave8|dis3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4x dw #804, wave2|c3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4a dw #800, wave2|c3, wave8|f3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4aa dw #804, wave2|c3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|c3 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|c4 dw hhat|#1000 dw #884, wave2|c2 dw hhat|#1000 db #40 ptn4b dw #800, wave2|c3, wave8|g3, wave21|a2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|a3 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|a2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|a3 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4bx dw #804, wave2|c3, wave21|a2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|a3 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|a2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|a3 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4c dw #800, wave2|c3, wave8|f3, wave21|ais2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|ais3 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|ais2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|g3, wave21|ais3 dw hhat|#1000 dw #884, wave2|c2 db 0 db #40 ptn4cx dw #804, wave2|c3, wave21|ais2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|ais3 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #804, wave30|f3, wave21|ais2 dw kick|#500 dw #884, wave2|c2 dw kick|#500 dw #804, wave2|g3, wave21|ais3 dw kick|#500 dw #884, wave2|c2 dw kick|#500 db #40 ptn4cxa dw #804, wave2|c3, wave21|ais2 dw kick|#500 dw #884, wave2|c2 db 0 dw #804, wave2|c4, wave21|ais3 dw hhat|#1000 dw #884, wave2|c2 db 0 dw #404, wave30|f3, wave21|ais2 dw kick|#500 dw #484, wave2|f3 db 0 dw #484, wave30|f3 dw kick|#500 dw #484, wave2|c2 db 0 dw #404, wave30|f3, wave21|ais3 dw kick|#500 dw #484, wave2|g3 db 0 dw #484, wave30|f3 dw kick|#500 dw #484, wave2|c2 db 0 db #40 ptn3 dw #800, wave2|c3, rest, wave10|c1 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|c4 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|f3 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|g3 db 0 dw #884, wave2|c2 db 0 db #40 ptn3a dw #800, wave2|c3, rest, wave10|a0 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|c4 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|f3 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|g3 db 0 dw #884, wave2|c2 db 0 db #40 ptn3b dw #800, wave2|c3, rest, wave10|ais0 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|c4 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|f3 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|g3 db 0 dw #884, wave2|c2 db 0 db #40 ptn3c dw #800, wave2|c3, rest, wave10|ais0 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|c4 db 0 dw #884, wave2|c2 db 0 dw #884, wave2|f3 dw hhat|#0800 dw #884, wave2|c2 dw hhat|#1000 dw #884, wave2|g3 dw hhat|#1800 dw #884, wave2|c2 dw hhat|#2000 db #40 ptn2 dw #800, wave6|c3, rest, rest db 0 dw #884, wave6|c2 db 0 dw #884, wave6|c4 db 0 dw #884, wave6|c2 db 0 dw #884, wave6|f3 db 0 dw #884, wave6|c2 db 0 dw #884, wave6|g3 db 0 dw #884, wave6|c2 db 0 db #40 ptn2a dw #800, wave5|c3, rest, rest db 0 dw #884, wave5|c2 db 0 dw #884, wave5|c4 db 0 dw #884, wave5|c2 db 0 dw #884, wave5|f3 db 0 dw #884, wave5|c2 db 0 dw #884, wave5|g3 db 0 dw #884, wave5|c2 db 0 db #40 ptn2b dw #800, wave4|c3, rest, rest db 0 dw #884, wave4|c2 db 0 dw #884, wave4|c4 db 0 dw #884, wave4|c2 db 0 dw #884, wave4|f3 db 0 dw #884, wave4|c2 db 0 dw #884, wave4|g3 db 0 dw #884, wave4|c2 db 0 db #40 ptn2c dw #800, wave3|c3, rest, rest db 0 dw #884, wave3|c2 db 0 dw #884, wave3|c4 db 0 dw #884, wave3|c2 db 0 dw #884, wave3|f3 db 0 dw #884, wave3|c2 db 0 dw #884, wave3|g3 db 0 dw #884, wave3|c2 db 0 db #40
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_optimization15.adb
best08618/asylo
0
28897
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_optimization15.adb -- { dg-do compile } -- { dg-options "-O3" } package body Loop_Optimization15 is type Integer_Array_T is array (B16_T range <>) of Integer; Len : constant B16_T := 10; Src : constant Integer_Array_T (1 .. Len) := (others => 0); Dst : Integer_Array_T (1 .. Len); procedure Proc (L : B16_T) is begin for I in 1 .. B16_T'Min (L, Len) loop Dst (I) := Src (I); end loop; end; end Loop_Optimization15;
courses/spark_for_ada_programmers/labs/answers/990_spark_example_project/string_fixed.ads
AdaCore/training_material
15
6740
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . F I X E D -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings; use Ada.Strings; package String_Fixed with SPARK_Mode is pragma Preelaborate; ------------------------ -- Search Subprograms -- ------------------------ function Index (Source : String; Set : Maps.Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural with Pre => Source'Length = 0 or else From in Source'Range, Post => Index'Result in 0 | Source'Range, Contract_Cases => ((for all I in Source'Range => (if I = From or else (I > From) = (Going = Forward) then (Test = Inside) /= Is_In (Source (I), Set))) => Index'Result = 0, others => Index'Result in Source'Range and then (Index'Result = From or else (Index'Result > From) = (Going = Forward)) and then (Test = Inside) = Is_In (Source (Index'Result), Set) and then (for all I in Source'Range => (if I /= Index'Result and then (I < Index'Result) = (Going = Forward) and then (I = From or else (I > From) = (Going = Forward)) then (Test = Inside) /= Is_In (Source (I), Set)))); -- Index searches for the first or last occurrence of any of a set of -- characters (when Test=Inside), or any of the complement of a set -- of characters (when Test=Outside). If Source is the null string, -- Index returns 0; otherwise, if From is not in Source'Range, then -- Index_Error is propagated. Otherwise, it returns the smallest index -- I >= From (if Going=Forward) or the largest index I <= From (if -- Going=Backward) such that Source(I) satisfies the Test condition with -- respect to Set; it returns 0 if there is no such Character in Source. function Any_In_Set (Source : String; Set : Maps.Character_Set) return Boolean is (for some C of Source => Is_In (C, Set)) with Ghost; function Is_Valid_Inside_Forward (Source : String; Set : Maps.Character_Set; Result : Natural) return Boolean is (if Result = 0 then not Any_In_Set (Source, Set) elsif Result not in Source'Range then Result = 0 elsif Result = Source'First then Is_In (Source (Result), Set) else Is_In (Source (Result), Set) and then not Any_In_Set (Source (Source'First .. Result - 1), Set)) with Ghost; function Is_Valid_Inside_Backward (Source : String; Set : Maps.Character_Set; Result : Natural) return Boolean is (if Result = 0 then not Any_In_Set (Source, Set) elsif Result not in Source'Range then Result = 0 elsif Result = Source'Last then Is_In (Source (Result), Set) else Is_In (Source (Result), Set) and then not Any_In_Set (Source (Result + 1 .. Source'Last), Set)) with Ghost; function All_In_Set (Source : String; Set : Maps.Character_Set) return Boolean is (for all C of Source => Is_In (C, Set)) with Ghost; function Is_Valid_Outside_Forward (Source : String; Set : Maps.Character_Set; Result : Natural) return Boolean is (if Result = 0 then All_In_Set (Source, Set) elsif Result not in Source'Range then Result = 0 elsif Result = Source'First then not Is_In (Source (Result), Set) else not Is_In (Source (Result), Set) and then All_In_Set (Source (Source'First .. Result - 1), Set)) with Ghost; function Is_Valid_Outside_Backward (Source : String; Set : Maps.Character_Set; Result : Natural) return Boolean is (if Result = 0 then All_In_Set (Source, Set) elsif Result not in Source'Range then Result = 0 elsif Result = Source'Last then not Is_In (Source (Result), Set) else not Is_In (Source (Result), Set) and then All_In_Set (Source (Result + 1 .. Source'Last), Set)) with Ghost; function Index (Source : String; Set : Maps.Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural with Post => (if Source'Length = 0 then Index'Result = 0 elsif Test = Inside and Going = Forward then Is_Valid_Inside_Forward (Source, Set, Index'Result) elsif Test = Inside and Going = Backward then Is_Valid_Inside_Backward (Source, Set, Index'Result) elsif Test = Outside and Going = Forward then Is_Valid_Outside_Forward (Source, Set, Index'Result) elsif Test = Outside and Going = Backward then Is_Valid_Outside_Backward (Source, Set, Index'Result) else False); -- If Going = Forward, -- returns Index (Source, Set, Source'First, Test, Forward); otherwise, -- returns Index (Source, Set, Source'Last, Test, Backward); function Index_Non_Blank (Source : String; From : Positive; Going : Direction := Forward) return Natural with Pre => Source'Length = 0 or else From in Source'Range, Post => Index_Non_Blank'Result in 0 | Source'Range, Contract_Cases => ((for all I in Source'Range => (if I = From or else (I > From) = (Going = Forward) then Source (I) = ' ')) => Index_Non_Blank'Result = 0, others => Index_Non_Blank'Result in Source'Range and then (Index_Non_Blank'Result = From or else (Index_Non_Blank'Result > From) = (Going = Forward)) and then Source (Index_Non_Blank'Result) /= ' ' and then (for all I in Source'Range => (if I /= Index_Non_Blank'Result and then (I < Index_Non_Blank'Result) = (Going = Forward) and then (I = From or else (I > From) = (Going = Forward)) then Source (I) = ' '))); -- Returns Index (Source, Maps.To_Set(Space), From, Outside, Going); function Index_Non_Blank (Source : String; Going : Direction := Forward) return Natural with Post => Index_Non_Blank'Result in 0 | Source'Range, Contract_Cases => ((for all C of Source => C = ' ') => Index_Non_Blank'Result = 0, others => Index_Non_Blank'Result in Source'Range and then Source (Index_Non_Blank'Result) /= ' ' and then (for all I in Source'Range => (if I /= Index_Non_Blank'Result and then (I < Index_Non_Blank'Result) = (Going = Forward) then Source (I) = ' '))); -- Returns Index(Source, Maps.To_Set(Space), Outside, Going) --------------------------------------- -- String Transformation Subprograms -- --------------------------------------- function Insert (Source : String; Before : Positive; New_Item : String) return String with Pre => Before >= Source'First and then (Source'Last = Integer'Last or else Before <= Source'Last + 1) and then New_Item'Length <= Integer'Last - Source'Length and then Source'First = 1 and then New_Item'First = 1, Post => Insert'Result'First = 1 and then Insert'Result = Source (Source'First .. Before - 1) & New_Item & Source (Before .. Source'Last); -- Propagates Index_Error if Before is not in Source'First .. -- Source'Last+1; otherwise, returns Source(Source'First..Before-1) -- & New_Item & Source(Before..Source'Last), but with lower bound 1. -- Beware of the overflow of the string length ! function Overwrite (Source : String; Position : Positive; New_Item : String) return String with Pre => Position >= Source'First and then (Source'Last = Integer'Last or else Position <= Source'Last + 1) and then New_Item'Length <= Integer'Last - (Position - Source'First + 1) and then Source'First = 1 and then New_Item'First = 1, Post => Overwrite'Result'First = 1 and then Overwrite'Result = Source (1 .. Position - 1) & New_Item & (if New_Item'Length > Source'Last - Position then "" else Source (Position + New_Item'Length .. Source'Last)); -- Propagates Index_Error if Position is not in Source'First .. -- Source'Last+1; otherwise, returns the string obtained from Source -- by consecutively replacing characters starting at Position with -- corresponding characters from New_Item with lower bound 1. If the end -- of Source is reached before the characters in New_Item are exhausted, -- the remaining characters from New_Item are appended to the string. -- Beware of the overflow of the string length ! function Delete (Source : String; From : Positive; Through : Natural) return String with Pre => From > Through or else (From in Source'Range and then Through <= Source'Last), Post => Delete'Result'First = 1, Contract_Cases => (From > Through => Delete'Result = Source, others => Delete'Result = Source (Source'First .. From - 1) & (if Through < Source'Last then Source (Through + 1 .. Source'Last) else "")); -- If From > Through, the returned string is Source with lower bound -- 1. If From not in Source'Range, or Through > Source'Last, then -- Index_Error is propagated. Otherwise, the returned string comprises -- Source(Source'First..From - 1) & Source(Through+1..Source'Last), but -- with lower bound 1. --------------------------------- -- String Selector Subprograms -- --------------------------------- function Trim (Source : String; Left : Maps.Character_Set; Right : Maps.Character_Set) return String with Post => (if (for all K in Source'Range => Is_In (Source (K), Left)) or (for all K in Source'Range => Is_In (Source (K), Right)) then Trim'Result = "" else (for some Low in Source'Range => (for some High in Source'Range => Trim'Result = Source (Low .. High) and then not Is_In (Source (Low), Left) and then not Is_In (Source (High), Right) and then (for all K in Source'Range => (if K < Low then Is_In (Source (K), Left)) and then (if K > High then Is_In (Source (K), Right)))))); -- Returns the string obtained by removing from Source all leading -- characters in Left and all trailing characters in Right. function Trim (Source : String; Side : Trim_End) return String with Post => (if (for all K in Source'Range => Source (K) = ' ') then Trim'Result = "" else (for some Low in Source'Range => (for some High in Source'Range => Trim'Result = Source (Low .. High) and then (if Side = Left then High = Source'Last else Source (High) /= ' ') and then (if Side = Right then Low = Source'First else Source (Low) /= ' ') and then (for all K in Source'Range => (if K < Low then Source (K) = ' ') and then (if K > High then Source (K) = ' '))))); -- Returns the string obtained by removing from Source all leading Space -- characters (if Side = Left), all trailing Space characters (if Side -- = Right), or all leading and trailing Space characters (if Side = -- Both). function Head (Source : String; Count : Natural; Pad : Character := Space) return String with Pre => Source'First = 1, Post => Head'Result'Length = Count, Contract_Cases => (Count <= Source'Length => Head'Result = Source (Source'First .. Count), others => Head'Result = Source & (1 .. Count - Source'Length => Pad)); -- Returns a string of length Count. If Count <= Source'Length, the -- string comprises the first Count characters of Source. Otherwise, -- its contents are Source concatenated with Count-Source'Length Pad -- characters. function Tail (Source : String; Count : Natural; Pad : Character := Space) return String with Pre => Source'First = 1, Post => Tail'Result'Length = Count, Contract_Cases => (Count = 0 => Tail'Result = "", (Count in 1 .. Source'Length) => Tail'Result = Source (Source'Last - Count + 1 .. Source'Last), others => Tail'Result = (1 .. Count - Source'Length => Pad) & Source); -- Returns a string of length Count. If Count <= Source'Length, the -- string comprises the last Count characters of Source. Otherwise, its -- contents are Count-Source'Length Pad characters concatenated with -- Source. ---------------------------------- -- String Constructor Functions -- ---------------------------------- function "*" (Left : Natural; Right : Character) return String with Post => "*"'Result'Length = Left and then (for all E of "*"'Result => E = Right); -- This function replicates a character a specified number of times. It -- returns a string whose length is Left and each of whose elements is -- Right. end String_Fixed;
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca.log_21829_1309.asm
ljhsiun2/medusa
9
3179
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r8 push %r9 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0xf11e, %r10 nop nop nop nop nop cmp $4244, %rax mov (%r10), %ebx nop xor $20628, %r10 lea addresses_D_ht+0x1b11e, %r8 nop nop nop nop and %rdx, %rdx vmovups (%r8), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r9 nop nop nop xor $10560, %rax lea addresses_A_ht+0x681e, %rdx nop nop nop nop sub $41919, %r11 mov $0x6162636465666768, %r8 movq %r8, %xmm0 movups %xmm0, (%rdx) nop nop nop nop dec %r9 lea addresses_D_ht+0x1e91e, %rsi lea addresses_D_ht+0x885e, %rdi clflush (%rdi) nop nop nop nop add $31151, %rbx mov $90, %rcx rep movsb nop nop nop xor %r10, %r10 lea addresses_WT_ht+0x191e, %rsi lea addresses_A_ht+0x1c11e, %rdi nop nop nop nop and %rbx, %rbx mov $21, %rcx rep movsq nop dec %rcx lea addresses_A_ht+0x12c5a, %rsi lea addresses_normal_ht+0x1d91e, %rdi clflush (%rdi) nop nop nop inc %rdx mov $120, %rcx rep movsl nop nop sub $62365, %r9 lea addresses_A_ht+0x1a5be, %rsi lea addresses_A_ht+0x9b1e, %rdi nop nop nop nop nop and %rax, %rax mov $118, %rcx rep movsb nop inc %rcx lea addresses_normal_ht+0x641e, %rsi lea addresses_normal_ht+0x1941e, %rdi nop nop nop xor $53233, %rbx mov $120, %rcx rep movsb nop nop nop xor $3718, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r8 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r8 push %rax push %rbp push %rdi push %rdx push %rsi // Store lea addresses_normal+0x475a, %r13 nop add %rax, %rax movl $0x51525354, (%r13) nop nop nop nop nop add $36329, %rax // Faulty Load lea addresses_D+0x1c91e, %r8 nop nop nop nop nop xor $55881, %rsi mov (%r8), %edi lea oracles, %rsi and $0xff, %rdi shlq $12, %rdi mov (%rsi,%rdi,1), %rdi pop %rsi pop %rdx pop %rdi pop %rbp pop %rax pop %r8 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_normal', 'same': False, 'AVXalign': True, 'congruent': 2}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 1}, 'dst': {'same': True, 'type': 'addresses_normal_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}} {'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 */
programs/oeis/049/A049711.asm
neoneye/loda
22
2223
; A049711: a(n) = n - prevprime(n). ; 1,1,2,1,2,1,2,3,4,1,2,1,2,3,4,1,2,1,2,3,4,1,2,3,4,5,6,1,2,1,2,3,4,5,6,1,2,3,4,1,2,1,2,3,4,1,2,3,4,5,6,1,2,3,4,5,6,1,2,1,2,3,4,5,6,1,2,3,4,1,2,1,2,3,4,5,6,1,2,3,4,1,2,3,4,5,6,1,2,3,4,5,6 lpb $0 mov $2,$0 seq $2,46666 ; a(n) = n - (smallest prime dividing n). mov $3,$2 min $3,1 sub $0,$3 add $1,$3 lpe add $1,1 mov $0,$1
tools/druss-commands.adb
stcarrez/bbox-ada-api
2
29393
----------------------------------------------------------------------- -- druss-commands -- Commands available for Druss -- Copyright (C) 2017, 2019, 2021 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with Util.Strings; with Util.Log.Loggers; with Readline; with Druss.Commands.Bboxes; with Druss.Commands.Get; with Druss.Commands.Status; with Druss.Commands.Wifi; with Druss.Commands.Devices; with Druss.Commands.Ping; package body Druss.Commands is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Commands"); function Uptime_Image (Value : in Natural) return String; procedure Quit (Name : in String; Args : in Argument_List'Class; Context : in out Context_Type); Help_Command : aliased Druss.Commands.Drivers.Help_Command_Type; Bbox_Commands : aliased Druss.Commands.Bboxes.Command_Type; Get_Commands : aliased Druss.Commands.Get.Command_Type; Wifi_Commands : aliased Druss.Commands.Wifi.Command_Type; Status_Commands : aliased Druss.Commands.Status.Command_Type; Device_Commands : aliased Druss.Commands.Devices.Command_Type; Ping_Commands : aliased Druss.Commands.Ping.Command_Type; procedure Gateway_Command (Command : in Drivers.Command_Type'Class; Args : in Util.Commands.Argument_List'Class; Arg_Pos : in Positive; Process : access procedure (Gateway : in out Gateways.Gateway_Type; Param : in String); Context : in out Context_Type) is pragma Unreferenced (Command); begin if Args.Get_Count < Arg_Pos then Context.Console.Notice (N_USAGE, "Missing argument for command"); Druss.Commands.Driver.Usage (Args, Context); end if; declare procedure Operation (Gateway : in out Druss.Gateways.Gateway_Type); Param : constant String := Args.Get_Argument (Arg_Pos); Gw : Druss.Gateways.Gateway_Ref; procedure Operation (Gateway : in out Druss.Gateways.Gateway_Type) is begin Process (Gateway, Param); end Operation; begin if Args.Get_Count = Arg_Pos then Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Operation'Access); else for I in Arg_Pos + 1 .. Args.Get_Count loop Gw := Druss.Gateways.Find_IP (Context.Gateways, Args.Get_Argument (I)); if not Gw.Is_Null then Operation (Gw.Value); end if; end loop; end if; end; end Gateway_Command; procedure Initialize is begin Driver.Set_Description ("Druss - The Bbox master controller"); Driver.Set_Usage ("[-v] [-d] [-i] [-o file] [-c config] <command> [<args>]" & ASCII.LF & "where:" & ASCII.LF & " -v Verbose execution mode" & ASCII.LF & " -d Debug execution mode" & ASCII.LF & " -i Enter the interactive mode" & ASCII.LF & " -c config Use the configuration file" & " (instead of $HOME/.config/druss/druss.properties)" & ASCII.LF & " -o file The output file to use"); Driver.Add_Command ("help", Help_Command'Access); Driver.Add_Command ("bbox", Bbox_Commands'Access); Driver.Add_Command ("get", Get_Commands'Access); Driver.Add_Command ("wifi", Wifi_Commands'Access); Driver.Add_Command ("status", Status_Commands'Access); Driver.Add_Command ("devices", Device_Commands'Access); Driver.Add_Command ("ping", Ping_Commands'Access); end Initialize; -- ------------------------------ -- Quit the interactive loop. -- ------------------------------ procedure Quit (Name : in String; Args : in Argument_List'Class; Context : in out Context_Type) is pragma Unreferenced (Name, Args, Context); begin raise Stop_Interactive; end Quit; -- ------------------------------ -- Enter in the interactive main loop waiting for user commands and executing them. -- ------------------------------ procedure Interactive (Context : in out Context_Type) is Args : Util.Commands.String_Argument_List (Max_Length => 1000, Max_Args => 100); begin Log.Debug ("Entering in interactive mode"); Driver.Add_Command (Name => "quit", Handler => Quit'Access, Description => "quit the program"); loop declare Line : constant String := Readline.Get_Line ("druss>"); begin Log.Debug ("Execute: {0}", Line); Args.Initialize (Line); Driver.Execute (Args.Get_Command_Name, Args, Context); exception when Stop_Interactive => Log.Debug ("Leaving interactive mode"); exit; when others => Context.Console.Notice (N_INFO, "Command failed"); end; end loop; exception when Ada.IO_Exceptions.End_Error => Log.Debug ("End_Error exception received"); end Interactive; -- ------------------------------ -- Print the bbox API status. -- ------------------------------ procedure Print_Status (Console : in Consoles.Console_Access; Field : in Field_Type; Value : in String) is begin if Value = "2" then Console.Print_Field (Field, "OK"); elsif Value = "-1" then Console.Print_Field (Field, "KO"); elsif Value = "1" then Console.Print_Field (Field, "Starting"); elsif Value = "0" then Console.Print_Field (Field, "Stopped"); else Console.Print_Field (Field, "?"); end if; end Print_Status; -- ------------------------------ -- Print a ON/OFF status. -- ------------------------------ procedure Print_On_Off (Console : in Consoles.Console_Access; Field : in Field_Type; Value : in String) is begin if Value = "1" then Console.Print_Field (Field, "ON"); elsif Value = "0" then Console.Print_Field (Field, "OFF"); else Console.Print_Field (Field, ""); end if; end Print_On_Off; function Uptime_Image (Value : in Natural) return String is D : constant Natural := Value / 86400; R : constant Natural := Value mod 86400; H : constant Natural := R / 3600; M : constant Natural := (R mod 3600) / 60; S : constant Natural := (R mod 3600) mod 60; begin if D > 0 then return Util.Strings.Image (D) & "d" & (if H > 0 then Natural'Image (H) & "h" else "") & (if M > 0 then Natural'Image (M) & "m" else ""); elsif H > 0 then return Util.Strings.Image (H) & "h" & (if M > 0 then Natural'Image (M) & "m" else ""); else return Util.Strings.Image (M) & "m" & Natural'Image (S) & "s"; end if; end Uptime_Image; -- ------------------------------ -- Print a uptime. -- ------------------------------ procedure Print_Uptime (Console : in Consoles.Console_Access; Field : in Field_Type; Value : in String) is begin if Value = "" then Console.Print_Field (Field, Value); else Console.Print_Field (Field, Uptime_Image (Natural'Value (Value))); end if; exception when others => Console.Print_Field (Field, Value); end Print_Uptime; -- ------------------------------ -- Print a performance measure in us or ms. -- ------------------------------ procedure Print_Perf (Console : in Consoles.Console_Access; Field : in Field_Type; Value : in String) is use Commands.Consoles; begin if Value = "" then Console.Print_Field (Field, Value); elsif Value'Length <= 3 then Console.Print_Field (Field, Value & " us", J_RIGHT); elsif Value'Length <= 6 then Console.Print_Field (Field, Value (Value'First .. Value'Last - 3) & "." & Value (Value'Last - 2 .. Value'Last) & " ms", J_RIGHT); else Console.Print_Field (Field, Value (Value'First .. Value'Last - 6) & "." & Value (Value'Last - 5 .. Value'Last - 3) & " s", J_RIGHT); end if; end Print_Perf; end Druss.Commands;
oeis/003/A003221.asm
neoneye/loda-programs
11
172357
<reponame>neoneye/loda-programs<filename>oeis/003/A003221.asm ; A003221: Number of even permutations of length n with no fixed points. ; Submitted by <NAME> ; 1,0,0,2,3,24,130,930,7413,66752,667476,7342290,88107415,1145396472,16035550518,240533257874,3848532125865,65425046139840,1177650830516968,22375365779822562,447507315596451051,9397653627525472280,206748379805560389930,4755212735527888968642,114125105652669335247133,2853127641316733381178624,74181318674235067910643900,2002895604204346833587385650,56081076917721711340446797823,1626351230613929628872957137272,48790536918417888866188714117726,1512506644470954554851850137649970 mov $1,1 mov $2,1 mov $3,$0 mov $4,1 lpb $3 mul $1,$3 mul $2,2 add $5,$4 div $1,$5 div $2,-2 add $2,$1 mul $1,$5 sub $3,1 div $4,$5 lpe mov $0,$2
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xca.log_8_1650.asm
ljhsiun2/medusa
9
4098
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %rax push %rbp push %rbx push %rcx // Store lea addresses_WT+0x9bc, %r8 sub %r13, %r13 movl $0x51525354, (%r8) cmp $60488, %rax // Store lea addresses_D+0x18edc, %rbp nop nop xor $16911, %rcx movb $0x51, (%rbp) nop nop nop dec %rbx // Store mov $0x660, %r8 nop sub %rax, %rax mov $0x5152535455565758, %r13 movq %r13, %xmm2 vmovups %ymm2, (%r8) nop add $62058, %rcx // Store lea addresses_WC+0x1f15c, %rbp nop nop nop and $38929, %rcx mov $0x5152535455565758, %r8 movq %r8, %xmm6 vmovups %ymm6, (%rbp) nop and %rax, %rax // Store mov $0xe5c, %rbp nop nop nop nop inc %r13 movw $0x5152, (%rbp) nop nop nop nop sub $61565, %rbp // Store mov $0x624, %r13 nop nop and $17866, %rbx mov $0x5152535455565758, %rbp movq %rbp, %xmm7 movups %xmm7, (%r13) cmp %rbp, %rbp // Faulty Load lea addresses_WT+0x6a5c, %rbp nop cmp %rax, %rax mov (%rbp), %r14 lea oracles, %r13 and $0xff, %r14 shlq $12, %r14 mov (%r13,%r14,1), %r14 pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': True, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'00': 8} 00 00 00 00 00 00 00 00 */
Ada/inc/Problem_50.ads
Tim-Tom/project-euler
0
2108
package Problem_50 is -- The prime 41, can be written as the sum of six consecutive primes: -- 41 = 2 + 3 + 5 + 7 + 11 + 13 -- This is the longest sum of consecutive primes that adds to a prime below -- one-hundred. The longest sum of consecutive primes below one-thousand that -- adds to a prime, contains 21 terms, and is equal to 953. -- -- Which prime, below one-million, can be written as the sum of the most -- consecutive primes? procedure Solve; end Problem_50;
dino/lcs/enemy/8A.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
104095
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004D3C move.l D0, (A4)+ 004D3E move.l D0, (A4)+ 032A78 move.w ($8a,A6), D2 [enemy+88] 032A7C jsr $1032.l [enemy+8A] 032AD4 move.w D2, ($8a,A6) [enemy+88] 032AD8 jsr $103a.l [enemy+8A] 032CB0 move.w D2, ($8a,A6) [enemy+88] 032CB4 move.w ($8,A0), D0 [enemy+8A] 032DAA move.w ($10,A0), ($8a,A6) [123p+ 8] 032DB0 add.w ($46,PC,D0.w), D1 [enemy+8A] 032E64 move.w D2, ($8a,A6) [enemy+88] 032E68 move.w ($8,A0), D0 [enemy+8A] 032EE4 move.w ($10,A0), ($8a,A6) [123p+ 8] 032EEA add.w ($46,PC,D0.w), D1 [enemy+8A] 0351FE move.w D2, ($8a,A6) [enemy+88] 035202 jsr $103a.l [enemy+8A] 035286 move.w D2, ($8a,A6) [enemy+88] 03528A jsr $103a.l [enemy+8A] 0352D0 move.w D2, ($8a,A6) [enemy+88] 0352D4 jsr $103a.l [enemy+8A] 035372 sub.w ($8a,A6), D0 [enemy+10] 035376 addi.w #$f, D0 [enemy+8A] 0353A0 sub.w ($8a,A6), D0 [enemy+10] 0353A4 addq.w #5, D0 [enemy+8A] 03566C move.w D2, ($8a,A6) [enemy+88] 035670 jsr $103a.l [enemy+8A] 035C4E move.w ($8a,A6), D0 035C52 addi.w #$7, D0 [enemy+8A] 03CBE2 move.w D2, ($8a,A6) [enemy+88] 03CBE6 bsr $3ce12 [enemy+8A] 03CCB0 move.w D2, ($8a,A6) [enemy+88] 03CCB4 jsr $103a.l [enemy+8A] 03CCE8 move.w D2, ($8a,A6) [enemy+88] 03CCEC jsr $103a.l [enemy+8A] 03CDCC move.w D2, ($8a,A6) [enemy+88] 03CDD0 bra $3ce4c [enemy+8A] 03CE08 move.w ($8a,A6), D2 [enemy+88] 03CE0C bra $3ce4c [enemy+8A] 03CE94 sub.w ($8a,A6), D0 [enemy+10] 03CE98 addi.w #$c, D0 [enemy+8A] 03CEC2 sub.w ($8a,A6), D0 [enemy+10] 03CEC6 addi.w #$7, D0 [enemy+8A] 03E846 move.w ($8a,A6), D0 03E84A cmp.w ($10,A6), D0 [enemy+8A] 03E876 move.w ($8a,A6), D0 03E87A addi.w #$8, D0 [enemy+8A] 03F3B0 move.w ($8a,A6), D0 [enemy+B0, enemy+B2] 03F3B4 cmp.w ($10,A6), D0 [enemy+8A] 040032 move.w ($8a,A6), D2 [enemy+88] 040036 jsr $103a.l [enemy+8A] 040A0C move.w ($8a,A6), D0 [enemy+B0, enemy+B2] 040A10 cmp.w ($10,A6), D0 [enemy+8A] 040A5A move.w ($8a,A6), D0 040A5E addi.w #$a, D0 [enemy+8A] 040B44 move.w ($8a,A6), D0 040B48 cmp.w ($10,A6), D0 [enemy+8A] 040B74 move.w ($8a,A6), D0 040B78 addi.w #$10, D0 [enemy+8A] 041332 move.w ($8a,A6), D0 [enemy+B0, enemy+B2] 041336 cmp.w ($10,A6), D0 [enemy+8A] 0419C6 move.w ($8a,A6), D2 [enemy+88] 0419CA jsr $103a.l [enemy+8A] 042774 move.w D2, ($8a,A6) [enemy+88] 042778 jsr $103a.l [enemy+8A] 04278C move.w ($8a,A6), D2 [enemy+88] 042790 jsr $103a.l [enemy+8A] 042E22 sub.w ($8a,A6), D2 [enemy+10] 042E26 moveq #$38, D3 [enemy+8A] 042E30 sub.w ($8a,A6), D2 [enemy+10] 042E34 bcs $42e44 [enemy+8A] 0447F8 move.w D2, ($8a,A6) 0447FC tst.b ($b5,A6) [enemy+8A] 044862 move.w D2, ($8a,A6) [enemy+88] 044866 bra $447fc [enemy+8A] 044984 move.w D2, ($8a,A6) [enemy+88] 044988 jsr $103a.l [enemy+8A] 044A44 sub.w ($8a,A6), D0 [enemy+10] 044A48 addq.w #8, D0 [enemy+8A] 044A70 sub.w ($8a,A6), D0 [enemy+10] 044A74 addi.w #$7, D0 [enemy+8A] 044AB6 sub.w ($8a,A6), D0 [enemy+10] 044ABA addq.w #4, D0 [enemy+8A] 044BEC move.w D2, ($8a,A6) [enemy+88] 044BF0 tst.b ($b5,A6) [enemy+8A] 045FDE move.w ($10,A0), ($8a,A6) [enemy+88] 045FE4 bsr $46bcc [enemy+8A] 0461E8 move.w ($10,A6), ($8a,A6) [enemy+88] 0461EE bsr $46bcc [enemy+8A] 046624 move.w D0, ($8a,A6) 046628 bsr $46bcc [enemy+8A] 046688 move.w ($10,A0), ($8a,A6) [enemy+88] 04668E bsr $46bcc [enemy+8A] 046854 move.w D2, ($8a,A6) 046858 move.b #$1, ($51,A6) [enemy+8A] 046AD8 move.w D2, ($8a,A6) [enemy+88] 046ADC bsr $46b0e [enemy+8A] 046BBC move.w D2, ($8a,A6) [enemy+88] 046BC0 jsr $103a.l [enemy+8A] 046BD0 move.w ($8a,A6), D2 [enemy+88] 046BD4 jsr $103a.l [enemy+8A] 046D2C sub.w ($8a,A6), D0 [enemy+10] 046D30 addq.w #2, D0 [enemy+8A] 046E04 move.w D2, ($8a,A6) [enemy+88] 046E08 bsr $46e4a [enemy+8A] 046F16 move.w D2, ($8a,A6) [enemy+88] 046F1A jsr $103a.l [enemy+8A] 048956 move.w D2, ($8a,A6) [enemy+88] 04895A jsr $103a.l [enemy+8A] 04E76C move.w D2, ($8a,A6) [enemy+88] 04E770 jsr $103a.l [enemy+8A] 050946 move.w D2, ($8a,A6) 05094A jsr $103a.l [enemy+8A] 050A50 move.w D0, ($8a,A4) 050A54 move.w #$180, D1 [enemy+8A] 050A58 move.w ($8a,A4), D0 050A5C sub.w ($10,A4), D0 [enemy+8A] 050AB8 sub.w ($8a,A4), D0 [enemy+10] 050ABC addi.w #$8, D0 [enemy+8A] 055D90 sub.w ($8a,A6), D2 [enemy+10] 055D94 move.w #$3b, D3 [enemy+8A] 055D9E sub.w ($8a,A6), D2 [enemy+10] 055DA2 bcs $55db2 [enemy+8A] 055DEE sub.w ($8a,A6), D2 [enemy+10] 055DF2 move.w #$28, D3 [enemy+8A] 055DFE sub.w ($8a,A6), D2 [enemy+10] 055E02 bcs $55e12 [enemy+8A] 055ECE move.w D0, ($8a,A6) 055ED2 rts [enemy+8A] 055F22 move.w ($10,A0), ($8a,A6) [enemy+88] 055F28 rts [enemy+8A] 056AAE move.l #$1000, ($8a,A6) [enemy+25] 056AB6 move.l #$100, ($86,A6) [enemy+8A, enemy+8C] 056ACA add.l D0, ($8a,A6) 056ACE move.w ($744,A5), ($82,A6) [enemy+8A, enemy+8C] 056B14 add.l D0, ($8a,A6) [enemy+86, enemy+88] 056B18 move.l ($8a,A6), D0 [enemy+8A, enemy+8C] 056B1C add.l D0, ($8,A6) [enemy+8A, enemy+8C] 056B20 cmpi.l #$a000, ($8a,A6) [enemy+ 8, enemy+ A] 056B28 blt $56b3c [enemy+8A, enemy+8C] 056B3C cmpi.l #-$a000, ($8a,A6) 056B44 bgt $56b58 [enemy+8A, enemy+8C] 056B62 add.l D0, ($8a,A6) [enemy+86, enemy+88] 056B66 move.l ($8a,A6), D0 [enemy+8A, enemy+8C] 056B6A add.l D0, ($8,A6) [enemy+8A, enemy+8C] 056B6E cmpi.l #$8000, ($8a,A6) [enemy+ 8, enemy+ A] 056B76 blt $56b8a [enemy+8A, enemy+8C] 056B8A cmpi.l #-$8000, ($8a,A6) 056B92 bgt $56ba6 [enemy+8A, enemy+8C] 058E3C move.w ($8a,A6), D0 058E40 cmp.w ($10,A6), D0 [enemy+8A] 058E8A move.w ($8a,A6), D0 058E8E addi.w #$a, D0 [enemy+8A] 0598B8 move.w ($8a,A6), D0 [enemy+C0, enemy+C2] 0598BC cmp.w ($10,A6), D0 [enemy+8A] 05AE0E move.w ($8a,A6), D2 [enemy+88] 05AE12 jsr $103a.l [enemy+8A] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
CSC-308/MASM/NestedLoops.asm
FrancesCoronel/cs-hu
2
95778
<reponame>FrancesCoronel/cs-hu ; ; Nested Loops ; .386 .model flat,stdcall .STACK include kernel32.inc include masm32.inc includelib kernel32.lib includelib masm32.lib .DATA ExitMsg byte "Press any key to continue . . . ", 00dh, 00ah, 0 CRLF byte 00dh, 00ah, 0 SPACE byte " ", 0 array dword 34, 56, 4, 10, 77, 51, 93, 30, 5, 52 endarray dword 0 arraysize equ endarray-array string byte 10 dup (0) continue byte 0 .CODE main proc ; ; Nested Loops ; mov ebx,0 ; for (i = 0; i < arraysize - 1; i++) outterloop: cmp ebx,arraysize-sizeof(dword) ; compare the number in ebx to arraysize - 1 (i < arraysize - 1;) jge endoutter ; jump if the number is greater than or equal to arraysize -1 mov ecx,ebx ; for (j = i + 1; j < arraysize; j++) add ecx,sizeof(dword) ; start ecx at ebx + 4 (j = i + 1;) innerloop: cmp ecx,arraysize ; compare the number in ecx to arraysize (j < arraysize;) jge endinner ; jump if the number is greater than or equal to arraysize ; ; Print indices i and j ; push ebx ; save ebx push ecx ; save ecx mov eax,ebx ; i is in ebx, move it to eax for printing invoke dwtoa,eax,addr string ; convert the number to an ASCII string invoke StdOut,addr string ; print the number invoke StdOut,addr SPACE ; print a SPACE pop ecx ; restore ecx push ecx ; save ecx mov eax,ecx ; j is in ecx, move it to eax for printing invoke dwtoa,eax,addr string ; convert the number to an ASCII string invoke StdOut,addr string ; print the number invoke StdOut,addr SPACE ; print a SPACE invoke StdOut,addr CRLF ; print a CR LF pop ecx ; restore ecx pop ebx ; restore ebx ; ; End printing indices i and j ; around: ; ; Increment the inner loop variable and continue looping ; add ecx,sizeof(dword) ; increment the number in ebx by 4 (j++) jmp innerloop ; loop back to the top of the loop endinner: ; ; Increment the outter loop variable and continue looping ; add ebx,sizeof(dword) ; increment the number in ebx by 4 (i++) jmp outterloop ; loop back to the top of the loop endoutter: ; ; Print the exit message ; invoke StdOut,addr ExitMsg ; print the exit message invoke StdIn,addr continue,1 ; read to keep console window open invoke ExitProcess,0 ; exit main endp end main
test/Succeed/fol-theorems/Eta5.agda
asr/apia
10
353
<reponame>asr/apia<gh_stars>1-10 ------------------------------------------------------------------------------ -- Testing the η-expansion ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Eta5 where postulate D : Set _≈_ : D → D → Set data ∃ (A : D → Set) : Set where _,_ : (t : D) → A t → ∃ A P : D → Set P ws = ∃ (λ zs → ws ≈ zs) {-# ATP definition P #-} postulate foo : ∀ ws → P ws → ∃ (λ zs → ws ≈ zs) {-# ATP prove foo #-}
thirdparty/adasdl/thin/adasdl/AdaSDL/binding/uintn_ptrops.ads
Lucretia/old_nehe_ada95
0
30581
with Interfaces.C.Pointers; generic type The_Element is mod <>; type The_Element_Array is array (Interfaces.C.size_t range <>) of aliased The_Element; package UintN_PtrOps is package C renames Interfaces.C; package Operations is new Interfaces.C.Pointers ( Index => Interfaces.C.size_t, Element => The_Element, Element_Array => The_Element_Array, Default_Terminator => 0); subtype Pointer is Operations.Pointer; function Value (Ref : in Pointer; Terminator : in The_Element) return The_Element_Array renames Operations.Value; function Value (Ref : in Pointer; Length : in C.ptrdiff_t) return The_Element_Array renames Operations.Value; -------------------------------- -- C-style Pointer Arithmetic -- -------------------------------- function "+" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer renames Operations."+"; function "+" (Left : in C.ptrdiff_t; Right : in Pointer) return Pointer renames Operations."+"; function "-" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer renames Operations."-"; function "-" (Left : in Pointer; Right : in Pointer) return C.ptrdiff_t renames Operations."-"; procedure Increment (Ref : in out Pointer) renames Operations.Increment; procedure Decrement (Ref : in out Pointer) renames Operations.Increment; function Virtual_Length (Ref : in Pointer; Terminator : in The_Element := 0) return C.ptrdiff_t renames Operations.Virtual_Length; procedure Copy_Terminated_Array (Source : in Pointer; Target : in Pointer; Limit : in C.ptrdiff_t := C.ptrdiff_t'Last; Terminator : in The_Element := 0) renames Operations.Copy_Terminated_Array; procedure Copy_Array (Source : in Pointer; Target : in Pointer; Length : in C.ptrdiff_t) renames Operations.Copy_Array; end UintN_PtrOps;
programs/oeis/089/A089817.asm
neoneye/loda
22
19615
; A089817: a(n) = 5*a(n-1) - a(n-2) + 1 with a(0)=1, a(1)=6. ; 1,6,30,145,696,3336,15985,76590,366966,1758241,8424240,40362960,193390561,926589846,4439558670,21271203505,101916458856,488311090776,2339638995025,11209883884350,53709780426726,257339018249281,1232985310819680,5907587535849120,28304952368425921,135617174306280486,649780919162976510,3113287421508602065,14916656188380033816,71469993520391567016,342433311413577801265,1640696563547497439310,7861049506323909395286,37664550968072049537121,180461705334036338290320,864643975702109641914480,4142758173176511871282081,19849146890180449714495926,95102976277725736701197550,455665734498448233791491825,2183225696214515432256261576,10460462746574128927489816056,50119088036656129205192818705,240134977436706517098474277470,1150555799146876456287178568646,5512644018297675764337418565761,26412664292341502365399914260160,126550677443409836062662152735040,606340722924707677947910849415041,2905152937180128553676892094340166,13919423962975935090436549622285790,66691966877699546898505856017088785,319540410425521799402092730463158136 mov $1,8 mov $2,2 lpb $0 sub $0,1 add $2,$1 add $1,$2 add $1,$2 add $1,$2 lpe sub $1,8 div $1,6 add $1,1 mov $0,$1
src/Data/Maybe/Primitive.agda
agda/agda-data-bindings
2
15972
<filename>src/Data/Maybe/Primitive.agda module Data.Maybe.Primitive where {-# IMPORT Data.Maybe #-} -- In Agda 2.2.10 and below, there's no FFI binding for the stdlib -- Maybe type, so we have to roll our own. This will change. data #Maybe (X : Set) : Set where just : X → #Maybe X nothing : #Maybe X {-# COMPILED_DATA #Maybe Data.Maybe.Maybe Data.Maybe.Just Data.Maybe.Nothing #-}
assembly_repl/repl.asm
emmettgb/Random_Code
2
3241
<gh_stars>1-10 section .data repl_prompt: db "Heya> " ret_0: db "You entered 0!" section .bss ; Input inp resb 1 section .text global _start _exit: mov rax, 60 mov rdi, 0 syscall ; ===============| ; _START ; Prints prompt by calling _show_prompt: ;, takes input, calls _parse:, on ret, checks for change in ; exit flag. If the exit flag has not been changed, then jumps to itself. ; ===============| _start: ; Check for exit code set to 1: mov rdi, 1 cmp rdi, inp je _exit mov rdi, 0 je _retzer ; Read call _prompt call _repl_input ; Evaluate mov rsi, inp mov rax, 1 mov rdi, 1 mov rdx, 2 syscall mov rsi, 10 mov rax, 1 mov rdi, 1 mov rdx, 2 syscall ; Loop jmp _start ; ===============| ; _REPL_INPUT ; Takes kernel standard in, returns to _repl. ; ===============| _repl_input: mov rax, 0 mov rdi, 0 mov rsi, inp mov rdx, 64 syscall ret ; ===============| ; _PROMPT ; Prints prompt, returns to _repl ; ===============| _prompt: mov rax, 1 mov rdi, 1 mov rsi, repl_prompt mov rdx, 6 syscall ret _retzer: mov rax, 1 mov rdi, 1 mov rsi, ret_0 mov rdx, 14 syscall
data/mapHeaders/undergroundpathwe.asm
adhi-thirumala/EvoYellow
16
8358
<reponame>adhi-thirumala/EvoYellow<gh_stars>10-100 UndergroundPathWE_h: db UNDERGROUND ; tileset db UNDERGROUND_PATH_WE_HEIGHT, UNDERGROUND_PATH_WE_WIDTH ; dimensions (y, x) dw UndergroundPathWEBlocks, UndergroundPathWETextPointers, UndergroundPathWEScript ; blocks, texts, scripts db $00 ; connections dw UndergroundPathWEObject ; objects
programs/oeis/021/A021697.asm
neoneye/loda
22
87884
; A021697: Decimal expansion of 1/693. ; 0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1 add $0,1 mov $1,10 pow $1,$0 mul $1,5 div $1,3465 mod $1,10 mov $0,$1
programs/oeis/101/A101103.asm
neoneye/loda
22
160007
; A101103: Partial sums of A101104. First differences of A005914. ; 1,13,36,60,84,108,132,156,180,204,228,252,276,300,324,348,372,396,420,444,468,492,516,540,564,588,612,636,660,684,708,732,756,780,804,828,852,876,900,924,948,972,996,1020,1044,1068,1092,1116,1140,1164,1188,1212,1236,1260,1284,1308,1332,1356,1380,1404,1428,1452,1476,1500,1524,1548,1572,1596,1620,1644,1668,1692,1716,1740,1764,1788,1812,1836,1860,1884,1908,1932,1956,1980,2004,2028,2052,2076,2100,2124,2148,2172,2196,2220,2244,2268,2292,2316,2340,2364 sub $0,1 mul $0,12 mov $1,13 add $1,$0 trn $0,1 add $0,$1
programs/oeis/141/A141759.asm
karttu/loda
1
163469
; A141759: a(n) = 16n^2 + 32n + 15. ; 15,63,143,255,399,575,783,1023,1295,1599,1935,2303,2703,3135,3599,4095,4623,5183,5775,6399,7055,7743,8463,9215,9999,10815,11663,12543,13455,14399,15375,16383,17423,18495,19599,20735,21903,23103,24335,25599,26895,28223,29583,30975,32399,33855,35343,36863,38415,39999,41615,43263,44943,46655,48399,50175,51983,53823,55695,57599,59535,61503,63503,65535,67599,69695,71823,73983,76175,78399,80655,82943,85263,87615,89999,92415,94863,97343,99855,102399,104975,107583,110223,112895,115599,118335,121103,123903,126735,129599,132495,135423,138383,141375,144399,147455,150543,153663,156815,159999,163215,166463,169743,173055,176399,179775,183183,186623,190095,193599,197135,200703,204303,207935,211599,215295,219023,222783,226575,230399,234255,238143,242063,246015,249999,254015,258063,262143,266255,270399,274575,278783,283023,287295,291599,295935,300303,304703,309135,313599,318095,322623,327183,331775,336399,341055,345743,350463,355215,359999,364815,369663,374543,379455,384399,389375,394383,399423,404495,409599,414735,419903,425103,430335,435599,440895,446223,451583,456975,462399,467855,473343,478863,484415,489999,495615,501263,506943,512655,518399,524175,529983,535823,541695,547599,553535,559503,565503,571535,577599,583695,589823,595983,602175,608399,614655,620943,627263,633615,639999,646415,652863,659343,665855,672399,678975,685583,692223,698895,705599,712335,719103,725903,732735,739599,746495,753423,760383,767375,774399,781455,788543,795663,802815,809999,817215,824463,831743,839055,846399,853775,861183,868623,876095,883599,891135,898703,906303,913935,921599,929295,937023,944783,952575,960399,968255,976143,984063,992015,999999 mov $1,2 add $1,$0 mul $1,$0 mul $1,16 add $1,15
oeis/092/A092557.asm
neoneye/loda-programs
11
15821
<filename>oeis/092/A092557.asm ; A092557: Triangle read by rows: T(1,1) = 1; for n>=2, write the first n^2 integers in an n X n array beginning with 1 in the upper left proceeding left to right and top to bottom; then T(n,k) is the last prime in the k-th row. ; 1,2,3,3,5,7,3,7,11,13,5,7,13,19,23,5,11,17,23,29,31,7,13,19,23,31,41,47,7,13,23,31,37,47,53,61,7,17,23,31,43,53,61,71,79,7,19,29,37,47,59,67,79,89,97,11,19,31,43,53,61,73,83,97,109,113,11,23,31,47,59,71,83,89 seq $0,75362 ; Triangle read by rows with the n-th row containing the first n multiples of n. seq $0,136548 ; a(n) = max {k >= 1 | sigma(k) <= n}.
10_32bit_enter/32bit_main.asm
cristicretu/CrtOS
1
162835
[org 0x7c00] ; bootloader offset mov bp, 0x9000 ; set the stack mov sp, bp mov bx, MSG_REAL_MODE call print call switch_to_pm jmp $ ; never executed %include "../05_bootsector_functions_strings/boot_sect_print.asm" %include "../09_32bit_gdt/32bit_gdt.asm" %include "../08_32bit_print/32bit_print.asm" %include "32bit_switch.asm" [bits 32] BEGIN_PM: mov ebx, MSG_PROT_MODE call print_string_pm jmp $ MSG_REAL_MODE db "Started in 16-bit real mode", 0 MSG_PROT_MODE db "Loaded 32-bit protected mode", 0 ; bootsector times 510-($-$$) db 0 dw 0xaa55
asm/spim/csc-201/t3.asm
dindoliboon/archive
4
87079
<gh_stars>1-10 # ========================================================================= # # NAME: # DATE: June 13, 2001 # ASSIGNMENT: Test #3, CSC-201-01 # OBJECTIVE: Find min/max values # # ========================================================================= .data .align 2 # ========================================================================= newline: .asciiz "\n" prompt1: .asciiz "Enter 10 integers\n" prompt2: .asciiz "Min value is: " prompt3: .asciiz "Max value is: " # ========================================================================= .text .align 2 # ========================================================================= # PURPOSE: Read a set of 10 integers and find min/max values # INPUT: n/a # OUTPUT: n/a # ========================================================================= # $t0 - counter # $t1 - last value # $t2 - test value # $s0 - min # $s1 - max # ========================================================================= proc_1: la $a0, prompt1 li $v0, 4 syscall # print "Enter numbers" add $t0, $zero, $zero add $t1, $zero, $zero add $t2, $zero, $zero add $s0, $zero, $zero add $s1, $zero, $zero # initalize values to 0 read: beq $t0, 10, reade # exit if counter is equal to 10 li $v0, 5 syscall # read integer move $t1, $v0 # save last value add $t0, $t0, 1 # increment counter beq $t2, 0, enable0 # if $t2 == 0, goto enable0 j noenable enable0: add $t2, $zero, 1 # set temp to 1 add $s0, $zero, $t0 # save last value add $s1, $zero, $t0 # save last value noenable: bgt $t1, $s1, set_max # if input > max, goto set_max blt $t1, $s0, set_min # if input < min, goto set_min j read # jump to beginning of loop set_max: add $s1, $t1, $zero # save max j read set_min: add $s0, $t1, $zero # save min j read reade: jr $ra # ========================================================================= # PURPOSE: Display min/max values # INPUT: n/a # OUTPUT: n/a # ========================================================================= proc_2: la $a0, prompt2 li $v0, 4 syscall # print "Min is ..." add $a0, $s0, $zero li $v0, 1 syscall # print min la $a0, newline li $v0, 4 syscall # print newline la $a0, prompt3 li $v0, 4 syscall # print "Max is ..." add $a0, $s1, $zero li $v0, 1 syscall # print max la $a0, newline li $v0, 4 syscall # print newline jr $ra # ========================================================================= # PURPOSE: Call min/max values and print integers # INPUT: n/a # OUTPUT: n/a # ========================================================================= main: jal proc_1 # get min/max values jal proc_2 # display min/max values li $v0, 10 syscall # exit the program # ========================================================================= # :::::::::::::::::::::::::::: END OF PROGRAM! :::::::::::::::::::::::::::: # =========================================================================
mips8.asm
SCGTall/Water
1
81137
#x from 10 - 370, y from 100 - 200, cube 45 x 25, word 8 x 16 .text li $a2, 0xFFFFFFFF li $s0, 190 li $s1, 150 li $s2, 78 li $s7, 10 move $s3, $s0 move $s4, $s1 div $s2, $s7 mfhi $s6 mflo $s5 add $a0, $s5, $zero jal read addi $s0, $s3, 12 move $s1, $s4 add $a0, $s6, $zero jal read move $s0, $s3 move $s1, $s4 j exit read: addi $sp, $sp, -4 sw $ra, ($sp) move $s2, $a0 beq $s2, 0, draw0 beq $s2, 1, draw1 beq $s2, 2, draw2 beq $s2, 3, draw3 beq $s2, 4, draw4 beq $s2, 5, draw5 beq $s2, 6, draw6 beq $s2, 7, draw7 beq $s2, 8, draw8 beq $s2, 9, draw9 lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw0: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col addi $s0, $s0, -8 addi $s1, $s1, -16 addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col addi $t6, $s0, 8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw1: addi $sp, $sp, -4 sw $ra, ($sp) addi $s0, $s0, 8 addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw2: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s0, 0 addi $s0, $s0, -8 jal row addi $s0, $s0, -8 addi $t6, $s1, 8 jal col addi $t6, $s0, 8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw3: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col addi $t6, $s0, 0 addi $s0, $s0, -8 jal row addi $s0, $s0, -8 addi $s1, $s1, -8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw4: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s1, 8 jal col addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $s1, $s1, -16 addi $t6, $s1, 8 jal col lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw5: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s1, 8 jal col addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s0, 0 addi $s0, $s0, -8 jal row addi $s0, $s0, -8 addi $s1, $s1, -16 addi $t6, $s0, 8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw6: addi $sp, $sp, -4 sw $ra, ($sp) jal draw5 addi $s0, $s0, -8 addi $s1, $s1, 8 addi $t6, $s1, 8 jal col lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw7: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw8: addi $sp, $sp, -4 sw $ra, ($sp) jal draw0 addi $t6, $s0, 0 addi $s0, $s0, -8 addi $s1, $s1, -8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra draw9: addi $sp, $sp, -4 sw $ra, ($sp) addi $t6, $s0, 8 jal row addi $t6, $s1, 8 jal col addi $t6, $s1, 8 jal col addi $s0, $s0, -8 addi $s1, $s1, -16 addi $t6, $s1, 8 jal col addi $t6, $s0, 8 jal row addi $t6, $s0, 0 addi $s0, $s0, -8 addi $s1, $s1, 8 jal row lw $ra, ($sp) addi $sp, $sp, 4 jr $ra row: ble $s0, $t6, DrawRow addi $s0, $s0, -1 jr $ra col: ble $s1, $t6, DrawCol addi $s1, $s1, -1 jr $ra DrawRow: li $t3, 0x10000100 #t3 = first Pixel of the screen sll $t0, $s1, 9 #y = y * 512 addu $t0, $t0, $s0 # (xy) t0 = x + y sll $t0, $t0, 2 # (xy) t0 = xy * 4 addu $t0, $t3, $t0 # adds xy to the first pixel ( t3 ) sw $a2, ($t0) # put the color ($a2) in $t0 addi $s0, $s0, 1 #adds 1 to the X of the head j row DrawCol: li $t3, 0x10000100 #t3 = first Pixel of the screen sll $t0, $s1, 9 #y = y * 512 addu $t0, $t0, $s0 # (xy) t0 = x + y sll $t0, $t0, 2 # (xy) t0 = xy * 4 addu $t0, $t3, $t0 # adds xy to the first pixel ( t3 ) sw $a2, ($t0) # put the color ($a2) in $t0 addi $s1, $s1, 1 #adds 1 to the X of the head j col exit: li $v0, 10 syscall
oeis/038/A038556.asm
neoneye/loda-programs
11
179238
<gh_stars>10-100 ; A038556: Periodic derivative of n. ; 0,0,3,0,5,6,3,0,9,10,15,12,5,6,3,0,17,18,23,20,29,30,27,24,9,10,15,12,5,6,3,0,33,34,39,36,45,46,43,40,57,58,63,60,53,54,51,48,17,18,23,20,29,30,27,24,9,10,15,12,5,6,3,0,65,66,71,68,77,78,75,72,89,90,95,92,85,86,83,80,113,114,119,116,125,126,123,120,105,106,111,108,101,102,99,96,33,34,39,36 mul $0,2 add $0,1 seq $0,38554 ; Derivative of n: write n in binary, replace each pair of adjacent bits with their mod 2 sum (a(0)=a(1)=0 by convention). Also n XOR (n shift 1).
test/Fail/Issue610.agda
redfish64/autonomic-agda
3
5199
-- Andreas, 2012-04-18, bug reported by pumpkingod on 2012-04-16 module Issue610 where import Common.Level open import Common.Equality data ⊥ : Set where record ⊤ : Set where record A : Set₁ where constructor set field .a : Set .get : A → Set get x = helper x module R where helper : .A -> Set helper x = A.a x ack : A → Set ack x = R.helper x x -- Expected error: -- Identifier R.helper is declared irrelevant, so it cannot be used here hah : set ⊤ ≡ set ⊥ hah = refl .moo : ⊥ moo with cong ack hah moo | q = subst (λ x → x) q _ baa : .⊥ → ⊥ baa () yoink : ⊥ yoink = baa moo
programs/oeis/078/A078070.asm
karttu/loda
0
242019
<reponame>karttu/loda ; A078070: Expansion of (1-x)/(1 + 2*x + 2*x^2 + x^3). ; 1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3,1,0,1,-3,4,-3 mov $1,$0 add $0,2 add $1,$0 pow $1,2 div $1,3 mov $0,$1 lpb $0,1 sub $0,8 lpe mov $1,$0
falling.asm
gasman/kisskill
2
17567
<reponame>gasman/kisskill falling ; ld b,50 ; 300 frames, 6 frames on each iteration ld b,44 ; a bit less, so that we have fuzz afterwards fall_lp push bc halt call do_wall call upd_spr32 call upd_spr24 call upd_spr16 halt call do_wall call upd_spr32 halt call do_wall call upd_spr32 call upd_spr24 halt call do_wall call upd_spr32 call upd_spr16 halt call do_wall call upd_spr32 call upd_spr24 halt call do_wall call upd_spr32 pop bc djnz fall_lp ret upd_spr32 spr32pos ld b,0 ; y ld c,16 ; x call sprite32 ld a,(spr32pos+1) inc a cp 192 ret z ld (spr32pos+1),a ret upd_spr24 spr24pos ld b,32 ld c,0x1c call sprite24 ld a,(spr24pos+1) inc a cp 192 ret z ld (spr24pos+1),a ret upd_spr16 spr16pos ld b,88 ld c,0x02 call sprite16 ld a,(spr16pos+1) inc a cp 192 ret z ld (spr16pos+1),a ret do_wall wall_pos ld hl,wall_bg ld de,0x5800 ld b,24 wall_row push bc rept 32 ldi endm pop bc ld a,h and 1 + (high wall_bg) ld h,a djnz wall_row ld hl,(wall_pos+1) ld bc,32 add hl,bc ld a,h and 1 + (high wall_bg) ld h,a ld (wall_pos+1),hl ret ; enter with b=y (pix), c=x (char); return with screen address in de calc_screen_addr ld l,b ; y ld h,high ypositions ld a,(hl) add a,c ; x ld e,a inc h ld d,(hl) ret sprite32 call calc_screen_addr ld hl,falling_32 ld b,96 sprite32lp push bc push de ldi ldi ldi ldi pop de call upde pop bc ld a,0x58 cp d ret z djnz sprite32lp ret sprite24 call calc_screen_addr ld hl,falling_24 ld b,72 sprite24lp push bc push de ldi ldi ldi pop de call upde pop bc ld a,0x58 cp d ret z djnz sprite24lp ret sprite16 call calc_screen_addr ld hl,falling_16 ld b,48 sprite16lp push bc push de ldi ldi pop de call upde pop bc ld a,0x58 cp d ret z djnz sprite16lp ret ;upde ; inc d ; ld a,d ; and 7 ; ret nz ; ld a,e ; add a,32 ; ld e,a ; ret c ; ld a,d ; sub 8 ; ld d,a ; ret falling_32 incbin "falling-32x96.bin" falling_24 incbin "falling-24x72.bin" falling_16 incbin "falling-16x48.bin" align 0x0200 wall_bg db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7,23, 7, 7, 7, 7, 7, 7 db 23, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7,23, 7,23, 7, 7, 7, 7, 7, 7, 7 db 7,23, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7 db 7, 7,23, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7,23, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7 db 7, 7, 7,23, 7, 7, 7,23, 7,23, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7 db 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7 db 7,23, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7 db 7, 7,23, 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7,23, 7, 7, 7, 7, 7 db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 db 7, 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7,23, 7,23, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7 db 7, 7, 7,23, 7, 7, 7, 7,23, 7, 7, 7, 7, 7,23, 7, 7,23, 7,23, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7,23 db 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7 db 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,23, 7, 7 ypositions rept 256, n db (n & 0x38)<<2 endm rept 256, n db 0x40|(n & 0x07)|(n & 0xc0)>>3 endm
source/oasis/program-elements-parameter_associations.ads
reznikmm/gela
0
23385
<filename>source/oasis/program-elements-parameter_associations.ads -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Element_Vectors; with Program.Elements.Associations; with Program.Elements.Expressions; with Program.Lexical_Elements; package Program.Elements.Parameter_Associations is pragma Pure (Program.Elements.Parameter_Associations); type Parameter_Association is limited interface and Program.Elements.Associations.Association; type Parameter_Association_Access is access all Parameter_Association'Class with Storage_Size => 0; not overriding function Formal_Parameter (Self : Parameter_Association) return Program.Elements.Expressions.Expression_Access is abstract; not overriding function Actual_Parameter (Self : Parameter_Association) return not null Program.Elements.Expressions.Expression_Access is abstract; type Parameter_Association_Text is limited interface; type Parameter_Association_Text_Access is access all Parameter_Association_Text'Class with Storage_Size => 0; not overriding function To_Parameter_Association_Text (Self : in out Parameter_Association) return Parameter_Association_Text_Access is abstract; not overriding function Arrow_Token (Self : Parameter_Association_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; type Parameter_Association_Vector is limited interface and Program.Element_Vectors.Element_Vector; type Parameter_Association_Vector_Access is access all Parameter_Association_Vector'Class with Storage_Size => 0; overriding function Element (Self : Parameter_Association_Vector; Index : Positive) return not null Program.Elements.Element_Access is abstract with Post'Class => Element'Result.Is_Parameter_Association; function To_Parameter_Association (Self : Parameter_Association_Vector'Class; Index : Positive) return not null Parameter_Association_Access is (Self.Element (Index).To_Parameter_Association); end Program.Elements.Parameter_Associations;
src/tests/gpuinferencetests.adb
sebsgit/textproc
0
2617
<filename>src/tests/gpuinferencetests.adb with AUnit.Assertions; use AUnit.Assertions; with Ada.Text_IO; with System; use System; with Ada.Containers; use Ada.Containers; with opencl; use opencl; with cl_objects; with GpuInference; with NeuralNet; with MathUtils; with Timer; package body GpuInferenceTests is procedure Register_Tests (T: in out TestCase) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, initOpenCL'Access, "init opencl"); Register_Routine (T, testGpuWeightUpload'Access, "Gpu NN weights test"); Register_Routine (T, testGpuWeightApply'Access, "Gpu NN weights apply test"); Register_Routine (T, testGpuForward'Access, "Gpu NN forward"); Register_Routine (T, testGpuForwardLargeNN'Access, "Gpu NN forward (big nn)"); end Register_Tests; function Name(T: TestCase) return Test_String is begin return Format("GPU Inference Tests"); end Name; procedure initOpenCL(T: in out Test_Cases.Test_Case'Class) is cl_status: opencl.Status; begin cl_status := opencl.Init(opencl.Get_OpenCL_Path(opencl.ARCH_32)); Assert(cl_status = opencl.SUCCESS, "init: " & cl_status'Image); end initOpenCL; procedure testGpuWeightUpload(T : in out Test_Cases.Test_Case'Class) is config: NeuralNet.Config(2); net: NeuralNet.Net(config.size); cl_code: opencl.Status; gpu_context: aliased cl_objects.Context := cl_objects.Create_Gpu(result_status => cl_code); gpu_queue: cl_objects.Command_Queue := gpu_context.Create_Command_Queue(result_status => cl_code); begin Assert(cl_code = opencl.SUCCESS, "Create context: " & cl_code'Image); config.inputSize := 1; config.act := NeuralNet.RELU; config.sizes := (2, 1); net := NeuralNet.create(config); Assert(net.layers.Length = 2, "layer count"); Assert(net.layers(1).Length = 2, "neurons in layer 1"); Assert(net.layers(2).Length = 1, "neurons in output layer"); -- hardcode biases and weights net.layers(1)(1).bias := 0.3; net.layers(1)(1).w := (1 => 0.5); net.layers(1)(2).bias := 0.7; net.layers(1)(2).w := (1 => 0.1); net.layers(2)(1).bias := 0.1; net.layers(2)(1).w := (0.4, 0.6); declare weight_buff: cl_objects.Buffer := GpuInference.Upload_Weights(ctx => gpu_context, nn => net, cl_code => cl_code); type HostWeightBuff is array (Positive range<>) of opencl.cl_float; host_weights: aliased HostWeightBuff(1 .. 4) := (others => 0.0); begin Assert(cl_code = opencl.SUCCESS, "Upload buffer: " & cl_code'Image); declare empty_ev: opencl.Events(1 .. 0); ev: cl_objects.Event := cl_objects.Enqueue_Read(queue => gpu_queue, mem_ob => weight_buff, offset => 0, size => 4 * 4, ptr => host_weights'Address, events_to_wait_for => empty_ev, code => cl_code); begin cl_code := ev.Wait; Assert(cl_code = opencl.SUCCESS, "Download buffer: " & cl_code'Image); Assert(host_weights(1) = 0.5, "w0"); Assert(host_weights(2) = 0.1, "w1"); Assert(host_weights(3) = 0.4, "w2"); Assert(host_weights(4) = 0.6, "w3"); end; end; end testGpuWeightUpload; procedure testGpuWeightApply(T : in out Test_Cases.Test_Case'Class) is config: NeuralNet.Config(2); net: NeuralNet.Net(config.size); cl_code: opencl.Status; gpu_context: aliased cl_objects.Context := cl_objects.Create_Gpu(result_status => cl_code); gpu_queue: cl_objects.Command_Queue := gpu_context.Create_Command_Queue(result_status => cl_code); begin Assert(cl_code = opencl.SUCCESS, "Create context: " & cl_code'Image); config.inputSize := 1; config.act := NeuralNet.RELU; config.sizes := (2, 1); net := NeuralNet.create(config); Assert(net.layers.Length = 2, "layer count"); Assert(net.layers(1).Length = 2, "neurons in layer 1"); Assert(net.layers(2).Length = 1, "neurons in output layer"); -- hardcode biases and weights net.layers(1)(1).bias := 0.3; net.layers(1)(1).w := (1 => 0.5); net.layers(1)(2).bias := 0.7; net.layers(1)(2).w := (1 => 0.1); net.layers(2)(1).bias := 0.1; net.layers(2)(1).w := (0.4, 0.6); declare type InputHostBuff is array(Positive range <>) of opencl.cl_float; input_host_buff: aliased InputHostBuff := (1 => 0.1, 2 => 0.2); input_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False), size => 2 * 4, host_ptr => input_host_buff'Address, result_status => cl_code); output_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.ALLOC_HOST_PTR => True, others => False), size => 4 * 4, host_ptr => System.Null_Address, result_status => cl_code); gpu_nn: constant GpuInference.NNData := GpuInference.Create(ctx => gpu_context'Unchecked_Access, nn => net, cl_code => cl_code); begin Assert(cl_code = opencl.SUCCESS, "GPU NN: " & cl_code'Image); declare type HostResultBuff is array (Positive range<>) of opencl.cl_float; host_result: aliased HostResultBuff(1 .. 4) := (others => 0.0); empty_ev: opencl.Events(1 .. 0); ev: constant cl_objects.Event := gpu_nn.Multiply_Weights(input => input_buff, output => output_buff, weight_offset => 0, layer_size => 2, output_size => 4, events_to_wait => empty_ev, cl_code => cl_code); downl_ev: cl_objects.Event := gpu_queue.Enqueue_Read(mem_ob => output_buff, offset => 0, size => 4 * 4, ptr => host_result'Address, events_to_wait_for => (1 => ev.Get_Handle), code => cl_code); begin cl_code := downl_ev.Wait; Assert(cl_code = opencl.SUCCESS, "result download: " & cl_code'Image); Assert(abs(host_result(1) - 0.1 * 0.5) < 0.001, "r0: " & host_result(1)'Image); Assert(abs(host_result(2) - 0.2 * 0.1) < 0.001, "r1: " & host_result(2)'Image); Assert(abs(host_result(3) - 0.1 * 0.4) < 0.001, "r2: " & host_result(3)'Image); Assert(abs(host_result(4) - 0.2 * 0.6) < 0.001, "r3: " & host_result(4)'Image); declare reduce_ev: constant cl_objects.Event := gpu_nn.Reduce_Activate(input => output_buff, output => input_buff, bias_offset => 0, layer_size => 2, output_size => 2, events_to_wait => empty_ev, cl_code => cl_code); downl_2_ev: cl_objects.Event := gpu_queue.Enqueue_Read(mem_ob => input_buff, offset => 0, size => 2 * 4, ptr => host_result'Address, events_to_wait_for => (1 => reduce_ev.Get_Handle), code => cl_code); begin Assert(cl_code = opencl.SUCCESS, "enq read: " & cl_code'Image); cl_code := downl_2_ev.Wait; Assert(cl_code = opencl.SUCCESS, "result download: " & cl_code'Image); Assert(abs(host_result(1) - (0.3 + 0.1 * 0.5 + 0.2 * 0.1)) < 0.001, "r0: " & host_result(1)'Image); Assert(abs(host_result(2) - (0.7 + 0.1 * 0.4 + 0.2 * 0.6)) < 0.001, "r1: " & host_result(2)'Image); end; end; end; end testGpuWeightApply; procedure testGpuForward(T : in out Test_Cases.Test_Case'Class) is config: NeuralNet.Config(2); net: NeuralNet.Net(config.size); cl_code: opencl.Status; gpu_context: aliased cl_objects.Context := cl_objects.Create_Gpu(result_status => cl_code); gpu_queue: cl_objects.Command_Queue := gpu_context.Create_Command_Queue(result_status => cl_code); cpu_results: MathUtils.Vector; cpu_result: Float := 0.0; input_value: Float; cpu_input: MathUtils.Vector; begin Assert(cl_code = opencl.SUCCESS, "Create context: " & cl_code'Image); config.inputSize := 1; config.act := NeuralNet.RELU; config.sizes := (2, 1); net := NeuralNet.create(config); Assert(net.layers.Length = 2, "layer count"); Assert(net.layers(1).Length = 2, "neurons in layer 1"); Assert(net.layers(2).Length = 1, "neurons in output layer"); input_value := 0.7; -- hardcode biases and weights net.layers(1)(1).bias := 0.5; net.layers(1)(1).w := (1 => 0.3); net.layers(1)(2).bias := 0.2; net.layers(1)(2).w := (1 => 0.17); net.layers(2)(1).bias := 0.7; net.layers(2)(1).w := (0.4, 0.9); cpu_input.Append(input_value); cpu_results := net.forward(cpu_input); cpu_result := cpu_results(1); declare null_events: opencl.Events(1 .. 0); type HostBuff is array (Positive range<>) of opencl.cl_float; host_input: aliased HostBuff(1 .. 1) := (others => opencl.cl_float(input_value)); host_result: aliased HostBuff(1 .. 1) := (others => 0.0); input_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False), size => 4, host_ptr => host_input'Address, result_status => cl_code); output_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.ALLOC_HOST_PTR => True, others => False), size => 4, host_ptr => System.Null_Address, result_status => cl_code); gpu_nn: constant GpuInference.NNData := GpuInference.Create(ctx => gpu_context'Unchecked_Access, nn => net, cl_code => cl_code); forward_ev: cl_objects.Event := gpu_nn.Forward(input => input_buff, output => output_buff, events_to_wait => null_events, cl_code => cl_code); begin Assert(cl_code = opencl.SUCCESS, "forward values"); cl_code := forward_ev.Wait; Assert(cl_code = opencl.SUCCESS, "wait for forward"); declare downl_ev: cl_objects.Event := gpu_queue.Enqueue_Read(mem_ob => output_buff, offset => 0, size => 4, ptr => host_result'Address, events_to_wait_for => null_events, code => cl_code); begin cl_code := downl_ev.Wait; Assert(cl_code = opencl.SUCCESS, "download result"); Assert(abs(Float(host_result(1)) - cpu_result) < 0.001, "Gpu nn forward fail"); end; end; end testGpuForward; procedure testGpuForwardLargeNN(T : in out Test_Cases.Test_Case'Class) is config: NeuralNet.Config(2); net: NeuralNet.Net(config.size); cl_code: opencl.Status; gpu_context: aliased cl_objects.Context := cl_objects.Create_Gpu(result_status => cl_code); gpu_queue: cl_objects.Command_Queue := gpu_context.Create_Command_Queue(result_status => cl_code); cpu_results: MathUtils.Vector; cpu_input: MathUtils.Vector; tmr: Timer.T; begin Assert(cl_code = opencl.SUCCESS, "Create context: " & cl_code'Image); config.inputSize := 32 * 37; config.act := NeuralNet.RELU; config.sizes := (150, 25); net := NeuralNet.create(config); for i in 1 .. config.inputSize loop cpu_input.Append(Float(i) / Float(config.inputSize)); end loop; tmr := Timer.start; cpu_results := net.forward(cpu_input); tmr.report("NN inference CPU"); declare null_events: opencl.Events(1 .. 0); type HostBuff is array (Positive range<>) of opencl.cl_float; host_input: aliased HostBuff(1 .. Positive(cpu_input.Length)) := (others => 0.0); host_result: aliased HostBuff(1 .. Positive(cpu_results.Length)) := (others => 0.0); begin for i in 1 .. cpu_input.Length loop declare value: constant Float := cpu_input(Positive(i)); begin host_input(Integer(i)) := opencl.cl_float(value); end; end loop; tmr.reset; declare input_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False), size => 4 * Integer(cpu_input.Length), host_ptr => host_input'Address, result_status => cl_code); output_buff: cl_objects.Buffer := gpu_context.Create_Buffer(flags => (opencl.ALLOC_HOST_PTR => True, others => False), size => 4 * Integer(cpu_results.Length), host_ptr => System.Null_Address, result_status => cl_code); gpu_nn: constant GpuInference.NNData := GpuInference.Create(ctx => gpu_context'Unchecked_Access, nn => net, cl_code => cl_code); forward_ev: cl_objects.Event := gpu_nn.Forward(input => input_buff, output => output_buff, events_to_wait => null_events, cl_code => cl_code); begin Assert(cl_code = opencl.SUCCESS, "forward values"); cl_code := forward_ev.Wait; tmr.report("NN inference GPU"); Assert(cl_code = opencl.SUCCESS, "wait for forward"); declare downl_ev: cl_objects.Event := gpu_queue.Enqueue_Read(mem_ob => output_buff, offset => 0, size => 4 * Integer(cpu_results.Length), ptr => host_result'Address, events_to_wait_for => null_events, code => cl_code); begin cl_code := downl_ev.Wait; Assert(cl_code = opencl.SUCCESS, "download result"); for i in 1 .. cpu_results.Length loop Assert(abs(Float(host_result(Integer(i))) - cpu_results(Positive(i))) < 0.001, "Gpu nn forward fail"); end loop; end; end; end; end testGpuForwardLargeNN; end GpuInferenceTests;
smsq/qpc/dos/close.asm
olifink/smsqe
0
14326
<reponame>olifink/smsqe<gh_stars>0 ; Close DOS V1.01  1997 <NAME> ; ; 2018-12-31 1.01 Adapted for new QPC2v5 DOS driver section dos xdef dos_close xref iou_achb xref iou_rchb xref ioa_cknm include 'dev8_keys_err' include 'dev8_keys_sys' include 'dev8_keys_chn' include 'dev8_keys_iod' include 'dev8_keys_qlv' include 'dev8_smsq_qpc_dos_data' include 'dev8_smsq_qpc_keys' dos_close reglist reg a3/a4 movem.l reglist,-(sp) move.l chn_hand(a0),d1 dc.w qpc.dclse cmp.b #4,chn_accs(a0) bne.s dos_smsclose dc.w qpc.ddelt ; Delete temporary directory file dos_smsclose move.l chn_ddef(a0),a4 ; Physical definition subq.b #1,iod_nrfl(a4) ; decrement file count lea chn_link(a0),a0 lea sys_fsch(a6),a1 move.w mem.rlst,a2 jsr (a2) ; unlink file from list lea -chn_link(a0),a0 move.w mem.rchp,a2 jsr (a2) movem.l (sp)+,reglist rts end
libsrc/_DEVELOPMENT/setjmp/c/sccz80/l_setjmp.asm
jpoikela/z88dk
640
100332
<reponame>jpoikela/z88dk ; djm 28/2/2000 ; int l_setjmp(jmp_buf *env) SECTION code_clib SECTION code_setjmp PUBLIC l_setjmp EXTERN error_znc l_setjmp: pop bc pop de push de push bc ld hl,2 add hl,sp ex de,hl ; hl = jmp_buf *env ; de = sp at return address ; bc = return address ld (hl),e inc hl ld (hl),d inc hl ld (hl),c inc hl ld (hl),b jp error_znc
vp8/encoder/ppc/sad_altivec.asm
mrchapp/libvpx
1
246340
<filename>vp8/encoder/ppc/sad_altivec.asm ; ; Copyright (c) 2010 The VP8 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. ; .globl vp8_sad16x16_ppc .globl vp8_sad16x8_ppc .globl vp8_sad8x16_ppc .globl vp8_sad8x8_ppc .globl vp8_sad4x4_ppc .macro load_aligned_16 V R O lvsl v3, 0, \R ;# permutate value for alignment lvx v1, 0, \R lvx v2, \O, \R vperm \V, v1, v2, v3 .endm .macro prologue mfspr r11, 256 ;# get old VRSAVE oris r12, r11, 0xffc0 mtspr 256, r12 ;# set VRSAVE stwu r1, -32(r1) ;# create space on the stack li r10, 16 ;# load offset and loop counter vspltisw v8, 0 ;# zero out total to start .endm .macro epilogue addi r1, r1, 32 ;# recover stack mtspr 256, r11 ;# reset old VRSAVE .endm .macro SAD_16 ;# v6 = abs (v4 - v5) vsububs v6, v4, v5 vsububs v7, v5, v4 vor v6, v6, v7 ;# v8 += abs (v4 - v5) vsum4ubs v8, v6, v8 .endm .macro sad_16_loop loop_label lvsl v3, 0, r5 ;# only needs to be done once per block ;# preload a line of data before getting into the loop lvx v4, 0, r3 lvx v1, 0, r5 lvx v2, r10, r5 add r5, r5, r6 add r3, r3, r4 vperm v5, v1, v2, v3 .align 4 \loop_label: ;# compute difference on first row vsububs v6, v4, v5 vsububs v7, v5, v4 ;# load up next set of data lvx v9, 0, r3 lvx v1, 0, r5 lvx v2, r10, r5 ;# perform abs() of difference vor v6, v6, v7 add r3, r3, r4 ;# add to the running tally vsum4ubs v8, v6, v8 ;# now onto the next line vperm v5, v1, v2, v3 add r5, r5, r6 lvx v4, 0, r3 ;# compute difference on second row vsububs v6, v9, v5 lvx v1, 0, r5 vsububs v7, v5, v9 lvx v2, r10, r5 vor v6, v6, v7 add r3, r3, r4 vsum4ubs v8, v6, v8 vperm v5, v1, v2, v3 add r5, r5, r6 bdnz \loop_label vspltisw v7, 0 vsumsws v8, v8, v7 stvx v8, 0, r1 lwz r3, 12(r1) .endm .macro sad_8_loop loop_label .align 4 \loop_label: ;# only one of the inputs should need to be aligned. load_aligned_16 v4, r3, r10 load_aligned_16 v5, r5, r10 ;# move onto the next line add r3, r3, r4 add r5, r5, r6 ;# only one of the inputs should need to be aligned. load_aligned_16 v6, r3, r10 load_aligned_16 v7, r5, r10 ;# move onto the next line add r3, r3, r4 add r5, r5, r6 vmrghb v4, v4, v6 vmrghb v5, v5, v7 SAD_16 bdnz \loop_label vspltisw v7, 0 vsumsws v8, v8, v7 stvx v8, 0, r1 lwz r3, 12(r1) .endm .align 2 ;# r3 unsigned char *src_ptr ;# r4 int src_stride ;# r5 unsigned char *ref_ptr ;# r6 int ref_stride ;# ;# r3 return value vp8_sad16x16_ppc: prologue li r9, 8 mtctr r9 sad_16_loop sad16x16_loop epilogue blr .align 2 ;# r3 unsigned char *src_ptr ;# r4 int src_stride ;# r5 unsigned char *ref_ptr ;# r6 int ref_stride ;# ;# r3 return value vp8_sad16x8_ppc: prologue li r9, 4 mtctr r9 sad_16_loop sad16x8_loop epilogue blr .align 2 ;# r3 unsigned char *src_ptr ;# r4 int src_stride ;# r5 unsigned char *ref_ptr ;# r6 int ref_stride ;# ;# r3 return value vp8_sad8x16_ppc: prologue li r9, 8 mtctr r9 sad_8_loop sad8x16_loop epilogue blr .align 2 ;# r3 unsigned char *src_ptr ;# r4 int src_stride ;# r5 unsigned char *ref_ptr ;# r6 int ref_stride ;# ;# r3 return value vp8_sad8x8_ppc: prologue li r9, 4 mtctr r9 sad_8_loop sad8x8_loop epilogue blr .macro transfer_4x4 I P lwz r0, 0(\I) add \I, \I, \P lwz r7, 0(\I) add \I, \I, \P lwz r8, 0(\I) add \I, \I, \P lwz r9, 0(\I) stw r0, 0(r1) stw r7, 4(r1) stw r8, 8(r1) stw r9, 12(r1) .endm .align 2 ;# r3 unsigned char *src_ptr ;# r4 int src_stride ;# r5 unsigned char *ref_ptr ;# r6 int ref_stride ;# ;# r3 return value vp8_sad4x4_ppc: prologue transfer_4x4 r3, r4 lvx v4, 0, r1 transfer_4x4 r5, r6 lvx v5, 0, r1 vspltisw v8, 0 ;# zero out total to start ;# v6 = abs (v4 - v5) vsububs v6, v4, v5 vsububs v7, v5, v4 vor v6, v6, v7 ;# v8 += abs (v4 - v5) vsum4ubs v7, v6, v8 vsumsws v7, v7, v8 stvx v7, 0, r1 lwz r3, 12(r1) epilogue blr
Lab 5/lab5-P2.asm
AndrewDichabeng/Computer-Systems-Foundations
0
18797
; Lab5 - Subroutine to print a record from an array of structures ; Constant definitions Display .EQU 04E9h ; address of Libra display ; Constant strings (prompts or labels to be printed to screen, etc) s_name: .DB 'Name: $' s_male: .DB 'Mr. $' s_female: .DB 'Ms. $' s_empNum: .DB 'Employee number: $' s_salary: .DB 'Salary: $' ; Offsets to access individual fields within the records ID .EQU 0 ; Zero bytes from start of record is ID NAME .EQU 1 ; One byte from start of record is name GENDER .EQU 3 ; 3 bytes from start of record is gender SALARY .EQU 4 ; 4 bytes from start of record is salary REC_SIZE .EQU 5 ; Total size of each record is 5 bytes ; Other defines male .EQU 0 ; Gender field: 0=male female .EQU 1 ; Gender field: 1=female ; --------------------------------------------------------------- ; Function: printEmployee ; Function to print an employee record to screen. ; Input Parameters: ; BX: Address of start of array of structures ; AL: Record number to be printed (record numbering starts at 0) ; Output Paramters: ; None. ; --------------------------------------------------------------- printEmployee: ; Save register values that will be modified in this routine push AX ; FIXED push BX ; FIXED push SI ; FIXED ; Calculate starting address of this record ; Starting address is START+(REC_NUM*REC_SIZE) mov AH, REC_SIZE ; FIXED Load REC_SIZE into AH mul AH ; FIXED Multiply REC_NUM (already in AL) by REC_SIZE (in AH) add Bx,Ax ; FIXED Compute START+(REC_NUM*REC_SIZE) ; Print 'Name: ' label mov SI, s_name ; FIXED call printStr ; Print Mr/Mrs according to gender mov AL, [BX+3] ; FIXED Load the gender field into AL. Need to use displacement addressing mode cmp AL, male ; Compare gender to zero je printMale printFemale: mov SI, s_female ; FIXED Print Ms. call printStr jmp printName printMale: mov SI, s_male ; FIXED Print Mr. call printStr ; Print name. Must load name pointer into DX, then call printStr printName: mov SI, [BX+1] ; FIXED Load the name field into SI. Need to use displacement addressing mode call printStr call newLine ; Print a newLine character ; Print employee number printEmpNum: mov AL, [s_empNum] ; FIXEDPrint 'Employee number: ' call printStr mov AL, [BX] ; FIXED Load the ID field into AL. Need to use displacement addressing mode call printInt call newLine ; Print employee salary printEmpSalary: mov AL, [s_salary] ; FIXED Print the 'Salary: ' label call printStr mov AL, [BX+4] ; FIXED Load the SALARY field into AL. Need to use displacement addressing mode call printSalary ; Prints salary in 1000's of $ call newLine ; Print a newline ; Restore registers pop SI ; FIXED pop BX ; FIXED pop AX ; FIXED ; Return to calling function RET ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; INSERT SUBROUTINES FROM lab5-P1.asm HERE ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; --------------------------------------------------------------- ; printStr: Subroutine to print a '$'-terminated string ; Input parameters: ; SI: Address of start of string to be printed ; Output parameters: ; None. ; --------------------------------------------------------------- printStr: ; Save registers modified by this subroutine push AX ; FIXED push CX ; FIXED push DX ; FIXED mov DX, Display LoopPS: mov AL, [SI] ; Load the next char to be printed - USING INPUT PARAMETER SI cmp AL, '$' ; Compare the char to '$' je quitPS ; If it is equal, then quit subroutine and return to calling code out DX,AL ; If it is not equal to '$', then print it inc SI ; Point to the next char to be printed jmp LoopPS ; Jump back to the top of the loop quitPS: ; Restore registers pop DX ; FIXED pop CX ; FIXED pop AX ; FIXED RET ; --------------------------------------------------------------- ; printInt: Subroutine to print a 1-byte unsigned (short) integer between 0-255 ; Input parameters: ; AL: Unsigned short int to be printed ; Output parameters: ; None. ; --------------------------------------------------------------- printInt: ; Save registers modified by this subroutine push AX ; FIXED push CX ; FIXED push DX ; FIXED mov DX, Display mov CL, 10 ; Will be dividing by 10... LoopPI: cmp AL, 10 ; Compare the number to 10 jl printLast ; If it is less than 10, then print this digit ; If it is greater than 10, divide by 10 mov AH, 0 ; Clear AH div CL ; Divide number by 10 call printDigit ; Print the quotient in AL mov AL, AH ; Move remainder into AL to be printed jmp LoopPI ; Jump back to the top of the loop printLast: call printDigit ; Restore registers pop DX ; FIXED pop CX ; FIXED pop AX ; FIXED RET ; --------------------------------------------------------------- ; printDigit: Subroutine to print a single decimal digit ; Input parameters: ; AL: Unsigned decimal digit (between 0-9) to be printed ; Output parameters: ; None. ; --------------------------------------------------------------- printDigit: ; Save registers modified by this subroutine push AX ; FIXED push DX ; FIXED mov DX, Display add AL, '0' ; Convert number to ASCII code ; RET ;-------------------> REMOVE COMMENT out DX,AL ; Print it ; Restore registers pop DX ; FIXED pop AX ; FIXED RET ; --------------------------------------------------------------- ; printSalary: Subroutine to print employee salary ; Input parameters: ; AL: Unsigned short int (0-99) representing salary in 1000's of $ ; Output parameters: ; None. ; --------------------------------------------------------------- ; Constant strings for this subroutine: s_thousands: .DB ',000$' s_dollars: .DB '$' printSalary: ; Save registers modified by this subroutine push AX ; FIXED push DX ; FIXED push SI ; FIXED mov DX, Display mov AH,AL ; Keep a copy of the salary in AH (need AL for printing...) mov AL, [s_dollars] ; Print '$' preceeding number out DX,AL ; Print it mov AL,AH ; Move salary back into AL call printInt ; Print the salary (0-255) mov SI, s_thousands ; Move the starting address of s_thousands string into BX call printStr ; Print ',000' ; Restore registers pop SI ; FIXED pop DX ; FIXED pop AX ; FIXED RET ; --------------------------------------------------------------- ; newLine: Subroutine to print a newline and a linefeed character ; Input parameters: ; None. ; Output parameters: ; None. ; --------------------------------------------------------------- ; Constants for this subroutine: s_CR .EQU 0Dh ; ASCII value for Carriage return s_LF .EQU 0Ah ; ASCII value for NewLine newLine: ; Save registers modified by this subroutine push AX ; FIXED push DX ; FIXED mov DX, Display ; Initialize the output port number in DX mov AL, s_LF ; Load line feed (LF) into AL out DX,AL ; print the char mov AL, s_CR ; Load carriage return (CR) into AL out DX,AL ; print the char ; Restore registers pop DX ; FIXED pop AX ; FIXED RET ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; END OF SUBROUTINES FROM lab5-P1.asm ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; --------------------------------------------------------------- ; main: Main function to test all subroutines ; --------------------------------------------------------------- main: ; Print dayShiftDB[0] mov BX, dayShiftDB ; FIXED Load address of dayShiftDB mov AL, 0 ; FIXED Load record number call printEmployee call newLine ; ;HEEEEELPPPP!!!!! ; Print dayShiftDB[3] mov BX, dayShiftDB ; FIXED Load address of dayShiftDB mov AL, 3 ; FIXED Load record number call printEmployee call newLine ; Print nightShiftDB[0] mov BX, nightShiftDB ; FIXED Load address of nightShiftDB mov AL, 0 ; FIXED Load record number call printEmployee call newLine ; Quit HLT ; --------------------------------------------------------------- ; Test data ; --------------------------------------------------------------- ; --------------------------------------------------------------- ; Record format: ; Struct Employee { ; int id; // 1-byte unsigned integer ID ; char* name; // 2-byte pointer to string of chars ; bool gender; // 1-byte Boolean (zero-->male, else-->female) ; short salary; // 1-byte unsigned short int salary (in $1000�s) ; }; ; --------------------------------------------------------------- .ORG 5000h dayShiftDB: ; Record dayShiftDB[0] .DB 12 ; dayShiftDB[0].id .DW name0 ; dayShiftDB[0].name .DB 0 ; dayShiftDB[0].gender .DB 50 ; dayShiftDB[0].salary ; Record dayShiftDB[1] .DB 27 .DW name1 .DB 1 .DB 58 ; Record dayShiftDB[2] .DB 1 .DW name2 .DB 1 .DB 70 ; Record dayShiftDB[3] .DB 77 .DW name3 .DB 0 .DB 32 nightShiftDB: .DB 7 .DW name4 ; Record nightShiftDB[0] .DB 1 .DB 99 .DB 80 .DW name5 ; Record nightShiftDB[1] .DB 0 .DB 75 name0: .DB '<NAME>$' name1: .DB '<NAME>$' name2: .DB '<NAME>$' name3: .DB '<NAME>$' name4: .DB 'The Boss!$' name5: .DB '<NAME>$' .END main ; Entry point of program is main()
Sources/Asm.asm
wisdark/MiniVisorPkg
390
80176
; ; @file Asm.asm ; ; @brief Cross platform MASM-written functions. ; ; @author <NAME> ; ; @copyright Copyright (c) 2020 - , <NAME>. All rights reserved. ; include AsmCommon.inc .const VMX_OK equ 0 VMX_ERROR_WITH_STATUS equ 1 VMX_ERROR_WITHOUT_STATUS equ 2 KTRAP_FRAME_SIZE equ 190h MACHINE_FRAME_SIZE equ 28h .code extern HandleVmExit : proc extern HandleVmExitFailure : proc ; ; @brief The entry point for the hypervisor. ; ; @details The easiest way to understand this code is to see this as an entry ; point of "VM-exit handler". ; ; Up on VM-exit, the processor starts executing this function as ; configured in the Host RIP field of VMCS. When this function is executed, ; the processor is in the vmx-root mode, which allows the processor to ; execute any instructions without causing VM-exit, and the processor is ; not governed by EPT. The code executed from here most typically emulates ; the instruction caused VM-exit by executing the same instruction on behalf of ; the guest (see HandleCpuid for example), or changing relevant processor ; state and letting the guest retry, for example, handling EPT violation. ; ; What we refer to as hypervisor is basically code executed in this ; context. We also refer those code as a VM-exit handler. ; AsmHypervisorEntryPoint proc frame ; ; Windows-specific: ; ; Three not-well known techniques are used in this function in oder for ; Windbg to display the stack trace of the guest while the VM-exit ; handlers are being executed. You can skip this comment block and ignore ; the first SUB instruction, .PUSHFRAME, .ALLOCSTACK and .ENDPROLOG if ; not interested in. This is not essential for the hypervisor. ; ; 1) The use of the FRAME (above) attribute. This emits a function table ; entry for this function in the .pdata section. See also: ; https://docs.microsoft.com/en-us/cpp/assembler/masm/proc?view=vs-2017 ; ; 2) The use of the .PUSHFRAME pseudo operation. This emits unwind data ; indicating that a machine frame has been pushed on the stack. A machine ; frame is usually pushed by the CPU in response to a trap or fault ( ; see: 6.12.1 Exception- or Interrupt-Handler Procedures), hence this ; pseudo operation is often used for their handler code. (In Windows ; kernel, the use of this pseudo operation is often wrapped in the ; GENERATE_TRAP_FRAME macro.) In our case, since VM-exit does not push ; the machine frame, we manually allocate it with the SUB instruction. ; See also: ; https://docs.microsoft.com/en-us/cpp/assembler/masm/dot-pushframe?view=vs-2017 ; ; 3) The use of the .ALLOCSTACK pseudo operation. This also emits another ; unwind data indicating how much the function uses stack. (This pseudo ; code is often wrapped by the alloc_stack macro and used within the ; GENERATE_TRAP_FRAME macro.) This function consumes 100h of stack on ; the top of the KTRAP_FRAME size (minus the machine frame size, which ; is already indicated by the .PUSHFRAME). See also: ; https://docs.microsoft.com/en-us/cpp/assembler/masm/dot-allocstack?view=vs-2017 ; .pushframe sub rsp, KTRAP_FRAME_SIZE .allocstack KTRAP_FRAME_SIZE - MACHINE_FRAME_SIZE + 100h ; ; Save the general purpose registers as they are not saved to and loaded ; from VMCS. Note that the flag register does not have to be saved as it ; is saved to VMCS on VM-exit and loaded from there on VM-entry. ; ; This operation subtracts RSP 8 * 15. ; PUSHAQ ; ; Save volatile XMM registers for the same reason as the general purpose ; registers. ; ; 0x60 for XMM registers and 8 for alignment. Remember that those SSE ; SEE instructions has to operate on 0x10 aligned memory. ; sub rsp, 68h movaps xmmword ptr [rsp + 0h], xmm0 movaps xmmword ptr [rsp + 10h], xmm1 movaps xmmword ptr [rsp + 20h], xmm2 movaps xmmword ptr [rsp + 30h], xmm3 movaps xmmword ptr [rsp + 40h], xmm4 movaps xmmword ptr [rsp + 50h], xmm5 ; ; Save the current stack pointer as an argument of the HandleVmExit ; function. ; mov rcx, rsp ; ; All stack allocation is done now. Indicate the end of prologue with the ; .ENDPROLOG pseudo operation as required by the FRAME attribute. ; sub rsp, 20h .endprolog ; ; BOOLEAN continueVm = HandleVmExit(stack); ; call HandleVmExit add rsp, 20h ; ; Restore XMM registers. ; movaps xmm5, xmmword ptr [rsp + 50h] movaps xmm4, xmmword ptr [rsp + 40h] movaps xmm3, xmmword ptr [rsp + 30h] movaps xmm2, xmmword ptr [rsp + 20h] movaps xmm1, xmmword ptr [rsp + 10h] movaps xmm0, xmmword ptr [rsp + 0h] add rsp, 68h ; ; if (continueVm == 0) goto ExitVm ; test al, al jz ExitVm ; ; Otherwise, restore the general purpose registers and resume execution ; of the guest. ; POPAQ vmresume jmp VmxError ExitVm: ; ; Termination of the VM is requested. Executes VMXOFF and end ; virtualization. At this point, some registers have specific values: ; RAX = Shared processor context ; RCX = Guest RIP for the next instruction ; RDX = Guest RSP ; R8 = Guest RFLAGS ; ; Note that unlike VMRESUME, VMXOFF does not update RIP, RSP etc, and ; just continues the next instruction (but the processor is no longer in ; VMX-root mode). We will check if error occured with VMXOFF subsequently. ; POPAQ vmxoff ; ; if (ZF) goto VmxError ; if (CF) goto VmxError ; jz VmxError jc VmxError ; ; Restore RFLAGS, RSP, and jump to the next instruction. ; push r8 popf mov rsp, rdx push rcx ret VmxError: ; ; VMRESUME or VMXOFF instruction failed. Unrecoverble. The most useful ; thing to do here is to call a C-function to diagnose the issue. ; pushfq PUSHAQ mov rcx, rsp sub rsp, 20h call HandleVmExitFailure jmp $ AsmHypervisorEntryPoint endp ; ; @brief Invalidates translations derived from EPT ; ; @param[in] RCX - The type of invalidation. ; ; @param[in] RDX - The description of translations to invalidate. ; ; @return An appropriate VMX_RESULT value. ; AsmInvept proc invept rcx, oword ptr [rdx] ; ; if (ZF) goto ErrorWithCode ; if (CF) goto ErrorWithoutCode ; return VMX_OK ; jz ErrorWithCode jc ErrorWithoutCode xor rax, rax ret ErrorWithCode: mov rax, VMX_ERROR_WITH_STATUS ret ErrorWithoutCode: mov rax, VMX_ERROR_WITHOUT_STATUS ret AsmInvept endp ; ; @brief Invalidates translations based on VPID ; ; @param[in] RCX - The type of invalidation. ; ; @param[in] RDX - The description of translations to invalidate. ; ; @return An appropriate VMX_RESULT value. ; AsmInvvpid proc invvpid rcx, oword ptr [rdx] ; ; if (ZF) goto ErrorWithCode ; if (CF) goto ErrorWithoutCode ; return VMX_OK ; jz ErrorWithCode jc errorWithoutCode xor rax, rax ret ErrorWithCode: mov rax, VMX_ERROR_WITH_STATUS ret errorWithoutCode: mov rax, VMX_ERROR_WITHOUT_STATUS ret AsmInvvpid endp ; ; @brief Reads the access rights byte of the segment. ; ; @details See: LAR-Load Access Rights Byte ; ; @param[in] RCX - The selector of the segment to read. ; ; @return The access rights byte of the segment, or 0 on failure. ; AsmLoadAccessRightsByte proc lar rax, rcx jz Success xor rax, rax Success: ret AsmLoadAccessRightsByte endp ; ; @brief Issues hypercall. ; ; @param[in] RCX - The hypercall number. ; ; @param[in] RDX - The arbitrary 64bit parameter 1. ; ; @param[in] R8 - The arbitrary 64bit parameter 2. ; ; @param[in] R9 - The arbitrary 64bit parameter 3. ; ; @return The 64bit return value. Meaning is depends on RCX. ; AsmVmxCall proc vmcall ret AsmVmxCall endp ; ; @brief Returns the return address from this function. ; ; @return The return address from this function. ; AsmGetCurrentInstructionPointer proc mov rax, [rsp] ret AsmGetCurrentInstructionPointer endp ; ; @brief Returns the current value of RSP. ; ; @return The current value of RSP. ; AsmGetCurrentStackPointer proc mov rax, rsp add rax, 8 ret AsmGetCurrentStackPointer endp end
libsrc/_DEVELOPMENT/l/sccz80/crt0/l_ugt.asm
jpoikela/z88dk
640
90297
<reponame>jpoikela/z88dk<filename>libsrc/_DEVELOPMENT/l/sccz80/crt0/l_ugt.asm ; Z88 Small C+ Run time Library ; Moved functions over to proper libdefs ; To make startup code smaller and neater! ; ; 6/9/98 djm SECTION code_clib SECTION code_l_sccz80 PUBLIC l_ugt EXTERN l_compare_result l_ugt: ld a,h cp d jp nz, l_compare_result ld a,l cp e jp l_compare_result
scripts/player/pause.scpt
katsuma/itunes-client
12
4391
tell application "iTunes" pause end tell
Library/GrObj/GrObj/grobjTransfer.asm
steakknife/pcgeos
504
93669
<reponame>steakknife/pcgeos<filename>Library/GrObj/GrObj/grobjTransfer.asm<gh_stars>100-1000 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: GrObj/GrObj FILE: grobjTransfer.asm AUTHOR: jon METHODS: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- jon may 1992 initial version DESCRIPTION: Transfer item creation stuff $Id: grobjTransfer.asm,v 1.1 97/04/04 18:07:21 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjTransferCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjCreateTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObj method for MSG_GO_CREATE_TRANSFER Called by: Pass: *ds:si = GrObj object ds:di = GrObj instance ss:bp - GrObjTransferParams Return: ss:[bp].GTP_curSlot - updated to the next slot in the tree specified by ss:[bp].GTP_textSSP.VTSSSP_treeBlock Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon May 11, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjCreateTransfer method dynamic GrObjClass, MSG_GO_CREATE_TRANSFER uses cx, dx, bp .enter ; ; Check the GOL_COPY lock ; test ds:[di].GOI_locks, mask GOL_COPY jnz done ; ; Allocate a DB item big enough for our grobj ; mov bx, ss:[bp].GTP_vmFile mov cx, size GrObjEntryPointRelocation mov ss:[bp].GTP_curSize, cx mov ax, DB_UNGROUPED call DBAlloc ;ax:di <- group:item movdw ss:[bp].GTP_id, axdi ; ; Store the unrelocated class ; call DBLock ;*es:di <- item mov di, es:[di] ;es:di <- item ; ; Unreloc class ; mov ax,MSG_META_GET_CLASS call ObjCallInstanceNoLockES mov ax, MSG_GO_GET_GROBJ_CLASS call GrObjWriteEntryPointRelocation call DBUnlock ; ; Indicate that we wrote the classes already ; mov ss:[bp].GTP_curPos, size GrObjEntryPointRelocation ; ; Write the rest of the data out ; mov ax, MSG_GO_WRITE_INSTANCE_TO_TRANSFER call ObjCallInstanceNoLock mov ax, ss:[bp].GTP_textSSP.VTSSSP_treeBlock mov di, ss:[bp].GTP_curSlot ; ; Store our identifier in the header ; movdw cxdx, ss:[bp].GTP_id push bp call VMLock mov es, ax movdw es:[di], cxdx call VMDirty call VMUnlock pop bp add di, size dword ;point to the next slot mov ss:[bp].GTP_curSlot, di done: .leave ret GrObjCreateTransfer endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjIncCxIfCopyable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObj method for MSG_GO_INC_CX_IF_COPYABLE Called by: MSG_GO_INC_CX_IF_COPYABLE Pass: *ds:si = GrObj object ds:di = GrObj instance Return: nothing Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon Mar 30, 1993 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjIncCXIfCopyable method dynamic GrObjClass, MSG_GO_INC_CX_IF_COPYABLE .enter test ds:[di].GOI_locks, mask GOL_COPY jnz done inc cx done: .leave ret GrObjIncCXIfCopyable endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDeselectIfCopyLockSet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Deselect the object if its copy lock is set. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: copy lock not set REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/ 8/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDeselectIfCopyLockSet method dynamic GrObjClass, MSG_GO_DESELECT_IF_COPY_LOCK_SET .enter test ds:[di].GOI_locks,mask GOL_COPY jnz deselect done: .leave ret deselect: mov ax,MSG_GO_BECOME_UNSELECTED call ObjCallInstanceNoLock jmp done GrObjDeselectIfCopyLockSet endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjWriteEntryPointRelocation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: This routine write an EntryPointRelocation and the entry number of the "leaf" grobj class into the passed buffer. Pass: es:di - empty buffer to write GrObjEntryPointRelocation cx:dx - class ptr ax - message to send to cx:dx class that will return leaf grobj class (eg., MSG_GO_GET_GROBJ_CLASS or MSG_GV_GET_GROBJ_CLASS) Return: nothing Destroyed: nothing Comments: Revision History: Name Date Description ---- ------------ ----------- jon Aug 17, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjWriteEntryPointRelocation proc far uses ax, bx, cx, dx, di, ds, es .enter ; ; Push the buffer ptr and the passed class onto the stack ; so we can call ObjUnRelocateEntryPoint later ; pushdw esdi ;push buffer ptr pushdw cxdx ;push class on stack ; ; Nudge the buffer ptr down by a word so that the grobj entry number ; getw written immediately after the (eventual) location of the full ; relocation. ; ; We need to make sure that EPR_entryNumber is the last field ; in EntryPointRelocation for this to work. ; CheckHack <((offset EPR_entryNumber) + (size word)) eq (size EntryPointRelocation)> inc di inc di pushdw esdi ;push buffer ptr ; ; Get the "leaf" grobj class of the passed class ; ; clr bx ;get core block of current proc ; call GeodeAccessCoreBlock movdw esdi, cxdx ;es:di <- class call ObjCallClassNoLock ; ; Unrelocate the leaf grobj class. The pointer is offset by ; a word so that the entry point is written into the bottom of ; the passed buffer. ; pushdw cxdx ;push class on stack call ObjUnRelocateEntryPoint ;fill in EntryPointRelocation ; ; Unrelocate the passed class into the beginning of the passed buffer ; call ObjUnRelocateEntryPoint ;fill in EntryPointRelocation .leave ret GrObjWriteEntryPointRelocation endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjWriteInstanceToTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObj method for MSG_GO_WRITE_INSTANCE_TO_TRANSFER Called by: Pass: *ds:si = GrObj object ds:di = GrObj instance ss:[bp] - GrObjTransferParams Return: ss:[bp].GTP_curPos updated to point past data Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon May 13, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjWriteInstanceToTransfer method dynamic GrObjClass, MSG_GO_WRITE_INSTANCE_TO_TRANSFER uses cx,dx .enter ; ; Allocate some space to create our GrObjTransferDataDirectory and ; our GrObjDefiningData ; sub sp, size GrObjTransferDataDirectory + size GrObjDefiningData mov di, sp segmov es, ss ; ; Start writing... ; push si ;save GrObj object chunk GrObjDeref si,ds,si ;ds:si <- instance push ds:[si].GOI_normalTransform ;save normal transform chunk ; ; Store tile flags ; clr ax ;no var data for now... stosw ; ; Store the rest of the instance data ; mov ax, ds:[si].GOI_attrFlags mov es:[di].GODD_attrFlags, ax test ax, mask GOAF_DONT_COPY_LOCKS mov ax, 0 jnz storeLocks mov ax, ds:[si].GOI_locks storeLocks: mov es:[di].GODD_locks, ax ; ; unreloc area token ; push di ;save ptr mov bx, ds:[si].GOI_areaAttrToken cmp bx, CA_NULL_ELEMENT je gotAreaToken mov_tr ax, bx clr bx, cx ;point at area array, ;from doc -> xfer mov di, ss:[bp].GTP_optBlock mov dx, CA_NULL_ELEMENT call StyleSheetCopyElement mov ss:[bp].GTP_optBlock, di gotAreaToken: push bx ;save unreloc'd token ; ; unreloc line token ; mov bx, ds:[si].GOI_lineAttrToken cmp bx, CA_NULL_ELEMENT je gotLineToken mov_tr ax, bx mov bx, 1 ;point at line array clr cx mov di, ss:[bp].GTP_optBlock mov dx, CA_NULL_ELEMENT call StyleSheetCopyElement mov ss:[bp].GTP_optBlock, di gotLineToken: pop ax ;ax <- unreloc'd token pop di ;di <- dest ptr mov es:[di].GODD_lineToken, bx mov es:[di].GODD_areaToken, ax ; ; Store the normal transform ; CheckEvenSize ObjectTransform mov cx, size ObjectTransform / 2 pop si ;si <- normal transform chunk mov si, ds:[si] add di, offset GODD_normalTransform push di ;save dest transform rep movsw pop di ;es:di <- dest transform ; ; Adjust the object so that the selection center is the ; origin for the transfer item ; subdwf es:[di].OT_center.PDF_x, ss:[bp].GTP_selectionCenterDOCUMENT.PDF_x, cx subdwf es:[di].OT_center.PDF_y, ss:[bp].GTP_selectionCenterDOCUMENT.PDF_y, cx ; ; Deal with ATTR_GO_PARENT_DIMENSIONS_OFFSET/ ; GOOF_HAS_UNBALANCED_PARENT_DIMENSIONS ; pop si ;*ds:si = GrObj mov ax, ATTR_GO_PARENT_DIMENSIONS_OFFSET call ObjVarFindData jnc noGoofingOff ; ; if we have an X offset, expand parent width by that offset on ; *each* side of center to account for either a positive or negative ; offset (we don't want to change the object center point) ; movwwf dxax, ds:[bx].PF_x tstwwf dxax ;sets Z flag only jz noGoofx tst dx ;check S flag jns goofXOkay negwwf dxax ;get abs goofXOkay: shlwwf dxax ;expand on each side of center addwwf es:[di].OT_parentWidth, dxax noGoofx: ; ; if we have an Y offset, expand parent height by that offset on ; *each* side of center to account for either a positive or negative ; offset (we don't want to change the object center point) ; movwwf dxax, ds:[bx].PF_y tstwwf dxax ;sets Z flag only jz noGoofy tst dx ;check S flag jns goofYOkay negwwf dxax ;get abs goofYOkay: shlwwf dxax ;expand on each side of center addwwf es:[di].OT_parentHeight, dxax noGoofy: noGoofingOff: ; ; Write the structure to the item ; mov di, sp ;point di back to the beginning ;of the structure mov cx, size GrObjTransferDataDirectory + size GrObjDefiningData call GrObjWriteDataToTransfer add sp, cx .leave ret GrObjWriteInstanceToTransfer endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjWriteDataToTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: Writes a block of data into the current transfer item Pass: ss:[bp] - GrObjTransferParams es:[di] - structure to write out cx - size of structure in es:[di] Return: nothing Destroyed: nothing Comments: ss:bp.GTP_curSize and ss:bp.GTP_curPos are updated accordingly Revision History: Name Date Description ---- ------------ ----------- jon Jan 21, 1993 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjWriteDataToTransfer proc far uses ax, bx, cx, dx, bp, di, si, es, ds .enter ; ; Set ds:si -> structure to write ; segmov ds, es mov si, di ; ; Figure out whether GTP_id points to a VM block ; or a DB item ; mov bx, ss:[bp].GTP_vmFile mov ax, ss:[bp].GTP_id.high add ss:[bp].GTP_curSize, cx push cx ;save size tst ss:[bp].GTP_id.low jnz grObjInDB ; ; The object is in a vm block, so lock it down ; mov di, bp ;ss:[di] <- GTP call VMLock call VMDirty mov bx, bp ;bx <- mem handle ; ; Get more space for our structure ; mov bp, di ;ss:[bp] <- GTP mov ax, ss:[bp].GTP_curSize mov ch, mask HAF_NO_ERR call MemReAlloc mov es, ax clr di jmp startWriting grObjInDB: ; ; GTP_id points to a DB item, so do a realloc ; mov di, ss:[bp].GTP_id.low mov cx, ss:[bp].GTP_curSize call DBReAlloc ;get room for our tokens call DBLock ;*es:di <- item call DBDirty mov di, es:[di] ;es:di <- item clr bx ;no mem handle startWriting: ; ; Spew the passed structure into the item ; add di, ss:[bp].GTP_curPos pop cx ;cx <- size add ss:[bp].GTP_curPos, cx rep movsb ;spunk! ; ; Unlock whatever we locked ; tst bx jnz unlockVM call DBUnlock done: .leave ret unlockVM: mov bp, bx ;bp <- mem handle call VMUnlock jmp done GrObjWriteDataToTransfer endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjReadInstanceFromTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObj method for MSG_GO_READ_INSTANCE_DATA_FROM_TRANSFER Called by: Pass: *ds:si = GrObj object ds:di = GrObj instance ss:[bp] - GrObjTransferParams Return: ss:[bp].GTP_curPos - updated to after read data Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon May 11, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjReadInstanceFromTransfer method dynamic GrObjClass, MSG_GO_READ_INSTANCE_FROM_TRANSFER uses cx, bp .enter ; Protect from stack overflow. mov di, size GrObjTransferParams push di ;popped by routine mov di, 800 ;number of bytes required call GrObjBorrowStackSpaceWithData push di ;save token for ReturnStack ; ; Allocate some space to create our GrObjTransferDataDirectory and ; our GrObjDefiningData ; mov cx, size GrObjTransferDataDirectory + size GrObjDefiningData sub sp, cx mov di, sp segmov es, ss call GrObjReadDataFromTransfer ; ; Now es:di should be pointing to a GrObjTransferDataDirectory ; add di, size GrObjTransferDataDirectory ; ; Set attr flags (should be a message) ; ; Also clear out the wrap type 'cause it'll cause hell in GeoWrite ; if you paste a bunch of GrObjs and it recalcs the path for each ; one... ; GrObjDeref bx,ds,si mov ax, es:[di].GODD_attrFlags andnf ax, not mask GOAF_WRAP mov ds:[bx].GOI_attrFlags, ax ; ; Set locks ; mov ax, es:[di].GODD_locks mov ds:[bx].GOI_locks, ax ; ; reloc line token ; push di ;save GODD mov ax, es:[di].GODD_areaToken push ax ;save area token mov ax, es:[di].GODD_lineToken cmp ax, CA_NULL_ELEMENT jne relocateLineToken GrObjDeref bx,ds,si mov ds:[bx].GOI_lineAttrToken, ax jmp checkAreaAttrToken relocateLineToken: mov bx, 1 ;point at line array mov cx, bx ;from xfer -> doc mov di, ss:[bp].GTP_optBlock mov dx, CA_NULL_ELEMENT call StyleSheetCopyElement mov ss:[bp].GTP_optBlock, di mov cx, bx ;cx <- token mov ax, MSG_GO_SET_GROBJ_LINE_TOKEN call ObjCallInstanceNoLock checkAreaAttrToken: ; ; reloc area token ; pop ax ;ax <- unreloc'd area token cmp ax, CA_NULL_ELEMENT jne relocateAreaToken GrObjDeref bx,ds,si mov ds:[bx].GOI_areaAttrToken, ax jmp doneWithTokens relocateAreaToken: clr bx ;area array offset mov cx, 1 mov di, ss:[bp].GTP_optBlock mov dx, CA_NULL_ELEMENT call StyleSheetCopyElement mov ss:[bp].GTP_optBlock, di mov cx, bx ;cx <- token mov ax, MSG_GO_SET_GROBJ_AREA_TOKEN call ObjCallInstanceNoLock doneWithTokens: pop di ;di <- GODD ; ; create a normal transform for ourselves and fill it in ; call GrObjCreateNormalTransform add di, offset GODD_normalTransform ; ; Point ds:si at dest normal transform ; GrObjDeref si,ds,si push si ;save obj ptr mov si, ds:[si].GOI_normalTransform mov si, ds:[si] CheckEvenSize ObjectTransform mov cx, size ObjectTransform/2 xchg di, si segxchg ds, es push di rep movsw pop di ; ; Adjust the object so that the passed center is the ; origin for the transfer item ; adddwf es:[di].OT_center.PDF_x, ss:[bp].GTP_selectionCenterDOCUMENT.PDF_x, cx adddwf es:[di].OT_center.PDF_y, ss:[bp].GTP_selectionCenterDOCUMENT.PDF_y, cx mov di, si segxchg ds, es ; ; Clear our invalid bit ; pop si ;ds:si <- obj BitClr ds:[si].GOI_optFlags, GOOF_GROBJ_INVALID add sp, size GrObjTransferDataDirectory + size GrObjDefiningData pop di call GrObjReturnStackSpaceWithData .leave ret GrObjReadInstanceFromTransfer endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjReadDataFromTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: Reads a block of data into the current transfer item Pass: ss:[bp] - GrObjTransferParams es:[di] - structure to fill in cx - size of structure in es:[di] Return: nothing Destroyed: nothing Comments: ss:bp.GTP_curSize and ss:bp.GTP_curPos are updated accordingly Revision History: Name Date Description ---- ------------ ----------- jon Jan 21, 1993 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjReadDataFromTransfer proc far uses ax, bx, cx, dx, bp, di, si, es, ds .enter ; ; Set ds:si -> structure to fill ; segmov ds, es mov si, di ; ; Figure out whether GTP_id points to a VM block ; or a DB item ; mov bx, ss:[bp].GTP_vmFile mov ax, ss:[bp].GTP_id.high tst ss:[bp].GTP_id.low jnz grObjInDB mov di, bp ;di <- data ptr call VMLock mov bx, bp ;bx <- mem handle mov bp, di ;ss:bp <- GTP mov es, ax clr di jmp lockedBlock grObjInDB: ; ; The object is in a DB item ; mov di, ss:[bp].GTP_id.low call DBLock mov di, es:[di] clr bx ;no mem handle lockedBlock: add di, ss:[bp].GTP_curPos ; ; Switch ds:si and es:di so that ds:si = source, es:di = dest ; segxchg ds, es xchg di, si add ss:[bp].GTP_curPos, cx ; ; Spew! ; rep movsb ; ; Unlock our block ; tst bx jnz unlockVM segxchg ds, es call DBUnlock done: .leave ret unlockVM: mov bp, bx call VMUnlock jmp done GrObjReadDataFromTransfer endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjReplaceWithTransfer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObj method for MSG_GO_REPLACE_WITH_TRANSFER Called by: Pass: *ds:si = GrObj object ds:di = GrObj instance VM override file set ss:[bp] - GrObjTransferParams Return: nothing Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon May 11, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjReplaceWithTransfer method dynamic GrObjClass, MSG_GO_REPLACE_WITH_TRANSFER uses bp .enter mov ax, MSG_GO_READ_INSTANCE_FROM_TRANSFER call ObjCallInstanceNoLock mov bp, GOANT_PASTED call GrObjOptNotifyAction .leave ret GrObjReplaceWithTransfer endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjQuickTransferTakeMouseGrabIfPossible %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This is the default handler. Doesn't do anything. Always returns carry clear. CALLED BY: MSG_GO_QUICK_TRANSFER_TAKE_MOUSE_GRAB_IF_POSSIBLE PASS: *ds:si = GrObjClass object ds:di = GrObjClass instance data ds:bx = GrObjClass object (same as *ds:si) es = segment of GrObjClass ax = message # ss:bp = LargeMouseData ^lcx:dx = optr to the owner of the Quick Transfer Object RETURN: carry: SET - Object was eligible and mouse was grabbed. CLEAR - Object was not eligible, mouse grab was not changed. DESTROYED: ax can be destroyed SIDE EFFECTS: NOT TO BE CALLED WITH MF_STACK. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/20/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjQuickTransferTakeMouseGrabIfPossible method dynamic GrObjClass, MSG_GO_QUICK_TRANSFER_TAKE_MOUSE_GRAB_IF_POSSIBLE .enter clc .leave ret GrObjQuickTransferTakeMouseGrabIfPossible endm GrObjTransferCode ends
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c87b35c.ada
best08618/asylo
7
8022
<reponame>best08618/asylo -- C87B35C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT OVERLOADING RESOLUTION USES THE RULE THAT: -- -- THE EXPONENT OPERAND OF A FLOATING POINT EXPONENTIATION MUST BE -- OF THE TYPE PREDEFINED INTEGER. -- TRH 4 AUG 82 WITH REPORT; USE REPORT; PROCEDURE C87B35C IS TYPE FIXED IS DELTA 0.01 RANGE 0.0 .. 4.0; ERR : BOOLEAN := FALSE; FUNCTION F1 (X : INTEGER) RETURN INTEGER IS BEGIN RETURN X; END F1; FUNCTION F1 (X : INTEGER) RETURN FLOAT IS BEGIN ERR := TRUE; RETURN 1.0; END F1; FUNCTION F1 (X : INTEGER) RETURN FIXED IS BEGIN ERR := TRUE; RETURN 1.0; END F1; BEGIN TEST ("C87B35C","EXPONENT OPERAND FOR FLOATING POINT " & "EXPONENTIATION MUST BE OF TYPE PREDEFINED INTEGER"); DECLARE FUNCTION "+" (X, Y : INTEGER) RETURN INTEGER RENAMES STANDARD."*"; BEGIN IF ( FLOAT'(2.0) ** F1(3) /= 8.0 OR FLOAT'(2.0) ** (3 + 1) /= 8.0 ) THEN FAILED ("EXPONENT OF FLOATING POINT EXPONENTIATION " & "MUST BE PREDEFINED INTEGER (A)"); END IF; IF ( 2.0 ** F1(3) /= FLOAT'(8.0) OR 2.0 ** (3 + 1) /= FLOAT'(8.0) ) THEN FAILED ("EXPONENT OF FLOATING POINT EXPONENTIATION" & "MUST BE PREDEFINED INTEGER (B)"); END IF; IF ERR THEN FAILED ("EXPONENT OF FLOATING POINT EXPONENTIATION" & "MUST BE PREDEFINED INTEGER (C)"); END IF; END; RESULT; END C87B35C;
lift/x86/testdata/x86_64/import/import.asm
decomp/experimental
9
24824
<gh_stars>1-10 [BITS 64] extern exit global _start:function section .text _start: mov edi, 42 call exit ret
ada-unchecked_conversion.ads
mgrojo/adalib
15
15800
<reponame>mgrojo/adalib<gh_stars>10-100 -- 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 --------------------------------------------------------------------------- generic type Source (<>) is limited private; type Target (<>) is limited private; function Ada.Unchecked_Conversion (S : Source) return Target; pragma Convention (Intrinsic, Ada.Unchecked_Conversion); pragma Pure (Ada.Unchecked_Conversion);
tpantlr2-code/code/reference/MyELang.g4
cgonul/antlr-poc
10
1846
<reponame>cgonul/antlr-poc<gh_stars>1-10 grammar MyELang; import ELang; expr : INT | ID ; INT : [0-9]+ ;
specs/ada/server/cfg/tkmrpc-operation_handlers-cfg-tkm_limits.ads
DrenfongWong/tkm-rpc
0
20653
<reponame>DrenfongWong/tkm-rpc<gh_stars>0 with Tkmrpc.Request; with Tkmrpc.Response; package Tkmrpc.Operation_Handlers.Cfg.Tkm_Limits is procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type); -- Handler for the tkm_limits operation. end Tkmrpc.Operation_Handlers.Cfg.Tkm_Limits;
src/search-filters.ads
stcarrez/ada-search
9
9525
<gh_stars>1-10 ----------------------------------------------------------------------- -- search-filters -- Search engine filters -- Copyright (C) 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with Search.Tokenizers; -- == Filters == -- Filters are used to make some text transformation on token strings produced by the lexer. -- They are chained together and the end of the chain gives the token string to the tokenizer. -- A filter can transform the string in lower case, another can compute the stem of the word -- and only return stems, another may filter and ignore some words. -- -- The `Filter_Chain` holds the chain of filters and each filter is added by using the -- `Add_Filter` procedure. package Search.Filters is type Filter_Type is abstract limited new Ada.Finalization.Limited_Controlled and Search.Tokenizers.Consumer_Type with private; type Filter_Type_Access is access all Filter_Type'Class; overriding procedure Push_Token (Chain : in out Filter_Type; Token : in String; Consumer : not null access procedure (Token : in String)); type Filter_Chain is new Filter_Type with private; procedure Add_Filter (Chain : in out Filter_Chain; Filter : in Filter_Type_Access); private type Filter_Type is abstract limited new Ada.Finalization.Limited_Controlled and Search.Tokenizers.Consumer_Type with record Next : Filter_Type_Access; end record; type Filter_Chain is new Filter_Type with null record; end Search.Filters;
source/jni/u2/main/vmode.asm
Falken42/SecondReality
9
241333
ALIGN 16 mode0d db 256 dup(0) mode0e db 256 dup(0) mode13 db 256 dup(0) vid_oldint dd 0 vid_curmode dw -1 vid_intti PROC NEAR cmp ah,0fh je @@f cmp ah,0 je @@1 @@nn: jmp cs:vid_oldint @@f: cmp cs:vid_curmode,-1 je @@nn mov ax,cs:vid_curmode mov ah,40 mov bh,0 iret @@1: nop ; cmp al,13h ; je @@mode13 ; cmp al,13h+80h ; je @@mode13noclr ; cmp al,0dh ; je @@mode0d ; cmp al,0dh+80h ; je @@mode0dnoclr ; cmp al,0eh ; je @@mode0e cmp al,4 ja @@gn cmp cs:notextmode,0 je @@gn iret @@gn: mov cs:vid_curmode,-1 jmp cs:vid_oldint @@mode13: mov cs:vid_curmode,13h pusha push ds push es call clearpalette mov ax,cs mov ds,ax mov si,OFFSET mode13 call loadvmode call clearvram pop es pop ds popa iret @@mode13noclr: mov cs:vid_curmode,13h pusha push ds push es ;call clearpalette mov ax,cs mov ds,ax mov si,OFFSET mode13 call loadvmode pop es pop ds popa iret @@mode0d: mov cs:vid_curmode,0dh pusha push ds push es call clearpalette mov ax,cs mov ds,ax mov si,OFFSET mode0d call loadvmode call clearvram pop es pop ds popa iret @@mode0dnoclr: mov cs:vid_curmode,13h pusha push ds push es call clearpalette mov ax,cs mov ds,ax mov si,OFFSET mode0d call loadvmode pop es pop ds popa iret @@mode0e: mov cs:vid_curmode,0eh pusha push ds push es call clearpalette mov ax,cs mov ds,ax mov si,OFFSET mode0e call loadvmode call clearvram pop es pop ds popa iret vid_intti ENDP vmode_deinit PROC NEAR xor ax,ax mov ds,ax mov ax,word ptr cs:vid_oldint[0] mov bx,word ptr cs:vid_oldint[2] mov word ptr ds:[010h*4+0],ax mov word ptr ds:[010h*4+2],bx ret vmode_deinit ENDP vmode_init PROC NEAR pusha push ds push es push fs push gs IF 0 mov ax,0dh ;320x200x16 int 10h mov ax,cs mov ds,ax mov si,OFFSET mode0d call savevmode mov ax,13h ;320x200x256 int 10h mov ax,cs mov ds,ax mov si,OFFSET mode13 call savevmode mov ax,0eh ;640x350x16 int 10h mov ax,cs mov ds,ax mov si,OFFSET mode0e call savevmode mov ax,3 int 10h ENDIF xor ax,ax mov ds,ax mov ax,word ptr ds:[010h*4+0] mov bx,word ptr ds:[010h*4+2] mov word ptr cs:vid_oldint[0],ax mov word ptr cs:vid_oldint[2],bx mov word ptr ds:[010h*4+0],OFFSET vid_intti mov word ptr ds:[010h*4+2],cs pop gs pop fs pop es pop ds popa ret vmode_init ENDP VSAL MACRO mov ds:[si],al inc si ENDM ;vmode data to DS:SI savevmode PROC NEAR mov dx,3cch in al,dx VSAL ;Read Sequencer (3C4) mov dx,3c4h xor ah,ah mov cx,04h+1 @@r1: mov al,ah out dx,al inc dx in al,dx VSAL dec dx inc ah loop @@r1 ;Read CRTC (3D4) mov dx,3d4h xor ah,ah mov cx,18h+1 @@r2: mov al,ah out dx,al inc dx in al,dx VSAL dec dx inc ah LOOP @@r2 ;Read GFX controller (3CE) mov dx,3ceh xor ah,ah mov cx,08h+1 @@r3: mov al,ah out dx,al inc dx in al,dx VSAL dec dx inc ah loop @@r3 ;Read Attribute controller (3C0) xor ah,ah mov cx,14h+1 @@r4: mov dx,3dah in al,dx mov dx,3c0h mov al,ah out dx,al inc dx in al,dx VSAL dec dx out dx,al mov al,20h out dx,al inc ah loop @@r4 ret savevmode ENDP ;vmode data from DS:SI loadvmode PROC NEAR mov dx,3dah @@1: in al,dx test al,8 jnz @@1 @@2: in al,dx test al,8 jz @@2 ;Syncronous reset mov dx,3c4h mov ax,0200h out dx,ax ;Clear CRTC protection flag mov dx,3d4h mov al,011h out dx,al inc dx in al,dx and al,not 128 out dx,al ;Set misc register mov al,ds:[si] inc si mov dx,3c2h out dx,al ;Set Sequencer (3C4) mov dx,3c4h xor al,al mov cx,04h+1 @@w1: mov ah,ds:[si] inc si out dx,ax inc al loop @@w1 ;Set CRTC (3D4) mov dx,3d4h xor al,al mov cx,18h+1 @@w2: mov ah,ds:[si] inc si out dx,ax inc al loop @@w2 ;Set GFX controller (3CE) mov dx,3ceh xor al,al mov cx,08h+1 @@w3: mov ah,ds:[si] inc si out dx,ax inc al loop @@w3 ;Set Attribute controller (3C0) mov dx,3dah in al,dx mov dx,3c0h xor ah,ah mov cx,14h+1 @@w4: mov al,ah out dx,al mov al,ds:[si] out dx,al inc si inc ah loop @@w4 ;Enable display, enable PEL mask mov dx,3c0h mov al,20h out dx,al mov dx,3c6h mov al,0ffh out dx,al ret loadvmode ENDP clearvram PROC NEAR push es push di mov dx,3c4h mov ax,0f02h out dx,ax mov ax,0a000h mov es,ax xor di,di xor eax,eax mov cx,16384 rep stosd pop di pop es ret clearvram ENDP clearpalette PROC NEAR mov dx,3c8h xor al,al out dx,al inc dx mov cx,768 @@1: out dx,al loop @@1 ret clearpalette ENDP
v2.0/source/msdos/fat.asm
neozeed/MS-DOS
7
244760
<reponame>neozeed/MS-DOS<gh_stars>1-10 ; ; FAT operations for MSDOS ; INCLUDE DOSSEG.ASM CODE SEGMENT BYTE PUBLIC 'CODE' ASSUME SS:DOSGROUP,CS:DOSGROUP .xlist .xcref INCLUDE DOSSYM.ASM INCLUDE DEVSYM.ASM .cref .list TITLE FAT - FAT maintenance routines NAME FAT i_need CURBUF,DWORD i_need CLUSSPLIT,BYTE i_need CLUSSAVE,WORD i_need CLUSSEC,WORD i_need THISDRV,BYTE i_need DEVCALL,BYTE i_need CALLMED,BYTE i_need CALLRBYT,BYTE i_need BUFFHEAD,DWORD i_need CALLXAD,DWORD i_need CALLBPB,DWORD SUBTTL UNPACK -- UNPACK FAT ENTRIES PAGE ASSUME SS:DOSGROUP procedure UNPACK,NEAR ASSUME DS:DOSGROUP,ES:NOTHING ; Inputs: ; BX = Cluster number ; ES:BP = Base of drive parameters ; Outputs: ; DI = Contents of FAT for given cluster ; Zero set means DI=0 (free cluster) ; SI Destroyed, No other registers affected. Fatal error if cluster too big. CMP BX,ES:[BP.dpb_max_cluster] JA HURTFAT CALL MAPCLUSTER ASSUME DS:NOTHING MOV DI,[DI] JNC HAVCLUS PUSH CX MOV CL,4 SHR DI,CL POP CX STC HAVCLUS: AND DI,0FFFH PUSH SS POP DS return HURTFAT: PUSH AX MOV AH,80H ; Signal Bad FAT to INT int_fatal_abort handler MOV DI,0FFFH ; In case INT int_fatal_abort returns (it shouldn't) invoke FATAL POP AX ; Try to ignore bad FAT return UNPACK ENDP SUBTTL PACK -- PACK FAT ENTRIES PAGE procedure PACK,NEAR ASSUME DS:DOSGROUP,ES:NOTHING ; Inputs: ; BX = Cluster number ; DX = Data ; ES:BP = Pointer to drive DPB ; Outputs: ; The data is stored in the FAT at the given cluster. ; SI,DX,DI all destroyed ; No other registers affected CALL MAPCLUSTER ASSUME DS:NOTHING MOV SI,[DI] JNC ALIGNED PUSH CX MOV CL,4 SHL DX,CL POP CX AND SI,0FH JMP SHORT PACKIN ALIGNED: AND SI,0F000H PACKIN: OR SI,DX MOV [DI],SI LDS SI,[CURBUF] MOV [SI.BUFDIRTY],1 CMP BYTE PTR [CLUSSPLIT],0 PUSH SS POP DS ASSUME DS:DOSGROUP retz PUSH AX PUSH BX PUSH CX MOV AX,[CLUSSAVE] MOV DS,WORD PTR [CURBUF+2] ASSUME DS:NOTHING ADD SI,BUFINSIZ MOV [SI],AH PUSH SS POP DS ASSUME DS:DOSGROUP PUSH AX MOV DX,[CLUSSEC] MOV SI,1 XOR AL,AL invoke GETBUFFRB LDS DI,[CURBUF] ASSUME DS:NOTHING MOV [DI.BUFDIRTY],1 ADD DI,BUFINSIZ DEC DI ADD DI,ES:[BP.dpb_sector_size] POP AX MOV [DI],AL PUSH SS POP DS POP CX POP BX POP AX return PACK ENDP SUBTTL MAPCLUSTER - BUFFER A FAT SECTOR PAGE procedure MAPCLUSTER,NEAR ASSUME DS:DOSGROUP,ES:NOTHING ; Inputs: ; ES:BP Points to DPB ; BX Is cluster number ; Function: ; Get a pointer to the cluster ; Outputs: ; DS:DI Points to contents of FAT for given cluster ; DS:SI Points to start of buffer ; Carry set if cluster data is in high 12 bits of word ; No other registers effected MOV BYTE PTR [CLUSSPLIT],0 PUSH AX PUSH BX PUSH CX PUSH DX MOV AX,BX SHR AX,1 ADD AX,BX XOR DX,DX MOV CX,ES:[BP.dpb_sector_size] DIV CX ; AX is FAT sector # DX is sector index ADD AX,ES:[BP.dpb_first_FAT] DEC CX PUSH AX PUSH DX PUSH CX MOV DX,AX XOR AL,AL MOV SI,1 invoke GETBUFFRB LDS SI,[CURBUF] ASSUME DS:NOTHING LEA DI,[SI.BufInSiz] POP CX POP AX POP DX ADD DI,AX CMP AX,CX JNZ MAPRET MOV AL,[DI] PUSH SS POP DS ASSUME DS:DOSGROUP INC BYTE PTR [CLUSSPLIT] MOV BYTE PTR [CLUSSAVE],AL MOV [CLUSSEC],DX INC DX XOR AL,AL MOV SI,1 invoke GETBUFFRB LDS SI,[CURBUF] ASSUME DS:NOTHING LEA DI,[SI.BufInSiz] MOV AL,[DI] PUSH SS POP DS ASSUME DS:DOSGROUP MOV BYTE PTR [CLUSSAVE+1],AL MOV DI,OFFSET DOSGROUP:CLUSSAVE MAPRET: POP DX POP CX POP BX MOV AX,BX SHR AX,1 POP AX return MAPCLUSTER ENDP SUBTTL FATREAD -- CHECK DRIVE GET FAT PAGE ASSUME DS:DOSGROUP,ES:NOTHING procedure FAT_operation,NEAR FATERR: AND DI,STECODE ; Put error code in DI MOV AH,2 ; While trying to read FAT MOV AL,BYTE PTR [THISDRV] ; Tell which drive invoke FATAL1 entry FATREAD ASSUME DS:DOSGROUP,ES:NOTHING ; Function: ; If disk may have been changed, FAT is read in and buffers are ; flagged invalid. If not, no action is taken. ; Outputs: ; ES:BP = Base of drive parameters ; All other registers destroyed MOV AL,BYTE PTR [THISDRV] invoke GETBP MOV AL,DMEDHL MOV AH,ES:[BP.dpb_UNIT] MOV WORD PTR [DEVCALL],AX MOV BYTE PTR [DEVCALL.REQFUNC],DEVMDCH MOV [DEVCALL.REQSTAT],0 MOV AL,ES:[BP.dpb_media] MOV BYTE PTR [CALLMED],AL PUSH ES PUSH DS MOV BX,OFFSET DOSGROUP:DEVCALL LDS SI,ES:[BP.dpb_driver_addr] ; DS:SI Points to device header ASSUME DS:NOTHING POP ES ; ES:BX Points to call header invoke DEVIOCALL2 PUSH SS POP DS ASSUME DS:DOSGROUP POP ES ; Restore ES:BP MOV DI,[DEVCALL.REQSTAT] TEST DI,STERR JNZ FATERR XOR AH,AH XCHG AH,ES:[BP.dpb_first_access] ; Reset dpb_first_access MOV AL,BYTE PTR [THISDRV] ; Use physical unit number OR AH,BYTE PTR [CALLRBYT] JS NEWDSK ; new disk or first access? JZ CHKBUFFDIRT return ; If Media not changed CHKBUFFDIRT: INC AH ; Here if ?Media..Check buffers LDS DI,[BUFFHEAD] ASSUME DS:NOTHING NBUFFER: ; Look for dirty buffers CMP AX,WORD PTR [DI.BUFDRV] retz ; There is a dirty buffer, assume Media OK LDS DI,[DI.NEXTBUF] CMP DI,-1 JNZ NBUFFER ; If no dirty buffers, assume Media changed NEWDSK: invoke SETVISIT NXBUFFER: MOV [DI.VISIT],1 CMP AL,[DI.BUFDRV] ; For this drive? JNZ SKPBUFF MOV WORD PTR [DI.BUFDRV],00FFH ; Free up buffer invoke SCANPLACE SKPBUFF: invoke SKIPVISIT JNZ NXBUFFER LDS DI,ES:[BP.dpb_driver_addr] TEST [DI.SDEVATT],ISFATBYDEV JNZ GETFREEBUF context DS MOV BX,2 CALL UNPACK ; Read the first FAT sector into CURBUF LDS DI,[CURBUF] JMP SHORT GOTGETBUF GETFREEBUF: ASSUME DS:NOTHING PUSH ES ; Get a free buffer for BIOS to use PUSH BP LDS DI,[BUFFHEAD] invoke BUFWRITE POP BP POP ES GOTGETBUF: ADD DI,BUFINSIZ MOV WORD PTR [CALLXAD+2],DS PUSH SS POP DS ASSUME DS:DOSGROUP MOV WORD PTR [CALLXAD],DI MOV AL,DBPBHL MOV AH,BYTE PTR ES:[BP.dpb_UNIT] MOV WORD PTR [DEVCALL],AX MOV BYTE PTR [DEVCALL.REQFUNC],DEVBPB MOV [DEVCALL.REQSTAT],0 MOV AL,BYTE PTR ES:[BP.dpb_media] MOV [CALLMED],AL PUSH ES PUSH DS PUSH WORD PTR ES:[BP.dpb_driver_addr+2] PUSH WORD PTR ES:[BP.dpb_driver_addr] MOV BX,OFFSET DOSGROUP:DEVCALL POP SI POP DS ; DS:SI Points to device header ASSUME DS:NOTHING POP ES ; ES:BX Points to call header invoke DEVIOCALL2 POP ES ; Restore ES:BP PUSH SS POP DS ASSUME DS:DOSGROUP MOV DI,[DEVCALL.REQSTAT] TEST DI,STERR JNZ FATERRJ MOV AL,BYTE PTR ES:[BP.dpb_media] LDS SI,[CALLBPB] ASSUME DS:NOTHING CMP AL,BYTE PTR [SI.BPMEDIA] JZ DPBOK invoke $SETDPB LDS DI,[CALLXAD] ; Get back buffer pointer MOV AL,BYTE PTR ES:[BP.dpb_FAT_count] MOV AH,BYTE PTR ES:[BP.dpb_FAT_size] MOV WORD PTR [DI.BUFWRTCNT-BUFINSIZ],AX ;Correct buffer info DPBOK: context ds MOV AX,-1 TEST ES:[BP.dpb_current_dir],AX retz ; If root, leave as root MOV ES:[BP.dpb_current_dir],AX ; Path may be bad, mark invalid return FATERRJ: JMP FATERR FAT_operation ENDP do_ext CODE ENDS END
oeis/019/A019432.asm
neoneye/loda-programs
11
173881
<gh_stars>10-100 ; A019432: Continued fraction for tan(1/9). ; Submitted by <NAME> ; 0,8,1,25,1,43,1,61,1,79,1,97,1,115,1,133,1,151,1,169,1,187,1,205,1,223,1,241,1,259,1,277,1,295,1,313,1,331,1,349,1,367,1,385,1,403,1,421,1,439,1,457,1,475,1,493,1,511,1,529,1,547,1,565,1,583,1,601,1,619,1,637,1,655,1,673,1,691,1,709,1,727,1,745,1,763,1,781,1,799,1,817,1,835,1,853,1,871,1,889 seq $0,19428 ; Continued fraction for tan(1/5). mov $2,8 add $2,$0 add $1,$2 div $2,5 mul $2,4 add $1,$2 mov $0,$1 sub $0,12
dosshell/swapper/woados.asm
minblock/msdos
0
160339
<gh_stars>0 ;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1985-1991 ; * All Rights Reserved. ; */ ;----------------------------------------------------------------------------; ; This module contains the read key borad buffer routines needed for function; ; 0ah and function 3fh (when the file is a console device) ; ; ; ; Here are some of the problems and related issues: ; ; ; ; (1) In case the handle points to COMMn, we should ideally like to ; ; trap the call as a wait will be involved. However, there is no ; ; provision in Dos to do a 'GetStatus' call on a given file ; ; handle. ; ; ; ; In the above case, we will let the call go through to Dos and ; ; will not be able to switch out till the 3FH read on an handle ; ; redirected to COMMn or AUX is satisfied. ; ; ; ; (2) The 3FH call provides a file handle, where as the INT 21H ; ; 'GetStatus' calls assume a file handle of 0 implicitly. Thus ; ; we should not use INT 21H 'GetStatus'/'ReadKey (low #s)' calls ; ; when trapping a 3FH call. INT 16H would be fine as we would ; ; never get to our trap if the handle does not point to a CON ; ; device. ; ; ; ; (3) The trap for INT 21H/AH=0AH call would work fine. Here we do ; ; not check to see whether handle 0 has been redirected or not, ; ; but we still work OK because the INT 21H/'GetStatus' and low ; ; numbered 'ReadKey' calls take care of redirection themselves. ; ; ; ; History: ; ; ; ; Thu May-10-1990. -by- <NAME> [amitc] ; ; Added the 'DoDosWait' routine in place of the 'DoInt16' routine. ; ; This is necessary because the console input might be redirected ; ; before an INT 21H/AH=0AH call is made and INT 16H calls do not ; ; support redirection while Dos calls do. (Fix for bug # 1334 (new) ; ; in Windows 3.0). ; ; ; ; Tue June-20-1989. -by- <NAME> [amitc] ; ; Created. (Added the History legend) ; ;----------------------------------------------------------------------------; ?win = 0 ?DF = 1 .xlist include cmacros.inc include woasegs.inc include macros.mac include njmp.mac include woakeys.inc .list .286 ;----------------------------------------------------------------------------; ; declare all public names here. ; ;----------------------------------------------------------------------------; public XenixRead public ReadConsoleBuffer public DoDosWait ;----------------------------------------------------------------------------; createSeg _WOARLMSEG,StubSeg,word,public,code sBegin StubSeg assumes cs,StubSeg assumes ds,Data ;----------------------------------------------------------------------------; ; declare external functions defined elsewhere. ; ;----------------------------------------------------------------------------; externNP SwitchIfPossible ;(WOARLM.ASM) externNP DosCall ;(WOARLM.ASM) externNP DoInt28 ;(WOARLM.ASM) ;----------------------------------------------------------------------------; ; declare external StubSeg variables that are defined elsewhere ; ;----------------------------------------------------------------------------; externD ActualInt21 ;original INT 21 vector externD ActualInt16 ;original INT 16 vector externB ConsoleRawMode ;console in raw or cooked mode externB WOAsInt16 ;chain down our own int 16 ;----------------------------------------------------------------------------; ; have any variables needed by the trap routines ; ;----------------------------------------------------------------------------; public RCB_FileHandle public b3fRCB public lp3fMode KeyBoardBuf label byte ;place where we will have our traps db 256 dup (?) ;max size of buffer for function 0ah ReadFileBuf label byte db 128 dup (?) ;max size of buffer for func 3fh TempReadFileBuf label byte db 128 dup (?) ;max size of buffer for func 3fh StartCol db ? ;start cursor coloumn InsertMode db 0 ;insert mode indicator (toggle) LastXenixCount db 0 ;used by Xenix Read,length of last line XenixBufPos dw 0 ;used by Xenix Read,ptr in last line b3fRCB db 0 ;ReadConBuffer from 3fH trap or not RCB_FileHandle dw 1 ;handle of STDOUT (or for 3FH call) lp3fMode dd ? ;pointer to mode word in SFT BufferedExtKey db 0 ;key buffered or not ;----------------------------------------------------------------------------; ; define the two tables for handling the edit characters. ; ;----------------------------------------------------------------------------; ; define the allowable edit character codes EscTable label byte db ED_F6 ;F6 db ED_RIGHT_ARROW ;--> db ED_F1 ;F1 db ED_DEL ;DEL db ED_F2 ;F2 db ED_F4 ;F4 db ED_F3 ;F3 db ED_F5 ;F5 db ED_LEFT_ARROW ;<-- db ED_INS ;INS db ED_F7 ;F7 db ED_F7 ;to terminate table EscTableLength equ $-EscTable ; store the offset of the corresponding handler routines in reverse order EscFunction label word dw RCB_ReadLoop ;ignore the character dw RCB_TwoEsc ;handles F7 dw RCB_Insert ;handles INS dw RCB_BackSpace ;handles left arror dw RCB_ReEdit ;handles F5 dw RCB_CopyLine ;handles F3 dw RCB_SkipStr ;handles F4 dw RCB_CopyStr ;handles F2 dw RCB_SkipOne ;handles DEL dw RCB_CopyOne ;handles F1 dw RCB_CopyOne ;handles right arrow dw RCB_CtrlZ ;handles F6 ;----------------------------------------------------------------------------; ; XenixRead: ; ; ; ; This routine reads the console device like a file. It maintains a line ; ; buffer upto a length of 128 bytes. When the buffer is empty, it fills it ; ; up by a 'ReadConsoleBuffer' call. It then transfers the user requested # ; ; of bytes from this buffer. The local buffer stays intact accross call and ; ; if it is not empty, the requests are satisfied from there. ; ; ; ; However, if the console is set into raw mode, then just the required # of ; ; characters are obtained using a direct console input without echo and saved; ; into the buffer. ; ; ; ; ES:DX -- has user buffer long pointer ; ; CX -- # of characters requested ; ;----------------------------------------------------------------------------; XenixRead proc near assumes cs,StubSeg assumes ds,StubSeg assumes es,nothing cmp ConsoleRawMode,0ffh ;is the console in raw mode ? jnz @f ;no, do a buffered read ; console is in raw mode, do a raw read call RawRead ;do a raw read jmp short XenixReadRet ;return back @@: mov di,dx ;ES:DI -> buffer push dx ;Save start of buffer to compute count mov si,XenixBufPos ;# of characters left in buffer or si,si ;Buffer left from last call? jnz XenixXferFromBuffer ;try to satisfy the req. from the buffer ; XenixBuffer is empty, or we have taken up all characters that it had. In any ; case we need to get a new line from the console. However, if there is a buffer ; then it will serve as the editing template. pushem es,di,cx ;save the trasfer address smov es,ds ;es is stubseg, which has local buffer mov cx,128 ;Xenix line buffer size is atbest 128 xchg ch,LastXenixCount ;get former length of buffer ; if we do have a buffer left from a previous call, that will serve as the ; template. Note that the 0aH and 3fh Dos calls will have different buffers. mov dx,StubSegOFFSET TempReadFileBuf call ReadConsoleBuffer ;get a new line. mov XenixBufPos,0 ;current position in buffer ; the local buffer possibly has a new line now. popem es,di,cx ;get back lptr to users buffer mov si,StubSegOFFSET ReadFileBuf or al,al ;Empty? jz XenixXferFromBuffer ;Yes, LastXenixCount left at 0 dec al ;Don't include CR ; set the length of the template for the next call to be the length of the ; line just read. mov [LastXenixCount],al ;Length of next template for next call XenixXferFromBuffer: cmp byte ptr [si],1ah ;^Z? jnz XenixTransferLoop ;no, trasfer the characters mov byte ptr es:[di],1ah ;^Z to output buffer (no inc of DI) jmp short XenixReadDone ;all done, finish up ; transfer characters from local to the users buffer XenixTransferLoop: lodsb ;load the next char from local buffer stosb ;place it in users buffer cmp al,0dh ;dis we just transfer a CR ? jnz @f ;No mov bptr [si],0ah ;insert LF after CR to simulate file @@: cmp al,0ah ;was the last char a LF ? loopnz XenixTRansferLoop ;Continue while chars and NOT LF jnz @f ;Stopped due to CX = 0, still have buffer ; data transfer completed XenixReadDone: mov al,0ah ;echo LF to stdout call OutChar ;display the character xor si,si ;nothing in internal buffer @@: mov [XenixBufPos],si ;Set internal buffer ptr for next call pop dx ;Recover start of xfer buffer mov ax,di ;posn of last char in users buffer sub ax,dx ;diff is count of chars transfered XenixReadRet: clc ;show success ret XenixRead endp ;----------------------------------------------------------------------------; ; RawRead: ; ; ; ; This routine waits for keystrokes, and once it gets them it filles them up ; ; in the user provided buffer at es:dx. It will fill CX number of characters ; ; into the buffer. While it is waiting for characters, it tests to see if a ; ; context switch can be done or not. (characters are not echoed by this call); ; ; ; As noted in the header, we must do INT 16 get-status and read calls. ; ;----------------------------------------------------------------------------; RawRead proc near mov ax,cx ;set up return value. mov di,dx ;get ES:DI to point to the buffer push ax ;save value RawReadLoop: RawReadFromKeyBoard: call GetInt16KeyFromDos ;get a character in AL RawKeyInAl: stosb ;save it in the buffer loop RawReadLoop ;read requested number of characters pop ax ;get back no of characters read ret RawRead endp ;----------------------------------------------------------------------------; ; ReadConsoleBuffer: ; ; ; ; This routine is called to fill a buffer with a line obtained from the cons-; ; -ole. It allows full editing support exactly like dos, based on a template ; ; which is nothing but the buffers previous contents. ; ; ; ; Dos Functions 0ah and 3fh use this call to read the next line from console ; ; ; ; On Entry: ; ; ES:DX -- users buffer past the 1st two bytes ; ; CL -- user buffer size. ; ; CH -- number of characters already in buffer (if the user ; ; had done the same call earlier on the same buffer). ; ;----------------------------------------------------------------------------; ReadConsoleBuffer proc near assumes cs,StubSeg assumes ds,StubSeg assumes es,nothing mov di,dx ;this will be our work pointer mov si,dx ;si will point to the start mov ax,cx ;al is buffer length, ah template length xor ch,ch ;cx will hold final length of input ; we are done if a zero length buffer is specified. or al,al ;test length of buffer njz ReadConsoleBufferRet ;return back ; in BL we will hold position in buffer and BH will have previous template ; length. xor bx,bx mov bl,ah ;bl = template length, current pos=bh=0 ;----------------------------------------------------------------------------; ; this call allows the user to edit the previous buffer. We allow edit only ; ; when we have a valid prior template. Two conditions must be met: ; ; 1. length of buffer specified must not be less than or equal to the ; ; template length, and ; ; 2. there must be a carriage return at the end of the template ; ;----------------------------------------------------------------------------; cmp al,bl ;check length consistency jbe ReadConsoleNoEdit ;editing functions not allowed cmp bptr es:[bx+si],0dh ;carriage return at end ? jz @f ;template is valid, it's length in BL ReadConsoleNoEdit: xor bx,bx ;throw away previous template length @@: mov dl,al ;size of buffer dec dl ;no of characters we can put ;----------------------------------------------------------------------------; ; we must get the exact cursor position on the screen for the editing, do an ; ; int 10h call to get the current cursor position. ; ;----------------------------------------------------------------------------; pushem bx,cx,dx ;save relevant registers mov ah,15 ;get active page call int 10h ;bh has current page mov ah,3 ;read cursor position call int 10h ;cursor position in dl mov StartCol,dl ;save it popem bx,cx,dx ;restore the saved registers RCB_StartNewLine: ; do initializations push si ;save start of user buffer mov di,StubSegOFFSET KeyBoardBuf cmp b3fRCB,0 ;is it from a 3FH trap ? jz RCB_SNL_DI_OK ;no, DI is correct mov di,StubSegOFFSET ReadFileBuf RCB_SNL_DI_OK: mov InsertMode,0 ;reset insert mode toggle mov bh,0 ;no characters from template yet mov dh,0 ;# of characters in buffer call GetChar ;get the first character cmp al,0ah ;LF ? jnz RCB_CharacterInAL ;no!, a valid character ; we will filter out the first LF, so that inut redirection will work. ;----------------------------------------------------------------------------; ; The main read loop starts now. We read and process characters. The charact-; ; -ers could be normal characters which go into the buffer, normal edit char-; ; -cters like backspace,etc., or they could be 2 byte template edit characte-; ; -rs. We get out of the loop,once we read a CR or we reach the end of the ; ; buffer. ; ;----------------------------------------------------------------------------; RCB_ReadLoop: call GetChar ;get the next character RCB_CharacterInAL: ; take action depending on the type of the character. cmp al,"F"-"@" ;^F ? jz RCB_ReadLoop ;ignore ^F cmp al,ED_STARTEDIT ;start of EDIT cgaracter jz RCB_ProcessEdit ;yes, process the next edit key cmp al,127 ;DEL key ? njz RCB_BackSpace ;treat as backspace character cmp al,08 ;backspace character njz RCB_BackSpace ;process backspace cmp al,0dh ;CR? jz RCB_EndLine ;Yes, finished cmp al,0ah ;LF? jz RCB_NewLine ;Yes, new line and keep reading cmp al,ED_CANCELEDIT ;CANCEL? (Esc for IBM) jz RCB_KillNew ;yes, kill line and start over ; we have a normal character to stuff into the buffer. RCB_SaveChar: cmp dh,dl ;Room for char? jae RCB_BufFul ;no room, buffer is full mov [di],al ;Char into buffer inc di ;update buffer pointer inc dh ;got a char call OutAnyChar ;ouput the character ; one character processed. cmp InsertMode,0 ;are we insert mode ? ; if insert mode is on, get more characters but do not advance the template jnz RCB_ReadLoop ;read more, insert is on. ; advance template cmp bh,bl ;Past end of template or no template ? jae RCB_ReadLoop ;yes, we are out of chars in template inc si ;skip to next char in template inc bh ;one more character seen in template jmp short RCB_ReadLoop ;continue till EOB or CR ReadConsoleBufferRet: mov ax,cx ;get return count in AX clc ;for success ret ReadConsoleBuffer endp ;----------------------------------------------------------------------------; ; ROUTINES NEEDED BY READ CONSOLE BUFFER CODE ; ;----------------------------------------------------------------------------; ;----------------------------------------------------------------------------; ; When the end of the buffer is reached, sound the beep and continue looking ; ; for CR. ; ;----------------------------------------------------------------------------; RCB_BufFul: mov al,7 ;code for bell call OutChar ;output character in AL jmp short RCB_ReadLoop ;Keep looking for CR ;----------------------------------------------------------------------------; ; We hev obtained the first character of a two character escape sequence. ; ; We get the second character and process the chracter based on a table of ; ; routines indexed by the second character. ; ;----------------------------------------------------------------------------; RCB_ProcessEdit: push di ;save DI (cannot change it!) push es ;save users segment call GetExtChar ;get the key smov es,cs ;load segment for jump table mov cx,EscTableLength ;length of table for scan mov di,StubSegOFFSET EscTable;offset of second byte table repnz scasb ;Look it up in the table shl cx,1 ;convert byte offset to word mov bp,cx ;move to BP to index function table pop es ;get back users segment pop di ;restore DI jmp cs:[bp+EscFunction] ;Go to the right routine ;----------------------------------------------------------------------------; ; Process the carriage return character. ; ;----------------------------------------------------------------------------; RCB_EndLine: mov [di],al ;put the cr in the buffer call OutChar ;echo it pop di ;get start of user buffer inc dh ;dh is length including CR ; fall into the re-edit command. ;----------------------------------------------------------------------------; ; RCB_CopyNew is used when the reedit command is detected ; ;----------------------------------------------------------------------------; RCB_CopyNew: mov si,StubSegOFFSET KeyBoardBuf;DS:SI -> local buffer cmp b3fRCB,0 ;is it from a 3FH trap ? jz RCB_CN_SI_OK ;no, SI is correct mov si,StubSegOFFSET ReadFileBuf RCB_CN_SI_OK: mov cl,dh ;get number of characters including CR push cx ;save count for return rep movsb ;copy final line to user buffer pop ax ;get back count in ax for return ret ;all done ;----------------------------------------------------------------------------; ; This routine outputs a CR,LF pair onto the screen. ; ;----------------------------------------------------------------------------; RCB_OutCRLF: mov al,0dh ;code for CR call OutChar ;output CR mov al,0ah ;code for LF jmp OutChar ;output and return to caller ;----------------------------------------------------------------------------; ; this code is executed when we get an LF, it outputs a CR,LF pair and goes ; ; back to the main read loop. ; ;----------------------------------------------------------------------------; RCB_NewLine: call RCB_OutCRLF ;go to next line jmp RCB_ReadLoop ;go back to main read loop ;----------------------------------------------------------------------------; ; This function flushes the inputs obtained till now but retains the template; ;----------------------------------------------------------------------------; RCB_KillNew: mov al,'\' ;code for cancel indicator call OutChar ;print the cancel indicator pop si ;remember start of edit buffer ; fall into the putnew code. ;----------------------------------------------------------------------------; ; following code fragment is used by the reedit command ; ;----------------------------------------------------------------------------; RCB_PutNew: call RCB_OutCRLF ;go to next line on screen pushem ax,bx,cx ;save important registers xor cx,cx mov cl,StartCol ;get the start coloumn at command start ; we must outout a series of spaces to get to the correct starting coloumn RCB_OutSpaces: jcxz RCB_OutSpacesDone ;we are now at correct coloumn mov al, 20h ;code for space character RCB_OutSpacesLoop: call OutChar ;output the next space loop RCB_OutSpacesLoop ;till we reach correct cursor position RCB_OutSpacesDone: popem ax,bx,cx ;restore registers jmp RCB_StartNewLine ;start all over again ;----------------------------------------------------------------------------; ; process BACKSPACE. ; ;----------------------------------------------------------------------------; RCB_BackSpace: or dh,dh ;test no of characters in line jz RCB_BackUpDone ;no chars in line, do nothing to line call RCB_BackUp ;do one char backup mov al,[di] ;get the deleted char cmp al,' ' ;test for characters below space jae RCB_BackUpDone ;was a normal char cmp al,9 ;was it a tab ? jz RCB_BackTab ;was a tab, fix up users display call RCB_BackOnScreen ;was a control char, zap the '^' RCB_BackUpDone: cmp InsertMode,0 ;insert on or off ? njnz RCB_ReadLoop ;in insert mode, get more chars or bh,bh ;test for position in template njz RCB_ReadLoop ;cant go back, we are at start dec bh ;go back in template ,dec count dec si ;decrement pointer in template jmp RCB_ReadLoop ;continue in main read loop ;----------------------------------------------------------------------------; ; This fragment backs up over a tab, with the first character already beacked; ; over. ; ;----------------------------------------------------------------------------; RCB_BackTab: push di ;save poistion in local buffer dec di ;back up one char mov cl,dh ;number of chars currently in line mov al,' ' ;we look for spaces push bx ;save template context mov bl,7 ;at best we back over 7 more spaces jcxz RCB_BackTabDone ;at start, do nothing RCB_FindPos: cmp al,[di] ;look back jna RCB_CheckCount ;test the count of look back cmp byte ptr [di],9 ;is it a tab character jz RCB_HaveTab ;found a tab dec bl ;back one char if non tab control char RCB_CheckCount: dec di ;go back one more loop RCB_FindPos ;loop till satisfied RCB_BackTabDone: sub bl,[StartCol] ;subtract starting coloumn RCB_HaveTab: sub bl,dh ;subtract no of characters add cl,bl ;add no of look backs we did and cl,7 ;cx has correct number to erase cld ;back to normal pop bx ;restore template context pop di ;restore position in local buffer jz RCB_BackUpDone ;nothing to erase RCB_TabBack: call RCB_BackOnScreen ;back over a character loop RCB_TabBack ;erase correct number of chars jmp short RCB_BackUpDone ;done. ;----------------------------------------------------------------------------; ; This code fragment backs over a character on the screen as well as in the ; ; local buffer. The second entry point backs a character just on the screen, ; ; not disturbing the buffers. ; ;----------------------------------------------------------------------------; RCB_BackUp: dec dh ;decrement count of characters dec di ;backup buffer pointer RCB_BackOnScreen: mov al,8 ;code for back space call OutChar ;go back one coloumn mov al,' ' ;space character call OutChar ;space out character to erase it mov al,8 ;backspace again jmp OutChar ;character erased, cursor ok,jmp rets ;----------------------------------------------------------------------------; ; this code fragment is hit when an escape character is actually to be put in; ; the buffer. ; ;----------------------------------------------------------------------------; RCB_TwoEsc: mov al,ED_STARTEDIT ;code to save for escape jmp RCB_SaveChar ;save the character and proceed ;----------------------------------------------------------------------------; ; the code fragment used to copy the rest of the remplate. ; ;----------------------------------------------------------------------------; RCB_CopyLine: mov cl,bl ;total size of template sub cl,bh ;minus position in template= copy count jmp short RCB_CopyEach ;does the copy based on count in CX ;----------------------------------------------------------------------------; ; copies the template till the indicated character. ; ;----------------------------------------------------------------------------; RCB_CopyStr: call RCB_FindTemplateChar ;find the char,returns distance in CX jmp short RCB_CopyEach ;copy up to it ;----------------------------------------------------------------------------; ; Copies characters from the templates based on count. The first entry point ; ; copies one character, the next on expects a count in CX. ; ;----------------------------------------------------------------------------; RCB_CopyOne: mov cl,1 ;need to copy 1 character RCB_CopyEach: mov InsertMode,0 ;all copies turn off insert mode cmp dh,dl ;test for end of buffer jz @f ;at end of buffer, can't do anything cmp bh,bl ;compares distance to template end jz @f ;at end of template, can't do anything lods byte ptr es:[si] ;Get byte from template mov [di],al ;Save in buffer inc di ;Next char in line call OutAnyChar ;Print char inc bh ;ahead in template inc dh ;ahead in line loop RCB_CopyEach ;untill all characters are copied @@: jmp RCB_ReadLoop ;continue reading from keyboard ;----------------------------------------------------------------------------; ; skips one character in the template. ; ;----------------------------------------------------------------------------; RCB_SkipOne: cmp bh,bl ;compare distance to end of template jz @f ;at end of template,cannot skip inc bh ;ahead in template inc si ;bump pointer in template @@: jmp RCB_ReadLoop ;continue in main loop ;----------------------------------------------------------------------------; ; skips to the indicated character in the template. ; ;----------------------------------------------------------------------------; RCB_SkipStr: call RCB_FindTemplateChar ;find out how far to go add si,cx ;go there bumping pointer in template add bh,cl ;add count of character seen in templ jmp RCB_ReadLoop ;get back tomain loop ;----------------------------------------------------------------------------; ; This routine gets the next character from the keyboard and looks ahead in ; ; the template for a match, leaving in CX the number of characters toge there; ; ; ; If the operation cannot be done, the return address is pooped off the stack; ; and a direct jump is done to get back to the main read loop. So the caller ; ; must not push ANYTHING onto the stack before calling this code. ; ;----------------------------------------------------------------------------; RCB_FindTemplateChar: call GetChar ;Get the char to look for cmp al,ED_STARTEDIT ;did he type a function key? jnz @f ;no, set up for scan call GetChar ;eat next char jmp short RCB_NotFound ;go try again @@: mov cl,bl ;get number of characters in template sub cl,bh ;cx is number of chars to end of templ jz RCB_NotFound ;at end of template dec cx ;cannot point past end, limit search jz RCB_NotFound ;if only one char in template,forget it push di ;save poistion in buffer mov di,si ;template to es:di inc di ;next character repne scasb ;look pop di ;get back pointer in buffer jnz RCB_NotFound ;didn't find the char not cl ;turn how far to go into how far we went add cl,bl ;add size of template sub cl,bh ;sub cur pos, result distance to skip ret RCB_NotFound: pop bp ;chuck return address jmp RCB_ReadLoop ;go back to main loop ;----------------------------------------------------------------------------; ; this code discards the current template and makes line typed till now the ; ; new template. ; ;----------------------------------------------------------------------------; RCB_ReEdit: mov al,'@' ;output re-edit character call OutChar ;display the character pop di ;Recover addr of start of template buffer push di ;save it call RCB_CopyNew ;copy current line into template pop si ;get back template start in si mov bl,dh ;size of line is new size template jmp RCB_PutNew ;start over again ;----------------------------------------------------------------------------; ; this code fragment, toggels the insertmode flag. ; ;----------------------------------------------------------------------------; RCB_Insert: not InsertMode ;toggle the flag jmp RCB_ReadLoop ;go back into the main read loop ;----------------------------------------------------------------------------; ; puts a real live ^z in the buffer (embedded) ; ;----------------------------------------------------------------------------; RCB_CtrlZ: mov al,'Z'-'@' ;code for ^z jmp RCB_SaveChar ;save in buffer and proceed ;----------------------------------------------------------------------------; ; 'OutAnyChar prints out ctrl characters in a printable format, it jmps ; ; 'OutChar' if the character is not a control character or if it is a tab ; ;----------------------------------------------------------------------------; OutAnyChar: ; filter out non control characters and tabl cmp al,9 ;Tab is not converted to ^char jz OutChar ;print normal cmp al,' ' ;Chars above and = to space are normal jae OutChar ;print normal characters push ax ;Save char mov al,'^' ;Print ^ call OutChar ;print the character pop ax ;get back control code add al,'@' ;Make char printable and print it ; all into the normal print code errn$ OutChar ;----------------------------------------------------------------------------; ; this code prints out non-control characters and tabs (which is expanded) ; ; we will use a 40H/INT 21H call to do the output. If this is being called ; ; while we are in the middle of a INT 21/0AH call, RCB_FileHandle will be 1 ; ; (stdout). If we are trapping a 3FH call, RCB_FileHandle would be the handle; ; that 3FH used, we have already made sure that the handle has write access. ; ; ; ; Also, if the call is from a 3FH call, we will change the mode byte in the ; ; SFT entry for the file to grant temporary write permision. We will restore ; ; the permision later. ; ;----------------------------------------------------------------------------; cProc OutChar,<NEAR,PUBLIC,PASCAL>,<ds,dx,ax,bx,cx,es,di> localB OutChar_Byte ;byte to output localB OutChar_Mode ;original SFT mode cBegin mov OutChar_Byte,al ;save the byte to output mov bx,RCB_FileHandle ;handle to be used for write call lea dx,OutChar_Byte ;ss:dx -> byte to output cmp b3fRCB,0 ;trapping a 3FH call ? jz OutChar0AH ;no, trapping a 0AH call ; grant temporary write permison to the SFT les di,lp3fMode ;es:di -> mode byte in SFT mov al,es:[di] ;get the mode mov OutChar_Mode,al ;save it and al,80h ;reser mode/access bits or al,42h ;deny-none/read-write access mov es:[di],al ;save mode ; now write the byte smov ds,ss ;ds:dx -> byte to output mov cx,1 ;1 character to write mov ah,40h ;write code call DosCall ;output the character ; finally restore the SFT mode. mov al,OutChar_Mode ;get saved value mov es:[di],al ;restore SFT mode jmp short OutCharRet ;done. OutChar0Ah: smov ds,ss ;ds:dx -> byte to output mov cx,1 ;1 character to write mov ah,40h ;write code call DosCall ;output the character OutCharRet: cEnd ;----------------------------------------------------------------------------; ; this routine gets the next character typed in at the keyboard. It does a ; ; get status call waiting for a character to get ready, and as it waits, it ; ; tests to see if a context switch is possible and if it is, it would do the ; ; context switching. ; ; ; ; If the call has come from a 0AH trap, we should do INT 21 GetStatus/GetKey ; ; calls, else if the call has come from a 3FH trap we should use INT 16H to ; ; do the 'GetStatus'/'ReadKey' calls. A flag would be set if the trap is from; ; a 3FH call. ; ;----------------------------------------------------------------------------; GetChar proc near cmp b3FRCB,0 ;is it a 3FH call ReadConBuffer ? jz GetChar0ACall ;no, call GetInt16KeyFromDos ;use INT 16H calls. jmp short GetCharRet ;return. GetChar0ACall: call DoInt28 ;yield, not if in crit. error handler call SwitchIfPossible ;do a context switch if appropriate call DoDosWait ;wait for key jz GetChar ;wait till key ready mov ah,8 ;get the code int 21h call call DosCall ;get the character ; the key is ready, return back with code in AL GetCharRet: ret GetChar endp ;----------------------------------------------------------------------------; ; GetInt16KeyFromDos: ; ; ; ; This is called while we are trapping the 3FH dos call. As noted in the ; ; header of the file, we will have to do INT 16H status/get key calls. ; ; When a key code is returned as 00h, we will save the scan code and return ; ; the scan code on the next invocation of this call. ; ; ; ; Note: some applications like EXTRA do their own INT 9/INT 16 handle without; ; chaining them on. For this reason we will do a regular INT 16H rather than ; ; trying to call down stream. ; ; ; ; This code has a special hack in it! This routine is called from the code ; ; that traps the INT 21H/AH=3Fh call. We do INT 16H calls to get a key rather; ; than INT 21H calls to care of problems with redirection. However, this ; ; means that we will not be processing CTRL+C and CTRL+BREAK keys correctly. ; ; To take care of this problem, we now do a dummy INT 21H get keyboard status; ; once a key becomes ready. ; ;----------------------------------------------------------------------------; GetInt16KeyFromDos proc near cmp BufferedExtKey,0 ;is there a buffered key ? jz GI16KFD_WaitLoop ;no. mov al,BufferedExtKey ;get the saved key mov BufferedExtKey,0 ;no more in the buffer jmp short GI16KFD_Ret ;ret GI16KFD_WaitLoop: call DoInt28 ;yield, not if in crit. error handler ; do a INT 16H, set a flag so that our own hook will let it go and also will ; try the 'SwitchIfPossible' call. mov cs:[WOAsInt16],0ffh ;our own INT 16 mov ah,01h ;get status call int 16h ;do the call mov cs:[WOAsInt16],0 ;reset the flag ; test for a key ready. jz GI16KFD_WaitLoop ;no. ; As explained in the header, do an INT 21H get status call to give DOS a ; chance to handle CTRL+C and CTRL+BREAK keys. mov ah,0bh ;get status key call DosCall ;ignore results ; do a INT 16H, set a flag so that our own hook will let it go and also will ; try the 'SwitchIfPossible' call. mov cs:[WOAsInt16],0ffh ;our own INT 16 mov ah,0 ;get the key int 16h ;do the call mov cs:[WOAsInt16],0 ;reset the flag or al,al ;is it an extended key jnz GI16KFD_Ret ;no. mov BufferedExtKey,ah ;save the scan code of ext key GI16KFD_Ret: ret GetInt16KeyFromDos endp ;----------------------------------------------------------------------------; ; GetExtChar: ; ; ; ; This gets the second character of an extended key stroke. If we are in the ; ; middle of a 3FH trap, the character would already have been saved else ; ; we must do a AH=08H dos call to get it. ; ;----------------------------------------------------------------------------; GetExtChar proc near cmp b3fRCB,0 ;from a #FH trap ? jz @f ;no. call GetInt16KeyFromDos ;will get the buffered key ret @@: mov ah,08h ;get char call DosCall ;get the char ret GetExtChar endp ;----------------------------------------------------------------------------; ; DoDosWait: ; ; ; ; Does a check keyboard status call to see whether a key is ready or not. ; ; Zero flag is set if no key is available. This routine does INT 21H call ; ; rather than INT 16H so that redirection of console will be taken care of. ; ;----------------------------------------------------------------------------; DoDosWait proc near push ax ;save mov ah,0bh ;check keyboard status call call DosCall ;call to dos direct or al,al ;set/reset zero flag pop ax ;restore ret DoDosWait endp ;----------------------------------------------------------------------------; sEnd StubSeg end 
LectureNotes/NumbersAndSets/Lecture1.agda
Smaug123/agdaproofs
4
15685
<filename>LectureNotes/NumbersAndSets/Lecture1.agda {-# OPTIONS --warning=error --safe --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import LogicalFormulae open import Numbers.Integers.Integers open import Numbers.Naturals.Semiring open import Numbers.Naturals.Subtraction open import Numbers.Naturals.Naturals open import Numbers.Naturals.Order open import Numbers.Naturals.Exponentiation open import Numbers.Primes.PrimeNumbers open import Maybe open import Semirings.Definition import Semirings.Solver open module NatSolver = Semirings.Solver ℕSemiring multiplicationNIsCommutative module LectureNotes.NumbersAndSets.Lecture1 where a-Na : (a : ℕ) → a -N' a ≡ yes 0 a-Na zero = refl a-Na (succ a) = a-Na a -N''lemma : (a b : ℕ) → (a<b : a ≤N b) → b -N' a ≡ yes (subtractionNResult.result (-N a<b)) -N''lemma zero (succ b) (inl x) = refl -N''lemma (succ a) (succ b) (inl x) = -N''lemma a b (inl (canRemoveSuccFrom<N x)) -N''lemma a b (inr x) rewrite x | a-Na b = ans where ans : yes 0 ≡ yes (subtractionNResult.result (-N (inr (refl {x = b})))) ans with -N (inr (refl {x = b})) ans | record { result = result ; pr = pr } with result ans | record { result = result ; pr = pr } | zero = refl ans | record { result = result ; pr = pr } | succ bl = exFalso (cannotAddAndEnlarge'' pr) -N'' : (a b : ℕ) (a<b : a ≤N b) → ℕ -N'' a b a<b with -N''lemma a b a<b ... | bl with b -N' a -N'' a b a<b | bl | yes x = x n3Bigger : (n : ℕ) → (n ≡ 0) || (n ≤N n ^N 3) n3Bigger n = exponentiationIncreases n 2 n3Bigger' : (n : ℕ) → n ≤N n ^N 3 n3Bigger' zero = inr refl n3Bigger' (succ n) with n3Bigger (succ n) n3Bigger' (succ n) | inr f = f -- How to use the semiring solver -- The process is very mechanical; I haven't yet worked out how to do reflection, -- so there's quite a bit of transcribing expressions into the Expr form. -- The first two arguments to from-to-by are totally mindless in construction. proof : (n : ℕ) → ((n *N n) +N ((2 *N n) +N 1)) ≡ (n +N 1) *N (n +N 1) proof n = from plus (times (const n) (const n)) (plus (times (succ (succ zero)) (const n)) (succ zero)) to times (plus (const n) (succ zero)) (plus (const n) (succ zero)) by applyEquality (λ i → succ (n *N n) +N (n +N i)) ((from (const n) to (plus (const n) zero) by refl))
externals/mpir-3.0.0/mpn/x86_64/k8/not.asm
JaminChan/eos_win
12
9786
<reponame>JaminChan/eos_win dnl mpn_not dnl Copyright 2011 The <NAME> dnl This file is part of the MPIR Library. dnl The MPIR Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 2.1 of the License, or (at dnl your option) any later version. dnl The MPIR 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 Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the MPIR Library; see the file COPYING.LIB. If not, write dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, dnl Boston, MA 02110-1301, USA. include(`../config.m4') ASM_START() PROLOGUE(mpn_not) mov $1,%ecx lea -8(%rdi,%rsi,8),%rdi sub %rsi,%rcx jnc skiplp ALIGN(16) lp: notq (%rdi,%rcx,8) notq 8(%rdi,%rcx,8) add $2,%rcx jnc lp skiplp: jnz case0 case1: notq (%rdi,%rcx,8) case0: ret EPILOGUE()
programs/oeis/221/A221543.asm
karttu/loda
0
83869
<gh_stars>0 ; A221543: Number of 0..n arrays of length 5 with each element differing from at least one neighbor by something other than 1, starting with 0. ; 3,22,103,303,716,1455,2658,4487,7128,10791,15710,22143,30372,40703,53466,69015,87728,110007,136278,166991,202620,243663,290642,344103,404616,472775,549198,634527,729428,834591,950730,1078583,1218912,1372503,1540166,1722735,1921068,2136047,2368578,2619591,2890040,3180903,3493182,3827903,4186116,4568895,4977338,5412567,5875728,6367991,6890550,7444623,8031452,8652303,9308466,10001255,10732008,11502087,12312878,13165791,14062260,15003743,15991722,17027703,18113216,19249815,20439078,21682607,22982028,24338991,25755170,27232263,28771992,30376103,32046366,33784575,35592548,37472127,39425178,41453591,43559280,45744183,48010262,50359503,52793916,55315535,57926418,60628647,63424328,66315591,69304590,72393503,75584532,78879903,82281866,85792695,89414688,93150167,97001478,100970991,105061100,109274223,113612802,118079303,122676216,127406055,132271358,137274687,142418628,147705791,153138810,158720343,164453072,170339703,176382966,182585615,188950428,195480207,202177778,209045991,216087720,223305863,230703342,238283103,246048116,254001375,262145898,270484727,279020928,287757591,296697830,305844783,315201612,324771503,334557666,344563335,354791768,365246247,375930078,386846591,397999140,409391103,421025882,432906903,445037616,457421495,470062038,482962767,496127228,509558991,523261650,537238823,551494152,566031303,580853966,595965855,611370708,627072287,643074378,659380791,675995360,692921943,710164422,727726703,745612716,763826415,782371778,801252807,820473528,840037991,859950270,880214463,900834692,921815103,943159866,964873175,986959248,1009422327,1032266678,1055496591,1079116380,1103130383,1127542962,1152358503,1177581416,1203216135,1229267118,1255738847,1282635828,1309962591,1337723690,1365923703,1394567232,1423658903,1453203366,1483205295,1513669388,1544600367,1576002978,1607881991,1640242200,1673088423,1706425502,1740258303,1774591716,1809430655,1844780058,1880644887,1917030128,1953940791 mov $1,$0 trn $1,3 add $1,3 mov $5,$0 lpb $0,1 mul $0,2 sub $0,2 mov $1,$3 lpe mov $2,10 mov $6,$5 lpb $2,1 add $1,$6 sub $2,1 lpe mov $4,$5 lpb $4,1 sub $4,1 add $7,$6 lpe mov $2,6 mov $6,$7 lpb $2,1 add $1,$6 sub $2,1 lpe mov $4,$5 mov $7,0 lpb $4,1 sub $4,1 add $7,$6 lpe mov $2,5 mov $6,$7 lpb $2,1 add $1,$6 sub $2,1 lpe mov $4,$5 mov $7,0 lpb $4,1 sub $4,1 add $7,$6 lpe mov $2,1 mov $6,$7 lpb $2,1 add $1,$6 sub $2,1 lpe
alloy4fun_models/trashltl/models/8/XueZk3SfgbvHqMHrm.als
Kaixi26/org.alloytools.alloy
0
1434
open main pred idXueZk3SfgbvHqMHrm_prop9 { all f: File | eventually after f in Protected implies always f not in Trash } pred __repair { idXueZk3SfgbvHqMHrm_prop9 } check __repair { idXueZk3SfgbvHqMHrm_prop9 <=> prop9o }
formal_model_spec/block.als
vasil-sd/ada-tlsf
3
4632
module block[exactly Time] -- моменты времени упорядочены open util/ordering[Time] -- адреса и размеры упорядочены open util/ordering[Addr] open util/ordering[UniqSize] -- Реляционная спецификация модели для блоков -- Адреса - множество уникальных объектов с линейным порядком -- Размеры - множество уникальных объектов с линейным порядком -- Операции: -- для адресной арифметики: -- адрес + размер = адрес -- для работы с размерами: -- размер + размер = размер -- Блоки памяти - множество уникальных объектов, характеризуются адресом и размером -- Линейно упорядочены (порядок индуцирован адресами) -- Закрывают всю память встык, то есть (кроме первого и последнего): -- адрес предыдущего + его размер = адресу следующего -- у первого нет предыдущего, у последнего - следующего -- для динамики операций введём время у размеров и адресов блоков -- для самих адресов и размеров вводить время не будем (возможно это стоило бы -- ввести для привычности и наглядности, но это потребует намного больше -- писанины, а семантически будет эквивалентно текущему варианту) -- Основные инварианты, которые нужно сохранять, введя операции над блоками -- 1. Сплошное покрытие блоками памяти, без "дыр", по-умолчению считаем, что -- работаем с выровненными адресами и размерами и все блоки всегда впритык -- todo, после введения списков свободных -- 2. свободный блок может быть только в одном списке свободных -- 3. нет свободных блоков вне списков свободных -- 4. в списках свободных только свободные блоки. let Sum [Left, Right] { Left.Add[Right] } sig Addr { -- тут вводим операцию сложения адреса с размером Add: UniqSize -> Addr } -- Зададим несколько основных свойств на сложение адресов и размеров -- (не факт, что они все необходимы для корректной модели, но -- для привычного восприятия точно нужны :) ) -- Сумма адреса и размера всегда должна быть больше этого адреса fact { all Left : Addr - last | all Right : UniqSize | let S = Sum[Left, Right] | gt[S, Left] } -- Добавление одинакового размера не должно приводить к разным адресам fact { all A : Addr | all S : UniqSize | lone Sum[A, S] } -- Какой бы размер мы не прибавили к последнему адресу, следующий мы не получим fact { no last.(Addr <: Add) } -- добавление одинакового размера к разным блокам должно приводить к разным адресам fact { all A : Addr | all S : UniqSize | lone Add.A.S } -- добавление разных размеров к адресу должно приводить к разным адресам fact { all disj A1, A2 : Addr | lone A1.Add.A2 } -- Тут уникальные упорядоченные размеры sig UniqSize { -- тут вводим операцию сложения размеров Add : UniqSize -> UniqSize } -- Тут тоже зададим ограничения на Add, чтобы она выглядела привычнее -- сложение: сумма всегда больше слагаемых fact { all Left : UniqSize | all Right : UniqSize | let S = Sum[Left, Right] { gt[S, Left] gt[S, Right] } } -- добавление одинакового размера не должно приводить к разным размерам fact { all Left : UniqSize | all Right : UniqSize | lone Sum[Left, Right] } -- добавление одного и того же размера к разным не должно приводить к одному размеру fact { all Right : UniqSize | all Result : UniqSize | lone Add.Result.Right } -- от перестановки результат не меняется fact { all Left : UniqSize | all Right : UniqSize | Sum[Left, Right] = Sum[Right, Left] } -- ассоциативность fact { all S1 : UniqSize | all S2 : UniqSize | all S3 : UniqSize | Sum[Sum[S1, S2], S3] = Sum[S1, Sum[S2, S3]] } -- блок памяти -- характеризуются адресом и размером sig Block { -- блоков с одинаковыми адресами нет (disj) -- хотя может это вынести на проверку валидности? Address : disj Addr lone -> Time, -- а вот с одинаковыми размерами могут быть Size : UniqSize lone -> Time } -- адрес и размер должны быть одновременно -- или одновременно отсутствовать fact { all T : Time | all B : Block | (one B.Address.T iff one B.Size.T) or (no B.Address.T iff no B.Size.T) } -- Расположение блоков в памяти: друг за другом, без перекрытия -- [ <- Size0 -> ][ <- Size1 -> ][ <- Size2 -> ] -- ^ ^ ^ -- Addr0 Addr1 Addr2 -- Addr0 + Size0 Addr1 + Size1 -- -- Условие правильности адресов: -- Кроме первого адреса все остальные являются сложением предыдущего с -- некоторым уникальным размером -- немного полезных вспомогательных функций: -- UsedBlocks - это блоки, которые используются в заданный момент времени для модели -- для моделирования операций, когда могут появляться/исчезать блоки памяти -- нужен пул свободных абстрактных блоков, которые ещё не соответствуют -- каким-то конкретным блокам -- абстрактный блок - это блок без адреса и размера -- соответственно появляется два класса блоков: абстрактные и конкретные -- UsedBlocks - даём список конкретных блоков на заданный момент времени fun UsedBlocks [t : Time] : set Block { {B : Block | one B.Address.t} } -- Дуальная к UsedBlocks fun UnusedBlocks [t : Time] : set Block { Block - t.UsedBlocks } -- начальный блок: блок с минимальным адресом на нужный момент времени fun FirstBlock[t:Time] : one Block { {B : Block | B.Address.t = min[t.UsedBlocks.Address.t]} } -- конечный - с максимальным адресом на нужный момент времени fun LastBlock[t: Time] : one Block { {B : Block | B.Address.t = max[t.UsedBlocks.Address.t]} } -- получить следующий блок для заданного на момент времени t fun NextBlock[t: Time, b : Block] : Block { let NextBlockAddress = Sum[b.Address.t, b.Size.t] -- адрес следующего -- получаем отношение Block -> Addr на нужный момент времени | let RelBlocksToAddressForTime = Address.t -- делаем операцию join справа по NextBlockAddress -- и получаем все блоки по этому адресу | let AllBlocksAtAddress = RelBlocksToAddressForTime.NextBlockAddress | AllBlocksAtAddress -- возвращаем результат } -- предыдущий блок у данного на момент времени t fun PrevBlock[t: Time, b : Block] : Block { -- возвращаем множество блоков, адрес у которых равен -- сумме адреса текущего с его размером {B : Block | Sum[B.Address.t, B.Size.t] = b.Address.t} } -- Предикат валидности конкретных блоков на момент времени t pred Valid[t:Time] { -- у всех кроме последнего есть следующий и ровно один -- и предыдущий у следующего это текущий блок all B : t.UsedBlocks - LastBlock[t] | one NextBlock[t, B] and PrevBlock[t, NextBlock[t,B]] = B -- у последнего нет следующего no NextBlock[t, LastBlock[t]] -- у первого нет предыдущего no PrevBlock[t, FirstBlock[t]] -- у каждого кроме первого есть предыдущий -- и следующий у предыдущего - это текущий блок all B : t.UsedBlocks - FirstBlock[t] | one PrevBlock[t, B] and NextBlock[t, PrevBlock[t, B]] = B } -- этот предикат говорит о том, что с T до T.next поменялись -- только блоки B_Except, все остальные остались такие же -- его будем использовать для рамочных гипотез при -- написании предикатов к операциям над блоками -- (шаг T -> T.next выбран потому, что потом моделирование -- операций будет по шагам T -> T.next) pred AllBlocksAreSameExcept[T:Time, B_Except:set Block] { all B : Block - B_Except { B.Address.(T.next) = B.Address.T B.Size.(T.next) = B.Size.T } } -- тут простой запуск поиска моделей, чтобы посмотреть, -- что у нас получается и как работают предикаты Show_All_Except_One_Are_Unchanged_During_Time: run { all t : Time | Valid[t] one B : Block | all T : Time - last | AllBlocksAreSameExcept[T, B] } for 5 but 5 UniqSize, 5 Addr, exactly 6 Block, exactly 3 Time
programs/oeis/011/A011758.asm
neoneye/loda
22
176447
<reponame>neoneye/loda ; A011758: Barker sequence of length 13. ; 1,1,1,1,1,-1,-1,1,1,-1,1,-1,1 pow $0,2 sub $0,1 div $0,12 mul $0,2 div $0,3 sub $0,3 mov $1,-1 bin $1,$0 mov $0,$1
programs/oeis/224/A224338.asm
jmorken/loda
1
102081
; A224338: Number of idempotent 7X7 0..n matrices of rank 6. ; 889,10199,57337,218743,653177,1647079,3670009,7440167,13999993,24801847,41803769,67575319,105413497,159468743,234881017,337925959,476171129,658642327,895999993,1200725687,1587318649,2072502439,2675441657 mov $1,2 add $1,$0 pow $1,6 sub $1,64 mul $1,14 add $1,889
src/tcl.adb
thindil/tashy2
2
1890
-- Copyright (c) 2020-2021 <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.Characters.Handling; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Tashy2; use Tashy2; with Tcl.Variables; use Tcl.Variables; package body Tcl is --## rule off GLOBAL_REFERENCES -- ****iv* Tcl/Tcl.Default_Interpreter -- FUNCTION Pointer to the default Tcl interpreter -- HISTORY -- 8.6.0 - Added -- SOURCE Default_Interpreter: Tcl_Interpreter := Null_Interpreter; -- **** --## rule on GLOBAL_REFERENCES procedure Set_Interpreter(Interpreter: Tcl_Interpreter) is begin if Interpreter = Null_Interpreter then return; end if; Default_Interpreter := Interpreter; end Set_Interpreter; function Get_Interpreter return Tcl_Interpreter is begin return Default_Interpreter; end Get_Interpreter; function Tcl_Init(Interpreter: Tcl_Interpreter) return Boolean is function Native_Tcl_Init(Interp: Tcl_Interpreter) return Tcl_Results with Global => null, Import, Convention => C, External_Name => "Tcl_Init"; begin if Native_Tcl_Init(Interp => Interpreter) = TCL_ERROR then return False; end if; return True; end Tcl_Init; -- ****if* Tcl/Tcl.Native_Tcl_Eval -- FUNCTION -- Binding to C function Tcl_Eval, evalutate the selected Tcl script -- PARAMETERS -- Interp - Tcl interpreter on which the Tcl script will be evaluated -- Script - Tcl script to evaluate -- RESULT -- Tcl_Results value -- HISTORY -- 8.6.0 - Added -- SOURCE function Native_Tcl_Eval (Interp: Tcl_Interpreter; Script: chars_ptr) return Tcl_Results with Global => null, Import, Convention => C, External_Name => "Tcl_Eval"; -- **** procedure Tcl_Eval (Tcl_Script: String; Interpreter: Tcl_Interpreter := Get_Interpreter) is begin if Native_Tcl_Eval (Interp => Interpreter, Script => To_C_String(Str => Tcl_Script)) = TCL_ERROR then return; end if; end Tcl_Eval; function Tcl_Eval (Tcl_Script: String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_String_Result is Message: Unbounded_String := Null_Unbounded_String; Result_Code: constant Tcl_Results := Native_Tcl_Eval (Interp => Interpreter, Script => To_C_String(Str => Tcl_Script)); Result_String: constant String := Tcl_Get_Result(Interpreter => Interpreter); begin if Result_Code = TCL_ERROR then Message := To_Unbounded_String (Source => Tcl_Get_Var (Var_Name => "errorInfo", Interpreter => Interpreter)); end if; Return_Result_Block : declare Message_Length: constant Natural := Length(Source => Message); Result: constant Tcl_String_Result (Message_Length => Message_Length, Result_Length => Result_String'Length) := (Message_Length => Message_Length, Result_Length => Result_String'Length, Return_Code => Result_Code, Result => Result_String, Message => To_String(Source => Message)); begin return Result; end Return_Result_Block; end Tcl_Eval; function Tcl_Eval (Tcl_Script: String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Boolean_Result is Message: Unbounded_String := Null_Unbounded_String; Result_Code: constant Tcl_Results := Native_Tcl_Eval (Interp => Interpreter, Script => To_C_String(Str => Tcl_Script)); begin if Result_Code = TCL_ERROR then Message := To_Unbounded_String (Source => Tcl_Get_Var (Var_Name => "errorInfo", Interpreter => Interpreter)); end if; Return_Result_Block : declare Message_Length: constant Natural := Length(Source => Message); Result: constant Tcl_Boolean_Result (Message_Length => Message_Length) := (Message_Length => Message_Length, Return_Code => Result_Code, Result => (if Tcl_Get_Result(Interpreter => Interpreter) in "1" | "true" | "on" | "yes" then True else False), Message => To_String(Source => Message)); begin return Result; end Return_Result_Block; end Tcl_Eval; function Tcl_Eval (Tcl_Script: String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Integer_Result is Message: Unbounded_String := Null_Unbounded_String; Result_Code: constant Tcl_Results := Native_Tcl_Eval (Interp => Interpreter, Script => To_C_String(Str => Tcl_Script)); begin if Result_Code = TCL_ERROR then Message := To_Unbounded_String (Source => Tcl_Get_Var (Var_Name => "errorInfo", Interpreter => Interpreter)); end if; Return_Result_Block : declare Message_Length: constant Natural := Length(Source => Message); Result: constant Tcl_Integer_Result (Message_Length => Message_Length) := (Message_Length => Message_Length, Return_Code => Result_Code, Result => Tcl_Get_Result(Interpreter => Interpreter), Message => To_String(Source => Message)); begin return Result; end Return_Result_Block; end Tcl_Eval; function Tcl_Eval (Tcl_Script: String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Float_Result is Message: Unbounded_String := Null_Unbounded_String; Result_Code: constant Tcl_Results := Native_Tcl_Eval (Interp => Interpreter, Script => To_C_String(Str => Tcl_Script)); begin if Result_Code = TCL_ERROR then Message := To_Unbounded_String (Source => Tcl_Get_Var (Var_Name => "errorInfo", Interpreter => Interpreter)); end if; Return_Result_Block : declare Message_Length: constant Natural := Length(Source => Message); Result: constant Tcl_Float_Result (Message_Length => Message_Length) := (Message_Length => Message_Length, Return_Code => Result_Code, Result => Tcl_Get_Result(Interpreter => Interpreter), Message => To_String(Source => Message)); begin return Result; end Return_Result_Block; end Tcl_Eval; function Tcl_Eval_File (File_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tcl_Results is function Native_Tcl_Eval_File (Interp: Tcl_Interpreter; File: chars_ptr) return Tcl_Results with Global => null, Import, Convention => C, External_Name => "Tcl_EvalFile"; begin return Native_Tcl_Eval_File (Interp => Interpreter, File => To_C_String(Str => File_Name)); end Tcl_Eval_File; function Tcl_Get_Result (Interpreter: Tcl_Interpreter := Get_Interpreter) return String is function Tcl_Get_String_Result (Interp: Tcl_Interpreter) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Tcl_GetStringResult"; begin return From_C_String(Item => Tcl_Get_String_Result(Interp => Interpreter)); end Tcl_Get_Result; function Tcl_Get_Result (Interpreter: Tcl_Interpreter := Get_Interpreter) return Integer is use Ada.Characters.Handling; Result: constant String := Tcl_Get_Result(Interpreter => Interpreter); Value: Integer := 0; begin if Result = "" then return 0; end if; if Result'Length > Integer'Width then return 0; end if; Check_Characters_Loop : for I in reverse Result'Range loop if I = Result'First and Result(I) = '-' then Value := -(Value); end if; exit Check_Characters_Loop when Value < 0; if Is_Digit(Item => Result(I)) then if Value + (Integer'Value("" & Result(I)) * (10**(Result'Last - I))) > Integer'Last then return 0; end if; Value := Value + (Integer'Value("" & Result(I)) * (10**(Result'Last - I))); else return 0; end if; end loop Check_Characters_Loop; return Value; end Tcl_Get_Result; procedure Tcl_Set_Result (Tcl_Result: String; Result_Type: Result_Types := Default_Result_Type; Interpreter: Tcl_Interpreter := Get_Interpreter) is use Interfaces.C; procedure Native_Tcl_Set_Result (Interp: Tcl_Interpreter; Result: chars_ptr; Free_Proc: int) with Global => null, Import, Convention => C, External_Name => "Tcl_SetResult"; begin Native_Tcl_Set_Result (Interp => Interpreter, Result => To_C_String(Str => Tcl_Result), Free_Proc => Result_Types'Enum_Rep(Result_Type)); end Tcl_Set_Result; procedure Tcl_Update (Interpreter: Tcl_Interpreter := Get_Interpreter; Idle_Tasks_Only: Boolean := False) is begin Tcl_Eval (Tcl_Script => "update" & (if Idle_Tasks_Only then " idletasks" else ""), Interpreter => Interpreter); end Tcl_Update; end Tcl;
oeis/131/A131137.asm
neoneye/loda-programs
11
242428
; A131137: Denominator of (exponential) expansion of log((2*x/3-1)/(x-1)). ; 1,3,9,27,27,81,243,243,729,2187,729,2187,6561,6561,19683,59049,59049,177147,531441,177147,531441,1594323,1594323,4782969,14348907,14348907,43046721,129140163,14348907,43046721,129140163,129140163,387420489,1162261467,1162261467,3486784401,10460353203,3486784401,10460353203,31381059609,31381059609,94143178827,282429536481,282429536481,847288609443,2541865828329,847288609443,2541865828329,7625597484987,7625597484987,22876792454961,68630377364883,68630377364883,205891132094649,617673396283947 seq $0,131138 ; a(n)=log_3(A131137(n)). add $0,2 seq $0,60816 ; a(0) = 1; a(n) = (5*3^(n-1) - 1)/2 for n > 0. div $0,15 mul $0,2 add $0,1
code/display/border.asm
abekermsx/skooted
3
4355
initialize_border: ld a,138 ld hl,6144 call WRTVRM ; draw top left inc l ld bc,11 * 2 ld a,140 call FILVRM ; draw top ld hl,6144 + 1 + 11 * 2 ld a,139 call WRTVRM ; draw top right ld b,11 * 2 ld hl,6144 + 32 initialize_border_loop: ld a,172 call WRTVRM ; draw left ld de,11 * 2 + 1 add hl,de ld a,172 call WRTVRM ; draw right ld de,32 - 11 * 2 - 1 add hl,de djnz initialize_border_loop ld a,170 call WRTVRM ; draw bottom left inc l ld bc,11 * 2 ld a,140 call FILVRM ; draw bottom ld hl,6144 + 32 + 32 * 11 * 2 + 1 + 11 * 2 ld a,171 call WRTVRM ; draw bottom right ret
agda-stdlib-0.9/src/Data/Container.agda
qwe2/try-agda
1
3467
<reponame>qwe2/try-agda ------------------------------------------------------------------------ -- The Agda standard library -- -- Containers, based on the work of Abbott and others ------------------------------------------------------------------------ module Data.Container where open import Data.M open import Data.Product as Prod hiding (map) open import Data.W open import Function renaming (id to ⟨id⟩; _∘_ to _⟨∘⟩_) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (_↔_; module Inverse) import Function.Related as Related open import Level open import Relation.Binary using (Setoid; module Setoid; Preorder; module Preorder) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_; refl) open import Relation.Unary using (_⊆_) ------------------------------------------------------------------------ -- Containers -- A container is a set of shapes, and for every shape a set of -- positions. infix 5 _▷_ record Container (ℓ : Level) : Set (suc ℓ) where constructor _▷_ field Shape : Set ℓ Position : Shape → Set ℓ open Container public -- The semantics ("extension") of a container. ⟦_⟧ : ∀ {ℓ} → Container ℓ → Set ℓ → Set ℓ ⟦ C ⟧ X = Σ[ s ∈ Shape C ] (Position C s → X) -- The least and greatest fixpoints of a container. μ : ∀ {ℓ} → Container ℓ → Set ℓ μ C = W (Shape C) (Position C) ν : ∀ {ℓ} → Container ℓ → Set ℓ ν C = M (Shape C) (Position C) -- Equality, parametrised on an underlying relation. Eq : ∀ {c ℓ} {C : Container c} {X Y : Set c} → (X → Y → Set ℓ) → ⟦ C ⟧ X → ⟦ C ⟧ Y → Set (c ⊔ ℓ) Eq {C = C} _≈_ (s , f) (s′ , f′) = Σ[ eq ∈ s ≡ s′ ] (∀ p → f p ≈ f′ (P.subst (Position C) eq p)) private -- Note that, if propositional equality were extensional, then -- Eq _≡_ and _≡_ would coincide. Eq⇒≡ : ∀ {c} {C : Container c} {X : Set c} {xs ys : ⟦ C ⟧ X} → P.Extensionality c c → Eq _≡_ xs ys → xs ≡ ys Eq⇒≡ {xs = s , f} {ys = .s , f′} ext (refl , f≈f′) = P.cong (_,_ s) (ext f≈f′) setoid : ∀ {ℓ} → Container ℓ → Setoid ℓ ℓ → Setoid ℓ ℓ setoid C X = record { Carrier = ⟦ C ⟧ X.Carrier ; _≈_ = _≈_ ; isEquivalence = record { refl = (refl , λ _ → X.refl) ; sym = sym ; trans = λ {_ _ zs} → trans zs } } where module X = Setoid X _≈_ = Eq X._≈_ sym : {xs ys : ⟦ C ⟧ X.Carrier} → xs ≈ ys → ys ≈ xs sym {_ , _} {._ , _} (refl , f) = (refl , X.sym ⟨∘⟩ f) trans : ∀ {xs ys : ⟦ C ⟧ X.Carrier} zs → xs ≈ ys → ys ≈ zs → xs ≈ zs trans {_ , _} {._ , _} (._ , _) (refl , f₁) (refl , f₂) = (refl , λ p → X.trans (f₁ p) (f₂ p)) ------------------------------------------------------------------------ -- Functoriality -- Containers are functors. map : ∀ {c} {C : Container c} {X Y} → (X → Y) → ⟦ C ⟧ X → ⟦ C ⟧ Y map f = Prod.map ⟨id⟩ (λ g → f ⟨∘⟩ g) module Map where identity : ∀ {c} {C : Container c} X → let module X = Setoid X in (xs : ⟦ C ⟧ X.Carrier) → Eq X._≈_ (map ⟨id⟩ xs) xs identity {C = C} X xs = Setoid.refl (setoid C X) composition : ∀ {c} {C : Container c} {X Y : Set c} Z → let module Z = Setoid Z in (f : Y → Z.Carrier) (g : X → Y) (xs : ⟦ C ⟧ X) → Eq Z._≈_ (map f (map g xs)) (map (f ⟨∘⟩ g) xs) composition {C = C} Z f g xs = Setoid.refl (setoid C Z) ------------------------------------------------------------------------ -- Container morphisms -- Representation of container morphisms. record _⇒_ {c} (C₁ C₂ : Container c) : Set c where field shape : Shape C₁ → Shape C₂ position : ∀ {s} → Position C₂ (shape s) → Position C₁ s open _⇒_ public -- Interpretation of _⇒_. ⟪_⟫ : ∀ {c} {C₁ C₂ : Container c} → C₁ ⇒ C₂ → ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X ⟪ m ⟫ xs = (shape m (proj₁ xs) , proj₂ xs ⟨∘⟩ position m) module Morphism where -- Naturality. Natural : ∀ {c} {C₁ C₂ : Container c} → (∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X) → Set (suc c) Natural {c} {C₁} m = ∀ {X} (Y : Setoid c c) → let module Y = Setoid Y in (f : X → Y.Carrier) (xs : ⟦ C₁ ⟧ X) → Eq Y._≈_ (m $ map f xs) (map f $ m xs) -- Natural transformations. NT : ∀ {c} (C₁ C₂ : Container c) → Set (suc c) NT C₁ C₂ = ∃ λ (m : ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X) → Natural m -- Container morphisms are natural. natural : ∀ {c} {C₁ C₂ : Container c} (m : C₁ ⇒ C₂) → Natural ⟪ m ⟫ natural {C₂ = C₂} m Y f xs = Setoid.refl (setoid C₂ Y) -- In fact, all natural functions of the right type are container -- morphisms. complete : ∀ {c} {C₁ C₂ : Container c} → (nt : NT C₁ C₂) → ∃ λ m → (X : Setoid c c) → let module X = Setoid X in (xs : ⟦ C₁ ⟧ X.Carrier) → Eq X._≈_ (proj₁ nt xs) (⟪ m ⟫ xs) complete (nt , nat) = (m , λ X xs → nat X (proj₂ xs) (proj₁ xs , ⟨id⟩)) where m = record { shape = λ s → proj₁ (nt (s , ⟨id⟩)) ; position = λ {s} → proj₂ (nt (s , ⟨id⟩)) } -- Identity. id : ∀ {c} (C : Container c) → C ⇒ C id _ = record {shape = ⟨id⟩; position = ⟨id⟩} -- Composition. infixr 9 _∘_ _∘_ : ∀ {c} {C₁ C₂ C₃ : Container c} → C₂ ⇒ C₃ → C₁ ⇒ C₂ → C₁ ⇒ C₃ f ∘ g = record { shape = shape f ⟨∘⟩ shape g ; position = position g ⟨∘⟩ position f } -- Identity and composition commute with ⟪_⟫. id-correct : ∀ {c} {C : Container c} {X : Set c} → ⟪ id C ⟫ {X} ≗ ⟨id⟩ id-correct xs = refl ∘-correct : ∀ {c} {C₁ C₂ C₃ : Container c} (f : C₂ ⇒ C₃) (g : C₁ ⇒ C₂) {X : Set c} → ⟪ f ∘ g ⟫ {X} ≗ (⟪ f ⟫ ⟨∘⟩ ⟪ g ⟫) ∘-correct f g xs = refl ------------------------------------------------------------------------ -- Linear container morphisms record _⊸_ {c} (C₁ C₂ : Container c) : Set c where field shape⊸ : Shape C₁ → Shape C₂ position⊸ : ∀ {s} → Position C₂ (shape⊸ s) ↔ Position C₁ s morphism : C₁ ⇒ C₂ morphism = record { shape = shape⊸ ; position = _⟨$⟩_ (Inverse.to position⊸) } ⟪_⟫⊸ : ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X ⟪_⟫⊸ = ⟪ morphism ⟫ open _⊸_ public using (shape⊸; position⊸; ⟪_⟫⊸) ------------------------------------------------------------------------ -- All and any -- All. □ : ∀ {c} {C : Container c} {X : Set c} → (X → Set c) → (⟦ C ⟧ X → Set c) □ P (s , f) = ∀ p → P (f p) □-map : ∀ {c} {C : Container c} {X : Set c} {P Q : X → Set c} → P ⊆ Q → □ {C = C} P ⊆ □ Q □-map P⊆Q = _⟨∘⟩_ P⊆Q -- Any. ◇ : ∀ {c} {C : Container c} {X : Set c} → (X → Set c) → (⟦ C ⟧ X → Set c) ◇ P (s , f) = ∃ λ p → P (f p) ◇-map : ∀ {c} {C : Container c} {X : Set c} {P Q : X → Set c} → P ⊆ Q → ◇ {C = C} P ⊆ ◇ Q ◇-map P⊆Q = Prod.map ⟨id⟩ P⊆Q -- Membership. infix 4 _∈_ _∈_ : ∀ {c} {C : Container c} {X : Set c} → X → ⟦ C ⟧ X → Set c x ∈ xs = ◇ (_≡_ x) xs -- Bag and set equality and related preorders. Two containers xs and -- ys are equal when viewed as sets if, whenever x ∈ xs, we also have -- x ∈ ys, and vice versa. They are equal when viewed as bags if, -- additionally, the sets x ∈ xs and x ∈ ys have the same size. open Related public using (Kind; Symmetric-kind) renaming ( implication to subset ; reverse-implication to superset ; equivalence to set ; injection to subbag ; reverse-injection to superbag ; bijection to bag ) [_]-Order : ∀ {ℓ} → Kind → Container ℓ → Set ℓ → Preorder ℓ ℓ ℓ [ k ]-Order C X = Related.InducedPreorder₂ k (_∈_ {C = C} {X = X}) [_]-Equality : ∀ {ℓ} → Symmetric-kind → Container ℓ → Set ℓ → Setoid ℓ ℓ [ k ]-Equality C X = Related.InducedEquivalence₂ k (_∈_ {C = C} {X = X}) infix 4 _∼[_]_ _∼[_]_ : ∀ {c} {C : Container c} {X : Set c} → ⟦ C ⟧ X → Kind → ⟦ C ⟧ X → Set c _∼[_]_ {C = C} {X} xs k ys = Preorder._∼_ ([ k ]-Order C X) xs ys
src/natools-smaz_implementations-base_64_tools.adb
faelys/natools
0
17517
<reponame>faelys/natools ------------------------------------------------------------------------------ -- Copyright (c) 2016-2017, <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.Smaz_Implementations.Base_64_Tools is use type Ada.Streams.Stream_Element_Offset; ----------------------- -- Bit Manipulations -- ----------------------- function Low_6 (Byte : in Character) return Base_64_Digit is (Base_64_Digit (Natural (Character'Pos (Byte)) mod 64)); function Low_4 (Byte : in Character) return Single_Byte_Padding is (Single_Byte_Padding (Natural (Character'Pos (Byte)) mod 16)); function Low_2 (Byte : in Character) return Double_Byte_Padding is (Double_Byte_Padding (Natural (Character'Pos (Byte)) mod 4)); -- Least significant bits of a byte function High_6 (Byte : in Character) return Base_64_Digit is (Base_64_Digit (Natural (Character'Pos (Byte)) / 4)); function High_4 (Byte : in Character) return Single_Byte_Padding is (Single_Byte_Padding (Natural (Character'Pos (Byte)) / 16)); function High_2 (Byte : in Character) return Double_Byte_Padding is (Double_Byte_Padding (Natural (Character'Pos (Byte)) / 64)); -- Most significant bits of a byte function Image_2_4 (Low : Double_Byte_Padding; High : Single_Byte_Padding) return Base_64_Symbol is (Image (Low + High * 4)); function Image_4_2 (Low : Single_Byte_Padding; High : Double_Byte_Padding) return Base_64_Symbol is (Image (Low + High * 16)); -- Composition into a base-64 symbol function Low_4 (Digit : in Base_64_Digit) return Natural is (Natural (Digit mod 16)); function Low_2 (Digit : in Base_64_Digit) return Natural is (Natural (Digit mod 4)); -- Least significat bits of a digit function High_4 (Digit : in Base_64_Digit) return Natural is (Natural (Digit / 4)); function High_2 (Digit : in Base_64_Digit) return Natural is (Natural (Digit / 16)); -- Least significat bits of a digit function Value_2_6 (Low, High : in Natural) return Character is (Character'Val (Low + High * 4)); function Value_4_4 (Low, High : in Natural) return Character is (Character'Val (Low + High * 16)); function Value_6_2 (Low, High : in Natural) return Character is (Character'Val (Low + High * 64)); -- Combine parts of digits into a Character ---------------------- -- Public Interface -- ---------------------- procedure Decode (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out String) is Index : Positive := Output'First; Padding_1 : Single_Byte_Padding; Padding_2 : Double_Byte_Padding; begin while Index in Output'Range loop case Output'Last - Index + 1 is when 1 => Decode_Single (Input, Offset, Output (Index), Padding_1); Index := Index + 1; when 2 => Decode_Double (Input, Offset, Output (Index .. Index + 1), Padding_2); Index := Index + 2; when others => Decode_Block (Input, Offset, Output (Index .. Index + 2)); Index := Index + 3; end case; end loop; end Decode; procedure Decode_Block (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Full_Block) is Data : array (1 .. 4) of Base_64_Digit; begin for I in Data'Range loop Next_Digit (Input, Offset, Data (I)); end loop; Output (1) := Value_6_2 (Natural (Data (1)), Low_2 (Data (2))); Output (2) := Value_4_4 (High_4 (Data (2)), Low_4 (Data (3))); Output (3) := Value_2_6 (High_2 (Data (3)), Natural (Data (4))); end Decode_Block; procedure Decode_Double (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Double_Byte; Padding : out Double_Byte_Padding) is Data : array (1 .. 3) of Base_64_Digit; begin for I in Data'Range loop Next_Digit (Input, Offset, Data (I)); end loop; Output (1) := Value_6_2 (Natural (Data (1)), Low_2 (Data (2))); Output (2) := Value_4_4 (High_4 (Data (2)), Low_4 (Data (3))); Padding := Double_Byte_Padding (High_2 (Data (3))); end Decode_Double; procedure Decode_Single (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Character; Padding : out Single_Byte_Padding) is Data : array (1 .. 2) of Base_64_Digit; begin for I in Data'Range loop Next_Digit (Input, Offset, Data (I)); end loop; Output := Value_6_2 (Natural (Data (1)), Low_2 (Data (2))); Padding := Single_Byte_Padding (High_4 (Data (2))); end Decode_Single; procedure Encode (Input : in String; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset) is Index : Positive := Input'First; begin while Index in Input'Range loop case Input'Last - Index + 1 is when 1 => Encode_Single (Input (Index), 0, Output, Offset); Index := Index + 1; when 2 => Encode_Double (Input (Index .. Index + 1), 0, Output, Offset); Index := Index + 2; when others => Encode_Block (Input (Index .. Index + 2), Output, Offset); Index := Index + 3; end case; end loop; end Encode; procedure Encode_Block (Input : in Full_Block; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset) is begin Output (Offset + 0) := Image (Low_6 (Input (1))); Output (Offset + 1) := Image_2_4 (High_2 (Input (1)), Low_4 (Input (2))); Output (Offset + 2) := Image_4_2 (High_4 (Input (2)), Low_2 (Input (3))); Output (Offset + 3) := Image (High_6 (Input (3))); Offset := Offset + 4; end Encode_Block; procedure Encode_Double (Input : in Double_Byte; Padding : in Double_Byte_Padding; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset) is begin Output (Offset + 0) := Image (Low_6 (Input (1))); Output (Offset + 1) := Image_2_4 (High_2 (Input (1)), Low_4 (Input (2))); Output (Offset + 2) := Image_4_2 (High_4 (Input (2)), Padding); Offset := Offset + 3; end Encode_Double; procedure Encode_Single (Input : in Character; Padding : in Single_Byte_Padding; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset) is begin Output (Offset + 0) := Image (Low_6 (Input)); Output (Offset + 1) := Image_2_4 (High_2 (Input), Padding); Offset := Offset + 2; end Encode_Single; procedure Next_Digit (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Digit : out Base_64_Digit) is begin while Input (Offset) not in Base_64_Symbol loop Offset := Offset + 1; end loop; Digit := Value (Input (Offset)); Offset := Offset + 1; end Next_Digit; procedure Next_Digit_Or_End (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Digit : out Base_64_Digit; Finished : out Boolean) is begin loop if Offset not in Input'Range then Finished := True; return; end if; exit when Input (Offset) in Base_64_Symbol; Offset := Offset + 1; end loop; Digit := Value (Input (Offset)); Finished := False; Offset := Offset + 1; end Next_Digit_Or_End; end Natools.Smaz_Implementations.Base_64_Tools;
programs/oeis/178/A178936.asm
karttu/loda
0
162769
<reponame>karttu/loda ; A178936: Floor((2*3^n+3*2^n)/5). ; 1,2,6,15,42,116,330,951,2778,8180,24234,72087,215034,642644,1923018,5759223,17258010,51734708,155125482,465219159,1395342906,4185399572,12554940426,37662304695,112981880922,338935576436,1016786596650,3050319524631,9150878043258,27452473068500,82357097082954,247070647003767,741210652521114,2223629380582964,6670882987788138 cal $0,94125 ; a(n) = 3*2^n + 2*3^n. div $0,5 add $0,1 mov $1,$0 sub $1,1
clickairplaymenu.applescript
bluemixgaragelondon/airplay-reconnect
8
3419
<filename>clickairplaymenu.applescript on run argv set tvname to item 1 of argv display notification "Sending display to " & tvname with title "Grabbing TV" tell application "System Events" tell process "SystemUIServer" click (menu bar item 1 of menu bar 1 whose description contains "Displays") set displaymenu to menu 1 of result -- Tolerate numbers in brackets after the tv name -- click ((menu item 1 where its name starts with tvname) of displaymenu) end tell end tell end run
programs/oeis/098/A098923.asm
karttu/loda
0
94777
<filename>programs/oeis/098/A098923.asm ; A098923: 33-gonal numbers: n(31n-29)/2. ; 0,1,33,96,190,315,471,658,876,1125,1405,1716,2058,2431,2835,3270,3736,4233,4761,5320,5910,6531,7183,7866,8580,9325,10101,10908,11746,12615,13515,14446,15408,16401,17425,18480,19566,20683,21831,23010 mov $2,$0 bin $2,2 mul $2,31 add $0,$2 mov $1,$0
src/Projects/eu_projects-nodes-action_nodes.ads
fintatarta/eugen
0
12388
<filename>src/Projects/eu_projects-nodes-action_nodes.ads<gh_stars>0 with EU_Projects.Nodes.Partners; with EU_Projects.Times.Time_Expressions; with EU_Projects.Event_Names; with EU_Projects.Node_Tables; with EU_Projects.Efforts; -- -- An action node is a basic node that represent an activity, that is, a WP -- or a task. An action has -- -- * A leader -- * An activity interval with begin and end dates -- -- Actually, there is the necessity of two types of begin/end dates. At -- the beginning the activity dates can be expressed in symbolic, e.g., -- the begin date of a task is the largest of the end dates of two -- other tasks. -- -- The constraints expressed in this way will be mapped to absolute -- dates by solving the corrispondent system of equations. After that, the -- symbolic dates need to be changed to their "absolute" counterpart. The -- symbolic dates are set during creation time, while the absolute times need -- to be fixed after all the project has been set. -- -- Because of this, an Action_Node has two states: if the absolute -- action times have been fixed or not. Absolute times can be fixed -- only once. -- package EU_Projects.Nodes.Action_Nodes is type Action_Node is abstract new Node_Type with private; type Instant_Raw is new String; type Duration_Raw is new String; type Action_Time is private; function Create (Start_On : Instant_Raw; End_On : Instant_Raw) return Action_Time; function Create (Depends_On : Node_Label_Lists.Vector; End_On : Instant_Raw) return Action_Time; function Create (Start_On : Instant_Raw; Duration : Duration_Raw) return Action_Time; function Create (Depends_On : Node_Label_Lists.Vector; Duration : Duration_Raw) return Action_Time; function Starting_Time (Item : Action_Node) return Times.Instant with Pre => Item.Is_Fixed (Event_Names.Begin_Name); function Ending_Time (Item : Action_Node) return Times.Instant with Pre => Item.Is_Fixed (Event_Names.End_Name); function Timing (Item : Action_Node) return String; function Leader (Item : Action_Node) return Partners.Partner_Label; overriding function Variables (Item : Action_Node) return Variable_List; overriding procedure Parse_Raw_Expressions (Item : in out Action_Node; Vars : Times.Time_Expressions.Parsing.Symbol_Table); overriding function Is_Variable (Item : Action_Node; Var : Simple_Identifier) return Boolean; overriding function Is_A (Item : Action_Node; Var : Simple_Identifier; Class : Times.Time_Type) return Boolean; overriding function Is_Fixed (Item : Action_Node; Var : Simple_Identifier) return Boolean; overriding procedure Fix_Instant (Item : in out Action_Node; Var : Simple_Identifier; Value : Times.Instant); overriding function Get_Symbolic_Instant (Item : Action_Node; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Instant; overriding function Get_Symbolic_Duration (Item : Action_Node; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Duration; procedure Add_Effort (Item : in out Action_Node; Partner : in Nodes.Partners.Partner_Label; PM : in Efforts.Person_Months); function Effort_Of (Item : Action_Node; Partner : Nodes.Partners.Partner_Label) return Efforts.Person_Months; type Effort_Entry is record Partner : Nodes.Partners.Partner_Label; Effort : Efforts.Person_Months; end record; type Effort_List is array (Partners.Partner_Index range <>) of Effort_Entry; function Efforts_Of (Item : Action_Node; Names : Partners.Partner_Name_Array) return Effort_List; Duplicated_Effort : exception; Unknown_Partner : exception; private use type Times.Time_Expressions.Symbolic_Instant; use type Times.Time_Expressions.Symbolic_Duration; use type Times.Time_Type; type Action_Time is record Start : Unbounded_String; Stop : Unbounded_String; Duration : Unbounded_String; end record with Type_Invariant => (if Stop = Null_Unbounded_String then Duration /= Null_Unbounded_String else Duration = Null_Unbounded_String); function Var_Begin (Item : Action_Node) return Times.Time_Expressions.Symbolic_Instant; function Var_End (Item : Action_Node) return Times.Time_Expressions.Symbolic_Instant; function Var_Duration (Item : Action_Node) return Times.Time_Expressions.Symbolic_Duration; procedure Initialize_Efforts (Item : in out Action_Node; Node_Dir : Node_Tables.Node_Table); type Action_Node is abstract new Node_Type with record Raw_Time : Action_Time; Start_Symbolic : Times.Time_Expressions.Symbolic_Instant; Stop_Symbolic : Times.Time_Expressions.Symbolic_Instant; Duration_Symbolic : Times.Time_Expressions.Symbolic_Duration; Start_At : Times.Instant; Stop_At : Times.Instant; Elapsed_Time : Times.Duration; Start_Fixed : Boolean := False; Stop_Fixed : Boolean := False; Leader : Nodes.Partners.Partner_Label; Partner_Effort : Efforts.Effort_Maps.Map; end record; function To_U (X : Instant_Raw) return Unbounded_String is (To_Unbounded_String (String (X))); function To_U (X : Duration_Raw) return Unbounded_String is (To_Unbounded_String (String (X))); function After (List : Node_Label_Lists.Vector) return Instant_Raw; function Create (Start_On : Instant_Raw; End_On : Instant_Raw) return Action_Time is (Start => To_U (Start_On), Stop => To_U (End_On), Duration => Null_Unbounded_String); function Create (Depends_On : Node_Label_Lists.Vector; End_On : Instant_Raw) return Action_Time is (Create (After (Depends_On), End_On)); function Create (Start_On : Instant_Raw; Duration : Duration_Raw) return Action_Time is (Start => To_U (Start_On), Stop => Null_Unbounded_String, Duration => To_U (Duration)); function Create (Depends_On : Node_Label_Lists.Vector; Duration : Duration_Raw) return Action_Time is (Create (After (Depends_On), Duration)); function Leader (Item : Action_Node) return Partners.Partner_Label is (Item.Leader); function Starting_Time (Item : Action_Node) return Times.Instant is (Item.Start_At); function Ending_Time (Item : Action_Node) return Times.Instant is (Item.Stop_At); function Timing (Item : Action_Node) return String is ("M" & Times.Image (Item.Starting_Time) & "-M" & Times.Image (Item.Ending_Time)); -- function Event_Var (Item : Action_Node; -- Event : Event_Type) return Identifier -- is (case Event is -- when Start => Item.Starting_Time_Var, -- when Stop => Item.Ending_Time_Var); -- -- function Event_Time (Item : Action_Node; -- Event : Event_Type) return Times.Instant -- is (case Event is -- when Start => Item.Starting_Time, -- when Stop => Item.Ending_Time); function Variables (Item : Action_Node) return Variable_List is ((1 => Event_Names.Begin_Name, 2 => Event_Names.End_Name, 3 => Event_Names.Duration_Name)); function Is_Variable (Item : Action_Node; Var : Simple_Identifier) return Boolean is (Var = Event_Names.Begin_Name or Var = Event_Names.End_Name or Var = Event_Names.Duration_Name); function Is_A (Item : Action_Node; Var : Simple_Identifier; Class : Times.Time_Type) return Boolean is (if Var = Event_Names.Begin_Name or Var = Event_Names.End_Name then Class = Times.Instant_Value elsif Var = Event_Names.Duration_Name then Class = Times.Duration_Value else False); function Is_Fixed (Item : Action_Node; Var : Simple_Identifier) return Boolean is (if Var = Event_Names.Begin_Name then Item.Start_Fixed elsif Var = Event_Names.End_Name then Item.Stop_Fixed elsif Var = Event_Names.Duration_Name then Item.Start_Fixed and Item.Stop_Fixed else raise Constraint_Error); overriding function Get_Symbolic_Instant (Item : Action_Node; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Instant is (if Var = Event_Names.Begin_Name then Item.Start_Symbolic elsif Var = Event_Names.End_Name then Item.Stop_Symbolic else raise Unknown_Instant_Var); overriding function Get_Symbolic_Duration (Item : Action_Node; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Duration is (if Var = Event_Names.Duration_Name then Item.Duration_Symbolic else raise Unknown_Duration_Var); function Effort_Of (Item : Action_Node; Partner : Nodes.Partners.Partner_Label) return Efforts.Person_Months is (if Item.Partner_Effort.Contains (Partner) then Item.Partner_Effort (Partner) else raise Unknown_Partner); end EU_Projects.Nodes.Action_Nodes;
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_21829_1867.asm
ljhsiun2/medusa
9
99479
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r8 push %rax push %rdx push %rsi lea addresses_UC_ht+0x9944, %r12 nop nop nop nop nop add $50434, %r11 and $0xffffffffffffffc0, %r12 vmovaps (%r12), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %rsi inc %r8 lea addresses_normal_ht+0xbcf4, %rax nop nop nop sub %rdx, %rdx mov $0x6162636465666768, %r10 movq %r10, %xmm7 vmovups %ymm7, (%rax) nop nop nop and $35785, %r11 pop %rsi pop %rdx pop %rax pop %r8 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r8 push %rax push %rbx push %rsi // Faulty Load lea addresses_UC+0x4f4, %r12 nop xor $52091, %rbx movb (%r12), %r8b lea oracles, %rbx and $0xff, %r8 shlq $12, %r8 mov (%rbx,%r8,1), %r8 pop %rsi pop %rbx pop %rax pop %r8 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 3, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_normal_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
oeis/028/A028860.asm
neoneye/loda-programs
11
26395
; A028860: a(n+2) = 2*a(n+1) + 2*a(n); a(0) = -1, a(1) = 1. ; Submitted by <NAME>(s4) ; -1,1,0,2,4,12,32,88,240,656,1792,4896,13376,36544,99840,272768,745216,2035968,5562368,15196672,41518080,113429504,309895168,846649344,2313089024,6319476736,17265131520,47169216512,128868696064,352075825152,961889042432,2627929735168,7179637555200,19615134580736,53589544271872,146409357705216,399997803954176,1092814323318784,2985624254545920,8156877155729408,22285002820550656,60883759952560128,166337525546221568,454442570997563392,1241560193087569920,3392005528170266624,9267131442515673088 mov $1,-1 mov $3,1 lpb $0 sub $0,1 mov $2,$3 add $3,$1 mov $1,$2 mul $3,2 lpe mov $0,$1
data/maps/objects/SafariZoneEastRestHouse.asm
opiter09/ASM-Machina
1
168499
<reponame>opiter09/ASM-Machina<filename>data/maps/objects/SafariZoneEastRestHouse.asm SafariZoneEastRestHouse_Object: db $a ; border block def_warps warp 2, 7, 4, SAFARI_ZONE_EAST warp 3, 7, 4, SAFARI_ZONE_EAST def_signs def_objects object SPRITE_SCIENTIST, 1, 3, WALK, UP_DOWN, 1 ; person object SPRITE_ROCKER, 4, 2, STAY, NONE, 2 ; person object SPRITE_SILPH_WORKER, 5, 2, STAY, NONE, 3 ; person def_warps_to SAFARI_ZONE_EAST_REST_HOUSE
oeis/001/A001056.asm
neoneye/loda-programs
11
4362
<reponame>neoneye/loda-programs ; A001056: a(n) = a(n-1)*a(n-2) + 1, a(0) = 1, a(1) = 3. ; Submitted by <NAME> ; 1,3,4,13,53,690,36571,25233991,922832284862,23286741570717144243,21489756930695820973683319349467,500426416062641238759467086706254193219790764168482,10754042042885415070816603338436200915110904821126871858491675028294447933424899095,5381606717708113077798871474753833275262765660168321552771296972742624833153456048326444818420239983696159726808440220432252429323791 mov $2,1 mov $3,2 lpb $0 sub $0,1 mov $4,$3 mov $3,$2 mul $2,$4 add $2,1 lpe mov $0,$2
examples/realview-pb-a8/startup_a9.asm
jsdelivrbot/ppci-mirror
0
244971
; DCD 0x20000678 ; Setup stack pointer ; DCD 0x06daa0e3 ; mov sp, #0x60 << 8 mov sp, 0x30000 BL main_main ; Branch to main (this is actually in the interrupt vector) local_loop: B local_loop
src/Data/FingerTree/Cons.agda
oisdk/agda-indexed-fingertree
1
14594
<gh_stars>1-10 {-# OPTIONS --without-K --safe #-} open import Algebra module Data.FingerTree.Cons {r m} (ℳ : Monoid r m) where open import Data.Product open import Data.FingerTree.Measures ℳ open import Data.FingerTree.Structures ℳ open import Data.FingerTree.Reasoning ℳ open σ ⦃ ... ⦄ open Monoid ℳ renaming (Carrier to 𝓡) infixr 5 _◂_ infixl 5 _▸_ _◂_ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (x : Σ) → (xs : Tree Σ) → μ⟨ Tree Σ ⟩≈ (μ x ∙ μ xs) a ◂ empty = single a ⇑[ ℳ ↯ ] a ◂ single b = deep ⟪ D₁ a & empty & D₁ b ⇓⟫ ⇑[ ℳ ↯ ] a ◂ deep (𝓂 ↤ D₁ b & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₂ a b & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₂ b c & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₃ a b c & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₃ b c d & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₄ a b c d & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₄ b c d e & m & rs ⇑[ 𝓂≈ ]) with ⟪ N₃ c d e ⇓⟫ ◂ m ... | m′ ⇑[ m′≈ ] = deep (μ a ∙ 𝓂 ↤ D₂ a b & m′ & rs ⇑[ ∙≫ ≪∙ m′≈ ] ≈[ ℳ ↯ ] ≈[ ∙≫ 𝓂≈ ]′) ⇑ _▸_ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → (x : Σ) → μ⟨ Tree Σ ⟩≈ (μ xs ∙ μ x) empty ▸ a = single a ⇑[ ℳ ↯ ] single a ▸ b = deep ⟪ D₁ a & empty & D₁ b ⇓⟫ ⇑[ ℳ ↯ ] deep (𝓂 ↤ ls & m & D₁ a ⇑[ 𝓂≈ ]) ▸ b = deep (𝓂 ∙ μ b ↤ ls & m & D₂ a b ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₂ a b ⇑[ 𝓂≈ ]) ▸ c = deep (𝓂 ∙ μ c ↤ ls & m & D₃ a b c ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₃ a b c ⇑[ 𝓂≈ ]) ▸ d = deep (𝓂 ∙ μ d ↤ ls & m & D₄ a b c d ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₄ a b c d ⇑[ 𝓂≈ ]) ▸ e with m ▸ ⟪ N₃ a b c ⇓⟫ ... | m′ ⇑[ m′≈ ] = deep (𝓂 ∙ μ e ↤ ls & m′ & D₂ d e ⇑[ ∙≫ ≪∙ m′≈ ] ≈[ ℳ ↯ ] ≈[ ≪∙ 𝓂≈ ]′) ⇑ open import Data.List as List using (List; _∷_; []) listToTree : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : List Σ) → μ⟨ Tree Σ ⟩≈ (μ xs) listToTree [] = empty ⇑ listToTree (x ∷ xs) = [ ℳ ↯ ]≈ do ys ← listToTree xs [ μ x ∙> s ⟿ s ] x ◂ ys
examples/stm32f0/rtc/rtc_irq.ads
ekoeppen/STM32_Generic_Ada_Drivers
1
30919
<filename>examples/stm32f0/rtc/rtc_irq.ads with Ada.Interrupts.Names; use Ada.Interrupts.Names; with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control; package RTC_IRQ is Alarm_Occurred : Suspension_Object; protected Handler is pragma Interrupt_Priority; private procedure IRQ_Handler; pragma Attach_Handler (IRQ_Handler, RTC); end Handler; end RTC_IRQ;
Numeral/Natural/Function/GreatestCommonDivisor/Extended.agda
Lolirofle/stuff-in-agda
6
12604
<filename>Numeral/Natural/Function/GreatestCommonDivisor/Extended.agda module Numeral.Natural.Function.GreatestCommonDivisor.Extended where import Lvl open import Data open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Logic.Propositional open import Numeral.Integer as ℤ open import Numeral.Integer.Oper open import Numeral.Integer.Proofs hiding (_≤_) open import Numeral.Natural as ℕ open import Numeral.Natural.Function.GreatestCommonDivisor import Numeral.Natural.Oper as ℕ open import Numeral.Natural.Oper.FlooredDivision open import Numeral.Natural.Oper.Modulo open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Classical open import Syntax.Number open import Type -- TODO: Does the same algorithm work in the naturals? https://math.stackexchange.com/questions/237372/finding-positive-b%C3%A9zout-coefficients https://math.stackexchange.com/questions/1230224/positive-solutions-of-893x-2432y-19?rq=1 gcdExt : ℕ → ℕ → (ℕ ⨯ ℤ ⨯ ℤ) gcdExt a b = gcdFold(\{a (𝐒 b) _ (succ min) _ (x , y) → (y , (x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(b))) ⋅ y)))}) (\_ _ _ _ _ → Tuple.swap) (1 , 0) a b open import Logic.IntroInstances open import Logic.Predicate open import Numeral.Natural.Inductions open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.DivMod.Proofs open import Numeral.Natural.Oper.Modulo.Proofs open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Proofs.Util open import Structure.Operator.Properties open import Syntax.Function open import Syntax.Transitivity private variable a b d : ℕ gcd-gcdExt-equal : (gcd a b ≡ Tuple.left(gcdExt a b)) gcd-gcdExt-equal {a}{b} = Gcd-unique {a}{b} Gcd-gcd Gcd-gcdFold -- Also called: Bézout's identity, extended Euclid's algorithm. gcd-linearCombination-existence : ∃{Obj = ℤ ⨯ ℤ}(\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ b) ⋅ y) ≡ +ₙ(gcd a b))}) gcd-linearCombination-existence {a}{b} = [ℕ]-strong-induction {φ = b ↦ ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ b) ⋅ y) ≡ +ₙ(gcd a b))})} base step {b}{a} where base : ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\{(x , y) → (((+ₙ a) ⋅ x) + (0 ⋅ y) ≡ +ₙ(gcd a 0))}) ∃.witness (base {a}) = (1 , 0) ∃.proof (base {ℕ.𝟎}) = [≡]-intro ∃.proof (base {ℕ.𝐒 a}) = [≡]-intro step : ∀{i} → (∀{j} → (j ≤ i) → ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ j) ⋅ y) ≡ +ₙ(gcd a j))})) → ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\{(x , y) → (((+ₙ a) ⋅ x) + ((+𝐒ₙ i) ⋅ y) ≡ +ₙ(gcd a (ℕ.𝐒(i))))}) ∃.witness (step {i} prev {a}) with [≥]-or-[<] {a}{ℕ.𝐒(i)} ... | [∨]-introₗ ia with [∃]-intro (x , y) ← prev{a mod ℕ.𝐒(i)} ([≤]-without-[𝐒] (mod-maxᵣ {a = a})) {ℕ.𝐒(i)} = (y , ((x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y)))) ... | [∨]-introᵣ (succ ai) with [∃]-intro (x , y) ← prev{a} ai {ℕ.𝐒(i)} = (y , x) ∃.proof (step {i} prev {a}) with [≥]-or-[<] {a}{ℕ.𝐒(i)} ... | [∨]-introₗ ia with [∃]-intro (x , y) ⦃ p ⦄ ← prev{a mod ℕ.𝐒(i)} ([≤]-without-[𝐒] (mod-maxᵣ {a = a})) {ℕ.𝐒(i)} = ((+ₙ a) ⋅ y) + ((+𝐒ₙ i) ⋅ (x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+ₙ a) ⋅ y) (distributivityₗ(_⋅_)(_−_) {+𝐒ₙ i}{x}{(+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y}) ] ((+ₙ a) ⋅ y) + (((+𝐒ₙ i) ⋅ x) − ((+𝐒ₙ i) ⋅ ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+ₙ a) ⋅ y) (congruence₂ᵣ(_−_)((+𝐒ₙ i) ⋅ x) p1) ] ((+ₙ a) ⋅ y) + (((+𝐒ₙ i) ⋅ x) − ((+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ{a = (+ₙ a) ⋅ y}{b = (+𝐒ₙ i) ⋅ x} ] ((+𝐒ₙ i) ⋅ x) + (((+ₙ a) ⋅ y) − ((+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+𝐒ₙ i) ⋅ x) (distributivityᵣ(_⋅_)(_−_) {+ₙ a}{_}{y}) ]-sym ((+𝐒ₙ i) ⋅ x) + (((+ₙ a) − (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i))))) ⋅ y) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+𝐒ₙ i) ⋅ x) (congruence₂ₗ(_⋅_)(y) p2) ] ((+𝐒ₙ i) ⋅ x) + ((+ₙ(a mod ℕ.𝐒(i))) ⋅ y) 🝖[ _≡_ ]-[ p ] +ₙ(gcd (ℕ.𝐒(i)) (a mod ℕ.𝐒(i))) 🝖-end where p0 = (ℕ.𝐒 i) ℕ.⋅ (a ⌊/⌋ ℕ.𝐒(i)) 🝖[ _≡_ ]-[ commutativity(ℕ._⋅_) {ℕ.𝐒 i}{a ⌊/⌋ ℕ.𝐒(i)} ] (a ⌊/⌋ ℕ.𝐒(i)) ℕ.⋅ (ℕ.𝐒 i) 🝖[ _≡_ ]-[ OneTypeTwoOp.moveᵣ-to-invOp {b = a mod ℕ.𝐒(i)}{c = a} (([⌊/⌋][mod]-is-division-with-remainder {y = i})) ] a ℕ.−₀ (a mod ℕ.𝐒(i)) 🝖-end p1 = (+𝐒ₙ i) ⋅ ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y) 🝖[ _≡_ ]-[ associativity(_⋅_) {+𝐒ₙ i} ]-sym ((+𝐒ₙ i) ⋅ (+ₙ(a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[] ((+ₙ(ℕ.𝐒 i)) ⋅ (+ₙ(a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(y) (preserving₂(+ₙ_)(ℕ._⋅_)(_⋅_) {ℕ.𝐒 i}) ]-sym (+ₙ((ℕ.𝐒 i) ℕ.⋅ (a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(y) (congruence₁(+ₙ_) p0) ] (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y 🝖-end p2 = (+ₙ a) − (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_−_)(+ₙ a) ([+ₙ][−₀][−]-preserving (mod-maxₗ {a}{ℕ.𝐒(i)})) ] (+ₙ a) − ((+ₙ a) − (+ₙ(a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(+ₙ a) (preserving₂(−_)(_+_)(_+_) {+ₙ a}{−(+ₙ(a mod ℕ.𝐒(i)))}) ] (+ₙ a) + ((−(+ₙ a)) − (−(+ₙ(a mod ℕ.𝐒(i))))) 🝖[ _≡_ ]-[ associativity(_+_) {+ₙ a}{−(+ₙ a)} ]-sym ((+ₙ a) − (+ₙ a)) − (−(+ₙ(a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂(_+_) (inverseFunctionᵣ(_+_)(−_) {+ₙ a}) (involution(−_)) ] 0 + (+ₙ(a mod ℕ.𝐒(i))) 🝖[ _≡_ ]-[ identityₗ(_+_)(0) ] +ₙ(a mod ℕ.𝐒(i)) 🝖[ _≡_ ]-end ... | [∨]-introᵣ (succ ai) with [∃]-intro (x , y) ⦃ p ⦄ ← prev{a} ai {ℕ.𝐒(i)} = commutativity(_+_) {(+ₙ a) ⋅ y}{(+ₙ ℕ.𝐒(i)) ⋅ x} 🝖 p
scripts/musicinfo.js.applescript
stephanwilliams/dnscript
1
1873
<gh_stars>1-10 function run(args) { var name = ""; var artist = ""; var album = ""; if (applicationIsOpen("iTunes")) { var iTunes = Application("iTunes"); if (iTunes.playerState() === "playing") { name = iTunes.currentTrack().name(); artist = iTunes.currentTrack().artist(); album = iTunes.currentTrack().album(); } } if (applicationIsOpen("VLC")) { var VLC = Application("VLC"); if (VLC.playing() === true) { var info = VLC.nameOfCurrentItem().split(" - "); name = info[1]; artist = info[0]; album = ""; } } switch (args[0]) { case "name": return name; case "artist": return artist; case "album": return album; } } function applicationIsOpen(name) { return Application("System Events").processes.whose({name: name}).length > 0; }
oeis/157/A157791.asm
neoneye/loda-programs
11
26654
; A157791: Least number of lattice points on two adjacent sides from which every point of a square n X n lattice is visible. ; Submitted by <NAME> ; 1,1,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 mov $3,1 lpb $3 trn $0,1 mul $0,2 add $0,1 mov $2,2 sub $3,1 lpb $0 add $2,1 div $0,$2 mul $0,2 lpe lpe mov $0,$2 sub $0,2
src/gen-model-stypes.adb
jquorning/dynamo
15
14869
<filename>src/gen-model-stypes.adb ----------------------------------------------------------------------- -- gen-model-stypes -- Simple data type definitions -- Copyright (C) 2021 <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. ----------------------------------------------------------------------- package body Gen.Model.Stypes is -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : Stype_Definition; Name : String) return UBO.Object is begin if Name = "parent" then return UBO.To_Object (From.Parent_Type); elsif Name = "name" then return UBO.To_Object (From.Type_Name); elsif Name = "isEnum" then return UBO.To_Object (False); elsif Name = "isDiscrete" or Name = "isNewDiscrete" then return UBO.To_Object (True); elsif Name = "sqlType" then if Length (From.Sql_Type) > 0 then return UBO.To_Object (Mappings.Get_Type_Name (From.Sql_Type)); else return UBO.To_Object (Mappings.Get_Type_Name (From.Parent_Type)); end if; else return Mappings.Mapping_Definition (From).Get_Value (Name); end if; end Get_Value; -- ------------------------------ -- Prepare the generation of the model. -- ------------------------------ overriding procedure Prepare (O : in out Stype_Definition) is begin O.Target := O.Type_Name; end Prepare; -- ------------------------------ -- Initialize the table definition instance. -- ------------------------------ overriding procedure Initialize (O : in out Stype_Definition) is begin null; end Initialize; -- ------------------------------ -- Create an simple type with its parent type. -- ------------------------------ function Create_Stype (Name : in UString; Parent : in UString) return Stype_Definition_Access is use Ada.Strings.Unbounded; Stype : constant Stype_Definition_Access := new Stype_Definition; begin Stype.Set_Name (Name); declare Pos : constant Natural := Index (Stype.Name, ".", Ada.Strings.Backward); begin Stype.Parent_Type := Parent; if Pos > 0 then Stype.Pkg_Name := Unbounded_Slice (Stype.Name, 1, Pos - 1); Stype.Type_Name := Unbounded_Slice (Stype.Name, Pos + 1, Length (Stype.Name)); Stype.Nullable_Type := "Nullable_" & Stype.Type_Name; -- Stype.Target := Stype.Name; else Stype.Pkg_Name := To_Unbounded_String ("ADO"); Stype.Type_Name := Stype.Name; -- Stype.Target := Stype.Name; end if; end; return Stype; end Create_Stype; end Gen.Model.Stypes;
oeis/158/A158608.asm
neoneye/loda-programs
11
170906
; A158608: a(n) = a(n-1) + 16*a(n-2), starting a(0)=1, a(1)=4. ; Submitted by <NAME>(s2) ; 1,4,20,84,404,1748,8212,36180,167572,746452,3427604,15370836,70212500,316145876,1439545876,6497879892,29530613908,133496692180,605986514708,2741933589588,12437717824916,56308655258324,255312140456980 mov $1,3 mov $3,1 lpb $0 sub $0,1 mov $2,$3 add $3,$1 mov $1,16 mul $1,$2 lpe mov $0,$3
Agda/12-univalence.agda
hemangandhi/HoTT-Intro
0
2554
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-} module 12-univalence where import 11-function-extensionality open 11-function-extensionality public -- Section 10.1 Type extensionality equiv-eq : {i : Level} {A : UU i} {B : UU i} → Id A B → A ≃ B equiv-eq {A = A} refl = equiv-id A UNIVALENCE : {i : Level} (A B : UU i) → UU (lsuc i) UNIVALENCE A B = is-equiv (equiv-eq {A = A} {B = B}) is-contr-total-equiv-UNIVALENCE : {i : Level} (A : UU i) → ((B : UU i) → UNIVALENCE A B) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv-UNIVALENCE A UA = fundamental-theorem-id' A ( equiv-id A) ( λ B → equiv-eq {B = B}) ( UA) UNIVALENCE-is-contr-total-equiv : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) → (B : UU i) → UNIVALENCE A B UNIVALENCE-is-contr-total-equiv A c = fundamental-theorem-id A ( equiv-id A) ( c) ( λ B → equiv-eq {B = B}) ev-id : {i j : Level} {A : UU i} (P : (B : UU i) → (A ≃ B) → UU j) → ((B : UU i) (e : A ≃ B) → P B e) → P A (equiv-id A) ev-id {A = A} P f = f A (equiv-id A) IND-EQUIV : {i j : Level} {A : UU i} → ((B : UU i) (e : A ≃ B) → UU j) → UU _ IND-EQUIV P = sec (ev-id P) triangle-ev-id : {i j : Level} {A : UU i} (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → (ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ~ ((ev-id (λ X e → P (pair X e))) ∘ (ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P})) triangle-ev-id P f = refl abstract IND-EQUIV-is-contr-total-equiv : {i j : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) → (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → IND-EQUIV (λ B e → P (pair B e)) IND-EQUIV-is-contr-total-equiv {i} {j} A c P = section-comp ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ( ev-id (λ X e → P (pair X e))) ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P}) ( triangle-ev-id P) ( sec-ev-pair (UU i) (λ X → A ≃ X) P) ( is-sing-is-contr (Σ (UU i) (λ X → A ≃ X)) ( pair ( pair A (equiv-id A)) ( λ t → ( inv (contraction c (pair A (equiv-id A)))) ∙ ( contraction c t))) ( P) ( pair A (equiv-id A))) abstract is-contr-total-equiv-IND-EQUIV : {i : Level} (A : UU i) → ( {j : Level} (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → IND-EQUIV (λ B e → P (pair B e))) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv-IND-EQUIV {i} A ind = is-contr-is-sing ( Σ (UU i) (λ X → A ≃ X)) ( pair A (equiv-id A)) ( λ P → section-comp' ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ( ev-id (λ X e → P (pair X e))) ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P}) ( triangle-ev-id P) ( sec-ev-pair (UU i) (λ X → A ≃ X) P) ( ind P)) -- The univalence axiom postulate univalence : {i : Level} (A B : UU i) → UNIVALENCE A B eq-equiv : {i : Level} (A B : UU i) → (A ≃ B) → Id A B eq-equiv A B = inv-is-equiv (univalence A B) abstract is-contr-total-equiv : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv A = is-contr-total-equiv-UNIVALENCE A (univalence A) inv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → Id (inv-equiv (inv-equiv e)) e inv-inv-equiv (pair f (pair (pair g G) (pair h H))) = eq-htpy-equiv refl-htpy is-equiv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} → is-equiv (inv-equiv {A = A} {B = B}) is-equiv-inv-equiv = is-equiv-has-inverse ( inv-equiv) ( inv-inv-equiv) ( inv-inv-equiv) equiv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} → (A ≃ B) ≃ (B ≃ A) equiv-inv-equiv = pair inv-equiv is-equiv-inv-equiv is-contr-total-equiv' : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → X ≃ A)) is-contr-total-equiv' A = is-contr-equiv ( Σ (UU _) (λ X → A ≃ X)) ( equiv-tot (λ X → equiv-inv-equiv)) ( is-contr-total-equiv A) abstract Ind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) → sec (ev-id P) Ind-equiv A P = IND-EQUIV-is-contr-total-equiv A ( is-contr-total-equiv A) ( λ t → P (pr1 t) (pr2 t)) ind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) → P A (equiv-id A) → {B : UU i} (e : A ≃ B) → P B e ind-equiv A P p {B} = pr1 (Ind-equiv A P) p B -- Subuniverses is-subuniverse : {l1 l2 : Level} (P : UU l1 → UU l2) → UU ((lsuc l1) ⊔ l2) is-subuniverse P = is-subtype P subuniverse : (l1 l2 : Level) → UU ((lsuc l1) ⊔ (lsuc l2)) subuniverse l1 l2 = Σ (UU l1 → UU l2) is-subuniverse {- By univalence, subuniverses are closed under equivalences. -} in-subuniverse-equiv : {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P X → P Y in-subuniverse-equiv P e = tr P (eq-equiv _ _ e) in-subuniverse-equiv' : {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P Y → P X in-subuniverse-equiv' P e = tr P (inv (eq-equiv _ _ e)) total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2) total-subuniverse {l1} P = Σ (UU l1) (pr1 P) {- We also introduce the notion of 'global subuniverse'. The handling of universe levels is a bit more complicated here, since (l : Level) → A l are kinds but not types. -} is-global-subuniverse : (α : Level → Level) (P : (l : Level) → subuniverse l (α l)) → (l1 l2 : Level) → UU _ is-global-subuniverse α P l1 l2 = (X : UU l1) (Y : UU l2) → X ≃ Y → (pr1 (P l1)) X → (pr1 (P l2)) Y {- Next we characterize the identity type of a subuniverse. -} Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → (s t : total-subuniverse P) → UU l1 Eq-total-subuniverse (pair P H) (pair X p) t = X ≃ (pr1 t) Eq-total-subuniverse-eq : {l1 l2 : Level} (P : subuniverse l1 l2) → (s t : total-subuniverse P) → Id s t → Eq-total-subuniverse P s t Eq-total-subuniverse-eq (pair P H) (pair X p) .(pair X p) refl = equiv-id X abstract is-contr-total-Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) (s : total-subuniverse P) → is-contr (Σ (total-subuniverse P) (λ t → Eq-total-subuniverse P s t)) is-contr-total-Eq-total-subuniverse (pair P H) (pair X p) = is-contr-total-Eq-substructure (is-contr-total-equiv X) H X (equiv-id X) p abstract is-equiv-Eq-total-subuniverse-eq : {l1 l2 : Level} (P : subuniverse l1 l2) (s t : total-subuniverse P) → is-equiv (Eq-total-subuniverse-eq P s t) is-equiv-Eq-total-subuniverse-eq (pair P H) (pair X p) = fundamental-theorem-id ( pair X p) ( equiv-id X) ( is-contr-total-Eq-total-subuniverse (pair P H) (pair X p)) ( Eq-total-subuniverse-eq (pair P H) (pair X p)) eq-Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → {s t : total-subuniverse P} → Eq-total-subuniverse P s t → Id s t eq-Eq-total-subuniverse P {s} {t} = inv-is-equiv (is-equiv-Eq-total-subuniverse-eq P s t) -- Section 12.2 Univalence implies function extensionality is-equiv-postcomp-univalence : {l1 l2 : Level} {X Y : UU l1} (A : UU l2) (e : X ≃ Y) → is-equiv (postcomp A (map-equiv e)) is-equiv-postcomp-univalence {X = X} A = ind-equiv X ( λ Y e → is-equiv (postcomp A (map-equiv e))) ( is-equiv-id (A → X)) weak-funext-univalence : {l : Level} {A : UU l} {B : A → UU l} → WEAK-FUNEXT A B weak-funext-univalence {A = A} {B} is-contr-B = is-contr-retract-of ( fib (postcomp A (pr1 {B = B})) id) ( pair ( λ f → pair (λ x → pair x (f x)) refl) ( pair ( λ h x → tr B (htpy-eq (pr2 h) x) (pr2 (pr1 h x))) ( refl-htpy))) ( is-contr-map-is-equiv ( is-equiv-postcomp-univalence A (equiv-pr1 is-contr-B)) ( id)) funext-univalence : {l : Level} {A : UU l} {B : A → UU l} (f : (x : A) → B x) → FUNEXT f funext-univalence {A = A} {B} f = FUNEXT-WEAK-FUNEXT (λ A B → weak-funext-univalence) A B f -- Exercises -- Exercise 10.1 tr-equiv-eq-ap : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {x y : A} (p : Id x y) → (map-equiv (equiv-eq (ap B p))) ~ tr B p tr-equiv-eq-ap refl = refl-htpy -- Exercise 10.2 subuniverse-is-contr : {i : Level} → subuniverse i i subuniverse-is-contr {i} = pair is-contr is-subtype-is-contr unit' : (i : Level) → UU i unit' i = pr1 (Raise i unit) abstract is-contr-unit' : (i : Level) → is-contr (unit' i) is-contr-unit' i = is-contr-equiv' unit (pr2 (Raise i unit)) is-contr-unit abstract center-UU-contr : (i : Level) → total-subuniverse (subuniverse-is-contr {i}) center-UU-contr i = pair (unit' i) (is-contr-unit' i) contraction-UU-contr : {i : Level} (A : Σ (UU i) is-contr) → Id (center-UU-contr i) A contraction-UU-contr (pair A is-contr-A) = eq-Eq-total-subuniverse subuniverse-is-contr ( equiv-is-contr (is-contr-unit' _) is-contr-A) abstract is-contr-UU-contr : (i : Level) → is-contr (Σ (UU i) is-contr) is-contr-UU-contr i = pair (center-UU-contr i) (contraction-UU-contr) is-trunc-UU-trunc : (k : 𝕋) (i : Level) → is-trunc (succ-𝕋 k) (Σ (UU i) (is-trunc k)) is-trunc-UU-trunc k i X Y = is-trunc-is-equiv k ( Id (pr1 X) (pr1 Y)) ( ap pr1) ( is-emb-pr1-is-subtype ( is-prop-is-trunc k) X Y) ( is-trunc-is-equiv k ( (pr1 X) ≃ (pr1 Y)) ( equiv-eq) ( univalence (pr1 X) (pr1 Y)) ( is-trunc-equiv-is-trunc k (pr2 X) (pr2 Y))) ev-true-false : {l : Level} (A : UU l) → (f : bool → A) → A × A ev-true-false A f = pair (f true) (f false) map-universal-property-bool : {l : Level} {A : UU l} → A × A → (bool → A) map-universal-property-bool (pair x y) true = x map-universal-property-bool (pair x y) false = y issec-map-universal-property-bool : {l : Level} {A : UU l} → ((ev-true-false A) ∘ map-universal-property-bool) ~ id issec-map-universal-property-bool (pair x y) = eq-pair-triv (pair refl refl) isretr-map-universal-property-bool' : {l : Level} {A : UU l} (f : bool → A) → (map-universal-property-bool (ev-true-false A f)) ~ f isretr-map-universal-property-bool' f true = refl isretr-map-universal-property-bool' f false = refl isretr-map-universal-property-bool : {l : Level} {A : UU l} → (map-universal-property-bool ∘ (ev-true-false A)) ~ id isretr-map-universal-property-bool f = eq-htpy (isretr-map-universal-property-bool' f) universal-property-bool : {l : Level} (A : UU l) → is-equiv (λ (f : bool → A) → pair (f true) (f false)) universal-property-bool A = is-equiv-has-inverse map-universal-property-bool issec-map-universal-property-bool isretr-map-universal-property-bool ev-true : {l : Level} {A : UU l} → (bool → A) → A ev-true f = f true triangle-ev-true : {l : Level} (A : UU l) → (ev-true) ~ (pr1 ∘ (ev-true-false A)) triangle-ev-true A = refl-htpy aut-bool-bool : bool → (bool ≃ bool) aut-bool-bool true = equiv-id bool aut-bool-bool false = equiv-neg-𝟚 bool-aut-bool : (bool ≃ bool) → bool bool-aut-bool e = map-equiv e true decide-true-false : (b : bool) → coprod (Id b true) (Id b false) decide-true-false true = inl refl decide-true-false false = inr refl eq-false : (b : bool) → (¬ (Id b true)) → (Id b false) eq-false true p = ind-empty (p refl) eq-false false p = refl eq-true : (b : bool) → (¬ (Id b false)) → Id b true eq-true true p = refl eq-true false p = ind-empty (p refl) Eq-𝟚-eq : (x y : bool) → Id x y → Eq-𝟚 x y Eq-𝟚-eq x .x refl = reflexive-Eq-𝟚 x eq-false-equiv' : (e : bool ≃ bool) → Id (map-equiv e true) true → is-decidable (Id (map-equiv e false) false) → Id (map-equiv e false) false eq-false-equiv' e p (inl q) = q eq-false-equiv' e p (inr x) = ind-empty ( Eq-𝟚-eq true false ( ap pr1 ( is-prop-is-contr' ( is-contr-map-is-equiv (is-equiv-map-equiv e) true) ( pair true p) ( pair false (eq-true (map-equiv e false) x))))) {- eq-false-equiv : (e : bool ≃ bool) → Id (map-equiv e true) true → Id (map-equiv e false) false eq-false-equiv e p = eq-false-equiv' e p (has-decidable-equality-𝟚 (map-equiv e false) false) -} {- eq-true-equiv : (e : bool ≃ bool) → ¬ (Id (map-equiv e true) true) → Id (map-equiv e false) true eq-true-equiv e f = {!!} issec-bool-aut-bool' : ( e : bool ≃ bool) (d : is-decidable (Id (map-equiv e true) true)) → htpy-equiv (aut-bool-bool (bool-aut-bool e)) e issec-bool-aut-bool' e (inl p) true = ( htpy-equiv-eq (ap aut-bool-bool p) true) ∙ (inv p) issec-bool-aut-bool' e (inl p) false = ( htpy-equiv-eq (ap aut-bool-bool p) false) ∙ ( inv (eq-false-equiv e p)) issec-bool-aut-bool' e (inr f) true = ( htpy-equiv-eq ( ap aut-bool-bool (eq-false (map-equiv e true) f)) true) ∙ ( inv (eq-false (map-equiv e true) f)) issec-bool-aut-bool' e (inr f) false = ( htpy-equiv-eq (ap aut-bool-bool {!eq-true-equiv e ?!}) {!!}) ∙ ( inv {!!}) issec-bool-aut-bool : (aut-bool-bool ∘ bool-aut-bool) ~ id issec-bool-aut-bool e = eq-htpy-equiv ( issec-bool-aut-bool' e ( has-decidable-equality-𝟚 (map-equiv e true) true)) -}
Task/Zig-zag-matrix/AppleScript/zig-zag-matrix-2.applescript
LaudateCorpus1/RosettaCodeData
1
2910
<filename>Task/Zig-zag-matrix/AppleScript/zig-zag-matrix-2.applescript set n to 5 set m to {} repeat with i from 1 to n set end of m to {} -- Built a foundation for the matrix out of n empty lists. end repeat set {v, d, i} to {0, -1, 1} repeat while v < n ^ 2 if length of m's item i < n then set {end of m's item i, i, v} to {f(v, n), i + d, v + 1} if i < 1 then set {i, d} to {1, -d} else if i > n then set {i, d} to {n, -d} else if i > 1 and (count of m's item (i - 1)) = 1 then set d to -d end if else set {i, d} to {i + 1, 1} end if end repeat -- Handler/function to format the cells on the fly. on f(v, n) return (characters -(length of (n ^ 2 as string)) thru -1 of (" " & v)) as string end f -- Reformat the matrix into a table for viewing. set text item delimiters to "" repeat with i in m set i's contents to (i as string) & return end repeat return return & m as string
VerificationConditions.agda
iwilare/imp-semantics
6
12778
<filename>VerificationConditions.agda open import Data.Nat using (ℕ; _+_) renaming (_≤?_ to _≤?ₙ_) open import Data.Bool using (Bool; true; false; not; _∧_) open import Data.String using (String; _≟_) open import Data.Sum using (_⊎_; [_,_]′; inj₁; inj₂) open import Data.Product using (_×_; _,_) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Data.Product using (_×_; _,_; -,_; _-,-_; ∃; ∃-syntax) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym) open import Level using (Level; suc; _⊔_) open import IMP open import Hoare data True {l} : Set l where ⊤ : True data acom {l} : Set (suc l) where SKIP : acom _::=_ : String → aexp → acom _::_ : acom {l} → acom {l} → acom IF_THEN_ELSE_ : bexp → acom {l} → acom {l} → acom WHILE[_]_DO_ : assn {l} → bexp → acom {l} → acom strip : ∀{l} → acom {l} → com strip SKIP = SKIP strip (x ::= a) = x ::= a strip (c₁ :: c₂) = strip c₁ :: strip c₂ strip (IF b THEN c₁ ELSE c₂) = IF b THEN strip c₁ ELSE strip c₂ strip (WHILE[ I ] b DO c) = WHILE b DO strip c pre : ∀{l} → acom {l} → assn → assn pre SKIP Q = Q pre (x ::= a) Q s = Q (s [ x ::= aval a s ]) pre (c₁ :: c₂) Q = pre c₁ (pre c₂ Q) pre (IF b THEN c₁ ELSE c₂) Q s with bval b s ... | true = pre c₁ Q s ... | false = pre c₂ Q s pre (WHILE[ I ] b DO c) Q = I vc : ∀{l} → acom {l} → assn → Set l vc SKIP Q = True vc (x ::= x₁) Q = True vc (c₁ :: c₂) Q = vc c₁ (pre c₂ Q) × vc c₂ Q vc (IF b THEN c₁ ELSE c₂) Q = vc c₁ Q × vc c₂ Q vc (WHILE[ I ] b DO c) Q = (∀ s → I s × bval b s ≡ true → pre c I s) × (∀ s → I s × bval b s ≡ false → Q s) × vc c I extract-if-pre₁ : ∀{l} {Q : assn {l}} {c₁ c₂ s} b → pre (IF b THEN c₁ ELSE c₂) Q s × bval b s ≡ true → pre c₁ Q s extract-if-pre₁ b (x , y) rewrite y = x extract-if-pre₂ : ∀{l} {Q : assn {l}} {c₁ c₂ s} b → pre (IF b THEN c₁ ELSE c₂) Q s × bval b s ≡ false → pre c₂ Q s extract-if-pre₂ b (x , y) rewrite y = x vc-correctness : ∀{l} {P Q : assn} c → vc {l} c Q → (∀ s → P s → pre c Q s) → ⊢[ P ] strip c [ Q ] vc-correctness SKIP v i = Conseq i Skip (λ s z → z) vc-correctness (x ::= a) v i = Conseq i Loc (λ r k → k) vc-correctness (c₁ :: c₂) v i = Comp (vc-correctness c₁ (Data.Product.proj₁ v) i) (vc-correctness c₂ (Data.Product.proj₂ v) (λ s z → z)) vc-correctness {l}{P}{Q} (IF b THEN c₁ ELSE c₂) (fst , snd) i = Conseq i (If (vc-correctness c₁ fst (λ s p → extract-if-pre₁ b p)) (vc-correctness c₂ snd (λ s p → extract-if-pre₂ b p))) (λ s z → z) vc-correctness (WHILE[ I ] b DO c) (fst , fst₁ , snd) i = Conseq i (While (vc-correctness c snd fst)) fst₁ pre-mono : ∀{l} {P P′ : assn {l}} {s′} c → (∀ s → P s → P′ s) → pre c P s′ → pre c P′ s′ pre-mono {s′ = s′} SKIP x x₁ = x s′ x₁ pre-mono (x₂ ::= x₃) x x₁ = x _ x₁ pre-mono (c :: c₁) x x₁ = pre-mono c (λ s → pre-mono c₁ x) x₁ pre-mono {s′ = s′} (IF x₂ THEN c₁ ELSE c₂) x x₁ with bval x₂ s′ ... | true = pre-mono c₁ x x₁ ... | false = pre-mono c₂ x x₁ pre-mono (WHILE[ x₂ ] x₃ DO c) x x₁ = x₁ vc-mono : ∀{l} {P P′ : assn {l}} c → (∀ s → P s → P′ s) → vc c P → vc c P′ vc-mono SKIP _ _ = ⊤ vc-mono (x ::= a) _ _ = ⊤ vc-mono (c₁ :: c₂) pp′ (vcpre , vc2) = vc-mono c₁ (λ _ → pre-mono c₂ pp′) vcpre , vc-mono c₂ pp′ vc2 vc-mono (IF b THEN c₁ ELSE c₂) pp′ (vc₁ , vc₂) = vc-mono c₁ pp′ vc₁ , vc-mono c₂ pp′ vc₂ vc-mono (WHILE[ I ] b DO c) pp′ (I₁ , I₂ , vcc) = I₁ , (λ s z → pp′ s (I₂ s z)) , vcc either : ∀ c → c ≡ true ⊎ c ≡ false either true = inj₁ refl either false = inj₂ refl construct-if-pre : ∀{l} {P Q : assn {l}} {ac₁ ac₂} b s → (bval b s ≡ true → pre ac₁ Q s) → (bval b s ≡ false → pre ac₂ Q s) → pre (IF b THEN ac₁ ELSE ac₂) Q s construct-if-pre b s f g with bval b s ... | true = f refl ... | false = g refl vc-completeness : ∀{l} {P Q : assn {l}} c → ⊢[ P ] c [ Q ] → ∃[ c̃ ] ( c ≡ strip c̃ × vc c̃ Q × (∀ s → P s → pre c̃ Q s)) vc-completeness c Skip = SKIP , refl , ⊤ , (λ x c → c) vc-completeness c Loc = _ , refl , ⊤ , (λ x c → c) vc-completeness (c₁ :: c₂) (Comp x y) with vc-completeness c₁ x ... | ac₁ , b , c , d with vc-completeness c₂ y ... | ac₂ , f , g , h rewrite b | f = (ac₁ :: ac₂) , refl , (vc-mono ac₁ h c , g) , (λ s ps → pre-mono ac₁ h (d s ps)) vc-completeness {P = P} (IF b THEN c₁ ELSE c₂) (If d₁ d₂) with vc-completeness c₁ d₁ ... | ac₁ , f , g , h with vc-completeness c₂ d₂ ... | ac₂ , j , k , m rewrite f | j = (IF b THEN ac₁ ELSE ac₂) , refl , (g , k) , (λ s ps → construct-if-pre {P = P} b s (λ t → h s (ps , t)) (λ f → m s (ps , f))) vc-completeness (WHILE b DO c) (While r) with vc-completeness c r ... | ac , f , g , h rewrite f = (WHILE[ _ ] b DO ac) , refl , (h , (λ s z → z) , g) , λ s z → z vc-completeness c (Conseq x₁ r x₂) with vc-completeness c r ... | ac , f , g , h rewrite f = ac , refl , vc-mono ac x₂ g , (λ s ps → pre-mono ac x₂ (h s (x₁ s ps)))
examples/outdated-and-incorrect/lattice/Lattice.agda
asr/agda-kanso
1
2926
<reponame>asr/agda-kanso<gh_stars>1-10 module Lattice where open import Prelude open import PartialOrder as PO open import SemiLattice as SL import Chain open POrder using (Dual) record Lattice (A : Set) : Set1 where field sl : SemiLattice A _⊔_ : A -> A -> A prf : IsSemiLattice (Dual (SemiLat.po sl)) _⊔_ module Lat {A : Set}(L : Lattice A) where private module LL = Lattice L module SLL = SemiLat LL.sl private sl' : SemiLattice A sl' = record { po = Dual SLL.po; _⊓_ = LL._⊔_; prf = LL.prf } module SLL' = SemiLat sl' hiding ( Monotone ; Antitone ; _==_; ==-refl; ==-sym; ==-trans ; po ) renaming ( _≤_ to _≥_ ; ≤-refl to ≥-refl ; ≤-trans to ≥-trans ; ≤-antisym to ≥-antisym ; ==≤-L to ==≥-R ; ==≤-R to ==≥-L ; _⊓_ to _⊔_ ; ⊓-lbL to ⊔-ubL ; ⊓-lbR to ⊔-ubR ; ⊓-glb to ⊔-lub ; ⊓-commute to ⊔-commute ; ⊓-assoc to ⊔-assoc ; ⊓-idem to ⊔-idem ; ≤⊓-L to ≥⊔-L ; ≤⊓-R to ≥⊔-R ; ⊓-monotone-R to ⊔-monotone-R ; ⊓-monotone-L to ⊔-monotone-L ; ≤⊓-compat to ≥⊔-compat ; ⊓-cong to ⊔-cong ; ⊓-cong-L to ⊔-cong-L ; ⊓-cong-R to ⊔-cong-R ) open SLL public open SLL' public DualLattice : Lattice A DualLattice = record { sl = sl'; _⊔_ = _⊓_; prf = SemiLattice.prf LL.sl } module MeetJoin {A : Set}(L : Lattice A) where private module L = Lat L open L open module C== = Chain _==_ (\x -> ==-refl) (\x y z -> ==-trans) -- Experiment with very explicit proof ⊓⊔-absorb-LL = \{x y} -> (x ⊓ (x ⊔ y)) == x from ≤-antisym ((x ⊓ (x ⊔ y)) ≤ x from ⊓-lbL) (x ≤ (x ⊓ (x ⊔ y)) from ⊓-glb (x ≤ x from ≤-refl) (x ≤ (x ⊔ y) from ⊔-ubL) ) ⊓⊔-eq : forall {x y} -> (x ⊓ y) == (x ⊔ y) -> x == y ⊓⊔-eq {x}{y} p = chain> x === x ⊓ (x ⊔ y) by ==-sym ⊓⊔-absorb-LL === x ⊓ (x ⊓ y) by ==-sym (⊓-cong-R p) === (x ⊓ x) ⊓ y by {!!} -- ⊓-assoc === x ⊓ y by ⊓-cong-L ⊓-idem === y ⊓ x by ⊓-commute === (y ⊓ y) ⊓ x by ⊓-cong-L (==-sym ⊓-idem) === y ⊓ (y ⊓ x) by ==-sym ⊓-assoc === y ⊓ (x ⊓ y) by ⊓-cong-R ⊓-commute === y ⊓ (x ⊔ y) by {! !} -- ⊓-cong-R p === y ⊓ (y ⊔ x) by ⊓-cong-R ⊔-commute === y by ⊓⊔-absorb-LL module JoinMeet {A : Set}(L : Lattice A) = MeetJoin (Lat.DualLattice L) hiding (⊓⊔-eq) renaming (⊓⊔-absorb-LL to ⊔⊓-absorb-LL)
asm/amd64/core.asm
drkameleon/elena-lang
0
246367
<reponame>drkameleon/elena-lang // --- Predefined References -- define INIT 10013h define NEWFRAME 10014h define EXIT 1001Dh define PREPARE 10027h define CORE_OS_TABLE 20009h // --- System Core Functions -- procedure % INIT ret end procedure % NEWFRAME ret end // ; ==== Command Set == // ; close inline % 15h mov rsp, rbp pop rbp end // ; validate inline % 03Ah cmp dword ptr [rax], eax end // ; ncopy (src, tgt) inline % 42h mov esi, dword ptr [rax] mov dword ptr [rdi], esi end // ; nadd inline % 43h mov edx, dword ptr [rax] add dword ptr [rdi], edx end // ; nsave inline % 47h mov dword ptr [rdi], ebx end // ; nload inline % 48h mov ebx, dword ptr [rax] end // ; restore inline % 92h add rbp, __arg1 end // ; aloadfi inline % 94h mov rax, qword ptr [rbp+__arg1] end // ; aloadsi inline % 95h mov rax, qword ptr [rsp+__arg1] end // ; open inline % 98h push rbp mov rbp, rsp end // ; reserve inline % 0BFh sub rsp, __arg1 push rbp push 0 mov rbp, rsp end // ; bloadsi inline % 0C9h mov rdi, qword ptr [rsp + __arg1] end // ; aloadbi (__arg1 : index) inline % 0CEh mov rax, qword ptr [rdi + __arg1] end // xcallrm (rdx contains message, __arg1 contains vmtentry) inline % 0FEh call code : __arg1 end
examples/outdated-and-incorrect/cbs/Proc.agda
asr/agda-kanso
1
1181
module Proc where open import Basics module ProcDef (U : Set)(T : U -> Set)(Name : U -> Set) where LT : U -> Set LT a = Lift (T a) record Tran (a b : U) : Set where field upV : T b -> LT a downV : T a -> LT b mapLT : {a b : U} -> (T a -> LT b) -> List (T a) -> List (T b) mapLT f [] = [] mapLT f (x :: xs) with f x ... | bot = mapLT f xs ... | lift y = y :: mapLT f xs infixr 40 _!_ _!_+_ infix 40 >_ infixr 30 _||_ _/|_ data Proc (a : U) : Set where o : Proc a >_ : (T a -> Proc a) -> Proc a _!_ : LT a -> Proc a -> Proc a _!_+_ : LT a -> Proc a -> (T a -> Proc a) -> Proc a _||_ : Proc a -> Proc a -> Proc a _/|_ : {b : U} -> Tran a b -> Proc b -> Proc a def : Name a -> Proc a Env : Set Env = (a : U) -> Name a -> Proc a record Param : Set1 where field U : Set T : U -> Set Name : U -> Set env : ProcDef.Env U T Name module Process (param : Param) where private open module Par = Param param public private open module Pro = ProcDef U T Name public infixr 40 _!g_ _!_+g_ infix 40 >g_ infixr 30 _||g_ _/|g_ data Guard {a : U} : Proc a -> Set where og : Guard o >g_ : (f : T a -> Proc a) -> Guard (> f) _!g_ : (w : LT a)(p : Proc a) -> Guard (w ! p) _!_+g_ : (w : LT a)(p : Proc a)(f : T a -> Proc a) -> Guard (w ! p + f) _||g_ : {p1 p2 : Proc a} -> Guard p1 -> Guard p2 -> Guard (p1 || p2) _/|g_ : {b : U}(φ : Tran a b){p : Proc b} -> Guard p -> Guard (φ /| p) defg : (x : Name a) -> Guard (env a x) -> Guard (def x) infix 20 _-[_]->_ _-!_!->_ open Tran data _-[_]->_ {a : U} : Proc a -> LT a -> Proc a -> Set where qtau : {p : Proc a} -> p -[ bot ]-> p rx-o : {v : T a} -> o -[ lift v ]-> o rx-! : {v : T a}{w : LT a}{p : Proc a} -> w ! p -[ lift v ]-> w ! p rx-> : {v : T a}{f : T a -> Proc a} -> > f -[ lift v ]-> f v rx-+ : {v : T a}{w : LT a}{p : Proc a}{f : T a -> Proc a} -> w ! p + f -[ lift v ]-> f v rx-|| : {v : T a}{p1 p2 p1' p2' : Proc a} -> p1 -[ lift v ]-> p1' -> p2 -[ lift v ]-> p2' -> p1 || p2 -[ lift v ]-> p1' || p2' rx-/| : {v : T a}{b : U}{φ : Tran a b}{q q' : Proc b} -> q -[ downV φ v ]-> q' -> φ /| q -[ lift v ]-> φ /| q' rx-def : {v : T a}{p : Proc a}{x : Name a} -> env a x -[ lift v ]-> p -> def x -[ lift v ]-> p data _-!_!->_ {a : U} : Proc a -> LT a -> Proc a -> Set where tx-! : {w : LT a}{p : Proc a} -> w ! p -! w !-> p tx-+ : {w : LT a}{p : Proc a}{f : T a -> Proc a} -> w ! p + f -! w !-> p tx-!| : {w : LT a}{p p' q q' : Proc a} -> p -! w !-> p' -> q -[ w ]-> q' -> p || q -! w !-> p' || q' tx-|! : {w : LT a}{p p' q q' : Proc a} -> p -[ w ]-> p' -> q -! w !-> q' -> p || q -! w !-> p' || q' tx-/| : {b : U}{w : LT b}{φ : Tran a b}{q q' : Proc b} -> q -! w !-> q' -> φ /| q -! upV φ =<< w !-> φ /| q' tx-def : {w : LT a}{p : Proc a}{x : Name a} -> env a x -! w !-> p -> def x -! w !-> p data Silent {a : U} : Proc a -> Set where silent-o : Silent o silent-> : {f : T a -> Proc a} -> Silent (> f) silent-|| : {p1 p2 : Proc a} -> Silent p1 -> Silent p2 -> Silent (p1 || p2) silent-def : {x : Name a} -> Silent (env _ x) -> Silent (def x) silent-/| : {b : U}{φ : Tran a b}{p : Proc b} -> Silent p -> Silent (φ /| p) infixr 40 _>!>_ _>*>_ data _-[_]->*_ {a : U} : Proc a -> List (T a) -> Proc a -> Set where rnop : {p : Proc a} -> p -[ [] ]->* p _>?>_ : {p q r : Proc a}{x : T a}{xs : List (T a)} -> p -[ lift x ]-> q -> q -[ xs ]->* r -> p -[ x :: xs ]->* r rx-||* : forall {a xs}{p1 p2 q1 q2 : Proc a} -> p1 -[ xs ]->* p2 -> q1 -[ xs ]->* q2 -> p1 || q1 -[ xs ]->* p2 || q2 rx-||* rnop rnop = rnop rx-||* (s1 >?> t1) (s2 >?> t2) = rx-|| s1 s2 >?> rx-||* t1 t2 rx-/|* : forall {a b xs}{φ : Tran a b}{p q : Proc b} -> p -[ mapLT (downV φ) xs ]->* q -> φ /| p -[ xs ]->* φ /| q rx-/|* {xs = []} rnop = rnop rx-/|* {xs = x :: xs}{φ = φ} t with it (downV φ x) refl rx-/|* {xs = x :: xs}{φ}{p}{q} t | it bot eq = rx-/| (lem₁ eq) >?> rx-/|* (lem₂ eq t) where lem₁ : forall {w} -> w == bot -> p -[ w ]-> p lem₁ refl = qtau lem₂ : downV φ x == bot -> p -[ mapLT (downV φ) (x :: xs) ]->* q -> p -[ mapLT (downV φ) xs ]->* q lem₂ eq h with downV φ x lem₂ refl h | .bot = h rx-/|* {a}{b}{x :: xs}{φ}{p}{q} t | it (lift y) eq = rx-/| (lem₁ eq t) >?> rx-/|* (lem₂ eq t) where Eqn = downV φ x == lift y Asm = p -[ mapLT (downV φ) (x :: xs) ]->* q r : Eqn -> Asm -> Proc b r eq t with downV φ x r refl (_>?>_ {q = q} _ _) | ._ = q lem₁ : (eq : Eqn)(h : Asm) -> p -[ downV φ x ]-> r eq h lem₁ eq t with downV φ x lem₁ refl (s >?> _) | ._ = s lem₂ : (eq : Eqn)(h : Asm) -> r eq h -[ mapLT (downV φ) xs ]->* q lem₂ eq t with downV φ x lem₂ refl (_ >?> t) | ._ = t data _-!_!->*_ {a : U} : Proc a -> List (T a) -> Proc a -> Set where tnop : {p : Proc a} -> p -! [] !->* p _>!>_ : {p q r : Proc a}{x : T a}{xs : List (T a)} -> p -! lift x !-> q -> q -! xs !->* r -> p -! x :: xs !->* r _>*>_ : {p q r : Proc a}{xs : List (T a)} -> p -! bot !-> q -> q -! xs !->* r -> p -! xs !->* r
kill.asm
avabe/Operating_Systems_Assignment1
0
240221
<reponame>avabe/Operating_Systems_Assignment1 _kill: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char **argv) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 56 push %esi 4: 53 push %ebx 5: 83 e4 f0 and $0xfffffff0,%esp 8: 83 ec 10 sub $0x10,%esp b: 8b 45 08 mov 0x8(%ebp),%eax e: 8b 55 0c mov 0xc(%ebp),%edx int i; if(argc < 2){ 11: 83 f8 01 cmp $0x1,%eax 14: 7e 2f jle 45 <main+0x45> 16: 8d 5a 04 lea 0x4(%edx),%ebx 19: 8d 34 82 lea (%edx,%eax,4),%esi 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "usage: kill pid...\n"); exit(0); } for(i=1; i<argc; i++) kill(atoi(argv[i])); 20: 8b 03 mov (%ebx),%eax 22: 83 c3 04 add $0x4,%ebx 25: 89 04 24 mov %eax,(%esp) 28: e8 23 02 00 00 call 250 <atoi> 2d: 89 04 24 mov %eax,(%esp) 30: e8 c3 02 00 00 call 2f8 <kill> for(i=1; i<argc; i++) 35: 39 f3 cmp %esi,%ebx 37: 75 e7 jne 20 <main+0x20> exit(0); 39: c7 04 24 00 00 00 00 movl $0x0,(%esp) 40: e8 83 02 00 00 call 2c8 <exit> printf(2, "usage: kill pid...\n"); 45: c7 44 24 04 a8 07 00 movl $0x7a8,0x4(%esp) 4c: 00 4d: c7 04 24 02 00 00 00 movl $0x2,(%esp) 54: e8 d7 03 00 00 call 430 <printf> exit(0); 59: c7 04 24 00 00 00 00 movl $0x0,(%esp) 60: e8 63 02 00 00 call 2c8 <exit> 65: 66 90 xchg %ax,%ax 67: 66 90 xchg %ax,%ax 69: 66 90 xchg %ax,%ax 6b: 66 90 xchg %ax,%ax 6d: 66 90 xchg %ax,%ax 6f: 90 nop 00000070 <strcpy>: #include "fcntl.h" #include "user.h" #include "x86.h" char * strcpy(char *s, const char *t) { 70: 55 push %ebp 71: 89 e5 mov %esp,%ebp 73: 8b 45 08 mov 0x8(%ebp),%eax 76: 8b 4d 0c mov 0xc(%ebp),%ecx 79: 53 push %ebx char *os; os = s; while ((*s++ = *t++) != 0); 7a: 89 c2 mov %eax,%edx 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80: 41 inc %ecx 81: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 85: 42 inc %edx 86: 84 db test %bl,%bl 88: 88 5a ff mov %bl,-0x1(%edx) 8b: 75 f3 jne 80 <strcpy+0x10> return os; } 8d: 5b pop %ebx 8e: 5d pop %ebp 8f: c3 ret 00000090 <strncpy>: char* strncpy(char *s, const char *t, int n) { 90: 55 push %ebp char *os; os = s; while((n--) > 0 && ((*s++ = *t++) != 0)); 91: 31 d2 xor %edx,%edx { 93: 89 e5 mov %esp,%ebp 95: 56 push %esi 96: 8b 45 08 mov 0x8(%ebp),%eax 99: 53 push %ebx 9a: 8b 75 0c mov 0xc(%ebp),%esi 9d: 8b 5d 10 mov 0x10(%ebp),%ebx while((n--) > 0 && ((*s++ = *t++) != 0)); a0: eb 12 jmp b4 <strncpy+0x24> a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi a8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx ac: 88 0c 10 mov %cl,(%eax,%edx,1) af: 42 inc %edx b0: 84 c9 test %cl,%cl b2: 74 08 je bc <strncpy+0x2c> b4: 89 d9 mov %ebx,%ecx b6: 29 d1 sub %edx,%ecx b8: 85 c9 test %ecx,%ecx ba: 7f ec jg a8 <strncpy+0x18> return os; } bc: 5b pop %ebx bd: 5e pop %esi be: 5d pop %ebp bf: c3 ret 000000c0 <strcmp>: int strcmp(const char *p, const char *q) { c0: 55 push %ebp c1: 89 e5 mov %esp,%ebp c3: 8b 4d 08 mov 0x8(%ebp),%ecx c6: 53 push %ebx c7: 8b 5d 0c mov 0xc(%ebp),%ebx while (*p && *p == *q) ca: 0f b6 01 movzbl (%ecx),%eax cd: 0f b6 13 movzbl (%ebx),%edx d0: 84 c0 test %al,%al d2: 75 18 jne ec <strcmp+0x2c> d4: eb 22 jmp f8 <strcmp+0x38> d6: 8d 76 00 lea 0x0(%esi),%esi d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; e0: 41 inc %ecx while (*p && *p == *q) e1: 0f b6 01 movzbl (%ecx),%eax p++, q++; e4: 43 inc %ebx e5: 0f b6 13 movzbl (%ebx),%edx while (*p && *p == *q) e8: 84 c0 test %al,%al ea: 74 0c je f8 <strcmp+0x38> ec: 38 d0 cmp %dl,%al ee: 74 f0 je e0 <strcmp+0x20> return (uchar) *p - (uchar) *q; } f0: 5b pop %ebx return (uchar) *p - (uchar) *q; f1: 29 d0 sub %edx,%eax } f3: 5d pop %ebp f4: c3 ret f5: 8d 76 00 lea 0x0(%esi),%esi f8: 5b pop %ebx f9: 31 c0 xor %eax,%eax return (uchar) *p - (uchar) *q; fb: 29 d0 sub %edx,%eax } fd: 5d pop %ebp fe: c3 ret ff: 90 nop 00000100 <strlen>: uint strlen(const char *s) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for (n = 0; s[n]; n++); 106: 80 39 00 cmpb $0x0,(%ecx) 109: 74 15 je 120 <strlen+0x20> 10b: 31 d2 xor %edx,%edx 10d: 8d 76 00 lea 0x0(%esi),%esi 110: 42 inc %edx 111: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 115: 89 d0 mov %edx,%eax 117: 75 f7 jne 110 <strlen+0x10> return n; } 119: 5d pop %ebp 11a: c3 ret 11b: 90 nop 11c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for (n = 0; s[n]; n++); 120: 31 c0 xor %eax,%eax } 122: 5d pop %ebp 123: c3 ret 124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000130 <memset>: void * memset(void *dst, int c, uint n) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 8b 55 08 mov 0x8(%ebp),%edx 136: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 137: 8b 4d 10 mov 0x10(%ebp),%ecx 13a: 8b 45 0c mov 0xc(%ebp),%eax 13d: 89 d7 mov %edx,%edi 13f: fc cld 140: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 142: 5f pop %edi 143: 89 d0 mov %edx,%eax 145: 5d pop %ebp 146: c3 ret 147: 89 f6 mov %esi,%esi 149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000150 <strchr>: char * strchr(const char *s, char c) { 150: 55 push %ebp 151: 89 e5 mov %esp,%ebp 153: 8b 45 08 mov 0x8(%ebp),%eax 156: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for (; *s; s++) 15a: 0f b6 10 movzbl (%eax),%edx 15d: 84 d2 test %dl,%dl 15f: 74 1b je 17c <strchr+0x2c> if (*s == c) 161: 38 d1 cmp %dl,%cl 163: 75 0f jne 174 <strchr+0x24> 165: eb 17 jmp 17e <strchr+0x2e> 167: 89 f6 mov %esi,%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 170: 38 ca cmp %cl,%dl 172: 74 0a je 17e <strchr+0x2e> for (; *s; s++) 174: 40 inc %eax 175: 0f b6 10 movzbl (%eax),%edx 178: 84 d2 test %dl,%dl 17a: 75 f4 jne 170 <strchr+0x20> return (char *) s; return 0; 17c: 31 c0 xor %eax,%eax } 17e: 5d pop %ebp 17f: c3 ret 00000180 <gets>: char * gets(char *buf, int max) { 180: 55 push %ebp 181: 89 e5 mov %esp,%ebp 183: 57 push %edi 184: 56 push %esi int i, cc; char c; for (i = 0; i + 1 < max;) { 185: 31 f6 xor %esi,%esi gets(char *buf, int max) { 187: 53 push %ebx 188: 83 ec 3c sub $0x3c,%esp 18b: 8b 5d 08 mov 0x8(%ebp),%ebx cc = read(0, &c, 1); 18e: 8d 7d e7 lea -0x19(%ebp),%edi for (i = 0; i + 1 < max;) { 191: eb 32 jmp 1c5 <gets+0x45> 193: 90 nop 194: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cc = read(0, &c, 1); 198: ba 01 00 00 00 mov $0x1,%edx 19d: 89 54 24 08 mov %edx,0x8(%esp) 1a1: 89 7c 24 04 mov %edi,0x4(%esp) 1a5: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1ac: e8 2f 01 00 00 call 2e0 <read> if (cc < 1) 1b1: 85 c0 test %eax,%eax 1b3: 7e 19 jle 1ce <gets+0x4e> break; buf[i++] = c; 1b5: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1b9: 43 inc %ebx 1ba: 88 43 ff mov %al,-0x1(%ebx) if (c == '\n' || c == '\r') 1bd: 3c 0a cmp $0xa,%al 1bf: 74 1f je 1e0 <gets+0x60> 1c1: 3c 0d cmp $0xd,%al 1c3: 74 1b je 1e0 <gets+0x60> for (i = 0; i + 1 < max;) { 1c5: 46 inc %esi 1c6: 3b 75 0c cmp 0xc(%ebp),%esi 1c9: 89 5d d4 mov %ebx,-0x2c(%ebp) 1cc: 7c ca jl 198 <gets+0x18> break; } buf[i] = '\0'; 1ce: 8b 45 d4 mov -0x2c(%ebp),%eax 1d1: c6 00 00 movb $0x0,(%eax) return buf; } 1d4: 8b 45 08 mov 0x8(%ebp),%eax 1d7: 83 c4 3c add $0x3c,%esp 1da: 5b pop %ebx 1db: 5e pop %esi 1dc: 5f pop %edi 1dd: 5d pop %ebp 1de: c3 ret 1df: 90 nop 1e0: 8b 45 08 mov 0x8(%ebp),%eax 1e3: 01 c6 add %eax,%esi 1e5: 89 75 d4 mov %esi,-0x2c(%ebp) 1e8: eb e4 jmp 1ce <gets+0x4e> 1ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000001f0 <stat>: int stat(const char *n, struct stat *st) { 1f0: 55 push %ebp int fd; int r; fd = open(n, O_RDONLY); 1f1: 31 c0 xor %eax,%eax stat(const char *n, struct stat *st) { 1f3: 89 e5 mov %esp,%ebp 1f5: 83 ec 18 sub $0x18,%esp fd = open(n, O_RDONLY); 1f8: 89 44 24 04 mov %eax,0x4(%esp) 1fc: 8b 45 08 mov 0x8(%ebp),%eax stat(const char *n, struct stat *st) { 1ff: 89 5d f8 mov %ebx,-0x8(%ebp) 202: 89 75 fc mov %esi,-0x4(%ebp) fd = open(n, O_RDONLY); 205: 89 04 24 mov %eax,(%esp) 208: e8 fb 00 00 00 call 308 <open> if (fd < 0) 20d: 85 c0 test %eax,%eax 20f: 78 2f js 240 <stat+0x50> 211: 89 c3 mov %eax,%ebx return -1; r = fstat(fd, st); 213: 8b 45 0c mov 0xc(%ebp),%eax 216: 89 1c 24 mov %ebx,(%esp) 219: 89 44 24 04 mov %eax,0x4(%esp) 21d: e8 fe 00 00 00 call 320 <fstat> close(fd); 222: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 225: 89 c6 mov %eax,%esi close(fd); 227: e8 c4 00 00 00 call 2f0 <close> return r; } 22c: 89 f0 mov %esi,%eax 22e: 8b 5d f8 mov -0x8(%ebp),%ebx 231: 8b 75 fc mov -0x4(%ebp),%esi 234: 89 ec mov %ebp,%esp 236: 5d pop %ebp 237: c3 ret 238: 90 nop 239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 240: be ff ff ff ff mov $0xffffffff,%esi 245: eb e5 jmp 22c <stat+0x3c> 247: 89 f6 mov %esi,%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <atoi>: int atoi(const char *s) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 8b 4d 08 mov 0x8(%ebp),%ecx 256: 53 push %ebx int n; n = 0; while ('0' <= *s && *s <= '9') 257: 0f be 11 movsbl (%ecx),%edx 25a: 88 d0 mov %dl,%al 25c: 2c 30 sub $0x30,%al 25e: 3c 09 cmp $0x9,%al n = 0; 260: b8 00 00 00 00 mov $0x0,%eax while ('0' <= *s && *s <= '9') 265: 77 1e ja 285 <atoi+0x35> 267: 89 f6 mov %esi,%esi 269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n * 10 + *s++ - '0'; 270: 41 inc %ecx 271: 8d 04 80 lea (%eax,%eax,4),%eax 274: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while ('0' <= *s && *s <= '9') 278: 0f be 11 movsbl (%ecx),%edx 27b: 88 d3 mov %dl,%bl 27d: 80 eb 30 sub $0x30,%bl 280: 80 fb 09 cmp $0x9,%bl 283: 76 eb jbe 270 <atoi+0x20> return n; } 285: 5b pop %ebx 286: 5d pop %ebp 287: c3 ret 288: 90 nop 289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000290 <memmove>: void * memmove(void *vdst, const void *vsrc, int n) { 290: 55 push %ebp 291: 89 e5 mov %esp,%ebp 293: 56 push %esi 294: 8b 45 08 mov 0x8(%ebp),%eax 297: 53 push %ebx 298: 8b 5d 10 mov 0x10(%ebp),%ebx 29b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while (n-- > 0) 29e: 85 db test %ebx,%ebx 2a0: 7e 1a jle 2bc <memmove+0x2c> 2a2: 31 d2 xor %edx,%edx 2a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi *dst++ = *src++; 2b0: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 2b4: 88 0c 10 mov %cl,(%eax,%edx,1) 2b7: 42 inc %edx while (n-- > 0) 2b8: 39 d3 cmp %edx,%ebx 2ba: 75 f4 jne 2b0 <memmove+0x20> return vdst; } 2bc: 5b pop %ebx 2bd: 5e pop %esi 2be: 5d pop %ebp 2bf: c3 ret 000002c0 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2c0: b8 01 00 00 00 mov $0x1,%eax 2c5: cd 40 int $0x40 2c7: c3 ret 000002c8 <exit>: SYSCALL(exit) 2c8: b8 02 00 00 00 mov $0x2,%eax 2cd: cd 40 int $0x40 2cf: c3 ret 000002d0 <wait>: SYSCALL(wait) 2d0: b8 03 00 00 00 mov $0x3,%eax 2d5: cd 40 int $0x40 2d7: c3 ret 000002d8 <pipe>: SYSCALL(pipe) 2d8: b8 04 00 00 00 mov $0x4,%eax 2dd: cd 40 int $0x40 2df: c3 ret 000002e0 <read>: SYSCALL(read) 2e0: b8 05 00 00 00 mov $0x5,%eax 2e5: cd 40 int $0x40 2e7: c3 ret 000002e8 <write>: SYSCALL(write) 2e8: b8 10 00 00 00 mov $0x10,%eax 2ed: cd 40 int $0x40 2ef: c3 ret 000002f0 <close>: SYSCALL(close) 2f0: b8 15 00 00 00 mov $0x15,%eax 2f5: cd 40 int $0x40 2f7: c3 ret 000002f8 <kill>: SYSCALL(kill) 2f8: b8 06 00 00 00 mov $0x6,%eax 2fd: cd 40 int $0x40 2ff: c3 ret 00000300 <exec>: SYSCALL(exec) 300: b8 07 00 00 00 mov $0x7,%eax 305: cd 40 int $0x40 307: c3 ret 00000308 <open>: SYSCALL(open) 308: b8 0f 00 00 00 mov $0xf,%eax 30d: cd 40 int $0x40 30f: c3 ret 00000310 <mknod>: SYSCALL(mknod) 310: b8 11 00 00 00 mov $0x11,%eax 315: cd 40 int $0x40 317: c3 ret 00000318 <unlink>: SYSCALL(unlink) 318: b8 12 00 00 00 mov $0x12,%eax 31d: cd 40 int $0x40 31f: c3 ret 00000320 <fstat>: SYSCALL(fstat) 320: b8 08 00 00 00 mov $0x8,%eax 325: cd 40 int $0x40 327: c3 ret 00000328 <link>: SYSCALL(link) 328: b8 13 00 00 00 mov $0x13,%eax 32d: cd 40 int $0x40 32f: c3 ret 00000330 <mkdir>: SYSCALL(mkdir) 330: b8 14 00 00 00 mov $0x14,%eax 335: cd 40 int $0x40 337: c3 ret 00000338 <chdir>: SYSCALL(chdir) 338: b8 09 00 00 00 mov $0x9,%eax 33d: cd 40 int $0x40 33f: c3 ret 00000340 <dup>: SYSCALL(dup) 340: b8 0a 00 00 00 mov $0xa,%eax 345: cd 40 int $0x40 347: c3 ret 00000348 <getpid>: SYSCALL(getpid) 348: b8 0b 00 00 00 mov $0xb,%eax 34d: cd 40 int $0x40 34f: c3 ret 00000350 <sbrk>: SYSCALL(sbrk) 350: b8 0c 00 00 00 mov $0xc,%eax 355: cd 40 int $0x40 357: c3 ret 00000358 <sleep>: SYSCALL(sleep) 358: b8 0d 00 00 00 mov $0xd,%eax 35d: cd 40 int $0x40 35f: c3 ret 00000360 <uptime>: SYSCALL(uptime) 360: b8 0e 00 00 00 mov $0xe,%eax 365: cd 40 int $0x40 367: c3 ret 00000368 <detach>: SYSCALL(detach) 368: b8 16 00 00 00 mov $0x16,%eax 36d: cd 40 int $0x40 36f: c3 ret 00000370 <priority>: SYSCALL(priority) 370: b8 17 00 00 00 mov $0x17,%eax 375: cd 40 int $0x40 377: c3 ret 00000378 <policy>: SYSCALL(policy) 378: b8 18 00 00 00 mov $0x18,%eax 37d: cd 40 int $0x40 37f: c3 ret 00000380 <wait_stat>: SYSCALL(wait_stat) 380: b8 19 00 00 00 mov $0x19,%eax 385: cd 40 int $0x40 387: c3 ret 388: 66 90 xchg %ax,%ax 38a: 66 90 xchg %ax,%ax 38c: 66 90 xchg %ax,%ax 38e: 66 90 xchg %ax,%ax 00000390 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 57 push %edi 394: 56 push %esi 395: 53 push %ebx char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 396: 89 d3 mov %edx,%ebx 398: c1 eb 1f shr $0x1f,%ebx { 39b: 83 ec 4c sub $0x4c,%esp if(sgn && xx < 0){ 39e: 84 db test %bl,%bl { 3a0: 89 45 c0 mov %eax,-0x40(%ebp) 3a3: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 3a5: 74 79 je 420 <printint+0x90> 3a7: f6 45 08 01 testb $0x1,0x8(%ebp) 3ab: 74 73 je 420 <printint+0x90> neg = 1; x = -xx; 3ad: f7 d8 neg %eax neg = 1; 3af: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3b6: 31 f6 xor %esi,%esi 3b8: 8d 5d d7 lea -0x29(%ebp),%ebx 3bb: eb 05 jmp 3c2 <printint+0x32> 3bd: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 3c0: 89 fe mov %edi,%esi 3c2: 31 d2 xor %edx,%edx 3c4: f7 f1 div %ecx 3c6: 8d 7e 01 lea 0x1(%esi),%edi 3c9: 0f b6 92 c4 07 00 00 movzbl 0x7c4(%edx),%edx }while((x /= base) != 0); 3d0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3d2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3d5: 75 e9 jne 3c0 <printint+0x30> if(neg) 3d7: 8b 55 c4 mov -0x3c(%ebp),%edx 3da: 85 d2 test %edx,%edx 3dc: 74 08 je 3e6 <printint+0x56> buf[i++] = '-'; 3de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 3e3: 8d 7e 02 lea 0x2(%esi),%edi 3e6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 3ea: 8b 7d c0 mov -0x40(%ebp),%edi 3ed: 8d 76 00 lea 0x0(%esi),%esi 3f0: 0f b6 06 movzbl (%esi),%eax 3f3: 4e dec %esi write(fd, &c, 1); 3f4: 89 5c 24 04 mov %ebx,0x4(%esp) 3f8: 89 3c 24 mov %edi,(%esp) 3fb: 88 45 d7 mov %al,-0x29(%ebp) 3fe: b8 01 00 00 00 mov $0x1,%eax 403: 89 44 24 08 mov %eax,0x8(%esp) 407: e8 dc fe ff ff call 2e8 <write> while(--i >= 0) 40c: 39 de cmp %ebx,%esi 40e: 75 e0 jne 3f0 <printint+0x60> putc(fd, buf[i]); } 410: 83 c4 4c add $0x4c,%esp 413: 5b pop %ebx 414: 5e pop %esi 415: 5f pop %edi 416: 5d pop %ebp 417: c3 ret 418: 90 nop 419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 420: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 427: eb 8d jmp 3b6 <printint+0x26> 429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000430 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 430: 55 push %ebp 431: 89 e5 mov %esp,%ebp 433: 57 push %edi 434: 56 push %esi 435: 53 push %ebx 436: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 439: 8b 75 0c mov 0xc(%ebp),%esi 43c: 0f b6 1e movzbl (%esi),%ebx 43f: 84 db test %bl,%bl 441: 0f 84 d1 00 00 00 je 518 <printf+0xe8> state = 0; 447: 31 ff xor %edi,%edi 449: 46 inc %esi ap = (uint*)(void*)&fmt + 1; 44a: 8d 45 10 lea 0x10(%ebp),%eax write(fd, &c, 1); 44d: 89 fa mov %edi,%edx 44f: 8b 7d 08 mov 0x8(%ebp),%edi ap = (uint*)(void*)&fmt + 1; 452: 89 45 d0 mov %eax,-0x30(%ebp) 455: eb 41 jmp 498 <printf+0x68> 457: 89 f6 mov %esi,%esi 459: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 460: 83 f8 25 cmp $0x25,%eax 463: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 466: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 46b: 74 1e je 48b <printf+0x5b> write(fd, &c, 1); 46d: b8 01 00 00 00 mov $0x1,%eax 472: 89 44 24 08 mov %eax,0x8(%esp) 476: 8d 45 e2 lea -0x1e(%ebp),%eax 479: 89 44 24 04 mov %eax,0x4(%esp) 47d: 89 3c 24 mov %edi,(%esp) 480: 88 5d e2 mov %bl,-0x1e(%ebp) 483: e8 60 fe ff ff call 2e8 <write> 488: 8b 55 d4 mov -0x2c(%ebp),%edx 48b: 46 inc %esi for(i = 0; fmt[i]; i++){ 48c: 0f b6 5e ff movzbl -0x1(%esi),%ebx 490: 84 db test %bl,%bl 492: 0f 84 80 00 00 00 je 518 <printf+0xe8> if(state == 0){ 498: 85 d2 test %edx,%edx c = fmt[i] & 0xff; 49a: 0f be cb movsbl %bl,%ecx 49d: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 4a0: 74 be je 460 <printf+0x30> } else { putc(fd, c); } } else if(state == '%'){ 4a2: 83 fa 25 cmp $0x25,%edx 4a5: 75 e4 jne 48b <printf+0x5b> if(c == 'd'){ 4a7: 83 f8 64 cmp $0x64,%eax 4aa: 0f 84 f0 00 00 00 je 5a0 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 4b0: 81 e1 f7 00 00 00 and $0xf7,%ecx 4b6: 83 f9 70 cmp $0x70,%ecx 4b9: 74 65 je 520 <printf+0xf0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 4bb: 83 f8 73 cmp $0x73,%eax 4be: 0f 84 8c 00 00 00 je 550 <printf+0x120> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4c4: 83 f8 63 cmp $0x63,%eax 4c7: 0f 84 13 01 00 00 je 5e0 <printf+0x1b0> putc(fd, *ap); ap++; } else if(c == '%'){ 4cd: 83 f8 25 cmp $0x25,%eax 4d0: 0f 84 e2 00 00 00 je 5b8 <printf+0x188> write(fd, &c, 1); 4d6: b8 01 00 00 00 mov $0x1,%eax 4db: 46 inc %esi 4dc: 89 44 24 08 mov %eax,0x8(%esp) 4e0: 8d 45 e7 lea -0x19(%ebp),%eax 4e3: 89 44 24 04 mov %eax,0x4(%esp) 4e7: 89 3c 24 mov %edi,(%esp) 4ea: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4ee: e8 f5 fd ff ff call 2e8 <write> 4f3: ba 01 00 00 00 mov $0x1,%edx 4f8: 8d 45 e6 lea -0x1a(%ebp),%eax 4fb: 89 54 24 08 mov %edx,0x8(%esp) 4ff: 89 44 24 04 mov %eax,0x4(%esp) 503: 89 3c 24 mov %edi,(%esp) 506: 88 5d e6 mov %bl,-0x1a(%ebp) 509: e8 da fd ff ff call 2e8 <write> for(i = 0; fmt[i]; i++){ 50e: 0f b6 5e ff movzbl -0x1(%esi),%ebx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 512: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 514: 84 db test %bl,%bl 516: 75 80 jne 498 <printf+0x68> } } } 518: 83 c4 3c add $0x3c,%esp 51b: 5b pop %ebx 51c: 5e pop %esi 51d: 5f pop %edi 51e: 5d pop %ebp 51f: c3 ret printint(fd, *ap, 16, 0); 520: c7 04 24 00 00 00 00 movl $0x0,(%esp) 527: b9 10 00 00 00 mov $0x10,%ecx 52c: 8b 5d d0 mov -0x30(%ebp),%ebx 52f: 89 f8 mov %edi,%eax 531: 8b 13 mov (%ebx),%edx 533: e8 58 fe ff ff call 390 <printint> ap++; 538: 89 d8 mov %ebx,%eax state = 0; 53a: 31 d2 xor %edx,%edx ap++; 53c: 83 c0 04 add $0x4,%eax 53f: 89 45 d0 mov %eax,-0x30(%ebp) 542: e9 44 ff ff ff jmp 48b <printf+0x5b> 547: 89 f6 mov %esi,%esi 549: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi s = (char*)*ap; 550: 8b 45 d0 mov -0x30(%ebp),%eax 553: 8b 10 mov (%eax),%edx ap++; 555: 83 c0 04 add $0x4,%eax 558: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 55b: 85 d2 test %edx,%edx 55d: 0f 84 aa 00 00 00 je 60d <printf+0x1dd> while(*s != 0){ 563: 0f b6 02 movzbl (%edx),%eax s = (char*)*ap; 566: 89 d3 mov %edx,%ebx while(*s != 0){ 568: 84 c0 test %al,%al 56a: 74 27 je 593 <printf+0x163> 56c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 570: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 573: b8 01 00 00 00 mov $0x1,%eax s++; 578: 43 inc %ebx write(fd, &c, 1); 579: 89 44 24 08 mov %eax,0x8(%esp) 57d: 8d 45 e3 lea -0x1d(%ebp),%eax 580: 89 44 24 04 mov %eax,0x4(%esp) 584: 89 3c 24 mov %edi,(%esp) 587: e8 5c fd ff ff call 2e8 <write> while(*s != 0){ 58c: 0f b6 03 movzbl (%ebx),%eax 58f: 84 c0 test %al,%al 591: 75 dd jne 570 <printf+0x140> state = 0; 593: 31 d2 xor %edx,%edx 595: e9 f1 fe ff ff jmp 48b <printf+0x5b> 59a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 10, 1); 5a0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 5a7: b9 0a 00 00 00 mov $0xa,%ecx 5ac: e9 7b ff ff ff jmp 52c <printf+0xfc> 5b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi write(fd, &c, 1); 5b8: b9 01 00 00 00 mov $0x1,%ecx 5bd: 8d 45 e5 lea -0x1b(%ebp),%eax 5c0: 89 4c 24 08 mov %ecx,0x8(%esp) 5c4: 89 44 24 04 mov %eax,0x4(%esp) 5c8: 89 3c 24 mov %edi,(%esp) 5cb: 88 5d e5 mov %bl,-0x1b(%ebp) 5ce: e8 15 fd ff ff call 2e8 <write> state = 0; 5d3: 31 d2 xor %edx,%edx 5d5: e9 b1 fe ff ff jmp 48b <printf+0x5b> 5da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi putc(fd, *ap); 5e0: 8b 5d d0 mov -0x30(%ebp),%ebx 5e3: 8b 03 mov (%ebx),%eax ap++; 5e5: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 5e8: 89 3c 24 mov %edi,(%esp) putc(fd, *ap); 5eb: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5ee: b8 01 00 00 00 mov $0x1,%eax 5f3: 89 44 24 08 mov %eax,0x8(%esp) 5f7: 8d 45 e4 lea -0x1c(%ebp),%eax 5fa: 89 44 24 04 mov %eax,0x4(%esp) 5fe: e8 e5 fc ff ff call 2e8 <write> state = 0; 603: 31 d2 xor %edx,%edx ap++; 605: 89 5d d0 mov %ebx,-0x30(%ebp) 608: e9 7e fe ff ff jmp 48b <printf+0x5b> s = "(null)"; 60d: bb bc 07 00 00 mov $0x7bc,%ebx while(*s != 0){ 612: b0 28 mov $0x28,%al 614: e9 57 ff ff ff jmp 570 <printf+0x140> 619: 66 90 xchg %ax,%ax 61b: 66 90 xchg %ax,%ax 61d: 66 90 xchg %ax,%ax 61f: 90 nop 00000620 <free>: static Header base; static Header *freep; void free(void *ap) { 620: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 621: a1 7c 0a 00 00 mov 0xa7c,%eax { 626: 89 e5 mov %esp,%ebp 628: 57 push %edi 629: 56 push %esi 62a: 53 push %ebx 62b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 62e: 8d 4b f8 lea -0x8(%ebx),%ecx 631: eb 0d jmp 640 <free+0x20> 633: 90 nop 634: 90 nop 635: 90 nop 636: 90 nop 637: 90 nop 638: 90 nop 639: 90 nop 63a: 90 nop 63b: 90 nop 63c: 90 nop 63d: 90 nop 63e: 90 nop 63f: 90 nop for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 640: 39 c8 cmp %ecx,%eax 642: 8b 10 mov (%eax),%edx 644: 73 32 jae 678 <free+0x58> 646: 39 d1 cmp %edx,%ecx 648: 72 04 jb 64e <free+0x2e> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 64a: 39 d0 cmp %edx,%eax 64c: 72 32 jb 680 <free+0x60> break; if(bp + bp->s.size == p->s.ptr){ 64e: 8b 73 fc mov -0x4(%ebx),%esi 651: 8d 3c f1 lea (%ecx,%esi,8),%edi 654: 39 fa cmp %edi,%edx 656: 74 30 je 688 <free+0x68> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 658: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 65b: 8b 50 04 mov 0x4(%eax),%edx 65e: 8d 34 d0 lea (%eax,%edx,8),%esi 661: 39 f1 cmp %esi,%ecx 663: 74 3c je 6a1 <free+0x81> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 665: 89 08 mov %ecx,(%eax) freep = p; } 667: 5b pop %ebx freep = p; 668: a3 7c 0a 00 00 mov %eax,0xa7c } 66d: 5e pop %esi 66e: 5f pop %edi 66f: 5d pop %ebp 670: c3 ret 671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 678: 39 d0 cmp %edx,%eax 67a: 72 04 jb 680 <free+0x60> 67c: 39 d1 cmp %edx,%ecx 67e: 72 ce jb 64e <free+0x2e> { 680: 89 d0 mov %edx,%eax 682: eb bc jmp 640 <free+0x20> 684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 688: 8b 7a 04 mov 0x4(%edx),%edi 68b: 01 fe add %edi,%esi 68d: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 690: 8b 10 mov (%eax),%edx 692: 8b 12 mov (%edx),%edx 694: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 697: 8b 50 04 mov 0x4(%eax),%edx 69a: 8d 34 d0 lea (%eax,%edx,8),%esi 69d: 39 f1 cmp %esi,%ecx 69f: 75 c4 jne 665 <free+0x45> p->s.size += bp->s.size; 6a1: 8b 4b fc mov -0x4(%ebx),%ecx freep = p; 6a4: a3 7c 0a 00 00 mov %eax,0xa7c p->s.size += bp->s.size; 6a9: 01 ca add %ecx,%edx 6ab: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6ae: 8b 53 f8 mov -0x8(%ebx),%edx 6b1: 89 10 mov %edx,(%eax) } 6b3: 5b pop %ebx 6b4: 5e pop %esi 6b5: 5f pop %edi 6b6: 5d pop %ebp 6b7: c3 ret 6b8: 90 nop 6b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000006c0 <malloc>: return freep; } void* malloc(uint nbytes) { 6c0: 55 push %ebp 6c1: 89 e5 mov %esp,%ebp 6c3: 57 push %edi 6c4: 56 push %esi 6c5: 53 push %ebx 6c6: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6c9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6cc: 8b 15 7c 0a 00 00 mov 0xa7c,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6d2: 8d 78 07 lea 0x7(%eax),%edi 6d5: c1 ef 03 shr $0x3,%edi 6d8: 47 inc %edi if((prevp = freep) == 0){ 6d9: 85 d2 test %edx,%edx 6db: 0f 84 8f 00 00 00 je 770 <malloc+0xb0> 6e1: 8b 02 mov (%edx),%eax 6e3: 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){ 6e6: 39 cf cmp %ecx,%edi 6e8: 76 66 jbe 750 <malloc+0x90> 6ea: 81 ff 00 10 00 00 cmp $0x1000,%edi 6f0: bb 00 10 00 00 mov $0x1000,%ebx 6f5: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6f8: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6ff: eb 10 jmp 711 <malloc+0x51> 701: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 708: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 70a: 8b 48 04 mov 0x4(%eax),%ecx 70d: 39 f9 cmp %edi,%ecx 70f: 73 3f jae 750 <malloc+0x90> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 711: 39 05 7c 0a 00 00 cmp %eax,0xa7c 717: 89 c2 mov %eax,%edx 719: 75 ed jne 708 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 71b: 89 34 24 mov %esi,(%esp) 71e: e8 2d fc ff ff call 350 <sbrk> if(p == (char*)-1) 723: 83 f8 ff cmp $0xffffffff,%eax 726: 74 18 je 740 <malloc+0x80> hp->s.size = nu; 728: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 72b: 83 c0 08 add $0x8,%eax 72e: 89 04 24 mov %eax,(%esp) 731: e8 ea fe ff ff call 620 <free> return freep; 736: 8b 15 7c 0a 00 00 mov 0xa7c,%edx if((p = morecore(nunits)) == 0) 73c: 85 d2 test %edx,%edx 73e: 75 c8 jne 708 <malloc+0x48> return 0; } } 740: 83 c4 1c add $0x1c,%esp return 0; 743: 31 c0 xor %eax,%eax } 745: 5b pop %ebx 746: 5e pop %esi 747: 5f pop %edi 748: 5d pop %ebp 749: c3 ret 74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 750: 39 cf cmp %ecx,%edi 752: 74 4c je 7a0 <malloc+0xe0> p->s.size -= nunits; 754: 29 f9 sub %edi,%ecx 756: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 759: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 75c: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 75f: 89 15 7c 0a 00 00 mov %edx,0xa7c } 765: 83 c4 1c add $0x1c,%esp return (void*)(p + 1); 768: 83 c0 08 add $0x8,%eax } 76b: 5b pop %ebx 76c: 5e pop %esi 76d: 5f pop %edi 76e: 5d pop %ebp 76f: c3 ret base.s.ptr = freep = prevp = &base; 770: b8 80 0a 00 00 mov $0xa80,%eax 775: ba 80 0a 00 00 mov $0xa80,%edx base.s.size = 0; 77a: 31 c9 xor %ecx,%ecx base.s.ptr = freep = prevp = &base; 77c: a3 7c 0a 00 00 mov %eax,0xa7c base.s.size = 0; 781: b8 80 0a 00 00 mov $0xa80,%eax base.s.ptr = freep = prevp = &base; 786: 89 15 80 0a 00 00 mov %edx,0xa80 base.s.size = 0; 78c: 89 0d 84 0a 00 00 mov %ecx,0xa84 792: e9 53 ff ff ff jmp 6ea <malloc+0x2a> 797: 89 f6 mov %esi,%esi 799: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi prevp->s.ptr = p->s.ptr; 7a0: 8b 08 mov (%eax),%ecx 7a2: 89 0a mov %ecx,(%edx) 7a4: eb b9 jmp 75f <malloc+0x9f>
GameAI.asm
sidebog7/ZXWargame
1
1718
; Choose the computer's next move ; Troop is stored at ix ; index number is at c decide_comp_move: ld (ix+troopdata_dir),direction_south push de dcm_choose_random_move: ld d,3 call random_num_btwn_1_d ld (ix+troopdata_order),a cp key_fire jr nz,dcm_after_choose_move ld a,(ix+troopdata_type) cp troop_type_knight jr nz,dcm_choose_random_move dcm_after_choose_move: ld a,(ix+troopdata_order) cp key_move jr nz,dcm_not_chosen_move ld d,2 call random_num_btwn_1_d cp 1 jr nz,dcm_not_chosen_move ld d,4 call random_num_btwn_1_d ld (ix+troopdata_dir), a dcm_not_chosen_move: pop de ret
dependencies/agar/ada-core/agar-core-object.adb
amvb/GUCEF
5
28346
<reponame>amvb/GUCEF with C_String; with Interfaces.C; with Interfaces.C.Strings; package body Agar.Core.Object is package C renames Interfaces.C; package C_Strings renames Interfaces.C.Strings; use type C.int; function New_Object (Parent : in Object_Access_t; Name : in String; Object_Class : in Class_Not_Null_Access_t) return Object_Access_t is Ch_Name : aliased C.char_array := C.To_C (Name); begin return Thin.Object.New_Object (Parent => Parent, Name => C_String.To_C_String (Ch_Name'Unchecked_Access), Object_Class => Object_Class); end New_Object; procedure Attach_To_Named (VFS_Root : in Object_Not_Null_Access_t; Path : in String; Child : in Object_Access_t) is Ch_Path : aliased C.char_array := C.To_C (Path); begin Thin.Object.Attach_To_Named (VFS_Root => VFS_Root, Path => C_String.To_C_String (Ch_Path'Unchecked_Access), Child => Child); end Attach_To_Named; function Find (VFS_Root : in Object_Not_Null_Access_t; Pattern : in String) return Object_Access_t is Ch_Format : aliased C.char_array := C.To_C ("%s"); Ch_Pattern : aliased C.char_array := C.To_C (Pattern); begin return Thin.Object.Find (VFS_Root => VFS_Root, Format => C_String.To_C_String (Ch_Format'Unchecked_Access), Data => C_String.To_C_String (Ch_Pattern'Unchecked_Access)); end Find; function Find_Parent (VFS_Root : in Object_Not_Null_Access_t; Name : in String; Object_Type : in String) return Object_Access_t is Ch_Name : aliased C.char_array := C.To_C (Name); Ch_Object_Type : aliased C.char_array := C.To_C (Object_Type); begin return Thin.Object.Find_Parent (VFS_Root => VFS_Root, Name => C_String.To_C_String (Ch_Name'Unchecked_Access), Object_Type => C_String.To_C_String (Ch_Object_Type'Unchecked_Access)); end Find_Parent; function Find_Child (VFS_Root : in Object_Not_Null_Access_t; Name : in String) return Object_Access_t is Ch_Name : aliased C.char_array := C.To_C (Name); begin return Thin.Object.Find_Child (VFS_Root => VFS_Root, Name => C_String.To_C_String (Ch_Name'Unchecked_Access)); end Find_Child; procedure Copy_Name (Object : in Object_Not_Null_Access_t; Path : out String; Used : out Natural) is Path_Length : constant C.size_t := Path'Length; Ch_Path : aliased C.char_array := (Path_Length => C.nul); Ch_Path_Acc : constant C_Strings.char_array_access := Ch_Path'Unchecked_Access; Result : C.int; Length : C.size_t; begin Result := Thin.Object.Copy_Name (Object => Object, Path => C_String.To_C_Char_Array (Ch_Path_Acc), Size => Ch_Path'Length); if Result = 0 then Length := C_String.Length (C_String.To_C_String (Ch_Path_Acc)); Path (Path'First .. Path'First + Natural (Length)) := C_String.To_String (Item => C_String.To_C_Char_Array (Ch_Path_Acc), Size => Length); Used := Natural (Length); else Path (Path'First) := Character'Val (0); Used := 0; end if; end Copy_Name; procedure Set_Name (Object : in Object_Not_Null_Access_t; Name : in String) is Ch_Format : aliased C.char_array := C.To_C ("%s"); Ch_Name : aliased C.char_array := C.To_C (Name); begin Thin.Object.Set_Name (Object => Object, Format => C_String.To_C_String (Ch_Format'Unchecked_Access), Data => C_String.To_C_String (Ch_Name'Unchecked_Access)); end Set_Name; procedure Register_Namespace (Name : in String; Prefix : in String; URL : in String) is Ch_Name : aliased C.char_array := C.To_C (Name); Ch_Prefix : aliased C.char_array := C.To_C (Prefix); Ch_URL : aliased C.char_array := C.To_C (URL); begin Thin.Object.Register_Namespace (Name => C_String.To_C_String (Ch_Name'Unchecked_Access), Prefix => C_String.To_C_String (Ch_Prefix'Unchecked_Access), URL => C_String.To_C_String (Ch_URL'Unchecked_Access)); end Register_Namespace; procedure Unregister_Namespace (Name : in String) is Ch_Name : aliased C.char_array := C.To_C (Name); begin Thin.Object.Unregister_Namespace (C_String.To_C_String (Ch_Name'Unchecked_Access)); end Unregister_Namespace; function Lookup_Class (Spec : in String) return Class_Access_t is Ch_Spec : aliased C.char_array := C.To_C (Spec); begin return Thin.Object.Lookup_Class (C_String.To_C_String (Ch_Spec'Unchecked_Access)); end Lookup_Class; function Load_Class (Spec : in String) return Class_Access_t is Ch_Spec : aliased C.char_array := C.To_C (Spec); begin return Thin.Object.Load_Class (C_String.To_C_String (Ch_Spec'Unchecked_Access)); end Load_Class; procedure Register_Module_Directory (Path : in String) is Ch_Path : aliased C.char_array := C.To_C (Path); begin Thin.Object.Register_Module_Directory (C_String.To_C_String (Ch_Path'Unchecked_Access)); end Register_Module_Directory; procedure Unregister_Module_Directory (Path : in String) is Ch_Path : aliased C.char_array := C.To_C (Path); begin Thin.Object.Unregister_Module_Directory (C_String.To_C_String (Ch_Path'Unchecked_Access)); end Unregister_Module_Directory; function Is_Of_Class (Object : in Object_Not_Null_Access_t; Pattern : in String) return Boolean is Ch_Pattern : aliased C.char_array := C.To_C (Pattern); begin return 1 = Thin.Object.Is_Of_Class (Object => Object, Pattern => C_String.To_C_String (Ch_Pattern'Unchecked_Access)); end Is_Of_Class; function In_Use (Object : in Object_Not_Null_Access_t) return Boolean is begin return 1 = Thin.Object.In_Use (Object); end In_Use; function Add_Dependency (Object : in Object_Not_Null_Access_t; Dependency : in Object_Not_Null_Access_t; Persistent : in Boolean) return Dependency_Access_t is begin return Thin.Object.Add_Dependency (Object => Object, Dependency => Dependency, Persistent => Boolean'Pos (Persistent)); end Add_Dependency; function Find_Dependency (Object : in Object_Not_Null_Access_t; Index : in Interfaces.Unsigned_32; Pointer : access Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Find_Dependency (Object => Object, Index => Index, Pointer => Pointer); end Find_Dependency; function Load (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Load (Object); end Load; function Load_From_File (Object : in Object_Not_Null_Access_t; File : in String) return Boolean is Ch_File : aliased C.char_array := C.To_C (File); begin return 0 = Thin.Object.Load_From_File (Object => Object, File => C_String.To_C_String (Ch_File'Unchecked_Access)); end Load_From_File; function Load_Data (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Load_Data (Object); end Load_Data; function Load_Data_From_File (Object : in Object_Not_Null_Access_t; File : in String) return Boolean is Ch_File : aliased C.char_array := C.To_C (File); begin return 0 = Thin.Object.Load_Data_From_File (Object => Object, File => C_String.To_C_String (Ch_File'Unchecked_Access)); end Load_Data_From_File; function Load_Generic (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Load_Generic (Object); end Load_Generic; function Load_Generic_From_File (Object : in Object_Not_Null_Access_t; File : in String) return Boolean is Ch_File : aliased C.char_array := C.To_C (File); begin return 0 = Thin.Object.Load_Generic_From_File (Object => Object, File => C_String.To_C_String (Ch_File'Unchecked_Access)); end Load_Generic_From_File; function Save (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Save (Object); end Save; function Save_All (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Save_All (Object); end Save_All; function Save_To_File (Object : in Object_Not_Null_Access_t; File : in String) return Boolean is Ch_File : aliased C.char_array := C.To_C (File); begin return 0 = Thin.Object.Save_To_File (Object => Object, File => C_String.To_C_String (Ch_File'Unchecked_Access)); end Save_To_File; function Serialize (Object : in Object_Not_Null_Access_t; Source : in Data_Source.Data_Source_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Serialize (Object, Source); end Serialize; function Unserialize (Object : in Object_Not_Null_Access_t; Source : in Data_Source.Data_Source_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Unserialize (Object, Source); end Unserialize; function Read_Header (Object : in Object_Not_Null_Access_t; Header : in Object_Header_Access_t) return Boolean is begin return 0 = Thin.Object.Read_Header (Object, Header); end Read_Header; function Page_In (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Page_In (Object); end Page_In; function Page_Out (Object : in Object_Not_Null_Access_t) return Boolean is begin return 0 = Thin.Object.Page_Out (Object); end Page_Out; end Agar.Core.Object;
tools/scitools/conf/understand/ada/ada12/s-vmexta.ads
brucegua/moocos
1
20159
<filename>tools/scitools/conf/understand/ada/ada12/s-vmexta.ads ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V M S _ E X C E P T I O N _ T A B L E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1997-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is usually used only on Alpha/VMS systems in the case -- where there is at least one Import/Export exception present. with System.Standard_Library; package System.VMS_Exception_Table is package SSL renames System.Standard_Library; procedure Register_VMS_Exception (Code : SSL.Exception_Code; E : SSL.Exception_Data_Ptr); -- Register an exception in the hash table mapping with a VMS -- condition code. -- LOTS more comments needed here regarding the entire scheme ??? private function Base_Code_In (Code : SSL.Exception_Code) return SSL.Exception_Code; -- Value of Code with the severity bits masked off function Coded_Exception (X : SSL.Exception_Code) return SSL.Exception_Data_Ptr; -- Given a VMS condition, find and return it's allocated Ada exception -- (called only from init.c). end System.VMS_Exception_Table;
src/main/fragment/mos6502-common/vwum1=_neg_vwum2.asm
jbrandwood/kickc
2
176148
sec lda #0 sbc {m2} sta {m1} lda #0 sbc {m2}+1 sta {m1}+1
Compilation/Projet/test/test.asm
FlorentSimonnot/S6
0
94675
<reponame>FlorentSimonnot/S6 extern printf extern scanf __size___tab__ dq 8 format_ent db "%d", 10, 0 format_long db "%ld", 10, 0 format_sent db "%d\n", 10, 0 section .text global _start _start : call main jmp end main : push rbp mov rbp, rsp push QWORD 0 push QWORD 0 push QWORD 0 push QWORD 0 push QWORD 0 fin_main: pop rbx pop rbx pop rbx pop rbx pop rbx pop rbp ret _end: mov rdi, rax mov rax, 60 syscall